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

mmsinputwidgetclass.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/mmsinputwidgetclass.h"
00034 #include <string.h>
00035 
00036 //store attribute descriptions here
00037 TAFF_ATTRDESC MMSGUI_INPUTWIDGET_ATTR_I[] = MMSGUI_INPUTWIDGET_ATTR_INIT;
00038 
00039 // address attribute names
00040 #define GETATTRNAME(aname) MMSGUI_INPUTWIDGET_ATTR_I[MMSGUI_INPUTWIDGET_ATTR::MMSGUI_INPUTWIDGET_ATTR_IDS_##aname].name
00041 
00042 // address attribute types
00043 #define GETATTRTYPE(aname) MMSGUI_INPUTWIDGET_ATTR_I[MMSGUI_INPUTWIDGET_ATTR::MMSGUI_INPUTWIDGET_ATTR_IDS_##aname].type
00044 
00045 
00046 MMSInputWidgetClass::MMSInputWidgetClass() {
00047     unsetAll();
00048 }
00049 
00050 MMSInputWidgetClass::~MMSInputWidgetClass() {
00051 
00052 }
00053 
00054 void MMSInputWidgetClass::unsetAll() {
00055     this->className = "";
00056     unsetCursorState();
00057     MMSTextBaseClass::unsetAll();
00058 }
00059 
00060 void MMSInputWidgetClass::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     }
00067 
00068     if (!prefix) {
00069         startTAFFScan
00070         {
00071             switch (attrid) {
00072             case MMSGUI_BASE_ATTR::MMSGUI_BASE_ATTR_IDS_class:
00073                 setClassName(attrval_str);
00074                 break;
00075 
00076             // special macro for font parameters
00077             SET_FONT_FROM_TAFF(MMSGUI_INPUTWIDGET_ATTR)
00078 
00079             // special macro for shadow parameters
00080             SET_SHADOW_FROM_TAFF(MMSGUI_INPUTWIDGET_ATTR)
00081 
00082             // special macro for textinfo parameters
00083             SET_TEXTINFO_FROM_TAFF(MMSGUI_INPUTWIDGET_ATTR)
00084 
00085             case MMSGUI_INPUTWIDGET_ATTR::MMSGUI_INPUTWIDGET_ATTR_IDS_cursor_state:
00086                 if ((attrval_int & 0xff) == 0x01)
00087                     setCursorState(MMSSTATE_AUTO);
00088                 else
00089                 if (attrval_int)
00090                     setCursorState(MMSSTATE_TRUE);
00091                 else
00092                     setCursorState(MMSSTATE_FALSE);
00093                 break;
00094             }
00095         }
00096         endTAFFScan
00097     }
00098     else {
00099         unsigned int pl = strlen(prefix->c_str());
00100 
00101         startTAFFScan_WITHOUT_ID
00102         {
00103             // check if attrname has correct prefix
00104             if (pl >= strlen(attrname))
00105                 continue;
00106             if (memcmp(attrname, prefix->c_str(), pl)!=0)
00107                 continue;
00108             attrname = &attrname[pl];
00109 
00110             // special storage for macros
00111             bool attrval_str_valid;
00112             bool int_val_set;
00113             bool byte_val_set;
00114             int  *p_int_val = &attrval_int;
00115 
00116             // okay, correct prefix, check attributes now
00117 
00118             // special macro for font parameters
00119             SET_FONT_FROM_TAFF_WITH_PREFIX(MMSGUI_INPUTWIDGET_ATTR)
00120             else
00121             // special macro for shadow parameters
00122             SET_SHADOW_FROM_TAFF_WITH_PREFIX(MMSGUI_INPUTWIDGET_ATTR)
00123             else
00124             // special macro for textinfo parameters
00125             SET_TEXTINFO_FROM_TAFF_WITH_PREFIX(MMSGUI_INPUTWIDGET_ATTR)
00126             else
00127             if (ISATTRNAME(cursor_state)) {
00128                 if ((attrval_int & 0xff) == 0x01)
00129                     setCursorState(MMSSTATE_AUTO);
00130                 else
00131                 if (attrval_int)
00132                     setCursorState(MMSSTATE_TRUE);
00133                 else
00134                     setCursorState(MMSSTATE_FALSE);
00135                 break;
00136             }
00137         }
00138         endTAFFScan_WITHOUT_ID
00139     }
00140 
00141     if ((reset_paths)&&(path)&&(*path!="")) {
00142         // set my paths
00143         if (!isFontPath())
00144             setFontPath(*path);
00145     }
00146 }
00147 
00148 void MMSInputWidgetClass::setClassName(string className) {
00149     this->className = className;
00150 }
00151 
00152 string MMSInputWidgetClass::getClassName() {
00153     return this->className;
00154 }
00155 
00156 bool MMSInputWidgetClass::isCursorState() {
00157     return this->iscursor_state;
00158 }
00159 
00160 void MMSInputWidgetClass::setCursorState(MMSSTATE cursor_state) {
00161     this->cursor_state = cursor_state;
00162     this->iscursor_state = true;
00163 }
00164 
00165 void MMSInputWidgetClass::unsetCursorState() {
00166     this->iscursor_state = false;
00167 }
00168 
00169 MMSSTATE MMSInputWidgetClass::getCursorState() {
00170     return this->cursor_state;
00171 }
00172 

Generated by doxygen