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 setFocusable(true);
00068
00069
00070 this->timer = new MMSTimer(true);
00071 this->timeOut_connection = this->timer->timeOut.connect(sigc::mem_fun(this, &MMSPopupWindow::timeOut));
00072
00073 return MMSWindow::create(dx, dy, w, h, alignment, flags, own_surface, backbuffer);
00074 }
00075
00076 void MMSPopupWindow::timeOut(void) {
00077
00078
00079 hide(false, true);
00080 }
00081
00082 void MMSPopupWindow::afterShowAction(MMSPulser *pulser) {
00083
00084
00085 MMSWindow::afterShowAction(pulser);
00086
00087
00088 unsigned int duration = getDuration();
00089 if (duration > 0) {
00090 this->timer->start(duration * 1000);
00091 }
00092 }
00093
00094 bool MMSPopupWindow::beforeHideAction(MMSPulser *pulser) {
00095
00096
00097 this->timer->stop();
00098
00099
00100 return MMSWindow::beforeHideAction(pulser);
00101 }
00102
00103
00104
00105
00106
00107
00108 #define GETPOPUPWINDOW(x) \
00109 if (this->myPopupWindowClass.is##x()) return myPopupWindowClass.get##x(); \
00110 else if ((popupWindowClass)&&(popupWindowClass->is##x())) return popupWindowClass->get##x(); \
00111 else return this->theme->popupWindowClass.get##x();
00112
00113 unsigned int MMSPopupWindow::getDuration() {
00114 GETPOPUPWINDOW(Duration);
00115 }
00116
00117
00118
00119
00120
00121 void MMSPopupWindow::setDuration(unsigned int duration) {
00122 myPopupWindowClass.setDuration(duration);
00123
00124
00125 if(duration == 0) {
00126 this->timer->stop();
00127 } else {
00128 if(this->isShown()) {
00129 if(!this->timer->isRunning()) {
00130 this->timer->start(duration * 1000);
00131 } else {
00132 this->timer->restart();
00133 }
00134 }
00135 }
00136 }
00137
00138 void MMSPopupWindow::updateFromThemeClass(MMSPopupWindowClass *themeClass) {
00139 if (themeClass->isDuration())
00140 setDuration(themeClass->getDuration());
00141
00142 MMSWindow::updateFromThemeClass(&(themeClass->windowClass));
00143 }
00144
00145
00146
00147