home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / programming / dreamscape / source / Dreamscape / Headers / utils / h / dbox next >
Encoding:
Text File  |  1996-08-18  |  2.2 KB  |  83 lines

  1.  
  2. // utils.h.dbox
  3.  
  4. // Dreamscape - C++ class library for RISC OS
  5. // Copyright (c) 1996 Mark Seaborn <mseaborn@argonet.co.uk>
  6. //
  7. // This library is free software; you can redistribute it and/or
  8. // modify it under the terms of the GNU Library General Public
  9. // License as published by the Free Software Foundation; either
  10. // version 2 of the License, or (at your option) any later version.
  11. // See the Dreamscape documentation for more information.
  12.  
  13. #ifndef dreamscape_dbox_H
  14. #define dreamscape_dbox_H
  15.  
  16. #include "window.h"
  17. #include "actionbutton.h"
  18.  
  19. class DialogueBoxHandler {
  20. public:
  21.   virtual void keep() = 0;
  22.   virtual void revert() = 0;
  23.   virtual void save();
  24. };
  25.  
  26. class DialogueBox: public BaseWindow {
  27.   Window *window;
  28.   unsigned owns_window: 1;
  29.   ActionButton *ok, *cancel, *save;
  30.   List<DialogueBoxHandler *> handlers;
  31.  
  32.   class ShowingHandler: public Command {
  33.     DialogueBox *dbox;
  34.   public:
  35.     ShowingHandler(DialogueBox *d): dbox(d) {}
  36.     void execute();
  37.   } showing_handler;
  38.   friend ShowingHandler;
  39.  
  40.   class OKHandler: public ActionButtonClickHandler {
  41.     DialogueBox *dbox;
  42.   public:
  43.     OKHandler(DialogueBox *d): dbox(d) {}
  44.     void action_button_click(const ActionButtonClickInfo &info);
  45.   } ok_handler;
  46.   friend OKHandler;
  47.  
  48.   class CancelHandler: public ActionButtonClickHandler {
  49.     DialogueBox *dbox;
  50.   public:
  51.     CancelHandler(DialogueBox *d): dbox(d) {}
  52.     void action_button_click(const ActionButtonClickInfo &info);
  53.   } cancel_handler;
  54.   friend CancelHandler;
  55.  
  56.   class SaveHandler: public ActionButtonClickHandler {
  57.     DialogueBox *dbox;
  58.   public:
  59.     SaveHandler(DialogueBox *d): dbox(d) {}
  60.     void action_button_click(const ActionButtonClickInfo &info);
  61.   } save_handler;
  62.   friend SaveHandler;
  63.  
  64.   void set_handlers();
  65.  
  66. public:
  67.   DialogueBox(BaseWindow *window, ActionButton *ok, ActionButton *cancel,
  68.     ActionButton *save = 0);
  69.   enum { has_save_button = 1 };
  70.   DialogueBox(BaseWindow *window, int flags = 0);
  71.   DialogueBox(const char *name, int flags = 0);
  72.   virtual ~DialogueBox();
  73.  
  74.   void add_handler(DialogueBoxHandler *handler);
  75.   void remove_handler(DialogueBoxHandler *handler);
  76.  
  77.   BaseWindow &get_next_window();
  78.   const BaseWindow &get_next_window() const;
  79.   bool has_next_window() const;
  80. };
  81.  
  82. #endif
  83.