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/mmsimagewidget.h"
00034 #include "mmsgui/mmsimagewidgetthread.h"
00035 
00036 
00037 
00038 
00039 
00040 MMSImageWidget::MMSImageWidget(MMSWindow *root, string className, MMSTheme *theme) : imageThread(NULL) {
00041     create(root, className, theme);
00042 }
00043 
00044 MMSImageWidget::~MMSImageWidget() {
00045     if (imageThread) {
00046         imageThread->stop();
00047         while(imageThread->isRunning()) {
00048             usleep(1000);
00049         }
00050 
00051         delete imageThread;
00052         imageThread=NULL;
00053     }
00054 }
00055 
00056 bool MMSImageWidget::create(MMSWindow *root, string className, MMSTheme *theme) {
00057     this->type = MMSWIDGETTYPE_IMAGE;
00058     this->className = className;
00059 
00060     
00061     this->da = new MMSWIDGET_DRAWABLE_ATTRIBUTES;
00062     if (theme) this->da->theme = theme; else this->da->theme = globalTheme;
00063     this->imageWidgetClass = this->da->theme->getImageWidgetClass(className);
00064     this->da->baseWidgetClass = &(this->da->theme->imageWidgetClass.widgetClass);
00065     if (this->imageWidgetClass) this->da->widgetClass = &(this->imageWidgetClass->widgetClass); else this->da->widgetClass = NULL;
00066 
00067     
00068     this->imagepath_set = false;
00069     this->selimagepath_set = false;
00070 
00071     this->imagepath_p_set = false;
00072     this->selimagepath_p_set = false;
00073 
00074     this->imagepath_i_set = false;
00075     this->selimagepath_i_set = false;
00076 
00077     this->image = NULL;
00078     image_loaded = false;
00079     image_curr_index = 0;
00080 
00081     this->selimage = NULL;
00082     selimage_loaded = false;
00083     selimage_curr_index = 0;
00084 
00085     this->image_p = NULL;
00086     image_p_loaded = false;
00087     image_p_curr_index = 0;
00088 
00089     this->selimage_p = NULL;
00090     selimage_p_loaded = false;
00091     selimage_p_curr_index = 0;
00092 
00093     this->image_i = NULL;
00094     image_i_loaded = false;
00095     image_i_curr_index = 0;
00096 
00097     this->selimage_i = NULL;
00098     selimage_i_loaded = false;
00099     selimage_i_curr_index = 0;
00100 
00101     if(imageThread) {
00102         imageThread->stop();
00103         while(imageThread->isRunning()) {
00104             usleep(1000);
00105         }
00106         delete imageThread;
00107     }
00108     imageThread = NULL;
00109     this->current_fgset = false;
00110 
00111     
00112     return MMSWidget::create(root, true, false, false, true, true, true, true);
00113 }
00114 
00115 void MMSImageWidget::loadMyImage(string path, string filename, MMSFBSurface **surface, MMSIM_DESC_SUF **surfdesc,
00116                                  unsigned int *index, unsigned int mirror_size, bool gen_taff) {
00117     
00118     if (this->imageThread)
00119         this->imageThread->pause(true);
00120 
00121     
00122     *surface = this->rootwindow->im->getImage(path, filename, surfdesc, mirror_size, gen_taff);
00123     *index = 0;
00124     if (!*surface) {
00125         if (this->imageThread)
00126             this->imageThread->pause(false);
00127         return;
00128     }
00129     if (!*surfdesc) {
00130         if (this->imageThread)
00131             this->imageThread->pause(false);
00132         return;
00133     }
00134 
00135     
00136     if ((*surfdesc)[1].delaytime == MMSIM_DESC_SUF_END) {
00137         if (this->imageThread)
00138             this->imageThread->pause(false);
00139         return;
00140     }
00141 
00142     
00143     if (this->imageThread) {
00144         
00145         this->imageThread->pause(false);
00146     }
00147     else {
00148         
00149         this->imageThread = new MMSImageWidgetThread(this);
00150         this->imageThread->start();
00151     }
00152 }
00153 
00154 MMSWidget *MMSImageWidget::copyWidget() {
00155     
00156     MMSImageWidget *newWidget = new MMSImageWidget(this->rootwindow, className);
00157 
00158     newWidget->className = this->className;
00159     newWidget->imageWidgetClass = this->imageWidgetClass;
00160     newWidget->myImageWidgetClass = this->myImageWidgetClass;
00161 
00162     newWidget->imagepath_set = this->imagepath_set;
00163     newWidget->selimagepath_set = this->selimagepath_set;
00164 
00165     newWidget->imagepath_p_set = this->imagepath_p_set;
00166     newWidget->selimagepath_p_set = this->selimagepath_p_set;
00167 
00168     newWidget->imagepath_i_set = this->imagepath_i_set;
00169     newWidget->selimagepath_i_set = this->selimagepath_i_set;
00170 
00171     newWidget->image_suf = this->image_suf;
00172     newWidget->image_curr_index = this->image_curr_index;
00173     newWidget->selimage_suf = this->selimage_suf;
00174     newWidget->selimage_curr_index = this->selimage_curr_index;
00175 
00176     newWidget->image_p_suf = this->image_p_suf;
00177     newWidget->image_p_curr_index = this->image_p_curr_index;
00178     newWidget->selimage_p_suf = this->selimage_p_suf;
00179     newWidget->selimage_p_curr_index = this->selimage_p_curr_index;
00180 
00181     newWidget->image_i_suf = this->image_i_suf;
00182     newWidget->image_i_curr_index = this->image_i_curr_index;
00183     newWidget->selimage_i_suf = this->selimage_i_suf;
00184     newWidget->selimage_i_curr_index = this->selimage_i_curr_index;
00185 
00186     newWidget->image_loaded = this->image_loaded;
00187     newWidget->image_p_loaded = this->image_p_loaded;
00188     newWidget->image_i_loaded = this->image_i_loaded;
00189     newWidget->selimage_loaded = this->selimage_loaded;
00190     newWidget->selimage_p_loaded = this->selimage_p_loaded;
00191     newWidget->selimage_i_loaded = this->selimage_i_loaded;
00192 
00193     newWidget->imageThread = this->imageThread;
00194 
00195     newWidget->current_fgset = this->current_fgset;
00196     newWidget->current_fgimage = this->current_fgimage;
00197     newWidget->current_fgimage2 = this->current_fgimage2;
00198 
00199     
00200     MMSWidget::copyWidget((MMSWidget*)newWidget);
00201 
00202     
00203     newWidget->image = NULL;
00204     newWidget->selimage = NULL;
00205     newWidget->image_p = NULL;
00206     newWidget->selimage_p = NULL;
00207     newWidget->image_i = NULL;
00208     newWidget->selimage_i = NULL;
00209     if (this->rootwindow) {
00210         bool b;
00211         if (!getImagesOnDemand(b))
00212             b = false;
00213         if ((!b)||(newWidget->isVisible())) {
00214             loadMyImage(newWidget->getImagePath(), newWidget->getImageName(),
00215                         &newWidget->image, &(newWidget->image_suf), &image_curr_index, getMirrorSize(), getGenTaff());
00216             image_loaded = true;
00217             loadMyImage(newWidget->getSelImagePath(), newWidget->getSelImageName(),
00218                         &newWidget->selimage, &(newWidget->selimage_suf), &selimage_curr_index, getMirrorSize(), getGenTaff());
00219             selimage_loaded = true;
00220 
00221             loadMyImage(newWidget->getImagePath_p(), newWidget->getImageName_p(),
00222                         &newWidget->image_p, &(newWidget->image_p_suf), &image_p_curr_index, getMirrorSize(), getGenTaff());
00223             image_p_loaded = true;
00224             loadMyImage(newWidget->getSelImagePath_p(), newWidget->getSelImageName_p(),
00225                         &newWidget->selimage_p, &(newWidget->selimage_p_suf), &selimage_p_curr_index, getMirrorSize(), getGenTaff());
00226             selimage_p_loaded = true;
00227 
00228             loadMyImage(newWidget->getImagePath_i(), newWidget->getImageName_i(),
00229                         &newWidget->image_i, &(newWidget->image_i_suf), &image_i_curr_index, getMirrorSize(), getGenTaff());
00230             image_i_loaded = true;
00231             loadMyImage(newWidget->getSelImagePath_i(), newWidget->getSelImageName_i(),
00232                         &newWidget->selimage_i, &(newWidget->selimage_i_suf), &selimage_i_curr_index, getMirrorSize(), getGenTaff());
00233             selimage_i_loaded = true;
00234         }
00235     }
00236 
00237     return newWidget;
00238 }
00239 
00240 bool MMSImageWidget::init() {
00241     
00242     if (!MMSWidget::init())
00243         return false;
00244 
00245     bool b;
00246     if (!getImagesOnDemand(b))
00247         b = false;
00248 
00249     if ((!b)||(this->isVisible())) {
00250         
00251         if (!image_loaded) {
00252             loadMyImage(getImagePath(), getImageName(), &this->image, &(this->image_suf), &image_curr_index, getMirrorSize(), getGenTaff());
00253             image_loaded = true;
00254         }
00255         if (!selimage_loaded) {
00256             loadMyImage(getSelImagePath(), getSelImageName(), &this->selimage, &(this->selimage_suf), &selimage_curr_index, getMirrorSize(), getGenTaff());
00257             selimage_loaded = true;
00258         }
00259 
00260         if (!image_p_loaded) {
00261             loadMyImage(getImagePath_p(), getImageName_p(), &this->image_p, &(this->image_p_suf), &image_p_curr_index, getMirrorSize(), getGenTaff());
00262             image_p_loaded = true;
00263         }
00264         if (!selimage_p_loaded) {
00265             loadMyImage(getSelImagePath_p(), getSelImageName_p(), &this->selimage_p, &(this->selimage_p_suf), &selimage_p_curr_index, getMirrorSize(), getGenTaff());
00266             selimage_p_loaded = true;
00267         }
00268 
00269         if (!image_i_loaded) {
00270             loadMyImage(getImagePath_i(), getImageName_i(), &this->image_i, &(this->image_i_suf), &image_i_curr_index, getMirrorSize(), getGenTaff());
00271             image_i_loaded = true;
00272         }
00273         if (!selimage_i_loaded) {
00274             loadMyImage(getSelImagePath_i(), getSelImageName_i(), &this->selimage_i, &(this->selimage_i_suf), &selimage_i_curr_index, getMirrorSize(), getGenTaff());
00275             selimage_i_loaded = true;
00276         }
00277     }
00278 
00279     return true;
00280 }
00281 
00282 bool MMSImageWidget::release() {
00283     
00284     if (!MMSWidget::release())
00285         return false;
00286 
00287     
00288     this->rootwindow->im->releaseImage(this->image);
00289     this->image = NULL;
00290     this->image_loaded = false;
00291     this->rootwindow->im->releaseImage(this->selimage);
00292     this->selimage = NULL;
00293     this->selimage_loaded = false;
00294     this->rootwindow->im->releaseImage(this->image_p);
00295     this->image_p = NULL;
00296     this->image_p_loaded = false;
00297     this->rootwindow->im->releaseImage(this->selimage_p);
00298     this->selimage_p = NULL;
00299     this->selimage_p_loaded = false;
00300     this->rootwindow->im->releaseImage(this->image_i);
00301     this->image_i = NULL;
00302     this->image_i_loaded = false;
00303     this->rootwindow->im->releaseImage(this->selimage_i);
00304     this->selimage_i = NULL;
00305     this->selimage_i_loaded = false;
00306 
00307     return true;
00308 }
00309 
00310 void MMSImageWidget::workWithRatio(MMSFBSurface *suf, MMSFBRectangle *surfaceGeom) {
00311     int w, h, dw, dh, ratio;
00312 
00313     if (getUseRatio()) {
00314         
00315         suf->getSize(&w, &h);
00316 
00317         dw = w - surfaceGeom->w;
00318         dh = h - surfaceGeom->h;
00319 
00320         if (dw || dh) {
00321             ratio = (10000 * w) / h;
00322             bool fw = false, fh = false;
00323 
00324             if (getFitWidth())
00325                 fw = true;
00326             else
00327             if (getFitHeight())
00328                 fh = true;
00329 
00330             if (((dw > dh)&&(!fh))||(fw)) {
00331                 
00332                 int t = ((10000 * (surfaceGeom->w+0.0) + 5000) / ratio) + 0.5;
00333 
00334                 
00335                 MMSALIGNMENT alignment = getAlignment();
00336                 if (alignment == MMSALIGNMENT_NOTSET) alignment = MMSALIGNMENT_CENTER;
00337                 switch (alignment) {
00338                     case MMSALIGNMENT_CENTER:
00339                         surfaceGeom->y = (surfaceGeom->h - t) / 2;
00340                         break;
00341                     case MMSALIGNMENT_LEFT:
00342                         surfaceGeom->y = (surfaceGeom->h - t) / 2;
00343                         break;
00344                     case MMSALIGNMENT_RIGHT:
00345                         surfaceGeom->y = (surfaceGeom->h - t) / 2;
00346                         break;
00347                     case MMSALIGNMENT_TOP_CENTER:
00348                         surfaceGeom->y = 0;
00349                         break;
00350                     case MMSALIGNMENT_TOP_LEFT:
00351                         surfaceGeom->y = 0;
00352                         break;
00353                     case MMSALIGNMENT_TOP_RIGHT:
00354                         surfaceGeom->y = 0;
00355                         break;
00356                     case MMSALIGNMENT_BOTTOM_CENTER:
00357                         surfaceGeom->y = surfaceGeom->h - t;
00358                         break;
00359                     case MMSALIGNMENT_BOTTOM_LEFT:
00360                         surfaceGeom->y = surfaceGeom->h - t;
00361                         break;
00362                     case MMSALIGNMENT_BOTTOM_RIGHT:
00363                         surfaceGeom->y = surfaceGeom->h - t;
00364                         break;
00365                     default:
00366                         surfaceGeom->y = 0;
00367                         break;
00368                 }
00369 
00370                 surfaceGeom->h = t;
00371             }
00372             else {
00373                 
00374                 int t = (((surfaceGeom->h+0.0) * ratio + 5000) / 10000) + 0.5;
00375 
00376                 
00377                 MMSALIGNMENT alignment = getAlignment();
00378                 if (alignment == MMSALIGNMENT_NOTSET) alignment = MMSALIGNMENT_CENTER;
00379                 switch (alignment) {
00380                     case MMSALIGNMENT_CENTER:
00381                         surfaceGeom->x = (surfaceGeom->w - t) / 2;
00382                         break;
00383                     case MMSALIGNMENT_LEFT:
00384                         surfaceGeom->x = 0;
00385                         break;
00386                     case MMSALIGNMENT_RIGHT:
00387                         surfaceGeom->x = surfaceGeom->w - t;
00388                         break;
00389                     case MMSALIGNMENT_TOP_CENTER:
00390                         surfaceGeom->x = (surfaceGeom->w - t) / 2;
00391                         break;
00392                     case MMSALIGNMENT_TOP_LEFT:
00393                         surfaceGeom->x = 0;
00394                         break;
00395                     case MMSALIGNMENT_TOP_RIGHT:
00396                         surfaceGeom->x = surfaceGeom->w - t;
00397                         break;
00398                     case MMSALIGNMENT_BOTTOM_CENTER:
00399                         surfaceGeom->x = (surfaceGeom->w - t) / 2;
00400                         break;
00401                     case MMSALIGNMENT_BOTTOM_LEFT:
00402                         surfaceGeom->x = 0;
00403                         break;
00404                     case MMSALIGNMENT_BOTTOM_RIGHT:
00405                         surfaceGeom->x = surfaceGeom->w - t;
00406                         break;
00407                     default:
00408                         surfaceGeom->x = 0;
00409                         break;
00410                 }
00411 
00412                 surfaceGeom->w = t;
00413             }
00414         }
00415     }
00416 }
00417 
00418 void MMSImageWidget::getForeground(MMSFBSurface **image, MMSFBSurface **image2) {
00419     *image = NULL;
00420     *image2= NULL;
00421 
00422     if (isActivated()) {
00423 
00424         if (isSelected()) {
00425             *image = (this->selimage)?this->selimage_suf[selimage_curr_index].surface:NULL;
00426             *image2= (this->image)?this->image_suf[image_curr_index].surface:NULL;
00427         }
00428         else {
00429             *image = (this->image)?this->image_suf[image_curr_index].surface:NULL;
00430             *image2= (this->selimage)?this->selimage_suf[selimage_curr_index].surface:NULL;
00431         }
00432         if (isPressed()) {
00433             if (isSelected()) {
00434                 if (this->selimage_p)
00435                     *image = this->selimage_p_suf[selimage_p_curr_index].surface;
00436                 if (this->image_p)
00437                     *image2= this->image_p_suf[image_p_curr_index].surface;
00438             }
00439             else {
00440                 if (this->image_p)
00441                     *image = this->image_p_suf[image_p_curr_index].surface;
00442                 if (this->selimage_p)
00443                     *image2= this->selimage_p_suf[selimage_p_curr_index].surface;
00444             }
00445         }
00446     }
00447     else {
00448         if (isSelected()) {
00449             *image = (this->selimage_i)?this->selimage_i_suf[selimage_i_curr_index].surface:NULL;
00450             *image2= (this->image_i)?this->image_i_suf[image_i_curr_index].surface:NULL;
00451         }
00452         else {
00453             *image = (this->image_i)?this->image_i_suf[image_i_curr_index].surface:NULL;
00454             *image2= (this->selimage_i)?this->selimage_i_suf[selimage_i_curr_index].surface:NULL;
00455         }
00456     }
00457 }
00458 
00459 bool MMSImageWidget::enableRefresh(bool enable) {
00460     if (!MMSWidget::enableRefresh(enable)) return false;
00461 
00462     
00463     this->current_fgset = false;
00464 
00465     return true;
00466 }
00467 
00468 bool MMSImageWidget::checkRefreshStatus() {
00469     if (MMSWidget::checkRefreshStatus()) return true;
00470 
00471     if (this->current_fgset) {
00472         
00473         MMSFBSurface *image, *image2;
00474         getForeground(&image, &image2);
00475 
00476         if (image == this->current_fgimage && image2 == this->current_fgimage2) {
00477             
00478             return false;
00479         }
00480     }
00481 
00482     
00483     enableRefresh();
00484 
00485     return true;
00486 }
00487 
00488 
00489 bool MMSImageWidget::draw(bool *backgroundFilled) {
00490     bool myBackgroundFilled = false;
00491 
00492     if(!surface)
00493         return false;
00494 
00495     if (backgroundFilled) {
00496         if (this->has_own_surface)
00497             *backgroundFilled = false;
00498     }
00499     else
00500         backgroundFilled = &myBackgroundFilled;
00501 
00502     
00503     this->surface->lock();
00504 
00505     
00506     if (MMSWidget::draw(backgroundFilled)) {
00507         
00508         MMSFBRectangle surfaceGeom;
00509 
00510         
00511         unsigned int blend;
00512         getBlend(blend);
00513 
00514         
00515         MMSFBSurface *suf, *suf2;
00516         getForeground(&suf, &suf2);
00517         this->current_fgimage   = suf;
00518         this->current_fgimage2  = suf2;
00519         this->current_fgset     = true;
00520 
00521         if (!blend) {
00522             
00523             if (suf) {
00524                 
00525                 this->surface->setBlittingFlagsByBrightnessAlphaAndOpacity(this->brightness, 255, opacity);
00526 
00527                 
00528                 surfaceGeom = getSurfaceGeometry();
00529 
00530                 suf->lock();
00531 
00532                 
00533                 workWithRatio(suf, &surfaceGeom);
00534 
00535                 
00536                 this->surface->stretchBlit(suf, NULL, &surfaceGeom);
00537 
00538                 suf->unlock();
00539             }
00540         }
00541         else {
00542             
00543             if (blend > 255)
00544                 blend=255;
00545 
00546             
00547             if (suf) {
00548                 
00549                 double blendfactor;
00550                 getBlendFactor(blendfactor);
00551                 unsigned int a = (unsigned int)(255 - (blendfactor * (double)blend));
00552                 if (a > 255) a = 255;
00553                 this->surface->setBlittingFlagsByBrightnessAlphaAndOpacity(this->brightness, a, opacity);
00554 
00555                 
00556                 surfaceGeom = getSurfaceGeometry();
00557 
00558                 suf->lock();
00559 
00560                 
00561                 workWithRatio(suf, &surfaceGeom);
00562 
00563                 
00564                 this->surface->stretchBlit(suf, NULL, &surfaceGeom);
00565 
00566                 suf->unlock();
00567             }
00568 
00569             
00570             if (suf2) {
00571                 
00572                 this->surface->setBlittingFlagsByBrightnessAlphaAndOpacity(this->brightness, blend, opacity);
00573 
00574                 
00575                 surfaceGeom = getSurfaceGeometry();
00576 
00577                 suf2->lock();
00578 
00579                 
00580                 workWithRatio(suf2, &surfaceGeom);
00581 
00582                 
00583                 this->surface->stretchBlit(suf2, NULL, &surfaceGeom);
00584 
00585                 suf2->unlock();
00586             }
00587         }
00588 
00589         
00590         updateWindowSurfaceWithSurface(!*backgroundFilled);
00591     }
00592 
00593     
00594     this->surface->unlock();
00595 
00596     
00597     return MMSWidget::drawDebug();
00598 }
00599 
00600 
00601 
00602 void MMSImageWidget::setVisible(bool visible, bool refresh) {
00603     bool b;
00604 
00605     if (getImagesOnDemand(b))
00606         if (b) {
00607             
00608             if (visible) {
00609                 
00610                 if (!this->isVisible()) {
00611                     if (!image_loaded) {
00612                         loadMyImage(getImagePath(), getImageName(), &this->image, &(this->image_suf), &image_curr_index, getMirrorSize(), getGenTaff());
00613                         image_loaded = true;
00614                     }
00615                     if (!selimage_loaded) {
00616                         loadMyImage(getSelImagePath(), getSelImageName(), &this->selimage, &(this->selimage_suf), &selimage_curr_index, getMirrorSize(), getGenTaff());
00617                         selimage_loaded = true;
00618                     }
00619                     if (!image_p_loaded) {
00620                         loadMyImage(getImagePath_p(), getImageName_p(), &this->image_p, &(this->image_p_suf), &image_p_curr_index, getMirrorSize(), getGenTaff());
00621                         image_p_loaded = true;
00622                     }
00623                     if (!selimage_p_loaded) {
00624                         loadMyImage(getSelImagePath_p(), getSelImageName_p(), &this->selimage_p, &(this->selimage_p_suf), &selimage_p_curr_index, getMirrorSize(), getGenTaff());
00625                         selimage_p_loaded = true;
00626                     }
00627                     if (!image_i_loaded) {
00628                         loadMyImage(getImagePath_i(), getImageName_i(), &this->image_i, &(this->image_i_suf), &image_i_curr_index, getMirrorSize(), getGenTaff());
00629                         image_i_loaded = true;
00630                     }
00631                     if (!selimage_i_loaded) {
00632                         loadMyImage(getSelImagePath_i(), getSelImageName_i(), &this->selimage_i, &(this->selimage_i_suf), &selimage_i_curr_index, getMirrorSize(), getGenTaff());
00633                         selimage_i_loaded = true;
00634                     }
00635                 }
00636             }
00637             else {
00638                 
00639                 if (this->isVisible()) {
00640                     if (image_loaded) {
00641                         this->rootwindow->im->releaseImage(this->image);
00642                         this->image = NULL;
00643                         image_loaded = false;
00644                     }
00645                     if (selimage_loaded) {
00646                         this->rootwindow->im->releaseImage(this->selimage);
00647                         this->selimage = NULL;
00648                         selimage_loaded = false;
00649                     }
00650                     if (image_p_loaded) {
00651                         this->rootwindow->im->releaseImage(this->image_p);
00652                         this->image_p = NULL;
00653                         image_p_loaded = false;
00654                     }
00655                     if (selimage_p_loaded) {
00656                         this->rootwindow->im->releaseImage(this->selimage_p);
00657                         this->selimage_p = NULL;
00658                         selimage_p_loaded = false;
00659                     }
00660                     if (image_i_loaded) {
00661                         this->rootwindow->im->releaseImage(this->image_i);
00662                         this->image_i = NULL;
00663                         image_i_loaded = false;
00664                     }
00665                     if (selimage_i_loaded) {
00666                         this->rootwindow->im->releaseImage(this->selimage_i);
00667                         this->selimage_i = NULL;
00668                         selimage_i_loaded = false;
00669                     }
00670                 }
00671             }
00672         }
00673 
00674     
00675     MMSWidget::setVisible(visible, refresh);
00676 }
00677 
00678 
00679 
00680 
00681 
00682 #define GETIMAGE(x) \
00683     if (this->myImageWidgetClass.is##x()) return myImageWidgetClass.get##x(); \
00684     else if ((imageWidgetClass)&&(imageWidgetClass->is##x())) return imageWidgetClass->get##x(); \
00685     else return this->da->theme->imageWidgetClass.get##x();
00686 
00687 string MMSImageWidget::getImagePath() {
00688     GETIMAGE(ImagePath);
00689 }
00690 
00691 string MMSImageWidget::getImageName() {
00692     GETIMAGE(ImageName);
00693 }
00694 
00695 string MMSImageWidget::getSelImagePath() {
00696     GETIMAGE(SelImagePath);
00697 }
00698 
00699 string MMSImageWidget::getSelImageName() {
00700     GETIMAGE(SelImageName);
00701 }
00702 
00703 string MMSImageWidget::getImagePath_p() {
00704     GETIMAGE(ImagePath_p);
00705 }
00706 
00707 string MMSImageWidget::getImageName_p() {
00708     GETIMAGE(ImageName_p);
00709 }
00710 
00711 string MMSImageWidget::getSelImagePath_p() {
00712     GETIMAGE(SelImagePath_p);
00713 }
00714 
00715 string MMSImageWidget::getSelImageName_p() {
00716     GETIMAGE(SelImageName_p);
00717 }
00718 
00719 string MMSImageWidget::getImagePath_i() {
00720     GETIMAGE(ImagePath_i);
00721 }
00722 
00723 string MMSImageWidget::getImageName_i() {
00724     GETIMAGE(ImageName_i);
00725 }
00726 
00727 string MMSImageWidget::getSelImagePath_i() {
00728     GETIMAGE(SelImagePath_i);
00729 }
00730 
00731 string MMSImageWidget::getSelImageName_i() {
00732     GETIMAGE(SelImageName_i);
00733 }
00734 
00735 bool MMSImageWidget::getUseRatio() {
00736     GETIMAGE(UseRatio);
00737 }
00738 
00739 bool MMSImageWidget::getFitWidth() {
00740     GETIMAGE(FitWidth);
00741 }
00742 
00743 bool MMSImageWidget::getFitHeight() {
00744     GETIMAGE(FitHeight);
00745 }
00746 
00747 MMSALIGNMENT MMSImageWidget::getAlignment() {
00748     GETIMAGE(Alignment);
00749 }
00750 
00751 unsigned int MMSImageWidget::getMirrorSize() {
00752     GETIMAGE(MirrorSize);
00753 }
00754 
00755 bool MMSImageWidget::getGenTaff() {
00756     GETIMAGE(GenTaff);
00757 }
00758 
00759 
00760 
00761 
00762 
00763 
00764 void MMSImageWidget::setImagePath(string imagepath, bool load, bool refresh) {
00765     myImageWidgetClass.setImagePath(imagepath);
00766     this->imagepath_set = true;
00767     if (load)
00768         if (this->rootwindow) {
00769             
00770             enableRefresh((this->image == this->current_fgimage || this->image == this->current_fgimage2));
00771 
00772             this->rootwindow->im->releaseImage(this->image);
00773             this->image = NULL;
00774             image_loaded = false;
00775             bool b;
00776             if (!getImagesOnDemand(b))
00777                 b = false;
00778             if ((!b)||(this->isVisible())) {
00779                 loadMyImage(getImagePath(), getImageName(), &this->image, &(this->image_suf), &image_curr_index, getMirrorSize(), getGenTaff());
00780                 image_loaded = true;
00781             }
00782         }
00783 
00784     this->refresh(refresh);
00785 }
00786 
00787 void MMSImageWidget::setImageName(string imagename, bool load, bool refresh) {
00788     if (!this->imagepath_set) myImageWidgetClass.unsetImagePath();
00789     myImageWidgetClass.setImageName(imagename);
00790     if (load)
00791         if (this->rootwindow) {
00792             
00793             enableRefresh((this->image == this->current_fgimage || this->image == this->current_fgimage2));
00794 
00795             this->rootwindow->im->releaseImage(this->image);
00796             this->image = NULL;
00797             image_loaded = false;
00798             bool b;
00799             if (!getImagesOnDemand(b))
00800                 b = false;
00801             if ((!b)||(this->isVisible())) {
00802                 loadMyImage(getImagePath(), getImageName(), &this->image, &(this->image_suf), &image_curr_index, getMirrorSize(), getGenTaff());
00803                 image_loaded = true;
00804             }
00805         }
00806 
00807     this->refresh(refresh);
00808 }
00809 
00810 void MMSImageWidget::setImage(string imagepath, string imagename, bool load, bool refresh) {
00811     myImageWidgetClass.setImagePath(imagepath);
00812     myImageWidgetClass.setImageName(imagename);
00813     if (load)
00814         if (this->rootwindow) {
00815             
00816             enableRefresh((this->image == this->current_fgimage || this->image == this->current_fgimage2));
00817 
00818             this->rootwindow->im->releaseImage(this->image);
00819             this->image = NULL;
00820             image_loaded = false;
00821             bool b;
00822             if (!getImagesOnDemand(b))
00823                 b = false;
00824             if ((!b)||(this->isVisible())) {
00825                 loadMyImage(getImagePath(), getImageName(), &this->image, &(this->image_suf), &image_curr_index, getMirrorSize(), getGenTaff());
00826                 image_loaded = true;
00827             }
00828         }
00829 
00830     this->refresh(refresh);
00831 }
00832 
00833 void MMSImageWidget::setSelImagePath(string selimagepath, bool load, bool refresh) {
00834     myImageWidgetClass.setSelImagePath(selimagepath);
00835     this->selimagepath_set = true;
00836     if (load)
00837         if (this->rootwindow) {
00838             
00839             enableRefresh((this->selimage == this->current_fgimage || this->selimage == this->current_fgimage2));
00840 
00841             this->rootwindow->im->releaseImage(this->selimage);
00842             this->selimage = NULL;
00843             selimage_loaded = false;
00844             bool b;
00845             if (!getImagesOnDemand(b))
00846                 b = false;
00847             if ((!b)||(this->isVisible())) {
00848                 loadMyImage(getSelImagePath(), getSelImageName(), &this->selimage, &(this->selimage_suf), &selimage_curr_index, getMirrorSize(), getGenTaff());
00849                 selimage_loaded = true;
00850             }
00851         }
00852 
00853     this->refresh(refresh);
00854 }
00855 
00856 void MMSImageWidget::setSelImageName(string selimagename, bool load, bool refresh) {
00857     if (!this->selimagepath_set) myImageWidgetClass.unsetSelImagePath();
00858     myImageWidgetClass.setSelImageName(selimagename);
00859     if (load)
00860         if (this->rootwindow) {
00861             
00862             enableRefresh((this->selimage == this->current_fgimage || this->selimage == this->current_fgimage2));
00863 
00864             this->rootwindow->im->releaseImage(this->selimage);
00865             this->selimage = NULL;
00866             selimage_loaded = false;
00867             bool b;
00868             if (!getImagesOnDemand(b))
00869                 b = false;
00870             if ((!b)||(this->isVisible())) {
00871                 loadMyImage(getSelImagePath(), getSelImageName(), &this->selimage, &(this->selimage_suf), &selimage_curr_index, getMirrorSize(), getGenTaff());
00872                 selimage_loaded = true;
00873             }
00874         }
00875 
00876     this->refresh(refresh);
00877 }
00878 
00879 void MMSImageWidget::setSelImage(string selimagepath, string selimagename, bool load, bool refresh) {
00880     myImageWidgetClass.setSelImagePath(selimagepath);
00881     myImageWidgetClass.setSelImageName(selimagename);
00882     if (load)
00883         if (this->rootwindow) {
00884             
00885             enableRefresh((this->selimage == this->current_fgimage || this->selimage == this->current_fgimage2));
00886 
00887             this->rootwindow->im->releaseImage(this->selimage);
00888             this->selimage = NULL;
00889             selimage_loaded = false;
00890             bool b;
00891             if (!getImagesOnDemand(b))
00892                 b = false;
00893             if ((!b)||(this->isVisible())) {
00894                 loadMyImage(getSelImagePath(), getSelImageName(), &this->selimage, &(this->selimage_suf), &selimage_curr_index, getMirrorSize(), getGenTaff());
00895                 selimage_loaded = true;
00896             }
00897         }
00898 
00899     this->refresh(refresh);
00900 }
00901 
00902 
00903 
00904 void MMSImageWidget::setImagePath_p(string imagepath_p, bool load, bool refresh) {
00905     myImageWidgetClass.setImagePath_p(imagepath_p);
00906     this->imagepath_p_set = true;
00907     if (load)
00908         if (this->rootwindow) {
00909             
00910             enableRefresh((this->image_p == this->current_fgimage || this->image_p == this->current_fgimage2));
00911 
00912             this->rootwindow->im->releaseImage(this->image_p);
00913             this->image_p = NULL;
00914             image_p_loaded = false;
00915             bool b;
00916             if (!getImagesOnDemand(b))
00917                 b = false;
00918             if ((!b)||(this->isVisible())) {
00919                 loadMyImage(getImagePath_p(), getImageName_p(), &this->image_p, &(this->image_p_suf), &image_p_curr_index, getMirrorSize(), getGenTaff());
00920                 image_p_loaded = true;
00921             }
00922         }
00923 
00924     this->refresh(refresh);
00925 }
00926 
00927 void MMSImageWidget::setImageName_p(string imagename_p, bool load, bool refresh) {
00928     if (!this->imagepath_p_set) myImageWidgetClass.unsetImagePath_p();
00929     myImageWidgetClass.setImageName_p(imagename_p);
00930     if (load)
00931         if (this->rootwindow) {
00932             
00933             enableRefresh((this->image_p == this->current_fgimage || this->image_p == this->current_fgimage2));
00934 
00935             this->rootwindow->im->releaseImage(this->image_p);
00936             this->image_p = NULL;
00937             image_p_loaded = false;
00938             bool b;
00939             if (!getImagesOnDemand(b))
00940                 b = false;
00941             if ((!b)||(this->isVisible())) {
00942                 loadMyImage(getImagePath_p(), getImageName_p(), &this->image_p, &(this->image_p_suf), &image_p_curr_index, getMirrorSize(), getGenTaff());
00943                 image_p_loaded = true;
00944             }
00945         }
00946 
00947     this->refresh(refresh);
00948 }
00949 
00950 void MMSImageWidget::setImage_p(string imagepath_p, string imagename_p, bool load, bool refresh) {
00951     myImageWidgetClass.setImagePath_p(imagepath_p);
00952     myImageWidgetClass.setImageName_p(imagename_p);
00953     if (load)
00954         if (this->rootwindow) {
00955             
00956             enableRefresh((this->image_p == this->current_fgimage || this->image_p == this->current_fgimage2));
00957 
00958             this->rootwindow->im->releaseImage(this->image_p);
00959             this->image_p = NULL;
00960             image_p_loaded = false;
00961             bool b;
00962             if (!getImagesOnDemand(b))
00963                 b = false;
00964             if ((!b)||(this->isVisible())) {
00965                 loadMyImage(getImagePath_p(), getImageName_p(), &this->image_p, &(this->image_p_suf), &image_p_curr_index, getMirrorSize(), getGenTaff());
00966                 image_p_loaded = true;
00967             }
00968         }
00969 
00970     this->refresh(refresh);
00971 }
00972 
00973 void MMSImageWidget::setSelImagePath_p(string selimagepath_p, bool load, bool refresh) {
00974     myImageWidgetClass.setSelImagePath_p(selimagepath_p);
00975     this->selimagepath_p_set = true;
00976     if (load)
00977         if (this->rootwindow) {
00978             
00979             enableRefresh((this->selimage_p == this->current_fgimage || this->selimage_p == this->current_fgimage2));
00980 
00981             this->rootwindow->im->releaseImage(this->selimage_p);
00982             this->selimage_p = NULL;
00983             selimage_p_loaded = false;
00984             bool b;
00985             if (!getImagesOnDemand(b))
00986                 b = false;
00987             if ((!b)||(this->isVisible())) {
00988                 loadMyImage(getSelImagePath_p(), getSelImageName_p(), &this->selimage_p, &(this->selimage_p_suf), &selimage_p_curr_index, getMirrorSize(), getGenTaff());
00989                 selimage_p_loaded = true;
00990             }
00991         }
00992 
00993     this->refresh(refresh);
00994 }
00995 
00996 void MMSImageWidget::setSelImageName_p(string selimagename_p, bool load, bool refresh) {
00997     if (!this->selimagepath_p_set) myImageWidgetClass.unsetSelImagePath_p();
00998     myImageWidgetClass.setSelImageName_p(selimagename_p);
00999     if (load)
01000         if (this->rootwindow) {
01001             
01002             enableRefresh((this->selimage_p == this->current_fgimage || this->selimage_p == this->current_fgimage2));
01003 
01004             this->rootwindow->im->releaseImage(this->selimage_p);
01005             this->selimage_p = NULL;
01006             selimage_p_loaded = false;
01007             bool b;
01008             if (!getImagesOnDemand(b))
01009                 b = false;
01010             if ((!b)||(this->isVisible())) {
01011                 loadMyImage(getSelImagePath_p(), getSelImageName_p(), &this->selimage_p, &(this->selimage_p_suf), &selimage_p_curr_index, getMirrorSize(), getGenTaff());
01012                 selimage_p_loaded = true;
01013             }
01014         }
01015 
01016     this->refresh(refresh);
01017 }
01018 
01019 void MMSImageWidget::setSelImage_p(string selimagepath_p, string selimagename_p, bool load, bool refresh) {
01020     myImageWidgetClass.setSelImagePath_p(selimagepath_p);
01021     myImageWidgetClass.setSelImageName_p(selimagename_p);
01022     if (load)
01023         if (this->rootwindow) {
01024             
01025             enableRefresh((this->selimage_p == this->current_fgimage || this->selimage_p == this->current_fgimage2));
01026 
01027             this->rootwindow->im->releaseImage(this->selimage_p);
01028             this->selimage_p = NULL;
01029             selimage_p_loaded = false;
01030             bool b;
01031             if (!getImagesOnDemand(b))
01032                 b = false;
01033             if ((!b)||(this->isVisible())) {
01034                 loadMyImage(getSelImagePath_p(), getSelImageName_p(), &this->selimage_p, &(this->selimage_p_suf), &selimage_p_curr_index, getMirrorSize(), getGenTaff());
01035                 selimage_p_loaded = true;
01036             }
01037         }
01038 
01039     this->refresh(refresh);
01040 }
01041 
01042 
01043 
01044 void MMSImageWidget::setImagePath_i(string imagepath_i, bool load, bool refresh) {
01045     myImageWidgetClass.setImagePath_i(imagepath_i);
01046     this->imagepath_i_set = true;
01047     if (load)
01048         if (this->rootwindow) {
01049             
01050             enableRefresh((this->image_i == this->current_fgimage || this->image_i == this->current_fgimage2));
01051 
01052             this->rootwindow->im->releaseImage(this->image_i);
01053             this->image_i = NULL;
01054             image_i_loaded = false;
01055             bool b;
01056             if (!getImagesOnDemand(b))
01057                 b = false;
01058             if ((!b)||(this->isVisible())) {
01059                 loadMyImage(getImagePath_i(), getImageName_i(), &this->image_i, &(this->image_i_suf), &image_i_curr_index, getMirrorSize(), getGenTaff());
01060                 image_i_loaded = true;
01061             }
01062         }
01063 
01064     this->refresh(refresh);
01065 }
01066 
01067 void MMSImageWidget::setImageName_i(string imagename_i, bool load, bool refresh) {
01068     if (!this->imagepath_i_set) myImageWidgetClass.unsetImagePath_i();
01069     myImageWidgetClass.setImageName_i(imagename_i);
01070     if (load)
01071         if (this->rootwindow) {
01072             
01073             enableRefresh((this->image_i == this->current_fgimage || this->image_i == this->current_fgimage2));
01074 
01075             this->rootwindow->im->releaseImage(this->image_i);
01076             this->image_i = NULL;
01077             image_i_loaded = false;
01078             bool b;
01079             if (!getImagesOnDemand(b))
01080                 b = false;
01081             if ((!b)||(this->isVisible())) {
01082                 loadMyImage(getImagePath_i(), getImageName_i(), &this->image_i, &(this->image_i_suf), &image_i_curr_index, getMirrorSize(), getGenTaff());
01083                 image_i_loaded = true;
01084             }
01085         }
01086 
01087     this->refresh(refresh);
01088 }
01089 
01090 void MMSImageWidget::setImage_i(string imagepath_i, string imagename_i, bool load, bool refresh) {
01091     myImageWidgetClass.setImagePath_i(imagepath_i);
01092     myImageWidgetClass.setImageName_i(imagename_i);
01093     if (load)
01094         if (this->rootwindow) {
01095             
01096             enableRefresh((this->image_i == this->current_fgimage || this->image_i == this->current_fgimage2));
01097 
01098             this->rootwindow->im->releaseImage(this->image_i);
01099             this->image_i = NULL;
01100             image_i_loaded = false;
01101             bool b;
01102             if (!getImagesOnDemand(b))
01103                 b = false;
01104             if ((!b)||(this->isVisible())) {
01105                 loadMyImage(getImagePath_i(), getImageName_i(), &this->image_i, &(this->image_i_suf), &image_i_curr_index, getMirrorSize(), getGenTaff());
01106                 image_i_loaded = true;
01107             }
01108         }
01109 
01110     this->refresh(refresh);
01111 }
01112 
01113 void MMSImageWidget::setSelImagePath_i(string selimagepath_i, bool load, bool refresh) {
01114     myImageWidgetClass.setSelImagePath_i(selimagepath_i);
01115     this->selimagepath_i_set = true;
01116     if (load)
01117         if (this->rootwindow) {
01118             
01119             enableRefresh((this->selimage_i == this->current_fgimage || this->selimage_i == this->current_fgimage2));
01120 
01121             this->rootwindow->im->releaseImage(this->selimage_i);
01122             this->selimage_i = NULL;
01123             selimage_i_loaded = false;
01124             bool b;
01125             if (!getImagesOnDemand(b))
01126                 b = false;
01127             if ((!b)||(this->isVisible())) {
01128                 loadMyImage(getSelImagePath_i(), getSelImageName_i(), &this->selimage_i, &(this->selimage_i_suf), &selimage_i_curr_index, getMirrorSize(), getGenTaff());
01129                 selimage_i_loaded = true;
01130             }
01131         }
01132 
01133     this->refresh(refresh);
01134 }
01135 
01136 void MMSImageWidget::setSelImageName_i(string selimagename_i, bool load, bool refresh) {
01137     if (!this->selimagepath_i_set) myImageWidgetClass.unsetSelImagePath_i();
01138     myImageWidgetClass.setSelImageName_i(selimagename_i);
01139     if (load)
01140         if (this->rootwindow) {
01141             
01142             enableRefresh((this->selimage_i == this->current_fgimage || this->selimage_i == this->current_fgimage2));
01143 
01144             this->rootwindow->im->releaseImage(this->selimage_i);
01145             this->selimage_i = NULL;
01146             selimage_i_loaded = false;
01147             bool b;
01148             if (!getImagesOnDemand(b))
01149                 b = false;
01150             if ((!b)||(this->isVisible())) {
01151                 loadMyImage(getSelImagePath_i(), getSelImageName_i(), &this->selimage_i, &(this->selimage_i_suf), &selimage_i_curr_index, getMirrorSize(), getGenTaff());
01152                 selimage_i_loaded = true;
01153             }
01154         }
01155 
01156     this->refresh(refresh);
01157 }
01158 
01159 void MMSImageWidget::setSelImage_i(string selimagepath_i, string selimagename_i, bool load, bool refresh) {
01160     myImageWidgetClass.setSelImagePath_i(selimagepath_i);
01161     myImageWidgetClass.setSelImageName_i(selimagename_i);
01162     if (load)
01163         if (this->rootwindow) {
01164             
01165             enableRefresh((this->selimage_i == this->current_fgimage || this->selimage_i == this->current_fgimage2));
01166 
01167             this->rootwindow->im->releaseImage(this->selimage_i);
01168             this->selimage_i = NULL;
01169             selimage_i_loaded = false;
01170             bool b;
01171             if (!getImagesOnDemand(b))
01172                 b = false;
01173             if ((!b)||(this->isVisible())) {
01174                 loadMyImage(getSelImagePath_i(), getSelImageName_i(), &this->selimage_i, &(this->selimage_i_suf), &selimage_i_curr_index, getMirrorSize(), getGenTaff());
01175                 selimage_i_loaded = true;
01176             }
01177         }
01178 
01179     this->refresh(refresh);
01180 }
01181 
01182 void MMSImageWidget::setUseRatio(bool useratio, bool refresh) {
01183     myImageWidgetClass.setUseRatio(useratio);
01184 
01185     
01186     enableRefresh();
01187 
01188     this->refresh(refresh);
01189 }
01190 
01191 void MMSImageWidget::setFitWidth(bool fitwidth, bool refresh) {
01192     myImageWidgetClass.setFitWidth(fitwidth);
01193 
01194     
01195     enableRefresh();
01196 
01197     this->refresh(refresh);
01198 }
01199 
01200 void MMSImageWidget::setFitHeight(bool fitheight, bool refresh) {
01201     myImageWidgetClass.setFitHeight(fitheight);
01202 
01203     
01204     enableRefresh();
01205 
01206     this->refresh(refresh);
01207 }
01208 
01209 void MMSImageWidget::setAlignment(MMSALIGNMENT alignment, bool refresh) {
01210     myImageWidgetClass.setAlignment(alignment);
01211 
01212     
01213     enableRefresh();
01214 
01215     this->refresh(refresh);
01216 }
01217 
01218 void MMSImageWidget::setMirrorSize(unsigned int mirrorsize, bool refresh) {
01219     myImageWidgetClass.setMirrorSize(mirrorsize);
01220 
01221     
01222     enableRefresh();
01223 
01224     this->refresh(refresh);
01225 }
01226 
01227 void MMSImageWidget::setGenTaff(bool gentaff, bool refresh) {
01228     myImageWidgetClass.setGenTaff(gentaff);
01229 
01230     
01231     enableRefresh();
01232 
01233     this->refresh(refresh);
01234 }
01235 
01236 void MMSImageWidget::updateFromThemeClass(MMSImageWidgetClass *themeClass) {
01237     if (themeClass->isImagePath())
01238         setImagePath(themeClass->getImagePath());
01239     if (themeClass->isImageName())
01240         setImageName(themeClass->getImageName());
01241     if (themeClass->isSelImagePath())
01242         setSelImagePath(themeClass->getSelImagePath());
01243     if (themeClass->isSelImageName())
01244         setSelImageName(themeClass->getSelImageName());
01245     if (themeClass->isImagePath_p())
01246         setImagePath_p(themeClass->getImagePath_p());
01247     if (themeClass->isImageName_p())
01248         setImageName_p(themeClass->getImageName_p());
01249     if (themeClass->isSelImagePath_p())
01250         setSelImagePath_p(themeClass->getSelImagePath_p());
01251     if (themeClass->isSelImageName_p())
01252         setSelImageName_p(themeClass->getSelImageName_p());
01253     if (themeClass->isImagePath_i())
01254         setImagePath_i(themeClass->getImagePath_i());
01255     if (themeClass->isImageName_i())
01256         setImageName_i(themeClass->getImageName_i());
01257     if (themeClass->isSelImagePath_i())
01258         setSelImagePath_i(themeClass->getSelImagePath_i());
01259     if (themeClass->isSelImageName_i())
01260         setSelImageName_i(themeClass->getSelImageName_i());
01261     if (themeClass->isUseRatio())
01262         setUseRatio(themeClass->getUseRatio());
01263     if (themeClass->isFitWidth())
01264         setFitWidth(themeClass->getFitWidth());
01265     if (themeClass->isFitHeight())
01266         setFitHeight(themeClass->getFitHeight());
01267     if (themeClass->isAlignment())
01268         setAlignment(themeClass->getAlignment());
01269     if (themeClass->isMirrorSize())
01270         setMirrorSize(themeClass->getMirrorSize());
01271     if (themeClass->isGenTaff())
01272         setGenTaff(themeClass->getGenTaff());
01273 
01274     MMSWidget::updateFromThemeClass(&(themeClass->widgetClass));
01275 }
01276 
01277 
01278 
01279