📄 forms.h
字号:
//// "$Id: forms.H,v 1.2 2002/12/01 15:38:37 neurosurg Exp $"//// Forms emulation header file for the Fast Light Tool Kit (FLTK).//// Copyright 1998-2002 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 "Fl.H"#include "Fl_Group.H"#include "Fl_Window.H"#include "fl_draw.H"typedef Fl_Widget FL_OBJECT;typedef Fl_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 FL_BLACK#define FL_COL1 FL_GRAY#define FL_MCOL FL_LIGHT1#define FL_LEFT_BCOL FL_LIGHT3 // 53 is better match#define FL_TOP_BCOL FL_LIGHT2 // 51#define FL_BOTTOM_BCOL FL_DARK2 // 40#define FL_RIGHT_BCOL FL_DARK3 // 36#define FL_INACTIVE FL_INACTIVE_COLOR#define FL_INACTIVE_COL FL_INACTIVE_COLOR#define FL_FREE_COL1 FL_FREE_COLOR#define FL_FREE_COL2 ((Fl_Color)(FL_FREE_COLOR+1))#define FL_FREE_COL3 ((Fl_Color)(FL_FREE_COLOR+2))#define FL_FREE_COL4 ((Fl_Color)(FL_FREE_COLOR+3))#define FL_FREE_COL5 ((Fl_Color)(FL_FREE_COLOR+4))#define FL_FREE_COL6 ((Fl_Color)(FL_FREE_COLOR+5))#define FL_FREE_COL7 ((Fl_Color)(FL_FREE_COLOR+6))#define FL_FREE_COL8 ((Fl_Color)(FL_FREE_COLOR+7))#define FL_FREE_COL9 ((Fl_Color)(FL_FREE_COLOR+8))#define FL_FREE_COL10 ((Fl_Color)(FL_FREE_COLOR+9))#define FL_FREE_COL11 ((Fl_Color)(FL_FREE_COLOR+10))#define FL_FREE_COL12 ((Fl_Color)(FL_FREE_COLOR+11))#define FL_FREE_COL13 ((Fl_Color)(FL_FREE_COLOR+12))#define FL_FREE_COL14 ((Fl_Color)(FL_FREE_COLOR+13))#define FL_FREE_COL15 ((Fl_Color)(FL_FREE_COLOR+14))#define FL_FREE_COL16 ((Fl_Color)(FL_FREE_COLOR+15))#define FL_TOMATO ((Fl_Color)(131))#define FL_INDIANRED ((Fl_Color)(164))#define FL_SLATEBLUE ((Fl_Color)(195))#define FL_DARKGOLD ((Fl_Color)(84))#define FL_PALEGREEN ((Fl_Color)(157))#define FL_ORCHID ((Fl_Color)(203))#define FL_DARKCYAN ((Fl_Color)(189))#define FL_DARKTOMATO ((Fl_Color)(113))#define FL_WHEAT ((Fl_Color)(174))#define FL_ALIGN_BESIDE FL_ALIGN_INSIDE#define FL_PUP_TOGGLE 2 // FL_MENU_TOGGLE#define FL_PUP_INACTIVE 1 // FL_MENU_INACTIVE#define FL_NO_FRAME FL_NO_BOX#define FL_ROUNDED3D_UPBOX FL_ROUND_UP_BOX#define FL_ROUNDED3D_DOWNBOX FL_ROUND_DOWN_BOX#define FL_OVAL3D_UPBOX FL_ROUND_UP_BOX#define FL_OVAL3D_DOWNBOX FL_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 FL_HELVETICA#define FL_BOLD_STYLE FL_HELVETICA_BOLD#define FL_ITALIC_STYLE FL_HELVETICA_ITALIC#define FL_BOLDITALIC_STYLE FL_HELVETICA_BOLD_ITALIC#define FL_FIXED_STYLE FL_COURIER#define FL_FIXEDBOLD_STYLE FL_COURIER_BOLD#define FL_FIXEDITALIC_STYLE FL_COURIER_ITALIC#define FL_FIXEDBOLDITALIC_STYLE FL_COURIER_BOLD_ITALIC#define FL_TIMES_STYLE FL_TIMES#define FL_TIMESBOLD_STYLE FL_TIMES_BOLD#define FL_TIMESITALIC_STYLE FL_TIMES_ITALIC#define FL_TIMESBOLDITALIC_STYLE FL_TIMES_BOLD_ITALIC// hacks to change the labeltype() when passed to fl_set_object_lstyle():#define FL_SHADOW_STYLE (FL_SHADOW_LABEL<<8)#define FL_ENGRAVED_STYLE (FL_ENGRAVED_LABEL<<8)#define FL_EMBOSSED_STYLE (FL_EMBOSSED_LABEL<<0)// size values are different from XForms, match older Forms:#define FL_TINY_SIZE 8#define FL_SMALL_SIZE 11 // 10//#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_EXPORT 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, 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_EXPORT Fl_Widget* fl_do_forms(void);FL_EXPORT 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->labelsize(s);}inline void fl_set_object_lstyle(Fl_Widget* o,int a) { o->labelfont((uchar)a); o->labeltype((Fl_Labeltype)(a>>8));}inline void fl_set_object_lcol(Fl_Widget* o, unsigned a) {o->labelcolor(a);}#define fl_set_object_lcolor fl_set_object_lcolinline void fl_set_object_lalign(Fl_Widget* o, Fl_Align a) {o->align(a);}#define fl_set_object_align fl_set_object_laligninline void fl_set_object_color(Fl_Widget* o,unsigned a,unsigned b) {o->color(a,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((Fl_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;}FL_EXPORT void fl_end_form();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_end_group() {Fl_Group::current()->forms_end();}inline void fl_addto_group(Fl_Widget* o) {((Fl_Group* )o)->begin();}#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_geometry
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -