📄 messagebox.cpp
字号:
#include "MessageBox.h"#include "alert_gui.h"#include <FL/Fl_Window.H>#include <FL/Fl_Box.H>#include <FL/Fl_Button.H>#include <FL/Fl_Input.H>#include <FL/Fl.H>#include <FL/fl_draw.H>#include <string.h>#include <stdio.h>#include <stdarg.h>#include <FL/Fl_Pixmap.H>#include "pic/tishi.xpm"#include "pic/yiwen.xpm"#define SCREEN_WIDTH 635#define SCREEN_HEIGHT 428static Fl_Pixmap pixmap_inform(tishi_xpm);static Fl_Pixmap pixmap_quest(yiwen_xpm);static int innards1(const char * fmt,const char *fl_ok,const char *fl_cancel,const char * title){ if (!message_form) message_form=(Fl_Window*)make_dialog_window(); message->label(fmt); if ((fl_ok)&&(!fl_cancel)) { message_form->label(title); message_form->resize((635-330)/2,(446-105)/2,330,105); message->position(80, 28); okButton->position(120,72); okButton->show(); okButton->label(fl_ok); dialog_icon->position(6,12); pixmap_inform.label(dialog_icon); } else okButton->hide(); if ((fl_ok)&&(fl_cancel)) { message_form->label(title); message_form->resize((635-330)/2,(446-105)/2,330,105); message_form->redraw(); message->position(65,28); cancelButton->show(); cancelButton->label(fl_cancel); cancelButton->position(165,72); okButton->show(); okButton->label(fl_ok); okButton->position(70,72); dialog_icon->position(6,12); pixmap_quest.label(dialog_icon); } else { cancelButton->hide(); } message_form->show(); int r; for (;;) { Fl_Widget *o = Fl::readqueue(); if (!o) Fl::wait(); else if (o == okButton) {r = 0; break;} else if (o == cancelButton) {r = 1; break;} else if (o == message_form) {r = 1; break;} } message_form->hide(); return r;}static const char* input_innards2(const char* fmt, const char *fl_ok,const char *fl_cancel,const char* defstr, uchar type,const char *title){ if (!message_form) message_form=(Fl_Window*)make_dialog_window(); message->label(fmt); message->resize(80,5,160, 25); input->type(type); input->show(); input->value(defstr); if ((fl_ok)&&(!fl_cancel)) { message_form->label(title); message_form->resize((635-330)/2,(446-105)/2,330,105); message->position(80, 15); okButton->position(120,72); okButton->show(); okButton->label(fl_ok); dialog_icon->position(6, 8); pixmap_inform.label(dialog_icon); } else okButton->hide(); if ((fl_ok)&&(fl_cancel)) { message_form->label(title); message_form->resize((635-330)/2,(446-105)/2,330,105); message_form->redraw(); message->position(65,15); cancelButton->show(); cancelButton->label(fl_cancel); cancelButton->position(165,72); okButton->show(); okButton->label(fl_ok); okButton->position(70,72); dialog_icon->position(6, 8); pixmap_quest.label(dialog_icon); } else { cancelButton->hide(); } message_form->show(); int r; for (;;) { Fl_Widget *o = Fl::readqueue(); if (!o) Fl::wait(); else if (o == okButton) {r = 0; break;} else if (o == cancelButton) {r = 1; break;} else if (o == message_form) {r = 1; break;} } message_form->hide(); input->hide(); message->resize(80,5,160, 25); return r ? 0 : input->value();}const char * fl_ok_ = "确定";const char * fl_cancel_ = "取消";void InformDlg( const char * fmt,const char * win_title){ innards1(fmt, fl_ok_, 0,win_title);}int QuestDlg(const char * fmt,const char * win_title){ int r = innards1(fmt,fl_ok_, fl_cancel_,win_title); return r;}const char * InputDlg( const char * fmt, const char * defstr,const char * win_title){ const char * r = input_innards2(fmt,fl_ok_, fl_cancel_, defstr, FL_NORMAL_INPUT,win_title); return r;}void cb_message_form(Fl_Window *,void *){ cancelButton->do_callback(cancelButton);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -