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

mmsinputwidget.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/mmsinputwidget.h"
00034 #include "mmsgui/mmsinputwidgetthread.h"
00035 #include "mmsgui/mmstextbase.h"
00036 
00037 
00038 MMSInputWidget::MMSInputWidget(MMSWindow *root, string className, MMSTheme *theme) : MMSWidget() {
00039     // initialize the callbacks
00040     this->onBeforeChange = new sigc::signal<bool, MMSWidget*, string, bool, MMSFBRectangle>::accumulated<bool_accumulator>;
00041 
00042     create(root, className, theme);
00043 }
00044 
00045 MMSInputWidget::~MMSInputWidget() {
00046     // delete the callbacks
00047     if (this->onBeforeChange)
00048         delete this->onBeforeChange;
00049 
00050     if (this->iwt)
00051         delete this->iwt;
00052 }
00053 
00054 bool MMSInputWidget::create(MMSWindow *root, string className, MMSTheme *theme) {
00055     this->type = MMSWIDGETTYPE_INPUT;
00056     this->className = className;
00057 
00058     // init attributes for drawable widgets
00059     this->da = new MMSWIDGET_DRAWABLE_ATTRIBUTES;
00060     if (theme) this->da->theme = theme; else this->da->theme = globalTheme;
00061     this->inputWidgetClass = this->da->theme->getInputWidgetClass(className);
00062     this->da->baseWidgetClass = &(this->da->theme->inputWidgetClass.widgetClass);
00063     if (this->inputWidgetClass) this->da->widgetClass = &(this->inputWidgetClass->widgetClass); else this->da->widgetClass = NULL;
00064 
00065     // clear
00066     initLanguage();
00067     this->fontpath = "";
00068     this->fontname = "";
00069     this->fontsize = 0;
00070     this->font = NULL;
00071     this->load_font = true;
00072     this->cursor_pos = 0;
00073     this->cursor_on = true;
00074     this->scroll_x = 0;
00075 
00076     // create thread
00077     this->iwt = new MMSInputWidgetThread(this);
00078     if (this->iwt)
00079         this->iwt->start();
00080 
00081     this->current_fgset = false;
00082 
00083     return MMSWidget::create(root, true, false, true, true, false, false, true);
00084 }
00085 
00086 MMSWidget *MMSInputWidget::copyWidget() {
00087     // create widget
00088     MMSInputWidget *newWidget = new MMSInputWidget(this->rootwindow, className);
00089 
00090     newWidget->className = this->className;
00091     newWidget->inputWidgetClass = this->inputWidgetClass;
00092     newWidget->myInputWidgetClass = this->myInputWidgetClass;
00093 
00094     newWidget->lang = this->lang;
00095 
00096     newWidget->cursor_pos = this->cursor_pos;
00097     newWidget->cursor_on = this->cursor_on;
00098     newWidget->scroll_x = this->scroll_x;
00099     newWidget->cursor_rect = this->cursor_rect;
00100 
00101     newWidget->iwt = this->iwt;
00102 
00103     newWidget->current_fgset = this->current_fgset;
00104     newWidget->current_fgcolor = this->current_fgcolor;
00105 
00106     // copy base widget
00107     MMSWidget::copyWidget((MMSWidget*)newWidget);
00108 
00109     // initialize the callbacks
00110     this->onBeforeChange = new sigc::signal<bool, MMSWidget*, string, bool, MMSFBRectangle>::accumulated<bool_accumulator>;
00111 
00112     // reload my font
00113     initLanguage(newWidget);
00114     newWidget->fontpath = "";
00115     newWidget->fontname = "";
00116     newWidget->fontsize = 0;
00117     newWidget->font = NULL;
00118     newWidget->load_font = true;
00119     if (this->rootwindow) {
00120         // load font
00121         loadFont(newWidget);
00122     }
00123 
00124     return newWidget;
00125 }
00126 
00127 void MMSInputWidget::initLanguage(MMSInputWidget *widget) {
00128     if (!widget) widget = this;
00129 
00130     widget->lang = (!this->rootwindow)?MMSLANG_NONE:this->rootwindow->windowmanager->getTranslator()->getTargetLang();
00131 }
00132 
00133 void MMSInputWidget::loadFont(MMSInputWidget *widget) {
00134     if (!this->load_font) return;
00135     if (!widget) widget = this;
00136 
00137     if (this->rootwindow) {
00138         // get font parameter
00139         widget->lang = this->rootwindow->windowmanager->getTranslator()->getTargetLang();
00140         if (widget->font) this->rootwindow->fm->releaseFont(widget->font);
00141         widget->fontpath = widget->getFontPath();
00142         widget->fontname = widget->getFontName(widget->lang);
00143         widget->fontsize = widget->getFontSize();
00144         widget->font = this->rootwindow->fm->getFont(widget->fontpath, widget->fontname, widget->fontsize);
00145         if (widget->font) widget->load_font = false;
00146     }
00147 }
00148 
00149 bool MMSInputWidget::init() {
00150     // init widget basics
00151     if (!MMSWidget::init())
00152         return false;
00153 
00154     // init language
00155     initLanguage();
00156 
00157     // load font
00158     loadFont();
00159 
00160     return true;
00161 }
00162 
00163 bool MMSInputWidget::release() {
00164     // release widget basics
00165     if (!MMSWidget::release())
00166         return false;
00167 
00168     // release my font
00169     this->rootwindow->fm->releaseFont(this->font);
00170     this->fontpath = "";
00171     this->fontname = "";
00172     this->fontsize = 0;
00173     this->font = NULL;
00174     this->load_font = true;
00175 
00176     return true;
00177 }
00178 
00179 void MMSInputWidget::getForeground(MMSFBColor *color) {
00180     color->a = 0;
00181 
00182     if (isActivated()) {
00183         if (isSelected()) {
00184             *color = getSelColor();
00185         }
00186         else {
00187             *color = getColor();
00188         }
00189         if (isPressed()) {
00190             MMSFBColor mycol;
00191             if (isSelected()) {
00192                 mycol = getSelColor_p();
00193                 if (mycol.a>0) *color=mycol;
00194             }
00195             else {
00196                 mycol = getColor_p();
00197                 if (mycol.a>0) *color=mycol;
00198             }
00199         }
00200     }
00201     else {
00202         if (isSelected()) {
00203             *color = getSelColor_i();
00204         }
00205         else {
00206             *color = getColor_i();
00207         }
00208     }
00209 }
00210 
00211 bool MMSInputWidget::enableRefresh(bool enable) {
00212     if (!MMSWidget::enableRefresh(enable)) return false;
00213 
00214     // mark foreground as not set
00215     this->current_fgset = false;
00216 
00217     return true;
00218 }
00219 
00220 bool MMSInputWidget::checkRefreshStatus() {
00221     if (MMSWidget::checkRefreshStatus()) return true;
00222 
00223     if (this->current_fgset) {
00224         // current foreground initialized
00225         MMSFBColor color;
00226         getForeground(&color);
00227 
00228         if (color == this->current_fgcolor) {
00229             // foreground color not changed, so we do not enable refreshing
00230             return false;
00231         }
00232     }
00233 
00234     // (re-)enable refreshing
00235     enableRefresh();
00236 
00237     return true;
00238 }
00239 
00240 
00241 bool MMSInputWidget::draw(bool *backgroundFilled) {
00242     bool myBackgroundFilled = false;
00243 
00244     if(!surface)
00245         return false;
00246 
00247     if (backgroundFilled) {
00248         if (this->has_own_surface)
00249             *backgroundFilled = false;
00250     }
00251     else
00252         backgroundFilled = &myBackgroundFilled;
00253 
00254     // lock
00255     this->surface->lock();
00256 
00257     // draw widget basics
00258     if (MMSWidget::draw(backgroundFilled)) {
00259         int width, height, x, y = 0;
00260         int cursor_x=0, cursor_w = 4;
00261 
00262         // check if we have to (re)load the font
00263         loadFont();
00264 
00265         // draw my things
00266         if (this->font) {
00267             MMSFBRectangle surfaceGeom = getSurfaceGeometry();
00268 
00269             this->surface->setFont(this->font);
00270 
00271             string text = getText();
00272 
00273             // language specific conversions
00274             MMSLanguage targetlang = this->rootwindow->windowmanager->getTranslator()->getTargetLang();
00275             if ((targetlang == MMSLANG_IL) || (targetlang == MMSLANG_AR)) {
00276                 convBidiString(text, text, (targetlang == MMSLANG_AR) ? true : false);
00277             }
00278 
00279             // get width and height of the string to be drawn
00280             this->font->getStringWidth(text, -1, &width);
00281             this->font->getHeight(&height);
00282 
00283             // calc cursor position
00284             if (text.size() < (unsigned int)this->cursor_pos)
00285                 cursor_x = width;
00286             else
00287                 this->font->getStringWidth(text.substr(0,this->cursor_pos), -1, &cursor_x);
00288 
00289             MMSALIGNMENT alignment = getAlignment();
00290             switch (alignment) {
00291                 case MMSALIGNMENT_LEFT:
00292                 case MMSALIGNMENT_TOP_LEFT:
00293                 case MMSALIGNMENT_BOTTOM_LEFT:
00294                 default:
00295                     if (cursor_x + cursor_w + scroll_x > surfaceGeom.w)
00296                         // move text to the left
00297                         scroll_x-= cursor_x + cursor_w + scroll_x - surfaceGeom.w;
00298                     else
00299                     if (scroll_x < 0) {
00300                         // move text to the right
00301                         scroll_x+= surfaceGeom.w - (cursor_x + cursor_w + scroll_x);
00302                         if (scroll_x > 0)
00303                             scroll_x = 0;
00304                     }
00305                     x = surfaceGeom.x + scroll_x;
00306                     cursor_x+=scroll_x;
00307                     switch (alignment) {
00308                         case MMSALIGNMENT_LEFT:
00309                         default:
00310                             y = ((surfaceGeom.h - height) / 2) + surfaceGeom.y;
00311                             break;
00312                         case MMSALIGNMENT_TOP_LEFT:
00313                             y = surfaceGeom.y;
00314                             break;
00315                         case MMSALIGNMENT_BOTTOM_LEFT:
00316                             y = surfaceGeom.y + surfaceGeom.h - height;
00317                             break;
00318                     }
00319                     break;
00320                 case MMSALIGNMENT_RIGHT:
00321                 case MMSALIGNMENT_TOP_RIGHT:
00322                 case MMSALIGNMENT_BOTTOM_RIGHT:
00323                     if (cursor_x + scroll_x > surfaceGeom.w)
00324                         // move text to the left
00325                         scroll_x-= cursor_x + scroll_x - surfaceGeom.w;
00326                     else
00327                     if (scroll_x < 0) {
00328                         // move text to the right
00329                         scroll_x+= surfaceGeom.w - (cursor_x + cursor_w + scroll_x);
00330                         if (scroll_x > 0)
00331                             scroll_x = 0;
00332                     }
00333                     x = surfaceGeom.x + surfaceGeom.w - width - cursor_w;
00334                     cursor_x+=surfaceGeom.w - width - cursor_w;
00335                     if (cursor_x < 0) {
00336                         x-=cursor_x;
00337                         cursor_x = 0;
00338                     }
00339                     switch (alignment) {
00340                         case MMSALIGNMENT_RIGHT:
00341                             y = ((surfaceGeom.h - height) / 2) + surfaceGeom.y;
00342                             break;
00343                         case MMSALIGNMENT_TOP_RIGHT:
00344                             y = surfaceGeom.y;
00345                             break;
00346                         case MMSALIGNMENT_BOTTOM_RIGHT:
00347                             y = surfaceGeom.y + surfaceGeom.h - height;
00348                             break;
00349                         default:
00350                             break;
00351                     }
00352                     break;
00353                 case MMSALIGNMENT_CENTER:
00354                 case MMSALIGNMENT_TOP_CENTER:
00355                 case MMSALIGNMENT_BOTTOM_CENTER:
00356                     x = surfaceGeom.x + ((surfaceGeom.w - width) / 2) - cursor_w;
00357                     cursor_x+=((surfaceGeom.w - width) / 2) - cursor_w;
00358                     if (cursor_x < 0) {
00359                         x-=cursor_x;
00360                         cursor_x = 0;
00361                     }
00362                     switch (alignment) {
00363                         case MMSALIGNMENT_CENTER:
00364                             y = ((surfaceGeom.h - height) / 2) + surfaceGeom.y;
00365                             break;
00366                         case MMSALIGNMENT_TOP_CENTER:
00367                             y = surfaceGeom.y;
00368                             break;
00369                         case MMSALIGNMENT_BOTTOM_CENTER:
00370                             y = surfaceGeom.y + surfaceGeom.h - height;
00371                             break;
00372                         default:
00373                             break;
00374                     }
00375                     break;
00376             }
00377 
00378 
00379             // get color
00380             MMSFBColor color;
00381             getForeground(&color);
00382             this->current_fgcolor   = color;
00383             this->current_fgset     = true;
00384 
00385             if (color.a) {
00386                 // prepare for drawing
00387                 this->surface->setDrawingColorAndFlagsByBrightnessAndOpacity(
00388                                     color,
00389                                     (isSelected())?getSelShadowColor(MMSPOSITION_TOP):getShadowColor(MMSPOSITION_TOP),
00390                                     (isSelected())?getSelShadowColor(MMSPOSITION_BOTTOM):getShadowColor(MMSPOSITION_BOTTOM),
00391                                     (isSelected())?getSelShadowColor(MMSPOSITION_LEFT):getShadowColor(MMSPOSITION_LEFT),
00392                                     (isSelected())?getSelShadowColor(MMSPOSITION_RIGHT):getShadowColor(MMSPOSITION_RIGHT),
00393                                     (isSelected())?getSelShadowColor(MMSPOSITION_TOP_LEFT):getShadowColor(MMSPOSITION_TOP_LEFT),
00394                                     (isSelected())?getSelShadowColor(MMSPOSITION_TOP_RIGHT):getShadowColor(MMSPOSITION_TOP_RIGHT),
00395                                     (isSelected())?getSelShadowColor(MMSPOSITION_BOTTOM_LEFT):getShadowColor(MMSPOSITION_BOTTOM_LEFT),
00396                                     (isSelected())?getSelShadowColor(MMSPOSITION_BOTTOM_RIGHT):getShadowColor(MMSPOSITION_BOTTOM_RIGHT),
00397                                     getBrightness(), getOpacity());
00398 
00399                 // draw the text
00400                 this->surface->drawString(text, -1, x, y);
00401             }
00402 
00403             // get cursor rect
00404             this->cursor_rect.x = cursor_x;
00405             this->cursor_rect.y = y;
00406             this->cursor_rect.w = cursor_w;
00407             this->cursor_rect.h = height;
00408 
00409             if (this->cursor_on) {
00410                 // draw the cursor
00411                 MMSSTATE cursor_state = getCursorState();
00412                 if ((cursor_state == MMSSTATE_TRUE)||((cursor_state == MMSSTATE_AUTO) && isFocused())) {
00413                     this->surface->drawRectangle(cursor_x, y, cursor_w, height);
00414                 }
00415             }
00416         }
00417 
00418         // update window surface with an area of surface
00419         updateWindowSurfaceWithSurface(!*backgroundFilled);
00420     }
00421 
00422     // unlock
00423     this->surface->unlock();
00424 
00425     // draw widgets debug frame
00426     return MMSWidget::drawDebug();
00427 }
00428 
00429 void MMSInputWidget::drawCursor(bool cursor_on) {
00430     // show/hide the cursor
00431     this->cursor_on = cursor_on;
00432     MMSSTATE cursor_state = getCursorState();
00433     if ((cursor_state == MMSSTATE_TRUE)||((cursor_state == MMSSTATE_AUTO) && isFocused())) {
00434         // refresh is required
00435         enableRefresh();
00436 
00437         // refresh only, if cursor should be shown
00438         refresh();
00439     }
00440 }
00441 
00442 void MMSInputWidget::targetLangChanged(MMSLanguage lang) {
00443     this->load_font = true;
00444     loadFont();
00445 
00446     // recalculate content size for dynamic widgets, because new language can result in new widget size
00447     // note: DO NOT REFRESH at this point
00448     recalcContentSize(false);
00449 }
00450 
00451 void MMSInputWidget::setCursorPos(int cursor_pos, bool refresh) {
00452     if (cursor_pos < 0) {
00453         // out of range
00454         this->cursor_pos = 0;
00455         return;
00456     }
00457 
00458     string text = getText();
00459     if (text.size() >= (unsigned int)cursor_pos)
00460         // okay, set it
00461         this->cursor_pos = cursor_pos;
00462     else
00463         // out of range
00464         this->cursor_pos = text.size();
00465 
00466     // refresh is required
00467     enableRefresh();
00468 
00469     this->refresh(refresh);
00470 }
00471 
00472 bool MMSInputWidget::addTextAfterCursorPos(string text, bool refresh) {
00473     // something to add?
00474     if (text=="") return false;
00475     int textlen = text.size();
00476 
00477     // check if the change is accepted
00478     if (!this->onBeforeChange->emit(this, text, true, cursor_rect))
00479         return false;
00480 
00481     string oldtext;
00482     getText(oldtext);
00483     if (oldtext.size() < (unsigned int)this->cursor_pos)
00484         this->cursor_pos = oldtext.size();
00485 
00486     // insert the text and change the cursor position
00487     this->cursor_pos+=textlen;
00488     setText(oldtext.substr(0,this->cursor_pos-textlen) + text + oldtext.substr(this->cursor_pos-textlen), refresh, false);
00489 
00490     return true;
00491 }
00492 
00493 bool MMSInputWidget::removeTextBeforeCursorPos(int textlen, bool refresh) {
00494     // something to remove?
00495     if (textlen<=0) return false;
00496     if (this->cursor_pos<=0) return false;
00497 
00498     // check pos
00499     string text;
00500     getText(text);
00501     if (text.size() < (unsigned int)this->cursor_pos)
00502         this->cursor_pos = text.size();
00503 
00504     if (this->cursor_pos <= textlen)
00505         textlen = this->cursor_pos;
00506 
00507     // check if the change is accepted
00508     string rmtext = text.substr(this->cursor_pos - textlen, textlen);
00509     if (!this->onBeforeChange->emit(this, rmtext, false, cursor_rect))
00510         return false;
00511 
00512     //remove a part of the text
00513     this->cursor_pos-=textlen;
00514     setText(text.substr(0,this->cursor_pos) + text.substr(this->cursor_pos+textlen), refresh, false);
00515 
00516     return true;
00517 }
00518 
00519 void MMSInputWidget::handleInput(MMSInputEvent *inputevent) {
00520     bool processed = false;
00521 
00522     if (inputevent->type == MMSINPUTEVENTTYPE_KEYPRESS) {
00523         // keyboard inputs
00524 
00525         // save last inputevent
00526         this->da->last_inputevent = *inputevent;
00527 
00528         processed = true;
00529         switch (inputevent->key) {
00530             case MMSKEY_CURSOR_RIGHT:
00531                 setCursorPos(this->cursor_pos+1);
00532                 break;
00533             case MMSKEY_CURSOR_LEFT:
00534                 setCursorPos(this->cursor_pos-1);
00535                 break;
00536             case MMSKEY_BACKSPACE:
00537                 removeTextBeforeCursorPos(1);
00538                 break;
00539             case MMSKEY_HOME:
00540                 setCursorPos(0);
00541                 break;
00542             case MMSKEY_END:
00543                 setCursorPos(0xffff);
00544                 break;
00545             case MMSKEY_SPACE:
00546                 addTextAfterCursorPos(" ");
00547                 break;
00548             case MMSKEY_PLUS_SIGN:
00549                 addTextAfterCursorPos("+");
00550                 break;
00551             case MMSKEY_MINUS_SIGN:
00552                 addTextAfterCursorPos("-");
00553                 break;
00554             case MMSKEY_PERIOD:
00555                 addTextAfterCursorPos(".");
00556                 break;
00557             case MMSKEY_SLASH:
00558                 addTextAfterCursorPos("/");
00559                 break;
00560             case MMSKEY_UNDERSCORE:
00561                 addTextAfterCursorPos("_");
00562                 break;
00563             case MMSKEY_0:
00564                 addTextAfterCursorPos("0");
00565                 break;
00566             case MMSKEY_1:
00567                 addTextAfterCursorPos("1");
00568                 break;
00569             case MMSKEY_2:
00570                 addTextAfterCursorPos("2");
00571                 break;
00572             case MMSKEY_3:
00573                 addTextAfterCursorPos("3");
00574                 break;
00575             case MMSKEY_4:
00576                 addTextAfterCursorPos("4");
00577                 break;
00578             case MMSKEY_5:
00579                 addTextAfterCursorPos("5");
00580                 break;
00581             case MMSKEY_6:
00582                 addTextAfterCursorPos("6");
00583                 break;
00584             case MMSKEY_7:
00585                 addTextAfterCursorPos("7");
00586                 break;
00587             case MMSKEY_8:
00588                 addTextAfterCursorPos("8");
00589                 break;
00590             case MMSKEY_9:
00591                 addTextAfterCursorPos("9");
00592                 break;
00593             case MMSKEY_CAPITAL_A:
00594                 addTextAfterCursorPos("A");
00595                 break;
00596             case MMSKEY_CAPITAL_B:
00597                 addTextAfterCursorPos("B");
00598                 break;
00599             case MMSKEY_CAPITAL_C:
00600                 addTextAfterCursorPos("C");
00601                 break;
00602             case MMSKEY_CAPITAL_D:
00603                 addTextAfterCursorPos("D");
00604                 break;
00605             case MMSKEY_CAPITAL_E:
00606                 addTextAfterCursorPos("E");
00607                 break;
00608             case MMSKEY_CAPITAL_F:
00609                 addTextAfterCursorPos("F");
00610                 break;
00611             case MMSKEY_CAPITAL_G:
00612                 addTextAfterCursorPos("G");
00613                 break;
00614             case MMSKEY_CAPITAL_H:
00615                 addTextAfterCursorPos("H");
00616                 break;
00617             case MMSKEY_CAPITAL_I:
00618                 addTextAfterCursorPos("I");
00619                 break;
00620             case MMSKEY_CAPITAL_J:
00621                 addTextAfterCursorPos("J");
00622                 break;
00623             case MMSKEY_CAPITAL_K:
00624                 addTextAfterCursorPos("K");
00625                 break;
00626             case MMSKEY_CAPITAL_L:
00627                 addTextAfterCursorPos("L");
00628                 break;
00629             case MMSKEY_CAPITAL_M:
00630                 addTextAfterCursorPos("M");
00631                 break;
00632             case MMSKEY_CAPITAL_N:
00633                 addTextAfterCursorPos("N");
00634                 break;
00635             case MMSKEY_CAPITAL_O:
00636                 addTextAfterCursorPos("O");
00637                 break;
00638             case MMSKEY_CAPITAL_P:
00639                 addTextAfterCursorPos("P");
00640                 break;
00641             case MMSKEY_CAPITAL_Q:
00642                 addTextAfterCursorPos("Q");
00643                 break;
00644             case MMSKEY_CAPITAL_R:
00645                 addTextAfterCursorPos("R");
00646                 break;
00647             case MMSKEY_CAPITAL_S:
00648                 addTextAfterCursorPos("S");
00649                 break;
00650             case MMSKEY_CAPITAL_T:
00651                 addTextAfterCursorPos("T");
00652                 break;
00653             case MMSKEY_CAPITAL_U:
00654                 addTextAfterCursorPos("U");
00655                 break;
00656             case MMSKEY_CAPITAL_V:
00657                 addTextAfterCursorPos("V");
00658                 break;
00659             case MMSKEY_CAPITAL_W:
00660                 addTextAfterCursorPos("W");
00661                 break;
00662             case MMSKEY_CAPITAL_X:
00663                 addTextAfterCursorPos("X");
00664                 break;
00665             case MMSKEY_CAPITAL_Y:
00666                 addTextAfterCursorPos("Y");
00667                 break;
00668             case MMSKEY_CAPITAL_Z:
00669                 addTextAfterCursorPos("Z");
00670                 break;
00671             case MMSKEY_SMALL_A:
00672                 addTextAfterCursorPos("a");
00673                 break;
00674             case MMSKEY_SMALL_B:
00675                 addTextAfterCursorPos("b");
00676                 break;
00677             case MMSKEY_SMALL_C:
00678                 addTextAfterCursorPos("c");
00679                 break;
00680             case MMSKEY_SMALL_D:
00681                 addTextAfterCursorPos("d");
00682                 break;
00683             case MMSKEY_SMALL_E:
00684                 addTextAfterCursorPos("e");
00685                 break;
00686             case MMSKEY_SMALL_F:
00687                 addTextAfterCursorPos("f");
00688                 break;
00689             case MMSKEY_SMALL_G:
00690                 addTextAfterCursorPos("g");
00691                 break;
00692             case MMSKEY_SMALL_H:
00693                 addTextAfterCursorPos("h");
00694                 break;
00695             case MMSKEY_SMALL_I:
00696                 addTextAfterCursorPos("i");
00697                 break;
00698             case MMSKEY_SMALL_J:
00699                 addTextAfterCursorPos("j");
00700                 break;
00701             case MMSKEY_SMALL_K:
00702                 addTextAfterCursorPos("k");
00703                 break;
00704             case MMSKEY_SMALL_L:
00705                 addTextAfterCursorPos("l");
00706                 break;
00707             case MMSKEY_SMALL_M:
00708                 addTextAfterCursorPos("m");
00709                 break;
00710             case MMSKEY_SMALL_N:
00711                 addTextAfterCursorPos("n");
00712                 break;
00713             case MMSKEY_SMALL_O:
00714                 addTextAfterCursorPos("o");
00715                 break;
00716             case MMSKEY_SMALL_P:
00717                 addTextAfterCursorPos("p");
00718                 break;
00719             case MMSKEY_SMALL_Q:
00720                 addTextAfterCursorPos("q");
00721                 break;
00722             case MMSKEY_SMALL_R:
00723                 addTextAfterCursorPos("r");
00724                 break;
00725             case MMSKEY_SMALL_S:
00726                 addTextAfterCursorPos("s");
00727                 break;
00728             case MMSKEY_SMALL_T:
00729                 addTextAfterCursorPos("t");
00730                 break;
00731             case MMSKEY_SMALL_U:
00732                 addTextAfterCursorPos("u");
00733                 break;
00734             case MMSKEY_SMALL_V:
00735                 addTextAfterCursorPos("v");
00736                 break;
00737             case MMSKEY_SMALL_W:
00738                 addTextAfterCursorPos("w");
00739                 break;
00740             case MMSKEY_SMALL_X:
00741                 addTextAfterCursorPos("x");
00742                 break;
00743             case MMSKEY_SMALL_Y:
00744                 addTextAfterCursorPos("y");
00745                 break;
00746             case MMSKEY_SMALL_Z:
00747                 addTextAfterCursorPos("z");
00748                 break;
00749 
00750             default:
00751                 processed = false;
00752                 break;
00753         }
00754     }
00755 
00756     // not processed, call base widget
00757     if (!processed)
00758         MMSWidget::handleInput(inputevent);
00759 }
00760 
00761 
00762 /***********************************************/
00763 /* begin of theme access methods (get methods) */
00764 /***********************************************/
00765 
00766 #define GETINPUT(x) \
00767     if (this->myInputWidgetClass.is##x()) return myInputWidgetClass.get##x(); \
00768     else if ((inputWidgetClass)&&(inputWidgetClass->is##x())) return inputWidgetClass->get##x(); \
00769     else return this->da->theme->inputWidgetClass.get##x();
00770 
00771 #define GETINPUT2(x, y) \
00772     if (this->myInputWidgetClass.is##x()) y=myInputWidgetClass.get##x(); \
00773     else if ((inputWidgetClass)&&(inputWidgetClass->is##x())) y=inputWidgetClass->get##x(); \
00774     else y=this->da->theme->inputWidgetClass.get##x();
00775 
00776 #define GETINPUTFONT(lang) \
00777     if (this->myInputWidgetClass.isFontName(lang)) return myInputWidgetClass.getFontName(lang); \
00778     else if (this->myInputWidgetClass.isFontName(MMSLANG_NONE)) return myInputWidgetClass.getFontName(MMSLANG_NONE); \
00779     else if ((inputWidgetClass)&&(inputWidgetClass->isFontName(lang))) return inputWidgetClass->getFontName(lang); \
00780     else if ((inputWidgetClass)&&(inputWidgetClass->isFontName(MMSLANG_NONE))) return inputWidgetClass->getFontName(MMSLANG_NONE); \
00781     else return this->da->theme->inputWidgetClass.getFontName();
00782 
00783 #define GETINPUTSHADOW(x) \
00784     if (this->myInputWidgetClass.isShadowColor(x)) return myInputWidgetClass.getShadowColor(x); \
00785     else if ((inputWidgetClass)&&(inputWidgetClass->isShadowColor(x))) return inputWidgetClass->getShadowColor(x); \
00786     else return this->da->theme->inputWidgetClass.getShadowColor(x);
00787 
00788 #define GETINPUTSHADOWSEL(x) \
00789     if (this->myInputWidgetClass.isSelShadowColor(x)) return myInputWidgetClass.getSelShadowColor(x); \
00790     else if ((inputWidgetClass)&&(inputWidgetClass->isSelShadowColor(x))) return inputWidgetClass->getSelShadowColor(x); \
00791     else return this->da->theme->inputWidgetClass.getSelShadowColor(x);
00792 
00793 string MMSInputWidget::getFontPath() {
00794     GETINPUT(FontPath);
00795 }
00796 
00797 string MMSInputWidget::getFontName(MMSLanguage lang) {
00798     GETINPUTFONT(lang);
00799 }
00800 
00801 unsigned int MMSInputWidget::getFontSize() {
00802     GETINPUT(FontSize);
00803 }
00804 
00805 MMSALIGNMENT MMSInputWidget::getAlignment() {
00806     GETINPUT(Alignment);
00807 }
00808 
00809 MMSFBColor MMSInputWidget::getColor() {
00810     GETINPUT(Color);
00811 }
00812 
00813 MMSFBColor MMSInputWidget::getSelColor() {
00814     GETINPUT(SelColor);
00815 }
00816 
00817 MMSFBColor MMSInputWidget::getColor_p() {
00818     GETINPUT(Color_p);
00819 }
00820 
00821 MMSFBColor MMSInputWidget::getSelColor_p() {
00822     GETINPUT(SelColor_p);
00823 }
00824 
00825 MMSFBColor MMSInputWidget::getColor_i() {
00826     GETINPUT(Color_i);
00827 }
00828 
00829 MMSFBColor MMSInputWidget::getSelColor_i() {
00830     GETINPUT(SelColor_i);
00831 }
00832 
00833 string MMSInputWidget::getText() {
00834     GETINPUT(Text);
00835 }
00836 
00837 void MMSInputWidget::getText(string &text) {
00838     GETINPUT2(Text, text);
00839 }
00840 
00841 MMSSTATE MMSInputWidget::getCursorState() {
00842     GETINPUT(CursorState);
00843 }
00844 
00845 MMSFBColor MMSInputWidget::getShadowColor(MMSPOSITION position) {
00846     GETINPUTSHADOW(position);
00847 }
00848 
00849 MMSFBColor MMSInputWidget::getSelShadowColor(MMSPOSITION position) {
00850     GETINPUTSHADOWSEL(position);
00851 }
00852 
00853 /***********************************************/
00854 /* begin of theme access methods (set methods) */
00855 /***********************************************/
00856 
00857 void MMSInputWidget::setFontPath(string fontpath, bool load, bool refresh) {
00858     myInputWidgetClass.setFontPath(fontpath);
00859     if (load) {
00860         this->load_font = true;
00861         loadFont();
00862     }
00863 
00864     // refresh is required
00865     enableRefresh();
00866 
00867     this->refresh(refresh);
00868 }
00869 
00870 void MMSInputWidget::setFontName(MMSLanguage lang, string fontname, bool load, bool refresh) {
00871     myInputWidgetClass.setFontName(fontname, lang);
00872     if (load) {
00873         this->load_font = true;
00874         loadFont();
00875     }
00876 
00877     // refresh is required
00878     enableRefresh();
00879 
00880     this->refresh(refresh);
00881 }
00882 
00883 void MMSInputWidget::setFontName(string fontname, bool load, bool refresh) {
00884     setFontName(MMSLANG_NONE, fontname, load, refresh);
00885 }
00886 
00887 void MMSInputWidget::setFontSize(unsigned int fontsize, bool load, bool refresh) {
00888     myInputWidgetClass.setFontSize(fontsize);
00889     if (load) {
00890         this->load_font = true;
00891         loadFont();
00892     }
00893 
00894     // refresh is required
00895     enableRefresh();
00896 
00897     this->refresh(refresh);
00898 }
00899 
00900 void MMSInputWidget::setFont(MMSLanguage lang, string fontpath, string fontname, unsigned int fontsize, bool load, bool refresh) {
00901     myInputWidgetClass.setFontPath(fontpath);
00902     myInputWidgetClass.setFontName(fontname, lang);
00903     myInputWidgetClass.setFontSize(fontsize);
00904     if (load) {
00905         this->load_font = true;
00906         loadFont();
00907     }
00908 
00909     // refresh is required
00910     enableRefresh();
00911 
00912     this->refresh(refresh);
00913 }
00914 
00915 void MMSInputWidget::setFont(string fontpath, string fontname, unsigned int fontsize, bool load, bool refresh) {
00916     setFont(MMSLANG_NONE, fontpath, fontname, fontsize, load, refresh);
00917 }
00918 
00919 void MMSInputWidget::setAlignment(MMSALIGNMENT alignment, bool refresh) {
00920     myInputWidgetClass.setAlignment(alignment);
00921 
00922     // refresh is required
00923     enableRefresh();
00924 
00925     this->refresh(refresh);
00926 }
00927 
00928 void MMSInputWidget::setColor(MMSFBColor color, bool refresh) {
00929     myInputWidgetClass.setColor(color);
00930 
00931     // refresh required?
00932     enableRefresh((color != this->current_fgcolor));
00933 
00934     this->refresh(refresh);
00935 }
00936 
00937 void MMSInputWidget::setSelColor(MMSFBColor selcolor, bool refresh) {
00938     myInputWidgetClass.setSelColor(selcolor);
00939 
00940     // refresh required?
00941     enableRefresh((selcolor != this->current_fgcolor));
00942 
00943     this->refresh(refresh);
00944 }
00945 
00946 void MMSInputWidget::setColor_p(MMSFBColor color_p, bool refresh) {
00947     myInputWidgetClass.setColor_p(color_p);
00948 
00949     // refresh required?
00950     enableRefresh((color_p != this->current_fgcolor));
00951 
00952     this->refresh(refresh);
00953 }
00954 
00955 void MMSInputWidget::setSelColor_p(MMSFBColor selcolor_p, bool refresh) {
00956     myInputWidgetClass.setSelColor_p(selcolor_p);
00957 
00958     // refresh required?
00959     enableRefresh((selcolor_p != this->current_fgcolor));
00960 
00961     this->refresh(refresh);
00962 }
00963 
00964 void MMSInputWidget::setColor_i(MMSFBColor color_i, bool refresh) {
00965     myInputWidgetClass.setColor_i(color_i);
00966 
00967     // refresh required?
00968     enableRefresh((color_i != this->current_fgcolor));
00969 
00970     this->refresh(refresh);
00971 }
00972 
00973 void MMSInputWidget::setSelColor_i(MMSFBColor selcolor_i, bool refresh) {
00974     myInputWidgetClass.setSelColor_i(selcolor_i);
00975 
00976     // refresh required?
00977     enableRefresh((selcolor_i != this->current_fgcolor));
00978 
00979     this->refresh(refresh);
00980 }
00981 
00982 void MMSInputWidget::setText(string text, bool refresh, bool reset_cursor) {
00983     myInputWidgetClass.setText(text);
00984 
00985     if (reset_cursor)
00986         // set cursor to the end
00987         setCursorPos(0xffff, refresh);
00988     else
00989         // try to leave cursor at its position
00990         setCursorPos(this->cursor_pos, refresh);
00991 
00992     // refresh is required
00993     enableRefresh();
00994 
00995     this->refresh(refresh);
00996 }
00997 
00998 void MMSInputWidget::setCursorState(MMSSTATE cursor_state, bool refresh) {
00999     myInputWidgetClass.setCursorState(cursor_state);
01000 
01001     // refresh is required
01002     enableRefresh();
01003 
01004     this->refresh(refresh);
01005 }
01006 
01007 void MMSInputWidget::setShadowColor(MMSPOSITION position, MMSFBColor color, bool refresh) {
01008     myInputWidgetClass.setShadowColor(position, color);
01009 
01010     // refresh is required
01011     enableRefresh();
01012 
01013     this->refresh(refresh);
01014 }
01015 
01016 void MMSInputWidget::setSelShadowColor(MMSPOSITION position, MMSFBColor selcolor, bool refresh) {
01017     myInputWidgetClass.setSelShadowColor(position, selcolor);
01018 
01019     // refresh is required
01020     enableRefresh();
01021 
01022     this->refresh(refresh);
01023 }
01024 
01025 void MMSInputWidget::updateFromThemeClass(MMSInputWidgetClass *themeClass) {
01026 
01027     // update widget-specific settings
01028     if (themeClass->isCursorState())
01029         setCursorState(themeClass->getCursorState());
01030 
01031     // update base text-specific settings
01032     MMSTEXTBASE_UPDATE_FROM_THEME_CLASS(this, themeClass);
01033 
01034     // update general widget settings
01035     MMSWidget::updateFromThemeClass(&(themeClass->widgetClass));
01036 }
01037 
01038 /***********************************************/
01039 /* end of theme access methods                 */
01040 /***********************************************/

Generated by doxygen