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/mmslabelwidgetclass.h" 00034 #include <string.h> 00035 00036 // store attribute descriptions here 00037 TAFF_ATTRDESC MMSGUI_LABELWIDGET_ATTR_I[] = MMSGUI_LABELWIDGET_ATTR_INIT; 00038 00039 // address attribute names 00040 #define GETATTRNAME(aname) MMSGUI_LABELWIDGET_ATTR_I[MMSGUI_LABELWIDGET_ATTR::MMSGUI_LABELWIDGET_ATTR_IDS_##aname].name 00041 00042 // address attribute types 00043 #define GETATTRTYPE(aname) MMSGUI_LABELWIDGET_ATTR_I[MMSGUI_LABELWIDGET_ATTR::MMSGUI_LABELWIDGET_ATTR_IDS_##aname].type 00044 00045 00046 MMSLabelWidgetClass::MMSLabelWidgetClass() { 00047 unsetAll(); 00048 } 00049 00050 void MMSLabelWidgetClass::unsetAll() { 00051 this->className = ""; 00052 unsetSlidable(); 00053 unsetSlideSpeed(); 00054 unsetTranslate(); 00055 MMSTextBaseClass::unsetAll(); 00056 } 00057 00058 void MMSLabelWidgetClass::setAttributesFromTAFF(MMSTaffFile *tafff, string *prefix, string *path, bool reset_paths) { 00059 MMSFBColor color; 00060 00061 if ((reset_paths)&&(path)&&(*path!="")) { 00062 // unset my paths 00063 unsetFontPath(); 00064 } 00065 00066 if (!prefix) { 00067 startTAFFScan 00068 { 00069 switch (attrid) { 00070 case MMSGUI_BASE_ATTR::MMSGUI_BASE_ATTR_IDS_class: 00071 setClassName(attrval_str); 00072 break; 00073 00074 // special macro for font parameters 00075 SET_FONT_FROM_TAFF(MMSGUI_LABELWIDGET_ATTR) 00076 00077 // special macro for shadow parameters 00078 SET_SHADOW_FROM_TAFF(MMSGUI_LABELWIDGET_ATTR) 00079 00080 // special macro for textinfo parameters 00081 SET_TEXTINFO_FROM_TAFF(MMSGUI_LABELWIDGET_ATTR) 00082 00083 case MMSGUI_LABELWIDGET_ATTR::MMSGUI_LABELWIDGET_ATTR_IDS_slidable: 00084 setSlidable((attrval_int)?true:false); 00085 break; 00086 case MMSGUI_LABELWIDGET_ATTR::MMSGUI_LABELWIDGET_ATTR_IDS_slide_speed: 00087 setSlideSpeed(attrval_int); 00088 break; 00089 case MMSGUI_LABELWIDGET_ATTR::MMSGUI_LABELWIDGET_ATTR_IDS_translate: 00090 setTranslate((attrval_int)?true:false); 00091 break; 00092 } 00093 } 00094 endTAFFScan 00095 } 00096 else { 00097 unsigned int pl = strlen(prefix->c_str()); 00098 00099 startTAFFScan_WITHOUT_ID 00100 { 00101 // check if attrname has correct prefix 00102 if (pl >= strlen(attrname)) 00103 continue; 00104 if (memcmp(attrname, prefix->c_str(), pl)!=0) 00105 continue; 00106 attrname = &attrname[pl]; 00107 00108 // special storage for macros 00109 bool attrval_str_valid; 00110 bool int_val_set; 00111 bool byte_val_set; 00112 int *p_int_val = &attrval_int; 00113 00114 // okay, correct prefix, check attributes now 00115 00116 // special macro for font parameters 00117 SET_FONT_FROM_TAFF_WITH_PREFIX(MMSGUI_LABELWIDGET_ATTR) 00118 else 00119 // special macro for shadow parameters 00120 SET_SHADOW_FROM_TAFF_WITH_PREFIX(MMSGUI_LABELWIDGET_ATTR) 00121 else 00122 // special macro for textinfo parameters 00123 SET_TEXTINFO_FROM_TAFF_WITH_PREFIX(MMSGUI_LABELWIDGET_ATTR) 00124 else 00125 if (ISATTRNAME(slidable)) { 00126 setSlidable((attrval_int)?true:false); 00127 } 00128 else 00129 if (ISATTRNAME(slide_speed)) { 00130 setSlideSpeed(attrval_int); 00131 } 00132 else 00133 if (ISATTRNAME(translate)) { 00134 setTranslate((attrval_int)?true:false); 00135 } 00136 } 00137 endTAFFScan_WITHOUT_ID 00138 } 00139 00140 if ((reset_paths)&&(path)&&(*path!="")) { 00141 // set my paths 00142 if (!isFontPath()) 00143 setFontPath(*path); 00144 } 00145 } 00146 00147 void MMSLabelWidgetClass::setClassName(string className) { 00148 this->className = className; 00149 } 00150 00151 string MMSLabelWidgetClass::getClassName() { 00152 return this->className; 00153 } 00154 00155 bool MMSLabelWidgetClass::isSlidable() { 00156 return this->isslidable; 00157 } 00158 00159 void MMSLabelWidgetClass::setSlidable(bool slidable) { 00160 this->slidable = slidable; 00161 this->isslidable = true; 00162 } 00163 00164 void MMSLabelWidgetClass::unsetSlidable() { 00165 this->isslidable = false; 00166 } 00167 00168 bool MMSLabelWidgetClass::getSlidable() { 00169 return this->slidable; 00170 } 00171 00172 bool MMSLabelWidgetClass::isSlideSpeed() { 00173 return this->isslidespeed; 00174 } 00175 00176 void MMSLabelWidgetClass::setSlideSpeed(unsigned char slidespeed) { 00177 this->slidespeed = slidespeed; 00178 this->isslidespeed = true; 00179 } 00180 00181 void MMSLabelWidgetClass::unsetSlideSpeed() { 00182 this->isslidespeed = false; 00183 } 00184 00185 unsigned char MMSLabelWidgetClass::getSlideSpeed() { 00186 return this->slidespeed; 00187 } 00188 00189 00190 bool MMSLabelWidgetClass::isTranslate() { 00191 return this->istranslate; 00192 } 00193 00194 void MMSLabelWidgetClass::setTranslate(bool translate) { 00195 this->translate = translate; 00196 this->istranslate = true; 00197 } 00198 00199 void MMSLabelWidgetClass::unsetTranslate() { 00200 this->istranslate = false; 00201 } 00202 00203 bool MMSLabelWidgetClass::getTranslate() { 00204 return this->translate; 00205 } 00206