00001 #ifndef QUIT_BUTTON_IMPLEMENTATION_FILE
00002 #define QUIT_BUTTON_IMPLEMENTATION_FILE
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "message_box.h"
00019 #include "quit_button.h"
00020
00021 #include <wp_passive/wp_implementation.h>
00022
00023 #include <stdlib.h>
00024 #include <Xm/PushB.h>
00025
00026 class quit_warning : public message_box
00027 {
00028 public:
00029 quit_warning(manager &root, const c_point &origin, const color &f,
00030 const color &b, quit_button &qb)
00031 : message_box(root, origin, WARNING, "Are you sure you want to quit?",
00032 "", f, b),
00033 to_alert(qb) {}
00034
00035 virtual void button_event(int button_number) {
00036 if (button_number == WARNING_OKAY) {
00037 to_alert.quit_button_event();
00038 root().shut_down();
00039 } else erase();
00040 }
00041
00042 private:
00043 quit_button &to_alert;
00044 };
00045
00046 quit_button::quit_button(manager &parent, const c_point &origin,
00047 const color &a_foreground, const color &a_background)
00048 : button(parent, origin, "Push to Quit", a_foreground, a_background),
00049 really(NIL)
00050 {}
00051
00052 quit_button::~quit_button() { if (really) delete really; }
00053
00054 void quit_button::quit_button_event() {}
00055
00056 void quit_button::button_event()
00057 {
00058 if (really) delete really;
00059 color cornsilk = root().lookup("cornsilk");
00060 color azure = root().lookup("azure");
00061 really = new quit_warning
00062 (root(), drawable::origin(), cornsilk, azure, *this);
00063 really->draw();
00064 }
00065
00066
00067 #endif //QUIT_BUTTON_IMPLEMENTATION_FILE
00068