📄 widgets.h
字号:
int bg; // text background color int hi; // border highlight color int lo; // border lowlight color void *mdfunc; // function to call when mouse button down within window void *mufunc; // function to call when mouse button up within window void *mmfunc; // function to call when mouse button motion within window void *kdfunc; // function to call on keypress void *kufunc; // function to call on keyrelease void *parent; BLIST *list; // buttons attached to window int response; // ALERT_CANCEL or ALERT_OK} ALERT;// Notice box widgettypedef struct { int type; // NoticeType int id; int x; // x location relative to parent int y; // y location relative to parent int w; // width int h; // height int fg; // text foreground color int bg; // text background color int hi; // border highlight color int lo; // border lowlight color void *mdfunc; // function to call when mouse button down within window void *mufunc; // function to call when mouse button up within window void *mmfunc; // function to call when mouse button motion within window void *kdfunc; // function to call on keypress void *kufunc; // function to call on keyrelease void *parent; BLIST *list; // buttons attached to window} NOTICE;typedef struct textList { char *str; int fg; int bg; struct textList *prev; struct textList *next;} TLIST;// Textbox widgettypedef struct { int type; // TextBoxType int id; int x; // x location relative to parent int y; // y location relative to parent int w; // width int h; // height int fg; // text foreground color int bg; // text background color int hi; // border highlight color int lo; // border lowlight color void *mdfunc; // function to call when mouse button down within window void *mufunc; // function to call when mouse button up within window void *mmfunc; // function to call when mouse button motion within window void *kdfunc; // function to call on keypress void *kufunc; // function to call on keyrelease void *parent; BLIST *list; TLIST *text; // start of text list int lines; // number of lines in text list int vlines; // number of lines visible at one time int line; // current line in text list int xoffset; // horizontal offset} TEXTBOX;typedef struct strList { char *str; struct strList *prev; struct strList *next;} SLIST;// Inputbox widgettypedef struct { int type; // InputBoxType int id; int x; // x location relative to parent int y; // y location relative to parent int w; // width int h; // height int fg; // text foreground color int bg; // text background color int hi; // border highlight color int lo; // border lowlight color void *mdfunc; // function to call when mouse button down within window void *mufunc; // function to call when mouse button up within window void *mmfunc; // function to call when mouse button motion within window void *kdfunc; // function to call on keypress void *kufunc; // function to call on keyrelease void *parent; BLIST *list; SLIST *text; // start of text list int lines; // number of lines in text list int vlines; // number of lines visible at one time int line; // current line in text list int cursorx; // cursor position in line int cursory; // cursor line in window bool cursorstate; // cursor on/off int mode; // insert/overwrite mode} INPUTBOX;// Vertical slider widgettypedef struct { int type; // VSliderType int id; int x; // x location relative to parent int y; // y location relative to parent int w; // width int h; // height int fg; // text foreground color int bg; // text background color int hi; // border highlight color int lo; // border lowlight color void *mdfunc; // function to call when mouse button down within window void *mufunc; // function to call when mouse button up within window void *mmfunc; // function to call when mouse button motion within window void *kdfunc; // function to call on keypress void *kufunc; // function to call on keyrelease void *parent; BLIST *list; // buttons attached to slider int size; // size of marker in pixels int position; // position of slider in pixels from top int pc; // percent = 0 -> 100 int range; // range of slider (resolution) int offset; // offset within range (0 -> range - 1) int change; // change when clicked in slider region bool drag; // true if dragging slider int state; // mouse state void *adjfunc; // function to call on auto adjustment} VSLIDER;// Horizontal slider widgettypedef struct { int type; // HSliderType int id; int x; // x location relative to parent int y; // y location relative to parent int w; // width int h; // height int fg; // text foreground color int bg; // text background color int hi; // border highlight color int lo; // border lowlight color void *mdfunc; // function to call when mouse button down within window void *mufunc; // function to call when mouse button up within window void *mmfunc; // function to call when mouse button motion within window void *kdfunc; // function to call on keypress void *kufunc; // function to call on keyrelease void *parent; BLIST *list; // buttons attached to slider int size; // size of marker in pixels int position; // position of slider in pixels from left end int pc; // percent = 0 -> 100 int range; // range of slider (resolution) int offset; // offset within range (0 -> range - 1) int change; // change when clicked in slider region bool drag; // true if dragging slider int state; // mouse state void *adjfunc; // function to call on auto adjustment} HSLIDER;// General Widget Structure// All widgets have the following headertypedef struct { int type; // type of widget int id; int x; // x location relative to parent int y; // y location relative to parent int w; // width int h; // height int fg; // text foreground color int bg; // text background color int hi; // border highlight color int lo; // border lowlight color void *mdfunc; // function to call when mouse button down within window void *mufunc; // function to call when mouse button up within window void *mmfunc; // function to call when mouse button motion within window void *kdfunc; // function to call on keypress void *kufunc; // function to call on keyrelease void *parent; // pointer to parent widget, if any} PARMS;typedef union { PARMS p; // common elements WINDOW window; // elements specific to widget types MENU menu; VMENU vmenu; BUTTON button; CHECKBOX checkbox; LABEL label; HLABEL hlabel; ALERT alert; NOTICE notice; TEXTBOX textbox; INPUTBOX inputbox;} WIDGET;typedef struct widgetList{ WIDGET *w; struct widgetList *next;} WLIST;// Global variablesextern unsigned char fontdata[];extern void *topWidget;extern Uint32 black; // 0extern Uint32 blue; // 1extern Uint32 green; // 2extern Uint32 cyan; // 3extern Uint32 red; // 4extern Uint32 magenta; // 5extern Uint32 brown; // 6extern Uint32 lgray; // 7extern Uint32 gray; // 8extern Uint32 lblue; // 9extern Uint32 lgreen; // 10extern Uint32 lcyan; // 11extern Uint32 lred; // 12extern Uint32 lmagenta; // 13extern Uint32 yellow; // 14extern Uint32 white; // 15extern Uint32 lyellow; // 16extern Uint32 dyellow; // 17extern Uint32 pink; // 18extern Uint32 dblue; // 19extern Uint32 dgreen; // 20extern bool popUpActive;extern WLIST *wlist;// Prototypesextern void initWidgets(void);extern void widgetQuit(void);extern void drawChar(int x, int y, int fg, int bg, char chr);extern void attachCallBack(void *w, int type, void *func);extern void removeCallBack(void *w, int type);extern void nullCallBack(void *w, ...);extern WINDOW *newWindow(int x, int y, int w, int h, int fg, int bg, int hi, int lo);extern MENU *newMenu(int x, int y, int w, int h, int fg, int bg, int hi, int lo);extern VMENU *newVMenu(int x, int y, int w, int h, int fg, int bg, int hi, int lo);extern BUTTON *newButton(int x, int y, int fg, int bg, int hi, int lo, char *text);extern CHECKBOX *newCheckBox(int x, int y, int fg, int bg, int hi, int lo, char *text, bool *val);extern LABEL *newLabel(int x, int y, int fg, int bg, int hi, int lo, char *text);extern HLABEL *newHLabel(int x, int y, int fg, int bg, int hi, int lo, char *text);extern ALERT *newAlertBox(int x, int y, char *text);extern NOTICE *newNoticeBox(int x, int y, char *text);extern TEXTBOX *newTextBox(int x, int y, int w, int h, int fg, int bg, int hi, int lo);extern INPUTBOX *newInputBox(int x, int y, int w, int h, int fg, int bg, int hi, int lo);extern VSLIDER *newVSlider(int x, int y, int w, int h, int fg, int bg, int hi, int lo, int range, int change);extern HSLIDER *newHSlider(int x, int y, int w, int h, int fg, int bg, int hi, int lo, int range, int change);extern void addCheckBox(void *w, CHECKBOX *checkbox, bool border);extern void addButton(void *w, BUTTON *button, bool border);extern void addLabel(void *w, LABEL *label, bool border);extern void addTextBox(void *w, TEXTBOX *tbox);extern void addText(TEXTBOX *tbox, char *str);extern void addTextEntry(TEXTBOX *tbox, char *str, int line);extern void addInputBox(void *w, INPUTBOX *ibox);extern void addInput(INPUTBOX *ibox, char *str);extern void addVSlider(void *w, VSLIDER *vs);extern void addHSlider(void *w, HSLIDER *hs);extern void removeTList(TEXTBOX *tbox);extern void removeTListEntry(TEXTBOX *tbox, int line);extern void toggleTextHighlight(TEXTBOX *tbox, int line);extern char *getText(TEXTBOX *tbox, int line);extern void setTListEntry(TEXTBOX *tbox, int line);extern void incTListEntry(TEXTBOX *tbox, int count);extern void decTListEntry(TEXTBOX *tbox, int count);extern void showWidget(void *w);extern void popUpWidget(void *w);extern void pushDownWidget(void *w);extern void updateScreen(void);extern void processCB(SDL_Event *ev);extern void dump_widget_list(void);#endif // _WIDGETS_H_// end of file
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -