chiark / gitweb /
Imported Upstream version 1.0.0
[e16] / src / dialog.h
1 /*
2  * Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
3  * Copyright (C) 2004-2009 Kim Woelders
4  *
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:
11  *
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.
16  *
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.
23  */
24 #ifndef _DIALOG_H_
25 #define _DIALOG_H_
26
27 #include "config.h"
28
29 #if ENABLE_DIALOGS
30
31 /* Dialog items */
32 #define DITEM_NONE         0
33 #define DITEM_BUTTON       1
34 #define DITEM_CHECKBUTTON  2
35 #define DITEM_TEXT         3
36 #define DITEM_IMAGE        4
37 #define DITEM_SEPARATOR    5
38 #define DITEM_TABLE        6
39 #define DITEM_RADIOBUTTON  7
40 #define DITEM_SLIDER       8
41 #define DITEM_AREA         9
42
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
49
50 /* Dialog footer flags */
51 #define DLG_OK             0x01
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)
57
58 typedef struct _dialog Dialog;
59 typedef struct _ditem DItem;
60
61 typedef void        (DialogCallbackFunc) (Dialog * d, int val, void *data);
62 typedef void        (DialogItemCallbackFunc) (DItem * di, int val, void *data);
63
64 typedef struct {
65    const char         *name;
66    const char         *label;
67    const char         *title;
68    int                 sound;
69    const char         *header_image;
70    const char         *header_text;
71    void                (*fill) (Dialog * d, DItem * table, void *data);
72    int                 flags;
73    DialogCallbackFunc *func;
74 } DialogDef;
75
76 /* dialog.c */
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,
81                                   void *data);
82 void                DialogSetTitle(Dialog * d, const char *title);
83 void                DialogSetExitFunction(Dialog * d, DialogCallbackFunc * func,
84                                           int val);
85 void                DialogCallExitFunction(Dialog * d);
86 void                DialogSetData(Dialog * d, void *data);
87 void               *DialogGetData(Dialog * d);
88
89 void                DialogShow(Dialog * d);
90 void                DialogShowCentered(Dialog * d);
91 void                DialogRedraw(Dialog * d);
92 void                DialogClose(Dialog * d);
93
94 void                DialogArrange(Dialog * d, int resize);
95 void                DialogKeybindingsDestroy(Dialog * d);
96 void                DialogItemTableEmpty(DItem * di);
97
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,
102                                void *data);
103
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,
116                                     int h);
117 void                DialogItemRadioButtonSetEventFunc(DItem * di,
118                                                       DialogItemCallbackFunc *
119                                                       func);
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,
124                                               char homogenous_v);
125 void                DialogItemSeparatorSetOrientation(DItem * di,
126                                                       char horizontal);
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,
132                                                         int *val_ptr);
133 void                DialogItemRadioButtonGroupSetVal(DItem * di, int val);
134
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,
144                                               int *upper);
145
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);
153
154 DItem              *DialogItemAddButton(DItem * parent, const char *text,
155                                         DialogCallbackFunc * func, int val,
156                                         char doclose, int image);
157
158 void                DialogCallbackClose(Dialog * d, int val, void *data);
159
160 void                DialogsInit(void);
161
162 #endif /* ENABLE_DIALOGS */
163
164 #endif /* _DIALOG_H_ */