1 /* Public domain */ 2 3 #ifndef _AGAR_WIDGET_TOOLBAR_H_ 4 #define _AGAR_WIDGET_TOOLBAR_H_ 5 6 #include <agar/gui/widget.h> 7 #include <agar/gui/box.h> 8 #include <agar/gui/button.h> 9 10 #include <agar/gui/begin.h> 11 12 #define AG_TOOLBAR_MAX_ROWS 8 13 14 enum ag_toolbar_type { 15 AG_TOOLBAR_HORIZ, 16 AG_TOOLBAR_VERT 17 }; 18 19 typedef struct ag_toolbar { 20 struct ag_box box; 21 struct ag_box *rows[AG_TOOLBAR_MAX_ROWS]; 22 enum ag_toolbar_type type; 23 int nRows; /* Number of rows */ 24 int nButtons; /* Total number of buttons */ 25 int curRow; /* Current row index */ 26 Uint flags; 27 #define AG_TOOLBAR_HOMOGENOUS 0x01 /* Scale buttons homogenously */ 28 #define AG_TOOLBAR_STICKY 0x02 /* Single toggle selection */ 29 #define AG_TOOLBAR_MULTI_STICKY 0x04 /* Multiple toggle selections */ 30 #define AG_TOOLBAR_HFILL 0x08 31 #define AG_TOOLBAR_VFILL 0x10 32 #define AG_TOOLBAR_EXPAND (AG_TOOLBAR_HFILL|AG_TOOLBAR_VFILL) 33 } AG_Toolbar; 34 35 __BEGIN_DECLS 36 extern AG_WidgetClass agToolbarClass; 37 38 AG_Toolbar *AG_ToolbarNew(void *, enum ag_toolbar_type, int, Uint); 39 void AG_ToolbarInit(AG_Toolbar *, enum ag_toolbar_type, int, Uint); 40 void AG_ToolbarScale(void *, int, int); 41 void AG_ToolbarRow(AG_Toolbar *, int); 42 AG_Button *AG_ToolbarButton(AG_Toolbar *, const char *, int, 43 void (*)(AG_Event *), const char *, ...); 44 AG_Button *AG_ToolbarButtonIcon(AG_Toolbar *, AG_Surface *, int, 45 void (*)(AG_Event *), const char *, ...); 46 void AG_ToolbarSeparator(AG_Toolbar *); 47 void AG_ToolbarSelect(AG_Toolbar *, AG_Button *); 48 void AG_ToolbarDeselect(AG_Toolbar *, AG_Button *); 49 void AG_ToolbarSelectOnly(AG_Toolbar *, AG_Button *); 50 void AG_ToolbarSelectAll(AG_Toolbar *); 51 void AG_ToolbarDeselectAll(AG_Toolbar *); 52 __END_DECLS 53 54 #include <agar/gui/close.h> 55 #endif /* _AGAR_WIDGET_TOOLBAR_H_ */ 56