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

mmslabelwidget.h

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 #ifndef MMSLABELWIDGET_H_
00034 #define MMSLABELWIDGET_H_
00035 
00036 #include "mmsgui/mmswidget.h"
00037 #include "mmsgui/mmslabelwidgetthread.h"
00038 
00039 //! With this class you can display one line text.
00040 /*!
00041 You can display one line of text. If you want to have more the one line, you should use the MMSTextBox widget.
00042 The label widget cannot be focused.
00043 \author Jens Schneider
00044 */
00045 class MMSLabelWidget : public MMSWidget {
00046 
00047     private:
00048         string              className;
00049         MMSLabelWidgetClass *labelWidgetClass;
00050         MMSLabelWidgetClass myLabelWidgetClass;
00051 
00052         //! language in which the text is to be translated
00053         MMSLanguage lang;
00054 
00055         //! loaded font
00056         MMSFBFont *font;
00057 
00058         //! path to the loaded font file
00059         string fontpath;
00060 
00061         //! name of the loaded font file
00062         string fontname;
00063 
00064         //! requested size of the font
00065         unsigned int fontsize;
00066 
00067         //! have to (re)load font?
00068         bool load_font;
00069 
00070 
00071         int slide_width;
00072         int slide_offset;
00073 
00074         unsigned int frame_delay;
00075         unsigned int frame_delay_set;
00076 
00077         class MMSLabelWidgetThread  *labelThread;
00078 
00079         //! the translated text will be stored here, this is used in the draw() method
00080         string translated_text;
00081 
00082         //! if true the translated_text is valid
00083         bool translated;
00084 
00085         //! swap left-right alignment
00086         bool swap_left_right;
00087 
00088         //! current foreground values set?
00089         bool            current_fgset;
00090 
00091         //! current foreground color
00092         MMSFBColor      current_fgcolor;
00093 
00094         bool create(MMSWindow *root, string className, MMSTheme *theme);
00095 
00096         void initLanguage(MMSLabelWidget *widget = NULL);
00097         void loadFont(MMSLabelWidget *widget = NULL);
00098         bool init();
00099         bool release();
00100 
00101         bool prepareText(int *width, int *height, bool recalc = false);
00102         void calcContentSize();
00103 
00104         void getForeground(MMSFBColor *color);
00105         bool enableRefresh(bool enable = true);
00106         bool checkRefreshStatus();
00107 
00108         bool draw(bool *backgroundFilled = NULL);
00109 
00110         //! Internal method: Inform the widget, that the language has changed.
00111         void targetLangChanged(MMSLanguage lang);
00112 
00113     public:
00114         MMSLabelWidget(MMSWindow *root, string className, MMSTheme *theme = NULL);
00115         ~MMSLabelWidget();
00116 
00117         MMSWidget *copyWidget();
00118 
00119         int getStringWidth(const char *text = NULL);
00120 
00121     public:
00122         /* theme access methods */
00123         string getFontPath();
00124         string getFontName(MMSLanguage lang = MMSLANG_NONE);
00125         unsigned int getFontSize();
00126         MMSALIGNMENT getAlignment();
00127         MMSFBColor getColor();
00128         MMSFBColor getSelColor();
00129         MMSFBColor getColor_p();
00130         MMSFBColor getSelColor_p();
00131         MMSFBColor getColor_i();
00132         MMSFBColor getSelColor_i();
00133         string getText();
00134         void getText(string &text);
00135         bool getSlidable();
00136         unsigned char getSlideSpeed();
00137         bool getTranslate();
00138         MMSFBColor getShadowColor(MMSPOSITION position);
00139         MMSFBColor getSelShadowColor(MMSPOSITION position);
00140 
00141         void setFontPath(string fontpath, bool load = true, bool refresh = true);
00142         void setFontName(MMSLanguage lang, string fontname, bool load = true, bool refresh = true);
00143         void setFontName(string fontname, bool load = true, bool refresh = true);
00144         void setFontSize(unsigned int  fontsize, bool load = true, bool refresh = true);
00145         void setFont(MMSLanguage lang, string fontpath, string fontname, unsigned int fontsize, bool load = true, bool refresh = true);
00146         void setFont(string fontpath, string fontname, unsigned int fontsize, bool load = true, bool refresh = true);
00147         void setAlignment(MMSALIGNMENT alignment, bool refresh = true);
00148         void setColor(MMSFBColor color, bool refresh = true);
00149         void setSelColor(MMSFBColor selcolor, bool refresh = true);
00150         void setColor_p(MMSFBColor color_p, bool refresh = true);
00151         void setSelColor_p(MMSFBColor selcolor_p, bool refresh = true);
00152         void setColor_i(MMSFBColor color_i, bool refresh = true);
00153         void setSelColor_i(MMSFBColor selcolor_i, bool refresh = true);
00154         void setText(string text, bool refresh = true);
00155         void setSlidable(bool slidable);
00156         void setSlideSpeed(unsigned char slidespeed);
00157         void setTranslate(bool translate, bool refresh = true);
00158         void setShadowColor(MMSPOSITION position, MMSFBColor color, bool refresh = true);
00159         void setSelShadowColor(MMSPOSITION position, MMSFBColor selcolor, bool refresh = true);
00160 
00161         void updateFromThemeClass(MMSLabelWidgetClass *themeClass);
00162 
00163     // friends
00164     friend class MMSWindow;
00165     friend class MMSLabelWidgetThread;
00166 };
00167 
00168 #endif /*MMSLABELWIDGET_H_*/

Generated by doxygen