00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
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
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
00058 MMSButtonWidget *newWidget = new MMSButtonWidget(this->rootwindow, className);
00059
00060
00061
00062 newWidget->className = this->className;
00063 newWidget->buttonWidgetClass = this->buttonWidgetClass;
00064 newWidget->myButtonWidgetClass = this->myButtonWidgetClass;
00065
00066
00067 MMSWidget::copyWidget((MMSWidget*)newWidget);
00068
00069 return newWidget;
00070 }
00071
00072 bool MMSButtonWidget::init() {
00073
00074 if (!MMSWidget::init())
00075 return false;
00076
00077 return true;
00078 }
00079
00080 bool MMSButtonWidget::release() {
00081
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
00102 this->surface->lock();
00103
00104
00105 if (MMSWidget::draw(backgroundFilled)) {
00106
00107 updateWindowSurfaceWithSurface(!*backgroundFilled);
00108 }
00109
00110
00111 this->surface->unlock();
00112
00113
00114 return MMSWidget::drawDebug();
00115 }
00116
00117
00118
00119
00120
00121 void MMSButtonWidget::updateFromThemeClass(MMSButtonWidgetClass *themeClass) {
00122 MMSWidget::updateFromThemeClass(&(themeClass->widgetClass));
00123 }
00124
00125
00126
00127