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

mmsdialogmanager.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-2012 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/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 // read widget attributes from TAFF which are not defined in theme classes
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 // set widget attributes which are not defined in theme classes
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         // have to delete my objects
00106         if (this->rootWindow_is_mine) {
00107             // delete the rootWindow if it was initialized by me
00108             if (this->rootWindow)
00109                 delete this->rootWindow;
00110         }
00111         else {
00112             // i should not delete the rootWindow because it was not initialized by me
00113             // so delete only the loaded child windows
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         // reset all values if a window is already loaded
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     // get taff file name
00163     string tafffilename = filename + ".taff";
00164 
00165     //check for file
00166     if(!file_exist(filename))
00167         if(!file_exist(tafffilename))
00168             throw MMSDialogManagerError(1, "dialog file (" + filename + ") not found");
00169 
00170     // open the taff file
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     // get root tag
00183     int tagid = tafff->getFirstTag();
00184     if (tagid < 0) {
00185         delete tafff;
00186         throw MMSDialogManagerError(1, "invalid taff file " + tafffilename);
00187     }
00188 
00189     // check if the correct tag
00190     if (tagid != MMSGUI_TAGTABLE_TAG_MMSDIALOG) {
00191         DEBUGMSG("MMSGUI", "no valid dialog file: %s", filename.c_str());
00192         return NULL;
00193     }
00194 
00195     // save the filename
00196     this->filename = filename;
00197 
00198     // through the doc
00199     this->throughDoc(tafff, NULL, this->rootWindow, theme);
00200 
00201     // free the document
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     // get taff file name
00212     string tafffilename = filename + ".taff";
00213 
00214     //check for file
00215     if(!file_exist(filename))
00216         if(!file_exist(tafffilename))
00217             throw MMSDialogManagerError(1, "dialog file (" + filename + ") not found");
00218 
00219     // open the taff file
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     // get root tag
00232     int tagid = tafff->getFirstTag();
00233     if (tagid < 0) {
00234         delete tafff;
00235         throw MMSDialogManagerError(1, "invalid taff file " + tafffilename);
00236     }
00237 
00238     // check if the correct tag
00239     if (tagid != MMSGUI_TAGTABLE_TAG_MMSDIALOG) {
00240         DEBUGMSG("MMSGUI", "no valid dialog file: %s", filename.c_str());
00241         return NULL;
00242     }
00243 
00244     // through the doc
00245 //printf("loadChildDialog(), root=%x, file=%s\n", this->rootWindow, filename.c_str());
00246     this->throughDoc(tafff, NULL, this->rootWindow, theme);
00247 
00248     // free the document
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     // iterate through childs
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             // get close tag of description
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                     // search for duplicate names for the same parent
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     // get themepath
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     // get themepath
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     // get themepath
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     // get themepath
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     // store only the 'root' child window in my list
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     // read settings from dialog
00708     themeClass.setAttributesFromTAFF(tafff);
00709 
00710     // is a class name given?
00711     if (!themeClass.getClassName().empty()) {
00712         // can load templateClass?
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         // are there any childs stored in the templateClass?
00723         if (!(tf = templateClass->getTAFF()))
00724             templateClass = NULL;
00725     }
00726 
00727     if (!templateClass) {
00728         // parse the children from dialog's template tag
00729         throughDoc(tafff, currentWidget, rootWindow, theme);
00730 
00731         return "";
00732     }
00733 
00734     // search for attributes which are only supported within dialog
00735     startTAFFScan
00736     {
00737         switch (attrid) {
00738         // read widget attributes from TAFF which are not defined in theme classes
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             // search for attributes which are to be set for templates child widgets
00751             string widgetName = &attrname[7];
00752             int pos = (int)widgetName.find(".");
00753             if (pos > 0) {
00754                 widgetName = widgetName.substr(0, pos);
00755 
00756                 // store the requested widget name here
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     // parse the children from templateClass
00766     throughDoc(tf, currentWidget, rootWindow, theme);
00767 
00768     // get the last window of root window
00769     MMSWindow *newWindow = (!currentWidget)?rootWindow->getLastWindow():NULL;
00770 
00771     if (!newWindow) {
00772         // get the last widget of currentWidget
00773         MMSWidget *newWidget = (!currentWidget)?((*rootWindow)[""]):currentWidget->getLastWidget();
00774 
00775         if (newWidget) {
00776             // set widget attributes which are not defined in theme classes
00777             SET_DM_SPECIFIC_WIDGET_ATTRIBUTES(newWidget, name, size, min_width, min_height, max_width, max_height);
00778 
00779             // for each child widget which is named by attribute
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             // set name of window
00793             newWindow->setName(name);
00794         }
00795 
00796         if (show) {
00797             // show window
00798             newWindow->show();
00799         }
00800 
00801         // for each child widget which is named by attribute
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     // parse the children from dialog's template tag
00810     throughDoc(tafff, currentWidget, rootWindow, theme);
00811 
00812     // return the name of the widget
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         // read widget attributes from TAFF which are not defined in theme classes
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     // set widget attributes which are not defined in theme classes
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     // return the name of the widget
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         // read widget attributes from TAFF which are not defined in theme classes
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     // set widget attributes which are not defined in theme classes
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     // return the name of the widget
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     // get themepath
00882     string themePath = (theme ? theme->getThemePath() : globalTheme->getThemePath());
00883 
00884     // read settings from dialog
00885     themeClass.widgetClass.border.setAttributesFromTAFF(tafff, NULL, &themePath);
00886     themeClass.widgetClass.setAttributesFromTAFF(tafff, NULL, &themePath);
00887     themeClass.setAttributesFromTAFF(tafff, NULL, &themePath);
00888 
00889     // create new label from theme class
00890     label = new MMSLabelWidget(rootWindow, themeClass.getClassName(), theme);
00891 
00892     // apply settings from dialog
00893     label->updateFromThemeClass(&themeClass);
00894 
00895     // search for attributes which are only supported within dialog
00896     startTAFFScan
00897     {
00898         switch (attrid) {
00899         // read widget attributes from TAFF which are not defined in theme classes
00900         READ_DM_SPECIFIC_WIDGET_ATTRIBUTES(name, size, min_width, min_height, max_width, max_height);
00901         }
00902     }
00903     endTAFFScan
00904 
00905     // set widget attributes which are not defined in theme classes
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     // return the name of the widget
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     // get themepath
00927     string themePath = (theme ? theme->getThemePath() : globalTheme->getThemePath());
00928 
00929     // read settings from dialog
00930     themeClass.widgetClass.border.setAttributesFromTAFF(tafff, NULL, &themePath);
00931     themeClass.widgetClass.setAttributesFromTAFF(tafff,  NULL, &themePath);
00932     themeClass.setAttributesFromTAFF(tafff, NULL, &themePath);
00933 
00934     // create new button from theme class
00935     button = new MMSButtonWidget(rootWindow, themeClass.getClassName(), theme);
00936 
00937     // apply settings from dialog
00938     button->updateFromThemeClass(&themeClass);
00939 
00940     // search for attributes which are only supported within dialog
00941     startTAFFScan
00942     {
00943         switch (attrid) {
00944         // read widget attributes from TAFF which are not defined in theme classes
00945         READ_DM_SPECIFIC_WIDGET_ATTRIBUTES(name, size, min_width, min_height, max_width, max_height);
00946         }
00947     }
00948     endTAFFScan
00949 
00950     // set widget attributes which are not defined in theme classes
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     // return the name of the widget
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     // get themepath
00970     string themePath = (theme ? theme->getThemePath() : globalTheme->getThemePath());
00971 
00972     // read settings from dialog
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     // create new canvas from factory with theme class
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     // apply settings from dialog
00992     canvas->updateFromThemeClass(canvas->canvasWidgetClass);
00993 
00994     // apply settings from dialog
00995     canvas->updateFromThemeClass(&themeClass);
00996 
00997     // search for attributes which are only supported within dialog
00998     startTAFFScan
00999     {
01000         switch (attrid) {
01001         // read widget attributes from TAFF which are not defined in theme classes
01002         READ_DM_SPECIFIC_WIDGET_ATTRIBUTES(name, size, min_width, min_height, max_width, max_height);
01003         }
01004     }
01005     endTAFFScan
01006 
01007     // set widget attributes which are not defined in theme classes
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     // return the name of the widget
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     // get themepath
01028     string themePath = (theme ? theme->getThemePath() : globalTheme->getThemePath());
01029 
01030     // read settings from dialog
01031     themeClass.widgetClass.border.setAttributesFromTAFF(tafff, NULL, &themePath);
01032     themeClass.widgetClass.setAttributesFromTAFF(tafff, NULL, &themePath);
01033     themeClass.setAttributesFromTAFF(tafff, NULL, &themePath);
01034 
01035     // create new image from theme class
01036     image = new MMSImageWidget(rootWindow, themeClass.getClassName(), theme);
01037 
01038     // apply settings from dialog
01039     image->updateFromThemeClass(&themeClass);
01040 
01041     // search for attributes which are only supported within dialog
01042     startTAFFScan
01043     {
01044         switch (attrid) {
01045         // read widget attributes from TAFF which are not defined in theme classes
01046         READ_DM_SPECIFIC_WIDGET_ATTRIBUTES(name, size, min_width, min_height, max_width, max_height);
01047         }
01048     }
01049     endTAFFScan
01050 
01051     // set widget attributes which are not defined in theme classes
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     // return the name of the widget
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     // get themepath
01072     string themePath = (theme ? theme->getThemePath() : globalTheme->getThemePath());
01073 
01074     // read settings from dialog
01075     themeClass.widgetClass.border.setAttributesFromTAFF(tafff, NULL, &themePath);
01076     themeClass.widgetClass.setAttributesFromTAFF(tafff, NULL, &themePath);
01077     themeClass.setAttributesFromTAFF(tafff, NULL, &themePath);
01078 
01079     // create new progressbar from theme class
01080     pBar = new MMSProgressBarWidget(rootWindow, themeClass.getClassName(), theme);
01081 
01082     // apply settings from dialog
01083     pBar->updateFromThemeClass(&themeClass);
01084 
01085     // search for attributes which are only supported within dialog
01086     startTAFFScan
01087     {
01088         switch (attrid) {
01089         // read widget attributes from TAFF which are not defined in theme classes
01090         READ_DM_SPECIFIC_WIDGET_ATTRIBUTES(name, size, min_width, min_height, max_width, max_height);
01091         }
01092     }
01093     endTAFFScan
01094 
01095     // set widget attributes which are not defined in theme classes
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     // return the name of the widget
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     // get themepath
01117     string themePath = (theme ? theme->getThemePath() : globalTheme->getThemePath());
01118 
01119     // read settings from dialog
01120     themeClass.widgetClass.border.setAttributesFromTAFF(tafff, NULL, &themePath);
01121     themeClass.widgetClass.setAttributesFromTAFF(tafff, NULL, &themePath);
01122     themeClass.setAttributesFromTAFF(tafff, NULL, &themePath);
01123 
01124     // create new menu from theme class
01125     menu = new MMSMenuWidget(rootWindow, themeClass.getClassName(), theme);
01126 
01127     // apply settings from dialog
01128     menu->updateFromThemeClass(&themeClass);
01129 
01130     // search for attributes which are only supported within dialog
01131     startTAFFScan
01132     {
01133         switch (attrid) {
01134         // read widget attributes from TAFF which are not defined in theme classes
01135         READ_DM_SPECIFIC_WIDGET_ATTRIBUTES(name, size, min_width, min_height, max_width, max_height);
01136         }
01137     }
01138     endTAFFScan
01139 
01140     // set widget attributes which are not defined in theme classes
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     // set the item layout, we need a temporary parent widget
01149     MMSHBoxWidget *tmpWidget = new MMSHBoxWidget(NULL);
01150 
01151     // are there any childs stored in the theme?
01152     if ((tf = menu->getTAFF())) {
01153         // yes, parse the childs from theme
01154         throughDoc(tf, tmpWidget, NULL, theme);
01155     }
01156     else {
01157         // no, parse the childs from dialog file
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             // try with theme failed, retry with childs from dialog file
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         // have a template - search for menu items which are set in the dialog file
01183         bool haveItems = false;
01184         bool returntag = true;
01185 
01186         // iterate through childs
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             // check if a <menuitem/> is given
01200             if (tid == MMSGUI_TAGTABLE_TAG_MENUITEM)
01201             {
01202                 // new menu item
01203                 MMSWidget *item = NULL;
01204                 haveItems = true;
01205 
01206                 if (tafff->hasAttributes()) {
01207                     // menu item has attributes, so we assume that the new item should be created with item template style
01208                     // create new menu item
01209                     item = menu->newItem();
01210 
01211                     // here we must loop for n widgets
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                                 // search for attributes which are to be set for menu items child widgets
01220                                 string widgetName = &attrname[7];
01221                                 int pos = (int)widgetName.find(".");
01222                                 if (pos > 0) {
01223                                     // widget name found
01224                                     widgetName = widgetName.substr(0, pos);
01225 
01226                                     // check if i have already processed this widget
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                                     // okay, searching for the widget within the new item
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                             // there is a child window given which represents a sub menu
01253                             menu->setSubMenuName(menu->getSize()-1, attrval_str);
01254                         }
01255                         else
01256                         if (memcmp(attrname, "goback", 6)==0) {
01257                             // if true, this item should be the go-back-item
01258                             //! if the user enters this item, the parent menu (if does exist) will be shown
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                     // menu item has NO attributes, so we try to read a specific item style from the <menuitem/> children
01278                     // checking for tags within <menuitem/>
01279                     MMSHBoxWidget *tmpWidget = new MMSHBoxWidget(NULL);
01280 
01281                     // parse the childs from dialog file
01282                     throughDoc(tafff, tmpWidget, NULL, theme);
01283                     returntag = true;
01284 
01285                     // here we create a new menu item based on disconnected child (if != NULL) or item template style
01286                     item = menu->newItem(-1, tmpWidget->disconnectChild());
01287 
01288                     // delete the temporary container
01289                     delete tmpWidget;
01290                 }
01291             }
01292             else {
01293                 // any other widgets given in the menu
01294                 printf("Warning: Tag <%s/> is not supported within <menu/>.\n", tafff->getCurrentTagName());
01295 
01296                 // we need a temporary widget
01297                 MMSHBoxWidget *tmpWidget = new MMSHBoxWidget(NULL);
01298 
01299                 // parse the childs from dialog file
01300                 throughDoc(tafff, tmpWidget, NULL, theme);
01301                 returntag = true;
01302 
01303                 // delete the widget, we cannot use it
01304                 delete tmpWidget;
01305             }
01306         }
01307 
01308         if (haveItems)
01309             menu->setFocus(false, false);
01310     }
01311 
01312     // return the name of the widget
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     // get themepath
01323     string themePath = (theme ? theme->getThemePath() : globalTheme->getThemePath());
01324 
01325     // read settings from dialog
01326     themeClass.widgetClass.border.setAttributesFromTAFF(tafff, NULL, &themePath);
01327     themeClass.widgetClass.setAttributesFromTAFF(tafff, NULL, &themePath);
01328     themeClass.setAttributesFromTAFF(tafff, NULL, &themePath);
01329 
01330     // create new textbox from theme class
01331     textbox = new MMSTextBoxWidget(rootWindow, themeClass.getClassName(), theme);
01332 
01333     // apply settings from dialog
01334     textbox->updateFromThemeClass(&themeClass);
01335 
01336     // search for attributes which are only supported within dialog
01337     startTAFFScan
01338     {
01339         switch (attrid) {
01340         // read widget attributes from TAFF which are not defined in theme classes
01341         READ_DM_SPECIFIC_WIDGET_ATTRIBUTES(name, size, min_width, min_height, max_width, max_height);
01342         }
01343     }
01344     endTAFFScan
01345 
01346     // set widget attributes which are not defined in theme classes
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     // return the name of the widget
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     // get themepath
01366     string themePath = (theme ? theme->getThemePath() : globalTheme->getThemePath());
01367 
01368     // read settings from dialog
01369     themeClass.widgetClass.border.setAttributesFromTAFF(tafff, NULL, &themePath);
01370     themeClass.widgetClass.setAttributesFromTAFF(tafff, NULL, &themePath);
01371     themeClass.setAttributesFromTAFF(tafff, NULL, &themePath);
01372 
01373     // create new arrow from theme class
01374     arrow = new MMSArrowWidget(rootWindow, themeClass.getClassName(), theme);
01375 
01376     // apply settings from dialog
01377     arrow->updateFromThemeClass(&themeClass);
01378 
01379     // search for attributes which are only supported within dialog
01380     startTAFFScan
01381     {
01382         switch (attrid) {
01383         // read widget attributes from TAFF which are not defined in theme classes
01384         READ_DM_SPECIFIC_WIDGET_ATTRIBUTES(name, size, min_width, min_height, max_width, max_height);
01385         }
01386     }
01387     endTAFFScan
01388 
01389     // set widget attributes which are not defined in theme classes
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     // return the name of the widget
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     // get themepath
01409     string themePath = (theme ? theme->getThemePath() : globalTheme->getThemePath());
01410 
01411     // read settings from dialog
01412     themeClass.widgetClass.border.setAttributesFromTAFF(tafff, NULL, &themePath);
01413     themeClass.widgetClass.setAttributesFromTAFF(tafff, NULL, &themePath);
01414     themeClass.setAttributesFromTAFF(tafff, NULL, &themePath);
01415 
01416     // create new slider from theme class
01417     slider = new MMSSliderWidget(rootWindow, themeClass.getClassName(), theme);
01418 
01419     // apply settings from dialog
01420     slider->updateFromThemeClass(&themeClass);
01421 
01422     // search for attributes which are only supported within dialog
01423     startTAFFScan
01424     {
01425         switch (attrid) {
01426         // read widget attributes from TAFF which are not defined in theme classes
01427         READ_DM_SPECIFIC_WIDGET_ATTRIBUTES(name, size, min_width, min_height, max_width, max_height);
01428         }
01429     }
01430     endTAFFScan
01431 
01432     // set widget attributes which are not defined in theme classes
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     // return the name of the widget
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     // get themepath
01452     string themePath = (theme ? theme->getThemePath() : globalTheme->getThemePath());
01453 
01454     // read settings from dialog
01455     themeClass.widgetClass.border.setAttributesFromTAFF(tafff, NULL, &themePath);
01456     themeClass.widgetClass.setAttributesFromTAFF(tafff, NULL, &themePath);
01457     themeClass.setAttributesFromTAFF(tafff, NULL, &themePath);
01458 
01459     // create new label from theme class
01460     input = new MMSInputWidget(rootWindow, themeClass.getClassName(), theme);
01461 
01462     // apply settings from dialog
01463     input->updateFromThemeClass(&themeClass);
01464 
01465     // search for attributes which are only supported within dialog
01466     startTAFFScan
01467     {
01468         switch (attrid) {
01469         // read widget attributes from TAFF which are not defined in theme classes
01470         READ_DM_SPECIFIC_WIDGET_ATTRIBUTES(name, size, min_width, min_height, max_width, max_height);
01471         }
01472     }
01473     endTAFFScan
01474 
01475     // set widget attributes which are not defined in theme classes
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     // return the name of the widget
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     // get themepath
01496     string themePath = (theme ? theme->getThemePath() : globalTheme->getThemePath());
01497 
01498     // read settings from dialog
01499     themeClass.widgetClass.border.setAttributesFromTAFF(tafff, NULL, &themePath);
01500     themeClass.widgetClass.setAttributesFromTAFF(tafff, NULL, &themePath);
01501     themeClass.setAttributesFromTAFF(tafff, NULL, &themePath);
01502 
01503     // create new checkbox from theme class
01504     checkbox = new MMSCheckBoxWidget(rootWindow, themeClass.getClassName(), theme);
01505 
01506     // apply settings from dialog
01507     checkbox->updateFromThemeClass(&themeClass);
01508 
01509     // search for attributes which are only supported within dialog
01510     startTAFFScan
01511     {
01512         switch (attrid) {
01513         // read widget attributes from TAFF which are not defined in theme classes
01514         READ_DM_SPECIFIC_WIDGET_ATTRIBUTES(name, size, min_width, min_height, max_width, max_height);
01515         }
01516     }
01517     endTAFFScan
01518 
01519     // set widget attributes which are not defined in theme classes
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     // return the name of the widget
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         // read widget attributes from TAFF which are not defined in theme classes
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     // set widget attributes which are not defined in theme classes
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     // return the name of the widget
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                 // read attributes from node
01582                 MMSButtonWidgetClass themeCls;
01583                 themeCls.widgetClass.border.setAttributesFromTAFF(tafff, &prefix);
01584                 themeCls.widgetClass.setAttributesFromTAFF(tafff, &prefix);
01585                 themeCls.setAttributesFromTAFF(tafff, &prefix);
01586                 // apply settings from node
01587                 ((MMSButtonWidget*)widget)->updateFromThemeClass(&themeCls);
01588             }
01589             break;
01590         case MMSWIDGETTYPE_IMAGE:
01591             {
01592                 // read attributes from node
01593                 MMSImageWidgetClass themeCls;
01594                 themeCls.widgetClass.border.setAttributesFromTAFF(tafff, &prefix);
01595                 themeCls.widgetClass.setAttributesFromTAFF(tafff, &prefix);
01596                 themeCls.setAttributesFromTAFF(tafff, &prefix);
01597                 // apply settings from node
01598                 ((MMSImageWidget*)widget)->updateFromThemeClass(&themeCls);
01599             }
01600             break;
01601         case MMSWIDGETTYPE_LABEL:
01602             {
01603                 // read attributes from node
01604                 MMSLabelWidgetClass themeCls;
01605                 themeCls.widgetClass.border.setAttributesFromTAFF(tafff, &prefix);
01606                 themeCls.widgetClass.setAttributesFromTAFF(tafff, &prefix);
01607                 themeCls.setAttributesFromTAFF(tafff, &prefix);
01608                 // apply settings from node
01609                 ((MMSLabelWidget*)widget)->updateFromThemeClass(&themeCls);
01610             }
01611             break;
01612         case MMSWIDGETTYPE_MENU:
01613             break;
01614         case MMSWIDGETTYPE_PROGRESSBAR:
01615             {
01616                 // read attributes from node
01617                 MMSProgressBarWidgetClass themeCls;
01618                 themeCls.widgetClass.border.setAttributesFromTAFF(tafff, &prefix);
01619                 themeCls.widgetClass.setAttributesFromTAFF(tafff, &prefix);
01620                 themeCls.setAttributesFromTAFF(tafff, &prefix);
01621                 // apply settings from node
01622                 ((MMSProgressBarWidget*)widget)->updateFromThemeClass(&themeCls);
01623             }
01624             break;
01625         case MMSWIDGETTYPE_TEXTBOX:
01626             {
01627                 // read attributes from node
01628                 MMSTextBoxWidgetClass themeCls;
01629                 themeCls.widgetClass.border.setAttributesFromTAFF(tafff, &prefix);
01630                 themeCls.widgetClass.setAttributesFromTAFF(tafff, &prefix);
01631                 themeCls.setAttributesFromTAFF(tafff, &prefix);
01632                 // apply settings from node
01633                 ((MMSTextBoxWidget*)widget)->updateFromThemeClass(&themeCls);
01634             }
01635             break;
01636         case MMSWIDGETTYPE_ARROW:
01637             {
01638                 // read attributes from node
01639                 MMSArrowWidgetClass themeCls;
01640                 themeCls.widgetClass.border.setAttributesFromTAFF(tafff, &prefix);
01641                 themeCls.widgetClass.setAttributesFromTAFF(tafff, &prefix);
01642                 themeCls.setAttributesFromTAFF(tafff, &prefix);
01643                 // apply settings from node
01644                 ((MMSArrowWidget*)widget)->updateFromThemeClass(&themeCls);
01645             }
01646             break;
01647         case MMSWIDGETTYPE_SLIDER:
01648             {
01649                 // read attributes from node
01650                 MMSSliderWidgetClass themeCls;
01651                 themeCls.widgetClass.border.setAttributesFromTAFF(tafff, &prefix);
01652                 themeCls.widgetClass.setAttributesFromTAFF(tafff, &prefix);
01653                 themeCls.setAttributesFromTAFF(tafff, &prefix);
01654                 // apply settings from node
01655                 ((MMSSliderWidget*)widget)->updateFromThemeClass(&themeCls);
01656             }
01657             break;
01658         case MMSWIDGETTYPE_INPUT:
01659             break;
01660         case MMSWIDGETTYPE_CHECKBOX:
01661             {
01662                 // read attributes from node
01663                 MMSCheckBoxWidgetClass themeCls;
01664                 themeCls.widgetClass.border.setAttributesFromTAFF(tafff, &prefix);
01665                 themeCls.widgetClass.setAttributesFromTAFF(tafff, &prefix);
01666                 themeCls.setAttributesFromTAFF(tafff, &prefix);
01667                 // apply settings from node
01668                 ((MMSCheckBoxWidget*)widget)->updateFromThemeClass(&themeCls);
01669             }
01670             break;
01671         case MMSWIDGETTYPE_CANVAS:
01672             {
01673                 // read attributes from node
01674                 MMSCanvasWidgetClass themeCls;
01675                 themeCls.widgetClass.border.setAttributesFromTAFF(tafff, &prefix);
01676                 themeCls.widgetClass.setAttributesFromTAFF(tafff, &prefix);
01677                 themeCls.setAttributesFromTAFF(tafff, &prefix);
01678                 // apply settings from node
01679                 ((MMSCanvasWidget*)widget)->updateFromThemeClass(&themeCls);
01680             }
01681             break;
01682         case MMSWIDGETTYPE_GAP:
01683             break;
01684     }
01685 }
01686 

Generated by doxygen