2 * Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
3 * Copyright (C) 2004-2009 Kim Woelders
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to
7 * deal in the Software without restriction, including without limitation the
8 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
9 * sell copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies of the Software, its documentation and marketing & publicity
14 * materials, and acknowledgment shall be given in the documentation, materials
15 * and software packages that this Software was used.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
21 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33 #define DITEM_BUTTON 1
34 #define DITEM_CHECKBUTTON 2
37 #define DITEM_SEPARATOR 5
39 #define DITEM_RADIOBUTTON 7
40 #define DITEM_SLIDER 8
43 /* Dialog button icons */
44 #define DLG_BUTTON_NONE 0
45 #define DLG_BUTTON_OK 1
46 #define DLG_BUTTON_CANCEL 2
47 #define DLG_BUTTON_APPLY 3
48 #define DLG_BUTTON_CLOSE 4
50 /* Dialog footer flags */
52 #define DLG_APPLY 0x02
53 #define DLG_CLOSE 0x04
54 #define DLG_NO_SEPARATOR 0x10
55 #define DLG_OC (DLG_OK | DLG_CLOSE)
56 #define DLG_OAC (DLG_OK | DLG_APPLY | DLG_CLOSE)
58 typedef struct _dialog Dialog;
59 typedef struct _ditem DItem;
61 typedef void (DialogCallbackFunc) (Dialog * d, int val, void *data);
62 typedef void (DialogItemCallbackFunc) (DItem * di, int val, void *data);
69 const char *header_image;
70 const char *header_text;
71 void (*fill) (Dialog * d, DItem * table, void *data);
73 DialogCallbackFunc *func;
77 Dialog *DialogCreate(const char *name);
78 Dialog *DialogFind(const char *name);
79 void DialogBindKey(Dialog * d, const char *key,
80 DialogCallbackFunc * func, int val,
82 void DialogSetTitle(Dialog * d, const char *title);
83 void DialogSetExitFunction(Dialog * d, DialogCallbackFunc * func,
85 void DialogCallExitFunction(Dialog * d);
86 void DialogSetData(Dialog * d, void *data);
87 void *DialogGetData(Dialog * d);
89 void DialogShow(Dialog * d);
90 void DialogShowCentered(Dialog * d);
91 void DialogRedraw(Dialog * d);
92 void DialogClose(Dialog * d);
94 void DialogArrange(Dialog * d, int resize);
95 void DialogKeybindingsDestroy(Dialog * d);
96 void DialogItemTableEmpty(DItem * di);
98 void DialogShowSimple(const DialogDef * dd, void *data);
99 void DialogShowSimpleWithName(const DialogDef * dd,
100 const char *name, void *data);
101 void DialogFill(Dialog * d, DItem * parent, const DialogDef * dd,
104 DItem *DialogInitItem(Dialog * d);
105 DItem *DialogAddItem(DItem * dii, int type);
106 Dialog *DialogItemGetDialog(DItem * di);
107 void DialogItemSetCallback(DItem * di, DialogCallbackFunc * func,
108 int val, void *data);
109 void DialogItemSetPadding(DItem * di, int left, int right,
110 int top, int bottom);
111 void DialogItemSetFill(DItem * di, char fill_h, char fill_v);
112 void DialogItemSetAlign(DItem * di, int align_h, int align_v);
113 void DialogItemSetText(DItem * di, const char *text);
114 void DialogItemCallCallback(Dialog * d, DItem * di);
115 void DialogDrawItems(Dialog * d, DItem * di, int x, int y, int w,
117 void DialogItemRadioButtonSetEventFunc(DItem * di,
118 DialogItemCallbackFunc *
120 void DialogItemCheckButtonSetState(DItem * di, char onoff);
121 void DialogItemCheckButtonSetPtr(DItem * di, char *onoff_ptr);
122 void DialogItemTableSetOptions(DItem * di, int num_columns,
123 char border, char homogenous_h,
125 void DialogItemSeparatorSetOrientation(DItem * di,
127 void DialogItemImageSetFile(DItem * di, const char *image);
128 void DialogItemSetRowSpan(DItem * di, int row_span);
129 void DialogItemSetColSpan(DItem * di, int col_span);
130 void DialogItemRadioButtonSetFirst(DItem * di, DItem * first);
131 void DialogItemRadioButtonGroupSetValPtr(DItem * di,
133 void DialogItemRadioButtonGroupSetVal(DItem * di, int val);
135 void DialogItemSliderSetVal(DItem * di, int val);
136 void DialogItemSliderSetBounds(DItem * di, int lower, int upper);
137 void DialogItemSliderSetUnits(DItem * di, int units);
138 void DialogItemSliderSetJump(DItem * di, int jump);
139 void DialogItemSliderSetMinLength(DItem * di, int min);
140 void DialogItemSliderSetValPtr(DItem * di, int *val_ptr);
141 void DialogItemSliderSetOrientation(DItem * di, char horizontal);
142 int DialogItemSliderGetVal(DItem * di);
143 void DialogItemSliderGetBounds(DItem * di, int *lower,
146 void DialogItemAreaSetSize(DItem * di, int w, int h);
147 void DialogItemAreaGetSize(DItem * di, int *w, int *h);
148 Win DialogItemAreaGetWindow(DItem * di);
149 void DialogItemAreaSetInitFunc(DItem * di,
150 DialogItemCallbackFunc * func);
151 void DialogItemAreaSetEventFunc(DItem * di,
152 DialogItemCallbackFunc * func);
154 DItem *DialogItemAddButton(DItem * parent, const char *text,
155 DialogCallbackFunc * func, int val,
156 char doclose, int image);
158 void DialogCallbackClose(Dialog * d, int val, void *data);
160 void DialogsInit(void);
162 #endif /* ENABLE_DIALOGS */
164 #endif /* _DIALOG_H_ */