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/mmsdialogmanager.h"
00034 #include "mmsgui/mmswindows.h"
00035 #include "mmsgui/mmswidgets.h"
00036 #include "mmsgui/mmscanvasfactory.h"
00037 #include "mmsgui/theme/mmsthememanager.h"
00038 #include <string.h>
00039 #include <algorithm>
00040
00041
00042 #define READ_DM_SPECIFIC_WIDGET_ATTRIBUTES(name, size, min_width, min_height, max_width, max_height) \
00043 case MMSGUI_BASE_ATTR::MMSGUI_BASE_ATTR_IDS_name: \
00044 name = attrval_str; \
00045 break; \
00046 case MMSGUI_BASE_ATTR::MMSGUI_BASE_ATTR_IDS_size: \
00047 size = attrval_str; \
00048 break; \
00049 case MMSGUI_BASE_ATTR::MMSGUI_BASE_ATTR_IDS_min_width: \
00050 min_width = attrval_str; \
00051 break; \
00052 case MMSGUI_BASE_ATTR::MMSGUI_BASE_ATTR_IDS_min_height: \
00053 min_height = attrval_str; \
00054 break; \
00055 case MMSGUI_BASE_ATTR::MMSGUI_BASE_ATTR_IDS_max_width: \
00056 max_width = attrval_str; \
00057 break; \
00058 case MMSGUI_BASE_ATTR::MMSGUI_BASE_ATTR_IDS_max_height: \
00059 max_height = attrval_str; \
00060 break;
00061
00062
00063
00064 #define SET_DM_SPECIFIC_WIDGET_ATTRIBUTES(widget, name, size, min_width, min_height, max_width, max_height) \
00065 if (!name.empty()) { \
00066 widget->setName(name); \
00067 insertNamedWidget(widget); \
00068 } \
00069 if (!size.empty()) { \
00070 if (!widget->setSizeHint(size)) \
00071 throw MMSDialogManagerError(1, "invalid widget size '" + size + "'"); \
00072 } \
00073 if (!min_width.empty()) { \
00074 if (!widget->setMinWidth(min_width)) \
00075 throw MMSDialogManagerError(1, "invalid widget min_width '" + min_width + "'"); \
00076 } \
00077 if (!min_height.empty()) { \
00078 if (!widget->setMinHeight(min_height)) \
00079 throw MMSDialogManagerError(1, "invalid widget min_height '" + min_height + "'"); \
00080 } \
00081 if (!max_width.empty()) { \
00082 if (!widget->setMaxWidth(max_width)) \
00083 throw MMSDialogManagerError(1, "invalid widget max_width '" + max_width + "'"); \
00084 } \
00085 if (!max_height.empty()) { \
00086 if (!widget->setMaxHeight(max_height)) \
00087 throw MMSDialogManagerError(1, "invalid widget max_height '" + max_height + "'"); \
00088 }
00089
00090
00091 MMSDialogManager::MMSDialogManager(bool leave_window) :
00092 leave_window(leave_window),
00093 rootWindow(NULL),
00094 rootWindow_is_mine(true) {
00095 }
00096
00097 MMSDialogManager::MMSDialogManager(MMSWindow *rootWindow) :
00098 leave_window(false),
00099 rootWindow(rootWindow),
00100 rootWindow_is_mine(!rootWindow) {
00101 }
00102
00103 MMSDialogManager::~MMSDialogManager() {
00104 if (!this->leave_window) {
00105
00106 if (this->rootWindow_is_mine) {
00107
00108 if (this->rootWindow)
00109 delete this->rootWindow;
00110 }
00111 else {
00112
00113
00114 for(vector<MMSChildWindow*>::iterator i = this->childWins.begin(); i != this->childWins.end(); ++i) {
00115 delete *i;
00116 }
00117 this->childWins.clear();
00118 }
00119 }
00120 }
00121
00122 bool MMSDialogManager::isLoaded() {
00123 return (this->rootWindow != NULL);
00124 }
00125
00126 void MMSDialogManager::insertNamedWidget(MMSWidget *widget) {
00127 this->namedWidgets.push_back(widget);
00128 }
00129
00130
00131 MMSWidget* MMSDialogManager::findWidget(string name) {
00132 if (this->rootWindow)
00133 return this->rootWindow->findWidget(name);
00134 else
00135 return NULL;
00136 }
00137
00138 MMSWidget* MMSDialogManager::operator[](string name) {
00139 MMSWidget *widget;
00140
00141 if ((widget = findWidget(name)))
00142 return widget;
00143 throw MMSDialogManagerError(1, "widget " + name + " not found");
00144 }
00145
00146
00147
00148 MMSWindow* MMSDialogManager::loadDialog(string filename, MMSTheme *theme) {
00149
00150 if (this->leave_window) {
00151
00152 if (this->rootWindow) {
00153 childWins.clear();
00154 namedWidgets.clear();
00155 description.unsetAll();
00156 this->filename = "";
00157 if (this->rootWindow_is_mine)
00158 this->rootWindow = NULL;
00159 }
00160 }
00161
00162
00163 string tafffilename = filename + ".taff";
00164
00165
00166 if(!file_exist(filename))
00167 if(!file_exist(tafffilename))
00168 throw MMSDialogManagerError(1, "dialog file (" + filename + ") not found");
00169
00170
00171 MMSTaffFile *tafff = new MMSTaffFile(tafffilename, &mmsgui_taff_description,
00172 filename, MMSTAFF_EXTERNAL_TYPE_XML);
00173
00174 if (!tafff)
00175 throw MMSDialogManagerError(1, "could not load dialog file " + filename);
00176
00177 if (!tafff->isLoaded()) {
00178 delete tafff;
00179 throw MMSDialogManagerError(1, "could not load dialog file " + filename);
00180 }
00181
00182
00183 int tagid = tafff->getFirstTag();
00184 if (tagid < 0) {
00185 delete tafff;
00186 throw MMSDialogManagerError(1, "invalid taff file " + tafffilename);
00187 }
00188
00189
00190 if (tagid != MMSGUI_TAGTABLE_TAG_MMSDIALOG) {
00191 DEBUGMSG("MMSGUI", "no valid dialog file: %s", filename.c_str());
00192 return NULL;
00193 }
00194
00195
00196 this->filename = filename;
00197
00198
00199 this->throughDoc(tafff, NULL, this->rootWindow, theme);
00200
00201
00202 delete tafff;
00203
00204 return rootWindow;
00205 }
00206
00207 MMSChildWindow* MMSDialogManager::loadChildDialog(string filename, MMSTheme *theme) {
00208
00209 unsigned int cw_size = childWins.size();
00210
00211
00212 string tafffilename = filename + ".taff";
00213
00214
00215 if(!file_exist(filename))
00216 if(!file_exist(tafffilename))
00217 throw MMSDialogManagerError(1, "dialog file (" + filename + ") not found");
00218
00219
00220 MMSTaffFile *tafff = new MMSTaffFile(tafffilename, &mmsgui_taff_description,
00221 filename, MMSTAFF_EXTERNAL_TYPE_XML);
00222
00223 if (!tafff)
00224 throw MMSDialogManagerError(1, "could not load dialog file " + filename);
00225
00226 if (!tafff->isLoaded()) {
00227 delete tafff;
00228 throw MMSDialogManagerError(1, "could not load dialog file " + filename);
00229 }
00230
00231
00232 int tagid = tafff->getFirstTag();
00233 if (tagid < 0) {
00234 delete tafff;
00235 throw MMSDialogManagerError(1, "invalid taff file " + tafffilename);
00236 }
00237
00238
00239 if (tagid != MMSGUI_TAGTABLE_TAG_MMSDIALOG) {
00240 DEBUGMSG("MMSGUI", "no valid dialog file: %s", filename.c_str());
00241 return NULL;
00242 }
00243
00244
00245
00246 this->throughDoc(tafff, NULL, this->rootWindow, theme);
00247
00248
00249 delete tafff;
00250
00251 if (cw_size < childWins.size())
00252 return childWins.at(cw_size);
00253 else
00254 return NULL;
00255 }
00256
00257 MMSDescriptionClass MMSDialogManager::getDescription() {
00258 return this->description;
00259 }
00260
00261
00262 void MMSDialogManager::throughDoc(MMSTaffFile *tafff, MMSWidget *currentWidget, MMSWindow *rootWindow,
00263 MMSTheme *theme, bool only_first_child) {
00264 vector<string> widgetNames;
00265 string widgetName;
00266 bool loop = true;
00267
00268
00269 while (loop) {
00270 if (only_first_child) loop = false;
00271
00272 bool eof;
00273 int tid = tafff->getNextTag(eof);
00274 if (eof) break;
00275 if (tid < 0) break;
00276
00277 switch (tid) {
00278 case MMSGUI_TAGTABLE_TAG_DESCRIPTION:
00279 getDescriptionValues(tafff, theme);
00280
00281 tafff->getNextTag(eof);
00282 break;
00283 case MMSGUI_TAGTABLE_TAG_MAINWINDOW:
00284 getMainWindowValues(tafff, theme);
00285 break;
00286 case MMSGUI_TAGTABLE_TAG_POPUPWINDOW:
00287 getPopupWindowValues(tafff, theme);
00288 break;
00289 case MMSGUI_TAGTABLE_TAG_ROOTWINDOW:
00290 getRootWindowValues(tafff, theme);
00291 break;
00292 case MMSGUI_TAGTABLE_TAG_CHILDWINDOW:
00293 getChildWindowValues(tafff, rootWindow, theme);
00294 break;
00295 default: {
00296 widgetName="";
00297 switch (tid) {
00298 case MMSGUI_TAGTABLE_TAG_TEMPLATE:
00299 widgetName = getTemplateValues(tafff, currentWidget, rootWindow, theme);
00300 break;
00301 case MMSGUI_TAGTABLE_TAG_VBOXWIDGET:
00302 widgetName = getVBoxValues(tafff, currentWidget, rootWindow, theme);
00303 break;
00304 case MMSGUI_TAGTABLE_TAG_HBOXWIDGET:
00305 widgetName = getHBoxValues(tafff, currentWidget, rootWindow, theme);
00306 break;
00307 case MMSGUI_TAGTABLE_TAG_LABELWIDGET:
00308 widgetName = getLabelValues(tafff, currentWidget, rootWindow, theme);
00309 break;
00310 case MMSGUI_TAGTABLE_TAG_BUTTONWIDGET:
00311 widgetName = getButtonValues(tafff, currentWidget, rootWindow, theme);
00312 break;
00313 case MMSGUI_TAGTABLE_TAG_IMAGEWIDGET:
00314 widgetName = getImageValues(tafff, currentWidget, rootWindow, theme);
00315 break;
00316 case MMSGUI_TAGTABLE_TAG_PROGRESSBARWIDGET:
00317 widgetName = getProgressBarValues(tafff, currentWidget, rootWindow, theme);
00318 break;
00319 case MMSGUI_TAGTABLE_TAG_MENUWIDGET:
00320 widgetName = getMenuValues(tafff, currentWidget, rootWindow, theme);
00321 break;
00322 case MMSGUI_TAGTABLE_TAG_TEXTBOXWIDGET:
00323 widgetName = getTextBoxValues(tafff, currentWidget, rootWindow, theme);
00324 break;
00325 case MMSGUI_TAGTABLE_TAG_ARROWWIDGET:
00326 widgetName = getArrowValues(tafff, currentWidget, rootWindow, theme);
00327 break;
00328 case MMSGUI_TAGTABLE_TAG_SLIDERWIDGET:
00329 widgetName = getSliderValues(tafff, currentWidget, rootWindow, theme);
00330 break;
00331 case MMSGUI_TAGTABLE_TAG_INPUTWIDGET:
00332 widgetName = getInputValues(tafff, currentWidget, rootWindow, theme);
00333 break;
00334 case MMSGUI_TAGTABLE_TAG_CHECKBOXWIDGET:
00335 widgetName = getCheckBoxValues(tafff, currentWidget, rootWindow, theme);
00336 break;
00337 case MMSGUI_TAGTABLE_TAG_GAPWIDGET:
00338 widgetName = getGapValues(tafff, currentWidget, rootWindow, theme);
00339 break;
00340 case MMSGUI_TAGTABLE_TAG_CANVASWIDGET:
00341 widgetName = getCanvasValues(tafff, currentWidget, rootWindow, theme);
00342 break;
00343 }
00344
00345 if(!widgetName.empty()) {
00346
00347 if(find(widgetNames.begin(), widgetNames.end(), widgetName) != widgetNames.end()) {
00348 throw MMSDialogManagerError(1, "duplicate widget name: " + widgetName);
00349 }
00350 widgetNames.push_back(widgetName);
00351 }
00352
00353 }
00354 break;
00355 }
00356 }
00357 }
00358
00359 void MMSDialogManager::getDescriptionValues(MMSTaffFile *tafff, MMSTheme *theme) {
00360
00361 this->description.setAttributesFromTAFF(tafff);
00362 }
00363
00364 void MMSDialogManager::getMainWindowValues(MMSTaffFile *tafff, MMSTheme *theme) {
00365 MMSMainWindowClass themeClass;
00366 string name = "", dx = "", dy = "", width = "", height = "";
00367
00368 if(this->rootWindow)
00369 throw MMSDialogManagerError(1, "found nested windows, new mainwindow rejected");
00370
00371
00372 string themePath = (theme ? theme->getThemePath() : globalTheme->getThemePath());
00373
00374 themeClass.windowClass.border.setAttributesFromTAFF(tafff, NULL, &themePath);
00375 themeClass.windowClass.setAttributesFromTAFF(tafff, &themePath);
00376 themeClass.setAttributesFromTAFF(tafff, &themePath);
00377
00378 if (themeClass.windowClass.getDx(dx))
00379 if (getPixelFromSizeHint(NULL, dx, 10000, 0) == false)
00380 throw MMSDialogManagerError(1, "invalid window dx '" + dx + "'");
00381
00382 if (themeClass.windowClass.getDy(dy))
00383 if (getPixelFromSizeHint(NULL, dy, 10000, 0) == false)
00384 throw MMSDialogManagerError(1, "invalid window dy '" + dy + "'");
00385
00386 if (themeClass.windowClass.getWidth(width))
00387 if (getPixelFromSizeHint(NULL, width, 10000, 0) == false)
00388 throw MMSDialogManagerError(1, "invalid window width '" + width + "'");
00389
00390 if (themeClass.windowClass.getHeight(height))
00391 if (getPixelFromSizeHint(NULL, height, 10000, 0) == false)
00392 throw MMSDialogManagerError(1, "invalid window height '" + height + "'");
00393
00394 bool os;
00395 bool *osp = NULL;
00396 if (themeClass.windowClass.getOwnSurface(os))
00397 osp = &os;
00398 bool bb;
00399 bool *bbp = NULL;
00400 if (themeClass.windowClass.getBackBuffer(bb))
00401 bbp = &bb;
00402
00403 startTAFFScan
00404 {
00405 switch (attrid) {
00406 case MMSGUI_BASE_ATTR::MMSGUI_BASE_ATTR_IDS_name:
00407 name = attrval_str;
00408 break;
00409 }
00410 }
00411 endTAFFScan
00412
00413 MMSALIGNMENT alignment;
00414 if (!themeClass.windowClass.getAlignment(alignment))
00415 alignment = MMSALIGNMENT_NOTSET;
00416
00417 if ((themeClass.windowClass.isDx())||(themeClass.windowClass.isDy()))
00418 this->rootWindow = new MMSMainWindow(themeClass.getClassName(),
00419 dx,
00420 dy,
00421 width,
00422 height,
00423 alignment,
00424 MMSW_NONE,
00425 theme,
00426 osp,
00427 bbp);
00428 else
00429 this->rootWindow = new MMSMainWindow(themeClass.getClassName(),
00430 width,
00431 height,
00432 alignment,
00433 MMSW_NONE,
00434 theme,
00435 osp,
00436 bbp);
00437
00438 this->rootWindow->setName(name);
00439 ((MMSMainWindow*)this->rootWindow)->updateFromThemeClass(&themeClass);
00440
00441 throughDoc(tafff, NULL, this->rootWindow, theme);
00442 }
00443
00444
00445 void MMSDialogManager::getPopupWindowValues(MMSTaffFile *tafff, MMSTheme *theme) {
00446 MMSPopupWindowClass themeClass;
00447 string name = "", dx = "", dy = "", width = "", height = "";
00448
00449 if(this->rootWindow)
00450 throw MMSDialogManagerError(1, "found nested windows, new popupwindow rejected");
00451
00452
00453 string themePath = (theme ? theme->getThemePath() : globalTheme->getThemePath());
00454
00455 themeClass.windowClass.border.setAttributesFromTAFF(tafff, NULL, &themePath);
00456 themeClass.windowClass.setAttributesFromTAFF(tafff, &themePath);
00457 themeClass.setAttributesFromTAFF(tafff, &themePath);
00458
00459 if (themeClass.windowClass.getDx(dx))
00460 if (getPixelFromSizeHint(NULL, dx, 10000, 0) == false)
00461 throw MMSDialogManagerError(1, "invalid window dx '" + dx + "'");
00462
00463 if (themeClass.windowClass.getDy(dy))
00464 if (getPixelFromSizeHint(NULL, dy, 10000, 0) == false)
00465 throw MMSDialogManagerError(1, "invalid window dy '" + dy + "'");
00466
00467 if (themeClass.windowClass.getWidth(width))
00468 if (getPixelFromSizeHint(NULL, width, 10000, 0) == false)
00469 throw MMSDialogManagerError(1, "invalid window width '" + width + "'");
00470
00471 if (themeClass.windowClass.getHeight(height))
00472 if (getPixelFromSizeHint(NULL, height, 10000, 0) == false)
00473 throw MMSDialogManagerError(1, "invalid window height '" + height + "'");
00474
00475 bool os;
00476 bool *osp = NULL;
00477 if (themeClass.windowClass.getOwnSurface(os))
00478 osp = &os;
00479 bool bb;
00480 bool *bbp = NULL;
00481 if (themeClass.windowClass.getBackBuffer(bb))
00482 bbp = &bb;
00483
00484 startTAFFScan
00485 {
00486 switch (attrid) {
00487 case MMSGUI_BASE_ATTR::MMSGUI_BASE_ATTR_IDS_name:
00488 name = attrval_str;
00489 break;
00490 }
00491 }
00492 endTAFFScan
00493
00494 MMSALIGNMENT alignment;
00495 if (!themeClass.windowClass.getAlignment(alignment))
00496 alignment = MMSALIGNMENT_NOTSET;
00497
00498 if ((themeClass.windowClass.isDx())||(themeClass.windowClass.isDy()))
00499 this->rootWindow = new MMSPopupWindow(themeClass.getClassName(),
00500 dx,
00501 dy,
00502 width,
00503 height,
00504 alignment,
00505 MMSW_NONE,
00506 theme,
00507 osp,
00508 bbp,
00509 0);
00510 else
00511 this->rootWindow = new MMSPopupWindow(themeClass.getClassName(),
00512 width,
00513 height,
00514 alignment,
00515 MMSW_NONE,
00516 theme,
00517 osp,
00518 bbp,
00519 0);
00520
00521 this->rootWindow->setName(name);
00522 ((MMSPopupWindow*)this->rootWindow)->updateFromThemeClass(&themeClass);
00523
00524 throughDoc(tafff, NULL, this->rootWindow, theme);
00525 }
00526
00527 void MMSDialogManager::getRootWindowValues(MMSTaffFile *tafff, MMSTheme *theme) {
00528 MMSRootWindowClass themeClass;
00529 string name = "", dx = "", dy = "", width = "", height = "";
00530
00531 if(this->rootWindow)
00532 throw MMSDialogManagerError(1, "found nested windows, new rootwindow rejected");
00533
00534
00535 string themePath = (theme ? theme->getThemePath() : globalTheme->getThemePath());
00536
00537 themeClass.windowClass.border.setAttributesFromTAFF(tafff, NULL, &themePath);
00538 themeClass.windowClass.setAttributesFromTAFF(tafff, &themePath);
00539 themeClass.setAttributesFromTAFF(tafff, &themePath);
00540
00541 if (themeClass.windowClass.getDx(dx))
00542 if (getPixelFromSizeHint(NULL, dx, 10000, 0) == false)
00543 throw MMSDialogManagerError(1, "invalid window dx '" + dx + "'");
00544
00545 if (themeClass.windowClass.getDy(dy))
00546 if (getPixelFromSizeHint(NULL, dy, 10000, 0) == false)
00547 throw MMSDialogManagerError(1, "invalid window dy '" + dy + "'");
00548
00549 if (themeClass.windowClass.getWidth(width))
00550 if (getPixelFromSizeHint(NULL, width, 10000, 0) == false)
00551 throw MMSDialogManagerError(1, "invalid window width '" + width + "'");
00552
00553 if (themeClass.windowClass.getHeight(height))
00554 if (getPixelFromSizeHint(NULL, height, 10000, 0) == false)
00555 throw MMSDialogManagerError(1, "invalid window height '" + height + "'");
00556
00557 bool os;
00558 bool *osp = NULL;
00559 if (themeClass.windowClass.getOwnSurface(os))
00560 osp = &os;
00561 bool bb;
00562 bool *bbp = NULL;
00563 if (themeClass.windowClass.getBackBuffer(bb))
00564 bbp = &bb;
00565
00566 startTAFFScan
00567 {
00568 switch (attrid) {
00569 case MMSGUI_BASE_ATTR::MMSGUI_BASE_ATTR_IDS_name:
00570 name = attrval_str;
00571 break;
00572 }
00573 }
00574 endTAFFScan
00575
00576 MMSALIGNMENT alignment;
00577 if (!themeClass.windowClass.getAlignment(alignment))
00578 alignment = MMSALIGNMENT_NOTSET;
00579
00580 if ((themeClass.windowClass.isDx())||(themeClass.windowClass.isDy()))
00581 this->rootWindow = new MMSRootWindow(themeClass.getClassName(),
00582 dx,
00583 dy,
00584 width,
00585 height,
00586 alignment,
00587 MMSW_NONE,
00588 theme,
00589 osp,
00590 bbp);
00591 else
00592 this->rootWindow = new MMSRootWindow(themeClass.getClassName(),
00593 width,
00594 height,
00595 alignment,
00596 MMSW_NONE,
00597 theme,
00598 osp,
00599 bbp);
00600
00601 this->rootWindow->setName(name);
00602 ((MMSRootWindow*)this->rootWindow)->updateFromThemeClass(&themeClass);
00603
00604 throughDoc(tafff, NULL, this->rootWindow, theme);
00605 }
00606
00607 void MMSDialogManager::getChildWindowValues(MMSTaffFile *tafff, MMSWindow *rootWindow, MMSTheme *theme) {
00608 MMSChildWindowClass themeClass;
00609 MMSChildWindow *childwin;
00610 string name = "", dx = "", dy = "", width = "", height = "";
00611 bool show = false;
00612
00613 if(!rootWindow)
00614 throw MMSDialogManagerError(1, "no parent window found, new childwindow rejected");
00615
00616
00617 string themePath = (theme ? theme->getThemePath() : globalTheme->getThemePath());
00618
00619 themeClass.windowClass.border.setAttributesFromTAFF(tafff, NULL, &themePath);
00620 themeClass.windowClass.setAttributesFromTAFF(tafff, &themePath);
00621 themeClass.setAttributesFromTAFF(tafff, &themePath);
00622
00623 if (themeClass.windowClass.getDx(dx))
00624 if (getPixelFromSizeHint(NULL, dx, 10000, 0) == false)
00625 throw MMSDialogManagerError(1, "invalid window dx '" + dx + "'");
00626
00627 if (themeClass.windowClass.getDy(dy))
00628 if (getPixelFromSizeHint(NULL, dy, 10000, 0) == false)
00629 throw MMSDialogManagerError(1, "invalid window dy '" + dy + "'");
00630
00631 if (themeClass.windowClass.getWidth(width))
00632 if (getPixelFromSizeHint(NULL, width, 10000, 0) == false)
00633 throw MMSDialogManagerError(1, "invalid window width '" + width + "'");
00634
00635 if (themeClass.windowClass.getHeight(height))
00636 if (getPixelFromSizeHint(NULL, height, 10000, 0) == false)
00637 throw MMSDialogManagerError(1, "invalid window height '" + height + "'");
00638
00639 bool os;
00640 bool *osp = NULL;
00641 if (themeClass.windowClass.getOwnSurface(os))
00642 osp = &os;
00643 bool bb;
00644 bool *bbp = NULL;
00645 if (themeClass.windowClass.getBackBuffer(bb))
00646 bbp = &bb;
00647
00648 startTAFFScan
00649 {
00650 switch (attrid) {
00651 case MMSGUI_BASE_ATTR::MMSGUI_BASE_ATTR_IDS_name:
00652 name = attrval_str;
00653 break;
00654 case MMSGUI_BASE_ATTR::MMSGUI_BASE_ATTR_IDS_show:
00655 show = (attrval_int) ? true : false;
00656 break;
00657 }
00658 }
00659 endTAFFScan
00660
00661 MMSALIGNMENT alignment;
00662 if (!themeClass.windowClass.getAlignment(alignment))
00663 alignment = MMSALIGNMENT_NOTSET;
00664
00665 if ((themeClass.windowClass.isDx())||(themeClass.windowClass.isDy()))
00666 childwin = new MMSChildWindow(themeClass.getClassName(),
00667 rootWindow,
00668 dx,
00669 dy,
00670 width,
00671 height,
00672 alignment,
00673 MMSW_NONE,
00674 theme,
00675 osp,
00676 bbp);
00677 else
00678 childwin = new MMSChildWindow(themeClass.getClassName(),
00679 rootWindow,
00680 width,
00681 height,
00682 alignment,
00683 MMSW_NONE,
00684 theme,
00685 osp,
00686 bbp);
00687
00688
00689 if (this->rootWindow == rootWindow)
00690 childWins.push_back(childwin);
00691
00692 childwin->setName(name);
00693 childwin->updateFromThemeClass(&themeClass);
00694
00695 throughDoc(tafff, NULL, childwin, theme);
00696
00697 if (show) childwin->show();
00698 }
00699
00700 string MMSDialogManager::getTemplateValues(MMSTaffFile *tafff, MMSWidget *currentWidget, MMSWindow *rootWindow, MMSTheme *theme) {
00701 MMSTemplateClass themeClass, *templateClass = NULL;
00702 string name, size, min_width, min_height, max_width, max_height;
00703 bool show = false;
00704 MMSTaffFile *tf;
00705 vector<string> widgetNames;
00706
00707
00708 themeClass.setAttributesFromTAFF(tafff);
00709
00710
00711 if (!themeClass.getClassName().empty()) {
00712
00713 if (theme) {
00714 templateClass = theme->getTemplateClass(themeClass.getClassName());
00715 }
00716 else {
00717 templateClass = globalTheme->getTemplateClass(themeClass.getClassName());
00718 }
00719 }
00720
00721 if (templateClass) {
00722
00723 if (!(tf = templateClass->getTAFF()))
00724 templateClass = NULL;
00725 }
00726
00727 if (!templateClass) {
00728
00729 throughDoc(tafff, currentWidget, rootWindow, theme);
00730
00731 return "";
00732 }
00733
00734
00735 startTAFFScan
00736 {
00737 switch (attrid) {
00738
00739 READ_DM_SPECIFIC_WIDGET_ATTRIBUTES(name, size, min_width, min_height, max_width, max_height);
00740
00741 case MMSGUI_BASE_ATTR::MMSGUI_BASE_ATTR_IDS_show:
00742 show = (attrval_int)?true:false;
00743 break;
00744 }
00745 }
00746 endTAFFScan
00747 startTAFFScan_WITHOUT_ID
00748 {
00749 if (memcmp(attrname, "widget.", 7)==0) {
00750
00751 string widgetName = &attrname[7];
00752 int pos = (int)widgetName.find(".");
00753 if (pos > 0) {
00754 widgetName = widgetName.substr(0, pos);
00755
00756
00757 if(find(widgetNames.begin(), widgetNames.end(), widgetName) == widgetNames.end()) {
00758 widgetNames.push_back(widgetName);
00759 }
00760 }
00761 }
00762 }
00763 endTAFFScan_WITHOUT_ID
00764
00765
00766 throughDoc(tf, currentWidget, rootWindow, theme);
00767
00768
00769 MMSWindow *newWindow = (!currentWidget)?rootWindow->getLastWindow():NULL;
00770
00771 if (!newWindow) {
00772
00773 MMSWidget *newWidget = (!currentWidget)?((*rootWindow)[""]):currentWidget->getLastWidget();
00774
00775 if (newWidget) {
00776
00777 SET_DM_SPECIFIC_WIDGET_ATTRIBUTES(newWidget, name, size, min_width, min_height, max_width, max_height);
00778
00779
00780 vector<string>::iterator i;
00781 vector<string>::iterator end = widgetNames.end();
00782 for (i = widgetNames.begin(); i != end; ++i) {
00783 updateTAFFAttributes(tafff, newWidget->findWidget(*i), *i);
00784 }
00785 }
00786 else {
00787 throw MMSDialogManagerError(1, "template error, no widget");
00788 }
00789 }
00790 else {
00791 if (!name.empty()) {
00792
00793 newWindow->setName(name);
00794 }
00795
00796 if (show) {
00797
00798 newWindow->show();
00799 }
00800
00801
00802 vector<string>::iterator i;
00803 vector<string>::iterator end = widgetNames.end();
00804 for (i = widgetNames.begin(); i != end; ++i) {
00805 updateTAFFAttributes(tafff, newWindow->findWidget(*i), *i);
00806 }
00807 }
00808
00809
00810 throughDoc(tafff, currentWidget, rootWindow, theme);
00811
00812
00813 return name;
00814 }
00815
00816
00817 string MMSDialogManager::getVBoxValues(MMSTaffFile *tafff, MMSWidget *currentWidget, MMSWindow *rootWindow, MMSTheme *theme) {
00818 MMSVBoxWidget *vbox;
00819 string name, size, min_width, min_height, max_width, max_height;
00820
00821 startTAFFScan
00822 {
00823 switch (attrid) {
00824
00825 READ_DM_SPECIFIC_WIDGET_ATTRIBUTES(name, size, min_width, min_height, max_width, max_height);
00826 }
00827 }
00828 endTAFFScan
00829
00830 vbox = new MMSVBoxWidget(rootWindow);
00831
00832
00833 SET_DM_SPECIFIC_WIDGET_ATTRIBUTES(vbox, name, size, min_width, min_height, max_width, max_height);
00834
00835 if (currentWidget)
00836 currentWidget->add(vbox);
00837 else
00838 rootWindow->add(vbox);
00839
00840 throughDoc(tafff, vbox, rootWindow, theme);
00841
00842
00843 return name;
00844 }
00845
00846 string MMSDialogManager::getHBoxValues(MMSTaffFile *tafff, MMSWidget *currentWidget, MMSWindow *rootWindow, MMSTheme *theme) {
00847 MMSHBoxWidget *hbox;
00848 string name, size, min_width, min_height, max_width, max_height;
00849
00850 startTAFFScan
00851 {
00852 switch (attrid) {
00853
00854 READ_DM_SPECIFIC_WIDGET_ATTRIBUTES(name, size, min_width, min_height, max_width, max_height);
00855 }
00856 }
00857 endTAFFScan
00858
00859 hbox = new MMSHBoxWidget(rootWindow);
00860
00861
00862 SET_DM_SPECIFIC_WIDGET_ATTRIBUTES(hbox, name, size, min_width, min_height, max_width, max_height);
00863
00864 if (currentWidget)
00865 currentWidget->add(hbox);
00866 else
00867 rootWindow->add(hbox);
00868
00869 throughDoc(tafff, hbox, rootWindow, theme);
00870
00871
00872 return name;
00873 }
00874
00875
00876 string MMSDialogManager::getLabelValues(MMSTaffFile *tafff, MMSWidget *currentWidget, MMSWindow *rootWindow, MMSTheme *theme) {
00877 MMSLabelWidgetClass themeClass;
00878 MMSLabelWidget *label;
00879 string name, size, min_width, min_height, max_width, max_height;
00880
00881
00882 string themePath = (theme ? theme->getThemePath() : globalTheme->getThemePath());
00883
00884
00885 themeClass.widgetClass.border.setAttributesFromTAFF(tafff, NULL, &themePath);
00886 themeClass.widgetClass.setAttributesFromTAFF(tafff, NULL, &themePath);
00887 themeClass.setAttributesFromTAFF(tafff, NULL, &themePath);
00888
00889
00890 label = new MMSLabelWidget(rootWindow, themeClass.getClassName(), theme);
00891
00892
00893 label->updateFromThemeClass(&themeClass);
00894
00895
00896 startTAFFScan
00897 {
00898 switch (attrid) {
00899
00900 READ_DM_SPECIFIC_WIDGET_ATTRIBUTES(name, size, min_width, min_height, max_width, max_height);
00901 }
00902 }
00903 endTAFFScan
00904
00905
00906 SET_DM_SPECIFIC_WIDGET_ATTRIBUTES(label, name, size, min_width, min_height, max_width, max_height);
00907
00908 if (currentWidget)
00909 currentWidget->add(label);
00910 else
00911 rootWindow->add(label);
00912
00913 throughDoc(tafff, label, rootWindow, theme);
00914
00915
00916 return name;
00917 }
00918
00919
00920
00921 string MMSDialogManager::getButtonValues(MMSTaffFile *tafff, MMSWidget *currentWidget, MMSWindow *rootWindow, MMSTheme *theme) {
00922 MMSButtonWidgetClass themeClass;
00923 MMSButtonWidget *button;
00924 string name, size, min_width, min_height, max_width, max_height;
00925
00926
00927 string themePath = (theme ? theme->getThemePath() : globalTheme->getThemePath());
00928
00929
00930 themeClass.widgetClass.border.setAttributesFromTAFF(tafff, NULL, &themePath);
00931 themeClass.widgetClass.setAttributesFromTAFF(tafff, NULL, &themePath);
00932 themeClass.setAttributesFromTAFF(tafff, NULL, &themePath);
00933
00934
00935 button = new MMSButtonWidget(rootWindow, themeClass.getClassName(), theme);
00936
00937
00938 button->updateFromThemeClass(&themeClass);
00939
00940
00941 startTAFFScan
00942 {
00943 switch (attrid) {
00944
00945 READ_DM_SPECIFIC_WIDGET_ATTRIBUTES(name, size, min_width, min_height, max_width, max_height);
00946 }
00947 }
00948 endTAFFScan
00949
00950
00951 SET_DM_SPECIFIC_WIDGET_ATTRIBUTES(button, name, size, min_width, min_height, max_width, max_height);
00952
00953 if (currentWidget)
00954 currentWidget->add(button);
00955 else
00956 rootWindow->add(button);
00957
00958 throughDoc(tafff, button, rootWindow, theme);
00959
00960
00961 return name;
00962 }
00963
00964 string MMSDialogManager::getCanvasValues(MMSTaffFile *tafff, MMSWidget *currentWidget, MMSWindow *rootWindow, MMSTheme *theme) {
00965 MMSCanvasWidgetClass themeClass;
00966 MMSCanvasWidget *canvas;
00967 string name, size, min_width, min_height, max_width, max_height, factoryname;
00968
00969
00970 string themePath = (theme ? theme->getThemePath() : globalTheme->getThemePath());
00971
00972
00973 themeClass.widgetClass.border.setAttributesFromTAFF(tafff, NULL, &themePath);
00974 themeClass.widgetClass.setAttributesFromTAFF(tafff, NULL, &themePath);
00975 themeClass.setAttributesFromTAFF(tafff, NULL, &themePath);
00976
00977
00978 themeClass.widgetClass.getFactoryName(factoryname);
00979
00980 if(factoryname.empty()) {
00981 throw MMSDialogManagerError(1, "canvas without factoryname is not allowed!");
00982 }
00983
00984 MMSCanvasFactory factory;
00985 canvas = factory.constructCanvas(factoryname.c_str(), rootWindow, themeClass.getClassName(), theme);
00986
00987 if(!canvas) {
00988 throw MMSDialogManagerError(1, "canvas with factoryname = '" + factoryname + "' is not registered!");
00989 }
00990
00991
00992 canvas->updateFromThemeClass(canvas->canvasWidgetClass);
00993
00994
00995 canvas->updateFromThemeClass(&themeClass);
00996
00997
00998 startTAFFScan
00999 {
01000 switch (attrid) {
01001
01002 READ_DM_SPECIFIC_WIDGET_ATTRIBUTES(name, size, min_width, min_height, max_width, max_height);
01003 }
01004 }
01005 endTAFFScan
01006
01007
01008 SET_DM_SPECIFIC_WIDGET_ATTRIBUTES(canvas, name, size, min_width, min_height, max_width, max_height);
01009
01010
01011 if (currentWidget)
01012 currentWidget->add(canvas);
01013 else
01014 rootWindow->add(canvas);
01015
01016 throughDoc(tafff, canvas, rootWindow, theme);
01017
01018
01019 return name;
01020 }
01021
01022 string MMSDialogManager::getImageValues(MMSTaffFile *tafff, MMSWidget *currentWidget, MMSWindow *rootWindow, MMSTheme *theme) {
01023 MMSImageWidgetClass themeClass;
01024 MMSImageWidget *image;
01025 string name, size, min_width, min_height, max_width, max_height;
01026
01027
01028 string themePath = (theme ? theme->getThemePath() : globalTheme->getThemePath());
01029
01030
01031 themeClass.widgetClass.border.setAttributesFromTAFF(tafff, NULL, &themePath);
01032 themeClass.widgetClass.setAttributesFromTAFF(tafff, NULL, &themePath);
01033 themeClass.setAttributesFromTAFF(tafff, NULL, &themePath);
01034
01035
01036 image = new MMSImageWidget(rootWindow, themeClass.getClassName(), theme);
01037
01038
01039 image->updateFromThemeClass(&themeClass);
01040
01041
01042 startTAFFScan
01043 {
01044 switch (attrid) {
01045
01046 READ_DM_SPECIFIC_WIDGET_ATTRIBUTES(name, size, min_width, min_height, max_width, max_height);
01047 }
01048 }
01049 endTAFFScan
01050
01051
01052 SET_DM_SPECIFIC_WIDGET_ATTRIBUTES(image, name, size, min_width, min_height, max_width, max_height);
01053
01054 if (currentWidget)
01055 currentWidget->add(image);
01056 else
01057 rootWindow->add(image);
01058
01059 throughDoc(tafff, image, rootWindow, theme);
01060
01061
01062 return name;
01063 }
01064
01065
01066 string MMSDialogManager::getProgressBarValues(MMSTaffFile *tafff, MMSWidget *currentWidget, MMSWindow *rootWindow, MMSTheme *theme) {
01067 MMSProgressBarWidgetClass themeClass;
01068 MMSProgressBarWidget *pBar;
01069 string name, size, min_width, min_height, max_width, max_height;
01070
01071
01072 string themePath = (theme ? theme->getThemePath() : globalTheme->getThemePath());
01073
01074
01075 themeClass.widgetClass.border.setAttributesFromTAFF(tafff, NULL, &themePath);
01076 themeClass.widgetClass.setAttributesFromTAFF(tafff, NULL, &themePath);
01077 themeClass.setAttributesFromTAFF(tafff, NULL, &themePath);
01078
01079
01080 pBar = new MMSProgressBarWidget(rootWindow, themeClass.getClassName(), theme);
01081
01082
01083 pBar->updateFromThemeClass(&themeClass);
01084
01085
01086 startTAFFScan
01087 {
01088 switch (attrid) {
01089
01090 READ_DM_SPECIFIC_WIDGET_ATTRIBUTES(name, size, min_width, min_height, max_width, max_height);
01091 }
01092 }
01093 endTAFFScan
01094
01095
01096 SET_DM_SPECIFIC_WIDGET_ATTRIBUTES(pBar, name, size, min_width, min_height, max_width, max_height);
01097
01098 if (currentWidget)
01099 currentWidget->add(pBar);
01100 else
01101 rootWindow->add(pBar);
01102
01103 throughDoc(tafff, pBar, rootWindow, theme);
01104
01105
01106 return name;
01107 }
01108
01109
01110 string MMSDialogManager::getMenuValues(MMSTaffFile *tafff, MMSWidget *currentWidget, MMSWindow *rootWindow, MMSTheme *theme) {
01111 MMSMenuWidgetClass themeClass;
01112 MMSMenuWidget *menu;
01113 string name, size, min_width, min_height, max_width, max_height;
01114 MMSTaffFile *tf;
01115
01116
01117 string themePath = (theme ? theme->getThemePath() : globalTheme->getThemePath());
01118
01119
01120 themeClass.widgetClass.border.setAttributesFromTAFF(tafff, NULL, &themePath);
01121 themeClass.widgetClass.setAttributesFromTAFF(tafff, NULL, &themePath);
01122 themeClass.setAttributesFromTAFF(tafff, NULL, &themePath);
01123
01124
01125 menu = new MMSMenuWidget(rootWindow, themeClass.getClassName(), theme);
01126
01127
01128 menu->updateFromThemeClass(&themeClass);
01129
01130
01131 startTAFFScan
01132 {
01133 switch (attrid) {
01134
01135 READ_DM_SPECIFIC_WIDGET_ATTRIBUTES(name, size, min_width, min_height, max_width, max_height);
01136 }
01137 }
01138 endTAFFScan
01139
01140
01141 SET_DM_SPECIFIC_WIDGET_ATTRIBUTES(menu, name, size, min_width, min_height, max_width, max_height);
01142
01143 if (currentWidget)
01144 currentWidget->add(menu);
01145 else
01146 rootWindow->add(menu);
01147
01148
01149 MMSHBoxWidget *tmpWidget = new MMSHBoxWidget(NULL);
01150
01151
01152 if ((tf = menu->getTAFF())) {
01153
01154 throughDoc(tf, tmpWidget, NULL, theme);
01155 }
01156 else {
01157
01158 throughDoc(tafff, tmpWidget, NULL, theme, true);
01159 }
01160
01161 bool haveItemTemplate = false;
01162 MMSWidget *itemTemplate = tmpWidget->disconnectChild();
01163 if (itemTemplate) {
01164 menu->setItemTemplate(itemTemplate);
01165 haveItemTemplate = true;
01166 }
01167 else {
01168 if (tf) {
01169
01170 throughDoc(tafff, tmpWidget, NULL, theme);
01171 MMSWidget *itemTemplate = tmpWidget->disconnectChild();
01172 if (itemTemplate) {
01173 menu->setItemTemplate(itemTemplate);
01174 haveItemTemplate = true;
01175 }
01176 }
01177 }
01178
01179 delete tmpWidget;
01180
01181 if (haveItemTemplate) {
01182
01183 bool haveItems = false;
01184 bool returntag = true;
01185
01186
01187 while (1) {
01188 bool eof;
01189 int tid = tafff->getNextTag(eof);
01190 if (eof) break;
01191 if (tid < 0) {
01192 if (returntag) break;
01193 returntag = true;
01194 continue;
01195 }
01196 else
01197 returntag = false;
01198
01199
01200 if (tid == MMSGUI_TAGTABLE_TAG_MENUITEM)
01201 {
01202
01203 MMSWidget *item = NULL;
01204 haveItems = true;
01205
01206 if (tafff->hasAttributes()) {
01207
01208
01209 item = menu->newItem();
01210
01211
01212 vector<string> wgs;
01213 bool wg_break = false;
01214 while (!wg_break) {
01215 wg_break = true;
01216 startTAFFScan_WITHOUT_ID
01217 {
01218 if (memcmp(attrname, "widget.", 7)==0) {
01219
01220 string widgetName = &attrname[7];
01221 int pos = (int)widgetName.find(".");
01222 if (pos > 0) {
01223
01224 widgetName = widgetName.substr(0, pos);
01225
01226
01227 if(find(wgs.begin(), wgs.end(), widgetName) != wgs.end()) {
01228 widgetName = "";
01229 continue;
01230 }
01231 wg_break = false;
01232 wgs.push_back(widgetName);
01233
01234
01235 MMSWidget *widget;
01236 if (item->getName() == widgetName) {
01237 widget = item;
01238 }else {
01239 widget = item->findWidget(widgetName);
01240 }
01241
01242 updateTAFFAttributes(tafff, widget, widgetName);
01243 }
01244 }
01245 }
01246 endTAFFScan_WITHOUT_ID
01247 }
01248
01249 startTAFFScan_WITHOUT_ID
01250 {
01251 if (memcmp(attrname, "childwindow", 11)==0) {
01252
01253 menu->setSubMenuName(menu->getSize()-1, attrval_str);
01254 }
01255 else
01256 if (memcmp(attrname, "goback", 6)==0) {
01257
01258
01259 if (memcmp(attrval_str, "true", 4)==0)
01260 menu->setBackItem(menu->getSize()-1);
01261 }
01262 }
01263 endTAFFScan_WITHOUT_ID
01264
01265 startTAFFScan
01266 {
01267 switch (attrid) {
01268 case MMSGUI_BASE_ATTR::MMSGUI_BASE_ATTR_IDS_name:
01269 if (*attrval_str)
01270 item->setName(attrval_str);
01271 break;
01272 }
01273 }
01274 endTAFFScan
01275 }
01276 else {
01277
01278
01279 MMSHBoxWidget *tmpWidget = new MMSHBoxWidget(NULL);
01280
01281
01282 throughDoc(tafff, tmpWidget, NULL, theme);
01283 returntag = true;
01284
01285
01286 item = menu->newItem(-1, tmpWidget->disconnectChild());
01287
01288
01289 delete tmpWidget;
01290 }
01291 }
01292 else {
01293
01294 printf("Warning: Tag <%s/> is not supported within <menu/>.\n", tafff->getCurrentTagName());
01295
01296
01297 MMSHBoxWidget *tmpWidget = new MMSHBoxWidget(NULL);
01298
01299
01300 throughDoc(tafff, tmpWidget, NULL, theme);
01301 returntag = true;
01302
01303
01304 delete tmpWidget;
01305 }
01306 }
01307
01308 if (haveItems)
01309 menu->setFocus(false, false);
01310 }
01311
01312
01313 return name;
01314 }
01315
01316
01317 string MMSDialogManager::getTextBoxValues(MMSTaffFile *tafff, MMSWidget *currentWidget, MMSWindow *rootWindow, MMSTheme *theme) {
01318 MMSTextBoxWidgetClass themeClass;
01319 MMSTextBoxWidget *textbox;
01320 string name, size, min_width, min_height, max_width, max_height;
01321
01322
01323 string themePath = (theme ? theme->getThemePath() : globalTheme->getThemePath());
01324
01325
01326 themeClass.widgetClass.border.setAttributesFromTAFF(tafff, NULL, &themePath);
01327 themeClass.widgetClass.setAttributesFromTAFF(tafff, NULL, &themePath);
01328 themeClass.setAttributesFromTAFF(tafff, NULL, &themePath);
01329
01330
01331 textbox = new MMSTextBoxWidget(rootWindow, themeClass.getClassName(), theme);
01332
01333
01334 textbox->updateFromThemeClass(&themeClass);
01335
01336
01337 startTAFFScan
01338 {
01339 switch (attrid) {
01340
01341 READ_DM_SPECIFIC_WIDGET_ATTRIBUTES(name, size, min_width, min_height, max_width, max_height);
01342 }
01343 }
01344 endTAFFScan
01345
01346
01347 SET_DM_SPECIFIC_WIDGET_ATTRIBUTES(textbox, name, size, min_width, min_height, max_width, max_height);
01348
01349 if (currentWidget)
01350 currentWidget->add(textbox);
01351 else
01352 rootWindow->add(textbox);
01353
01354 throughDoc(tafff, textbox, rootWindow, theme);
01355
01356
01357 return name;
01358 }
01359
01360 string MMSDialogManager::getArrowValues(MMSTaffFile *tafff, MMSWidget *currentWidget, MMSWindow *rootWindow, MMSTheme *theme) {
01361 MMSArrowWidgetClass themeClass;
01362 MMSArrowWidget *arrow;
01363 string name, size, min_width, min_height, max_width, max_height;
01364
01365
01366 string themePath = (theme ? theme->getThemePath() : globalTheme->getThemePath());
01367
01368
01369 themeClass.widgetClass.border.setAttributesFromTAFF(tafff, NULL, &themePath);
01370 themeClass.widgetClass.setAttributesFromTAFF(tafff, NULL, &themePath);
01371 themeClass.setAttributesFromTAFF(tafff, NULL, &themePath);
01372
01373
01374 arrow = new MMSArrowWidget(rootWindow, themeClass.getClassName(), theme);
01375
01376
01377 arrow->updateFromThemeClass(&themeClass);
01378
01379
01380 startTAFFScan
01381 {
01382 switch (attrid) {
01383
01384 READ_DM_SPECIFIC_WIDGET_ATTRIBUTES(name, size, min_width, min_height, max_width, max_height);
01385 }
01386 }
01387 endTAFFScan
01388
01389
01390 SET_DM_SPECIFIC_WIDGET_ATTRIBUTES(arrow, name, size, min_width, min_height, max_width, max_height);
01391
01392 if (currentWidget)
01393 currentWidget->add(arrow);
01394 else
01395 rootWindow->add(arrow);
01396
01397 throughDoc(tafff, arrow, rootWindow, theme);
01398
01399
01400 return name;
01401 }
01402
01403 string MMSDialogManager::getSliderValues(MMSTaffFile *tafff, MMSWidget *currentWidget, MMSWindow *rootWindow, MMSTheme *theme) {
01404 MMSSliderWidgetClass themeClass;
01405 MMSSliderWidget *slider;
01406 string name, size, min_width, min_height, max_width, max_height;
01407
01408
01409 string themePath = (theme ? theme->getThemePath() : globalTheme->getThemePath());
01410
01411
01412 themeClass.widgetClass.border.setAttributesFromTAFF(tafff, NULL, &themePath);
01413 themeClass.widgetClass.setAttributesFromTAFF(tafff, NULL, &themePath);
01414 themeClass.setAttributesFromTAFF(tafff, NULL, &themePath);
01415
01416
01417 slider = new MMSSliderWidget(rootWindow, themeClass.getClassName(), theme);
01418
01419
01420 slider->updateFromThemeClass(&themeClass);
01421
01422
01423 startTAFFScan
01424 {
01425 switch (attrid) {
01426
01427 READ_DM_SPECIFIC_WIDGET_ATTRIBUTES(name, size, min_width, min_height, max_width, max_height);
01428 }
01429 }
01430 endTAFFScan
01431
01432
01433 SET_DM_SPECIFIC_WIDGET_ATTRIBUTES(slider, name, size, min_width, min_height, max_width, max_height);
01434
01435 if (currentWidget)
01436 currentWidget->add(slider);
01437 else
01438 rootWindow->add(slider);
01439
01440 throughDoc(tafff, slider, rootWindow, theme);
01441
01442
01443 return name;
01444 }
01445
01446 string MMSDialogManager::getInputValues(MMSTaffFile *tafff, MMSWidget *currentWidget, MMSWindow *rootWindow, MMSTheme *theme) {
01447 MMSInputWidgetClass themeClass;
01448 MMSInputWidget *input;
01449 string name, size, min_width, min_height, max_width, max_height;
01450
01451
01452 string themePath = (theme ? theme->getThemePath() : globalTheme->getThemePath());
01453
01454
01455 themeClass.widgetClass.border.setAttributesFromTAFF(tafff, NULL, &themePath);
01456 themeClass.widgetClass.setAttributesFromTAFF(tafff, NULL, &themePath);
01457 themeClass.setAttributesFromTAFF(tafff, NULL, &themePath);
01458
01459
01460 input = new MMSInputWidget(rootWindow, themeClass.getClassName(), theme);
01461
01462
01463 input->updateFromThemeClass(&themeClass);
01464
01465
01466 startTAFFScan
01467 {
01468 switch (attrid) {
01469
01470 READ_DM_SPECIFIC_WIDGET_ATTRIBUTES(name, size, min_width, min_height, max_width, max_height);
01471 }
01472 }
01473 endTAFFScan
01474
01475
01476 SET_DM_SPECIFIC_WIDGET_ATTRIBUTES(input, name, size, min_width, min_height, max_width, max_height);
01477
01478 if (currentWidget)
01479 currentWidget->add(input);
01480 else
01481 rootWindow->add(input);
01482
01483 throughDoc(tafff, input, rootWindow, theme);
01484
01485
01486 return name;
01487 }
01488
01489
01490 string MMSDialogManager::getCheckBoxValues(MMSTaffFile *tafff, MMSWidget *currentWidget, MMSWindow *rootWindow, MMSTheme *theme) {
01491 MMSCheckBoxWidgetClass themeClass;
01492 MMSCheckBoxWidget *checkbox;
01493 string name, size, min_width, min_height, max_width, max_height;
01494
01495
01496 string themePath = (theme ? theme->getThemePath() : globalTheme->getThemePath());
01497
01498
01499 themeClass.widgetClass.border.setAttributesFromTAFF(tafff, NULL, &themePath);
01500 themeClass.widgetClass.setAttributesFromTAFF(tafff, NULL, &themePath);
01501 themeClass.setAttributesFromTAFF(tafff, NULL, &themePath);
01502
01503
01504 checkbox = new MMSCheckBoxWidget(rootWindow, themeClass.getClassName(), theme);
01505
01506
01507 checkbox->updateFromThemeClass(&themeClass);
01508
01509
01510 startTAFFScan
01511 {
01512 switch (attrid) {
01513
01514 READ_DM_SPECIFIC_WIDGET_ATTRIBUTES(name, size, min_width, min_height, max_width, max_height);
01515 }
01516 }
01517 endTAFFScan
01518
01519
01520 SET_DM_SPECIFIC_WIDGET_ATTRIBUTES(checkbox, name, size, min_width, min_height, max_width, max_height);
01521
01522 if (currentWidget)
01523 currentWidget->add(checkbox);
01524 else
01525 rootWindow->add(checkbox);
01526
01527 throughDoc(tafff, checkbox, rootWindow, theme);
01528
01529
01530 return name;
01531 }
01532
01533 string MMSDialogManager::getGapValues(MMSTaffFile *tafff, MMSWidget *currentWidget, MMSWindow *rootWindow, MMSTheme *theme) {
01534 MMSGapWidget *gap;
01535 string name, size, min_width, min_height, max_width, max_height;
01536
01537 startTAFFScan
01538 {
01539 switch (attrid) {
01540
01541 READ_DM_SPECIFIC_WIDGET_ATTRIBUTES(name, size, min_width, min_height, max_width, max_height);
01542 }
01543 }
01544 endTAFFScan
01545
01546 gap = new MMSGapWidget(rootWindow);
01547
01548
01549 SET_DM_SPECIFIC_WIDGET_ATTRIBUTES(gap, name, size, min_width, min_height, max_width, max_height);
01550
01551 if (currentWidget)
01552 currentWidget->add(gap);
01553 else
01554 rootWindow->add(gap);
01555
01556 throughDoc(tafff, gap, rootWindow, theme);
01557
01558
01559 return name;
01560 }
01561
01562
01563 MMSWindow *MMSDialogManager::getWindow() {
01564 return this->rootWindow;
01565 }
01566
01567
01568 void MMSDialogManager::updateTAFFAttributes(MMSTaffFile *tafff, MMSWidget *widget, string &widgetName) {
01569 if(!widget) {
01570 return;
01571 }
01572
01573 string prefix = "widget." + widgetName + ".";
01574
01575 switch (widget->getType()) {
01576 case MMSWIDGETTYPE_HBOX:
01577 case MMSWIDGETTYPE_VBOX:
01578 break;
01579 case MMSWIDGETTYPE_BUTTON:
01580 {
01581
01582 MMSButtonWidgetClass themeCls;
01583 themeCls.widgetClass.border.setAttributesFromTAFF(tafff, &prefix);
01584 themeCls.widgetClass.setAttributesFromTAFF(tafff, &prefix);
01585 themeCls.setAttributesFromTAFF(tafff, &prefix);
01586
01587 ((MMSButtonWidget*)widget)->updateFromThemeClass(&themeCls);
01588 }
01589 break;
01590 case MMSWIDGETTYPE_IMAGE:
01591 {
01592
01593 MMSImageWidgetClass themeCls;
01594 themeCls.widgetClass.border.setAttributesFromTAFF(tafff, &prefix);
01595 themeCls.widgetClass.setAttributesFromTAFF(tafff, &prefix);
01596 themeCls.setAttributesFromTAFF(tafff, &prefix);
01597
01598 ((MMSImageWidget*)widget)->updateFromThemeClass(&themeCls);
01599 }
01600 break;
01601 case MMSWIDGETTYPE_LABEL:
01602 {
01603
01604 MMSLabelWidgetClass themeCls;
01605 themeCls.widgetClass.border.setAttributesFromTAFF(tafff, &prefix);
01606 themeCls.widgetClass.setAttributesFromTAFF(tafff, &prefix);
01607 themeCls.setAttributesFromTAFF(tafff, &prefix);
01608
01609 ((MMSLabelWidget*)widget)->updateFromThemeClass(&themeCls);
01610 }
01611 break;
01612 case MMSWIDGETTYPE_MENU:
01613 break;
01614 case MMSWIDGETTYPE_PROGRESSBAR:
01615 {
01616
01617 MMSProgressBarWidgetClass themeCls;
01618 themeCls.widgetClass.border.setAttributesFromTAFF(tafff, &prefix);
01619 themeCls.widgetClass.setAttributesFromTAFF(tafff, &prefix);
01620 themeCls.setAttributesFromTAFF(tafff, &prefix);
01621
01622 ((MMSProgressBarWidget*)widget)->updateFromThemeClass(&themeCls);
01623 }
01624 break;
01625 case MMSWIDGETTYPE_TEXTBOX:
01626 {
01627
01628 MMSTextBoxWidgetClass themeCls;
01629 themeCls.widgetClass.border.setAttributesFromTAFF(tafff, &prefix);
01630 themeCls.widgetClass.setAttributesFromTAFF(tafff, &prefix);
01631 themeCls.setAttributesFromTAFF(tafff, &prefix);
01632
01633 ((MMSTextBoxWidget*)widget)->updateFromThemeClass(&themeCls);
01634 }
01635 break;
01636 case MMSWIDGETTYPE_ARROW:
01637 {
01638
01639 MMSArrowWidgetClass themeCls;
01640 themeCls.widgetClass.border.setAttributesFromTAFF(tafff, &prefix);
01641 themeCls.widgetClass.setAttributesFromTAFF(tafff, &prefix);
01642 themeCls.setAttributesFromTAFF(tafff, &prefix);
01643
01644 ((MMSArrowWidget*)widget)->updateFromThemeClass(&themeCls);
01645 }
01646 break;
01647 case MMSWIDGETTYPE_SLIDER:
01648 {
01649
01650 MMSSliderWidgetClass themeCls;
01651 themeCls.widgetClass.border.setAttributesFromTAFF(tafff, &prefix);
01652 themeCls.widgetClass.setAttributesFromTAFF(tafff, &prefix);
01653 themeCls.setAttributesFromTAFF(tafff, &prefix);
01654
01655 ((MMSSliderWidget*)widget)->updateFromThemeClass(&themeCls);
01656 }
01657 break;
01658 case MMSWIDGETTYPE_INPUT:
01659 break;
01660 case MMSWIDGETTYPE_CHECKBOX:
01661 {
01662
01663 MMSCheckBoxWidgetClass themeCls;
01664 themeCls.widgetClass.border.setAttributesFromTAFF(tafff, &prefix);
01665 themeCls.widgetClass.setAttributesFromTAFF(tafff, &prefix);
01666 themeCls.setAttributesFromTAFF(tafff, &prefix);
01667
01668 ((MMSCheckBoxWidget*)widget)->updateFromThemeClass(&themeCls);
01669 }
01670 break;
01671 case MMSWIDGETTYPE_CANVAS:
01672 {
01673
01674 MMSCanvasWidgetClass themeCls;
01675 themeCls.widgetClass.border.setAttributesFromTAFF(tafff, &prefix);
01676 themeCls.widgetClass.setAttributesFromTAFF(tafff, &prefix);
01677 themeCls.setAttributesFromTAFF(tafff, &prefix);
01678
01679 ((MMSCanvasWidget*)widget)->updateFromThemeClass(&themeCls);
01680 }
01681 break;
01682 case MMSWIDGETTYPE_GAP:
01683 break;
01684 }
01685 }
01686