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
40EDELIB_NS_BEGIN
41
51};
52
61};
62
74};
75
196class EDELIB_API MessageBox : public Fl_Window {
197private:
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
215public:
220 MessageBox(MessageBoxType t = MSGBOX_PLAIN);
221
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
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
341EDELIB_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
349EDELIB_API void clear_dialog_icons(void) EDELIB_DEPRECATED;
350
355EDELIB_API void message(const char* fmt, ...);
356
361EDELIB_API void alert(const char* fmt, ...);
362
368EDELIB_API int ask(const char* fmt, ...);
369
380EDELIB_API const char* input(const char* fmt, const char* deflt = 0, ...);
381
386EDELIB_API const char* password(const char* fmt, const char* deflt = 0, ...);
387
388#ifndef SKIP_DOCS
389/*
390 * FLTK compatibility
391 */
392extern void (*fl_message)(const char* fmt, ...);
393extern void (*fl_alert)(const char* fmt, ...);
394extern int (*fl_ask)(const char* fmt, ...);
395extern const char* (*fl_input)(const char* fmt, const char* deflt, ...);
396extern const char* (*fl_password)(const char* fmt, const char* deflt, ...);
397#endif
398
399EDELIB_NS_END
400#endif
Standard dialog.
Definition: MessageBox.h:196
void set_text(const char *t)
bool set_theme_icon(const char *name)
void add_button(Fl_Button *b, MessageBoxButtonType bt=MSGBOX_BUTTON_PLAIN)
void themed_dialog_icons(const char *msg, const char *alert=0, const char *ask=0, const char *input=0, const char *password=0)
void set_xpm_icon(const char *const *arr)
void clear(MessageBoxType t=MSGBOX_PLAIN)
MessageBox(MessageBoxType t=MSGBOX_PLAIN)
static void clear_themed_icons(void)
int ask(const char *fmt,...)
void add_button(const char *l, MessageBoxButtonType bt=MSGBOX_BUTTON_PLAIN, Fl_Callback cb=0, void *param=0)
bool set_icon(const char *path)
void run_plain(bool center=true)
const char * input(const char *fmt, const char *deflt=0,...)
static void set_themed_icons(const char *msg, const char *alert=0, const char *ask=0, const char *input=0, const char *password=0)
int run(bool center=true)
void alert(const char *fmt,...)
void focus_button(int b)
void set_input(const char *txt)
void message(const char *fmt,...)
void set_icon_from_type(MessageBoxIconType type)
const char * password(const char *fmt, const char *deflt=0,...)
const char * get_input(void)
MessageBoxIconType
Type of the icon in message box.
Definition: MessageBox.h:68
MessageBoxButtonType
Type of added button to MessageBox class.
Definition: MessageBox.h:58
void clear_dialog_icons(void)
MessageBoxType
Type of MessageBox dialog.
Definition: MessageBox.h:47
@ MSGBOX_ICON_TYPE_INPUT
Input-like icon.
Definition: MessageBox.h:72
@ MSGBOX_ICON_TYPE_PASSWORD
Password-like icon.
Definition: MessageBox.h:73
@ MSGBOX_ICON_TYPE_QUESTION
Question-like icon.
Definition: MessageBox.h:71
@ MSGBOX_ICON_TYPE_ALERT
Alert-like icon.
Definition: MessageBox.h:70
@ MSGBOX_ICON_TYPE_INFO
Info-like icon.
Definition: MessageBox.h:69
@ MSGBOX_BUTTON_RETURN
Button with 'enter' shortcut (Fl_Return_Button)
Definition: MessageBox.h:60
@ MSGBOX_BUTTON_PLAIN
Ordinary button (Fl_Button)
Definition: MessageBox.h:59
@ MSGBOX_PLAIN
Plain dialog.
Definition: MessageBox.h:48
@ MSGBOX_INPUT
Dialog with input field.
Definition: MessageBox.h:49
@ MSGBOX_INPUT_SECRET
Dialog with secret input field.
Definition: MessageBox.h:50