1 /********************************************************************************
2 *                                                                               *
3 *                         M e s s a g e   B o x e s                             *
4 *                                                                               *
5 *********************************************************************************
6 * Copyright (C) 1997,2006 by Jeroen van der Zijp.   All Rights Reserved.        *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or                 *
9 * modify it under the terms of the GNU Lesser General Public                    *
10 * License as published by the Free Software Foundation; either                  *
11 * version 2.1 of the License, or (at your option) any later version.            *
12 *                                                                               *
13 * This library is distributed in the hope that it will be useful,               *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of                *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU             *
16 * Lesser General Public License for more details.                               *
17 *                                                                               *
18 * You should have received a copy of the GNU Lesser General Public              *
19 * License along with this library; if not, write to the Free Software           *
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.    *
21 *********************************************************************************
22 * $Id: FXMessageBox.h 3297 2015-12-14 20:30:04Z arthurcnorman $                      *
23 ********************************************************************************/
24 #ifndef FXMESSAGEBOX_H
25 #define FXMESSAGEBOX_H
26 
27 #ifndef FXDIALOGBOX_H
28 #include "FXDialogBox.h"
29 #endif
30 
31 namespace FX {
32 
33 
34 // Message box buttons
35 enum {
36   MBOX_OK                   = 0x10000000, /// Message box has a only an OK button
37   MBOX_OK_CANCEL            = 0x20000000, /// Message box has OK and CANCEL buttons
38   MBOX_YES_NO               = 0x30000000, /// Message box has YES and NO buttons
39   MBOX_YES_NO_CANCEL        = 0x40000000, /// Message box has YES, NO, and CANCEL buttons
40   MBOX_QUIT_CANCEL          = 0x50000000, /// Message box has QUIT and CANCEL buttons
41   MBOX_QUIT_SAVE_CANCEL     = 0x60000000, /// Message box has QUIT, SAVE, and CANCEL buttons
42   MBOX_SKIP_SKIPALL_CANCEL  = 0x70000000, /// Message box has SKIP, SKIP ALL, and CANCEL buttons
43   MBOX_SAVE_CANCEL_DONTSAVE = 0x80000000  /// Message box has DON'T SAVE,CANCEL and SAVE buttons
44   };
45 
46 
47 // Return values
48 enum {
49   MBOX_CLICKED_YES      = 1,            /// The YES button was clicked
50   MBOX_CLICKED_NO       = 2,            /// The NO button was clicked
51   MBOX_CLICKED_OK       = 3,            /// The OK button was clicked
52   MBOX_CLICKED_CANCEL   = 4,            /// The CANCEL button was clicked
53   MBOX_CLICKED_QUIT     = 5,            /// The QUIT button was clicked
54   MBOX_CLICKED_SAVE     = 6,            /// The SAVE button was clicked
55   MBOX_CLICKED_SKIP     = 7,            /// The SKIP button was clicked
56   MBOX_CLICKED_SKIPALL  = 8             /// The SKIP ALL button was clicked
57   };
58 
59 
60 /**
61 * A Message Box is a convenience class which provides a dialog for
62 * very simple common yes/no type interactions with the user.
63 * The message box has an optional icon, a title string, and the question
64 * which is presented to the user.  It also has up to three buttons which
65 * furnish standard responses to the question.
66 * Message boxes are usually ran modally: the question must be answered
67 * before the program may continue.
68 */
69 class FXAPI FXMessageBox : public FXDialogBox {
FXDECLARE(FXMessageBox)70   FXDECLARE(FXMessageBox)
71 protected:
72   FXMessageBox(){}
73 private:
74   FXMessageBox(const FXMessageBox&);
75   FXMessageBox &operator=(const FXMessageBox&);
76   void initialize(const FXString& text,FXIcon* ic,FXuint whichbuttons);
77 public:
78   long onCmdClicked(FXObject*,FXSelector,void*);
79   long onCmdCancel(FXObject*,FXSelector,void*);
80 public:
81   enum{
82     ID_CLICKED_YES=FXDialogBox::ID_LAST,
83     ID_CLICKED_NO,
84     ID_CLICKED_OK,
85     ID_CLICKED_CANCEL,
86     ID_CLICKED_QUIT,
87     ID_CLICKED_SAVE,
88     ID_CLICKED_SKIP,
89     ID_CLICKED_SKIPALL,
90     ID_LAST
91     };
92 public:
93 
94   /// Construct message box with given caption, icon, and message text
95   FXMessageBox(FXWindow* owner,const FXString& caption,const FXString& text,FXIcon* ic=NULL,FXuint opts=0,FXint x=0,FXint y=0);
96 
97   /// Construct free floating message box with given caption, icon, and message text
98   FXMessageBox(FXApp* app,const FXString& caption,const FXString& text,FXIcon* ic=NULL,FXuint opts=0,FXint x=0,FXint y=0);
99 
100   /**
101   * Show a modal error message.
102   * The text message may contain printf-tyle formatting commands.
103   */
104   static FXuint error(FXWindow* owner,FXuint opts,const char* caption,const char* message,...) FX_PRINTF(4,5) ;
105 
106   /**
107   * Show modal error message, in free floating window.
108   */
109   static FXuint error(FXApp* app,FXuint opts,const char* caption,const char* message,...) FX_PRINTF(4,5) ;
110 
111   /**
112   * Show a modal warning message
113   * The text message may contain printf-tyle formatting commands.
114   */
115   static FXuint warning(FXWindow* owner,FXuint opts,const char* caption,const char* message,...) FX_PRINTF(4,5) ;
116 
117   /**
118   * Show modal warning message, in free floating window.
119   */
120   static FXuint warning(FXApp* app,FXuint opts,const char* caption,const char* message,...) FX_PRINTF(4,5) ;
121 
122   /**
123   * Show a modal question dialog
124   * The text message may contain printf-tyle formatting commands.
125   */
126   static FXuint question(FXWindow* owner,FXuint opts,const char* caption,const char* message,...) FX_PRINTF(4,5) ;
127 
128   /**
129   * Show modal question message, in free floating window.
130   */
131   static FXuint question(FXApp* app,FXuint opts,const char* caption,const char* message,...) FX_PRINTF(4,5) ;
132 
133   /**
134   * Show a modal information dialog
135   * The text message may contain printf-tyle formatting commands.
136   */
137   static FXuint information(FXWindow* owner,FXuint opts,const char* caption,const char* message,...) FX_PRINTF(4,5) ;
138 
139   /**
140   * Show modal information message, in free floating window.
141   */
142   static FXuint information(FXApp* app,FXuint opts,const char* caption,const char* message,...) FX_PRINTF(4,5) ;
143 
144   };
145 
146 }
147 
148 #endif
149