edelib  2.1.0
MessageBox.h
1 /*
2  * $Id: MessageBox.h 2839 2009-09-28 11:36:20Z karijes $
3  *
4  * Message dialog
5  * Copyright (c) 2005-2007 edelib authors
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser 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  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with this library. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef __EDELIB_MESSAGEBOX_H__
22 #define __EDELIB_MESSAGEBOX_H__
23 
24 #include "edelib-global.h"
25 
26 #include <FL/Fl_Window.H>
27 #include <FL/Fl_Button.H>
28 #include <FL/Fl_Box.H>
29 #include <FL/Fl_Input.H>
30 #include <FL/Fl_Pixmap.H>
31 
32 #define MSGBOX_MAX_BUTTONS 4 // Max buttons in dialog
33 
34 #define MSGBOX_ICON_ERROR "dialog-error"
35 #define MSGBOX_ICON_INFO "dialog-information"
36 #define MSGBOX_ICON_PASSWORD "dialog-password"
37 #define MSGBOX_ICON_WARNING "dialog-warning"
38 #define MSGBOX_ICON_QUESTION "dialog-question"
39 
40 EDELIB_NS_BEGIN
41 
51 };
52 
61 };
62 
74 };
75 
196 class EDELIB_API MessageBox : public Fl_Window {
197 private:
198  Fl_Box* img;
199  Fl_Box* txt;
200  Fl_Input* inpt;
201  Fl_Group* gr;
202  Fl_Pixmap* pix;
203 
204  MessageBoxType mbt;
205 
206  int nbuttons;
207  int b_start;
208  Fl_Button* buttons[MSGBOX_MAX_BUTTONS];
209 
210  void init(void);
211  void fix_sizes(void);
212 
213  void add(Fl_Widget*) { } // in case someone tries to be too smart
214 
215 public:
221 
225  ~MessageBox();
226 
231  void set_text(const char* t);
232 
238  bool set_icon(const char* path);
239 
246  bool set_theme_icon(const char* name);
247 
251  void set_xpm_icon(const char* const* arr);
252 
257  void set_icon_from_type(MessageBoxIconType type);
258 
267  const char* get_input(void);
268 
272  void set_input(const char* txt);
273 
277  void focus_button(int b);
278 
284  void add_button(Fl_Button* b, MessageBoxButtonType bt = MSGBOX_BUTTON_PLAIN);
285 
293  void add_button(const char* l, MessageBoxButtonType bt = MSGBOX_BUTTON_PLAIN, Fl_Callback cb = 0, void* param = 0);
294 
299  void clear(MessageBoxType t = MSGBOX_PLAIN);
300 
305  void run_plain(bool center = true);
306 
314  int run(bool center = true);
315 
324  static void set_themed_icons(const char* msg, const char* alert = 0, const char* ask = 0,
325  const char* input = 0, const char* password = 0);
326 
328  static void clear_themed_icons(void);
329 };
330 
341 EDELIB_API void themed_dialog_icons(const char* msg, const char* alert = 0,
342  const char* ask = 0, const char* input = 0, const char* password = 0) EDELIB_DEPRECATED;
343 
349 EDELIB_API void clear_dialog_icons(void) EDELIB_DEPRECATED;
350 
355 EDELIB_API void message(const char* fmt, ...);
356 
361 EDELIB_API void alert(const char* fmt, ...);
362 
368 EDELIB_API int ask(const char* fmt, ...);
369 
380 EDELIB_API const char* input(const char* fmt, const char* deflt = 0, ...);
381 
386 EDELIB_API const char* password(const char* fmt, const char* deflt = 0, ...);
387 
388 #ifndef SKIP_DOCS
389 /*
390  * FLTK compatibility
391  */
392 extern void (*fl_message)(const char* fmt, ...);
393 extern void (*fl_alert)(const char* fmt, ...);
394 extern int (*fl_ask)(const char* fmt, ...);
395 extern const char* (*fl_input)(const char* fmt, const char* deflt, ...);
396 extern const char* (*fl_password)(const char* fmt, const char* deflt, ...);
397 #endif
398 
399 EDELIB_NS_END
400 #endif
Button with &#39;enter&#39; shortcut (Fl_Return_Button)
Definition: MessageBox.h:60
Info-like icon.
Definition: MessageBox.h:69
Alert-like icon.
Definition: MessageBox.h:70
void clear_dialog_icons(void)
MessageBoxButtonType
Type of added button to MessageBox class.
Definition: MessageBox.h:58
Question-like icon.
Definition: MessageBox.h:71
Ordinary button (Fl_Button)
Definition: MessageBox.h:59
void alert(const char *fmt,...)
void message(const char *fmt,...)
MessageBoxType
Type of MessageBox dialog.
Definition: MessageBox.h:47
const char * input(const char *fmt, const char *deflt=0,...)
Dialog with secret input field.
Definition: MessageBox.h:50
MessageBoxIconType
Type of the icon in message box.
Definition: MessageBox.h:68
Plain dialog.
Definition: MessageBox.h:48
Input-like icon.
Definition: MessageBox.h:72
Password-like icon.
Definition: MessageBox.h:73
Dialog with input field.
Definition: MessageBox.h:49
void themed_dialog_icons(const char *msg, const char *alert=0, const char *ask=0, const char *input=0, const char *password=0)
Standard dialog.
Definition: MessageBox.h:196
int ask(const char *fmt,...)
const char * password(const char *fmt, const char *deflt=0,...)