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 name(""),
00046 sizehint(""),
00047 minmax_set(false),
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 content_size_initialized(false),
00057 content_width(0),
00058 content_height(0),
00059 content_width_child(0),
00060 content_height_child(0),
00061 bindata(NULL),
00062 rootwindow(NULL),
00063 parent_rootwindow(NULL),
00064 drawable(false),
00065 needsparentdraw(false),
00066 focusable_initial(false),
00067 selectable_initial(false),
00068 clickable_initial(false),
00069 canhavechildren(false),
00070 canselectchildren(false),
00071 visible(true),
00072 focused(false),
00073 selected(false),
00074 pressed(false),
00075 brightness(255),
00076 opacity(255),
00077 has_own_surface(false),
00078 skip_refresh(false),
00079 current_bgset(false),
00080 current_bgimage(NULL),
00081 onSelect(NULL),
00082 onFocus(NULL),
00083 onReturn(NULL),
00084 onClick(NULL),
00085 geomset(false),
00086 initialized(false),
00087 toRedraw(false),
00088 redrawChildren(false),
00089 windowSurface(NULL),
00090 surface(NULL),
00091 surfaceGeom(MMSFBRectangle(0,0,0,0)),
00092 parent(NULL),
00093 geom(MMSFBRectangle(0,0,0,0)),
00094 innerGeom(MMSFBRectangle(0,0,0,0)) {
00095 MMSIdFactory factory;
00096 this->id = factory.getId();
00097 }
00098
00099
00100 MMSWidget::~MMSWidget() {
00101
00102
00103 if (onSelect) delete onSelect;
00104 if (onFocus) delete onFocus;
00105 if (onReturn) delete onReturn;
00106 if (onClick) delete onClick;
00107
00108
00109 release();
00110
00111
00112 vector<MMSWidget*>::iterator end = children.end();
00113 for(vector<MMSWidget*>::iterator i = children.begin(); i != end; ++i) {
00114 delete *i;
00115 }
00116
00117
00118 if (this->rootwindow) {
00119 this->rootwindow->remove(this);
00120 }
00121
00122 if(this->surface) {
00123 delete this->surface;
00124 }
00125
00126
00127 if (this->da) {
00128 delete this->da;
00129 }
00130 }
00131
00132 MMSWIDGETTYPE MMSWidget::getType() {
00133 return this->type;
00134 }
00135
00136 string MMSWidget::getTypeString() {
00137 switch (this->type) {
00138 case MMSWIDGETTYPE_HBOX:
00139 return "hbox";
00140 case MMSWIDGETTYPE_VBOX:
00141 return "vbox";
00142 case MMSWIDGETTYPE_BUTTON:
00143 return "button";
00144 case MMSWIDGETTYPE_IMAGE:
00145 return "image";
00146 case MMSWIDGETTYPE_LABEL:
00147 return "label";
00148 case MMSWIDGETTYPE_MENU:
00149 return "menu";
00150 case MMSWIDGETTYPE_PROGRESSBAR:
00151 return "progressbar";
00152 case MMSWIDGETTYPE_TEXTBOX:
00153 return "textbox";
00154 case MMSWIDGETTYPE_ARROW:
00155 return "arrow";
00156 case MMSWIDGETTYPE_SLIDER:
00157 return "slider";
00158 case MMSWIDGETTYPE_INPUT:
00159 return "input";
00160 case MMSWIDGETTYPE_CHECKBOX:
00161 return "checkbox";
00162 case MMSWIDGETTYPE_GAP:
00163 return "gap";
00164 case MMSWIDGETTYPE_CANVAS:
00165 return "canvas";
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 (unsigned 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
01243 unsigned int borderthickness;
01244 if (!getBorderThickness(borderthickness))
01245 borderthickness = 0;
01246 if (!borderthickness) {
01247
01248
01249 MMSFBColor color;
01250 MMSFBSurface *image;
01251 getBackground(&color, &image);
01252
01253 if (color == this->current_bgcolor && image == this->current_bgimage) {
01254
01255 return false;
01256 }
01257 }
01258 }
01259
01260
01261 enableRefresh();
01262
01263 return true;
01264 }
01265
01266
01267 bool MMSWidget::draw(bool *backgroundFilled) {
01268 bool myBackgroundFilled = false;
01269 bool retry = false;
01270
01271
01272
01273
01274
01275 init();
01276
01277 if(!surface)
01278 return false;
01279
01280 if (backgroundFilled) {
01281 if (this->has_own_surface)
01282 *backgroundFilled = false;
01283 }
01284 else
01285 backgroundFilled = &myBackgroundFilled;
01286
01287 if ((!this->geomset)||(!this->visible))
01288 return false;
01289
01290
01291 if (this->surface) this->surface->lock();
01292 this->windowSurface->lock();
01293
01294
01295
01296 this->skip_refresh = true;
01297
01298
01299
01300 do {
01301
01302 MMSFBColor col;
01303 MMSFBSurface *suf;
01304 getBackground(&col, &suf);
01305 this->current_bgcolor = col;
01306 this->current_bgimage = suf;
01307 this->current_bgset = true;
01308
01309 if (suf) {
01310 if ((*backgroundFilled)||(retry)||(!this->has_own_surface)) {
01311
01312 this->surface->setBlittingFlagsByBrightnessAlphaAndOpacity(brightness, (col.a)?col.a:255, opacity);
01313
01314
01315 suf->lock();
01316 surface->stretchBlit(suf, NULL, &surfaceGeom);
01317 suf->unlock();
01318 *backgroundFilled = true;
01319
01320
01321 break;
01322 }
01323 else
01324
01325 retry = true;
01326 }
01327 else
01328 if (col.a) {
01329 if ((*backgroundFilled)||(retry)||(!this->has_own_surface)||((col.a==255)&&(opacity==255))) {
01330
01331 this->surface->setDrawingColorAndFlagsByBrightnessAndOpacity(col, brightness, opacity);
01332
01333
01334 this->surface->fillRectangle(surfaceGeom.x, surfaceGeom.y, surfaceGeom.w, surfaceGeom.h);
01335 *backgroundFilled = true;
01336
01337
01338 break;
01339 }
01340 else
01341
01342 retry = true;
01343 }
01344 else {
01345 if ((*backgroundFilled)||(!this->has_own_surface)) {
01346
01347 if (!*backgroundFilled) {
01348 if (this->surface) {
01349
01350
01351 this->surface->clear();
01352 *backgroundFilled = true;
01353 }
01354 }
01355 break;}
01356 else
01357
01358 retry = true;
01359 }
01360
01361
01362 if (!*backgroundFilled) {
01363
01364 MMSWidget *widget = NULL;
01365 vector<MMSWidget*> wlist;
01366 if (this->parent)
01367 widget = this->parent->getDrawableParent(false, false, false, &wlist);
01368
01369
01370
01371 for (unsigned int i=0; i < wlist.size(); i++) {
01372 MMSWidget *w = wlist.at(i);
01373 if ((w->drawable)&&(w->geomset)&&(w->visible)) {
01374 widget = w;
01375 break;
01376 }
01377 }
01378
01379
01380 if (this->drawable) {
01381
01382 this->surface->clear();
01383 }
01384 else {
01385
01386 MMSFBRegion clip;
01387 clip.x1 = innerGeom.x;
01388 clip.y1 = innerGeom.y;
01389 clip.x2 = innerGeom.x + innerGeom.w - 1;
01390 clip.y2 = innerGeom.y + innerGeom.h - 1;
01391
01392 this->windowSurface->setClip(&clip);
01393 this->windowSurface->clear();
01394 }
01395
01396 if (widget) {
01397
01398 MMSFBRectangle srcrect = widget->getVisibleSurfaceArea();
01399 srcrect.x+= this->innerGeom.x - widget->innerGeom.x;
01400 srcrect.y+= this->innerGeom.y - widget->innerGeom.y;
01401 srcrect.w = this->innerGeom.w;
01402 srcrect.h = this->innerGeom.h;
01403
01404 widget->surface->lock();
01405
01406 if (this->drawable) {
01407
01408 this->surface->setBlittingFlags(MMSFB_BLIT_NOFX);
01409 this->surface->blit(widget->surface, &srcrect, 0, 0);
01410 }
01411 else {
01412
01413 this->windowSurface->setBlittingFlags(MMSFB_BLIT_NOFX);
01414 this->windowSurface->blit(widget->surface, &srcrect, innerGeom.x, innerGeom.y);
01415 }
01416
01417 widget->surface->unlock();
01418 }
01419 else {
01420
01421 if (this->rootwindow) {
01422 MMSFBColor bgcolor;
01423 this->rootwindow->getBgColor(bgcolor);
01424 if (!this->rootwindow->bgimage) {
01425
01426 if (bgcolor.a) {
01427 if (this->drawable) {
01428
01429 this->surface->clear(bgcolor.r, bgcolor.g, bgcolor.b, bgcolor.a);
01430 }
01431 else {
01432
01433 this->windowSurface->clear(bgcolor.r, bgcolor.g, bgcolor.b, bgcolor.a);
01434 }
01435 }
01436 }
01437 else {
01438
01439 MMSFBRectangle src, dst;
01440 int sw, sh;
01441
01442 this->rootwindow->bgimage->lock();
01443
01444
01445 this->rootwindow->bgimage->getSize(&sw, &sh);
01446
01447
01448 int f1 = (this->rootwindow->innerGeom.w * 10000) / sw;
01449 int f2 = (this->rootwindow->innerGeom.h * 10000) / sh;
01450
01451
01452 src.x = (5000 + 10000 *(this->innerGeom.x - this->rootwindow->innerGeom.x)) / f1;
01453 src.w = (5000 + 10000 * this->innerGeom.w) / f1;
01454 src.y = (5000 + 10000 *(this->innerGeom.y - this->rootwindow->innerGeom.y)) / f2;
01455 src.h = (5000 + 10000 * this->innerGeom.h) / f2;
01456
01457 if (this->drawable) {
01458
01459 dst.x = 0;
01460 dst.w = this->innerGeom.w;
01461 dst.y = 0;
01462 dst.h = this->innerGeom.h;
01463
01464
01465 this->surface->setBlittingFlagsByBrightnessAlphaAndOpacity(255, (bgcolor.a)?bgcolor.a:255, 255);
01466 this->surface->stretchBlit(this->rootwindow->bgimage, &src, &dst);
01467 }
01468 else {
01469
01470 dst.x = this->innerGeom.x;
01471 dst.w = this->innerGeom.w;
01472 dst.y = this->innerGeom.y;
01473 dst.h = this->innerGeom.h;
01474
01475
01476 this->windowSurface->setBlittingFlagsByBrightnessAlphaAndOpacity(255, (bgcolor.a)?bgcolor.a:255, 255);
01477 this->windowSurface->stretchBlit(this->rootwindow->bgimage, &src, &dst);
01478 }
01479
01480 this->rootwindow->bgimage->unlock();
01481 }
01482 }
01483 }
01484
01485 if (!this->drawable) {
01486
01487 this->windowSurface->setClip(NULL);
01488 }
01489
01490 *backgroundFilled = true;
01491 }
01492 } while (retry);
01493
01494
01495 if (this->surface) this->surface->unlock();
01496 this->windowSurface->unlock();
01497
01498 return true;
01499 }
01500
01501
01502
01503 void MMSWidget::drawMyBorder() {
01504
01505 if ((!this->drawable)||(!this->geomset)||(!this->visible))
01506 return;
01507
01508 unsigned int margin;
01509 if (!getMargin(margin))
01510 margin = 0;
01511
01512 MMSFBRectangle mygeom;
01513 mygeom = this->geom;
01514 mygeom.x+= margin;
01515 mygeom.y+= margin;
01516 mygeom.w-= 2*margin;
01517 mygeom.h-= 2*margin;
01518
01519 unsigned int borderthickness;
01520 if (!getBorderThickness(borderthickness))
01521 borderthickness = 0;
01522
01523 bool borderrcorners;
01524 if (!getBorderRCorners(borderrcorners))
01525 borderrcorners = false;
01526
01527 if (isSelected()) {
01528 MMSFBColor c;
01529 getBorderSelColor(c);
01530 drawBorder(borderthickness, borderrcorners, this->da->borderselimages,
01531 this->da->borderselgeom, &(this->da->borderselgeomset), this->windowSurface,
01532 mygeom.x, mygeom.y, mygeom.w, mygeom.h, c, this->rootwindow->im,
01533 getBrightness(), getOpacity());
01534 }
01535 else {
01536 MMSFBColor c;
01537 getBorderColor(c);
01538 drawBorder(borderthickness, borderrcorners, this->da->borderimages,
01539 this->da->bordergeom, &(this->da->bordergeomset), this->windowSurface,
01540 mygeom.x, mygeom.y, mygeom.w, mygeom.h, c, this->rootwindow->im,
01541 getBrightness(), getOpacity());
01542 }
01543 }
01544
01545
01546
01547 bool MMSWidget::drawDebug() {
01548 if ((!this->geomset)||(!this->visible))
01549 return false;
01550
01551 bool debug;
01552 if (!this->getRootWindow()->getDebug(debug)) debug = false;
01553 if (debug) {
01554 this->surface->setDrawingFlagsByAlpha(255);
01555 this->windowSurface->setColor(255, 255, 255, 255);
01556 this->windowSurface->drawRectangle(this->geom.x, this->geom.y, this->geom.w, this->geom.h);
01557 if (this->innerGeom.x != this->geom.x) {
01558 this->windowSurface->setColor(200, 200, 200, 255);
01559 this->windowSurface->drawRectangle(this->innerGeom.x, this->innerGeom.y,
01560 this->innerGeom.w, this->innerGeom.h);
01561 }
01562 }
01563
01564 if (this->drawable) {
01565 if (this->da->initialArrowsDrawn == false) {
01566 switchArrowWidgets();
01567 this->da->initialArrowsDrawn = true;
01568 }
01569 }
01570
01571 return true;
01572 }
01573
01574 void MMSWidget::drawchildren(bool toRedrawOnly, bool *backgroundFilled, MMSFBRectangle *rect2update) {
01575
01576 if ((toRedrawOnly) && (this->toRedraw==false) && (this->redrawChildren==false))
01577 return;
01578
01579 if (!this->visible)
01580 return;
01581
01582 bool myBackgroundFilled = false;
01583 if (!backgroundFilled)
01584 backgroundFilled = &myBackgroundFilled;
01585
01586 if ((!toRedrawOnly)||(this->toRedraw)) {
01587 this->draw(backgroundFilled);
01588 }
01589
01590
01591 if ((!toRedrawOnly)||(this->toRedraw)||(this->redrawChildren)) {
01592 vector<MMSWidget *>::iterator end = this->children.end();
01593 for(vector<MMSWidget *>::iterator i = this->children.begin(); i != end; ++i) {
01594 MMSWidget *w = *i;
01595 if (!rect2update) {
01596
01597 w->drawchildren(toRedrawOnly, backgroundFilled, rect2update);
01598 }
01599 else {
01600
01601 if ((w->geom.x + w->geom.w > rect2update->x)
01602 &&(w->geom.x < rect2update->x + rect2update->w)
01603 &&(w->geom.y + w->geom.h > rect2update->y)
01604 &&(w->geom.y < rect2update->y + rect2update->h)) {
01605 w->drawchildren(toRedrawOnly, backgroundFilled, rect2update);
01606 }
01607 }
01608 }
01609
01610 drawMyBorder();
01611 }
01612
01613 this->toRedraw = this->redrawChildren = false;
01614
01615 }
01616
01617 void MMSWidget::themeChanged(string &themeName) {
01618 if (!isDrawable())
01619 return;
01620
01621
01622 release();
01623 this->initialized = false;
01624 }
01625
01626
01627 void MMSWidget::add(MMSWidget *widget) {
01628 if (canHaveChildren())
01629 if(this->children.size() < 1) {
01630
01631 this->children.push_back(widget);
01632
01633 children.at(0)->setParent(this);
01634 if (this->rootwindow)
01635 this->rootwindow->add(widget);
01636 }
01637 else
01638 throw MMSWidgetError(0,"this widget does only support one child");
01639 else
01640 throw MMSWidgetError(0,"this widget does not support children");
01641 }
01642
01643 void MMSWidget::markChildren2Redraw() {
01644 this->toRedraw = true;
01645 this->redrawChildren = true;
01646 vector<MMSWidget*>::iterator end = this->children.end();
01647 for(vector<MMSWidget*>::iterator i = this->children.begin(); i != end; ++i) {
01648 if((*i)->isVisible()) {
01649 (*i)->markChildren2Redraw();
01650 }
01651 }
01652 }
01653
01654 MMSWidget *MMSWidget::getDrawableParent(bool mark2Redraw, bool markChildren2Redraw, bool checkborder,
01655 vector<MMSWidget*> *wlist, bool followpath) {
01656 if (mark2Redraw) {
01657 this->toRedraw = true;
01658
01659 if (markChildren2Redraw) {
01660 this->markChildren2Redraw();
01661 }
01662 }
01663
01664 if (followpath)
01665 this->redrawChildren = true;
01666
01667 if (this->needsParentDraw(checkborder)==false) {
01668 if (wlist) wlist->push_back(this->parent);
01669 return this->parent->getDrawableParent(false, false, checkborder, wlist, true);
01670 }
01671 else
01672 if (this->parent) {
01673 if (wlist) wlist->push_back(this->parent);
01674 return this->parent->getDrawableParent(mark2Redraw, false, checkborder, wlist, followpath);
01675 }
01676
01677 return NULL;
01678 }
01679
01680 void MMSWidget::refresh(bool required) {
01681 MMSFBRectangle tobeupdated;
01682 unsigned int margin = 0;
01683 MMSWindow *myroot = this->rootwindow;
01684
01685
01686
01687 if (!this->geomset) {
01688
01689 return;
01690 }
01691
01692 if (!myroot) {
01693
01694 return;
01695 }
01696
01697
01698 if (recalcContentSize()) {
01699
01700 return;
01701 }
01702
01703
01704 if (!required) {
01705
01706 return;
01707 }
01708
01709 if (this->skip_refresh) {
01710
01711 return;
01712 }
01713
01714
01715 this->parent_rootwindow->lock();
01716
01717
01718
01719
01720 if (!myroot->isShown(true)) {
01721 DEBUGMSG("MMSGUI", "MMSWidget::refresh() skipped after MMSWindow::lock() because window is currently not shown");
01722
01723
01724 this->parent_rootwindow->unlock();
01725 return;
01726 }
01727
01728 if (this->drawable) {
01729 getMargin(margin);
01730 }
01731
01732
01733 tobeupdated.x = this->geom.x + margin;
01734 tobeupdated.y = this->geom.y + margin;
01735 tobeupdated.w = this->geom.w - 2*margin;
01736 tobeupdated.h = this->geom.h - 2*margin;
01737
01738
01739
01740 if (this->type == MMSWIDGETTYPE_MENU) {
01741 if (((MMSMenuWidget *)this)->getSmoothScrolling())
01742 recalculateChildren();
01743 }
01744 else
01745 if (this->type == MMSWIDGETTYPE_CANVAS) {
01746 recalculateChildren();
01747 }
01748
01749
01750 myroot->refreshFromChild(this->getDrawableParent(true, true), &tobeupdated, false);
01751
01752
01753 switchArrowWidgets();
01754
01755
01756 this->parent_rootwindow->unlock();
01757 }
01758
01759 bool MMSWidget::isDrawable() {
01760 return this->drawable;
01761 }
01762
01763 bool MMSWidget::needsParentDraw(bool checkborder) {
01764
01765
01766 return true;
01767
01768
01769
01770
01771 MMSFBColor c;
01772
01773 if (this->needsparentdraw)
01774 return true;
01775
01776 if (checkborder) {
01777 unsigned int borderthickness;
01778 if (!getBorderThickness(borderthickness))
01779 borderthickness = 0;
01780
01781 if (borderthickness>0) {
01782 bool borderrcorners;
01783 if (!getBorderRCorners(borderrcorners))
01784 borderrcorners = false;
01785
01786 if ((borderrcorners)||(getOpacity()!=255))
01787 return true;
01788 else
01789 if (this->selected) {
01790 MMSFBColor c;
01791 getBorderSelColor(c);
01792 if (c.a!=255)
01793 return true;
01794 }
01795 else {
01796 MMSFBColor c;
01797 getBorderColor(c);
01798 if (c.a!=255)
01799 return true;
01800 }
01801 }
01802 }
01803
01804 if (isActivated()) {
01805 if (!this->pressed) {
01806 if (this->selected) {
01807 getSelBgColor(c);
01808 if (c.a==255)
01809 return false;
01810 }
01811 else {
01812 getBgColor(c);
01813 if (c.a==255)
01814 return false;
01815 }
01816 }
01817 else {
01818 if (this->selected) {
01819 getSelBgColor_p(c);
01820 if (c.a==255)
01821 return false;
01822 }
01823 else {
01824 getBgColor_p(c);
01825 if (c.a==255)
01826 return false;
01827 }
01828 }
01829 }
01830 else {
01831 if (this->selected) {
01832 getSelBgColor_i(c);
01833 if (c.a==255)
01834 return false;
01835 }
01836 else {
01837 getBgColor_i(c);
01838 if (c.a==255)
01839 return false;
01840 }
01841 }
01842
01843 return true;
01844 }
01845
01846
01847 bool MMSWidget::canHaveChildren() {
01848 return this->canhavechildren;
01849 }
01850
01851 bool MMSWidget::canSelectChildren() {
01852 return this->canselectchildren;
01853 }
01854
01855
01856 void MMSWidget::setParent(MMSWidget *parent) {
01857 this->parent = parent;
01858 for_each(children.begin(), children.end(), bind2nd(mem_fun(&MMSWidget::setParent), this));
01859 }
01860
01861 MMSWidget *MMSWidget::getParent() {
01862 return this->parent;
01863 }
01864
01865 void MMSWidget::setRootWindow(MMSWindow *root, MMSWindow *parentroot) {
01866
01867 this->rootwindow = root;
01868
01869
01870 this->parent_rootwindow = parentroot;
01871
01872 if (this->rootwindow) {
01873
01874 if (!this->parent_rootwindow) {
01875 if (!this->rootwindow->parent)
01876 this->parent_rootwindow = this->rootwindow;
01877 else
01878 this->parent_rootwindow = this->rootwindow->getParent(true);
01879 }
01880
01881
01882 this->windowSurface = this->rootwindow->getSurface();
01883 this->rootwindow->add(this);
01884
01885 bool initial_load = false;
01886 this->rootwindow->getInitialLoad(initial_load);
01887 if (initial_load) {
01888
01889 init();
01890 }
01891 }
01892
01893
01894 vector<MMSWidget*>::iterator end = this->children.end();
01895 for(vector<MMSWidget*>::iterator i = this->children.begin(); i != end; ++i) {
01896 (*i)->setRootWindow(this->rootwindow, this->parent_rootwindow);
01897 }
01898 }
01899
01900 void MMSWidget::recalculateChildren() {
01901
01902 if(this->children.size() == 1) {
01903 children.at(0)->setGeometry(innerGeom);
01904 }
01905
01906 }
01907
01908 MMSWindow *MMSWidget::getRootWindow(MMSWindow **parentroot) {
01909 if (parentroot)
01910 *parentroot = this->parent_rootwindow;
01911 return this->rootwindow;
01912 }
01913
01914 int MMSWidget::getId() {
01915 return this->id;
01916 }
01917
01918 string MMSWidget::getName() {
01919 return this->name;
01920 }
01921
01922 void MMSWidget::setName(string name) {
01923 this->name = name;
01924 }
01925
01926
01927 void MMSWidget::setFocus(bool set, bool refresh, MMSInputEvent *inputevent) {
01928
01929 bool b;
01930 if (!getFocusable(b))
01931 return;
01932 if (!b)
01933 return;
01934
01935
01936 this->focused = set;
01937
01938 if (this->rootwindow) {
01939
01940
01941
01942 this->rootwindow->setFocusedWidget(this, set, true, refresh);
01943 }
01944
01945
01946
01947
01948 setSelected(set, refresh);
01949
01950
01951
01952
01953
01954 this->onFocus->emit(this, set);
01955
01956
01957 if (inputevent) {
01958 bool scrollonfocus;
01959 if (getScrollOnFocus(scrollonfocus)) {
01960 if (scrollonfocus) {
01961 if (inputevent->type == MMSINPUTEVENTTYPE_KEYPRESS) {
01962 switch (inputevent->key) {
01963 case MMSKEY_CURSOR_DOWN:
01964 scrollDown();
01965 break;
01966 case MMSKEY_CURSOR_UP:
01967 scrollUp();
01968 break;
01969 case MMSKEY_CURSOR_RIGHT:
01970 scrollRight();
01971 break;
01972 case MMSKEY_CURSOR_LEFT:
01973 scrollLeft();
01974 break;
01975 default:
01976 break;
01977 }
01978 }
01979 }
01980 }
01981 }
01982 }
01983
01984 bool MMSWidget::isFocused() {
01985 return this->focused;
01986 }
01987
01988 void MMSWidget::getJoinedWigdets(MMSWidget **caller_stack) {
01989 if ((this->da)&&(this->da->joinedWidget)) {
01990 int i=0;
01991 while ((caller_stack[i]) && (caller_stack[i] != this) && (i < 16)) i++;
01992 if (!caller_stack[i]) {
01993 caller_stack[i] = this;
01994 this->da->joinedWidget->getJoinedWigdets(caller_stack);
01995 }
01996 }
01997 }
01998
01999
02000 bool MMSWidget::setSelected(bool set, bool refresh, bool *changed, bool joined) {
02001 if (changed)
02002 *changed = false;
02003
02004 if (!joined) {
02005 if ((this->da)&&(this->da->joinedWidget)) {
02006
02007 MMSWidget *caller_stack[16] = {0};
02008 caller_stack[0] = this;
02009 this->da->joinedWidget->getJoinedWigdets(caller_stack);
02010 int i = 16;
02011 while (i-- > 1) {
02012 if (caller_stack[i]) {
02013 caller_stack[i]->setSelected(set, refresh, NULL, true);
02014 }
02015 }
02016 }
02017 }
02018
02019
02020 if (this->selected == set) {
02021
02022 if (canSelectChildren()) {
02023 bool rf = false;
02024 vector<MMSWidget*>::iterator end = children.end();
02025 for(vector<MMSWidget*>::iterator i = children.begin(); i != end; ++i) {
02026 if((*i)->setSelected(set, false)) {
02027 rf = true;
02028 }
02029 }
02030
02031 if (refresh && rf)
02032 this->refresh();
02033 }
02034 return false;
02035 }
02036
02037
02038 bool selectable;
02039 if (!getSelectable(selectable))
02040 selectable = false;
02041 bool canselchildren = canSelectChildren();
02042
02043
02044 if (selectable) {
02045 this->selected=set;
02046 if (changed) *changed = true;
02047 }
02048
02049
02050
02051 checkRefreshStatus();
02052
02053
02054
02055 if (canselchildren) {
02056 vector<MMSWidget*>::iterator end = children.end();
02057 for(vector<MMSWidget*>::iterator i = children.begin(); i != end; ++i) {
02058 (*i)->setSelected(set, false);
02059 }
02060 }
02061
02062
02063 if (((selectable)||(canselchildren))&&(refresh))
02064 this->refresh();
02065
02066
02067 if (selectable)
02068 if (set)
02069 this->onSelect->emit(this);
02070
02071 return true;
02072 }
02073
02074 bool MMSWidget::setSelected(bool set, bool refresh) {
02075 return setSelected(set, refresh, NULL, false);
02076 }
02077
02078 bool MMSWidget::isSelected() {
02079 return this->selected;
02080 }
02081
02082 void MMSWidget::unsetFocusableForAllChildren(bool refresh) {
02083 vector<MMSWidget*>::iterator end = children.end();
02084 for(vector<MMSWidget*>::iterator i = children.begin(); i != end; ++i) {
02085 (*i)->setFocusable(false, refresh);
02086 (*i)->unsetFocusableForAllChildren(refresh);
02087 }
02088 }
02089
02090
02091 bool MMSWidget::isActivated() {
02092 bool activated = true;
02093 getActivated(activated);
02094 return activated;
02095 }
02096
02097 bool MMSWidget::setPressed(bool set, bool refresh, bool joined) {
02098
02099 if (!joined) {
02100 if ((this->da)&&(this->da->joinedWidget)) {
02101
02102 MMSWidget *caller_stack[16] = {0};
02103 caller_stack[0] = this;
02104 this->da->joinedWidget->getJoinedWigdets(caller_stack);
02105 int i = 16;
02106 while (i-- > 1) {
02107 if (caller_stack[i])
02108 caller_stack[i]->setPressed(set, refresh, true);
02109 }
02110 }
02111 }
02112
02113
02114 if (this->pressed == set) {
02115
02116 if (canSelectChildren()) {
02117 bool ref = false;
02118 vector<MMSWidget*>::iterator end = children.end();
02119 for(vector<MMSWidget*>::iterator i = children.begin(); i != end; ++i) {
02120 if((*i)->setPressed(set, false)) {
02121 ref = true;
02122 }
02123 }
02124 if (ref && refresh) {
02125
02126 this->refresh();
02127 }
02128 }
02129
02130
02131 return false;
02132 }
02133
02134
02135 this->pressed = set;
02136
02137
02138
02139 checkRefreshStatus();
02140
02141
02142
02143 if (canSelectChildren()) {
02144 vector<MMSWidget*>::iterator end = children.end();
02145 for(vector<MMSWidget*>::iterator i = children.begin(); i != end; ++i) {
02146 (*i)->setPressed(set, false);
02147 }
02148 }
02149
02150
02151 this->refresh(refresh);
02152
02153
02154 return true;
02155 }
02156
02157 bool MMSWidget::setPressed(bool set, bool refresh) {
02158 return setPressed(set, refresh, false);
02159 }
02160
02161 bool MMSWidget::isPressed() {
02162 return this->pressed;
02163 }
02164
02165 void MMSWidget::setASelected(bool set, bool refresh) {
02166 setActivated(true, false);
02167 setSelected(set, refresh);
02168 }
02169
02170 void MMSWidget::setPSelected(bool set, bool refresh) {
02171 setPressed(true, false);
02172 setSelected(set, refresh);
02173 }
02174
02175 void MMSWidget::setISelected(bool set, bool refresh) {
02176 setActivated(false, false);
02177 setSelected(set, refresh);
02178 }
02179
02180 #ifdef sdsds
02181 void MMSWidget::handleNavigation(DFBInputDeviceKeySymbol key, MMSWidget *requestingchild) {
02182
02183 this->parent->handleNavigation(key,this);
02184 }
02185 #endif
02186
02187
02188
02189 void MMSWidget::resetPressed() {
02190
02191 string inputmode = "";
02192 getInputModeEx(inputmode);
02193 if (strToUpr(inputmode) == "CLICK") {
02194
02195 if (isPressed())
02196 setPressed(false);
02197
02198
02199 bool b = false;
02200 this->getFocusable(b);
02201 if (b)
02202 this->setFocus(false);
02203 else
02204 this->setSelected(false);
02205 }
02206 else {
02207
02208 if (isPressed())
02209 setPressed(false);
02210 }
02211 }
02212
02213
02214 void MMSWidget::handleInput(MMSInputEvent *inputevent) {
02215 bool b;
02216 if (inputevent->type == MMSINPUTEVENTTYPE_KEYPRESS) {
02217
02218
02219
02220 this->da->last_inputevent = *inputevent;
02221
02222 switch (inputevent->key) {
02223 case MMSKEY_CURSOR_DOWN:
02224
02225
02226
02227
02228
02229
02230
02231
02232
02233
02234 if (scrollDown())
02235 return;
02236 break;
02237
02238 case MMSKEY_CURSOR_UP:
02239 if (scrollUp())
02240 return;
02241 break;
02242
02243 case MMSKEY_CURSOR_RIGHT:
02244 if (scrollRight())
02245 return;
02246 break;
02247
02248 case MMSKEY_CURSOR_LEFT:
02249 if (scrollLeft())
02250 return;
02251 break;
02252
02253 case MMSKEY_RETURN:
02254 case MMSKEY_ZOOM:
02255
02256 if (emitOnReturnCallback()) {
02257 return;
02258 }
02259 break;
02260
02261 default:
02262 break;
02263 }
02264 }
02265 else
02266 if (inputevent->type == MMSINPUTEVENTTYPE_BUTTONPRESS) {
02267
02268 if (getClickable(b))
02269 if (b) {
02270
02271 this->da->last_inputevent = *inputevent;
02272 this->da->pressed_inputrect = this->geom;
02273
02274
02275 if (!isPressed())
02276 setPressed(true);
02277
02278
02279
02280 scrollTo(inputevent->posx, inputevent->posy, true, NULL,
02281 MMSWIDGET_SCROLL_MODE_SETPRESSED, &this->da->pressed_inputrect);
02282
02283 return;
02284 }
02285 }
02286 else
02287 if (inputevent->type == MMSINPUTEVENTTYPE_BUTTONRELEASE) {
02288
02289 if (getClickable(b))
02290 if (b) {
02291 if (this->da->last_inputevent.type == MMSINPUTEVENTTYPE_BUTTONPRESS) {
02292
02293 resetPressed();
02294
02295
02296 if ((inputevent->posx >= this->da->pressed_inputrect.x)&&(inputevent->posy >= this->da->pressed_inputrect.y)
02297 &&(inputevent->posx < this->da->pressed_inputrect.x + this->da->pressed_inputrect.w)&&(inputevent->posy < this->da->pressed_inputrect.y + this->da->pressed_inputrect.h)) {
02298
02299 bool changed = false;
02300 bool st_ok = scrollTo(this->da->last_inputevent.posx, this->da->last_inputevent.posy, true, &changed,
02301 MMSWIDGET_SCROLL_MODE_SETSELECTED | MMSWIDGET_SCROLL_MODE_RMPRESSED);
02302
02303
02304 this->onClick->emit(this, inputevent->posx - this->geom.x, inputevent->posy - this->geom.y,
02305 this->geom.w, this->geom.h);
02306
02307 if (changed) {
02308
02309 bool r;
02310 if (!getReturnOnScroll(r)) r = true;
02311 if (r) changed = false;
02312 }
02313 if (!changed && st_ok) {
02314
02315 emitOnReturnCallback();
02316 }
02317 }
02318 }
02319
02320
02321 resetPressed();
02322
02323
02324 this->da->last_inputevent = *inputevent;
02325 return;
02326 }
02327 }
02328 else
02329 if (inputevent->type == MMSINPUTEVENTTYPE_AXISMOTION) {
02330
02331 if (getClickable(b))
02332 if (b) {
02333 if (this->da->last_inputevent.type == MMSINPUTEVENTTYPE_BUTTONPRESS) {
02334
02335 if ((inputevent->posx >= this->da->pressed_inputrect.x)&&(inputevent->posy >= this->da->pressed_inputrect.y)
02336 &&(inputevent->posx < this->da->pressed_inputrect.x + this->da->pressed_inputrect.w)&&(inputevent->posy < this->da->pressed_inputrect.y + this->da->pressed_inputrect.h)) {
02337
02338 if (!isPressed())
02339 setPressed(true);
02340
02341
02342 scrollTo(this->da->last_inputevent.posx, this->da->last_inputevent.posy, true, NULL,
02343 MMSWIDGET_SCROLL_MODE_SETPRESSED);
02344 }
02345 else {
02346
02347 if (isPressed())
02348 setPressed(false);
02349
02350
02351 scrollTo(this->da->last_inputevent.posx, this->da->last_inputevent.posy, true, NULL,
02352 MMSWIDGET_SCROLL_MODE_RMPRESSED);
02353 }
02354 }
02355
02356 return;
02357 }
02358 }
02359
02360 throw MMSWidgetError(1,"input not handled");
02361 }
02362
02363
02364 bool MMSWidget::callOnReturn() {
02365 return true;
02366 }
02367
02368 bool MMSWidget::emitOnReturnCallback() {
02369
02370 if (!this->onReturn) return false;
02371
02372
02373 if (this->onReturn->empty()) return false;
02374
02375
02376 if (callOnReturn()) {
02377
02378 bool b;
02379 if (getFocusable(b, false)) {
02380 if (b) {
02381
02382 this->onReturn->emit(this);
02383 return true;
02384 }
02385 }
02386
02387
02388 printf("Widget \"%s\" (%s) is not focusable, cannot emit onReturn signal!\n",
02389 this->name.c_str(), this->getTypeString().c_str());
02390
02391 return false;
02392 }
02393 else {
02394
02395 return false;
02396 }
02397 }
02398
02399
02400
02401
02402
02403
02404
02405
02406
02407
02408
02409
02410
02411 void MMSWidget::setBinData(void *data) {
02412 this->bindata = data;
02413 }
02414
02415 void *MMSWidget::getBinData() {
02416 return this->bindata;
02417
02418 }
02419
02420 string MMSWidget::getSizeHint() {
02421 return this->sizehint;
02422 }
02423
02424 bool MMSWidget::setSizeHint(string &hint) {
02425 if (getPixelFromSizeHint(NULL, hint, 10000, 0)) {
02426 this->sizehint = hint;
02427 return true;
02428 }
02429 else
02430 return false;
02431 }
02432
02433 string MMSWidget::getMinWidth() {
02434 return this->min_width;
02435 }
02436
02437 int MMSWidget::getMinWidthPix() {
02438 return this->min_width_pix;
02439 }
02440
02441 bool MMSWidget::setMinWidth(string &min_width) {
02442 int pix, base_pix = 10000;
02443 if (this->rootwindow) base_pix = this->rootwindow->geom.w;
02444
02445 if (getPixelFromSizeHint(&pix, min_width, base_pix, 0)) {
02446 this->min_width = min_width;
02447 this->min_width_pix = pix;
02448 this->minmax_set = true;
02449 return true;
02450 }
02451 else
02452 return false;
02453 }
02454
02455 string MMSWidget::getMinHeight() {
02456 return this->min_height;
02457 }
02458
02459 int MMSWidget::getMinHeightPix() {
02460 return this->min_height_pix;
02461 }
02462
02463 bool MMSWidget::setMinHeight(string &min_height) {
02464 int pix, base_pix = 10000;
02465 if (this->rootwindow) base_pix = this->rootwindow->geom.h;
02466
02467 if (getPixelFromSizeHint(&pix, min_height, base_pix, 0)) {
02468 this->min_height = min_height;
02469 this->min_height_pix = pix;
02470 this->minmax_set = true;
02471 return true;
02472 }
02473 else
02474 return false;
02475 }
02476
02477 string MMSWidget::getMaxWidth() {
02478 return this->max_width;
02479 }
02480
02481 int MMSWidget::getMaxWidthPix() {
02482 return this->max_width_pix;
02483 }
02484
02485 bool MMSWidget::setMaxWidth(string &max_width) {
02486 int pix, base_pix = 10000;
02487 if (this->rootwindow) base_pix = this->rootwindow->geom.w;
02488
02489 if (getPixelFromSizeHint(&pix, max_width, base_pix, 0)) {
02490 this->max_width = max_width;
02491 this->max_width_pix = pix;
02492 this->minmax_set = true;
02493 return true;
02494 }
02495 else
02496 return false;
02497 }
02498
02499 string MMSWidget::getMaxHeight() {
02500 return this->max_height;
02501 }
02502
02503 int MMSWidget::getMaxHeightPix() {
02504 return this->max_height_pix;
02505 }
02506
02507 bool MMSWidget::setMaxHeight(string &max_height) {
02508 int pix, base_pix = 10000;
02509 if (this->rootwindow) base_pix = this->rootwindow->geom.h;
02510
02511 if (getPixelFromSizeHint(&pix, max_height, base_pix, 0)) {
02512 this->max_height = max_height;
02513 this->max_height_pix = pix;
02514 this->minmax_set = true;
02515 return true;
02516 }
02517 else
02518 return false;
02519 }
02520
02521 bool MMSWidget::isGeomSet() {
02522 return this->geomset;
02523 }
02524
02525 void MMSWidget::setGeomSet(bool set) {
02526 this->geomset = set;
02527 }
02528
02529
02530 bool MMSWidget::isVisible() {
02531 return this->visible;
02532 }
02533
02534 void MMSWidget::setVisible(bool visible, bool refresh) {
02535
02536 if (this->geomset) {
02537 if (visible) {
02538 if (!this->visible) {
02539 if ((!this->surface)&&(surfaceGeom.w!=0)&&(surfaceGeom.h!=0)) {
02540 unsigned int w,h;
02541 w=surfaceGeom.w;
02542 h=surfaceGeom.h;
02543 surfaceGeom.w=0;
02544 surfaceGeom.h=0;
02545 setSurfaceGeometry(w,h);
02546 }
02547 }
02548 }
02549 else {
02550 if (this->visible) {
02551 if (this->surface) {
02552 delete this->surface;
02553 this->surface = NULL;
02554 }
02555 }
02556 }
02557 }
02558
02559
02560
02561
02562
02563
02564 this->visible = visible;
02565 vector<MMSWidget*>::iterator end = children.end();
02566 for(vector<MMSWidget*>::iterator i = children.begin(); i != end; ++i) {
02567 (*i)->setVisible(this->visible, false);
02568 }
02569
02570
02571 enableRefresh();
02572
02573 this->refresh(refresh);
02574 }
02575
02576 unsigned char MMSWidget::getBrightness() {
02577 return this->brightness;
02578 }
02579
02580 void MMSWidget::setBrightness(unsigned char brightness, bool refresh) {
02581 this->brightness = brightness;
02582 vector<MMSWidget*>::iterator end = children.end();
02583 for(vector<MMSWidget*>::iterator i = children.begin(); i != end; ++i) {
02584 (*i)->setBrightness(brightness, false);
02585 }
02586
02587
02588 enableRefresh();
02589
02590 this->refresh(refresh);
02591 }
02592
02593 unsigned char MMSWidget::getOpacity() {
02594 return this->opacity;
02595 }
02596
02597 void MMSWidget::setOpacity(unsigned char opacity, bool refresh) {
02598 this->opacity = opacity;
02599 vector<MMSWidget*>::iterator end = children.end();
02600 for(vector<MMSWidget*>::iterator i = children.begin(); i != end; ++i) {
02601 (*i)->setOpacity(opacity, false);
02602 }
02603
02604
02605 enableRefresh();
02606
02607 this->refresh(refresh);
02608 }
02609
02610
02611 MMSWidget *MMSWidget::getNavigateUpWidget() {
02612 return this->da->navigateUpWidget;
02613 }
02614
02615 MMSWidget *MMSWidget::getNavigateDownWidget() {
02616 return this->da->navigateDownWidget;
02617 }
02618
02619 MMSWidget *MMSWidget::getNavigateLeftWidget() {
02620 return this->da->navigateLeftWidget;
02621 }
02622
02623 MMSWidget *MMSWidget::getNavigateRightWidget() {
02624 return this->da->navigateRightWidget;
02625 }
02626
02627 void MMSWidget::setNavigateUpWidget(MMSWidget *upwidget) {
02628 this->da->navigateUpWidget = upwidget;
02629 }
02630
02631 void MMSWidget::setNavigateDownWidget(MMSWidget *downwidget) {
02632 this->da->navigateDownWidget = downwidget;
02633 }
02634
02635 void MMSWidget::setNavigateRightWidget(MMSWidget *rightwidget) {
02636 this->da->navigateRightWidget = rightwidget;
02637 }
02638
02639 void MMSWidget::setNavigateLeftWidget(MMSWidget *leftwidget) {
02640 this->da->navigateLeftWidget = leftwidget;
02641 }
02642
02643 bool MMSWidget::canNavigateUp() {
02644 if (this->da->navigateUpWidget)
02645 return true;
02646 else
02647 return scrollUp(1, false, true);
02648 }
02649
02650 bool MMSWidget::canNavigateDown() {
02651 if (this->da->navigateDownWidget)
02652 return true;
02653 else
02654 return scrollDown(1, false, true);
02655 }
02656
02657 bool MMSWidget::canNavigateLeft() {
02658 if (this->da->navigateLeftWidget)
02659 return true;
02660 else
02661 return scrollLeft(1, false, true);
02662 }
02663
02664 bool MMSWidget::canNavigateRight() {
02665 if (this->da->navigateRightWidget)
02666 return true;
02667 else
02668 return scrollRight(1, false, true);
02669 }
02670
02671
02672
02673
02674
02675 #define GETWIDGET(x,y) \
02676 if (!this->da) return false; \
02677 else if (this->da->myWidgetClass.is##x()) return this->da->myWidgetClass.get##x(y); \
02678 else if ((this->da->widgetClass)&&(this->da->widgetClass->is##x())) return this->da->widgetClass->get##x(y); \
02679 else if (this->da->baseWidgetClass) return this->da->baseWidgetClass->get##x(y); \
02680 else return this->da->myWidgetClass.get##x(y);
02681
02682
02683 bool MMSWidget::getBgColor(MMSFBColor &bgcolor) {
02684 GETWIDGET(BgColor, bgcolor);
02685 }
02686
02687 bool MMSWidget::getSelBgColor(MMSFBColor &selbgcolor) {
02688 GETWIDGET(SelBgColor, selbgcolor);
02689 }
02690
02691 bool MMSWidget::getBgColor_p(MMSFBColor &bgcolor_p) {
02692 GETWIDGET(BgColor_p, bgcolor_p);
02693 }
02694
02695 bool MMSWidget::getSelBgColor_p(MMSFBColor &selbgcolor_p) {
02696 GETWIDGET(SelBgColor_p, selbgcolor_p);
02697 }
02698
02699 bool MMSWidget::getBgColor_i(MMSFBColor &bgcolor_i) {
02700 GETWIDGET(BgColor_i, bgcolor_i);
02701 }
02702
02703 bool MMSWidget::getSelBgColor_i(MMSFBColor &selbgcolor_i) {
02704 GETWIDGET(SelBgColor_i, selbgcolor_i);
02705 }
02706
02707 bool MMSWidget::getBgImagePath(string &bgimagepath) {
02708 GETWIDGET(BgImagePath,bgimagepath);
02709 }
02710
02711 bool MMSWidget::getBgImageName(string &bgimagename) {
02712 GETWIDGET(BgImageName,bgimagename);
02713 }
02714
02715 bool MMSWidget::getSelBgImagePath(string &selbgimagepath) {
02716 GETWIDGET(SelBgImagePath, selbgimagepath);
02717 }
02718
02719 bool MMSWidget::getSelBgImageName(string &selbgimagename) {
02720 GETWIDGET(SelBgImageName, selbgimagename);
02721 }
02722
02723 bool MMSWidget::getBgImagePath_p(string &bgimagepath_p) {
02724 GETWIDGET(BgImagePath_p, bgimagepath_p);
02725 }
02726
02727 bool MMSWidget::getBgImageName_p(string &bgimagename_p) {
02728 GETWIDGET(BgImageName_p, bgimagename_p);
02729 }
02730
02731 bool MMSWidget::getSelBgImagePath_p(string &selbgimagepath_p) {
02732 GETWIDGET(SelBgImagePath_p, selbgimagepath_p);
02733 }
02734
02735 bool MMSWidget::getSelBgImageName_p(string &selbgimagename_p) {
02736 GETWIDGET(SelBgImageName_p, selbgimagename_p);
02737 }
02738
02739 bool MMSWidget::getBgImagePath_i(string &bgimagepath_i) {
02740 GETWIDGET(BgImagePath_i, bgimagepath_i);
02741 }
02742
02743 bool MMSWidget::getBgImageName_i(string &bgimagename_i) {
02744 GETWIDGET(BgImageName_i, bgimagename_i);
02745 }
02746
02747 bool MMSWidget::getSelBgImagePath_i(string &selbgimagepath_i) {
02748 GETWIDGET(SelBgImagePath_i, selbgimagepath_i);
02749 }
02750
02751 bool MMSWidget::getSelBgImageName_i(string &selbgimagename_i) {
02752 GETWIDGET(SelBgImageName_i, selbgimagename_i);
02753 }
02754
02755 bool MMSWidget::getMargin(unsigned int &margin) {
02756 GETWIDGET(Margin, margin);
02757 }
02758
02759 bool MMSWidget::getFocusable(bool &focusable, bool check_selectable) {
02760 if (check_selectable) {
02761 if (getSelectable(focusable)) {
02762 if (focusable) {
02763 GETWIDGET(Focusable, focusable);
02764 }
02765 }
02766 else {
02767 GETWIDGET(Focusable, focusable);
02768 }
02769 }
02770 else {
02771 GETWIDGET(Focusable, focusable);
02772 }
02773
02774 return false;
02775 }
02776
02777 bool MMSWidget::getSelectable(bool &selectable) {
02778 GETWIDGET(Selectable, selectable);
02779 }
02780
02781 bool MMSWidget::getUpArrow(string &uparrow) {
02782 GETWIDGET(UpArrow, uparrow);
02783 }
02784
02785 bool MMSWidget::getDownArrow(string &downarrow) {
02786 GETWIDGET(DownArrow, downarrow);
02787 }
02788
02789 bool MMSWidget::getLeftArrow(string &leftarrow) {
02790 GETWIDGET(LeftArrow, leftarrow);
02791 }
02792
02793 bool MMSWidget::getRightArrow(string &rightarrow) {
02794 GETWIDGET(RightArrow, rightarrow);
02795 }
02796
02797 bool MMSWidget::getData(string &data) {
02798 GETWIDGET(Data, data);
02799 }
02800
02801 bool MMSWidget::getNavigateUp(string &navigateup) {
02802 GETWIDGET(NavigateUp, navigateup);
02803 }
02804
02805 bool MMSWidget::getNavigateDown(string &navigatedown) {
02806 GETWIDGET(NavigateDown, navigatedown);
02807 }
02808
02809 bool MMSWidget::getNavigateLeft(string &navigateleft) {
02810 GETWIDGET(NavigateLeft, navigateleft);
02811 }
02812
02813 bool MMSWidget::getNavigateRight(string &navigateright) {
02814 GETWIDGET(NavigateRight, navigateright);
02815 }
02816
02817
02818 bool MMSWidget::getVSlider(string &vslider) {
02819 GETWIDGET(VSlider, vslider);
02820 }
02821
02822 bool MMSWidget::getHSlider(string &hslider) {
02823 GETWIDGET(HSlider, hslider);
02824 }
02825
02826 bool MMSWidget::getImagesOnDemand(bool &imagesondemand) {
02827 GETWIDGET(ImagesOnDemand, imagesondemand);
02828 }
02829
02830 bool MMSWidget::getBlend(unsigned int &blend) {
02831 GETWIDGET(Blend, blend);
02832 }
02833
02834 bool MMSWidget::getBlendFactor(double &blendfactor) {
02835 GETWIDGET(BlendFactor, blendfactor);
02836 }
02837
02838 bool MMSWidget::getScrollOnFocus(bool &scrollonfocus) {
02839 GETWIDGET(ScrollOnFocus, scrollonfocus);
02840 }
02841
02842 bool MMSWidget::getClickable(bool &clickable) {
02843 GETWIDGET(Clickable, clickable);
02844 }
02845
02846 bool MMSWidget::getReturnOnScroll(bool &returnonscroll) {
02847 GETWIDGET(ReturnOnScroll, returnonscroll);
02848 }
02849
02850 bool MMSWidget::getInputMode(string &inputmode) {
02851 GETWIDGET(InputMode, inputmode);
02852 }
02853
02854 bool MMSWidget::getInputModeEx(string &inputmode) {
02855 getInputMode(inputmode);
02856 if (inputmode == "") {
02857 if (this->parent)
02858 return this->parent->getInputModeEx(inputmode);
02859 else
02860 inputmode = MMSWidget_inputmode;
02861 }
02862 return true;
02863 }
02864
02865 bool MMSWidget::getJoinedWidget(string &joinedwidget) {
02866 GETWIDGET(JoinedWidget, joinedwidget);
02867 }
02868
02869 bool MMSWidget::getActivated(bool &activated) {
02870 GETWIDGET(Activated, activated);
02871 }
02872
02873
02874 #define GETBORDER(x,y) \
02875 if (!this->da) return false; \
02876 else if (this->da->myWidgetClass.border.is##x()) return this->da->myWidgetClass.border.get##x(y); \
02877 else if ((this->da->widgetClass)&&(this->da->widgetClass->border.is##x())) return this->da->widgetClass->border.get##x(y); \
02878 else return this->da->baseWidgetClass->border.get##x(y);
02879
02880 #define GETBORDER_IMAGES(x,p,y) \
02881 if (!this->da) return false; \
02882 else if (this->da->myWidgetClass.border.is##x()) return this->da->myWidgetClass.border.get##x(p,y); \
02883 else if ((this->da->widgetClass)&&(this->da->widgetClass->border.is##x())) return this->da->widgetClass->border.get##x(p,y); \
02884 else return this->da->baseWidgetClass->border.get##x(p,y);
02885
02886
02887
02888 bool MMSWidget::getBorderColor(MMSFBColor &color) {
02889 GETBORDER(Color, color);
02890 }
02891
02892 bool MMSWidget::getBorderSelColor(MMSFBColor &selcolor) {
02893 GETBORDER(SelColor, selcolor);
02894 }
02895
02896 bool MMSWidget::getBorderImagePath(string &imagepath) {
02897 GETBORDER(ImagePath, imagepath);
02898 }
02899
02900 bool MMSWidget::getBorderImageNames(MMSBORDER_IMAGE_NUM num, string &imagename) {
02901 GETBORDER_IMAGES(ImageNames, num, imagename);
02902 }
02903
02904 bool MMSWidget::getBorderSelImagePath(string &selimagepath) {
02905 GETBORDER(SelImagePath, selimagepath);
02906 }
02907
02908 bool MMSWidget::getBorderSelImageNames(MMSBORDER_IMAGE_NUM num, string &selimagename) {
02909 GETBORDER_IMAGES(SelImageNames, num, selimagename);
02910 }
02911
02912 bool MMSWidget::getBorderThickness(unsigned int &thickness) {
02913 GETBORDER(Thickness, thickness);
02914 }
02915
02916 bool MMSWidget::getBorderMargin(unsigned int &margin) {
02917 GETBORDER(Margin, margin);
02918 }
02919
02920 bool MMSWidget::getBorderRCorners(bool &rcorners) {
02921 GETBORDER(RCorners, rcorners);
02922 }
02923
02924
02925
02926
02927
02928 bool MMSWidget::setBgColor(MMSFBColor bgcolor, bool refresh) {
02929 if (!this->da) return false;
02930 this->da->myWidgetClass.setBgColor(bgcolor);
02931
02932
02933 enableRefresh((bgcolor != this->current_bgcolor));
02934
02935 this->refresh(refresh);
02936
02937 return true;
02938 }
02939
02940 bool MMSWidget::setSelBgColor(MMSFBColor selbgcolor, bool refresh) {
02941 if (!this->da) return false;
02942 this->da->myWidgetClass.setSelBgColor(selbgcolor);
02943
02944
02945 enableRefresh((selbgcolor != this->current_bgcolor));
02946
02947 this->refresh(refresh);
02948
02949 return true;
02950 }
02951
02952 bool MMSWidget::setBgColor_p(MMSFBColor bgcolor_p, bool refresh) {
02953 if (!this->da) return false;
02954 this->da->myWidgetClass.setBgColor_p(bgcolor_p);
02955
02956
02957 enableRefresh((bgcolor_p != this->current_bgcolor));
02958
02959 this->refresh(refresh);
02960
02961 return true;
02962 }
02963
02964 bool MMSWidget::setSelBgColor_p(MMSFBColor selbgcolor_p, bool refresh) {
02965 if (!this->da) return false;
02966 this->da->myWidgetClass.setSelBgColor_p(selbgcolor_p);
02967
02968
02969 enableRefresh((selbgcolor_p != this->current_bgcolor));
02970
02971 this->refresh(refresh);
02972
02973 return true;
02974 }
02975
02976 bool MMSWidget::setBgColor_i(MMSFBColor bgcolor_i, bool refresh) {
02977 if (!this->da) return false;
02978 this->da->myWidgetClass.setBgColor_i(bgcolor_i);
02979
02980
02981 enableRefresh((bgcolor_i != this->current_bgcolor));
02982
02983 this->refresh(refresh);
02984
02985 return true;
02986 }
02987
02988 bool MMSWidget::setSelBgColor_i(MMSFBColor selbgcolor_i, bool refresh) {
02989 if (!this->da) return false;
02990 this->da->myWidgetClass.setSelBgColor_i(selbgcolor_i);
02991
02992
02993 enableRefresh((selbgcolor_i != this->current_bgcolor));
02994
02995 this->refresh(refresh);
02996
02997 return true;
02998 }
02999
03000 bool MMSWidget::setBgImagePath(string bgimagepath, bool load, bool refresh) {
03001 if (!this->da) return false;
03002 this->da->myWidgetClass.setBgImagePath(bgimagepath);
03003 if (load) {
03004 if (this->rootwindow) {
03005
03006 enableRefresh((this->da->bgimage == this->current_bgimage));
03007
03008 this->rootwindow->im->releaseImage(this->da->bgimage);
03009 string path, name;
03010 if (!getBgImagePath(path)) path = "";
03011 if (!getBgImageName(name)) name = "";
03012 this->da->bgimage = this->rootwindow->im->getImage(path, name);
03013 }
03014 }
03015
03016 this->refresh(refresh);
03017
03018 return true;
03019 }
03020
03021 bool MMSWidget::setBgImageName(string bgimagename, bool load, bool refresh) {
03022 if (!this->da) return false;
03023 this->da->myWidgetClass.setBgImageName(bgimagename);
03024 if (load) {
03025 if (this->rootwindow) {
03026
03027 enableRefresh((this->da->bgimage == this->current_bgimage));
03028
03029 this->rootwindow->im->releaseImage(this->da->bgimage);
03030 string path, name;
03031 if (!getBgImagePath(path)) path = "";
03032 if (!getBgImageName(name)) name = "";
03033 this->da->bgimage = this->rootwindow->im->getImage(path, name);
03034 }
03035 }
03036
03037 this->refresh(refresh);
03038
03039 return true;
03040 }
03041
03042 bool MMSWidget::setSelBgImagePath(string selbgimagepath, bool load, bool refresh) {
03043 if (!this->da) return false;
03044 this->da->myWidgetClass.setSelBgImagePath(selbgimagepath);
03045 if (load) {
03046 if (this->rootwindow) {
03047
03048 enableRefresh((this->da->selbgimage == this->current_bgimage));
03049
03050 this->rootwindow->im->releaseImage(this->da->selbgimage);
03051 string path, name;
03052 if (!getSelBgImagePath(path)) path = "";
03053 if (!getSelBgImageName(name)) name = "";
03054 this->da->selbgimage = this->rootwindow->im->getImage(path, name);
03055 }
03056 }
03057
03058 this->refresh(refresh);
03059
03060 return true;
03061 }
03062
03063 bool MMSWidget::setSelBgImageName(string selbgimagename, bool load, bool refresh) {
03064 if (!this->da) return false;
03065 this->da->myWidgetClass.setSelBgImageName(selbgimagename);
03066 if (load) {
03067 if (this->rootwindow) {
03068
03069 enableRefresh((this->da->selbgimage == this->current_bgimage));
03070
03071 this->rootwindow->im->releaseImage(this->da->selbgimage);
03072 string path, name;
03073 if (!getSelBgImagePath(path)) path = "";
03074 if (!getSelBgImageName(name)) name = "";
03075 this->da->selbgimage = this->rootwindow->im->getImage(path, name);
03076 }
03077 }
03078
03079 this->refresh(refresh);
03080
03081 return true;
03082 }
03083
03084 bool MMSWidget::setBgImagePath_p(string bgimagepath_p, bool load, bool refresh) {
03085 if (!this->da) return false;
03086 this->da->myWidgetClass.setBgImagePath_p(bgimagepath_p);
03087 if (load) {
03088 if (this->rootwindow) {
03089
03090 enableRefresh((this->da->bgimage_p == this->current_bgimage));
03091
03092 this->rootwindow->im->releaseImage(this->da->bgimage_p);
03093 string path, name;
03094 if (!getBgImagePath_p(path)) path = "";
03095 if (!getBgImageName_p(name)) name = "";
03096 this->da->bgimage_p = this->rootwindow->im->getImage(path, name);
03097 }
03098 }
03099
03100 this->refresh(refresh);
03101
03102 return true;
03103 }
03104
03105 bool MMSWidget::setBgImageName_p(string bgimagename_p, bool load, bool refresh) {
03106 if (!this->da) return false;
03107 this->da->myWidgetClass.setBgImageName_p(bgimagename_p);
03108 if (load) {
03109 if (this->rootwindow) {
03110
03111 enableRefresh((this->da->bgimage_p == this->current_bgimage));
03112
03113 this->rootwindow->im->releaseImage(this->da->bgimage_p);
03114 string path, name;
03115 if (!getBgImagePath_p(path)) path = "";
03116 if (!getBgImageName_p(name)) name = "";
03117 this->da->bgimage_p = this->rootwindow->im->getImage(path, name);
03118 }
03119 }
03120
03121 this->refresh(refresh);
03122
03123 return true;
03124 }
03125
03126 bool MMSWidget::setSelBgImagePath_p(string selbgimagepath_p, bool load, bool refresh) {
03127 if (!this->da) return false;
03128 this->da->myWidgetClass.setSelBgImagePath_p(selbgimagepath_p);
03129 if (load) {
03130 if (this->rootwindow) {
03131
03132 enableRefresh((this->da->selbgimage_p == this->current_bgimage));
03133
03134 this->rootwindow->im->releaseImage(this->da->selbgimage_p);
03135 string path, name;
03136 if (!getSelBgImagePath_p(path)) path = "";
03137 if (!getSelBgImageName_p(name)) name = "";
03138 this->da->selbgimage_p = this->rootwindow->im->getImage(path, name);
03139 }
03140 }
03141
03142 this->refresh(refresh);
03143
03144 return true;
03145 }
03146
03147 bool MMSWidget::setSelBgImageName_p(string selbgimagename_p, bool load, bool refresh) {
03148 if (!this->da) return false;
03149 this->da->myWidgetClass.setSelBgImageName_p(selbgimagename_p);
03150 if (load) {
03151 if (this->rootwindow) {
03152
03153 enableRefresh((this->da->selbgimage_p == this->current_bgimage));
03154
03155 this->rootwindow->im->releaseImage(this->da->selbgimage_p);
03156 string path, name;
03157 if (!getSelBgImagePath_p(path)) path = "";
03158 if (!getSelBgImageName_p(name)) name = "";
03159 this->da->selbgimage_p = this->rootwindow->im->getImage(path, name);
03160 }
03161 }
03162
03163 this->refresh(refresh);
03164
03165 return true;
03166 }
03167
03168 bool MMSWidget::setBgImagePath_i(string bgimagepath_i, bool load, bool refresh) {
03169 if (!this->da) return false;
03170 this->da->myWidgetClass.setBgImagePath_i(bgimagepath_i);
03171 if (load) {
03172 if (this->rootwindow) {
03173
03174 enableRefresh((this->da->bgimage_i == this->current_bgimage));
03175
03176 this->rootwindow->im->releaseImage(this->da->bgimage_i);
03177 string path, name;
03178 if (!getBgImagePath_i(path)) path = "";
03179 if (!getBgImageName_i(name)) name = "";
03180 this->da->bgimage_i = this->rootwindow->im->getImage(path, name);
03181 }
03182 }
03183
03184 this->refresh(refresh);
03185
03186 return true;
03187 }
03188
03189 bool MMSWidget::setBgImageName_i(string bgimagename_i, bool load, bool refresh) {
03190 if (!this->da) return false;
03191 this->da->myWidgetClass.setBgImageName_i(bgimagename_i);
03192 if (load) {
03193 if (this->rootwindow) {
03194
03195 enableRefresh((this->da->bgimage_i == this->current_bgimage));
03196
03197 this->rootwindow->im->releaseImage(this->da->bgimage_i);
03198 string path, name;
03199 if (!getBgImagePath_i(path)) path = "";
03200 if (!getBgImageName_i(name)) name = "";
03201 this->da->bgimage_i = this->rootwindow->im->getImage(path, name);
03202 }
03203 }
03204
03205 this->refresh(refresh);
03206
03207 return true;
03208 }
03209
03210 bool MMSWidget::setSelBgImagePath_i(string selbgimagepath_i, bool load, bool refresh) {
03211 if (!this->da) return false;
03212 this->da->myWidgetClass.setSelBgImagePath_i(selbgimagepath_i);
03213 if (load) {
03214 if (this->rootwindow) {
03215
03216 enableRefresh((this->da->selbgimage_i == this->current_bgimage));
03217
03218 this->rootwindow->im->releaseImage(this->da->selbgimage_i);
03219 string path, name;
03220 if (!getSelBgImagePath_i(path)) path = "";
03221 if (!getSelBgImageName_i(name)) name = "";
03222 this->da->selbgimage_i = this->rootwindow->im->getImage(path, name);
03223 }
03224 }
03225
03226 this->refresh(refresh);
03227
03228 return true;
03229 }
03230
03231 bool MMSWidget::setSelBgImageName_i(string selbgimagename_i, bool load, bool refresh) {
03232 if (!this->da) return false;
03233 this->da->myWidgetClass.setSelBgImageName_i(selbgimagename_i);
03234 if (load) {
03235 if (this->rootwindow) {
03236
03237 enableRefresh((this->da->selbgimage_i == this->current_bgimage));
03238
03239 this->rootwindow->im->releaseImage(this->da->selbgimage_i);
03240 string path, name;
03241 if (!getSelBgImagePath_i(path)) path = "";
03242 if (!getSelBgImageName_i(name)) name = "";
03243 this->da->selbgimage_i = this->rootwindow->im->getImage(path, name);
03244 }
03245 }
03246
03247 this->refresh(refresh);
03248
03249 return true;
03250 }
03251
03252 bool MMSWidget::setMargin(unsigned int margin, bool refresh) {
03253 if (!this->da) return false;
03254 this->da->myWidgetClass.setMargin(margin);
03255
03256 setInnerGeometry();
03257
03258
03259 enableRefresh();
03260
03261 this->refresh(refresh);
03262
03263 return true;
03264 }
03265
03266 bool MMSWidget::setFocusable(bool focusable, bool refresh) {
03267 if (!this->da) return false;
03268
03269 if (this->focusable_initial) {
03270 if ((!focusable)&&(isFocused()))
03271 setFocus(false, refresh);
03272 this->da->myWidgetClass.setFocusable(focusable);
03273 return true;
03274 }
03275 else {
03276
03277 if (!focusable) {
03278
03279 this->da->myWidgetClass.setFocusable(focusable);
03280 return true;
03281 }
03282 }
03283 return false;
03284 }
03285
03286 bool MMSWidget::setSelectable(bool selectable, bool refresh) {
03287 if (!this->da) return false;
03288 if (this->selectable_initial) {
03289 if ((!selectable)&&(isSelected()))
03290 setSelected(false, refresh);
03291 this->da->myWidgetClass.setSelectable(selectable);
03292 return true;
03293 }
03294 return false;
03295 }
03296
03297 bool MMSWidget::setUpArrow(string uparrow, bool refresh) {
03298 if (!this->da) return false;
03299 this->da->myWidgetClass.setUpArrow(uparrow);
03300 this->da->upArrowWidget = NULL;
03301
03302
03303 enableRefresh();
03304
03305 this->refresh(refresh);
03306
03307 return true;
03308 }
03309
03310 bool MMSWidget::setDownArrow(string downarrow, bool refresh) {
03311 if (!this->da) return false;
03312 this->da->myWidgetClass.setDownArrow(downarrow);
03313 this->da->downArrowWidget = NULL;
03314
03315
03316 enableRefresh();
03317
03318 this->refresh(refresh);
03319
03320 return true;
03321 }
03322
03323 bool MMSWidget::setLeftArrow(string leftarrow, bool refresh) {
03324 if (!this->da) return false;
03325 this->da->myWidgetClass.setLeftArrow(leftarrow);
03326 this->da->leftArrowWidget = NULL;
03327
03328
03329 enableRefresh();
03330
03331 this->refresh(refresh);
03332
03333 return true;
03334 }
03335
03336 bool MMSWidget::setRightArrow(string rightarrow, bool refresh) {
03337 if (!this->da) return false;
03338 this->da->myWidgetClass.setRightArrow(rightarrow);
03339 this->da->rightArrowWidget = NULL;
03340
03341
03342 enableRefresh();
03343
03344 this->refresh(refresh);
03345
03346 return true;
03347 }
03348
03349 bool MMSWidget::setData(string data) {
03350 if (!this->da) return false;
03351 this->da->myWidgetClass.setData(data);
03352 return true;
03353 }
03354
03355 bool MMSWidget::setNavigateUp(string navigateup) {
03356 if (!this->da) return false;
03357 this->da->myWidgetClass.setNavigateUp(navigateup);
03358 this->da->navigateUpWidget = NULL;
03359 if ((this->rootwindow)&&(!navigateup.empty()))
03360 this->da->navigateUpWidget = this->rootwindow->findWidget(navigateup);
03361 return true;
03362 }
03363
03364 bool MMSWidget::setNavigateDown(string navigatedown) {
03365 if (!this->da) return false;
03366 this->da->myWidgetClass.setNavigateDown(navigatedown);
03367 this->da->navigateDownWidget = NULL;
03368 if ((this->rootwindow)&&(!navigatedown.empty()))
03369 this->da->navigateDownWidget = this->rootwindow->findWidget(navigatedown);
03370 return true;
03371 }
03372
03373 bool MMSWidget::setNavigateLeft(string navigateleft) {
03374 if (!this->da) return false;
03375 this->da->myWidgetClass.setNavigateLeft(navigateleft);
03376 this->da->navigateLeftWidget = NULL;
03377 if ((this->rootwindow)&&(!navigateleft.empty()))
03378 this->da->navigateLeftWidget = this->rootwindow->findWidget(navigateleft);
03379 return true;
03380 }
03381
03382 bool MMSWidget::setNavigateRight(string navigateright) {
03383 if (!this->da) return false;
03384 this->da->myWidgetClass.setNavigateRight(navigateright);
03385 this->da->navigateRightWidget = NULL;
03386 if ((this->rootwindow)&&(!navigateright.empty()))
03387 this->da->navigateRightWidget = this->rootwindow->findWidget(navigateright);
03388 return true;
03389 }
03390
03391 bool MMSWidget::setVSlider(string vslider) {
03392 if (!this->da) return false;
03393 this->da->myWidgetClass.setVSlider(vslider);
03394 this->da->vSliderWidget = NULL;
03395 if ((this->rootwindow)&&(!vslider.empty()))
03396 this->da->vSliderWidget = this->rootwindow->findWidget(vslider);
03397 return true;
03398 }
03399
03400 bool MMSWidget::setHSlider(string hslider) {
03401 if (!this->da) return false;
03402 this->da->myWidgetClass.setHSlider(hslider);
03403 this->da->hSliderWidget = NULL;
03404 if ((this->rootwindow)&&(!hslider.empty()))
03405 this->da->hSliderWidget = this->rootwindow->findWidget(hslider);
03406 return true;
03407 }
03408
03409 bool MMSWidget::setImagesOnDemand(bool imagesondemand) {
03410 if (!this->da) return false;
03411 this->da->myWidgetClass.setImagesOnDemand(imagesondemand);
03412 return true;
03413 }
03414
03415 bool MMSWidget::setBlend(unsigned int blend, bool refresh) {
03416 if (this->da) this->da->myWidgetClass.setBlend(blend);
03417 vector<MMSWidget*>::iterator end = children.end();
03418 for(vector<MMSWidget*>::iterator i = children.begin(); i != end; ++i) {
03419 (*i)->setBlend(blend, false);
03420 }
03421
03422
03423 enableRefresh();
03424
03425 this->refresh(refresh);
03426
03427 return true;
03428 }
03429
03430 bool MMSWidget::setBlendFactor(double blendfactor, bool refresh) {
03431 if (this->da) this->da->myWidgetClass.setBlendFactor(blendfactor);
03432 vector<MMSWidget*>::iterator end = children.end();
03433 for(vector<MMSWidget*>::iterator i = children.begin(); i != end; ++i) {
03434 (*i)->setBlendFactor(blendfactor, false);
03435 }
03436
03437
03438 enableRefresh();
03439
03440 this->refresh(refresh);
03441
03442 return true;
03443 }
03444
03445 bool MMSWidget::setScrollOnFocus(bool scrollonfocus) {
03446 if (!this->da) return false;
03447 this->da->myWidgetClass.setScrollOnFocus(scrollonfocus);
03448 return true;
03449 }
03450
03451 bool MMSWidget::setClickable(bool clickable) {
03452 if (!this->da) return false;
03453 this->da->myWidgetClass.setClickable(clickable);
03454 return true;
03455 }
03456
03457 bool MMSWidget::setReturnOnScroll(bool returnonscroll) {
03458 if (!this->da) return false;
03459 this->da->myWidgetClass.setClickable(returnonscroll);
03460 return true;
03461 }
03462
03463 bool MMSWidget::setInputMode(string inputmode) {
03464 if (!this->da) return false;
03465 this->da->myWidgetClass.setInputMode(inputmode);
03466 return true;
03467 }
03468
03469 bool MMSWidget::setJoinedWidget(string joinedwidget) {
03470 if (!this->da) return false;
03471 this->da->myWidgetClass.setJoinedWidget(joinedwidget);
03472 this->da->joinedWidget = NULL;
03473 if ((this->rootwindow)&&(!joinedwidget.empty()))
03474 this->da->joinedWidget = this->rootwindow->findWidget(joinedwidget);
03475
03476
03477 return true;
03478 }
03479
03480
03481
03482 bool MMSWidget::setActivated(bool activated, bool refresh) {
03483 if (this->da) this->da->myWidgetClass.setActivated(activated);
03484
03485
03486 vector<MMSWidget*>::iterator end = children.end();
03487 for(vector<MMSWidget*>::iterator i = children.begin(); i != end; ++i) {
03488 (*i)->setActivated(activated, false);
03489 }
03490
03491
03492 checkRefreshStatus();
03493
03494
03495 this->refresh(refresh);
03496
03497 return true;
03498 }
03499
03500 bool MMSWidget::setBorderColor(MMSFBColor bordercolor, bool refresh) {
03501 if (!this->da) return false;
03502 this->da->myWidgetClass.border.setColor(bordercolor);
03503
03504
03505 enableRefresh();
03506
03507 this->refresh(refresh);
03508
03509 return true;
03510 }
03511
03512 bool MMSWidget::setBorderSelColor(MMSFBColor borderselcolor, bool refresh) {
03513 if (!this->da) return false;
03514 this->da->myWidgetClass.border.setSelColor(borderselcolor);
03515
03516
03517 enableRefresh();
03518
03519 this->refresh(refresh);
03520
03521 return true;
03522 }
03523
03524 bool MMSWidget::setBorderImagePath(string borderimagepath, bool load, bool refresh) {
03525 if (!this->da) return false;
03526 this->da->myWidgetClass.border.setImagePath(borderimagepath);
03527 if (load) {
03528 if (this->rootwindow) {
03529 string path, name;
03530 if (!getBorderImagePath(path)) path = "";
03531 for (int i=0;i<MMSBORDER_IMAGE_NUM_SIZE;i++) {
03532 this->rootwindow->im->releaseImage(this->da->borderimages[i]);
03533 if (!getBorderImageNames((MMSBORDER_IMAGE_NUM)i, name)) name = "";
03534 this->da->borderimages[i] = this->rootwindow->im->getImage(path, name);
03535 }
03536 }
03537 }
03538
03539
03540 enableRefresh();
03541
03542 this->refresh(refresh);
03543
03544 return true;
03545 }
03546
03547 bool MMSWidget::setBorderImageNames(string imagename_1, string imagename_2, string imagename_3, string imagename_4,
03548 string imagename_5, string imagename_6, string imagename_7, string imagename_8,
03549 bool load, bool refresh) {
03550 if (!this->da) return false;
03551 this->da->myWidgetClass.border.setImageNames(imagename_1, imagename_2, imagename_3, imagename_4,
03552 imagename_5, imagename_6, imagename_7, imagename_8);
03553 if (load) {
03554 if (this->rootwindow) {
03555 string path, name;
03556 if (!getBorderImagePath(path)) path = "";
03557 for (int i=0;i<MMSBORDER_IMAGE_NUM_SIZE;i++) {
03558 this->rootwindow->im->releaseImage(this->da->borderimages[i]);
03559 if (!getBorderImageNames((MMSBORDER_IMAGE_NUM)i, name)) name = "";
03560 this->da->borderimages[i] = this->rootwindow->im->getImage(path, name);
03561 }
03562 }
03563 }
03564
03565
03566 enableRefresh();
03567
03568 this->refresh(refresh);
03569
03570 return true;
03571 }
03572
03573 bool MMSWidget::setBorderSelImagePath(string borderselimagepath, bool load, bool refresh) {
03574 if (!this->da) return false;
03575 this->da->myWidgetClass.border.setSelImagePath(borderselimagepath);
03576 if (load) {
03577 if (this->rootwindow) {
03578 string path, name;
03579 if (!getBorderSelImagePath(path)) path = "";
03580 for (int i=0;i<MMSBORDER_IMAGE_NUM_SIZE;i++) {
03581 this->rootwindow->im->releaseImage(this->da->borderselimages[i]);
03582 if (!getBorderSelImageNames((MMSBORDER_IMAGE_NUM)i, name)) name = "";
03583 this->da->borderselimages[i] = this->rootwindow->im->getImage(path, name);
03584 }
03585 }
03586 }
03587
03588
03589 enableRefresh();
03590
03591 this->refresh(refresh);
03592
03593 return true;
03594 }
03595
03596 bool MMSWidget::setBorderSelImageNames(string selimagename_1, string selimagename_2, string selimagename_3, string selimagename_4,
03597 string selimagename_5, string selimagename_6, string selimagename_7, string selimagename_8,
03598 bool load, bool refresh) {
03599 if (!this->da) return false;
03600 this->da->myWidgetClass.border.setSelImageNames(selimagename_1, selimagename_2, selimagename_3, selimagename_4,
03601 selimagename_5, selimagename_6, selimagename_7, selimagename_8);
03602 if (load) {
03603 if (this->rootwindow) {
03604 string path, name;
03605 if (!getBorderSelImagePath(path)) path = "";
03606
03607 for (int i=0;i<MMSBORDER_IMAGE_NUM_SIZE;i++) {
03608 this->rootwindow->im->releaseImage(this->da->borderselimages[i]);
03609 if (!getBorderSelImageNames((MMSBORDER_IMAGE_NUM)i, name)) name = "";
03610 this->da->borderselimages[i] = this->rootwindow->im->getImage(path, name);
03611 }
03612 }
03613 }
03614
03615
03616 enableRefresh();
03617
03618 this->refresh(refresh);
03619
03620 return true;
03621 }
03622
03623 bool MMSWidget::setBorderThickness(unsigned int borderthickness, bool refresh) {
03624 if (!this->da) return false;
03625 this->da->myWidgetClass.border.setThickness(borderthickness);
03626
03627 setInnerGeometry();
03628
03629
03630 enableRefresh();
03631
03632 this->refresh(refresh);
03633
03634 return true;
03635 }
03636
03637 bool MMSWidget::setBorderMargin(unsigned int bordermargin, bool refresh) {
03638 if (!this->da) return false;
03639 this->da->myWidgetClass.border.setMargin(bordermargin);
03640
03641 setInnerGeometry();
03642
03643
03644 enableRefresh();
03645
03646 this->refresh(refresh);
03647
03648 return true;
03649 }
03650
03651 bool MMSWidget::setBorderRCorners(bool borderrcorners, bool refresh) {
03652 if (!this->da) return false;
03653 this->da->myWidgetClass.border.setRCorners(borderrcorners);
03654
03655
03656 enableRefresh();
03657
03658 this->refresh(refresh);
03659
03660 return true;
03661 }
03662
03663 void MMSWidget::updateFromThemeClass(MMSWidgetClass *themeClass) {
03664 bool b;
03665 MMSFBColor c;
03666 string s;
03667 unsigned int u;
03668 double d;
03669
03670 if (themeClass->getImagesOnDemand(b))
03671 setImagesOnDemand(b);
03672 if (themeClass->getBgColor(c))
03673 setBgColor(c);
03674 if (themeClass->getSelBgColor(c))
03675 setSelBgColor(c);
03676 if (themeClass->getBgColor_p(c))
03677 setBgColor_p(c);
03678 if (themeClass->getSelBgColor_p(c))
03679 setSelBgColor_p(c);
03680 if (themeClass->getBgColor_i(c))
03681 setBgColor_i(c);
03682 if (themeClass->getSelBgColor_i(c))
03683 setSelBgColor_i(c);
03684 if (themeClass->getBgImagePath(s))
03685 setBgImagePath(s);
03686 if (themeClass->getBgImageName(s))
03687 setBgImageName(s);
03688 if (themeClass->getSelBgImagePath(s))
03689 setSelBgImagePath(s);
03690 if (themeClass->getSelBgImageName(s))
03691 setSelBgImageName(s);
03692 if (themeClass->getBgImagePath_p(s))
03693 setBgImagePath_p(s);
03694 if (themeClass->getBgImageName_p(s))
03695 setBgImageName_p(s);
03696 if (themeClass->getSelBgImagePath_p(s))
03697 setSelBgImagePath_p(s);
03698 if (themeClass->getSelBgImageName_p(s))
03699 setSelBgImageName_p(s);
03700 if (themeClass->getBgImagePath_i(s))
03701 setBgImagePath_i(s);
03702 if (themeClass->getBgImageName_i(s))
03703 setBgImageName_i(s);
03704 if (themeClass->getSelBgImagePath_i(s))
03705 setSelBgImagePath_i(s);
03706 if (themeClass->getSelBgImageName_i(s))
03707 setSelBgImageName_i(s);
03708 if (themeClass->getMargin(u))
03709 setMargin(u);
03710 if (themeClass->getFocusable(b))
03711 setFocusable(b);
03712 if (themeClass->getSelectable(b))
03713 setSelectable(b);
03714 if (themeClass->getUpArrow(s))
03715 setUpArrow(s);
03716 if (themeClass->getDownArrow(s))
03717 setDownArrow(s);
03718 if (themeClass->getLeftArrow(s))
03719 setLeftArrow(s);
03720 if (themeClass->getRightArrow(s))
03721 setRightArrow(s);
03722 if (themeClass->getData(s))
03723 setData(s);
03724 if (themeClass->getNavigateUp(s))
03725 setNavigateUp(s);
03726 if (themeClass->getNavigateDown(s))
03727 setNavigateDown(s);
03728 if (themeClass->getNavigateLeft(s))
03729 setNavigateLeft(s);
03730 if (themeClass->getNavigateRight(s))
03731 setNavigateRight(s);
03732 if (themeClass->getVSlider(s))
03733 setVSlider(s);
03734 if (themeClass->getHSlider(s))
03735 setHSlider(s);
03736 if (themeClass->getBlend(u))
03737 setBlend(u);
03738 if (themeClass->getBlendFactor(d))
03739 setBlendFactor(d);
03740 if (themeClass->getScrollOnFocus(b))
03741 setScrollOnFocus(b);
03742 if (themeClass->getClickable(b))
03743 setClickable(b);
03744 if (themeClass->getReturnOnScroll(b))
03745 setReturnOnScroll(b);
03746 if (themeClass->getInputMode(s))
03747 setInputMode(s);
03748 if (themeClass->getJoinedWidget(s))
03749 setJoinedWidget(s);
03750 if (themeClass->getActivated(b))
03751 setActivated(b);
03752 if (themeClass->border.getColor(c))
03753 setBorderColor(c);
03754 if (themeClass->border.getSelColor(c))
03755 setBorderSelColor(c);
03756 if (themeClass->border.getImagePath(s))
03757 setBorderImagePath(s);
03758 if (themeClass->border.isImageNames()) {
03759 string s[8];
03760 themeClass->border.getImageNames(MMSBORDER_IMAGE_NUM_TOP_LEFT, s[0]);
03761 themeClass->border.getImageNames(MMSBORDER_IMAGE_NUM_TOP, s[1]);
03762 themeClass->border.getImageNames(MMSBORDER_IMAGE_NUM_TOP_RIGHT, s[2]);
03763 themeClass->border.getImageNames(MMSBORDER_IMAGE_NUM_RIGHT, s[3]);
03764 themeClass->border.getImageNames(MMSBORDER_IMAGE_NUM_BOTTOM_RIGHT, s[4]);
03765 themeClass->border.getImageNames(MMSBORDER_IMAGE_NUM_BOTTOM, s[5]);
03766 themeClass->border.getImageNames(MMSBORDER_IMAGE_NUM_BOTTOM_LEFT, s[6]);
03767 themeClass->border.getImageNames(MMSBORDER_IMAGE_NUM_LEFT, s[7]);
03768 setBorderImageNames(s[0], s[1], s[2], s[3], s[4], s[5], s[6], s[7]);
03769 }
03770 if (themeClass->border.getSelImagePath(s))
03771 setBorderSelImagePath(s);
03772 if (themeClass->border.isSelImageNames()) {
03773 string s[8];
03774 themeClass->border.getSelImageNames(MMSBORDER_IMAGE_NUM_TOP_LEFT, s[0]);
03775 themeClass->border.getSelImageNames(MMSBORDER_IMAGE_NUM_TOP, s[1]);
03776 themeClass->border.getSelImageNames(MMSBORDER_IMAGE_NUM_TOP_RIGHT, s[2]);
03777 themeClass->border.getSelImageNames(MMSBORDER_IMAGE_NUM_RIGHT, s[3]);
03778 themeClass->border.getSelImageNames(MMSBORDER_IMAGE_NUM_BOTTOM_RIGHT, s[4]);
03779 themeClass->border.getSelImageNames(MMSBORDER_IMAGE_NUM_BOTTOM, s[5]);
03780 themeClass->border.getSelImageNames(MMSBORDER_IMAGE_NUM_BOTTOM_LEFT, s[6]);
03781 themeClass->border.getSelImageNames(MMSBORDER_IMAGE_NUM_LEFT, s[7]);
03782 setBorderSelImageNames(s[0], s[1], s[2], s[3], s[4], s[5], s[6], s[7]);
03783 }
03784 if (themeClass->border.getThickness(u))
03785 setBorderThickness(u);
03786 if (themeClass->border.getMargin(u))
03787 setBorderMargin(u);
03788 if (themeClass->border.getRCorners(b))
03789 setBorderRCorners(b);
03790 }
03791
03792
03793
03794