MessageBox.h
/*
* $Id: MessageBox.h 2839 2009-09-28 11:36:20Z karijes $
*
* Message dialog
* Copyright (c) 2005-2007 edelib authors
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __EDELIB_MESSAGEBOX_H__
#define __EDELIB_MESSAGEBOX_H__
#include "edelib-global.h"
#include <FL/Fl_Window.H>
#include <FL/Fl_Button.H>
#include <FL/Fl_Box.H>
#include <FL/Fl_Input.H>
#include <FL/Fl_Pixmap.H>
#define MSGBOX_MAX_BUTTONS 4 // Max buttons in dialog
#define MSGBOX_ICON_ERROR "dialog-error"
#define MSGBOX_ICON_INFO "dialog-information"
#define MSGBOX_ICON_PASSWORD "dialog-password"
#define MSGBOX_ICON_WARNING "dialog-warning"
#define MSGBOX_ICON_QUESTION "dialog-question"
EDELIB_NS_BEGIN
enum MessageBoxType {
MSGBOX_PLAIN = 0,
MSGBOX_INPUT,
MSGBOX_INPUT_SECRET
};
enum MessageBoxButtonType {
MSGBOX_BUTTON_PLAIN = 0,
MSGBOX_BUTTON_RETURN
};
enum MessageBoxIconType {
MSGBOX_ICON_TYPE_INFO = 0,
MSGBOX_ICON_TYPE_ALERT,
MSGBOX_ICON_TYPE_QUESTION,
MSGBOX_ICON_TYPE_INPUT,
MSGBOX_ICON_TYPE_PASSWORD
};
class EDELIB_API MessageBox : public Fl_Window {
private:
Fl_Box* img;
Fl_Box* txt;
Fl_Input* inpt;
Fl_Group* gr;
Fl_Pixmap* pix;
MessageBoxType mbt;
int nbuttons;
int b_start;
Fl_Button* buttons[MSGBOX_MAX_BUTTONS];
void init(void);
void fix_sizes(void);
void add(Fl_Widget*) { } // in case someone tries to be too smart
public:
MessageBox(MessageBoxType t = MSGBOX_PLAIN);
~MessageBox();
void set_text(const char* t);
bool set_icon(const char* path);
bool set_theme_icon(const char* name);
void set_xpm_icon(const char* const* arr);
void set_icon_from_type(MessageBoxIconType type);
const char* get_input(void);
void set_input(const char* txt);
void focus_button(int b);
void add_button(Fl_Button* b, MessageBoxButtonType bt = MSGBOX_BUTTON_PLAIN);
void add_button(const char* l, MessageBoxButtonType bt = MSGBOX_BUTTON_PLAIN, Fl_Callback cb = 0, void* param = 0);
void clear(MessageBoxType t = MSGBOX_PLAIN);
void run_plain(bool center = true);
int run(bool center = true);
static void set_themed_icons(const char* msg, const char* alert = 0, const char* ask = 0,
const char* input = 0, const char* password = 0);
static void clear_themed_icons(void);
};
EDELIB_API void themed_dialog_icons(const char* msg, const char* alert = 0,
const char* ask = 0, const char* input = 0, const char* password = 0) EDELIB_DEPRECATED;
EDELIB_API void clear_dialog_icons(void) EDELIB_DEPRECATED;
EDELIB_API void message(const char* fmt, ...);
EDELIB_API void alert(const char* fmt, ...);
EDELIB_API int ask(const char* fmt, ...);
EDELIB_API const char* input(const char* fmt, const char* deflt = 0, ...);
EDELIB_API const char* password(const char* fmt, const char* deflt = 0, ...);
#ifndef SKIP_DOCS
/*
* FLTK compatibility
*/
extern void (*fl_message)(const char* fmt, ...);
extern void (*fl_alert)(const char* fmt, ...);
extern int (*fl_ask)(const char* fmt, ...);
extern const char* (*fl_input)(const char* fmt, const char* deflt, ...);
extern const char* (*fl_password)(const char* fmt, const char* deflt, ...);
#endif
EDELIB_NS_END
#endif
edelib::MSGBOX_BUTTON_RETURN
Button with &#39;enter&#39; shortcut (Fl_Return_Button)
Definition: MessageBox.h:60
edelib::MSGBOX_ICON_TYPE_INFO
Info-like icon.
Definition: MessageBox.h:69
edelib::MSGBOX_ICON_TYPE_ALERT
Alert-like icon.
Definition: MessageBox.h:70
edelib::clear_dialog_icons
void clear_dialog_icons(void)
edelib::MessageBoxButtonType
MessageBoxButtonType
Type of added button to MessageBox class.
Definition: MessageBox.h:58
edelib::MSGBOX_ICON_TYPE_QUESTION
Question-like icon.
Definition: MessageBox.h:71
edelib::MSGBOX_BUTTON_PLAIN
Ordinary button (Fl_Button)
Definition: MessageBox.h:59
edelib::MessageBoxType
MessageBoxType
Type of MessageBox dialog.
Definition: MessageBox.h:47
edelib::MSGBOX_INPUT_SECRET
Dialog with secret input field.
Definition: MessageBox.h:50
edelib::MessageBoxIconType
MessageBoxIconType
Type of the icon in message box.
Definition: MessageBox.h:68
edelib::MSGBOX_PLAIN
Plain dialog.
Definition: MessageBox.h:48
edelib::MSGBOX_ICON_TYPE_INPUT
Input-like icon.
Definition: MessageBox.h:72
edelib::MSGBOX_ICON_TYPE_PASSWORD
Password-like icon.
Definition: MessageBox.h:73
edelib::MSGBOX_INPUT
Dialog with input field.
Definition: MessageBox.h:49
edelib::MessageBox
Standard dialog.
Definition: MessageBox.h:196