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/mmspopupwindow.h"
00034
00035 MMSPopupWindow::MMSPopupWindow(string className, string dx, string dy, string w, string h, MMSALIGNMENT alignment,
00036 MMSWINDOW_FLAGS flags, MMSTheme *theme, bool *own_surface,
00037 bool *backbuffer, unsigned int duration) {
00038 create(className, dx, dy, w, h, alignment, flags, theme, own_surface, backbuffer, duration);
00039 }
00040
00041 MMSPopupWindow::MMSPopupWindow(string className, string w, string h, MMSALIGNMENT alignment,
00042 MMSWINDOW_FLAGS flags, MMSTheme *theme, bool *own_surface,
00043 bool *backbuffer, unsigned int duration) {
00044 create(className, "", "", w, h, alignment, flags, theme, own_surface, backbuffer, duration);
00045 }
00046
00047 MMSPopupWindow::~MMSPopupWindow() {
00048 this->timeOut_connection.disconnect();
00049 if (this->timer) {
00050 delete this->timer;
00051 }
00052 }
00053
00054 bool MMSPopupWindow::create(string className, string dx, string dy, string w, string h, MMSALIGNMENT alignment,
00055 MMSWINDOW_FLAGS flags, MMSTheme *theme, bool *own_surface,
00056 bool *backbuffer, unsigned int duration) {
00057 this->type = MMSWINDOWTYPE_POPUPWINDOW;
00058 this->className = className;
00059 if (theme) this->theme = theme; else this->theme = globalTheme;
00060 this->popupWindowClass = this->theme->getPopupWindowClass(className);
00061 this->baseWindowClass = &(this->theme->popupWindowClass.windowClass);
00062 if (this->popupWindowClass) this->windowClass = &(this->popupWindowClass->windowClass); else this->windowClass = NULL;
00063
00064 if (duration)
00065 setDuration(duration);
00066
00067
00068 this->timer = new MMSTimer(true);
00069 this->timeOut_connection = this->timer->timeOut.connect(sigc::mem_fun(this, &MMSPopupWindow::timeOut));
00070
00071 return MMSWindow::create(dx, dy, w, h, alignment, flags, own_surface, backbuffer);
00072 }
00073
00074 void MMSPopupWindow::timeOut(void) {
00075
00076
00077 hide(false, true);
00078 }
00079
00080 void MMSPopupWindow::afterShowAction(MMSPulser *pulser) {
00081
00082
00083 MMSWindow::afterShowAction(pulser);
00084
00085
00086 unsigned int duration = getDuration();
00087 if (duration > 0) {
00088 this->timer->start(duration * 1000);
00089 }
00090 }
00091
00092 bool MMSPopupWindow::beforeHideAction(MMSPulser *pulser) {
00093
00094
00095 this->timer->stop();
00096
00097
00098 return MMSWindow::beforeHideAction(pulser);
00099 }
00100
00101
00102
00103
00104
00105
00106 #define GETPOPUPWINDOW(x) \
00107 if (this->myPopupWindowClass.is##x()) return myPopupWindowClass.get##x(); \
00108 else if ((popupWindowClass)&&(popupWindowClass->is##x())) return popupWindowClass->get##x(); \
00109 else return this->theme->popupWindowClass.get##x();
00110
00111 unsigned int MMSPopupWindow::getDuration() {
00112 GETPOPUPWINDOW(Duration);
00113 }
00114
00115
00116
00117
00118
00119 void MMSPopupWindow::setDuration(unsigned int duration) {
00120 myPopupWindowClass.setDuration(duration);
00121
00122
00123 if(duration == 0) {
00124 this->timer->stop();
00125 } else {
00126 if(this->isShown()) {
00127 if(!this->timer->isRunning()) {
00128 this->timer->start(duration * 1000);
00129 } else {
00130 this->timer->restart();
00131 }
00132 }
00133 }
00134 }
00135
00136 void MMSPopupWindow::updateFromThemeClass(MMSPopupWindowClass *themeClass) {
00137 if (themeClass->isDuration())
00138 setDuration(themeClass->getDuration());
00139
00140 MMSWindow::updateFromThemeClass(&(themeClass->windowClass));
00141 }
00142
00143
00144
00145