Logo
  • Main Page
  • Related Pages
  • Modules
  • Classes
  • Files

mmsbuttonwidget.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2005-2007 Stefan Schwarzer, Jens Schneider,             *
00003  *                           Matthias Hardt, Guido Madaus                  *
00004  *                                                                         *
00005  *   Copyright (C) 2007-2008 BerLinux Solutions GbR                        *
00006  *                           Stefan Schwarzer & Guido Madaus               *
00007  *                                                                         *
00008  *   Copyright (C) 2009-2013 BerLinux Solutions GmbH                       *
00009  *                                                                         *
00010  *   Authors:                                                              *
00011  *      Stefan Schwarzer   <stefan.schwarzer@diskohq.org>,                 *
00012  *      Matthias Hardt     <matthias.hardt@diskohq.org>,                   *
00013  *      Jens Schneider     <jens.schneider@diskohq.org>,                   *
00014  *      Guido Madaus       <guido.madaus@diskohq.org>,                     *
00015  *      Patrick Helterhoff <patrick.helterhoff@diskohq.org>,               *
00016  *      René Bählkow       <rene.baehlkow@diskohq.org>                     *
00017  *                                                                         *
00018  *   This library is free software; you can redistribute it and/or         *
00019  *   modify it under the terms of the GNU Lesser General Public            *
00020  *   License version 2.1 as published by the Free Software Foundation.     *
00021  *                                                                         *
00022  *   This library is distributed in the hope that it will be useful,       *
00023  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00024  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
00025  *   Lesser General Public License for more details.                       *
00026  *                                                                         *
00027  *   You should have received a copy of the GNU Lesser General Public      *
00028  *   License along with this library; if not, write to the                 *
00029  *   Free Software Foundation, Inc.,                                       *
00030  *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
00031  **************************************************************************/
00032 
00033 #include "mmsgui/mmsbuttonwidget.h"
00034 
00035 MMSButtonWidget::MMSButtonWidget(MMSWindow *root, string className, MMSTheme *theme) : MMSWidget() {
00036     create(root, className, theme);
00037 }
00038 
00039 MMSButtonWidget::~MMSButtonWidget() {
00040 }
00041 
00042 bool MMSButtonWidget::create(MMSWindow *root, string className, MMSTheme *theme) {
00043     this->type = MMSWIDGETTYPE_BUTTON;
00044     this->className = className;
00045 
00046     // init attributes for drawable widgets
00047     this->da = new MMSWIDGET_DRAWABLE_ATTRIBUTES;
00048     if (theme) this->da->theme = theme; else this->da->theme = globalTheme;
00049     this->buttonWidgetClass = this->da->theme->getButtonWidgetClass(className);
00050     this->da->baseWidgetClass = &(this->da->theme->buttonWidgetClass.widgetClass);
00051     if (this->buttonWidgetClass) this->da->widgetClass = &(this->buttonWidgetClass->widgetClass); else this->da->widgetClass = NULL;
00052 
00053     return MMSWidget::create(root, true, false, true, true, true, true, true);
00054 }
00055 
00056 MMSWidget *MMSButtonWidget::copyWidget() {
00057     /* create widget */
00058     MMSButtonWidget *newWidget = new MMSButtonWidget(this->rootwindow, className);
00059 
00060     //copy _only_!!!!!!!! my attributes
00061 
00062     newWidget->className = this->className;
00063     newWidget->buttonWidgetClass = this->buttonWidgetClass;
00064     newWidget->myButtonWidgetClass = this->myButtonWidgetClass;
00065 
00066     /* copy base widget */
00067     MMSWidget::copyWidget((MMSWidget*)newWidget);
00068 
00069     return newWidget;
00070 }
00071 
00072 bool MMSButtonWidget::init() {
00073     // init widget basics
00074     if (!MMSWidget::init())
00075         return false;
00076 
00077     return true;
00078 }
00079 
00080 bool MMSButtonWidget::release() {
00081     // release widget basics
00082     if (!MMSWidget::release())
00083         return false;
00084 
00085     return true;
00086 }
00087 
00088 bool MMSButtonWidget::draw(bool *backgroundFilled) {
00089     bool myBackgroundFilled = false;
00090 
00091     if(!surface)
00092         return false;
00093 
00094     if (backgroundFilled) {
00095         if (this->has_own_surface)
00096             *backgroundFilled = false;
00097     }
00098     else
00099         backgroundFilled = &myBackgroundFilled;
00100 
00101     /* lock */
00102     this->surface->lock();
00103 
00104     /* draw widget basics */
00105     if (MMSWidget::draw(backgroundFilled)) {
00106         /* update window surface with an area of surface */
00107         updateWindowSurfaceWithSurface(!*backgroundFilled);
00108     }
00109 
00110     /* unlock */
00111     this->surface->unlock();
00112 
00113     /* draw widgets debug frame */
00114     return MMSWidget::drawDebug();
00115 }
00116 
00117 /***********************************************/
00118 /* begin of theme access methods (set methods) */
00119 /***********************************************/
00120 
00121 void MMSButtonWidget::updateFromThemeClass(MMSButtonWidgetClass *themeClass) {
00122     MMSWidget::updateFromThemeClass(&(themeClass->widgetClass));
00123 }
00124 
00125 /***********************************************/
00126 /* end of theme access methods                 */
00127 /***********************************************/

Generated by doxygen