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

mmslabelwidget.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-2012 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/mmslabelwidget.h"
00034 #include "mmsgui/mmstextbase.h"
00035 
00036 
00037 MMSLabelWidget::MMSLabelWidget(MMSWindow *root, string className, MMSTheme *theme) : MMSWidget() {
00038     create(root, className, theme);
00039 }
00040 
00041 MMSLabelWidget::~MMSLabelWidget() {
00042     if (labelThread) {
00043         labelThread->stop();
00044         labelThread=NULL;
00045     }
00046 }
00047 
00048 bool MMSLabelWidget::create(MMSWindow *root, string className, MMSTheme *theme) {
00049     this->type = MMSWIDGETTYPE_LABEL;
00050     this->className = className;
00051 
00052     // init attributes for drawable widgets
00053     this->da = new MMSWIDGET_DRAWABLE_ATTRIBUTES;
00054     if (theme) this->da->theme = theme; else this->da->theme = globalTheme;
00055     this->labelWidgetClass = this->da->theme->getLabelWidgetClass(className);
00056     this->da->baseWidgetClass = &(this->da->theme->labelWidgetClass.widgetClass);
00057     if (this->labelWidgetClass) this->da->widgetClass = &(this->labelWidgetClass->widgetClass); else this->da->widgetClass = NULL;
00058 
00059     // clear
00060     initLanguage();
00061     this->fontpath = "";
00062     this->fontname = "";
00063     this->fontsize = 0;
00064     this->font = NULL;
00065     this->load_font = true;
00066     this->slide_width = 0;
00067     this->slide_offset = 0;
00068     this->frame_delay = 100;
00069     this->frame_delay_set = false;
00070     this->labelThread = NULL;
00071     this->translated = false;
00072     this->swap_left_right = false;
00073     this->current_fgset = false;
00074 
00075     return MMSWidget::create(root, true, false, false, true, false, false, false);
00076 }
00077 
00078 MMSWidget *MMSLabelWidget::copyWidget() {
00079     // create widget
00080     MMSLabelWidget *newWidget = new MMSLabelWidget(this->rootwindow, className);
00081 
00082     newWidget->className = this->className;
00083     newWidget->labelWidgetClass = this->labelWidgetClass;
00084     newWidget->myLabelWidgetClass = this->myLabelWidgetClass;
00085 
00086     newWidget->lang = this->lang;
00087     newWidget->translated_text = this->translated_text;
00088     newWidget->current_fgcolor = this->current_fgcolor;
00089 
00090     // copy base widget
00091     MMSWidget::copyWidget((MMSWidget*)newWidget);
00092 
00093     // reload my font
00094     initLanguage(newWidget);
00095     newWidget->fontpath = "";
00096     newWidget->fontname = "";
00097     newWidget->fontsize = 0;
00098     newWidget->font = NULL;
00099     newWidget->load_font = true;
00100     newWidget->slide_width = 0;
00101     newWidget->slide_offset = 0;
00102     newWidget->frame_delay = 100;
00103     newWidget->frame_delay_set = false;
00104     newWidget->labelThread = NULL;
00105     newWidget->translated = false;
00106     newWidget->swap_left_right = false;
00107     newWidget->current_fgset = false;
00108     if (this->rootwindow) {
00109         // load font
00110         loadFont(newWidget);
00111 
00112         // first time the label thread has to be started
00113         if (newWidget->getSlidable()) {
00114             newWidget->setSlidable(true);
00115         }
00116     }
00117 
00118     return newWidget;
00119 }
00120 
00121 
00122 void MMSLabelWidget::initLanguage(MMSLabelWidget *widget) {
00123     if (!widget) widget = this;
00124 
00125     widget->lang = (!this->rootwindow)?MMSLANG_NONE:this->rootwindow->windowmanager->getTranslator()->getTargetLang();
00126 }
00127 
00128 void MMSLabelWidget::loadFont(MMSLabelWidget *widget) {
00129     if (!this->load_font) return;
00130     if (!widget) widget = this;
00131 
00132     if (this->rootwindow) {
00133         // get font parameter
00134         widget->lang = this->rootwindow->windowmanager->getTranslator()->getTargetLang();
00135         string fontpath = widget->getFontPath();
00136         string fontname = widget->getFontName(widget->lang);
00137         unsigned int fontsize = widget->getFontSize();
00138 
00139         if (fontpath != widget->fontpath || fontname != widget->fontname || fontsize != widget->fontsize || !widget->font) {
00140             // font parameter changed, (re)load it
00141             if (widget->font)
00142                 this->rootwindow->fm->releaseFont(widget->font);
00143             widget->fontpath = fontpath;
00144             widget->fontname = fontname;
00145             widget->fontsize = fontsize;
00146             widget->font = this->rootwindow->fm->getFont(widget->fontpath, widget->fontname, widget->fontsize);
00147             if (widget->font) {
00148                 widget->load_font = false;
00149             }
00150         }
00151         else {
00152             // font parameter not changed, so we do not reload it
00153             widget->load_font = false;
00154         }
00155     }
00156 }
00157 
00158 bool MMSLabelWidget::init() {
00159     // init widget basics
00160     if (!MMSWidget::init())
00161         return false;
00162 
00163     // init language
00164     initLanguage();
00165 
00166     // load font
00167     loadFont();
00168 
00169     // first time the label thread has to be started
00170     if (getSlidable()) {
00171         setSlidable(true);
00172     }
00173 
00174     return true;
00175 }
00176 
00177 bool MMSLabelWidget::release() {
00178     // release widget basics
00179     if (!MMSWidget::release())
00180         return false;
00181 
00182     // release my font
00183     this->rootwindow->fm->releaseFont(this->font);
00184     this->fontpath = "";
00185     this->fontname = "";
00186     this->fontsize = 0;
00187     this->font = NULL;
00188     this->load_font = true;
00189 
00190     return true;
00191 }
00192 
00193 
00194 bool MMSLabelWidget::prepareText(int *width, int *height, bool recalc) {
00195     // check if we have to (re)load the font
00196     this->surface->lock();
00197 
00198     loadFont();
00199 
00200     if (!this->font) {
00201         this->surface->unlock();
00202         return false;
00203     }
00204 
00205     // font available, use it for this surface
00206     this->surface->setFont(this->font);
00207 
00208     this->surface->unlock();
00209 
00210     if (!this->translated) {
00211         // text changed and have to be translated
00212         if ((this->rootwindow)&&(this->rootwindow->windowmanager)&&(getTranslate())) {
00213             // translate text
00214             string source;
00215             getText(source);
00216             this->rootwindow->windowmanager->getTranslator()->translate(source, this->translated_text);
00217         }
00218         else {
00219             // text can not or should not translated
00220             getText(this->translated_text);
00221         }
00222 
00223         // reset swap flag
00224         this->swap_left_right = false;
00225 
00226         // language specific conversions
00227         MMSLanguage targetlang = this->rootwindow->windowmanager->getTranslator()->getTargetLang();
00228         if ((targetlang == MMSLANG_IL) || (targetlang == MMSLANG_AR)) {
00229             if (convBidiString(this->translated_text, this->translated_text), (targetlang == MMSLANG_AR) ? true : false) {
00230                 // bidirectional conversion successful, swap alignment horizontal
00231                 this->swap_left_right = true;
00232             }
00233         }
00234 
00235         // mark as translated
00236         this->translated = true;
00237     }
00238 
00239     // get width and height of the string to be drawn
00240     int realWidth, realHeight;
00241     this->font->getStringWidth(this->translated_text, -1, &realWidth);
00242     this->font->getHeight(&realHeight);
00243 
00244     if (!this->minmax_set) {
00245         if (width)  *width = realWidth;
00246         if (height) *height = realHeight;
00247     }
00248     else {
00249         if (recalc) {
00250             // calculate dynamic label size
00251 
00252             // get maximum width and height of the label
00253             int maxWidth = getMaxWidthPix();
00254             if (maxWidth <= 0) maxWidth = getInnerGeometry().w;
00255             int maxHeight = getMaxHeightPix();
00256             if (maxHeight <= 0) maxHeight = getInnerGeometry().h;
00257 
00258             // get minimum width and height of the label
00259             int minWidth = getMinWidthPix();
00260             int minHeight = getMinHeightPix();
00261 
00262             if (width)  {
00263                 if (realWidth < minWidth)
00264                     *width = minWidth;
00265                 else
00266                 if (realWidth > maxWidth)
00267                     *width = maxWidth;
00268                 else
00269                     *width = realWidth;
00270 
00271                 if (*width <= 0) *width = 1;
00272             }
00273 
00274             if (height) {
00275                 if (realHeight < minHeight)
00276                     *height = minHeight;
00277                 else
00278                 if (realHeight > maxHeight)
00279                     *height = maxHeight;
00280                 else
00281                     *height = realHeight;
00282 
00283                 if (*height <= 0) *height = 1;
00284             }
00285         }
00286         else {
00287             if (width)  *width = realWidth;
00288             if (height) *height = realHeight;
00289         }
00290     }
00291 
00292     return true;
00293 }
00294 
00295 
00296 void MMSLabelWidget::calcContentSize() {
00297     int width, height;
00298 
00299     if (prepareText(&width, &height, true)) {
00300         // text is translated and font is set
00301         setContentSize(width, height);
00302     }
00303 }
00304 
00305 
00306 void MMSLabelWidget::getForeground(MMSFBColor *color) {
00307     color->a = 0;
00308 
00309     if (isActivated()) {
00310         if (isSelected()) {
00311             *color = getSelColor();
00312         }
00313         else {
00314             *color = getColor();
00315         }
00316         if (isPressed()) {
00317             MMSFBColor mycol;
00318             if (isSelected()) {
00319                 mycol = getSelColor_p();
00320                 if (mycol.a>0) *color=mycol;
00321             }
00322             else {
00323                 mycol = getColor_p();
00324                 if (mycol.a>0) *color=mycol;
00325             }
00326         }
00327     }
00328     else {
00329         if (isSelected()) {
00330             *color = getSelColor_i();
00331         }
00332         else {
00333             *color = getColor_i();
00334         }
00335     }
00336 }
00337 
00338 bool MMSLabelWidget::enableRefresh(bool enable) {
00339     if (!MMSWidget::enableRefresh(enable)) return false;
00340 
00341     // mark foreground as not set
00342     this->current_fgset = false;
00343 
00344     return true;
00345 }
00346 
00347 bool MMSLabelWidget::checkRefreshStatus() {
00348     if (MMSWidget::checkRefreshStatus()) return true;
00349 
00350     if (this->current_fgset) {
00351         // current foreground initialized
00352         MMSFBColor color;
00353         getForeground(&color);
00354 
00355         if (color == this->current_fgcolor) {
00356             // foreground color not changed, so we do not enable refreshing
00357             return false;
00358         }
00359     }
00360 
00361     // (re-)enable refreshing
00362     enableRefresh();
00363 
00364     return true;
00365 }
00366 
00367 
00368 bool MMSLabelWidget::draw(bool *backgroundFilled) {
00369     int width, height, x, y;
00370     bool myBackgroundFilled = false;
00371 
00372     if(!surface)
00373         return false;
00374 
00375     if (backgroundFilled) {
00376         if (this->has_own_surface)
00377             *backgroundFilled = false;
00378     }
00379     else
00380         backgroundFilled = &myBackgroundFilled;
00381 
00382     // lock
00383     this->surface->lock();
00384 
00385     // draw widget basics
00386     if (MMSWidget::draw(backgroundFilled)) {
00387         // draw my things
00388         if (prepareText(&width, &height)) {
00389             // text is translated and font is set
00390             MMSFBRectangle surfaceGeom = getSurfaceGeometry();
00391 
00392             // save the width of the text
00393             this->slide_width = width;
00394 
00395             switch ((!this->swap_left_right) ? getAlignment() : swapAlignmentHorizontal(getAlignment())) {
00396                 case MMSALIGNMENT_LEFT:
00397                     x = surfaceGeom.x;
00398                     y = ((surfaceGeom.h - height) / 2) + surfaceGeom.y;
00399                     break;
00400                 case MMSALIGNMENT_RIGHT:
00401                     x = surfaceGeom.x + surfaceGeom.w - width;
00402                     y = ((surfaceGeom.h - height) / 2) + surfaceGeom.y;
00403                     break;
00404                 case MMSALIGNMENT_CENTER:
00405                     x = ((surfaceGeom.w - width) / 2) + surfaceGeom.x;
00406                     y = ((surfaceGeom.h - height) / 2) + surfaceGeom.y;
00407                     break;
00408                 case MMSALIGNMENT_TOP_CENTER:
00409                     x = ((surfaceGeom.w - width) / 2) + surfaceGeom.x;
00410                     y = surfaceGeom.y;
00411                     break;
00412                 case MMSALIGNMENT_TOP_LEFT:
00413                     x = surfaceGeom.x;
00414                     y = surfaceGeom.y;
00415                     break;
00416                 case MMSALIGNMENT_TOP_RIGHT:
00417                     x = surfaceGeom.x + surfaceGeom.w - width;
00418                     y = surfaceGeom.y;
00419                     break;
00420                 case MMSALIGNMENT_BOTTOM_CENTER:
00421                     x = ((surfaceGeom.w - width) / 2) + surfaceGeom.x;
00422                     y = surfaceGeom.y + surfaceGeom.h - height;
00423                     break;
00424                 case MMSALIGNMENT_BOTTOM_LEFT:
00425                     x = surfaceGeom.x;
00426                     y = surfaceGeom.y + surfaceGeom.h - height;
00427                     break;
00428                 case MMSALIGNMENT_BOTTOM_RIGHT:
00429                     x = surfaceGeom.x + surfaceGeom.w - width;
00430                     y = surfaceGeom.y + surfaceGeom.h - height;
00431                     break;
00432                 default:
00433                     x = ((surfaceGeom.w - width) / 2) + surfaceGeom.x;
00434                     y = ((surfaceGeom.h - height) / 2) + surfaceGeom.y;
00435                     break;
00436             }
00437 
00438             // get color
00439             MMSFBColor color;
00440             getForeground(&color);
00441             this->current_fgcolor   = color;
00442             this->current_fgset     = true;
00443 
00444             if (color.a) {
00445                 // prepare for drawing
00446                 this->surface->setDrawingColorAndFlagsByBrightnessAndOpacity(
00447                                     color,
00448                                     (isSelected())?getSelShadowColor(MMSPOSITION_TOP):getShadowColor(MMSPOSITION_TOP),
00449                                     (isSelected())?getSelShadowColor(MMSPOSITION_BOTTOM):getShadowColor(MMSPOSITION_BOTTOM),
00450                                     (isSelected())?getSelShadowColor(MMSPOSITION_LEFT):getShadowColor(MMSPOSITION_LEFT),
00451                                     (isSelected())?getSelShadowColor(MMSPOSITION_RIGHT):getShadowColor(MMSPOSITION_RIGHT),
00452                                     (isSelected())?getSelShadowColor(MMSPOSITION_TOP_LEFT):getShadowColor(MMSPOSITION_TOP_LEFT),
00453                                     (isSelected())?getSelShadowColor(MMSPOSITION_TOP_RIGHT):getShadowColor(MMSPOSITION_TOP_RIGHT),
00454                                     (isSelected())?getSelShadowColor(MMSPOSITION_BOTTOM_LEFT):getShadowColor(MMSPOSITION_BOTTOM_LEFT),
00455                                     (isSelected())?getSelShadowColor(MMSPOSITION_BOTTOM_RIGHT):getShadowColor(MMSPOSITION_BOTTOM_RIGHT),
00456                                     getBrightness(), getOpacity());
00457 
00458                 // draw the text
00459                 this->surface->drawString(this->translated_text, -1, x - this->slide_offset, y);
00460             }
00461         }
00462 
00463         // update window surface with an area of surface
00464         updateWindowSurfaceWithSurface(!*backgroundFilled);
00465     }
00466 
00467     // unlock
00468     this->surface->unlock();
00469 
00470     // draw widgets debug frame
00471     return MMSWidget::drawDebug();
00472 }
00473 
00474 void MMSLabelWidget::targetLangChanged(MMSLanguage lang) {
00475     this->translated = false;
00476     this->load_font = true;
00477 
00478     // recalculate content size for dynamic widgets, because new language can result in new widget size
00479     // note: DO NOT REFRESH at this point
00480     recalcContentSize(false);
00481 }
00482 
00483 
00484 int MMSLabelWidget::getStringWidth(const char *text) {
00485     int realWidth = 0;
00486 
00487     loadFont();
00488     if(text)
00489         this->font->getStringWidth(text, -1, &realWidth);
00490     else
00491         this->font->getStringWidth(this->translated_text, -1, &realWidth);
00492 
00493     return realWidth;
00494 }
00495 
00496 /***********************************************/
00497 /* begin of theme access methods (get methods) */
00498 /***********************************************/
00499 
00500 #define GETLABEL(x) \
00501     if (this->myLabelWidgetClass.is##x()) return myLabelWidgetClass.get##x(); \
00502     else if ((labelWidgetClass)&&(labelWidgetClass->is##x())) return labelWidgetClass->get##x(); \
00503     else return this->da->theme->labelWidgetClass.get##x();
00504 
00505 #define GETLABEL2(x,y) \
00506     if (this->myLabelWidgetClass.is##x()) y=myLabelWidgetClass.get##x(); \
00507     else if ((labelWidgetClass)&&(labelWidgetClass->is##x())) y=labelWidgetClass->get##x(); \
00508     else y=this->da->theme->labelWidgetClass.get##x();
00509 
00510 #define GETLABELFONT(lang) \
00511     if (this->myLabelWidgetClass.isFontName(lang)) return myLabelWidgetClass.getFontName(lang); \
00512     else if (this->myLabelWidgetClass.isFontName(MMSLANG_NONE)) return myLabelWidgetClass.getFontName(MMSLANG_NONE); \
00513     else if ((labelWidgetClass)&&(labelWidgetClass->isFontName(lang))) return labelWidgetClass->getFontName(lang); \
00514     else if ((labelWidgetClass)&&(labelWidgetClass->isFontName(MMSLANG_NONE))) return labelWidgetClass->getFontName(MMSLANG_NONE); \
00515     else return this->da->theme->labelWidgetClass.getFontName();
00516 
00517 #define GETLABELSHADOW(x) \
00518     if (this->myLabelWidgetClass.isShadowColor(x)) return myLabelWidgetClass.getShadowColor(x); \
00519     else if ((labelWidgetClass)&&(labelWidgetClass->isShadowColor(x))) return labelWidgetClass->getShadowColor(x); \
00520     else return this->da->theme->labelWidgetClass.getShadowColor(x);
00521 
00522 #define GETLABELSHADOWSEL(x) \
00523     if (this->myLabelWidgetClass.isSelShadowColor(x)) return myLabelWidgetClass.getSelShadowColor(x); \
00524     else if ((labelWidgetClass)&&(labelWidgetClass->isSelShadowColor(x))) return labelWidgetClass->getSelShadowColor(x); \
00525     else return this->da->theme->labelWidgetClass.getSelShadowColor(x);
00526 
00527 
00528 string MMSLabelWidget::getFontPath() {
00529     GETLABEL(FontPath);
00530 }
00531 
00532 string MMSLabelWidget::getFontName(MMSLanguage lang) {
00533     GETLABELFONT(lang);
00534 }
00535 
00536 unsigned int MMSLabelWidget::getFontSize() {
00537     GETLABEL(FontSize);
00538 }
00539 
00540 MMSALIGNMENT MMSLabelWidget::getAlignment() {
00541     GETLABEL(Alignment);
00542 }
00543 
00544 MMSFBColor MMSLabelWidget::getColor() {
00545     GETLABEL(Color);
00546 }
00547 
00548 MMSFBColor MMSLabelWidget::getSelColor() {
00549     GETLABEL(SelColor);
00550 }
00551 
00552 MMSFBColor MMSLabelWidget::getColor_p() {
00553     GETLABEL(Color_p);
00554 }
00555 
00556 MMSFBColor MMSLabelWidget::getSelColor_p() {
00557     GETLABEL(SelColor_p);
00558 }
00559 
00560 MMSFBColor MMSLabelWidget::getColor_i() {
00561     GETLABEL(Color_i);
00562 }
00563 
00564 MMSFBColor MMSLabelWidget::getSelColor_i() {
00565     GETLABEL(SelColor_i);
00566 }
00567 
00568 string MMSLabelWidget::getText() {
00569     GETLABEL(Text);
00570 }
00571 
00572 void MMSLabelWidget::getText(string &text) {
00573     GETLABEL2(Text, text);
00574 }
00575 
00576 bool MMSLabelWidget::getSlidable() {
00577     GETLABEL(Slidable);
00578 }
00579 
00580 unsigned char MMSLabelWidget::getSlideSpeed() {
00581     GETLABEL(SlideSpeed);
00582 }
00583 
00584 bool MMSLabelWidget::getTranslate() {
00585     GETLABEL(Translate);
00586 }
00587 
00588 
00589 MMSFBColor MMSLabelWidget::getShadowColor(MMSPOSITION position) {
00590     GETLABELSHADOW(position);
00591 }
00592 
00593 MMSFBColor MMSLabelWidget::getSelShadowColor(MMSPOSITION position) {
00594     GETLABELSHADOWSEL(position);
00595 }
00596 
00597 
00598 /***********************************************/
00599 /* begin of theme access methods (set methods) */
00600 /***********************************************/
00601 
00602 void MMSLabelWidget::setFontPath(string fontpath, bool load, bool refresh) {
00603     myLabelWidgetClass.setFontPath(fontpath);
00604     if (load) {
00605         this->load_font = true;
00606         loadFont();
00607     }
00608 
00609     // refresh is required
00610     enableRefresh();
00611 
00612     this->refresh(refresh);
00613 }
00614 
00615 void MMSLabelWidget::setFontName(MMSLanguage lang, string fontname, bool load, bool refresh) {
00616     myLabelWidgetClass.setFontName(fontname, lang);
00617     if (load) {
00618         this->load_font = true;
00619         loadFont();
00620     }
00621 
00622     // refresh is required
00623     enableRefresh();
00624 
00625     this->refresh(refresh);
00626 }
00627 
00628 void MMSLabelWidget::setFontName(string fontname, bool load, bool refresh) {
00629     setFontName(MMSLANG_NONE, fontname, load, refresh);
00630 }
00631 
00632 void MMSLabelWidget::setFontSize(unsigned int fontsize, bool load, bool refresh) {
00633     myLabelWidgetClass.setFontSize(fontsize);
00634     if (load) {
00635         this->load_font = true;
00636         loadFont();
00637     }
00638 
00639     // refresh is required
00640     enableRefresh();
00641 
00642     this->refresh(refresh);
00643 }
00644 
00645 void MMSLabelWidget::setFont(MMSLanguage lang, string fontpath, string fontname, unsigned int fontsize, bool load, bool refresh) {
00646     myLabelWidgetClass.setFontPath(fontpath);
00647     myLabelWidgetClass.setFontName(fontname, lang);
00648     myLabelWidgetClass.setFontSize(fontsize);
00649     if (load) {
00650         this->load_font = true;
00651         loadFont();
00652     }
00653 
00654     // refresh is required
00655     enableRefresh();
00656 
00657     this->refresh(refresh);
00658 }
00659 
00660 void MMSLabelWidget::setFont(string fontpath, string fontname, unsigned int fontsize, bool load, bool refresh) {
00661     setFont(MMSLANG_NONE, fontpath, fontname, fontsize, load, refresh);
00662 }
00663 
00664 void MMSLabelWidget::setAlignment(MMSALIGNMENT alignment, bool refresh) {
00665     myLabelWidgetClass.setAlignment(alignment);
00666 
00667     // refresh is required
00668     enableRefresh();
00669 
00670     this->refresh(refresh);
00671 }
00672 
00673 void MMSLabelWidget::setColor(MMSFBColor color, bool refresh) {
00674     myLabelWidgetClass.setColor(color);
00675 
00676     // refresh required?
00677     enableRefresh((color != this->current_fgcolor));
00678 
00679     this->refresh(refresh);
00680 }
00681 
00682 void MMSLabelWidget::setSelColor(MMSFBColor selcolor, bool refresh) {
00683     myLabelWidgetClass.setSelColor(selcolor);
00684 
00685     // refresh required?
00686     enableRefresh((selcolor != this->current_fgcolor));
00687 
00688     this->refresh(refresh);
00689 }
00690 
00691 void MMSLabelWidget::setColor_p(MMSFBColor color_p, bool refresh) {
00692     myLabelWidgetClass.setColor_p(color_p);
00693 
00694     // refresh required?
00695     enableRefresh((color_p != this->current_fgcolor));
00696 
00697     this->refresh(refresh);
00698 }
00699 
00700 void MMSLabelWidget::setSelColor_p(MMSFBColor selcolor_p, bool refresh) {
00701     myLabelWidgetClass.setSelColor_p(selcolor_p);
00702 
00703     // refresh required?
00704     enableRefresh((selcolor_p != this->current_fgcolor));
00705 
00706     this->refresh(refresh);
00707 }
00708 
00709 void MMSLabelWidget::setColor_i(MMSFBColor color_i, bool refresh) {
00710     myLabelWidgetClass.setColor_i(color_i);
00711 
00712     // refresh required?
00713     enableRefresh((color_i != this->current_fgcolor));
00714 
00715     this->refresh(refresh);
00716 }
00717 
00718 void MMSLabelWidget::setSelColor_i(MMSFBColor selcolor_i, bool refresh) {
00719     myLabelWidgetClass.setSelColor_i(selcolor_i);
00720 
00721     // refresh required?
00722     enableRefresh((selcolor_i != this->current_fgcolor));
00723 
00724     this->refresh(refresh);
00725 }
00726 
00727 
00728 void MMSLabelWidget::setText(string text, bool refresh) {
00729     myLabelWidgetClass.setText(text);
00730     this->translated = false;
00731 
00732     // refresh is required
00733     enableRefresh();
00734 
00735     this->refresh(refresh);
00736 }
00737 
00738 void MMSLabelWidget::setSlidable(bool slidable) {
00739     myLabelWidgetClass.setSlidable(slidable);
00740     if (slidable) {
00741         // text should slide
00742         this->slide_offset = 0;
00743 
00744         if (this->labelThread) {
00745             // toggle pause off
00746             this->labelThread->pause(false);
00747         }
00748         else {
00749             // start a thread
00750             this->labelThread = new MMSLabelWidgetThread(this);
00751             this->labelThread->start();
00752         }
00753     }
00754     else {
00755         // static text
00756         if (labelThread)
00757             labelThread->stop();
00758         this->slide_offset = 0;
00759 
00760         // refresh is required
00761         enableRefresh();
00762 
00763         this->refresh();
00764     }
00765 }
00766 
00767 void MMSLabelWidget::setSlideSpeed(unsigned char slidespeed) {
00768     myLabelWidgetClass.setSlideSpeed(slidespeed);
00769     this->frame_delay = 100;
00770     this->frame_delay_set = false;
00771 }
00772 
00773 void MMSLabelWidget::setTranslate(bool translate, bool refresh) {
00774     myLabelWidgetClass.setTranslate(translate);
00775     this->translated = false;
00776 
00777     // refresh is required
00778     enableRefresh();
00779 
00780     this->refresh(refresh);
00781 }
00782 
00783 
00784 
00785 void MMSLabelWidget::setShadowColor(MMSPOSITION position, MMSFBColor color, bool refresh) {
00786     myLabelWidgetClass.setShadowColor(position, color);
00787 
00788     // refresh is required
00789     enableRefresh();
00790 
00791     this->refresh(refresh);
00792 }
00793 
00794 void MMSLabelWidget::setSelShadowColor(MMSPOSITION position, MMSFBColor selcolor, bool refresh) {
00795     myLabelWidgetClass.setSelShadowColor(position, selcolor);
00796 
00797     // refresh is required
00798     enableRefresh();
00799 
00800     this->refresh(refresh);
00801 }
00802 
00803 
00804 
00805 void MMSLabelWidget::updateFromThemeClass(MMSLabelWidgetClass *themeClass) {
00806 
00807     // update widget-specific settings
00808     if (themeClass->isSlidable())
00809         setSlidable(themeClass->getSlidable());
00810     if (themeClass->isSlideSpeed())
00811         setSlideSpeed(themeClass->getSlideSpeed());
00812     if (themeClass->isTranslate())
00813         setTranslate(themeClass->getTranslate());
00814 
00815     // update base text-specific settings
00816     MMSTEXTBASE_UPDATE_FROM_THEME_CLASS(this, themeClass);
00817 
00818     // update general widget settings
00819     MMSWidget::updateFromThemeClass(&(themeClass->widgetClass));
00820 }
00821 
00822 /***********************************************/
00823 /* end of theme access methods                 */
00824 /***********************************************/

Generated by doxygen