SetMinimumDimensions -> WidgetSetMinWidth
[grace.git] / src / widgets.h
blob4c97378aaa64655b2f481af19cc61d35741ac230
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 WidgetSetHeight(Widget w, unsigned int height);
52 void WidgetSetSize(Widget w, unsigned int width, unsigned int height);
53 void WidgetGetSize(Widget w, unsigned int *width, unsigned int *height);
54 void WidgetSetMinWidth(Widget w, unsigned int width, unsigned int height);
56 typedef void (*Key_CBProc)(void *anydata);
57 typedef struct {
58 Widget w;
59 int modifiers;
60 int key;
61 Key_CBProc cbproc;
62 void *anydata;
63 } Key_CBData;
65 void AddWidgetKeyPressCB(Widget w, int key, Key_CBProc cbproc, void *anydata);
66 void AddWidgetKeyPressCB2(Widget w, int modifiers, int key, Key_CBProc cbproc, void *anydata);
68 typedef struct _Widget_CBData Widget_CBData;
69 typedef void (*Widget_CBProc)(Widget_CBData *wcbdata);
70 struct _Widget_CBData {
71 Widget w;
72 Widget_CBProc cbproc;
73 void *anydata;
74 void *calldata;
76 void AddWidgetCB(Widget w, const char *callback, Widget_CBProc cbproc, void *anydata);
78 /* Dialog */
79 Widget CreateDialog(Widget parent, const char *s);
80 void DialogRaise(Widget form);
81 void DialogClose(Widget form);
82 void DialogSetResizable(Widget form, int onoff);
84 /* File selection dialog */
85 typedef struct {
86 Widget dialog;
87 Widget FSB;
88 Widget rc;
89 } FSBStructure;
90 FSBStructure *CreateFileSelectionBox(Widget parent, char *s);
92 typedef int (*FSB_CBProc)(
93 FSBStructure *fsbp,
94 char *, /* filename */
95 void * /* data the application registered */
97 void AddFileSelectionBoxCB(FSBStructure *fsbp, FSB_CBProc cbproc, void *anydata);
98 void SetFileSelectionBoxPattern(FSBStructure *fsb, char *pattern);
100 /* Containers */
101 Widget CreateVContainer(Widget parent);
102 Widget CreateHContainer(Widget parent);
104 /* Form */
105 Widget CreateForm(Widget parent);
106 void FormAddHChild(Widget form, Widget child);
107 void FormAddVChild(Widget form, Widget child);
108 void FormFixateVChild(Widget w);
110 /* Label */
111 Widget CreateLabel(Widget parent, char *s);
112 void LabelSetString(Widget w, char *s);
113 void LabelSetPixmap(Widget w, int width, int height, const unsigned char *bits);
115 /* Text */
116 Widget CreateLineTextEdit(Widget parent, int len);
117 Widget CreateMultiLineTextEdit(Widget parent, int nrows);
119 typedef struct {
120 Widget label;
121 Widget form;
122 Widget text;
123 int locked;
124 } TextStructure;
126 void TextSetLength(TextStructure *cst, int len);
127 char *TextGetString(TextStructure *cst);
128 void TextSetString(TextStructure *cst, char *s);
130 typedef int (*TextValidate_CBProc)(
131 char **value,
132 int *length,
133 void *data
135 void AddTextValidateCB(TextStructure *cst, TextValidate_CBProc cbproc, void *anydata);
136 int TextGetCursorPos(TextStructure *cst);
137 void TextSetCursorPos(TextStructure *cst, int pos);
138 int TextGetLastPosition(TextStructure *cst);
139 void TextInsert(TextStructure *cst, int pos, char *s);
140 void TextSetEditable(TextStructure *cst, int onoff);
142 /* Tab */
143 Widget CreateTab(Widget parent);
144 Widget CreateTabPage(Widget parent, char *s);
145 void SelectTabPage(Widget tab, Widget w);
147 /* Button */
148 typedef void (*Button_CBProc)(
149 Widget but,
150 void * /* data the application registered */
152 Widget CreateButton(Widget parent, char *label);
153 Widget CreateBitmapButton(Widget parent,
154 int width, int height, const unsigned char *bits);
156 /* ToggleButton */
157 typedef void (*TB_CBProc)(
158 Widget but,
159 int onoff, /* True/False */
160 void * /* data the application registered */
162 Widget CreateToggleButton(Widget parent, char *s);
163 int GetToggleButtonState(Widget w);
164 void SetToggleButtonState(Widget w, int value);
166 /* Grid */
167 Widget CreateGrid(Widget parent, int ncols, int nrows);
168 void PlaceGridChild(Widget grid, Widget w, int col, int row);
170 /* OptionChoice */
171 typedef struct _OptionStructure OptionStructure;
172 typedef struct {
173 int value;
174 char *label;
175 } OptionItem;
176 OptionStructure *CreateOptionChoice(Widget parent, char *labelstr, int ncols,
177 int nchoices, OptionItem *items);
178 OptionStructure *CreateOptionChoiceVA(Widget parent, char *labelstr, ...);
179 int GetOptionChoice(OptionStructure *opt);
180 void UpdateOptionChoice(OptionStructure *optp, int nchoices, OptionItem *items);
182 typedef void (*OC_CBProc)(
183 OptionStructure *opt,
184 int value, /* value */
185 void * /* data the application registered */
188 typedef struct {
189 int value;
190 Widget widget;
191 } OptionWidgetItem;
193 typedef struct {
194 OptionStructure *opt;
195 OC_CBProc cbproc;
196 void *anydata;
197 } OC_CBdata;
199 struct _OptionStructure {
200 int nchoices;
201 int ncols; /* preferred number of columns */
202 Widget menu;
203 Widget pulldown;
204 OptionWidgetItem *options;
206 unsigned int cbnum;
207 OC_CBdata **cblist;
209 void AddOptionChoiceCB(OptionStructure *opt, OC_CBProc cbproc, void *anydata);
211 /* Menu */
212 Widget CreatePopupMenu(Widget parent);
213 Widget CreateMenuBar(Widget parent);
214 Widget CreateMenu(Widget parent, char *label, char mnemonic, int help);
215 Widget CreateMenuButton(Widget parent, char *label, char mnemonic,
216 Button_CBProc cb, void *data);
217 Widget CreateMenuButtonA(Widget parent, char *label, char mnemonic,
218 char *accelerator, char* acceleratorText, Button_CBProc cb, void *data);
219 Widget CreateMenuHelpButton(Widget parent, char *label, char mnemonic,
220 Widget form, char *ha);
221 Widget CreateMenuToggle(Widget parent, char *label, char mnemonic,
222 TB_CBProc cb, void *data);
224 #endif /* __WIDGETS_H_ */