1 /*	Public domain	*/
2 
3 #ifndef _AGAR_WIDGET_COMBO_H_
4 #define _AGAR_WIDGET_COMBO_H_
5 
6 #include <agar/gui/widget.h>
7 #include <agar/gui/textbox.h>
8 #include <agar/gui/button.h>
9 #include <agar/gui/window.h>
10 #include <agar/gui/tlist.h>
11 
12 #include <agar/gui/begin.h>
13 
14 typedef struct ag_combo {
15 	struct ag_widget wid;
16 	Uint flags;
17 #define AG_COMBO_POLL	  	0x01	/* Polled list */
18 #define AG_COMBO_TREE	  	0x02	/* Tree display */
19 #define AG_COMBO_ANY_TEXT 	0x04	/* Accept text not matching an item */
20 #define AG_COMBO_HFILL	  	0x08
21 #define AG_COMBO_VFILL	  	0x10
22 #define AG_COMBO_SCROLLTOSEL	0x40	/* Scroll to initial selection */
23 #define AG_COMBO_EXPAND	  (AG_COMBO_HFILL|AG_COMBO_VFILL)
24 
25 	AG_Textbox *tbox;		/* Text input */
26 	AG_Button *button;		/* [...] button */
27 	AG_Tlist *list;			/* List of items */
28 	AG_Window *panel;
29 	int wSaved, hSaved;		/* Saved popup list geometry */
30 	int wPreList, hPreList;		/* Size hints */
31 } AG_Combo;
32 
33 #define AG_COMBO_FOREACH(it, com) \
34 	AG_TLIST_FOREACH(it, (com)->list)
35 #define AG_COMBO_FOREACH_ITEM(p, com, it, t) \
36 	AG_TLIST_FOREACH_ITEM((p),(com)->list, it, t)
37 
38 __BEGIN_DECLS
39 extern AG_WidgetClass agComboClass;
40 
41 AG_Combo *AG_ComboNew(void *, Uint, const char *, ...)
42 		      FORMAT_ATTRIBUTE(printf, 3, 4);
43 AG_Combo *AG_ComboNewS(void *, Uint, const char *);
44 
45 void AG_ComboSizeHint(AG_Combo *, const char *, int);
46 void AG_ComboSizeHintPixels(AG_Combo *, int, int);
47 void AG_ComboSelect(AG_Combo *, AG_TlistItem *);
48 AG_TlistItem *AG_ComboSelectPointer(AG_Combo *, void *);
49 AG_TlistItem *AG_ComboSelectText(AG_Combo *, const char *);
50 void AG_ComboSetButtonText(AG_Combo *, const char *);
51 void AG_ComboSetButtonSurface(AG_Combo *, AG_Surface *);
52 void AG_ComboSetButtonSurfaceNODUP(AG_Combo *, AG_Surface *);
53 __END_DECLS
54 
55 #include <agar/gui/close.h>
56 #endif /* _AGAR_WIDGET_COMBO_H_ */
57