📄 forms.h
字号:
//// "$Id: forms.H 4886 2006-03-30 09:55:32Z fabien $"//// Forms emulation header file for the Fast Light Tool Kit (FLTK).//// Copyright 1998-2006 by Bill Spitzak and others.//// This library is free software; you can redistribute it and/or// modify it under the terms of the GNU Library 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// Library General Public License for more details.//// You should have received a copy of the GNU Library General Public// License along with this library; if not, write to the Free Software// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307// USA.//// Please report all bugs and problems to "fltk-bugs@fltk.org".//#ifndef __FORMS_H__#define __FORMS_H__#include <fltk/Window.h>#include <fltk/run.h>#include <fltk/draw.h>#include <fltk/Color.h>#include <fltk/Style.h>typedef fltk::Widget FL_OBJECT;typedef fltk::Window FL_FORM;////////////////////////////////////////////////////////////////// Random constants & symbols defined by forms.h file:#ifndef NULL#define NULL 0#endif#ifndef FALSE#define FALSE 0#define TRUE 1#endif#define FL_ON 1#define FL_OK 1#define FL_VALID 1#define FL_PREEMPT 1#define FL_AUTO 2#define FL_WHEN_NEEDED FL_AUTO#define FL_OFF 0#define FL_NONE 0#define FL_CANCEL 0#define FL_INVALID 0#define FL_IGNORE -1#define FL_CLOSE -2#define FL_LCOL fltk::BLACK#define FL_COL1 fltk::GRAY75#define FL_MCOL fltk::GRAY85#define FL_LEFT_BCOL fltk::GRAY99#define FL_TOP_BCOL fltk::GRAY90#define FL_BOTTOM_BCOL fltk::GRAY35#define FL_RIGHT_BCOL fltk::GRAY20#define FL_INACTIVE fltk::GRAY66#define FL_INACTIVE_COL fltk::GRAY66#define FL_FREE_COL1 fltk::Color(16)#define FL_FREE_COL2 fltk::Color(17)#define FL_FREE_COL3 fltk::Color(18)#define FL_FREE_COL4 fltk::Color(19)#define FL_FREE_COL5 fltk::Color(20)#define FL_FREE_COL6 fltk::Color(21)#define FL_FREE_COL7 fltk::Color(22)#define FL_FREE_COL8 fltk::Color(23)#define FL_FREE_COL9 fltk::Color(24)#define FL_FREE_COL10 fltk::Color(25)#define FL_FREE_COL11 fltk::Color(26)#define FL_FREE_COL12 fltk::Color(27)#define FL_FREE_COL13 fltk::Color(28)#define FL_FREE_COL14 fltk::Color(29)#define FL_FREE_COL15 fltk::Color(30)#define FL_FREE_COL16 fltk::Color(31)#define FL_TOMATO fltk::Color(131)#define FL_INDIANRED fltk::Color(164)#define FL_SLATEBLUE fltk::Color(195)#define FL_DARKGOLD fltk::Color(84)#define FL_PALEGREEN fltk::Color(157)#define FL_ORCHID fltk::Color(203)#define FL_DARKCYAN fltk::Color(189)#define FL_DARKTOMATO fltk::Color(113)#define FL_WHEAT fltk::Color(174)#define FL_ALIGN_BESIDE fltk::ALIGN_INSIDE#define FL_PUP_TOGGLE 2 // FL_MENU_TOGGLE#define FL_PUP_INACTIVE 1 // FL_MENU_INACTIVE#define FL_NO_FRAME fltk::NO_BOX#define FL_ROUNDED3D_UPBOX fltk::ROUND_UP_BOX#define FL_ROUNDED3D_DOWNBOX fltk::ROUND_DOWN_BOX#define FL_OVAL3D_UPBOX fltk::ROUND_UP_BOX#define FL_OVAL3D_DOWNBOX fltk::ROUND_DOWN_BOX#define FL_MBUTTON1 1#define FL_LEFTMOUSE 1#define FL_MBUTTON2 2#define FL_MIDDLEMOUSE 2#define FL_MBUTTON3 3#define FL_RIGHTMOUSE 3#define FL_MBUTTON4 4#define FL_MBUTTON5 5#define FL_INVALID_STYLE 255#define FL_NORMAL_STYLE 0#define FL_BOLD_STYLE 1#define FL_ITALIC_STYLE 2#define FL_BOLDITALIC_STYLE 3#define FL_FIXED_STYLE 4#define FL_FIXEDBOLD_STYLE 5#define FL_FIXEDITALIC_STYLE 6#define FL_FIXEDBOLDITALIC_STYLE 7#define FL_TIMES_STYLE 8#define FL_TIMESBOLD_STYLE 9#define FL_TIMESITALIC_STYLE 10#define FL_TIMESBOLDITALIC_STYLE 11// hacks to change the labeltype() when passed to fl_set_object_lstyle():#define FL_SHADOW_STYLE 0x100#define FL_ENGRAVED_STYLE 0x200#define FL_EMBOSSED_STYLE 0x300// size values are different from XForms, match older Forms:#define FL_TINY_SIZE 8#define FL_SMALL_SIZE 11 // 10#undef FL_NORMAL_SIZE#define FL_NORMAL_SIZE 14 // 12#define FL_MEDIUM_SIZE 18 // 14#define FL_LARGE_SIZE 24 // 18#define FL_HUGE_SIZE 32 // 24#define FL_DEFAULT_SIZE FL_SMALL_SIZE#define FL_TINY_FONT FL_TINY_SIZE#define FL_SMALL_FONT FL_SMALL_SIZE#define FL_NORMAL_FONT FL_NORMAL_SIZE#define FL_MEDIUM_FONT FL_MEDIUM_SIZE#define FL_LARGE_FONT FL_LARGE_SIZE#define FL_HUGE_FONT FL_HUGE_SIZE#define FL_NORMAL_FONT1 FL_SMALL_FONT#define FL_NORMAL_FONT2 FL_NORMAL_FONT#define FL_DEFAULT_FONT FL_SMALL_FONT#define FL_RETURN_END_CHANGED FL_WHEN_RELEASE#define FL_RETURN_CHANGED FL_WHEN_CHANGED#define FL_RETURN_END FL_WHEN_RELEASE_ALWAYS#define FL_RETURN_ALWAYS (FL_WHEN_CHANGED|FL_WHEN_NOT_CHANGED)#define FL_BOUND_WIDTH 3typedef int FL_Coord;typedef int FL_COLOR;////////////////////////////////////////////////////////////////// fltk interaction:#define FL_CMD_OPT voidextern FL_FORMS_API void fl_initialize(int*, char*[], const char*, FL_CMD_OPT*, int);inline void fl_finish() {}typedef void (*FL_IO_CALLBACK) (int, void*);inline void fl_add_io_callback(int fd, short w, FL_IO_CALLBACK cb, void* v) { Fl::add_fd(fd,w,cb,v);}inline void fl_remove_io_callback(int fd, short, FL_IO_CALLBACK) { Fl::remove_fd(fd);} // removes all the callbacks!// type of callback is different and no "id" number is returned:inline void fl_add_timeout(long msec, void (*cb)(void*), void* v) { Fl::add_timeout(msec*.001, (Fl_Timeout_Handler)cb, v);}inline void fl_remove_timeout(int) {}// type of callback is different!inline void fl_set_idle_callback(void (*cb)()) {Fl::set_idle(cb);}FL_FORMS_API Fl_Widget* fl_do_forms(void);FL_FORMS_API Fl_Widget* fl_check_forms();inline Fl_Widget* fl_do_only_forms(void) {return fl_do_forms();}inline Fl_Widget* fl_check_only_forms(void) {return fl_check_forms();}// because of new redraw behavior, these are no-ops:inline void fl_freeze_object(Fl_Widget*) {}inline void fl_unfreeze_object(Fl_Widget*) {}inline void fl_freeze_form(Fl_Window*) {}inline void fl_unfreeze_form(Fl_Window*) {}inline void fl_freeze_all_forms() {}inline void fl_unfreeze_all_forms() {}inline void fl_set_focus_object(Fl_Window*, Fl_Widget* o) {Fl::focus(o);}inline void fl_reset_focus_object(Fl_Widget* o) {Fl::focus(o);}#define fl_set_object_focus fl_set_focus_object// void fl_set_form_atclose(Fl_Window*w,int (*cb)(Fl_Window*,void*),void* v)// void fl_set_atclose(int (*cb)(Fl_Window*,void*),void*)// fl_set_form_atactivate/atdeactivate not implemented!////////////////////////////////////////////////////////////////// Fl_Widget:inline void fl_set_object_boxtype(Fl_Widget* o, Fl_Boxtype a) {o->box(a);}inline void fl_set_object_lsize(Fl_Widget* o,int s) {o->label_size(s);}FL_FORMS_API void fl_set_object_lstyle(Fl_Widget* o,int a);inline void fl_set_object_lcol(Fl_Widget* o, unsigned a) {o->label_color((Fl_Color)a);}#define fl_set_object_lcolor fl_set_object_lcolinline void fl_set_object_lalign(Fl_Widget* o, Fl_Align a) { o->clear_flag(FL_ALIGN_MASK); o->set_flag(a);}#define fl_set_object_align fl_set_object_laligninline void fl_set_object_color(Fl_Widget* o,unsigned a,unsigned b) {o->color((Fl_Color)a); o->selection_color((Fl_Color)b);}inline void fl_set_object_label(Fl_Widget* o, const char* a) {o->label(a); o->redraw();}inline void fl_set_object_position(Fl_Widget*o,int x,int y) {o->position(x,y);}inline void fl_set_object_size(Fl_Widget* o, int w, int h) {o->size(w,h);}inline void fl_set_object_geometry(Fl_Widget* o,int x,int y,int w,int h) {o->resize(x,y,w,h);}inline void fl_get_object_geometry(Fl_Widget* o,int*x,int*y,int*w,int*h) { *x = o->x(); *y = o->y(); *w = o->w(); *h = o->h();}inline void fl_get_object_position(Fl_Widget* o,int*x,int*y) { *x = o->x(); *y = o->y();}typedef void (*Forms_CB)(Fl_Widget*, long);inline void fl_set_object_callback(Fl_Widget*o,Forms_CB c,long a) {o->callback(c,a);}#define fl_set_call_back fl_set_object_callbackinline void fl_call_object_callback(Fl_Widget* o) {o->do_callback();}inline void fl_trigger_object(Fl_Widget* o) {o->do_callback();}inline void fl_set_object_return(Fl_Widget* o, int v) { o->when(v|FL_WHEN_RELEASE);}inline void fl_redraw_object(Fl_Widget* o) {o->redraw();}inline void fl_show_object(Fl_Widget* o) {o->show();}inline void fl_hide_object(Fl_Widget* o) {o->hide();}inline void fl_free_object(Fl_Widget* x) {delete x;}inline void fl_delete_object(Fl_Widget* o) {((Fl_Group*)(o->parent()))->remove(*o);}inline void fl_activate_object(Fl_Widget* o) {o->activate();}inline void fl_deactivate_object(Fl_Widget* o) {o->deactivate();}inline void fl_add_object(Fl_Window* f, Fl_Widget* x) {f->add(x);}inline void fl_insert_object(Fl_Widget* o, Fl_Widget* b) { ((Fl_Group*)(b->parent()))->insert(*o,b);}inline Fl_Window* FL_ObjWin(Fl_Widget* o) {return o->window();}////////////////////////////////////////////////////////////////// things that appered in the demos a lot that I don't emulate, but// I did not want to edit out of all the demos...inline int fl_get_border_width() {return 3;}inline void fl_set_border_width(int) {}inline void fl_set_object_dblbuffer(Fl_Widget*, int) {}inline void fl_set_form_dblbuffer(Fl_Window*, int) {}////////////////////////////////////////////////////////////////// Fl_Window:inline void fl_free_form(Fl_Window* x) {delete x;}inline void fl_redraw_form(Fl_Window* f) {f->redraw();}inline Fl_Window* fl_bgn_form(Fl_Boxtype b,int w,int h) { Fl_Window* g = new Fl_Window(w,h,0); g->box(b); return g;}inline void fl_addto_form(Fl_Window* f) {f->begin();}inline Fl_Group* fl_bgn_group() {return new Fl_Group(0,0,0,0,0);}inline void fl_addto_group(Fl_Widget* o) {((Fl_Group* )o)->begin();}FL_FORMS_API void fl_end_group();FL_FORMS_API void fl_end_form();#define resizebox _ddfdesign_kludge()inline void fl_scale_form(Fl_Window* f, double x, double y) { f->resizable(f); f->size(int(f->w()*x),int(f->h()*y));}inline void fl_set_form_position(Fl_Window* f,int x,int y) {f->position(x,y);}inline void fl_set_form_size(Fl_Window* f, int w, int h) {f->size(w,h);}inline void fl_set_form_geometry(Fl_Window* f,int x,int y,int w,int h) { f->resize(x,y,w,h);}#define fl_set_initial_placement fl_set_form_geometryinline void fl_adjust_form_size(Fl_Window*) {}FL_FORMS_API void fl_show_form(Fl_Window* f,int p,int b,const char* n);enum { // "p" argument values:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -