WidgetSetMinWidth -> PanedWindowSetMinWidth
[grace.git] / src / widgets.h
blobcb5131934a543f4e7c8bad44cf5f37d83fa9930a
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);
55 typedef void (*Key_CBProc)(void *anydata);
56 typedef struct {
57 Widget w;
58 int modifiers;
59 int key;
60 Key_CBProc cbproc;
61 void *anydata;
62 } Key_CBData;
64 void AddWidgetKeyPressCB(Widget w, int key, Key_CBProc cbproc, void *anydata);
65 void AddWidgetKeyPressCB2(Widget w, int modifiers, int key, Key_CBProc cbproc, void *anydata);
67 typedef struct _Widget_CBData Widget_CBData;
68 typedef void (*Widget_CBProc)(Widget_CBData *wcbdata);
69 struct _Widget_CBData {
70 Widget w;
71 Widget_CBProc cbproc;
72 void *anydata;
73 void *calldata;
75 void AddWidgetCB(Widget w, const char *callback, Widget_CBProc cbproc, void *anydata);
77 /* Dialog */
78 Widget CreateDialog(Widget parent, const char *s);
79 void DialogRaise(Widget form);
80 void DialogClose(Widget form);
81 void DialogSetResizable(Widget form, int onoff);
83 /* File selection dialog */
84 typedef struct {
85 Widget dialog;
86 Widget FSB;
87 Widget rc;
88 } FSBStructure;
89 FSBStructure *CreateFileSelectionBox(Widget parent, char *s);
91 typedef int (*FSB_CBProc)(
92 FSBStructure *fsbp,
93 char *, /* filename */
94 void * /* data the application registered */
96 void AddFileSelectionBoxCB(FSBStructure *fsbp, FSB_CBProc cbproc, void *anydata);
97 void SetFileSelectionBoxPattern(FSBStructure *fsb, char *pattern);
99 /* Containers */
100 Widget CreateVContainer(Widget parent);
101 Widget CreateHContainer(Widget parent);
103 /* Form */
104 Widget CreateForm(Widget parent);
105 void FormAddHChild(Widget form, Widget child);
106 void FormAddVChild(Widget form, Widget child);
107 void FormFixateVChild(Widget w);
109 /* Label */
110 Widget CreateLabel(Widget parent, char *s);
111 void LabelSetString(Widget w, char *s);
112 void LabelSetPixmap(Widget w, int width, int height, const unsigned char *bits);
114 /* Text */
115 Widget CreateLineTextEdit(Widget parent, int len);
116 Widget CreateMultiLineTextEdit(Widget parent, int nrows);
118 typedef struct {
119 Widget label;
120 Widget form;
121 Widget text;
122 int locked;
123 } TextStructure;
125 void TextSetLength(TextStructure *cst, int len);
126 char *TextGetString(TextStructure *cst);
127 void TextSetString(TextStructure *cst, char *s);
129 typedef int (*TextValidate_CBProc)(
130 char **value,
131 int *length,
132 void *data
134 void AddTextValidateCB(TextStructure *cst, TextValidate_CBProc cbproc, void *anydata);
135 int TextGetCursorPos(TextStructure *cst);
136 void TextSetCursorPos(TextStructure *cst, int pos);
137 int TextGetLastPosition(TextStructure *cst);
138 void TextInsert(TextStructure *cst, int pos, char *s);
139 void TextSetEditable(TextStructure *cst, int onoff);
141 /* Tab */
142 Widget CreateTab(Widget parent);
143 Widget CreateTabPage(Widget parent, char *s);
144 void SelectTabPage(Widget tab, Widget w);
146 /* Button */
147 typedef void (*Button_CBProc)(
148 Widget but,
149 void * /* data the application registered */
151 Widget CreateButton(Widget parent, char *label);
152 Widget CreateBitmapButton(Widget parent,
153 int width, int height, const unsigned char *bits);
155 /* ToggleButton */
156 typedef void (*TB_CBProc)(
157 Widget but,
158 int onoff, /* True/False */
159 void * /* data the application registered */
161 Widget CreateToggleButton(Widget parent, char *s);
162 int GetToggleButtonState(Widget w);
163 void SetToggleButtonState(Widget w, int value);
165 /* Paned window */
166 Widget CreatePanedWindow(Widget parent);
167 void PanedWindowSetMinWidth(Widget w, unsigned int width);
169 /* Grid */
170 Widget CreateGrid(Widget parent, int ncols, int nrows);
171 void PlaceGridChild(Widget grid, Widget w, int col, int row);
173 /* OptionChoice */
174 typedef struct _OptionStructure OptionStructure;
175 typedef struct {
176 int value;
177 char *label;
178 } OptionItem;
179 OptionStructure *CreateOptionChoice(Widget parent, char *labelstr, int ncols,
180 int nchoices, OptionItem *items);
181 OptionStructure *CreateOptionChoiceVA(Widget parent, char *labelstr, ...);
182 int GetOptionChoice(OptionStructure *opt);
183 void UpdateOptionChoice(OptionStructure *optp, int nchoices, OptionItem *items);
185 typedef void (*OC_CBProc)(
186 OptionStructure *opt,
187 int value, /* value */
188 void * /* data the application registered */
191 typedef struct {
192 int value;
193 Widget widget;
194 } OptionWidgetItem;
196 typedef struct {
197 OptionStructure *opt;
198 OC_CBProc cbproc;
199 void *anydata;
200 } OC_CBdata;
202 struct _OptionStructure {
203 int nchoices;
204 int ncols; /* preferred number of columns */
205 Widget menu;
206 Widget pulldown;
207 OptionWidgetItem *options;
209 unsigned int cbnum;
210 OC_CBdata **cblist;
212 void AddOptionChoiceCB(OptionStructure *opt, OC_CBProc cbproc, void *anydata);
214 /* Menu */
215 Widget CreatePopupMenu(Widget parent);
216 Widget CreateMenuBar(Widget parent);
217 Widget CreateMenu(Widget parent, char *label, char mnemonic, int help);
218 Widget CreateMenuButton(Widget parent, char *label, char mnemonic,
219 Button_CBProc cb, void *data);
220 Widget CreateMenuButtonA(Widget parent, char *label, char mnemonic,
221 char *accelerator, char* acceleratorText, Button_CBProc cb, void *data);
222 Widget CreateMenuHelpButton(Widget parent, char *label, char mnemonic,
223 Widget form, char *ha);
224 Widget CreateMenuToggle(Widget parent, char *label, char mnemonic,
225 TB_CBProc cb, void *data);
227 #endif /* __WIDGETS_H_ */