00001 #ifndef MESSAGE_BOX_CLASS 00002 #define MESSAGE_BOX_CLASS 00003 00004 /*****************************************************************************\ 00005 * * 00006 * Name : message_box * 00007 * Author : Chris Koeritz * 00008 * * 00009 * Purpose: * 00010 * * 00011 * Displays a window on the screen with a message for the user and asks * 00012 * whether a choice is okay or not. The user's response is passed to * 00013 * the event function button_event. * 00014 * * 00015 ******************************************************************************* 00016 * Copyright (c) 1991-$now By Author. This program is free software; you can * 00017 * redistribute it and/or modify it under the terms of the GNU General Public * 00018 * License as published by the Free Software Foundation; either version 2 of * 00019 * the License or (at your option) any later version. This is online at: * 00020 * http://www.fsf.org/copyleft/gpl.html * 00021 * Please send any updates to: fred@gruntose.com * 00022 \*****************************************************************************/ 00023 00024 #include "dll_wp_active.h" 00025 00026 #include <basis/istring.h> 00027 #include <wp_passive/manager.h> 00028 #include <wp_passive/worker.h> 00029 00030 enum message_box_kinds { PROCEED, INFORMATION, WARNING, HELP }; 00031 // The different kinds of message boxes are: 00032 // 00033 // PROCEED: displays a box with a single message and offers the user the 00034 // three choices of YES, NO, or CANCEL. 00035 // 00036 // INFORMATION: displays a window with a message inside of it. the single 00037 // button is labelled OKAY. 00038 // 00039 // WARNING: displays a window with vital information inside of it. warning 00040 // dialogs require the user to accept the consequences of an action 00041 // that they have selected (despite the warning message) as OKAY or 00042 // to reject the consequences with CANCEL. 00043 // 00044 // HELP: display an error message and offer the choice of OKAY or 00045 // HELP which will pop up a brief help message. after reading the 00046 // message, the user must select OKAY. The event function will be fired 00047 // when either OKAY or HELP is pushed, but is not fired for the help 00048 // message itself. 00049 00050 enum PROCEED_BUTTONS { PROCEED_YES, PROCEED_NO, PROCEED_CANCEL }; 00051 enum INFORMATION_BUTTONS { INFO_OKAY }; 00052 enum WARNING_BUTTONS { WARNING_OKAY, WARNING_CANCEL }; 00053 enum HELP_BUTTONS { HELP_OKAY, HELP_HELP }; 00054 00055 class WP_ACTIVE_CLASS_STYLE message_box : public worker 00056 { 00057 public: 00058 message_box(manager &root, const c_point &origin, message_box_kinds kind, 00059 const char *message, const char *second_message = NIL, 00060 const color &foreground = colors::WHITE, 00061 const color &background = colors::BLACK); 00062 // creates a message for the user according to the "kind". if the 00063 // parent is activated, the message will appear. if the parent is 00064 // nil, then only the "show_box" function can cause the message_box 00065 // to appear. 00066 00067 ~message_box(); 00068 00069 IMPLEMENT_CLASS_NAME("message_box"); 00070 00071 virtual void draw(); 00072 00073 virtual void button_event(int button_number); 00074 // This event function is invoked when the user presses one of the 00075 // buttons in the message box. 00076 00077 static void message_box_callback(window_handle w, message_box *the_box, 00078 XmAnyCallbackStruct *call_data); 00079 00080 private: 00081 message_box_kinds _kind; 00082 istring _message; 00083 istring _second_message; 00084 int last_hit; 00085 message_box *extra_help_box; 00086 00087 void hookup_callbacks(); 00088 00089 void setup_proceed_box(); 00090 void setup_information_box(); 00091 void setup_warning_box(); 00092 void setup_help_box(); 00093 void show_help(); 00094 }; 00095 00096 #endif
1.5.1