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/fb/mmsfbwindow.h"
00034 #include "mmsgui/fb/mmsfbwindowmanager.h"
00035 
00036 
00037 
00038 
00039 #ifdef USE_DFB_WINMAN
00040 
00041 #define INITCHECK  if(!this->dfbwindow){MMSFB_SetError(0,"not initialized");return false;}
00042 
00043 MMSFBWindow::MMSFBWindow(IDirectFBWindow *dfbwindow, int x, int y) {
00044     
00045     this->dfbwindow = dfbwindow;
00046     this->surface = NULL;
00047 
00048     
00049     if (this->dfbwindow) {
00050         getConfiguration();
00051         this->dfbwindow->SetOpacity(this->dfbwindow, 0);
00052         this->config.posx = x;
00053         this->config.posy = y;
00054         this->config.opacity = 255;
00055         this->config.shown = false;
00056     }
00057 }
00058 
00059 MMSFBWindow::~MMSFBWindow() {
00060     if (this->dfbwindow)
00061         this->dfbwindow->Release(this->dfbwindow);
00062 }
00063 
00064 bool MMSFBWindow::getSurface(MMSFBSurface **surface) {
00065     DFBResult           dfbres;
00066     IDirectFBSurface    *dfbsurface;
00067 
00068     
00069     INITCHECK;
00070 
00071     if (this->surface) {
00072         
00073         *surface = this->surface;
00074         return true;
00075     }
00076 
00077     
00078     if ((dfbres=this->dfbwindow->GetSurface(this->dfbwindow, &dfbsurface)) != DFB_OK) {
00079         MMSFB_SetError(dfbres, "IDirectFBWindow::GetSurface() failed");
00080         return false;
00081     }
00082 
00083     
00084     *surface = new MMSFBSurface(dfbsurface);
00085     if (!*surface) {
00086         dfbsurface->Release(dfbsurface);
00087         MMSFB_SetError(0, "cannot create new instance of MMSFBSurface");
00088         return false;
00089     }
00090 
00091     
00092     this->surface = *surface;
00093 
00094     return true;
00095 }
00096 
00097 bool MMSFBWindow::getConfiguration(MMSFBWindowConfig *config) {
00098     DFBResult   dfbres;
00099 
00100     
00101     INITCHECK;
00102 
00103     
00104     MMSFBSurface *s;
00105     if (!getSurface(&s))
00106         return false;
00107 
00108     
00109     if (!this->surface->getConfiguration(&(this->config.surface_config)))
00110         return false;
00111 
00112     
00113     if (config)
00114         *config = this->config;
00115 
00116     return true;
00117 }
00118 
00119 bool MMSFBWindow::isShown() {
00120 
00121     
00122     INITCHECK;
00123 
00124     
00125     return this->config.shown;
00126 }
00127 
00128 bool MMSFBWindow::show() {
00129     DFBResult   dfbres;
00130 
00131     
00132     INITCHECK;
00133 
00134     
00135     if (this->config.shown)
00136         return true;
00137 
00138     
00139     if ((dfbres=this->dfbwindow->SetOpacity(this->dfbwindow, this->config.opacity)) != DFB_OK) {
00140         MMSFB_SetError(dfbres, "IDirectFBWindow::SetOpacity(" + iToStr(this->config.opacity) + ") failed");
00141         return false;
00142     }
00143 
00144     this->config.shown = true;
00145     return true;
00146 }
00147 
00148 bool MMSFBWindow::hide() {
00149     DFBResult   dfbres;
00150 
00151     
00152     INITCHECK;
00153 
00154     
00155     if (!this->config.shown)
00156         return true;
00157 
00158     
00159     if ((dfbres=this->dfbwindow->SetOpacity(this->dfbwindow, 0)) != DFB_OK) {
00160         MMSFB_SetError(dfbres, "IDirectFBWindow::SetOpacity(0) failed");
00161         return false;
00162     }
00163 
00164     this->config.shown = false;
00165     return true;
00166 }
00167 
00168 bool MMSFBWindow::getOpacity(unsigned char *opacity) {
00169 
00170     
00171     INITCHECK;
00172 
00173     
00174     *opacity = this->config.opacity;
00175 
00176     return true;
00177 }
00178 
00179 bool MMSFBWindow::setOpacity(unsigned char opacity) {
00180     DFBResult   dfbres;
00181 
00182     
00183     INITCHECK;
00184 
00185     if (this->config.shown) {
00186         
00187         if ((dfbres=this->dfbwindow->SetOpacity(this->dfbwindow, opacity)) != DFB_OK) {
00188             MMSFB_SetError(dfbres, "IDirectFBWindow::SetOpacity(" + iToStr(opacity) + ") failed");
00189             return false;
00190         }
00191     }
00192 
00193     
00194     this->config.opacity = opacity;
00195 
00196     return true;
00197 }
00198 
00199 bool MMSFBWindow::getPosition(int *x, int *y) {
00200 
00201     
00202     INITCHECK;
00203 
00204     
00205     *x = this->config.posx;
00206     *y = this->config.posy;
00207 
00208     return true;
00209 }
00210 
00211 bool MMSFBWindow::moveTo(int x, int y) {
00212     DFBResult   dfbres;
00213 
00214     
00215     INITCHECK;
00216 
00217     
00218     if ((dfbres=this->dfbwindow->MoveTo(this->dfbwindow, x, y)) != DFB_OK) {
00219         MMSFB_SetError(dfbres, "IDirectFBWindow::MoveTo(" + iToStr(x) + "," + iToStr(y) + ") failed");
00220         return false;
00221     }
00222 
00223     
00224     this->config.posx = x;
00225     this->config.posy = y;
00226 
00227     return true;
00228 }
00229 
00230 bool MMSFBWindow::getSize(int *w, int *h) {
00231 
00232     
00233     INITCHECK;
00234 
00235     
00236     *w = this->config.surface_config.w;
00237     *h = this->config.surface_config.h;
00238 
00239     return true;
00240 }
00241 
00242 bool MMSFBWindow::resize(int w, int h) {
00243     DFBResult   dfbres;
00244 
00245     
00246     INITCHECK;
00247 
00248     
00249     if ((dfbres=this->dfbwindow->Resize(this->dfbwindow, w, h)) != DFB_OK) {
00250         MMSFB_SetError(dfbres, "IDirectFBWindow::Resize(" + iToStr(w) + "x" + iToStr(h) + ") failed");
00251         return false;
00252     }
00253 
00254     
00255     if (!this->surface->getConfiguration(&this->config.surface_config))
00256         return false;
00257 
00258     return true;
00259 }
00260 
00261 bool MMSFBWindow::raiseToTop(int zlevel) {
00262     DFBResult   dfbres;
00263 
00264 
00265 
00266     
00267     INITCHECK;
00268 
00269     
00270     if ((dfbres=this->dfbwindow->RaiseToTop(this->dfbwindow)) != DFB_OK) {
00271         MMSFB_SetError(dfbres, "IDirectFBWindow::RaiseToTop() failed");
00272         return false;
00273     }
00274     return true;
00275 }
00276 
00277 bool MMSFBWindow::lowerToBottom() {
00278     DFBResult   dfbres;
00279 
00280     
00281     INITCHECK;
00282 
00283     
00284     if ((dfbres=this->dfbwindow->LowerToBottom(this->dfbwindow)) != DFB_OK) {
00285         MMSFB_SetError(dfbres, "IDirectFBWindow::LowerToBottom() failed");
00286         return false;
00287     }
00288     return true;
00289 }
00290 
00291 #endif
00292 
00293 
00294 
00295 
00296 
00297 #ifdef USE_MMSFB_WINMAN
00298 
00299 #define INITCHECK  if(!this->surface){MMSFB_SetError(0,"not initialized");return false;}
00300 
00301 MMSFBWindow::MMSFBWindow(MMSFBSurface *surface, int x, int y) {
00302     
00303 #ifdef  __HAVE_DIRECTFB__
00304     this->dfbwindow = NULL;
00305 #endif
00306     this->surface = surface;
00307 
00308     
00309     if (this->surface) {
00310         getConfiguration();
00311         this->config.posx = x;
00312         this->config.posy = y;
00313         this->config.opacity = 255;
00314         this->config.shown = false;
00315     }
00316 }
00317 
00318 MMSFBWindow::~MMSFBWindow() {
00319     if (this->surface)
00320         delete this->surface;
00321 }
00322 
00323 bool MMSFBWindow::getSurface(MMSFBSurface **surface) {
00324 
00325     
00326     INITCHECK;
00327 
00328     
00329     *surface = this->surface;
00330 
00331     return true;
00332 }
00333 
00334 bool MMSFBWindow::getConfiguration(MMSFBWindowConfig *config) {
00335 
00336     
00337     INITCHECK;
00338 
00339     
00340     if (!this->surface->getConfiguration(&(this->config.surface_config)))
00341         return false;
00342 
00343     
00344     if (config)
00345         *config = this->config;
00346 
00347     return true;
00348 }
00349 
00350 bool MMSFBWindow::isShown() {
00351 
00352     
00353     INITCHECK;
00354 
00355     
00356     return this->config.shown;
00357 }
00358 
00359 bool MMSFBWindow::show() {
00360 
00361     
00362     INITCHECK;
00363 
00364     
00365     if (this->config.shown)
00366         return true;
00367 
00368     
00369     this->config.shown = true;
00370 
00371     
00372     mmsfbwindowmanager->showWindow(this);
00373 
00374     return true;
00375 }
00376 
00377 bool MMSFBWindow::hide() {
00378 
00379     
00380     INITCHECK;
00381 
00382     
00383     if (!this->config.shown)
00384         return true;
00385 
00386     
00387     this->config.shown = false;
00388 
00389     
00390     mmsfbwindowmanager->hideWindow(this);
00391 
00392     return true;
00393 }
00394 
00395 bool MMSFBWindow::getOpacity(unsigned char *opacity) {
00396 
00397     
00398     INITCHECK;
00399 
00400     
00401     *opacity = this->config.opacity;
00402 
00403     return true;
00404 }
00405 
00406 bool MMSFBWindow::setOpacity(unsigned char opacity) {
00407 
00408     
00409     INITCHECK;
00410 
00411     
00412     this->config.opacity = opacity;
00413 
00414     
00415     mmsfbwindowmanager->setWindowOpacity(this);
00416 
00417     return true;
00418 }
00419 
00420 bool MMSFBWindow::getPosition(int *x, int *y) {
00421 
00422     
00423     INITCHECK;
00424 
00425     
00426     *x = this->config.posx;
00427     *y = this->config.posy;
00428 
00429     return true;
00430 }
00431 
00432 bool MMSFBWindow::moveTo(int x, int y, bool move_vrect) {
00433 
00434     
00435     INITCHECK;
00436 
00437     
00438     MMSFBRectangle vrect;
00439     if (move_vrect) {
00440         if (getVisibleRectangle(&vrect)) {
00441             vrect.x+= this->config.posx - x;
00442             vrect.y+= this->config.posy - y;
00443         }
00444         else
00445             move_vrect = false;
00446     }
00447 
00448     
00449     this->config.posx = x;
00450     this->config.posy = y;
00451 
00452     
00453     if (move_vrect)
00454         mmsfbwindowmanager->setWindowPosition(this, &vrect);
00455     else
00456         mmsfbwindowmanager->setWindowPosition(this);
00457 
00458     return true;
00459 }
00460 
00461 bool MMSFBWindow::getSize(int *w, int *h) {
00462 
00463     
00464     INITCHECK;
00465 
00466     
00467     *w = this->config.surface_config.w;
00468     *h = this->config.surface_config.h;
00469 
00470     return true;
00471 }
00472 
00473 bool MMSFBWindow::resize(int w, int h) {
00474 
00475     
00476     INITCHECK;
00477 
00478     
00479     mmsfbwindowmanager->setWindowSize(this, w, h);
00480 
00481     return true;
00482 }
00483 
00484 bool MMSFBWindow::raiseToTop(int zlevel) {
00485 
00486     
00487     INITCHECK;
00488 
00489     
00490     this->config.zlevel = zlevel;
00491 
00492     
00493     mmsfbwindowmanager->raiseToTop(this);
00494 
00495     return true;
00496 }
00497 
00498 bool MMSFBWindow::lowerToBottom() {
00499 
00500     
00501     INITCHECK;
00502 
00503     
00504     this->config.zlevel = 1000;
00505 
00506     
00507     mmsfbwindowmanager->lowerToBottom(this);
00508 
00509     return true;
00510 }
00511 
00512 bool MMSFBWindow::setVisibleRectangle(MMSFBRectangle *rect) {
00513 
00514     
00515     INITCHECK;
00516 
00517     
00518     return mmsfbwindowmanager->setWindowVisibleRectangle(this, rect);
00519 }
00520 
00521 bool MMSFBWindow::getVisibleRectangle(MMSFBRectangle *rect) {
00522 
00523     
00524     INITCHECK;
00525 
00526     
00527     return mmsfbwindowmanager->getWindowVisibleRectangle(this, rect);
00528 }
00529 
00530 bool MMSFBWindow::getScreenshot() {
00531 
00532     
00533     INITCHECK;
00534 
00535     
00536     return mmsfbwindowmanager->getScreenshot(this);
00537 }
00538 
00539 #endif
00540