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

mmstextboxwidgetclass.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/mmstextboxwidgetclass.h"
00034 #include <string.h>
00035 
00036 //store attribute descriptions here
00037 TAFF_ATTRDESC MMSGUI_TEXTBOXWIDGET_ATTR_I[] = MMSGUI_TEXTBOXWIDGET_ATTR_INIT;
00038 
00039 // address attribute names
00040 #define GETATTRNAME(aname) MMSGUI_TEXTBOXWIDGET_ATTR_I[MMSGUI_TEXTBOXWIDGET_ATTR::MMSGUI_TEXTBOXWIDGET_ATTR_IDS_##aname].name
00041 
00042 // address attribute types
00043 #define GETATTRTYPE(aname) MMSGUI_TEXTBOXWIDGET_ATTR_I[MMSGUI_TEXTBOXWIDGET_ATTR::MMSGUI_TEXTBOXWIDGET_ATTR_IDS_##aname].type
00044 
00045 
00046 MMSTextBoxWidgetClass::MMSTextBoxWidgetClass() {
00047     unsetAll();
00048 }
00049 
00050 void MMSTextBoxWidgetClass::unsetAll() {
00051     this->className = "";
00052     unsetWrap();
00053     unsetSplitWords();
00054     unsetTranslate();
00055     unsetFilePath();
00056     unsetFileName();
00057     MMSTextBaseClass::unsetAll();
00058 }
00059 
00060 void MMSTextBoxWidgetClass::setAttributesFromTAFF(MMSTaffFile *tafff, string *prefix, string *path, bool reset_paths) {
00061     MMSFBColor color;
00062 
00063     if ((reset_paths)&&(path)&&(*path!="")) {
00064         // unset my paths
00065         unsetFontPath();
00066         unsetFilePath();
00067     }
00068 
00069     if (!prefix) {
00070         startTAFFScan
00071         {
00072             switch (attrid) {
00073             case MMSGUI_BASE_ATTR::MMSGUI_BASE_ATTR_IDS_class:
00074                 setClassName(attrval_str);
00075                 break;
00076 
00077             // special macro for font parameters
00078             SET_FONT_FROM_TAFF(MMSGUI_TEXTBOXWIDGET_ATTR)
00079 
00080             // special macro for shadow parameters
00081             SET_SHADOW_FROM_TAFF(MMSGUI_TEXTBOXWIDGET_ATTR)
00082 
00083             // special macro for textinfo parameters
00084             SET_TEXTINFO_FROM_TAFF(MMSGUI_TEXTBOXWIDGET_ATTR)
00085 
00086             case MMSGUI_TEXTBOXWIDGET_ATTR::MMSGUI_TEXTBOXWIDGET_ATTR_IDS_wrap:
00087                 setWrap((attrval_int) ? true : false);
00088                 break;
00089             case MMSGUI_TEXTBOXWIDGET_ATTR::MMSGUI_TEXTBOXWIDGET_ATTR_IDS_splitwords:
00090                 setSplitWords((attrval_int) ? true : false);
00091                 break;
00092             case MMSGUI_TEXTBOXWIDGET_ATTR::MMSGUI_TEXTBOXWIDGET_ATTR_IDS_translate:
00093                 setTranslate((attrval_int)?true:false);
00094                 break;
00095             case MMSGUI_TEXTBOXWIDGET_ATTR::MMSGUI_TEXTBOXWIDGET_ATTR_IDS_file_path:
00096                 if (*attrval_str)
00097                     setFilePath(attrval_str);
00098                 else
00099                     setFilePath((path)?*path:"");
00100                 break;
00101             case MMSGUI_TEXTBOXWIDGET_ATTR::MMSGUI_TEXTBOXWIDGET_ATTR_IDS_file_name:
00102                 setFileName(attrval_str);
00103                 break;
00104             }
00105         }
00106         endTAFFScan
00107     }
00108     else {
00109         unsigned int pl = strlen(prefix->c_str());
00110 
00111         startTAFFScan_WITHOUT_ID
00112         {
00113             // check if attrname has correct prefix
00114             if (pl >= strlen(attrname))
00115                 continue;
00116             if (memcmp(attrname, prefix->c_str(), pl)!=0)
00117                 continue;
00118             attrname = &attrname[pl];
00119 
00120             // special storage for macros
00121             bool attrval_str_valid;
00122             bool int_val_set;
00123             bool byte_val_set;
00124             int  *p_int_val = &attrval_int;
00125 
00126             // okay, correct prefix, check attributes now
00127 
00128             // special macro for font parameters
00129             SET_FONT_FROM_TAFF_WITH_PREFIX(MMSGUI_TEXTBOXWIDGET_ATTR)
00130             else
00131             // special macro for shadow parameters
00132             SET_SHADOW_FROM_TAFF_WITH_PREFIX(MMSGUI_TEXTBOXWIDGET_ATTR)
00133             else
00134             // special macro for textinfo parameters
00135             SET_TEXTINFO_FROM_TAFF_WITH_PREFIX(MMSGUI_TEXTBOXWIDGET_ATTR)
00136             else
00137             if (ISATTRNAME(wrap)) {
00138                 setWrap((attrval_int) ? true : false);
00139             }
00140             else
00141             if (ISATTRNAME(splitwords)) {
00142                 setSplitWords((attrval_int) ? true : false);
00143             }
00144             else
00145             if (ISATTRNAME(translate)) {
00146                 setTranslate((attrval_int)?true:false);
00147             }
00148             else
00149             if (ISATTRNAME(file_path)) {
00150                 if (*attrval_str)
00151                     setFilePath(attrval_str);
00152                 else
00153                     setFilePath((path)?*path:"");
00154             }
00155             else
00156             if (ISATTRNAME(file_name)) {
00157                 setFileName(attrval_str);
00158             }
00159         }
00160         endTAFFScan_WITHOUT_ID
00161     }
00162 
00163     if ((reset_paths)&&(path)&&(*path!="")) {
00164         // set my paths
00165         if (!isFontPath())
00166             setFontPath(*path);
00167         if (!isFilePath())
00168             setFilePath(*path);
00169     }
00170 }
00171 
00172 void MMSTextBoxWidgetClass::setClassName(string className) {
00173     this->className = className;
00174 }
00175 
00176 string MMSTextBoxWidgetClass::getClassName() {
00177     return this->className;
00178 }
00179 
00180 
00181 bool MMSTextBoxWidgetClass::isWrap() {
00182     return this->iswrap;
00183 }
00184 
00185 void MMSTextBoxWidgetClass::setWrap(bool wrap) {
00186     this->wrap = wrap;
00187     this->iswrap = true;
00188 }
00189 
00190 void MMSTextBoxWidgetClass::unsetWrap() {
00191     this->iswrap = false;
00192 }
00193 
00194 bool MMSTextBoxWidgetClass::getWrap() {
00195     return this->wrap;
00196 }
00197 
00198 bool MMSTextBoxWidgetClass::isSplitWords() {
00199     return this->issplitwords;
00200 }
00201 
00202 void MMSTextBoxWidgetClass::setSplitWords(bool splitwords) {
00203     this->splitwords = splitwords;
00204     this->issplitwords = true;
00205 }
00206 
00207 void MMSTextBoxWidgetClass::unsetSplitWords() {
00208     this->issplitwords = false;
00209 }
00210 
00211 bool MMSTextBoxWidgetClass::getSplitWords() {
00212     return this->splitwords;
00213 }
00214 
00215 
00216 bool MMSTextBoxWidgetClass::isTranslate() {
00217     return this->istranslate;
00218 }
00219 
00220 void MMSTextBoxWidgetClass::setTranslate(bool translate) {
00221     this->translate = translate;
00222     this->istranslate = true;
00223 }
00224 
00225 void MMSTextBoxWidgetClass::unsetTranslate() {
00226     this->istranslate = false;
00227 }
00228 
00229 bool MMSTextBoxWidgetClass::getTranslate() {
00230     return this->translate;
00231 }
00232 
00233 bool MMSTextBoxWidgetClass::isFilePath() {
00234     return this->isfilepath;
00235 }
00236 
00237 void MMSTextBoxWidgetClass::setFilePath(string filepath) {
00238     this->filepath = filepath;
00239     this->isfilepath = true;
00240 }
00241 
00242 void MMSTextBoxWidgetClass::unsetFilePath() {
00243     this->isfilepath = false;
00244 }
00245 
00246 string MMSTextBoxWidgetClass::getFilePath() {
00247     return this->filepath;
00248 }
00249 
00250 bool MMSTextBoxWidgetClass::isFileName() {
00251     return this->isfilename;
00252 }
00253 
00254 void MMSTextBoxWidgetClass::setFileName(string filename) {
00255     this->filename = filename;
00256     this->isfilename = true;
00257 }
00258 
00259 void MMSTextBoxWidgetClass::unsetFileName() {
00260     this->isfilename = false;
00261 }
00262 
00263 string MMSTextBoxWidgetClass::getFileName() {
00264     return this->filename;
00265 }
00266 
00267 

Generated by doxygen