ubit
udialogs.hpp
1 /************************************************************************
2  *
3  * udialogs.hpp: dialog boxes
4  * Ubit GUI Toolkit - Version 6
5  * (C) 2009 | Eric Lecolinet | TELECOM ParisTech | http://www.enst.fr/~elc/ubit
6  *
7  * ***********************************************************************
8  * COPYRIGHT NOTICE :
9  * THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY AND WITHOUT EVEN THE
10  * IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
11  * YOU CAN REDISTRIBUTE IT AND/OR MODIFY IT UNDER THE TERMS OF THE GNU
12  * GENERAL PUBLIC LICENSE AS PUBLISHED BY THE FREE SOFTWARE FOUNDATION;
13  * EITHER VERSION 2 OF THE LICENSE, OR (AT YOUR OPTION) ANY LATER VERSION.
14  * SEE FILES 'COPYRIGHT' AND 'COPYING' FOR MORE DETAILS.
15  * ***********************************************************************/
16 
17 #ifndef _udialogs_hpp_
18 #define _udialogs_hpp_ 1
19 #include <ubit/uwin.hpp>
20 namespace ubit {
21 
29  class UDialog : public UWin {
30  public:
31  UCLASS(UDialog)
32 
33  UDialog(UArgs nodelist = UArgs::none);
35 
36  virtual ~UDialog() {destructs();}
37 
38  virtual UDialog& setTitle(const UStr& title) {UWin::setTitle(title); return *this;}
40 
41  virtual void show(bool state, UDisp*); // redefined
43 
44  virtual void show(bool state = true) {UDialog::show(state, null);} // redefined
53  static void showAlertDialog(const UStr& message_string);
55 
56  static void showAlertDialog(UArgs message_nodes);
58 
59  static void showErrorDialog(const UStr& message_string);
61 
62  static void showErrorDialog(UArgs message_nodes);
64 
65  static void showWarningDialog(const UStr& message_string);
67 
68  static void showWarningDialog(UArgs message_nodes);
70 
71  static void showMessageDialog(const UStr& title, const UStr& message_string,
72  UArgs icon = UArgs::none);
80  static void showMessageDialog(const UStr& title, UArgs message_nodes,
81  UArgs icon = UArgs::none);
90  static UStyle* createStyle(); // redefined
91  virtual bool realize(); // redefined
92 
93 #ifndef NO_DOC
94  virtual void addingTo(UChild&, UElem& parent);
95  virtual void removingFrom(UChild&, UElem& parent);
96  private:
97  UCall* open_call;
98  static class UOptionDialog* messdialog;
99 #endif
100  };
101 
102  inline UDialog& udialog(UArgs arglist = UArgs::none) {return *new UDialog(arglist);}
104 
105  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
117  class UFrame : public UDialog {
118  friend class UAppli;
119  public:
120  UCLASS(UFrame)
121 
122  UFrame(UArgs nodelist = UArgs::none);
124 
125  bool isMainFrame() const {return wmodes.IS_MAINFRAME;}
127 
128  virtual UFrame& setTitle(const UStr& title) {UWin::setTitle(title); return *this;}
130 
131  virtual void show(bool state, UDisp*); // redefined
132  virtual void show(bool state = true) {UFrame::show(state, null);} // redefined
133 
134  static UStyle* createStyle(); // redefined
135  virtual bool realize(); // redefined
136  };
137 
138  inline UFrame& uframe(const UArgs& a = UArgs::none) {return *new UFrame(a);}
140 
141 
142  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
146  class UOptionDialog : public UDialog {
147  public:
148  UCLASS(UOptionDialog)
149 
150  UOptionDialog(UArgs message_nodes = UArgs::none);
151  UOptionDialog(const UStr& title, UArgs message_nodes, UArgs icon, UArgs buttons);
152 
153  UOptionDialog& setTitle(const UStr& title);
154  UOptionDialog& setMessage(const UStr& string);
155  UOptionDialog& setMessage(UArgs nodelist);
156  UOptionDialog& setIcon(UArgs icon);
157  UOptionDialog& setButtons(UArgs buttons);
158 
159  protected:
160  uptr<UBox> picon, pmessage, pbuttons;
161  void constructs(UArgs message);
162  };
163 
164 }
165 #endif
virtual void removingFrom(UChild &, UElem &parent)
called when this object is removed from a parent (SEE DETAILS IF YOU REDEFINE THIS METHOD)...
Definition: udialogs.cpp:90
Predefined dialog box with optional content, icon and buttons area.
Definition: udialogs.hpp:146
static void showErrorDialog(const UStr &message_string)
pops up an Error dialog on the screen (see showMessageDialog()).
Definition: udialogs.cpp:245
virtual UWin & setTitle(const UStr &title)
changes the title of the window.
Definition: uwin.cpp:394
UFrame: toplevel and main window.
Definition: udialogs.hpp:117
static void showMessageDialog(const UStr &title, const UStr &message_string, UArgs icon=UArgs::none)
pops up a Message dialog on the screen.
virtual void show(bool state=true)
< shows/hides the dialog box on this display;
Definition: udialogs.hpp:132
virtual void show(bool state, UDisp *)
shows/hides the window on this display;
Display Context.
Definition: udisp.hpp:44
virtual UDialog & setTitle(const UStr &title)
changes the title of the dialog box.
Definition: udialogs.hpp:38
The Application Context.
Definition: uappli.hpp:79
lightweight general purpose container.
Definition: uelem.hpp:44
base class of callback objects for firing functions or methods.
Definition: ucall.hpp:144
Argument list (for passing arguments to constructor or add functions).
Definition: uargs.hpp:43
bool isMainFrame() const
is this frame the "main frame"? (
Definition: udialogs.hpp:125
virtual void destructs()
unlinks the object from its parents and destroys its children.
Definition: uelem.cpp:109
virtual void show(bool state, UDisp *)
shows/hides the window on this display;
virtual void show(bool state=true)
< shows/hides the dialog box on this display;
Definition: udialogs.hpp:44
static void showWarningDialog(const UStr &message_string)
pops up a Warning dialog on the screen (see showMessageDialog()).
Definition: udialogs.cpp:255
virtual bool realize()
[impl] initializes the window and its children.
Definition: udialogs.cpp:72
Definition: uhardfont.hpp:31
static void showAlertDialog(const UStr &message_string)
< shows/hides this dialog box.
Definition: udialogs.cpp:235
static const UArgs none
the empty arglist.
Definition: uargs.hpp:45
Dialog box.
Definition: udialogs.hpp:29
Base class for windows and menus.
Definition: uwin.hpp:47
virtual void addingTo(UChild &, UElem &parent)
called when this object is added to a parent.
Definition: udialogs.cpp:80
Compiled Object Style.
Definition: ustyle.hpp:44
Ubit String.
Definition: ustr.hpp:72
[impl] Internal implementation of a child node.
Definition: uchild.hpp:23
virtual UFrame & setTitle(const UStr &title)
changes the title of the dialog box.
Definition: udialogs.hpp:128
UDialog(UArgs nodelist=UArgs::none)
creates a new Dialog Window;
Definition: udialogs.cpp:68