Added CreateFileSelectionFilter
[grace.git] / src / widgets.h
blob5e89672773506fb3f47eb1b412593391fe37831c
1 /*
2 * Grace - GRaphing, Advanced Computation and Exploration of data
4 * Home page: http://plasma-gate.weizmann.ac.il/Grace/
6 * Copyright (c) 2012 Grace Development Team
8 * Maintained by Evgeny Stambulchik
11 * All Rights Reserved
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 /* Widgets */
30 #ifndef __WIDGETS_H_
31 #define __WIDGETS_H_
33 #include <config.h>
35 #ifdef MOTIF_GUI
36 /* for Widget */
37 #include <X11/Intrinsic.h>
38 #endif /* MOTIF_GUI */
40 #ifdef QT_GUI
41 #include "qtgui/qtinc.h"
42 #endif /* QT_GUI */
44 /* Widgets */
45 void WidgetManage(Widget w);
46 void WidgetUnmanage(Widget w);
47 int WidgetIsManaged(Widget w);
48 void *WidgetGetUserData(Widget w);
49 void WidgetSetUserData(Widget w, void *udata);
50 void WidgetSetSensitive(Widget w, int onoff);
51 void WidgetSetFocus(Widget w);
52 void WidgetSetWidth(Widget w, unsigned int width);
53 void WidgetSetHeight(Widget w, unsigned int height);
54 void WidgetSetSize(Widget w, unsigned int width, unsigned int height);
55 void WidgetGetSize(Widget w, unsigned int *width, unsigned int *height);
57 typedef void (*Key_CBProc)(void *anydata);
58 typedef struct {
59 Widget w;
60 int modifiers;
61 int key;
62 Key_CBProc cbproc;
63 void *anydata;
64 } Key_CBData;
66 void AddWidgetKeyPressCB(Widget w, int key, Key_CBProc cbproc, void *anydata);
67 void AddWidgetKeyPressCB2(Widget w, int modifiers, int key, Key_CBProc cbproc, void *anydata);
69 typedef struct _Widget_CBData Widget_CBData;
70 typedef void (*Widget_CBProc)(Widget_CBData *wcbdata);
71 struct _Widget_CBData {
72 Widget w;
73 Widget_CBProc cbproc;
74 void *anydata;
75 void *calldata;
77 void AddWidgetCB(Widget w, const char *callback, Widget_CBProc cbproc, void *anydata);
79 /* Dialog Window */
80 Widget CreateDialogWindow(Widget parent, const char *s);
82 /* Dialog */
83 Widget CreateDialog(Widget parent, const char *s);
84 void DialogRaise(Widget form);
85 void DialogClose(Widget form);
86 void DialogSetResizable(Widget form, int onoff);
88 /* File selection box */
89 Widget CreateFileSelectionBox(Widget parent);
91 /* File selection filter */
92 void CreateFileSelectionFilter(Widget parent, Widget fsb);
94 /* File selection dialog */
95 typedef struct {
96 Widget FSB;
97 Widget rc;
98 } FSBStructure;
99 FSBStructure *CreateFSBDialog(Widget parent, char *s);
101 typedef int (*FSB_CBProc)(
102 FSBStructure *fsbp,
103 char *, /* filename */
104 void * /* data the application registered */
106 void AddFSBDialogCB(FSBStructure *fsbp, FSB_CBProc cbproc, void *anydata);
107 void FSBDialogSetPattern(FSBStructure *fsb, char *pattern);
108 void FSBDialogSetDirectory(FSBStructure *fsb, char *directory);
110 /* Containers */
111 Widget CreateVContainer(Widget parent);
112 Widget CreateHContainer(Widget parent);
114 /* Form */
115 Widget CreateForm(Widget parent);
116 void FormAddHChild(Widget form, Widget child);
117 void FormAddVChild(Widget form, Widget child);
118 void FormFixateHChild(Widget w);
119 void FormFixateVChild(Widget w);
121 /* Grid */
122 Widget CreateGrid(Widget parent, int ncols, int nrows);
123 void PlaceGridChild(Widget grid, Widget w, int col, int row);
125 /* Frame */
126 Widget CreateFrame(Widget parent, char *s);
128 /* Scrolled window */
129 Widget CreateScrolledWindow(Widget parent);
131 /* Paned window */
132 Widget CreatePanedWindow(Widget parent);
133 void PanedWindowSetMinWidth(Widget w, unsigned int width);
135 /* Tab */
136 Widget CreateTab(Widget parent);
137 Widget CreateTabPage(Widget parent, char *s);
138 void SelectTabPage(Widget tab, Widget w);
140 /* Separator */
141 Widget CreateSeparator(Widget parent);
143 /* Label */
144 Widget CreateLabel(Widget parent, char *s);
145 void LabelSetString(Widget w, char *s);
146 void LabelSetPixmap(Widget w, int width, int height, const unsigned char *bits);
148 /* Text */
149 Widget CreateLineTextEdit(Widget parent, int len);
150 Widget CreateMultiLineTextEdit(Widget parent, int nrows);
152 typedef struct {
153 Widget label;
154 Widget form;
155 Widget text;
156 int locked;
157 } TextStructure;
159 void TextSetLength(TextStructure *cst, int len);
160 char *TextGetString(TextStructure *cst);
161 void TextSetString(TextStructure *cst, char *s);
163 typedef int (*TextValidate_CBProc)(
164 char **value,
165 int *length,
166 void *data
168 void AddTextValidateCB(TextStructure *cst, TextValidate_CBProc cbproc, void *anydata);
169 int TextGetCursorPos(TextStructure *cst);
170 void TextSetCursorPos(TextStructure *cst, int pos);
171 int TextGetLastPosition(TextStructure *cst);
172 void TextInsert(TextStructure *cst, int pos, char *s);
173 void TextSetEditable(TextStructure *cst, int onoff);
175 /* Button */
176 typedef void (*Button_CBProc)(
177 Widget but,
178 void * /* data the application registered */
180 Widget CreateButton(Widget parent, char *label);
181 Widget CreateBitmapButton(Widget parent,
182 int width, int height, const unsigned char *bits);
184 #define ARROW_UP 1
185 #define ARROW_DOWN 2
186 Widget CreateArrowButton(Widget parent, int arrow_type);
188 /* ToggleButton */
189 typedef void (*TB_CBProc)(
190 Widget but,
191 int onoff, /* True/False */
192 void * /* data the application registered */
194 Widget CreateToggleButton(Widget parent, char *s);
195 int GetToggleButtonState(Widget w);
196 void SetToggleButtonState(Widget w, int value);
198 /* Scale */
199 Widget CreateScale(Widget parent, char *s, int min, int max, int delta);
200 void SetScaleValue(Widget w, int value);
201 int GetScaleValue(Widget w);
203 /* SpinChoice */
204 typedef struct {
205 int type;
206 double min;
207 double max;
208 double incr;
209 Widget rc;
210 Widget text;
211 Widget arrow_up;
212 Widget arrow_down;
213 } SpinStructure;
214 SpinStructure *CreateSpinChoice(Widget parent, char *s, int len,
215 int type, double min, double max, double incr);
216 double GetSpinChoice(SpinStructure *spinp);
217 void SetSpinChoice(SpinStructure *spinp, double value);
219 typedef void (*Spin_CBProc)(
220 SpinStructure *spinp,
221 double, /* value of spinner */
222 void * /* data the application registered */
224 void AddSpinChoiceCB(SpinStructure *spinp, Spin_CBProc cbproc, void *data);
226 /* OptionChoice */
227 typedef struct _OptionStructure OptionStructure;
228 typedef struct {
229 int value;
230 char *label;
231 } OptionItem;
232 OptionStructure *CreateOptionChoice(Widget parent, char *labelstr, int ncols,
233 int nchoices, OptionItem *items);
234 OptionStructure *CreateOptionChoiceVA(Widget parent, char *labelstr, ...);
235 int GetOptionChoice(OptionStructure *opt);
236 void UpdateOptionChoice(OptionStructure *optp, int nchoices, OptionItem *items);
238 typedef void (*OC_CBProc)(
239 OptionStructure *opt,
240 int value, /* value */
241 void * /* data the application registered */
244 typedef struct {
245 int value;
246 Widget widget;
247 } OptionWidgetItem;
249 typedef struct {
250 OptionStructure *opt;
251 OC_CBProc cbproc;
252 void *anydata;
253 } OC_CBdata;
255 struct _OptionStructure {
256 int nchoices;
257 int ncols; /* preferred number of columns */
258 Widget menu;
259 Widget pulldown;
260 OptionWidgetItem *options;
262 unsigned int cbnum;
263 OC_CBdata **cblist;
265 void AddOptionChoiceCB(OptionStructure *opt, OC_CBProc cbproc, void *anydata);
267 /* Menu */
268 Widget CreatePopupMenu(Widget parent);
269 void PopupMenuShow(Widget w, void *data);
270 Widget CreateMenuBar(Widget parent);
271 Widget CreateMenu(Widget parent, char *label, char mnemonic, int help);
272 Widget CreateMenuButton(Widget parent, char *label, char mnemonic,
273 Button_CBProc cb, void *data);
274 Widget CreateMenuButtonA(Widget parent, char *label, char mnemonic,
275 char *accelerator, char* acceleratorText, Button_CBProc cb, void *data);
276 Widget CreateMenuHelpButton(Widget parent, char *label, char mnemonic,
277 Widget form, char *ha);
278 Widget CreateMenuToggle(Widget parent, char *label, char mnemonic,
279 TB_CBProc cb, void *data);
280 Widget CreateMenuSeparator(Widget parent);
282 #endif /* __WIDGETS_H_ */