Moved demotified functions
[grace.git] / src / widgets.h
blobc7495410623439c129656ccc2c28b37b233b4af9
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 /* Timer */
45 typedef void (*Timer_CBProc)(void *anydata);
46 typedef struct {
47 unsigned long timer_id;
48 unsigned long interval;
49 Timer_CBProc cbproc;
50 void *anydata;
51 } Timer_CBdata;
52 Timer_CBdata *CreateTimer(unsigned long interval, Timer_CBProc cbproc, void *anydata);
53 void TimerStart(Timer_CBdata *cbdata);
55 /* Widgets */
56 void WidgetManage(Widget w);
57 void WidgetUnmanage(Widget w);
58 int WidgetIsManaged(Widget w);
59 void *WidgetGetUserData(Widget w);
60 void WidgetSetUserData(Widget w, void *udata);
61 void WidgetSetSensitive(Widget w, int onoff);
62 void WidgetSetFocus(Widget w);
63 void WidgetSetWidth(Widget w, unsigned int width);
64 void WidgetSetHeight(Widget w, unsigned int height);
65 void WidgetSetSize(Widget w, unsigned int width, unsigned int height);
66 void WidgetGetSize(Widget w, unsigned int *width, unsigned int *height);
68 typedef void (*Key_CBProc)(void *anydata);
69 typedef struct {
70 Widget w;
71 int modifiers;
72 int key;
73 Key_CBProc cbproc;
74 void *anydata;
75 } Key_CBData;
77 void AddWidgetKeyPressCB(Widget w, int key, Key_CBProc cbproc, void *anydata);
78 void AddWidgetKeyPressCB2(Widget w, int modifiers, int key, Key_CBProc cbproc, void *anydata);
80 void AddWidgetButtonPressCB(Widget w, int button, Key_CBProc cbproc, void *anydata);
82 typedef struct {
83 char **text;
84 int allow_change;
85 } TextValidate_CD;
87 typedef struct _Widget_CBData Widget_CBData;
88 typedef void (*Widget_CBProc)(Widget_CBData *wcbdata);
89 struct _Widget_CBData {
90 Widget w;
91 Widget_CBProc cbproc;
92 void *anydata;
93 void *calldata;
95 void AddWidgetCB(Widget w, const char *callback, Widget_CBProc cbproc, void *anydata);
97 /* Dialog Window */
98 Widget CreateDialogWindow(Widget parent, const char *s);
100 /* Dialog */
101 Widget CreateDialog(Widget parent, const char *s);
102 void DialogRaise(Widget form);
103 void DialogClose(Widget form);
104 void DialogSetResizable(Widget form, int onoff);
106 /* File selection box */
107 Widget CreateFileSelectionBox(Widget parent);
109 /* File selection filter */
110 void CreateFileSelectionFilter(Widget parent, Widget fsb);
112 /* File selection dialog */
113 typedef struct {
114 Widget FSB;
115 Widget rc;
116 } FSBStructure;
117 FSBStructure *CreateFSBDialog(Widget parent, char *s);
119 typedef int (*FSB_CBProc)(
120 FSBStructure *fsbp,
121 char *, /* filename */
122 void * /* data the application registered */
124 void AddFSBDialogCB(FSBStructure *fsbp, FSB_CBProc cbproc, void *anydata);
125 void FSBDialogSetPattern(FSBStructure *fsb, char *pattern);
126 void FSBDialogSetDirectory(FSBStructure *fsb, char *directory);
128 /* Containers */
129 Widget CreateVContainer(Widget parent);
130 Widget CreateHContainer(Widget parent);
132 /* Form */
133 Widget CreateForm(Widget parent);
134 void FormAddHChild(Widget form, Widget child);
135 void FormAddVChild(Widget form, Widget child);
136 void FormFixateHChild(Widget w);
137 void FormFixateVChild(Widget w);
139 /* Grid */
140 Widget CreateGrid(Widget parent, int ncols, int nrows);
141 void PlaceGridChild(Widget grid, Widget w, int col, int row);
143 /* Frame */
144 Widget CreateFrame(Widget parent, char *s);
146 /* Scrolled window */
147 Widget CreateScrolledWindow(Widget parent);
149 /* Paned window */
150 Widget CreatePanedWindow(Widget parent);
151 void PanedWindowSetMinWidth(Widget w, unsigned int width);
153 /* Tab */
154 Widget CreateTab(Widget parent);
155 Widget CreateTabPage(Widget parent, char *s);
156 void SelectTabPage(Widget tab, Widget w);
158 /* Separator */
159 Widget CreateSeparator(Widget parent);
161 /* Label */
162 Widget CreateLabel(Widget parent, char *s);
163 void LabelSetString(Widget w, char *s);
164 void LabelSetPixmap(Widget w, int width, int height, const unsigned char *bits);
166 /* Text edit */
167 Widget CreateLineTextEdit(Widget parent, int len);
168 Widget CreateMultiLineTextEdit(Widget parent, int nrows);
169 char *TextEditGetString(Widget w);
170 void TextEditSetString(Widget w, char *s);
172 /* Text */
173 typedef struct {
174 Widget label;
175 Widget form;
176 Widget text;
177 int locked;
178 } TextStructure;
180 void TextInsertString(TextStructure *cst, int pos, char *s);
181 int TextGetCursorPos(TextStructure *cst);
182 void TextSetCursorPos(TextStructure *cst, int pos);
183 int TextGetLastPosition(TextStructure *cst);
184 void TextSetLength(TextStructure *cst, int len);
185 void TextSetEditable(TextStructure *cst, int onoff);
187 /* Button */
188 typedef void (*Button_CBProc)(
189 Widget but,
190 void * /* data the application registered */
192 Widget CreateButton(Widget parent, char *label);
193 Widget CreateBitmapButton(Widget parent,
194 int width, int height, const unsigned char *bits);
196 #define ARROW_UP 1
197 #define ARROW_DOWN 2
198 Widget CreateArrowButton(Widget parent, int arrow_type);
200 /* ToggleButton */
201 typedef void (*TB_CBProc)(
202 Widget but,
203 int onoff, /* True/False */
204 void * /* data the application registered */
206 Widget CreateToggleButton(Widget parent, char *s);
207 int ToggleButtonGetState(Widget w);
208 void ToggleButtonSetState(Widget w, int value);
210 /* Scale */
211 Widget CreateScale(Widget parent, char *s, int min, int max, int delta);
212 void ScaleSetValue(Widget w, int value);
213 int ScaleGetValue(Widget w);
215 /* OptionChoice */
216 typedef struct _OptionStructure OptionStructure;
217 typedef struct {
218 int value;
219 char *label;
220 } OptionItem;
221 OptionStructure *CreateOptionChoice(Widget parent, char *labelstr, int ncols,
222 int nchoices, OptionItem *items);
223 OptionStructure *CreateOptionChoiceVA(Widget parent, char *labelstr, ...);
224 int GetOptionChoice(OptionStructure *opt);
225 void UpdateOptionChoice(OptionStructure *optp, int nchoices, OptionItem *items);
227 typedef void (*OC_CBProc)(
228 OptionStructure *opt,
229 int value, /* value */
230 void * /* data the application registered */
233 typedef struct {
234 int value;
235 Widget widget;
236 } OptionWidgetItem;
238 typedef struct {
239 OptionStructure *opt;
240 OC_CBProc cbproc;
241 void *anydata;
242 } OC_CBdata;
244 struct _OptionStructure {
245 int nchoices;
246 int ncols; /* preferred number of columns */
247 Widget menu;
248 Widget pulldown;
249 OptionWidgetItem *options;
251 unsigned int cbnum;
252 OC_CBdata **cblist;
254 void AddOptionChoiceCB(OptionStructure *opt, OC_CBProc cbproc, void *anydata);
256 /* Menu */
257 Widget CreatePopupMenu(Widget parent);
258 void PopupMenuShow(Widget w, void *data);
259 Widget CreateMenuBar(Widget parent);
260 Widget CreateMenu(Widget parent, char *label, char mnemonic, int help);
261 Widget CreateMenuButton(Widget parent, char *label, char mnemonic,
262 Button_CBProc cb, void *data);
263 Widget CreateMenuButtonA(Widget parent, char *label, char mnemonic,
264 char *accelerator, char* acceleratorText, Button_CBProc cb, void *data);
265 Widget CreateMenuHelpButton(Widget parent, char *label, char mnemonic,
266 Widget form, char *ha);
267 Widget CreateMenuToggle(Widget parent, char *label, char mnemonic,
268 TB_CBProc cb, void *data);
269 Widget CreateMenuSeparator(Widget parent);
271 #endif /* __WIDGETS_H_ */