quit_button.cpp

Go to the documentation of this file.
00001 #ifndef QUIT_BUTTON_IMPLEMENTATION_FILE
00002 #define QUIT_BUTTON_IMPLEMENTATION_FILE
00003 
00004 /*****************************************************************************\
00005 *                                                                             *
00006 *  Name   : quit_button                                                       *
00007 *  Author : Chris Koeritz                                                     *
00008 *                                                                             *
00009 *******************************************************************************
00010 * Copyright (c) 1991-$now By Author.  This program is free software; you can  *
00011 * redistribute it and/or modify it under the terms of the GNU General Public  *
00012 * License as published by the Free Software Foundation; either version 2 of   *
00013 * the License or (at your option) any later version.  This is online at:      *
00014 *     http://www.fsf.org/copyleft/gpl.html                                    *
00015 * Please send any updates to: fred@gruntose.com                               *
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 

Generated on Fri Nov 28 04:29:04 2008 for HOOPLE Libraries by  doxygen 1.5.1