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

mmsprogressbarwidgetclass.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2005-2007 Stefan Schwarzer, Jens Schneider,             *
00003  *                           Matthias Hardt, Guido Madaus                  *
00004  *                                                                         *
00005  *   Copyright (C) 2007-2008 BerLinux Solutions GbR                        *
00006  *                           Stefan Schwarzer & Guido Madaus               *
00007  *                                                                         *
00008  *   Copyright (C) 2009-2013 BerLinux Solutions GmbH                       *
00009  *                                                                         *
00010  *   Authors:                                                              *
00011  *      Stefan Schwarzer   <stefan.schwarzer@diskohq.org>,                 *
00012  *      Matthias Hardt     <matthias.hardt@diskohq.org>,                   *
00013  *      Jens Schneider     <jens.schneider@diskohq.org>,                   *
00014  *      Guido Madaus       <guido.madaus@diskohq.org>,                     *
00015  *      Patrick Helterhoff <patrick.helterhoff@diskohq.org>,               *
00016  *      René Bählkow       <rene.baehlkow@diskohq.org>                     *
00017  *                                                                         *
00018  *   This library is free software; you can redistribute it and/or         *
00019  *   modify it under the terms of the GNU Lesser General Public            *
00020  *   License version 2.1 as published by the Free Software Foundation.     *
00021  *                                                                         *
00022  *   This library is distributed in the hope that it will be useful,       *
00023  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00024  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
00025  *   Lesser General Public License for more details.                       *
00026  *                                                                         *
00027  *   You should have received a copy of the GNU Lesser General Public      *
00028  *   License along with this library; if not, write to the                 *
00029  *   Free Software Foundation, Inc.,                                       *
00030  *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
00031  **************************************************************************/
00032 
00033 #include "mmsgui/theme/mmsprogressbarwidgetclass.h"
00034 #include <string.h>
00035 
00036 //store attribute descriptions here
00037 TAFF_ATTRDESC MMSGUI_PROGRESSBARWIDGET_ATTR_I[] = MMSGUI_PROGRESSBARWIDGET_ATTR_INIT;
00038 
00039 // address attribute names
00040 #define GETATTRNAME(aname) MMSGUI_PROGRESSBARWIDGET_ATTR_I[MMSGUI_PROGRESSBARWIDGET_ATTR::MMSGUI_PROGRESSBARWIDGET_ATTR_IDS_##aname].name
00041 
00042 // address attribute types
00043 #define GETATTRTYPE(aname) MMSGUI_PROGRESSBARWIDGET_ATTR_I[MMSGUI_PROGRESSBARWIDGET_ATTR::MMSGUI_PROGRESSBARWIDGET_ATTR_IDS_##aname].type
00044 
00045 
00046 MMSProgressBarWidgetClass::MMSProgressBarWidgetClass() {
00047     unsetAll();
00048 }
00049 
00050 void MMSProgressBarWidgetClass::unsetAll() {
00051     this->className = "";
00052     unsetColor();
00053     unsetSelColor();
00054     unsetProgress();
00055 }
00056 
00057 void MMSProgressBarWidgetClass::setAttributesFromTAFF(MMSTaffFile *tafff, string *prefix, string *path, bool reset_paths) {
00058     MMSFBColor color;
00059 
00060     if (!prefix) {
00061         startTAFFScan
00062         {
00063             switch (attrid) {
00064             case MMSGUI_BASE_ATTR::MMSGUI_BASE_ATTR_IDS_class:
00065                 setClassName(attrval_str);
00066                 break;
00067             case MMSGUI_PROGRESSBARWIDGET_ATTR::MMSGUI_PROGRESSBARWIDGET_ATTR_IDS_color:
00068                 setColor(MMSFBColor((unsigned int)attrval_int));
00069                 break;
00070             case MMSGUI_PROGRESSBARWIDGET_ATTR::MMSGUI_PROGRESSBARWIDGET_ATTR_IDS_color_a:
00071                 color.a = color.r = color.g = color.b = 0;
00072                 if (isColor()) color = getColor();
00073                 color.a = attrval_int;
00074                 setColor(color);
00075                 break;
00076             case MMSGUI_PROGRESSBARWIDGET_ATTR::MMSGUI_PROGRESSBARWIDGET_ATTR_IDS_color_r:
00077                 color.a = color.r = color.g = color.b = 0;
00078                 if (isColor()) color = getColor();
00079                 color.r = attrval_int;
00080                 setColor(color);
00081                 break;
00082             case MMSGUI_PROGRESSBARWIDGET_ATTR::MMSGUI_PROGRESSBARWIDGET_ATTR_IDS_color_g:
00083                 color.a = color.r = color.g = color.b = 0;
00084                 if (isColor()) color = getColor();
00085                 color.g = attrval_int;
00086                 setColor(color);
00087                 break;
00088             case MMSGUI_PROGRESSBARWIDGET_ATTR::MMSGUI_PROGRESSBARWIDGET_ATTR_IDS_color_b:
00089                 color.a = color.r = color.g = color.b = 0;
00090                 if (isColor()) color = getColor();
00091                 color.b = attrval_int;
00092                 setColor(color);
00093                 break;
00094             case MMSGUI_PROGRESSBARWIDGET_ATTR::MMSGUI_PROGRESSBARWIDGET_ATTR_IDS_selcolor:
00095                 setSelColor(MMSFBColor((unsigned int)attrval_int));
00096                 break;
00097             case MMSGUI_PROGRESSBARWIDGET_ATTR::MMSGUI_PROGRESSBARWIDGET_ATTR_IDS_selcolor_a:
00098                 color.a = color.r = color.g = color.b = 0;
00099                 if (isSelColor()) color = getSelColor();
00100                 color.a = attrval_int;
00101                 setSelColor(color);
00102                 break;
00103             case MMSGUI_PROGRESSBARWIDGET_ATTR::MMSGUI_PROGRESSBARWIDGET_ATTR_IDS_selcolor_r:
00104                 color.a = color.r = color.g = color.b = 0;
00105                 if (isSelColor()) color = getSelColor();
00106                 color.r = attrval_int;
00107                 setSelColor(color);
00108                 break;
00109             case MMSGUI_PROGRESSBARWIDGET_ATTR::MMSGUI_PROGRESSBARWIDGET_ATTR_IDS_selcolor_g:
00110                 color.a = color.r = color.g = color.b = 0;
00111                 if (isSelColor()) color = getSelColor();
00112                 color.g = attrval_int;
00113                 setSelColor(color);
00114                 break;
00115             case MMSGUI_PROGRESSBARWIDGET_ATTR::MMSGUI_PROGRESSBARWIDGET_ATTR_IDS_selcolor_b:
00116                 color.a = color.r = color.g = color.b = 0;
00117                 if (isSelColor()) color = getSelColor();
00118                 color.b = attrval_int;
00119                 setSelColor(color);
00120                 break;
00121             case MMSGUI_PROGRESSBARWIDGET_ATTR::MMSGUI_PROGRESSBARWIDGET_ATTR_IDS_progress:
00122                 setProgress(attrval_int);
00123                 break;
00124             }
00125         }
00126         endTAFFScan
00127     }
00128     else {
00129         unsigned int pl = strlen(prefix->c_str());
00130 
00131         startTAFFScan_WITHOUT_ID
00132         {
00133             // check if attrname has correct prefix
00134             if (pl >= strlen(attrname))
00135                 continue;
00136             if (memcmp(attrname, prefix->c_str(), pl)!=0)
00137                 continue;
00138             attrname = &attrname[pl];
00139 
00140             // special storage for macros
00141             bool attrval_str_valid;
00142             bool int_val_set;
00143             bool byte_val_set;
00144             int  *p_int_val = &attrval_int;
00145 
00146             // okay, correct prefix, check attributes now
00147             if (ISATTRNAME(color)) {
00148                 setColor(MMSFBColor((unsigned int)attrval_int));
00149             }
00150             else
00151             if (ISATTRNAME(color_a)) {
00152                 color.a = color.r = color.g = color.b = 0;
00153                 if (isColor()) color = getColor();
00154                 color.a = attrval_int;
00155                 setColor(color);
00156             }
00157             else
00158             if (ISATTRNAME(color_r)) {
00159                 color.a = color.r = color.g = color.b = 0;
00160                 if (isColor()) color = getColor();
00161                 color.r = attrval_int;
00162                 setColor(color);
00163             }
00164             else
00165             if (ISATTRNAME(color_g)) {
00166                 color.a = color.r = color.g = color.b = 0;
00167                 if (isColor()) color = getColor();
00168                 color.g = attrval_int;
00169                 setColor(color);
00170             }
00171             else
00172             if (ISATTRNAME(color_b)) {
00173                 color.a = color.r = color.g = color.b = 0;
00174                 if (isColor()) color = getColor();
00175                 color.b = attrval_int;
00176                 setColor(color);
00177             }
00178             else
00179             if (ISATTRNAME(selcolor)) {
00180                 setSelColor(MMSFBColor((unsigned int)attrval_int));
00181             }
00182             else
00183             if (ISATTRNAME(selcolor_a)) {
00184                 color.a = color.r = color.g = color.b = 0;
00185                 if (isSelColor()) color = getSelColor();
00186                 color.a = attrval_int;
00187                 setSelColor(color);
00188             }
00189             else
00190             if (ISATTRNAME(selcolor_r)) {
00191                 color.a = color.r = color.g = color.b = 0;
00192                 if (isSelColor()) color = getSelColor();
00193                 color.r = attrval_int;
00194                 setSelColor(color);
00195             }
00196             else
00197             if (ISATTRNAME(selcolor_g)) {
00198                 color.a = color.r = color.g = color.b = 0;
00199                 if (isSelColor()) color = getSelColor();
00200                 color.g = attrval_int;
00201                 setSelColor(color);
00202             }
00203             else
00204             if (ISATTRNAME(selcolor_b)) {
00205                 color.a = color.r = color.g = color.b = 0;
00206                 if (isSelColor()) color = getSelColor();
00207                 color.b = attrval_int;
00208                 setSelColor(color);
00209             }
00210             else
00211             if (ISATTRNAME(progress)) {
00212                 setProgress(attrval_int);
00213             }
00214         }
00215         endTAFFScan_WITHOUT_ID
00216     }
00217 }
00218 
00219 void MMSProgressBarWidgetClass::setClassName(string className) {
00220     this->className = className;
00221 }
00222 
00223 string MMSProgressBarWidgetClass::getClassName() {
00224     return this->className;
00225 }
00226 
00227 bool MMSProgressBarWidgetClass::isColor() {
00228     return this->iscolor;
00229 }
00230 
00231 void MMSProgressBarWidgetClass::setColor(MMSFBColor color) {
00232     this->color = color;
00233     this->iscolor = true;
00234 }
00235 
00236 void MMSProgressBarWidgetClass::unsetColor() {
00237     this->iscolor = false;
00238 }
00239 
00240 MMSFBColor MMSProgressBarWidgetClass::getColor() {
00241     return this->color;
00242 }
00243 
00244 bool MMSProgressBarWidgetClass::isSelColor() {
00245     return this->isselcolor;
00246 }
00247 
00248 void MMSProgressBarWidgetClass::setSelColor(MMSFBColor selcolor) {
00249     this->selcolor = selcolor;
00250     this->isselcolor = true;
00251 }
00252 
00253 void MMSProgressBarWidgetClass::unsetSelColor() {
00254     this->isselcolor = false;
00255 }
00256 
00257 MMSFBColor MMSProgressBarWidgetClass::getSelColor() {
00258     return this->selcolor;
00259 }
00260 
00261 bool MMSProgressBarWidgetClass::isProgress() {
00262     return this->isprogress;
00263 }
00264 
00265 void MMSProgressBarWidgetClass::setProgress(unsigned int progress) {
00266     this->progress = progress;
00267     this->isprogress = true;
00268 }
00269 
00270 void MMSProgressBarWidgetClass::unsetProgress() {
00271     this->isprogress = false;
00272 }
00273 
00274 unsigned int MMSProgressBarWidgetClass::getProgress() {
00275     return this->progress;
00276 }

Generated by doxygen