1
/* Copyright (C) 2000-2007 by George Williams */
3
* Redistribution and use in source and binary forms, with or without
4
* modification, are permitted provided that the following conditions are met:
6
* Redistributions of source code must retain the above copyright notice, this
7
* list of conditions and the following disclaimer.
9
* Redistributions in binary form must reproduce the above copyright notice,
10
* this list of conditions and the following disclaimer in the documentation
11
* and/or other materials provided with the distribution.
13
* The name of the author may not be used to endorse or promote products
14
* derived from this software without specific prior written permission.
16
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
#include "gprogress.h"
36
struct ggadgetcreatedata;
39
typedef GWindow GWidget;
41
typedef struct gwidgetcreatedata {
43
struct ggadgetcreatedata *gcd;
44
struct gwidgetcreatedata *wcd;
46
unsigned int trap_input: 1;
47
unsigned int tab_navigation: 1;
48
unsigned int arrow_navigation: 1;
49
unsigned int do_default: 1;
50
unsigned int do_cancel: 1;
52
void (*e_h)(GWindow, GEvent *); /* User's event function for window, our eh will call it */
53
#if 0 /* should expect these events: */
54
void (*create)(Widget *);
55
void (*close)(Widget *);
56
void (*expose)(Widget *,XEvent *);
57
void (*mouse)(Widget *,XEvent *,int count);
58
void (*key)(Widget *,XEvent *);
59
void (*resize)(Widget *,XEvent *);
60
void (*map)(Widget *,XEvent *);
61
void (*time)(Widget *,struct timer *timer);
62
void (*paste)(Widget *,void *data, long length);
66
typedef struct gwidgetcreatordata {
67
GWidget *(*creator)(GWidget *parent, GWidgetData *, void *data);
72
extern GWindow GWidgetCreateTopWindow(GDisplay *gdisp, GRect *pos, int (*eh)(GWindow,GEvent *), void *user_data, GWindowAttrs *wattrs);
73
extern GWindow GWidgetCreateSubWindow(GWindow w, GRect *pos, int (*eh)(GWindow,GEvent *), void *user_data, GWindowAttrs *wattrs);
74
extern GWindow GWidgetCreatePalette(GWindow w, GRect *pos, int (*eh)(GWindow,GEvent *), void *user_data, GWindowAttrs *wattrs);
76
GWindow GWindowGetCurrentFocusTopWindow(void);
77
GWindow GWidgetGetCurrentFocusWindow(void);
78
GWindow GWidgetGetPreviousFocusTopWindow(void);
79
struct ggadget *GWindowGetCurrentFocusGadget(void);
80
struct ggadget *GWindowGetFocusGadgetOfWindow(GWindow gw);
81
void GWindowClearFocusGadgetOfWindow(GWindow gw);
82
void GWidgetIndicateFocusGadget(struct ggadget *g);
83
void GWidgetNextFocus(GWindow);
84
void GWidgetPrevFocus(GWindow);
85
void GWidgetRequestVisiblePalette(GWindow palette,int visible);
86
void GWidgetHidePalettes(void);
87
void GPaletteDock(GWindow palette,int x, int y);
88
void GPaletteUndock(GWindow palette,int x, int y);
89
int GPaletteIsDocked(GWindow palette);
90
void GWidgetReparentWindow(GWindow child,GWindow newparent, int x,int y);
92
struct ggadget *GWidgetGetControl(GWindow gw, int cid);
93
struct ggadget *_GWidgetGetGadgets(GWindow gw);
94
GWindow GWidgetGetParent(GWindow gw);
95
GWindow GWidgetGetTopWidget(GWindow gw);
96
extern GDrawEH GWidgetGetEH(GWindow w);
97
extern void GWidgetSetEH(GWindow w,GDrawEH e_h);
98
extern void GWidgetFlowGadgets(GWindow gw);
99
extern void GWidgetToDesiredSize(GWindow gw);
101
/* Built in dialogs */
102
unichar_t *GWidgetOpenFile(const unichar_t *title, const unichar_t *defaultfile,
103
const unichar_t *initial_filter, unichar_t **mimetypes,GFileChooserFilterType filter);
104
unichar_t *GWidgetSaveAsFile(const unichar_t *title, const unichar_t *defaultfile,
105
const unichar_t *initial_filter, unichar_t **mimetypes,GFileChooserFilterType filter );
106
unichar_t *GWidgetSaveAsFileWithGadget(const unichar_t *title, const unichar_t *defaultfile,
107
const unichar_t *initial_filter, unichar_t **mimetypes,
108
GFileChooserFilterType filter, GGadgetCreateData *optional_gcd);
109
char *GWidgetOpenFile8(const char *title, const char *defaultfile,
110
const char *initial_filter, char **mimetypes,GFileChooserFilterType filter);
111
char *GWidgetSaveAsFileWithGadget8(const char *title, const char *defaultfile,
112
const char *initial_filter, char **mimetypes,
113
GFileChooserFilterType filter, GGadgetCreateData *optional_gcd);
114
char *GWidgetSaveAsFile8(const char *title, const char *defaultfile,
115
const char *initial_filter, char **mimetypes,GFileChooserFilterType filter );
116
int GWidgetAsk(const unichar_t *title, const unichar_t **answers, const unichar_t *mn,
117
int def, int cancel,const unichar_t *question,...);
118
int GWidgetAskCentered(const unichar_t *title,
119
const unichar_t ** answers, const unichar_t *mn, int def, int cancel,const unichar_t *question,...);
120
unichar_t *GWidgetAskString(const unichar_t *title,
121
const unichar_t *def,const unichar_t *question,...);
122
void GWidgetPostNotice(const unichar_t *title,const unichar_t *statement,...);
123
void GWidgetError(const unichar_t *title,const unichar_t *statement,...);
124
void GWidgetErrorR(int title,int statement,...);
125
int GWidgetAskR(int title, int *answers, int def, int cancel,int question,...);
126
int GWidgetAskR_(int title, int *answers, int def, int cancel,const unichar_t *question,...);
127
int GWidgetAskCenteredR(int title, int *answers, int def, int cancel,int question,...);
128
int GWidgetAskCenteredR_(int title, int *answers, int def, int cancel,const unichar_t *question,...);
129
unichar_t *GWidgetAskStringR(int title, const unichar_t *def,int question,...);
130
void GWidgetPostNoticeR(int title,int statement,...);
131
int GWidgetAsk8(const char *title, const char **answers,
132
int def, int cancel,const char *question,...);
133
int GWidgetAskCentered8(const char *title,
134
const char ** answers, int def, int cancel,const char *question,...);
135
char *GWidgetAskString8(const char *title,
136
const char *def,const char *question,...);
137
void GWidgetPostNotice8(const char *title,const char *statement,...);
138
void _GWidgetPostNotice8(const char *title,const char *statement,va_list ap);
139
int GWidgetPostNoticeActive8(const char *title);
140
void GWidgetError8(const char *title,const char *statement,...);
142
int GWidgetChoicesR(int title, const unichar_t **choices,int cnt, int def,int question,...);
143
int GWidgetChoicesBR(int title, const unichar_t **choices, int cnt, int def,
144
int buts[2],int question,...);
145
int GWidgetChoicesBRM(int title, const unichar_t **choices,char *sel,
146
int cnt, int buts[2], int question,...);
147
int GWidgetChoices8(const char *title, const char **choices,int cnt, int def,
148
const char *question,...);
149
int GWidgetChoicesB8(char *title, const char **choices, int cnt, int def,
150
char *buts[2], const char *question,...);
151
int GWidgetChoicesBM8(char *title, const char **choices,char *sel,
152
int cnt, char *buts[2], const char *question,...);
154
#define gwwv_choose_multiple GWidgetChoicesBM8
155
#define gwwv_choose_with_buttons GWidgetChoicesB8
156
#define gwwv_choose GWidgetChoices8
157
#define gwwv_ask_string GWidgetAskString8
158
#define gwwv_ask GWidgetAsk8
159
#define gwwv_ask_centered GWidgetAskCentered8
160
#define gwwv_post_error GWidgetError8
161
#define gwwv_post_notice GWidgetPostNotice8
162
#define gwwv_open_filename(tit,def,filter,filtfunc) GWidgetOpenFile8(tit,def,filter,NULL,filtfunc)
163
#define gwwv_save_filename(tit,def,filter) GWidgetSaveAsFile8(tit,def,filter,NULL,NULL)
164
#define gwwv_save_filename_with_gadget(tit,def,filter,gcd) GWidgetSaveAsFileWithGadget8(tit,def,filter,NULL,NULL,gcd)
166
void GWidgetCreateInsChar(void); /* takes input even when a modal dlg is active */
167
/* but is not modal itself */
168
void GInsCharSetChar(unichar_t ch); /* Sets current selection in ins char dlg */
170
extern GIC *GWidgetCreateInputContext(GWindow w,enum gic_style def_style);
171
extern GIC *GWidgetGetInputContext(GWindow w);
175
Widget *CreateCenteredDialog(Widget *parent, WidgetData *wd,void *data);
176
Widget *CreateDialog(Widget *parent, WidgetData *wd,void *data);
177
Widget *CreateTopWindow(Widget *parent, WidgetData *wd,void *data);
178
Widget *CreateCanvas(Widget *parent, WidgetData *wd,void *data);
179
Widget *CreateWidgets(Widget *parent, WidgetCreateData *wcd);
181
unichar_t *CreateFileDialog(unichar_t *title,unichar_t *dir,unichar_t *file,unichar_t *mimetypes, unichar_t *wildcard, unichar_t *open, unichar_t *cancel);
182
int CreateQuestionDialog(unichar_t *title, unichar_t *question,unichar_t *but1, unichar_t *but2, unichar_t *but3, unichar_t *but4, unichar_t *but5);
183
unichar_t *CreateStringDialog(unichar_t *title, unichar_t *question, unichar_t *def, unichar_t *ok, unichar_t *cancel);
184
TextInfo *CreateListDialog(unichar_t *title, unichar_t *question, TextInfo *list, unichar_t *ok, unichar_t *cancel);
185
void CreateNoteDlg(unichar_t *title,unichar_t *text,unichar_t *ok); /* does not take focus, vanishes if ignored */
186
void CreateWarningDlg(unichar_t *title,unichar_t *text,unichar_t *ok); /* does not take focus, vanishes if ignored */
187
void CreateErrorDlg(unichar_t *title,unichar_t *text,unichar_t *ok); /* does take focus */
188
void CreateFatalDlg(unichar_t *title,unichar_t *text,unichar_t *ok); /* does not return, preallocated */
189
void CreateCharDialog(); /* takes input even when a modal dlg is active */
190
/* but is not modal itself */
191
void CreatePrefsDialog();
193
void WidgetSetTitle(Widget *widg,unichar_t *title);
194
unichar_t_t WidgetGetTitle(Widget *widg);
196
void WidgetChangeMenu(Widget *widg,MenuItem *bar);
197
void WidgetChangeInvisibleCommands(Widget *widg,MenuItem *invisible);
198
MenuItem *WidgetGetMenu(Widget *widg);
199
MenuItem *WidgetGetInvisibleCommands(Widget *widg);
201
enum handler_mask { hm_close=1, hm_expose=2, hm_mouse=4, hm_key=8, hm_resize=16, hm_map=32, hm_time=64, hm_paste=128 };
202
void WidgetSetHandlers(Widget *widg,enum handler_mask hm, WidgetData *wd);
204
void WidgetMove(Widget *widg, int x, int y);
205
void WidgetResize(Widget *widg, int width, int height);
206
void WidgetReposition(Widget *widg, Rect *r);
207
Rect *WidgetGetPos(Widget *widg);
209
void WidgetRaise(Widget *widg);
210
void WidgetLower(Widget *widg);
212
void WidgetSetIconName(Widget *widg,unichar_t *name);
213
void WidgetSetIconPixmap(Widget *widg,Pixmap p);