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