aboutsummaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
authorMax Horn2003-11-01 20:52:41 +0000
committerMax Horn2003-11-01 20:52:41 +0000
commitf7ab7f62075107a8afbc071555b25612320664b9 (patch)
tree5151bc75f8e37ccf833f42f03699811df1c7c928 /gui
parente6eb3e234d4188a6753bfa3bf0cf637e6c716316 (diff)
downloadscummvm-rg350-f7ab7f62075107a8afbc071555b25612320664b9.tar.gz
scummvm-rg350-f7ab7f62075107a8afbc071555b25612320664b9.tar.bz2
scummvm-rg350-f7ab7f62075107a8afbc071555b25612320664b9.zip
cleanup: new MessageDialog subclass TimedMessageDialog
svn-id: r11033
Diffstat (limited to 'gui')
-rw-r--r--gui/message.cpp29
-rw-r--r--gui/message.h27
2 files changed, 34 insertions, 22 deletions
diff --git a/gui/message.cpp b/gui/message.cpp
index 0a70f1e4ea..8c6f8c30ec 100644
--- a/gui/message.cpp
+++ b/gui/message.cpp
@@ -19,15 +19,17 @@
*/
#include "stdafx.h"
-#include "message.h"
-#include "newgui.h"
+#include "gui/message.h"
+#include "gui/newgui.h"
+#include "common/str.h"
+#include "common/list.h"
enum {
kOkCmd = 'OK ',
kCancelCmd = 'CNCL'
};
-MessageDialog::MessageDialog(NewGui *gui, const String &message, uint32 timer, bool showOkButton, bool showCancelButton)
+MessageDialog::MessageDialog(NewGui *gui, const String &message, bool showOkButton, bool showCancelButton)
: Dialog(gui, 30, 20, 260, 124) {
// First, determine the size the dialog needs. For this we have to break
// down the string into lines, and taking the maximum of their widths.
@@ -87,17 +89,6 @@ MessageDialog::MessageDialog(NewGui *gui, const String &message, uint32 timer, b
if (showCancelButton)
addButton(cancelButtonPos, _h - 24, "CANCEL", kCancelCmd, '\27'); // Cancel dialog
-
- if (timer)
- _timer = _gui->get_time() + timer;
- else
- _timer = 0;
-}
-
-void MessageDialog::handleTickle() {
- Dialog::handleTickle();
- if (_timer && _gui->get_time() > _timer)
- close();
}
int MessageDialog::addLine(StringList &lines, const char *line, int size) {
@@ -157,3 +148,13 @@ void MessageDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data
}
}
+TimedMessageDialog::TimedMessageDialog(NewGui *gui, const Common::String &message, uint32 timer)
+ : MessageDialog(gui, message, false, false) {
+ _timer = _gui->get_time() + timer;
+}
+
+void TimedMessageDialog::handleTickle() {
+ MessageDialog::handleTickle();
+ if (_gui->get_time() > _timer)
+ close();
+}
diff --git a/gui/message.h b/gui/message.h
index 69f630a538..8635d08245 100644
--- a/gui/message.h
+++ b/gui/message.h
@@ -21,23 +21,34 @@
#ifndef MESSAGE_DIALOG_H
#define MESSAGE_DIALOG_H
-#include "dialog.h"
-#include "common/str.h"
-#include "common/list.h"
+#include "gui/dialog.h"
+
+namespace Common {
+ class String;
+ class StringList;
+}
class MessageDialog : public Dialog {
typedef Common::String String;
typedef Common::StringList StringList;
public:
- MessageDialog(NewGui *gui, const String &message, uint32 timer = 0, bool showOKButton = true, bool showCancelButton = false);
-
- void handleTickle();
+ MessageDialog(NewGui *gui, const Common::String &message, bool showOKButton = true, bool showCancelButton = false);
+
void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);
protected:
- uint32 _timer;
+ int addLine(Common::StringList &lines, const char *line, int size);
+};
+
+class TimedMessageDialog : public MessageDialog {
+public:
+ TimedMessageDialog(NewGui *gui, const Common::String &message, uint32 timer);
+
+ void handleTickle();
- int addLine(StringList &lines, const char *line, int size);
+protected:
+ uint32 _timer;
};
+
#endif