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/mmswidget.h"
00034 #include "mmsgui/mmsborder.h"
00035 #include "mmsgui/mmsmenuwidget.h"
00036 #include "mmsgui/mmssliderwidget.h"
00037 #include <string.h>
00038 #include <algorithm>
00039
00040
00041 string MMSWidget_inputmode = "";
00042
00043 MMSWidget::MMSWidget() :
00044 da(NULL),
00045 initialized(false),
00046 name(""),
00047 sizehint(""),
00048 min_width(""),
00049 min_width_pix(0),
00050 min_height(""),
00051 min_height_pix(0),
00052 max_width(""),
00053 max_width_pix(0),
00054 max_height(""),
00055 max_height_pix(0),
00056 minmax_set(false),
00057 content_size_initialized(false),
00058 content_width(0),
00059 content_height(0),
00060 content_width_child(0),
00061 content_height_child(0),
00062 bindata(NULL),
00063 rootwindow(NULL),
00064 parent_rootwindow(NULL),
00065 drawable(false),
00066 needsparentdraw(false),
00067 focusable_initial(false),
00068 selectable_initial(false),
00069 clickable_initial(false),
00070 canhavechildren(false),
00071 canselectchildren(false),
00072 visible(true),
00073 focused(false),
00074 selected(false),
00075 pressed(false),
00076 brightness(255),
00077 opacity(255),
00078 has_own_surface(false),
00079 onSelect(NULL),
00080 onFocus(NULL),
00081 onReturn(NULL),
00082 onClick(NULL),
00083 geomset(false),
00084 toRedraw(false),
00085 redrawChildren(false),
00086 windowSurface(NULL),
00087 surface(NULL),
00088 surfaceGeom(MMSFBRectangle(0,0,0,0)),
00089 parent(NULL),
00090 geom(MMSFBRectangle(0,0,0,0)),
00091 innerGeom(MMSFBRectangle(0,0,0,0)),
00092 skip_refresh(false) {
00093
00094
00095 this->current_bgset = false;
00096
00097 MMSIdFactory factory;
00098 this->id = factory.getId();
00099 }
00100
00101
00102 MMSWidget::~MMSWidget() {
00103
00104
00105 if (onSelect) delete onSelect;
00106 if (onFocus) delete onFocus;
00107 if (onReturn) delete onReturn;
00108 if (onClick) delete onClick;
00109
00110
00111 release();
00112
00113
00114 vector<MMSWidget*>::iterator end = children.end();
00115 for(vector<MMSWidget*>::iterator i = children.begin(); i != end; ++i) {
00116 delete *i;
00117 }
00118
00119
00120 if (this->rootwindow) {
00121 this->rootwindow->remove(this);
00122 }
00123
00124 if(this->surface) {
00125 delete this->surface;
00126 }
00127
00128
00129 if (this->da) {
00130 delete this->da;
00131 }
00132 }
00133
00134 MMSWIDGETTYPE MMSWidget::getType() {
00135 return this->type;
00136 }
00137
00138 string MMSWidget::getTypeString() {
00139 switch (this->type) {
00140 case MMSWIDGETTYPE_HBOX:
00141 return "hbox";
00142 case MMSWIDGETTYPE_VBOX:
00143 return "vbox";
00144 case MMSWIDGETTYPE_BUTTON:
00145 return "button";
00146 case MMSWIDGETTYPE_IMAGE:
00147 return "image";
00148 case MMSWIDGETTYPE_LABEL:
00149 return "label";
00150 case MMSWIDGETTYPE_MENU:
00151 return "menu";
00152 case MMSWIDGETTYPE_PROGRESSBAR:
00153 return "progressbar";
00154 case MMSWIDGETTYPE_TEXTBOX:
00155 return "textbox";
00156 case MMSWIDGETTYPE_ARROW:
00157 return "arrow";
00158 case MMSWIDGETTYPE_SLIDER:
00159 return "slider";
00160 case MMSWIDGETTYPE_INPUT:
00161 return "input";
00162 case MMSWIDGETTYPE_CHECKBOX:
00163 return "checkbox";
00164 case MMSWIDGETTYPE_GAP:
00165 return "gap";
00166 }
00167 return "";
00168 }
00169
00170 bool MMSWidget::create(MMSWindow *root, bool drawable, bool needsparentdraw, bool focusable, bool selectable,
00171 bool canhavechildren, bool canselectchildren, bool clickable) {
00172 bool b;
00173
00174 if (drawable) {
00175
00176
00177 this->da->bgimage = NULL;
00178 this->da->selbgimage = NULL;
00179 this->da->bgimage_p = NULL;
00180 this->da->selbgimage_p = NULL;
00181 this->da->bgimage_i = NULL;
00182 this->da->selbgimage_i = NULL;
00183 for (int i=0;i<MMSBORDER_IMAGE_NUM_SIZE;i++)
00184 this->da->borderimages[i] = NULL;
00185 da->bordergeomset = false;
00186 for (int i=0;i<MMSBORDER_IMAGE_NUM_SIZE;i++)
00187 this->da->borderselimages[i] = NULL;
00188 da->borderselgeomset = false;
00189
00190 this->da->upArrowWidget = NULL;
00191 this->da->downArrowWidget = NULL;
00192 this->da->leftArrowWidget = NULL;
00193 this->da->rightArrowWidget = NULL;
00194 this->da->initialArrowsDrawn= false;
00195
00196 this->da->navigateUpWidget = NULL;
00197 this->da->navigateDownWidget = NULL;
00198 this->da->navigateLeftWidget = NULL;
00199 this->da->navigateRightWidget = NULL;
00200
00201 this->da->vSliderWidget = NULL;
00202 this->da->hSliderWidget = NULL;
00203
00204 this->da->scrollPosX = 0;
00205 this->da->scrollPosY = 0;
00206 this->da->scrollDX = 8;
00207 this->da->scrollDY = 8;
00208
00209 this->da->joinedWidget = NULL;
00210
00211 if(!onSelect && selectable) {
00212 onSelect = new sigc::signal<void, MMSWidget*>;
00213 }
00214 if(!onFocus && focusable)
00215 onFocus = new sigc::signal<void, MMSWidget*, bool>;
00216 if(!onReturn && selectable)
00217 onReturn = new sigc::signal<void, MMSWidget*>;
00218 if(!onClick && clickable)
00219 onClick = new sigc::signal<void, MMSWidget*, int, int, int, int>;
00220 }
00221 else {
00222
00223 onSelect = NULL;
00224 onFocus = NULL;
00225 onReturn = NULL;
00226 onClick = NULL;
00227 }
00228
00229 this->drawable = drawable;
00230 this->needsparentdraw = needsparentdraw;
00231 this->focusable_initial = focusable;
00232 if (!this->focusable_initial) {
00233 if (getFocusable(b))
00234 if (b)
00235 setFocusable(false, false);
00236 }
00237 this->selectable_initial = selectable;
00238 if (!this->selectable_initial) {
00239 if (getSelectable(b))
00240 if (b)
00241 setSelectable(false, false);
00242 }
00243 this->canhavechildren = canhavechildren;
00244 this->canselectchildren = canselectchildren;
00245 this->clickable_initial = clickable;
00246 if (!this->clickable_initial)
00247 if (getClickable(b))
00248 if (b)
00249 setClickable(false);
00250
00251 setRootWindow(root);
00252 if (this->rootwindow) {
00253 this->windowSurface = this->rootwindow->getSurface();
00254 }
00255 this->sizehint.clear();
00256 this->min_width.clear();
00257 this->min_height.clear();
00258 this->max_width.clear();
00259 this->max_height.clear();
00260 this->minmax_set = false;
00261
00262 this->geomset=false;
00263
00264
00265
00266
00267
00268
00269 return true;
00270 }
00271
00272 void MMSWidget::copyWidget(MMSWidget *newWidget) {
00273
00274
00275 newWidget->initialized = this->initialized;
00276 newWidget->name = this->name;
00277 newWidget->sizehint = this->sizehint;
00278 newWidget->bindata=NULL;
00279 newWidget->rootwindow = this->rootwindow;
00280 newWidget->parent_rootwindow = this->parent_rootwindow;
00281 newWidget->drawable = this->drawable;
00282 newWidget->needsparentdraw = this->needsparentdraw;
00283 newWidget->focusable_initial = this->focusable_initial;
00284 newWidget->selectable_initial = this->selectable_initial;
00285 newWidget->clickable_initial = this->clickable_initial;
00286 newWidget->canhavechildren = this->canhavechildren;
00287 newWidget->canselectchildren = this->canselectchildren;
00288 newWidget->visible = this->visible;
00289 newWidget->focused = false;
00290 newWidget->selected = false;
00291 newWidget->pressed = false;
00292 newWidget->brightness = this->brightness;
00293 newWidget->opacity = this->opacity;
00294 newWidget->has_own_surface = this->has_own_surface;
00295 newWidget->skip_refresh = false;
00296 newWidget->current_bgset = this->current_bgset;
00297 newWidget->current_bgcolor = this->current_bgcolor;
00298 newWidget->current_bgimage = this->current_bgimage;
00299 newWidget->geomset = this->geomset;
00300 newWidget->toRedraw = this->toRedraw;
00301 newWidget->redrawChildren = this->redrawChildren;
00302
00303 newWidget->windowSurface = this->windowSurface;
00304
00305
00306 newWidget->surface = NULL;
00307
00308 newWidget->surfaceGeom = this->surfaceGeom;
00309
00310 newWidget->parent = this->parent;
00311 newWidget->children = this->children;
00312
00313 newWidget->geom = this->geom;
00314 newWidget->innerGeom = this->innerGeom;
00315
00316
00317 unsigned int size = children.size();
00318 for (unsigned int i = 0; i < size; i++)
00319 newWidget->children.at(i) = children.at(i)->copyWidget();
00320
00321 if (drawable) {
00322
00323 *(newWidget->da) = *(this->da);
00324 }
00325
00326 if (drawable) {
00327
00328
00329 newWidget->da->bgimage = NULL;
00330 newWidget->da->selbgimage = NULL;
00331 newWidget->da->bgimage_p = NULL;
00332 newWidget->da->selbgimage_p = NULL;
00333 newWidget->da->bgimage_i = NULL;
00334 newWidget->da->selbgimage_i = NULL;
00335 for (int i=0;i<MMSBORDER_IMAGE_NUM_SIZE;i++)
00336 newWidget->da->borderimages[i] = NULL;
00337 for (int i=0;i<MMSBORDER_IMAGE_NUM_SIZE;i++)
00338 newWidget->da->borderselimages[i] = NULL;
00339
00340 if (this->rootwindow) {
00341 string path, name;
00342
00343 if (!newWidget->getBgImagePath(path)) path = "";
00344 if (!newWidget->getBgImageName(name)) name = "";
00345 newWidget->da->bgimage = this->rootwindow->im->getImage(path, name);
00346
00347 if (!newWidget->getSelBgImagePath(path)) path = "";
00348 if (!newWidget->getSelBgImageName(name)) name = "";
00349 newWidget->da->selbgimage = this->rootwindow->im->getImage(path, name);
00350
00351 if (!newWidget->getBgImagePath_p(path)) path = "";
00352 if (!newWidget->getBgImageName_p(name)) name = "";
00353 newWidget->da->bgimage_p = this->rootwindow->im->getImage(path, name);
00354
00355 if (!newWidget->getSelBgImagePath_p(path)) path = "";
00356 if (!newWidget->getSelBgImageName_p(name)) name = "";
00357 newWidget->da->selbgimage_p = this->rootwindow->im->getImage(path, name);
00358
00359 if (!newWidget->getBgImagePath_i(path)) path = "";
00360 if (!newWidget->getBgImageName_i(name)) name = "";
00361 newWidget->da->bgimage_i = this->rootwindow->im->getImage(path, name);
00362
00363 if (!newWidget->getSelBgImagePath_i(path)) path = "";
00364 if (!newWidget->getSelBgImageName_i(name)) name = "";
00365 newWidget->da->selbgimage_i = this->rootwindow->im->getImage(path, name);
00366
00367 if (!newWidget->getBorderImagePath(path)) path = "";
00368 for (int i=0;i<MMSBORDER_IMAGE_NUM_SIZE;i++) {
00369 if (!newWidget->getBorderImageNames((MMSBORDER_IMAGE_NUM)i, name)) name = "";
00370 newWidget->da->borderimages[i] = this->rootwindow->im->getImage(path, name);
00371 }
00372
00373 if (!newWidget->getBorderSelImagePath(path)) path = "";
00374 for (int i=0;i<MMSBORDER_IMAGE_NUM_SIZE;i++) {
00375 if (!newWidget->getBorderSelImageNames((MMSBORDER_IMAGE_NUM)i, name)) name = "";
00376 newWidget->da->borderselimages[i] = this->rootwindow->im->getImage(path, name);
00377 }
00378 }
00379 }
00380 }
00381
00382 MMSWidget* MMSWidget::getChild(unsigned int atpos) {
00383 if (atpos < children.size())
00384 return children.at(atpos);
00385 else
00386 return NULL;
00387 }
00388
00389 MMSWidget* MMSWidget::disconnectChild(unsigned int atpos) {
00390 if (atpos < children.size()) {
00391 MMSWidget *widget = children.at(atpos);
00392 children.erase(children.begin()+atpos);
00393 return widget;
00394 }
00395 else
00396 return NULL;
00397 }
00398
00399 MMSWidget* MMSWidget::findWidget(string name) {
00400 MMSWidget *widget;
00401
00402 if (name == "") {
00403
00404 return NULL;
00405 }
00406
00407 if (name == this->name) {
00408
00409 return this;
00410 }
00411
00412
00413 vector<MMSWidget*>::iterator end = children.end();
00414 for(vector<MMSWidget*>::iterator i = children.begin(); i != end; ++i) {
00415 if((*i)->getName() == name) {
00416 return *i;
00417 }
00418 }
00419
00420
00421 for(vector<MMSWidget*>::iterator i = children.begin(); i != end; ++i) {
00422 if((widget = (*i)->findWidget(name))) {
00423 return widget;
00424 }
00425 }
00426
00427 return NULL;
00428 }
00429
00430 MMSWidget* MMSWidget::findWidgetType(MMSWIDGETTYPE type) {
00431 MMSWidget *widget;
00432
00433
00434 vector<MMSWidget*>::iterator end = children.end();
00435 for(vector<MMSWidget*>::iterator i = children.begin(); i != end; ++i) {
00436 if((*i)->getType() == type) {
00437 return *i;
00438 }
00439 }
00440
00441
00442 for(vector<MMSWidget*>::iterator i = children.begin(); i != end; ++i) {
00443 if((widget = (*i)->findWidget(name))) {
00444 return widget;
00445 }
00446 }
00447
00448 return NULL;
00449 }
00450
00451 MMSWidget* MMSWidget::getLastWidget() {
00452 if (this->children.size() > 0)
00453 return this->children.at(this->children.size()-1);
00454 return NULL;
00455 }
00456
00457 MMSWidget* MMSWidget::operator[](string name) {
00458 MMSWidget *widget;
00459
00460 if ((widget = findWidget(name)))
00461 return widget;
00462 throw MMSWidgetError(1, "widget " + name + " not found");
00463 }
00464
00465
00466
00467 bool MMSWidget::setSurfaceGeometry(unsigned int width, unsigned int height) {
00468 MMSFBRectangle mygeom;
00469
00470 if (!drawable) {
00471
00472 return false;
00473 }
00474
00475
00476 mygeom.x = 0;
00477 mygeom.y = 0;
00478 if ((int)width > this->innerGeom.w)
00479 mygeom.w = width;
00480 else
00481 mygeom.w = this->innerGeom.w;
00482 if ((int)height > this->innerGeom.h)
00483 mygeom.h = height;
00484 else
00485 mygeom.h = this->innerGeom.h;
00486
00487 if ((this->surfaceGeom.w != mygeom.w)||(this->surfaceGeom.h != mygeom.h)) {
00488
00489
00490 this->surfaceGeom = mygeom;
00491
00492
00493 if (this->surface) {
00494 delete this->surface;
00495 this->surface = NULL;
00496 }
00497
00498 this->windowSurface->lock();
00499
00500 if (this->has_own_surface) {
00501
00502 this->windowSurface->createCopy(&(this->surface), this->surfaceGeom.w, this->surfaceGeom.h);
00503 }
00504 else {
00505
00506 this->surface = this->windowSurface->getSubSurface(&(this->innerGeom));
00507 }
00508
00509 this->windowSurface->unlock();
00510
00511
00512 return true;
00513 }
00514 else {
00515 if (!this->has_own_surface) {
00516 if (this->surface) {
00517
00518 this->surfaceGeom = mygeom;
00519
00520
00521 this->surface->lock();
00522 this->surface->moveTo(this->innerGeom.x, this->innerGeom.y);
00523 this->surface->unlock();
00524 }
00525 }
00526
00527
00528 return false;
00529 }
00530 }
00531
00532 MMSFBRectangle MMSWidget::getSurfaceGeometry() {
00533 return this->surfaceGeom;
00534 }
00535
00536 MMSFBSurface *MMSWidget::getSurface() {
00537 return this->surface;
00538 }
00539
00540 void MMSWidget::setInnerGeometry() {
00541 MMSFBRectangle mygeom;
00542 unsigned int diff = 0;
00543
00544
00545 if (!isGeomSet())
00546 return;
00547
00548
00549 mygeom = this->geom;
00550
00551
00552 if (drawable) {
00553 unsigned int margin, borderthickness, bordermargin;
00554 if (!getMargin(margin))
00555 margin = 0;
00556 if (!getBorderThickness(borderthickness))
00557 borderthickness = 0;
00558 if (!getBorderMargin(bordermargin))
00559 bordermargin = 0;
00560 diff = margin + borderthickness + bordermargin;
00561 }
00562
00563 if ((int)(2*diff) >= mygeom.w) {
00564 diff = mygeom.w / 2 - 1;
00565 }
00566
00567 if ((int)(2*diff) >= mygeom.h) {
00568 diff = mygeom.h / 2 - 1;
00569 }
00570
00571 mygeom.x+= diff;
00572 mygeom.y+= diff;
00573 mygeom.w-= 2*diff;
00574 mygeom.h-= 2*diff;
00575
00576 if (memcmp(&(this->innerGeom), &mygeom, sizeof(mygeom))) {
00577
00578 this->innerGeom = mygeom;
00579
00580
00581 setSurfaceGeometry();
00582 }
00583 }
00584
00585 MMSFBRectangle MMSWidget::getInnerGeometry() {
00586 return this->innerGeom;
00587 }
00588
00589
00590 void MMSWidget::setGeometry(MMSFBRectangle geom) {
00591 MMSFBRectangle oldgeom;
00592 bool dimChanged = true;
00593
00594 if (this->geomset) {
00595
00596 dimChanged = ((this->geom.w!=geom.w)||(this->geom.h!=geom.h));
00597
00598
00599 if (dimChanged) {
00600
00601 if (drawable) {
00602 this->da->bordergeomset=false;
00603 this->da->borderselgeomset=false;
00604 }
00605 }
00606 else {
00607 if (this->geom.x!=geom.x) {
00608
00609 if (drawable) {
00610 if ((this->da->bordergeomset)||(this->da->borderselgeomset)) {
00611 int diff = this->geom.x - geom.x;
00612 for (int i=0;i<8;i++) {
00613 this->da->bordergeom[i].x -= diff;
00614 this->da->borderselgeom[i].x -= diff;
00615 }
00616 }
00617 }
00618 }
00619 if (this->geom.y!=geom.y) {
00620
00621 if (drawable) {
00622 if ((this->da->bordergeomset)||(this->da->borderselgeomset)) {
00623 int diff = this->geom.y - geom.y;
00624 for (int i=0;i<8;i++) {
00625 this->da->bordergeom[i].y -= diff;
00626 this->da->borderselgeom[i].y -= diff;
00627 }
00628 }
00629 }
00630 }
00631 }
00632 }
00633
00634
00635 this->geomset = true;
00636 oldgeom = this->geom;
00637 this->geom = geom;
00638
00639
00640
00641 if (this->has_own_surface) {
00642 if (dimChanged) {
00643
00644 setInnerGeometry();
00645 }
00646 else {
00647
00648 this->innerGeom.x+= this->geom.x - oldgeom.x;
00649 this->innerGeom.y+= this->geom.y - oldgeom.y;
00650 }
00651 }
00652 else {
00653
00654 setInnerGeometry();
00655 }
00656
00657
00658 this->recalculateChildren();
00659
00660 }
00661
00662 MMSFBRectangle MMSWidget::getGeometry() {
00663 return this->geom;
00664 }
00665
00666 MMSFBRectangle MMSWidget::getRealGeometry() {
00667 MMSFBRectangle r1,r2;
00668
00669
00670 if (!this->parent) {
00671
00672 if (!this->rootwindow)
00673 return this->geom;
00674
00675
00676 if (!isGeomSet()) {
00677 this->rootwindow->recalculateChildren();
00678 }
00679 r1 = this->geom;
00680 r2 = this->rootwindow->getRealGeometry();
00681 r1.x+=r2.x;
00682 r1.y+=r2.y;
00683 return r1;
00684 }
00685
00686
00687 r1 = this->geom;
00688 r2 = this->parent->getRealGeometry();
00689 r1.x+=r2.x;
00690 r1.y+=r2.y;
00691 return r1;
00692 }
00693
00694
00695
00696 bool MMSWidget::loadArrowWidgets() {
00697 bool b;
00698 string s;
00699
00700 if (!this->drawable)
00701 return false;
00702
00703
00704 if (!this->da->upArrowWidget)
00705 if (getUpArrow(s))
00706 if (!s.empty())
00707 if (this->rootwindow)
00708 if ((this->da->upArrowWidget = this->rootwindow->findWidget(s))) {
00709 if (!this->da->upArrowWidget->getSelectable(b))
00710 this->da->upArrowWidget = NULL;
00711 else
00712 if (!b)
00713 this->da->upArrowWidget = NULL;
00714 }
00715
00716 if (!this->da->downArrowWidget)
00717 if (getDownArrow(s))
00718 if (!s.empty())
00719 if (this->rootwindow)
00720 if ((this->da->downArrowWidget = this->rootwindow->findWidget(s))) {
00721 if (!this->da->downArrowWidget->getSelectable(b))
00722 this->da->downArrowWidget = NULL;
00723 else
00724 if (!b)
00725 this->da->downArrowWidget = NULL;
00726 }
00727
00728 if (!this->da->leftArrowWidget)
00729 if (getLeftArrow(s))
00730 if (!s.empty())
00731 if (this->rootwindow)
00732 if ((this->da->leftArrowWidget = this->rootwindow->findWidget(s))) {
00733 if (!this->da->leftArrowWidget->getSelectable(b))
00734 this->da->leftArrowWidget = NULL;
00735 else
00736 if (!b)
00737 this->da->leftArrowWidget = NULL;
00738 }
00739
00740 if (!this->da->rightArrowWidget)
00741 if (getRightArrow(s))
00742 if (!s.empty())
00743 if (this->rootwindow)
00744 if ((this->da->rightArrowWidget = this->rootwindow->findWidget(s))) {
00745 if (!this->da->rightArrowWidget->getSelectable(b))
00746 this->da->rightArrowWidget = NULL;
00747 else
00748 if (!b)
00749 this->da->rightArrowWidget = NULL;
00750 }
00751
00752 return true;
00753 }
00754
00755 void MMSWidget::switchArrowWidgets() {
00756
00757 if (!loadArrowWidgets())
00758 return;
00759
00760
00761 if (this->da->upArrowWidget) {
00762 if (this->da->scrollPosY == 0)
00763 this->da->upArrowWidget->setSelected(false);
00764 else
00765 this->da->upArrowWidget->setSelected(true);
00766 }
00767
00768 if (this->da->downArrowWidget) {
00769 if (this->surfaceGeom.h - this->surfaceGeom.y - (int)this->da->scrollPosY > this->innerGeom.h)
00770 this->da->downArrowWidget->setSelected(true);
00771 else
00772 this->da->downArrowWidget->setSelected(false);
00773 }
00774
00775 if (this->da->leftArrowWidget) {
00776 if (this->da->scrollPosX == 0)
00777 this->da->leftArrowWidget->setSelected(false);
00778 else
00779 this->da->leftArrowWidget->setSelected(true);
00780 }
00781
00782 if (this->da->rightArrowWidget) {
00783 if (this->surfaceGeom.w - this->surfaceGeom.x - (int)this->da->scrollPosX > this->innerGeom.w)
00784 this->da->rightArrowWidget->setSelected(true);
00785 else
00786 this->da->rightArrowWidget->setSelected(false);
00787 }
00788 }
00789
00790 bool MMSWidget::setScrollSize(unsigned int dX, unsigned int dY) {
00791 if (this->da) {
00792 this->da->scrollDX = dX;
00793 this->da->scrollDY = dY;
00794 return true;
00795 }
00796 return false;
00797 }
00798
00799 bool MMSWidget::setScrollPos(int posX, int posY, bool refresh, bool test) {
00800 if (!isGeomSet()) {
00801
00802 MMSWindow *root = getRootWindow();
00803 if (root) {
00804 root->recalculateChildren();
00805 }
00806 else
00807 return false;
00808 }
00809
00810 if (!this->surface) return false;
00811
00812 if (posX < 0) {
00813 if (this->da->scrollPosX > 0)
00814 posX = 0;
00815 else
00816 return false;
00817 }
00818
00819 if (posX + innerGeom.w > surfaceGeom.w) {
00820 if ((int)this->da->scrollPosX + innerGeom.w < surfaceGeom.w)
00821 posX = surfaceGeom.w - innerGeom.w;
00822 else
00823 return false;
00824 }
00825
00826 if (posY < 0) {
00827 if (this->da->scrollPosY > 0)
00828 posY = 0;
00829 else
00830 return false;
00831 }
00832
00833 if (posY + innerGeom.h > surfaceGeom.h) {
00834 if ((int)this->da->scrollPosY + innerGeom.h < surfaceGeom.h)
00835 posY = surfaceGeom.h - innerGeom.h;
00836 else
00837 return false;
00838 }
00839
00840 if (!test) {
00841 this->da->scrollPosX = posX;
00842 this->da->scrollPosY = posY;
00843
00844
00845 enableRefresh();
00846
00847 if (refresh)
00848 this->refresh();
00849 }
00850
00851 return true;
00852 }
00853
00854
00855 bool MMSWidget::scrollDown(unsigned int count, bool refresh, bool test, bool leave_selection) {
00856 if (!this->da) return false;
00857 if (setScrollPos((int)this->da->scrollPosX, (int)this->da->scrollPosY + count*(int)this->da->scrollDY, refresh, test)) {
00858 if (!test)
00859 switchArrowWidgets();
00860 return true;
00861 }
00862 return false;
00863 }
00864
00865 bool MMSWidget::scrollUp(unsigned int count, bool refresh, bool test, bool leave_selection) {
00866 if (!this->da) return false;
00867 if (setScrollPos((int)this->da->scrollPosX, (int)this->da->scrollPosY - count*(int)this->da->scrollDY, refresh, test)) {
00868 if (!test)
00869 switchArrowWidgets();
00870 return true;
00871 }
00872 return false;
00873 }
00874
00875 bool MMSWidget::scrollRight(unsigned int count, bool refresh, bool test, bool leave_selection) {
00876 if (!this->da) return false;
00877 if (setScrollPos((int)this->da->scrollPosX + count*(int)this->da->scrollDX, (int)this->da->scrollPosY, refresh, test)) {
00878 if (!test)
00879 switchArrowWidgets();
00880 return true;
00881 }
00882 return false;
00883 }
00884
00885 bool MMSWidget::scrollLeft(unsigned int count, bool refresh, bool test, bool leave_selection) {
00886 if (!this->da) return false;
00887 if (setScrollPos((int)this->da->scrollPosX - count*(int)this->da->scrollDX, (int)this->da->scrollPosY, refresh, test)) {
00888 if (!test)
00889 switchArrowWidgets();
00890 return true;
00891 }
00892 return false;
00893 }
00894
00895 bool MMSWidget::scrollTo(int posx, int posy, bool refresh, bool *changed, MMSWIDGET_SCROLL_MODE mode, MMSFBRectangle *inputrect) {
00896 if (changed)
00897 *changed = false;
00898 return true;
00899 }
00900
00901 MMSFBRectangle MMSWidget::getVisibleSurfaceArea() {
00902 MMSFBRectangle area;
00903
00904 area.x = surfaceGeom.x + (this->da)?this->da->scrollPosX:0;
00905 area.y = surfaceGeom.y + (this->da)?this->da->scrollPosY:0;
00906 area.w = innerGeom.w;
00907 area.h = innerGeom.h;
00908
00909 return area;
00910 }
00911
00912 void MMSWidget::updateWindowSurfaceWithSurface(bool useAlphaChannel) {
00913
00914 if (this->has_own_surface) {
00915
00916 MMSFBRectangle area = getVisibleSurfaceArea();
00917
00918
00919 this->windowSurface->lock();
00920 this->surface->lock();
00921
00922 this->windowSurface->setBlittingFlags(MMSFB_BLIT_NOFX);
00923 this->windowSurface->blit(this->surface, &area, innerGeom.x, innerGeom.y);
00924
00925
00926 this->surface->unlock();
00927 this->windowSurface->unlock();
00928 }
00929 }
00930
00931 bool MMSWidget::init() {
00932
00933 if (!this->rootwindow)
00934 return false;
00935
00936 if (this->initialized) {
00937
00938 return true;
00939 }
00940
00941 if ((drawable) && (this->da)) {
00942
00943 string path, name;
00944
00945 if (!getBgImagePath(path)) path = "";
00946 if (!getBgImageName(name)) name = "";
00947 this->da->bgimage = this->rootwindow->im->getImage(path, name);
00948
00949 if (!getSelBgImagePath(path)) path = "";
00950 if (!getSelBgImageName(name)) name = "";
00951 this->da->selbgimage = this->rootwindow->im->getImage(path, name);
00952
00953 if (!getBgImagePath_p(path)) path = "";
00954 if (!getBgImageName_p(name)) name = "";
00955 this->da->bgimage_p = this->rootwindow->im->getImage(path, name);
00956
00957 if (!getSelBgImagePath_p(path)) path = "";
00958 if (!getSelBgImageName_p(name)) name = "";
00959 this->da->selbgimage_p = this->rootwindow->im->getImage(path, name);
00960
00961 if (!getBgImagePath_i(path)) path = "";
00962 if (!getBgImageName_i(name)) name = "";
00963 this->da->bgimage_i = this->rootwindow->im->getImage(path, name);
00964
00965 if (!getSelBgImagePath_i(path)) path = "";
00966 if (!getSelBgImageName_i(name)) name = "";
00967 this->da->selbgimage_i = this->rootwindow->im->getImage(path, name);
00968
00969 if (!getBorderImagePath(path)) path = "";
00970 for (int i=0;i<MMSBORDER_IMAGE_NUM_SIZE;i++) {
00971 if (!getBorderImageNames((MMSBORDER_IMAGE_NUM)i, name)) name = "";
00972 this->da->borderimages[i] = this->rootwindow->im->getImage(path, name);
00973 }
00974
00975 if (!getBorderSelImagePath(path)) path = "";
00976 for (int i=0;i<MMSBORDER_IMAGE_NUM_SIZE;i++) {
00977 if (!getBorderSelImageNames((MMSBORDER_IMAGE_NUM)i, name)) name = "";
00978 this->da->borderselimages[i] = this->rootwindow->im->getImage(path, name);
00979 }
00980
00981
00982 if (!getNavigateUp(name)) name = "";
00983 this->da->navigateUpWidget = this->rootwindow->findWidget(name);
00984
00985 if (!getNavigateDown(name)) name = "";
00986 this->da->navigateDownWidget = this->rootwindow->findWidget(name);
00987
00988 if (!getNavigateLeft(name)) name = "";
00989 this->da->navigateLeftWidget = this->rootwindow->findWidget(name);
00990
00991 if (!getNavigateRight(name)) name = "";
00992 this->da->navigateRightWidget = this->rootwindow->findWidget(name);
00993
00994
00995 if (!getVSlider(name)) name = "";
00996 this->da->vSliderWidget = this->rootwindow->findWidget(name);
00997
00998 if (!getHSlider(name)) name = "";
00999 this->da->hSliderWidget = this->rootwindow->findWidget(name);
01000
01001
01002 if (!getJoinedWidget(name)) name = "";
01003 this->da->joinedWidget = this->rootwindow->findWidget(name);
01004 }
01005
01006 this->initialized = true;
01007 return true;
01008 }
01009
01010 bool MMSWidget::release() {
01011 if (!this->rootwindow)
01012 return false;
01013
01014 if ((drawable) && (this->da)) {
01015
01016 this->rootwindow->im->releaseImage(this->da->bgimage);
01017 this->da->bgimage = NULL;
01018 this->rootwindow->im->releaseImage(this->da->selbgimage);
01019 this->da->selbgimage = NULL;
01020 this->rootwindow->im->releaseImage(this->da->bgimage_p);
01021 this->da->bgimage_p = NULL;
01022 this->rootwindow->im->releaseImage(this->da->selbgimage_p);
01023 this->da->selbgimage_p = NULL;
01024 this->rootwindow->im->releaseImage(this->da->bgimage_i);
01025 this->da->bgimage_i = NULL;
01026 this->rootwindow->im->releaseImage(this->da->selbgimage_i);
01027 this->da->selbgimage_i = NULL;
01028
01029 for (int i=0;i<MMSBORDER_IMAGE_NUM_SIZE;i++) {
01030 this->rootwindow->im->releaseImage(this->da->borderimages[i]);
01031 this->da->borderimages[i] = NULL;
01032 }
01033
01034 for (int i=0;i<MMSBORDER_IMAGE_NUM_SIZE;i++) {
01035 this->rootwindow->im->releaseImage(this->da->borderselimages[i]);
01036 this->da->borderselimages[i] = NULL;
01037 }
01038
01039
01040 this->da->navigateUpWidget = NULL;
01041 this->da->navigateDownWidget = NULL;
01042 this->da->navigateLeftWidget = NULL;
01043 this->da->navigateRightWidget = NULL;
01044
01045
01046 this->da->vSliderWidget = NULL;
01047 this->da->hSliderWidget = NULL;
01048
01049
01050 this->da->joinedWidget = NULL;
01051 }
01052
01053 return true;
01054 }
01055
01056
01057
01058 bool MMSWidget::setContentSize(int content_width, int content_height) {
01059 if (!this->minmax_set) {
01060 return false;
01061 }
01062
01063 if (!this->parent)
01064 return false;
01065
01066 this->content_width = content_width;
01067 this->content_height = content_height;
01068 this->parent->setContentSizeFromChildren();
01069 return true;
01070 }
01071
01072
01073 void MMSWidget::setContentSizeFromChildren() {
01074 if (!this->minmax_set) {
01075 return;
01076 }
01077
01078 if (!this->parent)
01079 return;
01080
01081 int content_width;
01082 int content_height;
01083 if (children.at(0)->getContentSize(&content_width, &content_height)) {
01084 this->content_width_child = content_width;
01085 this->content_height_child = content_height;
01086 this->parent->setContentSizeFromChildren();
01087 }
01088 }
01089
01090
01091 bool MMSWidget::getContentSize(int *content_width, int *content_height) {
01092 if (!this->minmax_set) {
01093 return false;
01094 }
01095
01096 if (this->content_width <= 0 || this->content_height <= 0) {
01097 if (this->content_width_child <= 0 || this->content_height_child <= 0)
01098 return false;
01099
01100 *content_width = this->content_width_child;
01101 *content_height = this->content_height_child;
01102
01103 return true;
01104 }
01105
01106 *content_width = this->content_width;
01107 *content_height = this->content_height;
01108
01109 return true;
01110 }
01111
01112
01113 void MMSWidget::initContentSize() {
01114 if (this->content_size_initialized) {
01115
01116 return;
01117 }
01118
01119 if (this->minmax_set) {
01120
01121 calcContentSize();
01122 }
01123
01124 this->content_size_initialized = true;
01125
01126
01127 for (int i=0; i < children.size(); i++) {
01128 children.at(i)->initContentSize();
01129 }
01130 }
01131
01132 void MMSWidget::calcContentSize() {
01133
01134 }
01135
01136
01137 bool MMSWidget::recalcContentSize(bool refresh) {
01138 if (!this->minmax_set || !this->content_size_initialized) return false;
01139
01140
01141 int old_cwidth = -1;
01142 int old_cheight = -1;
01143 getContentSize(&old_cwidth, &old_cheight);
01144
01145
01146 calcContentSize();
01147
01148
01149 int new_cwidth = -1;
01150 int new_cheight = -1;
01151 getContentSize(&new_cwidth, &new_cheight);
01152
01153 if (old_cwidth == new_cwidth && old_cheight == new_cheight) {
01154
01155 return false;
01156 }
01157
01158
01159 this->rootwindow->setWidgetGeometryOnNextDraw();
01160
01161 if (refresh) {
01162
01163 if (this->rootwindow->isShown(true)) {
01164
01165 this->rootwindow->refresh();
01166 }
01167 }
01168
01169 return true;
01170 }
01171
01172
01173 void MMSWidget::getBackground(MMSFBColor *color, MMSFBSurface **image) {
01174 color->a = 0;
01175 *image = NULL;
01176
01177 if (this->drawable) {
01178 if (isActivated()) {
01179 if (isSelected()) {
01180 getSelBgColor(*color);
01181 *image = this->da->selbgimage;
01182 }
01183 else {
01184 getBgColor(*color);
01185 *image = this->da->bgimage;
01186 }
01187 if (isPressed()) {
01188 MMSFBColor mycol;
01189 if (isSelected()) {
01190 getSelBgColor_p(mycol);
01191 if (mycol.a>0) *color=mycol;
01192 if (this->da->selbgimage_p)
01193 *image = this->da->selbgimage_p;
01194 }
01195 else {
01196 getBgColor_p(mycol);
01197 if (mycol.a>0) *color=mycol;
01198 if (this->da->bgimage_p)
01199 *image = this->da->bgimage_p;
01200 }
01201 }
01202 }
01203 else {
01204 if (isSelected()) {
01205 getSelBgColor_i(*color);
01206 *image = this->da->selbgimage_i;
01207 }
01208 else {
01209 getBgColor_i(*color);
01210 *image = this->da->bgimage_i;
01211 }
01212 }
01213 }
01214 }
01215
01216
01217 bool MMSWidget::enableRefresh(bool enable) {
01218
01219 if (!enable) return false;
01220
01221
01222 this->skip_refresh = false;
01223 this->current_bgset = false;
01224
01225
01226 if (this->parent)
01227 return this->parent->enableRefresh();
01228
01229 return true;
01230 }
01231
01232
01233 bool MMSWidget::checkRefreshStatus() {
01234
01235 if (!this->skip_refresh) {
01236
01237 return true;
01238 }
01239
01240 if (this->current_bgset) {
01241
01242 MMSFBColor color;
01243 MMSFBSurface *image;
01244 getBackground(&color, &image);
01245
01246 if (color == this->current_bgcolor && image == this->current_bgimage) {
01247
01248 return false;
01249 }
01250 }
01251
01252
01253 enableRefresh();
01254
01255 return true;
01256 }
01257
01258
01259 bool MMSWidget::draw(bool *backgroundFilled) {
01260 bool myBackgroundFilled = false;
01261 bool retry = false;
01262
01263
01264
01265
01266
01267 init();
01268
01269 if(!surface)
01270 return false;
01271
01272 if (backgroundFilled) {
01273 if (this->has_own_surface)
01274 *backgroundFilled = false;
01275 }
01276 else
01277 backgroundFilled = &myBackgroundFilled;
01278
01279 if ((!this->geomset)||(!this->visible))
01280 return false;
01281
01282
01283 if (this->surface) this->surface->lock();
01284 this->windowSurface->lock();
01285
01286
01287
01288 this->skip_refresh = true;
01289
01290
01291
01292 do {
01293
01294 MMSFBColor col;
01295 MMSFBSurface *suf;
01296 getBackground(&col, &suf);
01297 this->current_bgcolor = col;
01298 this->current_bgimage = suf;
01299 this->current_bgset = true;
01300
01301 if (suf) {
01302 if ((*backgroundFilled)||(retry)||(!this->has_own_surface)) {
01303
01304 this->surface->setBlittingFlagsByBrightnessAlphaAndOpacity(brightness, (col.a)?col.a:255, opacity);
01305
01306
01307 suf->lock();
01308 surface->stretchBlit(suf, NULL, &surfaceGeom);
01309 suf->unlock();
01310 *backgroundFilled = true;
01311
01312
01313 break;
01314 }
01315 else
01316
01317 retry = true;
01318 }
01319 else
01320 if (col.a) {
01321 if ((*backgroundFilled)||(retry)||(!this->has_own_surface)||((col.a==255)&&(opacity==255))) {
01322
01323 this->surface->setDrawingColorAndFlagsByBrightnessAndOpacity(col, brightness, opacity);
01324
01325
01326 this->surface->fillRectangle(surfaceGeom.x, surfaceGeom.y, surfaceGeom.w, surfaceGeom.h);
01327 *backgroundFilled = true;
01328
01329
01330 break;
01331 }
01332 else
01333
01334 retry = true;
01335 }
01336 else {
01337 if ((*backgroundFilled)||(!this->has_own_surface)) {
01338
01339 if (!*backgroundFilled) {
01340 if (this->surface) {
01341
01342
01343 this->surface->clear();
01344 *backgroundFilled = true;
01345 }
01346 }
01347 break;}
01348 else
01349
01350 retry = true;
01351 }
01352
01353
01354 if (!*backgroundFilled) {
01355
01356 MMSWidget *widget = NULL;
01357 vector<MMSWidget*> wlist;
01358 if (this->parent)
01359 widget = this->parent->getDrawableParent(false, false, false, &wlist);
01360
01361
01362
01363 for (unsigned int i=0; i < wlist.size(); i++) {
01364 MMSWidget *w = wlist.at(i);
01365 if ((w->drawable)&&(w->geomset)&&(w->visible)) {
01366 widget = w;
01367 break;
01368 }
01369 }
01370
01371
01372 if (this->drawable) {
01373
01374 this->surface->clear();
01375 }
01376 else {
01377
01378 MMSFBRegion clip;
01379 clip.x1 = innerGeom.x;
01380 clip.y1 = innerGeom.y;
01381 clip.x2 = innerGeom.x + innerGeom.w - 1;
01382 clip.y2 = innerGeom.y + innerGeom.h - 1;
01383
01384 this->windowSurface->setClip(&clip);
01385 this->windowSurface->clear();
01386 }
01387
01388 if (widget) {
01389
01390 MMSFBRectangle srcrect = widget->getVisibleSurfaceArea();
01391 srcrect.x+= this->innerGeom.x - widget->innerGeom.x;
01392 srcrect.y+= this->innerGeom.y - widget->innerGeom.y;
01393 srcrect.w = this->innerGeom.w;
01394 srcrect.h = this->innerGeom.h;
01395
01396 widget->surface->lock();
01397
01398 if (this->drawable) {
01399
01400 this->surface->setBlittingFlags(MMSFB_BLIT_NOFX);
01401 this->surface->blit(widget->surface, &srcrect, 0, 0);
01402 }
01403 else {
01404
01405 this->windowSurface->setBlittingFlags(MMSFB_BLIT_NOFX);
01406 this->windowSurface->blit(widget->surface, &srcrect, innerGeom.x, innerGeom.y);
01407 }
01408
01409 widget->surface->unlock();
01410 }
01411 else {
01412
01413 if (this->rootwindow) {
01414 MMSFBColor bgcolor;
01415 this->rootwindow->getBgColor(bgcolor);
01416 if (!this->rootwindow->bgimage) {
01417
01418 if (bgcolor.a) {
01419 if (this->drawable) {
01420
01421 this->surface->clear(bgcolor.r, bgcolor.g, bgcolor.b, bgcolor.a);
01422 }
01423 else {
01424
01425 this->windowSurface->clear(bgcolor.r, bgcolor.g, bgcolor.b, bgcolor.a);
01426 }
01427 }
01428 }
01429 else {
01430
01431 MMSFBRectangle src, dst;
01432 int sw, sh;
01433
01434 this->rootwindow->bgimage->lock();
01435
01436
01437 this->rootwindow->bgimage->getSize(&sw, &sh);
01438
01439
01440 int f1 = (this->rootwindow->innerGeom.w * 10000) / sw;
01441 int f2 = (this->rootwindow->innerGeom.h * 10000) / sh;
01442
01443
01444 src.x = (5000 + 10000 *(this->innerGeom.x - this->rootwindow->innerGeom.x)) / f1;
01445 src.w = (5000 + 10000 * this->innerGeom.w) / f1;
01446 src.y = (5000 + 10000 *(this->innerGeom.y - this->rootwindow->innerGeom.y)) / f2;
01447 src.h = (5000 + 10000 * this->innerGeom.h) / f2;
01448
01449 if (this->drawable) {
01450
01451 dst.x = 0;
01452 dst.w = this->innerGeom.w;
01453 dst.y = 0;
01454 dst.h = this->innerGeom.h;
01455
01456
01457 this->surface->setBlittingFlagsByBrightnessAlphaAndOpacity(255, (bgcolor.a)?bgcolor.a:255, 255);
01458 this->surface->stretchBlit(this->rootwindow->bgimage, &src, &dst);
01459 }
01460 else {
01461
01462 dst.x = this->innerGeom.x;
01463 dst.w = this->innerGeom.w;
01464 dst.y = this->innerGeom.y;
01465 dst.h = this->innerGeom.h;
01466
01467
01468 this->windowSurface->setBlittingFlagsByBrightnessAlphaAndOpacity(255, (bgcolor.a)?bgcolor.a:255, 255);
01469 this->windowSurface->stretchBlit(this->rootwindow->bgimage, &src, &dst);
01470 }
01471
01472 this->rootwindow->bgimage->unlock();
01473 }
01474 }
01475 }
01476
01477 if (!this->drawable) {
01478
01479 this->windowSurface->setClip(NULL);
01480 }
01481
01482 *backgroundFilled = true;
01483 }
01484 } while (retry);
01485
01486
01487 if (this->surface) this->surface->unlock();
01488 this->windowSurface->unlock();
01489
01490 return true;
01491 }
01492
01493
01494
01495 void MMSWidget::drawMyBorder() {
01496
01497 if ((!this->drawable)||(!this->geomset)||(!this->visible))
01498 return;
01499
01500 unsigned int margin;
01501 if (!getMargin(margin))
01502 margin = 0;
01503
01504 MMSFBRectangle mygeom;
01505 mygeom = this->geom;
01506 mygeom.x+= margin;
01507 mygeom.y+= margin;
01508 mygeom.w-= 2*margin;
01509 mygeom.h-= 2*margin;
01510
01511 unsigned int borderthickness;
01512 if (!getBorderThickness(borderthickness))
01513 borderthickness = 0;
01514
01515 bool borderrcorners;
01516 if (!getBorderRCorners(borderrcorners))
01517 borderrcorners = false;
01518
01519 if (isSelected()) {
01520 MMSFBColor c;
01521 getBorderSelColor(c);
01522 drawBorder(borderthickness, borderrcorners, this->da->borderselimages,
01523 this->da->borderselgeom, &(this->da->borderselgeomset), this->windowSurface,
01524 mygeom.x, mygeom.y, mygeom.w, mygeom.h, c, this->rootwindow->im,
01525 getBrightness(), getOpacity());
01526 }
01527 else {
01528 MMSFBColor c;
01529 getBorderColor(c);
01530 drawBorder(borderthickness, borderrcorners, this->da->borderimages,
01531 this->da->bordergeom, &(this->da->bordergeomset), this->windowSurface,
01532 mygeom.x, mygeom.y, mygeom.w, mygeom.h, c, this->rootwindow->im,
01533 getBrightness(), getOpacity());
01534 }
01535 }
01536
01537
01538
01539 bool MMSWidget::drawDebug() {
01540 if ((!this->geomset)||(!this->visible))
01541 return false;
01542
01543 bool debug;
01544 if (!this->getRootWindow()->getDebug(debug)) debug = false;
01545 if (debug) {
01546 this->surface->setDrawingFlagsByAlpha(255);
01547 this->windowSurface->setColor(255, 255, 255, 255);
01548 this->windowSurface->drawRectangle(this->geom.x, this->geom.y, this->geom.w, this->geom.h);
01549 if (this->innerGeom.x != this->geom.x) {
01550 this->windowSurface->setColor(200, 200, 200, 255);
01551 this->windowSurface->drawRectangle(this->innerGeom.x, this->innerGeom.y,
01552 this->innerGeom.w, this->innerGeom.h);
01553 }
01554 }
01555
01556 if (this->drawable) {
01557 if (this->da->initialArrowsDrawn == false) {
01558 switchArrowWidgets();
01559 this->da->initialArrowsDrawn = true;
01560 }
01561 }
01562
01563 return true;
01564 }
01565
01566 void MMSWidget::drawchildren(bool toRedrawOnly, bool *backgroundFilled, MMSFBRectangle *rect2update) {
01567
01568 if ((toRedrawOnly) && (this->toRedraw==false) && (this->redrawChildren==false))
01569 return;
01570
01571 if (!this->visible)
01572 return;
01573
01574 bool myBackgroundFilled = false;
01575 if (!backgroundFilled)
01576 backgroundFilled = &myBackgroundFilled;
01577
01578 if ((!toRedrawOnly)||(this->toRedraw)) {
01579 this->draw(backgroundFilled);
01580 }
01581
01582
01583 if ((!toRedrawOnly)||(this->toRedraw)||(this->redrawChildren)) {
01584 vector<MMSWidget *>::iterator end = this->children.end();
01585 for(vector<MMSWidget *>::iterator i = this->children.begin(); i != end; ++i) {
01586 MMSWidget *w = *i;
01587 if (!rect2update) {
01588
01589 w->drawchildren(toRedrawOnly, backgroundFilled, rect2update);
01590 }
01591 else {
01592
01593 if ((w->geom.x + w->geom.w > rect2update->x)
01594 &&(w->geom.x < rect2update->x + rect2update->w)
01595 &&(w->geom.y + w->geom.h > rect2update->y)
01596 &&(w->geom.y < rect2update->y + rect2update->h)) {
01597 w->drawchildren(toRedrawOnly, backgroundFilled, rect2update);
01598 }
01599 }
01600 }
01601
01602 drawMyBorder();
01603 }
01604
01605 this->toRedraw = this->redrawChildren = false;
01606
01607 }
01608
01609 void MMSWidget::themeChanged(string &themeName) {
01610 if (!isDrawable())
01611 return;
01612
01613
01614 release();
01615 this->initialized = false;
01616 }
01617
01618
01619 void MMSWidget::add(MMSWidget *widget) {
01620 if (canHaveChildren())
01621 if(this->children.size() < 1) {
01622
01623 this->children.push_back(widget);
01624
01625 children.at(0)->setParent(this);
01626 if (this->rootwindow)
01627 this->rootwindow->add(widget);
01628 }
01629 else
01630 throw MMSWidgetError(0,"this widget does only support one child");
01631 else
01632 throw MMSWidgetError(0,"this widget does not support children");
01633 }
01634
01635 void MMSWidget::markChildren2Redraw() {
01636 this->toRedraw = true;
01637 this->redrawChildren = true;
01638 vector<MMSWidget*>::iterator end = this->children.end();
01639 for(vector<MMSWidget*>::iterator i = this->children.begin(); i != end; ++i) {
01640 if((*i)->isVisible()) {
01641 (*i)->markChildren2Redraw();
01642 }
01643 }
01644 }
01645
01646 MMSWidget *MMSWidget::getDrawableParent(bool mark2Redraw, bool markChildren2Redraw, bool checkborder,
01647 vector<MMSWidget*> *wlist, bool followpath) {
01648 if (mark2Redraw) {
01649 this->toRedraw = true;
01650
01651 if (markChildren2Redraw) {
01652 this->markChildren2Redraw();
01653 }
01654 }
01655
01656 if (followpath)
01657 this->redrawChildren = true;
01658
01659 if (this->needsParentDraw(checkborder)==false) {
01660 if (wlist) wlist->push_back(this->parent);
01661 return this->parent->getDrawableParent(false, false, checkborder, wlist, true);
01662 }
01663 else
01664 if (this->parent) {
01665 if (wlist) wlist->push_back(this->parent);
01666 return this->parent->getDrawableParent(mark2Redraw, false, checkborder, wlist, followpath);
01667 }
01668
01669 return NULL;
01670 }
01671
01672 void MMSWidget::refresh(bool required) {
01673 MMSFBRectangle tobeupdated;
01674 unsigned int margin = 0;
01675 MMSWindow *myroot = this->rootwindow;
01676
01677
01678
01679 if (!this->geomset) {
01680
01681 return;
01682 }
01683
01684 if (!myroot) {
01685
01686 return;
01687 }
01688
01689
01690 if (recalcContentSize()) {
01691
01692 return;
01693 }
01694
01695
01696 if (!required) {
01697
01698 return;
01699 }
01700
01701 if (this->skip_refresh) {
01702
01703 return;
01704 }
01705
01706
01707 this->parent_rootwindow->lock();
01708
01709
01710
01711
01712 if (!myroot->isShown(true)) {
01713 DEBUGMSG("MMSGUI", "MMSWidget::refresh() skipped after MMSWindow::lock() because window is currently not shown");
01714
01715
01716 this->parent_rootwindow->unlock();
01717 return;
01718 }
01719
01720 if (this->drawable) {
01721 getMargin(margin);
01722 }
01723
01724
01725 tobeupdated.x = this->geom.x + margin;
01726 tobeupdated.y = this->geom.y + margin;
01727 tobeupdated.w = this->geom.w - 2*margin;
01728 tobeupdated.h = this->geom.h - 2*margin;
01729
01730
01731
01732 if (this->type == MMSWIDGETTYPE_MENU) {
01733 if (((MMSMenuWidget *)this)->getSmoothScrolling())
01734 recalculateChildren();
01735 }
01736
01737
01738 myroot->refreshFromChild(this->getDrawableParent(true, true), &tobeupdated, false);
01739
01740
01741 switchArrowWidgets();
01742
01743
01744 this->parent_rootwindow->unlock();
01745 }
01746
01747 bool MMSWidget::isDrawable() {
01748 return this->drawable;
01749 }
01750
01751 bool MMSWidget::needsParentDraw(bool checkborder) {
01752
01753
01754 return true;
01755
01756
01757
01758
01759 MMSFBColor c;
01760
01761 if (this->needsparentdraw)
01762 return true;
01763
01764 if (checkborder) {
01765 unsigned int borderthickness;
01766 if (!getBorderThickness(borderthickness))
01767 borderthickness = 0;
01768
01769 if (borderthickness>0) {
01770 bool borderrcorners;
01771 if (!getBorderRCorners(borderrcorners))
01772 borderrcorners = false;
01773
01774 if ((borderrcorners)||(getOpacity()!=255))
01775 return true;
01776 else
01777 if (this->selected) {
01778 MMSFBColor c;
01779 getBorderSelColor(c);
01780 if (c.a!=255)
01781 return true;
01782 }
01783 else {
01784 MMSFBColor c;
01785 getBorderColor(c);
01786 if (c.a!=255)
01787 return true;
01788 }
01789 }
01790 }
01791
01792 if (isActivated()) {
01793 if (!this->pressed) {
01794 if (this->selected) {
01795 getSelBgColor(c);
01796 if (c.a==255)
01797 return false;
01798 }
01799 else {
01800 getBgColor(c);
01801 if (c.a==255)
01802 return false;
01803 }
01804 }
01805 else {
01806 if (this->selected) {
01807 getSelBgColor_p(c);
01808 if (c.a==255)
01809 return false;
01810 }
01811 else {
01812 getBgColor_p(c);
01813 if (c.a==255)
01814 return false;
01815 }
01816 }
01817 }
01818 else {
01819 if (this->selected) {
01820 getSelBgColor_i(c);
01821 if (c.a==255)
01822 return false;
01823 }
01824 else {
01825 getBgColor_i(c);
01826 if (c.a==255)
01827 return false;
01828 }
01829 }
01830
01831 return true;
01832 }
01833
01834
01835 bool MMSWidget::canHaveChildren() {
01836 return this->canhavechildren;
01837 }
01838
01839 bool MMSWidget::canSelectChildren() {
01840 return this->canselectchildren;
01841 }
01842
01843
01844 void MMSWidget::setParent(MMSWidget *parent) {
01845 this->parent = parent;
01846 for_each(children.begin(), children.end(), bind2nd(mem_fun(&MMSWidget::setParent), this));
01847 }
01848
01849 MMSWidget *MMSWidget::getParent() {
01850 return this->parent;
01851 }
01852
01853 void MMSWidget::setRootWindow(MMSWindow *root, MMSWindow *parentroot) {
01854
01855 this->rootwindow = root;
01856
01857
01858 this->parent_rootwindow = parentroot;
01859
01860 if (this->rootwindow) {
01861
01862 if (!this->parent_rootwindow) {
01863 if (!this->rootwindow->parent)
01864 this->parent_rootwindow = this->rootwindow;
01865 else
01866 this->parent_rootwindow = this->rootwindow->getParent(true);
01867 }
01868
01869
01870 this->windowSurface = this->rootwindow->getSurface();
01871 this->rootwindow->add(this);
01872
01873 bool initial_load = false;
01874 this->rootwindow->getInitialLoad(initial_load);
01875 if (initial_load) {
01876
01877 init();
01878 }
01879 }
01880
01881
01882 vector<MMSWidget*>::iterator end = this->children.end();
01883 for(vector<MMSWidget*>::iterator i = this->children.begin(); i != end; ++i) {
01884 (*i)->setRootWindow(this->rootwindow, this->parent_rootwindow);
01885 }
01886 }
01887
01888 void MMSWidget::recalculateChildren() {
01889
01890 if(this->children.size() == 1) {
01891 children.at(0)->setGeometry(innerGeom);
01892 }
01893
01894 }
01895
01896 MMSWindow *MMSWidget::getRootWindow(MMSWindow **parentroot) {
01897 if (parentroot)
01898 *parentroot = this->parent_rootwindow;
01899 return this->rootwindow;
01900 }
01901
01902 int MMSWidget::getId() {
01903 return this->id;
01904 }
01905
01906 string MMSWidget::getName() {
01907 return this->name;
01908 }
01909
01910 void MMSWidget::setName(string name) {
01911 this->name = name;
01912 }
01913
01914
01915 void MMSWidget::setFocus(bool set, bool refresh, MMSInputEvent *inputevent) {
01916
01917 bool b;
01918 if (!getFocusable(b))
01919 return;
01920 if (!b)
01921 return;
01922
01923
01924 this->focused = set;
01925
01926 if (this->rootwindow) {
01927
01928
01929
01930 this->rootwindow->setFocusedWidget(this, set, true, refresh);
01931 }
01932
01933
01934
01935
01936 setSelected(set, refresh);
01937
01938
01939
01940
01941
01942 this->onFocus->emit(this, set);
01943
01944
01945 if (inputevent) {
01946 bool scrollonfocus;
01947 if (getScrollOnFocus(scrollonfocus)) {
01948 if (scrollonfocus) {
01949 if (inputevent->type == MMSINPUTEVENTTYPE_KEYPRESS) {
01950 switch (inputevent->key) {
01951 case MMSKEY_CURSOR_DOWN:
01952 scrollDown();
01953 break;
01954 case MMSKEY_CURSOR_UP:
01955 scrollUp();
01956 break;
01957 case MMSKEY_CURSOR_RIGHT:
01958 scrollRight();
01959 break;
01960 case MMSKEY_CURSOR_LEFT:
01961 scrollLeft();
01962 break;
01963 default:
01964 break;
01965 }
01966 }
01967 }
01968 }
01969 }
01970 }
01971
01972 bool MMSWidget::isFocused() {
01973 return this->focused;
01974 }
01975
01976 void MMSWidget::getJoinedWigdets(MMSWidget **caller_stack) {
01977 if ((this->da)&&(this->da->joinedWidget)) {
01978 int i=0;
01979 while ((caller_stack[i]) && (caller_stack[i] != this) && (i < 16)) i++;
01980 if (!caller_stack[i]) {
01981 caller_stack[i] = this;
01982 this->da->joinedWidget->getJoinedWigdets(caller_stack);
01983 }
01984 }
01985 }
01986
01987
01988 bool MMSWidget::setSelected(bool set, bool refresh, bool *changed, bool joined) {
01989 if (changed)
01990 *changed = false;
01991
01992 if (!joined) {
01993 if ((this->da)&&(this->da->joinedWidget)) {
01994
01995 MMSWidget *caller_stack[16] = {0};
01996 caller_stack[0] = this;
01997 this->da->joinedWidget->getJoinedWigdets(caller_stack);
01998 int i = 16;
01999 while (i-- > 1) {
02000 if (caller_stack[i]) {
02001 caller_stack[i]->setSelected(set, refresh, NULL, true);
02002 }
02003 }
02004 }
02005 }
02006
02007
02008 if (this->selected == set) {
02009
02010 if (canSelectChildren()) {
02011 bool rf = false;
02012 vector<MMSWidget*>::iterator end = children.end();
02013 for(vector<MMSWidget*>::iterator i = children.begin(); i != end; ++i) {
02014 if((*i)->setSelected(set, false)) {
02015 rf = true;
02016 }
02017 }
02018
02019 if (refresh && rf)
02020 this->refresh();
02021 }
02022 return false;
02023 }
02024
02025
02026 bool selectable;
02027 if (!getSelectable(selectable))
02028 selectable = false;
02029 bool canselchildren = canSelectChildren();
02030
02031
02032 if (selectable) {
02033 this->selected=set;
02034 if (changed) *changed = true;
02035 }
02036
02037
02038
02039 checkRefreshStatus();
02040
02041
02042
02043 if (canselchildren) {
02044 vector<MMSWidget*>::iterator end = children.end();
02045 for(vector<MMSWidget*>::iterator i = children.begin(); i != end; ++i) {
02046 (*i)->setSelected(set, false);
02047 }
02048 }
02049
02050
02051 if (((selectable)||(canselchildren))&&(refresh))
02052 this->refresh();
02053
02054
02055 if (selectable)
02056 if (set)
02057 this->onSelect->emit(this);
02058
02059 return true;
02060 }
02061
02062 bool MMSWidget::setSelected(bool set, bool refresh) {
02063 return setSelected(set, refresh, NULL, false);
02064 }
02065
02066 bool MMSWidget::isSelected() {
02067 return this->selected;
02068 }
02069
02070 void MMSWidget::unsetFocusableForAllChildren(bool refresh) {
02071 vector<MMSWidget*>::iterator end = children.end();
02072 for(vector<MMSWidget*>::iterator i = children.begin(); i != end; ++i) {
02073 (*i)->setFocusable(false, refresh);
02074 (*i)->unsetFocusableForAllChildren(refresh);
02075 }
02076 }
02077
02078
02079 bool MMSWidget::isActivated() {
02080 bool activated = true;
02081 getActivated(activated);
02082 return activated;
02083 }
02084
02085 bool MMSWidget::setPressed(bool set, bool refresh, bool joined) {
02086
02087 if (!joined) {
02088 if ((this->da)&&(this->da->joinedWidget)) {
02089
02090 MMSWidget *caller_stack[16] = {0};
02091 caller_stack[0] = this;
02092 this->da->joinedWidget->getJoinedWigdets(caller_stack);
02093 int i = 16;
02094 while (i-- > 1) {
02095 if (caller_stack[i])
02096 caller_stack[i]->setPressed(set, refresh, true);
02097 }
02098 }
02099 }
02100
02101
02102 if (this->pressed == set) {
02103
02104 if (canSelectChildren()) {
02105 bool ref = false;
02106 vector<MMSWidget*>::iterator end = children.end();
02107 for(vector<MMSWidget*>::iterator i = children.begin(); i != end; ++i) {
02108 if((*i)->setPressed(set, false)) {
02109 ref = true;
02110 }
02111 }
02112 if (ref && refresh) {
02113
02114 this->refresh();
02115 }
02116 }
02117
02118
02119 return false;
02120 }
02121
02122
02123 this->pressed = set;
02124
02125
02126
02127 checkRefreshStatus();
02128
02129
02130
02131 if (canSelectChildren()) {
02132 vector<MMSWidget*>::iterator end = children.end();
02133 for(vector<MMSWidget*>::iterator i = children.begin(); i != end; ++i) {
02134 (*i)->setPressed(set, false);
02135 }
02136 }
02137
02138
02139 this->refresh(refresh);
02140
02141
02142 return true;
02143 }
02144
02145 bool MMSWidget::setPressed(bool set, bool refresh) {
02146 return setPressed(set, refresh, false);
02147 }
02148
02149 bool MMSWidget::isPressed() {
02150 return this->pressed;
02151 }
02152
02153 void MMSWidget::setASelected(bool set, bool refresh) {
02154 setActivated(true, false);
02155 setSelected(set, refresh);
02156 }
02157
02158 void MMSWidget::setPSelected(bool set, bool refresh) {
02159 setPressed(true, false);
02160 setSelected(set, refresh);
02161 }
02162
02163 void MMSWidget::setISelected(bool set, bool refresh) {
02164 setActivated(false, false);
02165 setSelected(set, refresh);
02166 }
02167
02168 #ifdef sdsds
02169 void MMSWidget::handleNavigation(DFBInputDeviceKeySymbol key, MMSWidget *requestingchild) {
02170
02171 this->parent->handleNavigation(key,this);
02172 }
02173 #endif
02174
02175
02176
02177 void MMSWidget::resetPressed() {
02178
02179 string inputmode = "";
02180 getInputModeEx(inputmode);
02181 if (strToUpr(inputmode) == "CLICK") {
02182
02183 if (isPressed())
02184 setPressed(false);
02185
02186
02187 bool b = false;
02188 this->getFocusable(b);
02189 if (b)
02190 this->setFocus(false);
02191 else
02192 this->setSelected(false);
02193 }
02194 else {
02195
02196 if (isPressed())
02197 setPressed(false);
02198 }
02199 }
02200
02201
02202 void MMSWidget::handleInput(MMSInputEvent *inputevent) {
02203 bool b;
02204 if (inputevent->type == MMSINPUTEVENTTYPE_KEYPRESS) {
02205
02206
02207
02208 this->da->last_inputevent = *inputevent;
02209
02210 switch (inputevent->key) {
02211 case MMSKEY_CURSOR_DOWN:
02212
02213
02214
02215
02216
02217
02218
02219
02220
02221
02222 if (scrollDown())
02223 return;
02224 break;
02225
02226 case MMSKEY_CURSOR_UP:
02227 if (scrollUp())
02228 return;
02229 break;
02230
02231 case MMSKEY_CURSOR_RIGHT:
02232 if (scrollRight())
02233 return;
02234 break;
02235
02236 case MMSKEY_CURSOR_LEFT:
02237 if (scrollLeft())
02238 return;
02239 break;
02240
02241 case MMSKEY_RETURN:
02242 case MMSKEY_ZOOM:
02243
02244 if (emitOnReturnCallback()) {
02245 return;
02246 }
02247 break;
02248
02249 default:
02250 break;
02251 }
02252 }
02253 else
02254 if (inputevent->type == MMSINPUTEVENTTYPE_BUTTONPRESS) {
02255
02256 if (getClickable(b))
02257 if (b) {
02258
02259 this->da->last_inputevent = *inputevent;
02260 this->da->pressed_inputrect = this->geom;
02261
02262
02263 if (!isPressed())
02264 setPressed(true);
02265
02266
02267
02268 scrollTo(inputevent->posx, inputevent->posy, true, NULL,
02269 MMSWIDGET_SCROLL_MODE_SETPRESSED, &this->da->pressed_inputrect);
02270
02271 return;
02272 }
02273 }
02274 else
02275 if (inputevent->type == MMSINPUTEVENTTYPE_BUTTONRELEASE) {
02276
02277 if (getClickable(b))
02278 if (b) {
02279 if (this->da->last_inputevent.type == MMSINPUTEVENTTYPE_BUTTONPRESS) {
02280
02281 resetPressed();
02282
02283
02284 if ((inputevent->posx >= this->da->pressed_inputrect.x)&&(inputevent->posy >= this->da->pressed_inputrect.y)
02285 &&(inputevent->posx < this->da->pressed_inputrect.x + this->da->pressed_inputrect.w)&&(inputevent->posy < this->da->pressed_inputrect.y + this->da->pressed_inputrect.h)) {
02286
02287 bool changed = false;
02288 bool st_ok = scrollTo(this->da->last_inputevent.posx, this->da->last_inputevent.posy, true, &changed,
02289 MMSWIDGET_SCROLL_MODE_SETSELECTED | MMSWIDGET_SCROLL_MODE_RMPRESSED);
02290
02291
02292 this->onClick->emit(this, inputevent->posx - this->geom.x, inputevent->posy - this->geom.y,
02293 this->geom.w, this->geom.h);
02294
02295 if (changed) {
02296
02297 bool r;
02298 if (!getReturnOnScroll(r)) r = true;
02299 if (r) changed = false;
02300 }
02301 if (!changed && st_ok) {
02302
02303 emitOnReturnCallback();
02304 }
02305 }
02306 }
02307
02308
02309 resetPressed();
02310
02311
02312 this->da->last_inputevent = *inputevent;
02313 return;
02314 }
02315 }
02316 else
02317 if (inputevent->type == MMSINPUTEVENTTYPE_AXISMOTION) {
02318
02319 if (getClickable(b))
02320 if (b) {
02321 if (this->da->last_inputevent.type == MMSINPUTEVENTTYPE_BUTTONPRESS) {
02322
02323 if ((inputevent->posx >= this->da->pressed_inputrect.x)&&(inputevent->posy >= this->da->pressed_inputrect.y)
02324 &&(inputevent->posx < this->da->pressed_inputrect.x + this->da->pressed_inputrect.w)&&(inputevent->posy < this->da->pressed_inputrect.y + this->da->pressed_inputrect.h)) {
02325
02326 if (!isPressed())
02327 setPressed(true);
02328
02329
02330 scrollTo(this->da->last_inputevent.posx, this->da->last_inputevent.posy, true, NULL,
02331 MMSWIDGET_SCROLL_MODE_SETPRESSED);
02332 }
02333 else {
02334
02335 if (isPressed())
02336 setPressed(false);
02337
02338
02339 scrollTo(this->da->last_inputevent.posx, this->da->last_inputevent.posy, true, NULL,
02340 MMSWIDGET_SCROLL_MODE_RMPRESSED);
02341 }
02342 }
02343
02344 return;
02345 }
02346 }
02347
02348 throw MMSWidgetError(1,"input not handled");
02349 }
02350
02351
02352 bool MMSWidget::callOnReturn() {
02353 return true;
02354 }
02355
02356 bool MMSWidget::emitOnReturnCallback() {
02357
02358 if (!this->onReturn) return false;
02359
02360
02361 if (this->onReturn->empty()) return false;
02362
02363
02364 if (callOnReturn()) {
02365
02366 bool b;
02367 if (getFocusable(b, false)) {
02368 if (b) {
02369
02370 this->onReturn->emit(this);
02371 return true;
02372 }
02373 }
02374
02375
02376 printf("Widget \"%s\" (%s) is not focusable, cannot emit onReturn signal!\n",
02377 this->name.c_str(), this->getTypeString().c_str());
02378
02379 return false;
02380 }
02381 else {
02382
02383 return false;
02384 }
02385 }
02386
02387
02388
02389
02390
02391
02392
02393
02394
02395
02396
02397
02398
02399 void MMSWidget::setBinData(void *data) {
02400 this->bindata = data;
02401 }
02402
02403 void *MMSWidget::getBinData() {
02404 return this->bindata;
02405
02406 }
02407
02408 string MMSWidget::getSizeHint() {
02409 return this->sizehint;
02410 }
02411
02412 bool MMSWidget::setSizeHint(string &hint) {
02413 if (getPixelFromSizeHint(NULL, hint, 10000, 0)) {
02414 this->sizehint = hint;
02415 return true;
02416 }
02417 else
02418 return false;
02419 }
02420
02421 string MMSWidget::getMinWidth() {
02422 return this->min_width;
02423 }
02424
02425 int MMSWidget::getMinWidthPix() {
02426 return this->min_width_pix;
02427 }
02428
02429 bool MMSWidget::setMinWidth(string &min_width) {
02430 int pix, base_pix = 10000;
02431 if (this->rootwindow) base_pix = this->rootwindow->geom.w;
02432
02433 if (getPixelFromSizeHint(&pix, min_width, base_pix, 0)) {
02434 this->min_width = min_width;
02435 this->min_width_pix = pix;
02436 this->minmax_set = true;
02437 return true;
02438 }
02439 else
02440 return false;
02441 }
02442
02443 string MMSWidget::getMinHeight() {
02444 return this->min_height;
02445 }
02446
02447 int MMSWidget::getMinHeightPix() {
02448 return this->min_height_pix;
02449 }
02450
02451 bool MMSWidget::setMinHeight(string &min_height) {
02452 int pix, base_pix = 10000;
02453 if (this->rootwindow) base_pix = this->rootwindow->geom.h;
02454
02455 if (getPixelFromSizeHint(&pix, min_height, base_pix, 0)) {
02456 this->min_height = min_height;
02457 this->min_height_pix = pix;
02458 this->minmax_set = true;
02459 return true;
02460 }
02461 else
02462 return false;
02463 }
02464
02465 string MMSWidget::getMaxWidth() {
02466 return this->max_width;
02467 }
02468
02469 int MMSWidget::getMaxWidthPix() {
02470 return this->max_width_pix;
02471 }
02472
02473 bool MMSWidget::setMaxWidth(string &max_width) {
02474 int pix, base_pix = 10000;
02475 if (this->rootwindow) base_pix = this->rootwindow->geom.w;
02476
02477 if (getPixelFromSizeHint(&pix, max_width, base_pix, 0)) {
02478 this->max_width = max_width;
02479 this->max_width_pix = pix;
02480 this->minmax_set = true;
02481 return true;
02482 }
02483 else
02484 return false;
02485 }
02486
02487 string MMSWidget::getMaxHeight() {
02488 return this->max_height;
02489 }
02490
02491 int MMSWidget::getMaxHeightPix() {
02492 return this->max_height_pix;
02493 }
02494
02495 bool MMSWidget::setMaxHeight(string &max_height) {
02496 int pix, base_pix = 10000;
02497 if (this->rootwindow) base_pix = this->rootwindow->geom.h;
02498
02499 if (getPixelFromSizeHint(&pix, max_height, base_pix, 0)) {
02500 this->max_height = max_height;
02501 this->max_height_pix = pix;
02502 this->minmax_set = true;
02503 return true;
02504 }
02505 else
02506 return false;
02507 }
02508
02509 bool MMSWidget::isGeomSet() {
02510 return this->geomset;
02511 }
02512
02513 void MMSWidget::setGeomSet(bool set) {
02514 this->geomset = set;
02515 }
02516
02517
02518 bool MMSWidget::isVisible() {
02519 return this->visible;
02520 }
02521
02522 void MMSWidget::setVisible(bool visible, bool refresh) {
02523
02524 if (this->geomset) {
02525 if (visible) {
02526 if (!this->visible) {
02527 if ((!this->surface)&&(surfaceGeom.w!=0)&&(surfaceGeom.h!=0)) {
02528 unsigned int w,h;
02529 w=surfaceGeom.w;
02530 h=surfaceGeom.h;
02531 surfaceGeom.w=0;
02532 surfaceGeom.h=0;
02533 setSurfaceGeometry(w,h);
02534 }
02535 }
02536 }
02537 else {
02538 if (this->visible) {
02539 if (this->surface) {
02540 delete this->surface;
02541 this->surface = NULL;
02542 }
02543 }
02544 }
02545 }
02546
02547
02548
02549
02550
02551
02552 this->visible = visible;
02553 vector<MMSWidget*>::iterator end = children.end();
02554 for(vector<MMSWidget*>::iterator i = children.begin(); i != end; ++i) {
02555 (*i)->setVisible(this->visible, false);
02556 }
02557
02558
02559 enableRefresh();
02560
02561 this->refresh(refresh);
02562 }
02563
02564 unsigned char MMSWidget::getBrightness() {
02565 return this->brightness;
02566 }
02567
02568 void MMSWidget::setBrightness(unsigned char brightness, bool refresh) {
02569 this->brightness = brightness;
02570 vector<MMSWidget*>::iterator end = children.end();
02571 for(vector<MMSWidget*>::iterator i = children.begin(); i != end; ++i) {
02572 (*i)->setBrightness(brightness, false);
02573 }
02574
02575
02576 enableRefresh();
02577
02578 this->refresh(refresh);
02579 }
02580
02581 unsigned char MMSWidget::getOpacity() {
02582 return this->opacity;
02583 }
02584
02585 void MMSWidget::setOpacity(unsigned char opacity, bool refresh) {
02586 this->opacity = opacity;
02587 vector<MMSWidget*>::iterator end = children.end();
02588 for(vector<MMSWidget*>::iterator i = children.begin(); i != end; ++i) {
02589 (*i)->setOpacity(opacity, false);
02590 }
02591
02592
02593 enableRefresh();
02594
02595 this->refresh(refresh);
02596 }
02597
02598
02599 MMSWidget *MMSWidget::getNavigateUpWidget() {
02600 return this->da->navigateUpWidget;
02601 }
02602
02603 MMSWidget *MMSWidget::getNavigateDownWidget() {
02604 return this->da->navigateDownWidget;
02605 }
02606
02607 MMSWidget *MMSWidget::getNavigateLeftWidget() {
02608 return this->da->navigateLeftWidget;
02609 }
02610
02611 MMSWidget *MMSWidget::getNavigateRightWidget() {
02612 return this->da->navigateRightWidget;
02613 }
02614
02615 void MMSWidget::setNavigateUpWidget(MMSWidget *upwidget) {
02616 this->da->navigateUpWidget = upwidget;
02617 }
02618
02619 void MMSWidget::setNavigateDownWidget(MMSWidget *downwidget) {
02620 this->da->navigateDownWidget = downwidget;
02621 }
02622
02623 void MMSWidget::setNavigateRightWidget(MMSWidget *rightwidget) {
02624 this->da->navigateRightWidget = rightwidget;
02625 }
02626
02627 void MMSWidget::setNavigateLeftWidget(MMSWidget *leftwidget) {
02628 this->da->navigateLeftWidget = leftwidget;
02629 }
02630
02631 bool MMSWidget::canNavigateUp() {
02632 if (this->da->navigateUpWidget)
02633 return true;
02634 else
02635 return scrollUp(1, false, true);
02636 }
02637
02638 bool MMSWidget::canNavigateDown() {
02639 if (this->da->navigateDownWidget)
02640 return true;
02641 else
02642 return scrollDown(1, false, true);
02643 }
02644
02645 bool MMSWidget::canNavigateLeft() {
02646 if (this->da->navigateLeftWidget)
02647 return true;
02648 else
02649 return scrollLeft(1, false, true);
02650 }
02651
02652 bool MMSWidget::canNavigateRight() {
02653 if (this->da->navigateRightWidget)
02654 return true;
02655 else
02656 return scrollRight(1, false, true);
02657 }
02658
02659
02660
02661
02662
02663 #define GETWIDGET(x,y) \
02664 if (!this->da) return false; \
02665 else if (this->da->myWidgetClass.is##x()) return this->da->myWidgetClass.get##x(y); \
02666 else if ((this->da->widgetClass)&&(this->da->widgetClass->is##x())) return this->da->widgetClass->get##x(y); \
02667 else if (this->da->baseWidgetClass) return this->da->baseWidgetClass->get##x(y); \
02668 else return this->da->myWidgetClass.get##x(y);
02669
02670
02671 bool MMSWidget::getBgColor(MMSFBColor &bgcolor) {
02672 GETWIDGET(BgColor, bgcolor);
02673 }
02674
02675 bool MMSWidget::getSelBgColor(MMSFBColor &selbgcolor) {
02676 GETWIDGET(SelBgColor, selbgcolor);
02677 }
02678
02679 bool MMSWidget::getBgColor_p(MMSFBColor &bgcolor_p) {
02680 GETWIDGET(BgColor_p, bgcolor_p);
02681 }
02682
02683 bool MMSWidget::getSelBgColor_p(MMSFBColor &selbgcolor_p) {
02684 GETWIDGET(SelBgColor_p, selbgcolor_p);
02685 }
02686
02687 bool MMSWidget::getBgColor_i(MMSFBColor &bgcolor_i) {
02688 GETWIDGET(BgColor_i, bgcolor_i);
02689 }
02690
02691 bool MMSWidget::getSelBgColor_i(MMSFBColor &selbgcolor_i) {
02692 GETWIDGET(SelBgColor_i, selbgcolor_i);
02693 }
02694
02695 bool MMSWidget::getBgImagePath(string &bgimagepath) {
02696 GETWIDGET(BgImagePath,bgimagepath);
02697 }
02698
02699 bool MMSWidget::getBgImageName(string &bgimagename) {
02700 GETWIDGET(BgImageName,bgimagename);
02701 }
02702
02703 bool MMSWidget::getSelBgImagePath(string &selbgimagepath) {
02704 GETWIDGET(SelBgImagePath, selbgimagepath);
02705 }
02706
02707 bool MMSWidget::getSelBgImageName(string &selbgimagename) {
02708 GETWIDGET(SelBgImageName, selbgimagename);
02709 }
02710
02711 bool MMSWidget::getBgImagePath_p(string &bgimagepath_p) {
02712 GETWIDGET(BgImagePath_p, bgimagepath_p);
02713 }
02714
02715 bool MMSWidget::getBgImageName_p(string &bgimagename_p) {
02716 GETWIDGET(BgImageName_p, bgimagename_p);
02717 }
02718
02719 bool MMSWidget::getSelBgImagePath_p(string &selbgimagepath_p) {
02720 GETWIDGET(SelBgImagePath_p, selbgimagepath_p);
02721 }
02722
02723 bool MMSWidget::getSelBgImageName_p(string &selbgimagename_p) {
02724 GETWIDGET(SelBgImageName_p, selbgimagename_p);
02725 }
02726
02727 bool MMSWidget::getBgImagePath_i(string &bgimagepath_i) {
02728 GETWIDGET(BgImagePath_i, bgimagepath_i);
02729 }
02730
02731 bool MMSWidget::getBgImageName_i(string &bgimagename_i) {
02732 GETWIDGET(BgImageName_i, bgimagename_i);
02733 }
02734
02735 bool MMSWidget::getSelBgImagePath_i(string &selbgimagepath_i) {
02736 GETWIDGET(SelBgImagePath_i, selbgimagepath_i);
02737 }
02738
02739 bool MMSWidget::getSelBgImageName_i(string &selbgimagename_i) {
02740 GETWIDGET(SelBgImageName_i, selbgimagename_i);
02741 }
02742
02743 bool MMSWidget::getMargin(unsigned int &margin) {
02744 GETWIDGET(Margin, margin);
02745 }
02746
02747 bool MMSWidget::getFocusable(bool &focusable, bool check_selectable) {
02748 if (check_selectable) {
02749 if (getSelectable(focusable)) {
02750 if (focusable) {
02751 GETWIDGET(Focusable, focusable);
02752 }
02753 }
02754 else {
02755 GETWIDGET(Focusable, focusable);
02756 }
02757 }
02758 else {
02759 GETWIDGET(Focusable, focusable);
02760 }
02761
02762 return false;
02763 }
02764
02765 bool MMSWidget::getSelectable(bool &selectable) {
02766 GETWIDGET(Selectable, selectable);
02767 }
02768
02769 bool MMSWidget::getUpArrow(string &uparrow) {
02770 GETWIDGET(UpArrow, uparrow);
02771 }
02772
02773 bool MMSWidget::getDownArrow(string &downarrow) {
02774 GETWIDGET(DownArrow, downarrow);
02775 }
02776
02777 bool MMSWidget::getLeftArrow(string &leftarrow) {
02778 GETWIDGET(LeftArrow, leftarrow);
02779 }
02780
02781 bool MMSWidget::getRightArrow(string &rightarrow) {
02782 GETWIDGET(RightArrow, rightarrow);
02783 }
02784
02785 bool MMSWidget::getData(string &data) {
02786 GETWIDGET(Data, data);
02787 }
02788
02789 bool MMSWidget::getNavigateUp(string &navigateup) {
02790 GETWIDGET(NavigateUp, navigateup);
02791 }
02792
02793 bool MMSWidget::getNavigateDown(string &navigatedown) {
02794 GETWIDGET(NavigateDown, navigatedown);
02795 }
02796
02797 bool MMSWidget::getNavigateLeft(string &navigateleft) {
02798 GETWIDGET(NavigateLeft, navigateleft);
02799 }
02800
02801 bool MMSWidget::getNavigateRight(string &navigateright) {
02802 GETWIDGET(NavigateRight, navigateright);
02803 }
02804
02805
02806 bool MMSWidget::getVSlider(string &vslider) {
02807 GETWIDGET(VSlider, vslider);
02808 }
02809
02810 bool MMSWidget::getHSlider(string &hslider) {
02811 GETWIDGET(HSlider, hslider);
02812 }
02813
02814 bool MMSWidget::getImagesOnDemand(bool &imagesondemand) {
02815 GETWIDGET(ImagesOnDemand, imagesondemand);
02816 }
02817
02818 bool MMSWidget::getBlend(unsigned int &blend) {
02819 GETWIDGET(Blend, blend);
02820 }
02821
02822 bool MMSWidget::getBlendFactor(double &blendfactor) {
02823 GETWIDGET(BlendFactor, blendfactor);
02824 }
02825
02826 bool MMSWidget::getScrollOnFocus(bool &scrollonfocus) {
02827 GETWIDGET(ScrollOnFocus, scrollonfocus);
02828 }
02829
02830 bool MMSWidget::getClickable(bool &clickable) {
02831 GETWIDGET(Clickable, clickable);
02832 }
02833
02834 bool MMSWidget::getReturnOnScroll(bool &returnonscroll) {
02835 GETWIDGET(ReturnOnScroll, returnonscroll);
02836 }
02837
02838 bool MMSWidget::getInputMode(string &inputmode) {
02839 GETWIDGET(InputMode, inputmode);
02840 }
02841
02842 bool MMSWidget::getInputModeEx(string &inputmode) {
02843 getInputMode(inputmode);
02844 if (inputmode == "") {
02845 if (this->parent)
02846 return this->parent->getInputModeEx(inputmode);
02847 else
02848 inputmode = MMSWidget_inputmode;
02849 }
02850 return true;
02851 }
02852
02853 bool MMSWidget::getJoinedWidget(string &joinedwidget) {
02854 GETWIDGET(JoinedWidget, joinedwidget);
02855 }
02856
02857 bool MMSWidget::getActivated(bool &activated) {
02858 GETWIDGET(Activated, activated);
02859 }
02860
02861
02862 #define GETBORDER(x,y) \
02863 if (!this->da) return false; \
02864 else if (this->da->myWidgetClass.border.is##x()) return this->da->myWidgetClass.border.get##x(y); \
02865 else if ((this->da->widgetClass)&&(this->da->widgetClass->border.is##x())) return this->da->widgetClass->border.get##x(y); \
02866 else return this->da->baseWidgetClass->border.get##x(y);
02867
02868 #define GETBORDER_IMAGES(x,p,y) \
02869 if (!this->da) return false; \
02870 else if (this->da->myWidgetClass.border.is##x()) return this->da->myWidgetClass.border.get##x(p,y); \
02871 else if ((this->da->widgetClass)&&(this->da->widgetClass->border.is##x())) return this->da->widgetClass->border.get##x(p,y); \
02872 else return this->da->baseWidgetClass->border.get##x(p,y);
02873
02874
02875
02876 bool MMSWidget::getBorderColor(MMSFBColor &color) {
02877 GETBORDER(Color, color);
02878 }
02879
02880 bool MMSWidget::getBorderSelColor(MMSFBColor &selcolor) {
02881 GETBORDER(SelColor, selcolor);
02882 }
02883
02884 bool MMSWidget::getBorderImagePath(string &imagepath) {
02885 GETBORDER(ImagePath, imagepath);
02886 }
02887
02888 bool MMSWidget::getBorderImageNames(MMSBORDER_IMAGE_NUM num, string &imagename) {
02889 GETBORDER_IMAGES(ImageNames, num, imagename);
02890 }
02891
02892 bool MMSWidget::getBorderSelImagePath(string &selimagepath) {
02893 GETBORDER(SelImagePath, selimagepath);
02894 }
02895
02896 bool MMSWidget::getBorderSelImageNames(MMSBORDER_IMAGE_NUM num, string &selimagename) {
02897 GETBORDER_IMAGES(SelImageNames, num, selimagename);
02898 }
02899
02900 bool MMSWidget::getBorderThickness(unsigned int &thickness) {
02901 GETBORDER(Thickness, thickness);
02902 }
02903
02904 bool MMSWidget::getBorderMargin(unsigned int &margin) {
02905 GETBORDER(Margin, margin);
02906 }
02907
02908 bool MMSWidget::getBorderRCorners(bool &rcorners) {
02909 GETBORDER(RCorners, rcorners);
02910 }
02911
02912
02913
02914
02915
02916 bool MMSWidget::setBgColor(MMSFBColor bgcolor, bool refresh) {
02917 if (!this->da) return false;
02918 this->da->myWidgetClass.setBgColor(bgcolor);
02919
02920
02921 enableRefresh((bgcolor != this->current_bgcolor));
02922
02923 this->refresh(refresh);
02924
02925 return true;
02926 }
02927
02928 bool MMSWidget::setSelBgColor(MMSFBColor selbgcolor, bool refresh) {
02929 if (!this->da) return false;
02930 this->da->myWidgetClass.setSelBgColor(selbgcolor);
02931
02932
02933 enableRefresh((selbgcolor != this->current_bgcolor));
02934
02935 this->refresh(refresh);
02936
02937 return true;
02938 }
02939
02940 bool MMSWidget::setBgColor_p(MMSFBColor bgcolor_p, bool refresh) {
02941 if (!this->da) return false;
02942 this->da->myWidgetClass.setBgColor_p(bgcolor_p);
02943
02944
02945 enableRefresh((bgcolor_p != this->current_bgcolor));
02946
02947 this->refresh(refresh);
02948
02949 return true;
02950 }
02951
02952 bool MMSWidget::setSelBgColor_p(MMSFBColor selbgcolor_p, bool refresh) {
02953 if (!this->da) return false;
02954 this->da->myWidgetClass.setSelBgColor_p(selbgcolor_p);
02955
02956
02957 enableRefresh((selbgcolor_p != this->current_bgcolor));
02958
02959 this->refresh(refresh);
02960
02961 return true;
02962 }
02963
02964 bool MMSWidget::setBgColor_i(MMSFBColor bgcolor_i, bool refresh) {
02965 if (!this->da) return false;
02966 this->da->myWidgetClass.setBgColor_i(bgcolor_i);
02967
02968
02969 enableRefresh((bgcolor_i != this->current_bgcolor));
02970
02971 this->refresh(refresh);
02972
02973 return true;
02974 }
02975
02976 bool MMSWidget::setSelBgColor_i(MMSFBColor selbgcolor_i, bool refresh) {
02977 if (!this->da) return false;
02978 this->da->myWidgetClass.setSelBgColor_i(selbgcolor_i);
02979
02980
02981 enableRefresh((selbgcolor_i != this->current_bgcolor));
02982
02983 this->refresh(refresh);
02984
02985 return true;
02986 }
02987
02988 bool MMSWidget::setBgImagePath(string bgimagepath, bool load, bool refresh) {
02989 if (!this->da) return false;
02990 this->da->myWidgetClass.setBgImagePath(bgimagepath);
02991 if (load) {
02992 if (this->rootwindow) {
02993
02994 enableRefresh((this->da->bgimage == this->current_bgimage));
02995
02996 this->rootwindow->im->releaseImage(this->da->bgimage);
02997 string path, name;
02998 if (!getBgImagePath(path)) path = "";
02999 if (!getBgImageName(name)) name = "";
03000 this->da->bgimage = this->rootwindow->im->getImage(path, name);
03001 }
03002 }
03003
03004 this->refresh(refresh);
03005
03006 return true;
03007 }
03008
03009 bool MMSWidget::setBgImageName(string bgimagename, bool load, bool refresh) {
03010 if (!this->da) return false;
03011 this->da->myWidgetClass.setBgImageName(bgimagename);
03012 if (load) {
03013 if (this->rootwindow) {
03014
03015 enableRefresh((this->da->bgimage == this->current_bgimage));
03016
03017 this->rootwindow->im->releaseImage(this->da->bgimage);
03018 string path, name;
03019 if (!getBgImagePath(path)) path = "";
03020 if (!getBgImageName(name)) name = "";
03021 this->da->bgimage = this->rootwindow->im->getImage(path, name);
03022 }
03023 }
03024
03025 this->refresh(refresh);
03026
03027 return true;
03028 }
03029
03030 bool MMSWidget::setSelBgImagePath(string selbgimagepath, bool load, bool refresh) {
03031 if (!this->da) return false;
03032 this->da->myWidgetClass.setSelBgImagePath(selbgimagepath);
03033 if (load) {
03034 if (this->rootwindow) {
03035
03036 enableRefresh((this->da->selbgimage == this->current_bgimage));
03037
03038 this->rootwindow->im->releaseImage(this->da->selbgimage);
03039 string path, name;
03040 if (!getSelBgImagePath(path)) path = "";
03041 if (!getSelBgImageName(name)) name = "";
03042 this->da->selbgimage = this->rootwindow->im->getImage(path, name);
03043 }
03044 }
03045
03046 this->refresh(refresh);
03047
03048 return true;
03049 }
03050
03051 bool MMSWidget::setSelBgImageName(string selbgimagename, bool load, bool refresh) {
03052 if (!this->da) return false;
03053 this->da->myWidgetClass.setSelBgImageName(selbgimagename);
03054 if (load) {
03055 if (this->rootwindow) {
03056
03057 enableRefresh((this->da->selbgimage == this->current_bgimage));
03058
03059 this->rootwindow->im->releaseImage(this->da->selbgimage);
03060 string path, name;
03061 if (!getSelBgImagePath(path)) path = "";
03062 if (!getSelBgImageName(name)) name = "";
03063 this->da->selbgimage = this->rootwindow->im->getImage(path, name);
03064 }
03065 }
03066
03067 this->refresh(refresh);
03068
03069 return true;
03070 }
03071
03072 bool MMSWidget::setBgImagePath_p(string bgimagepath_p, bool load, bool refresh) {
03073 if (!this->da) return false;
03074 this->da->myWidgetClass.setBgImagePath_p(bgimagepath_p);
03075 if (load) {
03076 if (this->rootwindow) {
03077
03078 enableRefresh((this->da->bgimage_p == this->current_bgimage));
03079
03080 this->rootwindow->im->releaseImage(this->da->bgimage_p);
03081 string path, name;
03082 if (!getBgImagePath_p(path)) path = "";
03083 if (!getBgImageName_p(name)) name = "";
03084 this->da->bgimage_p = this->rootwindow->im->getImage(path, name);
03085 }
03086 }
03087
03088 this->refresh(refresh);
03089
03090 return true;
03091 }
03092
03093 bool MMSWidget::setBgImageName_p(string bgimagename_p, bool load, bool refresh) {
03094 if (!this->da) return false;
03095 this->da->myWidgetClass.setBgImageName_p(bgimagename_p);
03096 if (load) {
03097 if (this->rootwindow) {
03098
03099 enableRefresh((this->da->bgimage_p == this->current_bgimage));
03100
03101 this->rootwindow->im->releaseImage(this->da->bgimage_p);
03102 string path, name;
03103 if (!getBgImagePath_p(path)) path = "";
03104 if (!getBgImageName_p(name)) name = "";
03105 this->da->bgimage_p = this->rootwindow->im->getImage(path, name);
03106 }
03107 }
03108
03109 this->refresh(refresh);
03110
03111 return true;
03112 }
03113
03114 bool MMSWidget::setSelBgImagePath_p(string selbgimagepath_p, bool load, bool refresh) {
03115 if (!this->da) return false;
03116 this->da->myWidgetClass.setSelBgImagePath_p(selbgimagepath_p);
03117 if (load) {
03118 if (this->rootwindow) {
03119
03120 enableRefresh((this->da->selbgimage_p == this->current_bgimage));
03121
03122 this->rootwindow->im->releaseImage(this->da->selbgimage_p);
03123 string path, name;
03124 if (!getSelBgImagePath_p(path)) path = "";
03125 if (!getSelBgImageName_p(name)) name = "";
03126 this->da->selbgimage_p = this->rootwindow->im->getImage(path, name);
03127 }
03128 }
03129
03130 this->refresh(refresh);
03131
03132 return true;
03133 }
03134
03135 bool MMSWidget::setSelBgImageName_p(string selbgimagename_p, bool load, bool refresh) {
03136 if (!this->da) return false;
03137 this->da->myWidgetClass.setSelBgImageName_p(selbgimagename_p);
03138 if (load) {
03139 if (this->rootwindow) {
03140
03141 enableRefresh((this->da->selbgimage_p == this->current_bgimage));
03142
03143 this->rootwindow->im->releaseImage(this->da->selbgimage_p);
03144 string path, name;
03145 if (!getSelBgImagePath_p(path)) path = "";
03146 if (!getSelBgImageName_p(name)) name = "";
03147 this->da->selbgimage_p = this->rootwindow->im->getImage(path, name);
03148 }
03149 }
03150
03151 this->refresh(refresh);
03152
03153 return true;
03154 }
03155
03156 bool MMSWidget::setBgImagePath_i(string bgimagepath_i, bool load, bool refresh) {
03157 if (!this->da) return false;
03158 this->da->myWidgetClass.setBgImagePath_i(bgimagepath_i);
03159 if (load) {
03160 if (this->rootwindow) {
03161
03162 enableRefresh((this->da->bgimage_i == this->current_bgimage));
03163
03164 this->rootwindow->im->releaseImage(this->da->bgimage_i);
03165 string path, name;
03166 if (!getBgImagePath_i(path)) path = "";
03167 if (!getBgImageName_i(name)) name = "";
03168 this->da->bgimage_i = this->rootwindow->im->getImage(path, name);
03169 }
03170 }
03171
03172 this->refresh(refresh);
03173
03174 return true;
03175 }
03176
03177 bool MMSWidget::setBgImageName_i(string bgimagename_i, bool load, bool refresh) {
03178 if (!this->da) return false;
03179 this->da->myWidgetClass.setBgImageName_i(bgimagename_i);
03180 if (load) {
03181 if (this->rootwindow) {
03182
03183 enableRefresh((this->da->bgimage_i == this->current_bgimage));
03184
03185 this->rootwindow->im->releaseImage(this->da->bgimage_i);
03186 string path, name;
03187 if (!getBgImagePath_i(path)) path = "";
03188 if (!getBgImageName_i(name)) name = "";
03189 this->da->bgimage_i = this->rootwindow->im->getImage(path, name);
03190 }
03191 }
03192
03193 this->refresh(refresh);
03194
03195 return true;
03196 }
03197
03198 bool MMSWidget::setSelBgImagePath_i(string selbgimagepath_i, bool load, bool refresh) {
03199 if (!this->da) return false;
03200 this->da->myWidgetClass.setSelBgImagePath_i(selbgimagepath_i);
03201 if (load) {
03202 if (this->rootwindow) {
03203
03204 enableRefresh((this->da->selbgimage_i == this->current_bgimage));
03205
03206 this->rootwindow->im->releaseImage(this->da->selbgimage_i);
03207 string path, name;
03208 if (!getSelBgImagePath_i(path)) path = "";
03209 if (!getSelBgImageName_i(name)) name = "";
03210 this->da->selbgimage_i = this->rootwindow->im->getImage(path, name);
03211 }
03212 }
03213
03214 this->refresh(refresh);
03215
03216 return true;
03217 }
03218
03219 bool MMSWidget::setSelBgImageName_i(string selbgimagename_i, bool load, bool refresh) {
03220 if (!this->da) return false;
03221 this->da->myWidgetClass.setSelBgImageName_i(selbgimagename_i);
03222 if (load) {
03223 if (this->rootwindow) {
03224
03225 enableRefresh((this->da->selbgimage_i == this->current_bgimage));
03226
03227 this->rootwindow->im->releaseImage(this->da->selbgimage_i);
03228 string path, name;
03229 if (!getSelBgImagePath_i(path)) path = "";
03230 if (!getSelBgImageName_i(name)) name = "";
03231 this->da->selbgimage_i = this->rootwindow->im->getImage(path, name);
03232 }
03233 }
03234
03235 this->refresh(refresh);
03236
03237 return true;
03238 }
03239
03240 bool MMSWidget::setMargin(unsigned int margin, bool refresh) {
03241 if (!this->da) return false;
03242 this->da->myWidgetClass.setMargin(margin);
03243
03244 setInnerGeometry();
03245
03246
03247 enableRefresh();
03248
03249 this->refresh(refresh);
03250
03251 return true;
03252 }
03253
03254 bool MMSWidget::setFocusable(bool focusable, bool refresh) {
03255 if (!this->da) return false;
03256
03257 if (this->focusable_initial) {
03258 if ((!focusable)&&(isFocused()))
03259 setFocus(false, refresh);
03260 this->da->myWidgetClass.setFocusable(focusable);
03261 return true;
03262 }
03263 else {
03264
03265 if (!focusable) {
03266
03267 this->da->myWidgetClass.setFocusable(focusable);
03268 return true;
03269 }
03270 }
03271 return false;
03272 }
03273
03274 bool MMSWidget::setSelectable(bool selectable, bool refresh) {
03275 if (!this->da) return false;
03276 if (this->selectable_initial) {
03277 if ((!selectable)&&(isSelected()))
03278 setSelected(false, refresh);
03279 this->da->myWidgetClass.setSelectable(selectable);
03280 return true;
03281 }
03282 return false;
03283 }
03284
03285 bool MMSWidget::setUpArrow(string uparrow, bool refresh) {
03286 if (!this->da) return false;
03287 this->da->myWidgetClass.setUpArrow(uparrow);
03288 this->da->upArrowWidget = NULL;
03289
03290
03291 enableRefresh();
03292
03293 this->refresh(refresh);
03294
03295 return true;
03296 }
03297
03298 bool MMSWidget::setDownArrow(string downarrow, bool refresh) {
03299 if (!this->da) return false;
03300 this->da->myWidgetClass.setDownArrow(downarrow);
03301 this->da->downArrowWidget = NULL;
03302
03303
03304 enableRefresh();
03305
03306 this->refresh(refresh);
03307
03308 return true;
03309 }
03310
03311 bool MMSWidget::setLeftArrow(string leftarrow, bool refresh) {
03312 if (!this->da) return false;
03313 this->da->myWidgetClass.setLeftArrow(leftarrow);
03314 this->da->leftArrowWidget = NULL;
03315
03316
03317 enableRefresh();
03318
03319 this->refresh(refresh);
03320
03321 return true;
03322 }
03323
03324 bool MMSWidget::setRightArrow(string rightarrow, bool refresh) {
03325 if (!this->da) return false;
03326 this->da->myWidgetClass.setRightArrow(rightarrow);
03327 this->da->rightArrowWidget = NULL;
03328
03329
03330 enableRefresh();
03331
03332 this->refresh(refresh);
03333
03334 return true;
03335 }
03336
03337 bool MMSWidget::setData(string data) {
03338 if (!this->da) return false;
03339 this->da->myWidgetClass.setData(data);
03340 return true;
03341 }
03342
03343 bool MMSWidget::setNavigateUp(string navigateup) {
03344 if (!this->da) return false;
03345 this->da->myWidgetClass.setNavigateUp(navigateup);
03346 this->da->navigateUpWidget = NULL;
03347 if ((this->rootwindow)&&(!navigateup.empty()))
03348 this->da->navigateUpWidget = this->rootwindow->findWidget(navigateup);
03349 return true;
03350 }
03351
03352 bool MMSWidget::setNavigateDown(string navigatedown) {
03353 if (!this->da) return false;
03354 this->da->myWidgetClass.setNavigateDown(navigatedown);
03355 this->da->navigateDownWidget = NULL;
03356 if ((this->rootwindow)&&(!navigatedown.empty()))
03357 this->da->navigateDownWidget = this->rootwindow->findWidget(navigatedown);
03358 return true;
03359 }
03360
03361 bool MMSWidget::setNavigateLeft(string navigateleft) {
03362 if (!this->da) return false;
03363 this->da->myWidgetClass.setNavigateLeft(navigateleft);
03364 this->da->navigateLeftWidget = NULL;
03365 if ((this->rootwindow)&&(!navigateleft.empty()))
03366 this->da->navigateLeftWidget = this->rootwindow->findWidget(navigateleft);
03367 return true;
03368 }
03369
03370 bool MMSWidget::setNavigateRight(string navigateright) {
03371 if (!this->da) return false;
03372 this->da->myWidgetClass.setNavigateRight(navigateright);
03373 this->da->navigateRightWidget = NULL;
03374 if ((this->rootwindow)&&(!navigateright.empty()))
03375 this->da->navigateRightWidget = this->rootwindow->findWidget(navigateright);
03376 return true;
03377 }
03378
03379 bool MMSWidget::setVSlider(string vslider) {
03380 if (!this->da) return false;
03381 this->da->myWidgetClass.setVSlider(vslider);
03382 this->da->vSliderWidget = NULL;
03383 if ((this->rootwindow)&&(!vslider.empty()))
03384 this->da->vSliderWidget = this->rootwindow->findWidget(vslider);
03385 return true;
03386 }
03387
03388 bool MMSWidget::setHSlider(string hslider) {
03389 if (!this->da) return false;
03390 this->da->myWidgetClass.setHSlider(hslider);
03391 this->da->hSliderWidget = NULL;
03392 if ((this->rootwindow)&&(!hslider.empty()))
03393 this->da->hSliderWidget = this->rootwindow->findWidget(hslider);
03394 return true;
03395 }
03396
03397 bool MMSWidget::setImagesOnDemand(bool imagesondemand) {
03398 if (!this->da) return false;
03399 this->da->myWidgetClass.setImagesOnDemand(imagesondemand);
03400 return true;
03401 }
03402
03403 bool MMSWidget::setBlend(unsigned int blend, bool refresh) {
03404 if (this->da) this->da->myWidgetClass.setBlend(blend);
03405 vector<MMSWidget*>::iterator end = children.end();
03406 for(vector<MMSWidget*>::iterator i = children.begin(); i != end; ++i) {
03407 (*i)->setBlend(blend, false);
03408 }
03409
03410
03411 enableRefresh();
03412
03413 this->refresh(refresh);
03414
03415 return true;
03416 }
03417
03418 bool MMSWidget::setBlendFactor(double blendfactor, bool refresh) {
03419 if (this->da) this->da->myWidgetClass.setBlendFactor(blendfactor);
03420 vector<MMSWidget*>::iterator end = children.end();
03421 for(vector<MMSWidget*>::iterator i = children.begin(); i != end; ++i) {
03422 (*i)->setBlendFactor(blendfactor, false);
03423 }
03424
03425
03426 enableRefresh();
03427
03428 this->refresh(refresh);
03429
03430 return true;
03431 }
03432
03433 bool MMSWidget::setScrollOnFocus(bool scrollonfocus) {
03434 if (!this->da) return false;
03435 this->da->myWidgetClass.setScrollOnFocus(scrollonfocus);
03436 return true;
03437 }
03438
03439 bool MMSWidget::setClickable(bool clickable) {
03440 if (!this->da) return false;
03441 this->da->myWidgetClass.setClickable(clickable);
03442 return true;
03443 }
03444
03445 bool MMSWidget::setReturnOnScroll(bool returnonscroll) {
03446 if (!this->da) return false;
03447 this->da->myWidgetClass.setClickable(returnonscroll);
03448 return true;
03449 }
03450
03451 bool MMSWidget::setInputMode(string inputmode) {
03452 if (!this->da) return false;
03453 this->da->myWidgetClass.setInputMode(inputmode);
03454 return true;
03455 }
03456
03457 bool MMSWidget::setJoinedWidget(string joinedwidget) {
03458 if (!this->da) return false;
03459 this->da->myWidgetClass.setJoinedWidget(joinedwidget);
03460 this->da->joinedWidget = NULL;
03461 if ((this->rootwindow)&&(!joinedwidget.empty()))
03462 this->da->joinedWidget = this->rootwindow->findWidget(joinedwidget);
03463
03464
03465 return true;
03466 }
03467
03468
03469
03470 bool MMSWidget::setActivated(bool activated, bool refresh) {
03471 if (this->da) this->da->myWidgetClass.setActivated(activated);
03472
03473
03474 vector<MMSWidget*>::iterator end = children.end();
03475 for(vector<MMSWidget*>::iterator i = children.begin(); i != end; ++i) {
03476 (*i)->setActivated(activated, false);
03477 }
03478
03479
03480 checkRefreshStatus();
03481
03482
03483 this->refresh(refresh);
03484
03485 return true;
03486 }
03487
03488 bool MMSWidget::setBorderColor(MMSFBColor bordercolor, bool refresh) {
03489 if (!this->da) return false;
03490 this->da->myWidgetClass.border.setColor(bordercolor);
03491
03492
03493 enableRefresh();
03494
03495 this->refresh(refresh);
03496
03497 return true;
03498 }
03499
03500 bool MMSWidget::setBorderSelColor(MMSFBColor borderselcolor, bool refresh) {
03501 if (!this->da) return false;
03502 this->da->myWidgetClass.border.setSelColor(borderselcolor);
03503
03504
03505 enableRefresh();
03506
03507 this->refresh(refresh);
03508
03509 return true;
03510 }
03511
03512 bool MMSWidget::setBorderImagePath(string borderimagepath, bool load, bool refresh) {
03513 if (!this->da) return false;
03514 this->da->myWidgetClass.border.setImagePath(borderimagepath);
03515 if (load) {
03516 if (this->rootwindow) {
03517 string path, name;
03518 if (!getBorderImagePath(path)) path = "";
03519 for (int i=0;i<MMSBORDER_IMAGE_NUM_SIZE;i++) {
03520 this->rootwindow->im->releaseImage(this->da->borderimages[i]);
03521 if (!getBorderImageNames((MMSBORDER_IMAGE_NUM)i, name)) name = "";
03522 this->da->borderimages[i] = this->rootwindow->im->getImage(path, name);
03523 }
03524 }
03525 }
03526
03527
03528 enableRefresh();
03529
03530 this->refresh(refresh);
03531
03532 return true;
03533 }
03534
03535 bool MMSWidget::setBorderImageNames(string imagename_1, string imagename_2, string imagename_3, string imagename_4,
03536 string imagename_5, string imagename_6, string imagename_7, string imagename_8,
03537 bool load, bool refresh) {
03538 if (!this->da) return false;
03539 this->da->myWidgetClass.border.setImageNames(imagename_1, imagename_2, imagename_3, imagename_4,
03540 imagename_5, imagename_6, imagename_7, imagename_8);
03541 if (load) {
03542 if (this->rootwindow) {
03543 string path, name;
03544 if (!getBorderImagePath(path)) path = "";
03545 for (int i=0;i<MMSBORDER_IMAGE_NUM_SIZE;i++) {
03546 this->rootwindow->im->releaseImage(this->da->borderimages[i]);
03547 if (!getBorderImageNames((MMSBORDER_IMAGE_NUM)i, name)) name = "";
03548 this->da->borderimages[i] = this->rootwindow->im->getImage(path, name);
03549 }
03550 }
03551 }
03552
03553
03554 enableRefresh();
03555
03556 this->refresh(refresh);
03557
03558 return true;
03559 }
03560
03561 bool MMSWidget::setBorderSelImagePath(string borderselimagepath, bool load, bool refresh) {
03562 if (!this->da) return false;
03563 this->da->myWidgetClass.border.setSelImagePath(borderselimagepath);
03564 if (load) {
03565 if (this->rootwindow) {
03566 string path, name;
03567 if (!getBorderSelImagePath(path)) path = "";
03568 for (int i=0;i<MMSBORDER_IMAGE_NUM_SIZE;i++) {
03569 this->rootwindow->im->releaseImage(this->da->borderselimages[i]);
03570 if (!getBorderSelImageNames((MMSBORDER_IMAGE_NUM)i, name)) name = "";
03571 this->da->borderselimages[i] = this->rootwindow->im->getImage(path, name);
03572 }
03573 }
03574 }
03575
03576
03577 enableRefresh();
03578
03579 this->refresh(refresh);
03580
03581 return true;
03582 }
03583
03584 bool MMSWidget::setBorderSelImageNames(string selimagename_1, string selimagename_2, string selimagename_3, string selimagename_4,
03585 string selimagename_5, string selimagename_6, string selimagename_7, string selimagename_8,
03586 bool load, bool refresh) {
03587 if (!this->da) return false;
03588 this->da->myWidgetClass.border.setSelImageNames(selimagename_1, selimagename_2, selimagename_3, selimagename_4,
03589 selimagename_5, selimagename_6, selimagename_7, selimagename_8);
03590 if (load) {
03591 if (this->rootwindow) {
03592 string path, name;
03593 if (!getBorderSelImagePath(path)) path = "";
03594
03595 for (int i=0;i<MMSBORDER_IMAGE_NUM_SIZE;i++) {
03596 this->rootwindow->im->releaseImage(this->da->borderselimages[i]);
03597 if (!getBorderSelImageNames((MMSBORDER_IMAGE_NUM)i, name)) name = "";
03598 this->da->borderselimages[i] = this->rootwindow->im->getImage(path, name);
03599 }
03600 }
03601 }
03602
03603
03604 enableRefresh();
03605
03606 this->refresh(refresh);
03607
03608 return true;
03609 }
03610
03611 bool MMSWidget::setBorderThickness(unsigned int borderthickness, bool refresh) {
03612 if (!this->da) return false;
03613 this->da->myWidgetClass.border.setThickness(borderthickness);
03614
03615 setInnerGeometry();
03616
03617
03618 enableRefresh();
03619
03620 this->refresh(refresh);
03621
03622 return true;
03623 }
03624
03625 bool MMSWidget::setBorderMargin(unsigned int bordermargin, bool refresh) {
03626 if (!this->da) return false;
03627 this->da->myWidgetClass.border.setMargin(bordermargin);
03628
03629 setInnerGeometry();
03630
03631
03632 enableRefresh();
03633
03634 this->refresh(refresh);
03635
03636 return true;
03637 }
03638
03639 bool MMSWidget::setBorderRCorners(bool borderrcorners, bool refresh) {
03640 if (!this->da) return false;
03641 this->da->myWidgetClass.border.setRCorners(borderrcorners);
03642
03643
03644 enableRefresh();
03645
03646 this->refresh(refresh);
03647
03648 return true;
03649 }
03650
03651 void MMSWidget::updateFromThemeClass(MMSWidgetClass *themeClass) {
03652 bool b;
03653 MMSFBColor c;
03654 string s;
03655 unsigned int u;
03656 double d;
03657
03658 if (themeClass->getImagesOnDemand(b))
03659 setImagesOnDemand(b);
03660 if (themeClass->getBgColor(c))
03661 setBgColor(c);
03662 if (themeClass->getSelBgColor(c))
03663 setSelBgColor(c);
03664 if (themeClass->getBgColor_p(c))
03665 setBgColor_p(c);
03666 if (themeClass->getSelBgColor_p(c))
03667 setSelBgColor_p(c);
03668 if (themeClass->getBgColor_i(c))
03669 setBgColor_i(c);
03670 if (themeClass->getSelBgColor_i(c))
03671 setSelBgColor_i(c);
03672 if (themeClass->getBgImagePath(s))
03673 setBgImagePath(s);
03674 if (themeClass->getBgImageName(s))
03675 setBgImageName(s);
03676 if (themeClass->getSelBgImagePath(s))
03677 setSelBgImagePath(s);
03678 if (themeClass->getSelBgImageName(s))
03679 setSelBgImageName(s);
03680 if (themeClass->getBgImagePath_p(s))
03681 setBgImagePath_p(s);
03682 if (themeClass->getBgImageName_p(s))
03683 setBgImageName_p(s);
03684 if (themeClass->getSelBgImagePath_p(s))
03685 setSelBgImagePath_p(s);
03686 if (themeClass->getSelBgImageName_p(s))
03687 setSelBgImageName_p(s);
03688 if (themeClass->getBgImagePath_i(s))
03689 setBgImagePath_i(s);
03690 if (themeClass->getBgImageName_i(s))
03691 setBgImageName_i(s);
03692 if (themeClass->getSelBgImagePath_i(s))
03693 setSelBgImagePath_i(s);
03694 if (themeClass->getSelBgImageName_i(s))
03695 setSelBgImageName_i(s);
03696 if (themeClass->getMargin(u))
03697 setMargin(u);
03698 if (themeClass->getFocusable(b))
03699 setFocusable(b);
03700 if (themeClass->getSelectable(b))
03701 setSelectable(b);
03702 if (themeClass->getUpArrow(s))
03703 setUpArrow(s);
03704 if (themeClass->getDownArrow(s))
03705 setDownArrow(s);
03706 if (themeClass->getLeftArrow(s))
03707 setLeftArrow(s);
03708 if (themeClass->getRightArrow(s))
03709 setRightArrow(s);
03710 if (themeClass->getData(s))
03711 setData(s);
03712 if (themeClass->getNavigateUp(s))
03713 setNavigateUp(s);
03714 if (themeClass->getNavigateDown(s))
03715 setNavigateDown(s);
03716 if (themeClass->getNavigateLeft(s))
03717 setNavigateLeft(s);
03718 if (themeClass->getNavigateRight(s))
03719 setNavigateRight(s);
03720 if (themeClass->getVSlider(s))
03721 setVSlider(s);
03722 if (themeClass->getHSlider(s))
03723 setHSlider(s);
03724 if (themeClass->getBlend(u))
03725 setBlend(u);
03726 if (themeClass->getBlendFactor(d))
03727 setBlendFactor(d);
03728 if (themeClass->getScrollOnFocus(b))
03729 setScrollOnFocus(b);
03730 if (themeClass->getClickable(b))
03731 setClickable(b);
03732 if (themeClass->getReturnOnScroll(b))
03733 setReturnOnScroll(b);
03734 if (themeClass->getInputMode(s))
03735 setInputMode(s);
03736 if (themeClass->getJoinedWidget(s))
03737 setJoinedWidget(s);
03738 if (themeClass->getActivated(b))
03739 setActivated(b);
03740 if (themeClass->border.getColor(c))
03741 setBorderColor(c);
03742 if (themeClass->border.getSelColor(c))
03743 setBorderSelColor(c);
03744 if (themeClass->border.getImagePath(s))
03745 setBorderImagePath(s);
03746 if (themeClass->border.isImageNames()) {
03747 string s[8];
03748 themeClass->border.getImageNames(MMSBORDER_IMAGE_NUM_TOP_LEFT, s[0]);
03749 themeClass->border.getImageNames(MMSBORDER_IMAGE_NUM_TOP, s[1]);
03750 themeClass->border.getImageNames(MMSBORDER_IMAGE_NUM_TOP_RIGHT, s[2]);
03751 themeClass->border.getImageNames(MMSBORDER_IMAGE_NUM_RIGHT, s[3]);
03752 themeClass->border.getImageNames(MMSBORDER_IMAGE_NUM_BOTTOM_RIGHT, s[4]);
03753 themeClass->border.getImageNames(MMSBORDER_IMAGE_NUM_BOTTOM, s[5]);
03754 themeClass->border.getImageNames(MMSBORDER_IMAGE_NUM_BOTTOM_LEFT, s[6]);
03755 themeClass->border.getImageNames(MMSBORDER_IMAGE_NUM_LEFT, s[7]);
03756 setBorderImageNames(s[0], s[1], s[2], s[3], s[4], s[5], s[6], s[7]);
03757 }
03758 if (themeClass->border.getSelImagePath(s))
03759 setBorderSelImagePath(s);
03760 if (themeClass->border.isSelImageNames()) {
03761 string s[8];
03762 themeClass->border.getSelImageNames(MMSBORDER_IMAGE_NUM_TOP_LEFT, s[0]);
03763 themeClass->border.getSelImageNames(MMSBORDER_IMAGE_NUM_TOP, s[1]);
03764 themeClass->border.getSelImageNames(MMSBORDER_IMAGE_NUM_TOP_RIGHT, s[2]);
03765 themeClass->border.getSelImageNames(MMSBORDER_IMAGE_NUM_RIGHT, s[3]);
03766 themeClass->border.getSelImageNames(MMSBORDER_IMAGE_NUM_BOTTOM_RIGHT, s[4]);
03767 themeClass->border.getSelImageNames(MMSBORDER_IMAGE_NUM_BOTTOM, s[5]);
03768 themeClass->border.getSelImageNames(MMSBORDER_IMAGE_NUM_BOTTOM_LEFT, s[6]);
03769 themeClass->border.getSelImageNames(MMSBORDER_IMAGE_NUM_LEFT, s[7]);
03770 setBorderSelImageNames(s[0], s[1], s[2], s[3], s[4], s[5], s[6], s[7]);
03771 }
03772 if (themeClass->border.getThickness(u))
03773 setBorderThickness(u);
03774 if (themeClass->border.getMargin(u))
03775 setBorderMargin(u);
03776 if (themeClass->border.getRCorners(b))
03777 setBorderRCorners(b);
03778 }
03779
03780
03781
03782