Debian Codegraph @

inc/ggadget.h

raw symbols SCIP
1 /* Copyright (C) 2000-2012 by George Williams */
2 /*
3 * Redistribution and use in source and binary forms, with or without
4 * modification, are permitted provided that the following conditions are met:
5
6 * Redistributions of source code must retain the above copyright notice, this
7 * list of conditions and the following disclaimer.
8
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.
12
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.
15
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.
26 */
27
28 #ifndef FONTFORGE_GGADGET_H
29 #define FONTFORGE_GGADGET_H
30
31 #include "gdraw.h"
32 #include "intl.h"
33 struct giocontrol;
34
35 typedef struct gtextinfo {
36 unichar_t *text;
37 GImage *image;
38 Color fg;
39 Color bg;
40 void *userdata;
41 GFont *font;
42 unsigned int disabled: 1;
43 unsigned int image_precedes: 1;
44 unsigned int checkable: 1; /* Only for menus */
45 unsigned int checked: 1; /* Only for menus */
46 unsigned int selected: 1; /* Only for lists (used internally for menu(bar)s, when cursor is on the line) */
47 unsigned int line: 1; /* Only for menus */
48 unsigned int text_is_1byte: 1; /* If passed in as 1byte (ie. iso-8859-1) text, will be converted */
49 unsigned int text_in_resource: 1; /* the text field is actually an index into the string resource table */
50 unsigned int changed: 1; /* If a row/column widget changed this */
51 unichar_t mnemonic; /* Only for menus and menubars */
52 /* should really be in menuitem, but that wastes space and complicates GTextInfoDraw */
53 char* text_untranslated; /* used to simplify hotkey lookup for menus. */
54 /*
55 * text_untranslated is either the GMenuItem2 shortcut or the GTextInfo prior
56 * to translation occurring. The shortcut text is considered first
57 * to allow the code to make the value explicit. This is useful in
58 * cases where the menu text to be translated (GTextInfo.text
59 * prior to calling sgettext() on it) is specially designed for
60 * translation, like File|New is. Having the hotkey of "New|No
61 * Shortcut" will give a text_untranslated of "New|No Shortcut".
62 * See HKTextInfoToUntranslatedText() for stripping out any
63 * potential underscore and the trailing "|Rest" string.
64 *
65 * Using a pointer like this relies on the GMenuItems used to make
66 * the menus are a static structure that outlasts the
67 * menu/gtextinfo itself.
68 **/
69 } GTextInfo;
70
71 #define GTEXTINFO_EMPTY { NULL, NULL, 0x000000, 0x000000, NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, '\0' }
72
73
74 typedef struct gtextinfo2 {
75 unichar_t *text;
76 GImage *image;
77 Color fg;
78 Color bg;
79 void *userdata;
80 GFont *font;
81 unsigned int disabled: 1;
82 unsigned int image_precedes: 1;
83 unsigned int checkable: 1; /* Only for menus */
84 unsigned int checked: 1; /* Only for menus */
85 unsigned int selected: 1; /* Only for lists (used internally for menu(bar)s, when cursor is on the line) */
86 unsigned int line: 1; /* Only for menus */
87 unsigned int text_is_1byte: 1; /* If passed in as 1byte (ie. iso-8859-1) text, will be converted */
88 unsigned int text_in_resource: 1; /* the text field is actually an index into the string resource table */
89 unsigned int changed: 1; /* If a row/column widget changed this */
90 unsigned int sort_me_first_in_list: 1; /* used for directories in file chooser widgets */
91 unichar_t mnemonic; /* Only for menus and menubars */
92 /* should really be in menuitem, but that wastes space and complicates GTextInfoDraw */
93 } GTextInfo2;
94
95 #define GTEXTINFO2_EMPTY { NULL, NULL, 0x000000, 0x000000, NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '\0' }
96
97
98 typedef struct gmenuitem {
99 GTextInfo ti;
100 unichar_t shortcut;
101 short short_mask;
102 struct gmenuitem *sub;
103 void (*moveto)(struct gwindow *base,struct gmenuitem *mi,GEvent *); /* called before creating submenu */
104 void (*invoke)(struct gwindow *base,struct gmenuitem *mi,GEvent *); /* called on mouse release */
105 int mid;
106 } GMenuItem;
107
108 #define GMENUITEM_LINE { { NULL, NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 1, 0, 0, 0, '\0' }, '\0', 0, NULL, NULL, NULL, 0 }
109 #define GMENUITEM_EMPTY { GTEXTINFO_EMPTY, '\0', 0, NULL, NULL, NULL, 0 }
110
111
112 typedef struct gmenuitem2 {
113 GTextInfo ti;
114 char *shortcut;
115 struct gmenuitem2 *sub;
116 void (*moveto)(struct gwindow *base,struct gmenuitem *mi,GEvent *); /* called before creating submenu */
117 void (*invoke)(struct gwindow *base,struct gmenuitem *mi,GEvent *); /* called on mouse release */
118 int mid;
119 } GMenuItem2;
120
121 #define GMENUITEM2_LINE { { NULL, NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 1, 0, 0, 0, '\0' }, NULL, NULL, NULL, NULL, 0 }
122 #define GMENUITEM2_EMPTY { GTEXTINFO_EMPTY, NULL, NULL, NULL, NULL, 0 }
123
124 typedef struct tabinfo {
125 unichar_t *text;
126 struct ggadgetcreatedata *gcd;
127 unsigned int disabled: 1;
128 unsigned int selected: 1;
129 unsigned int text_is_1byte: 1; /* If passed in as 1byte (ie. iso-8859-1) text, will be converted */
130 unsigned int text_in_resource: 1; /* the text field is actually an index into the string resource table */
131 unsigned char nesting;
132 } GTabInfo;
133
134 #define GTABINFO_EMPTY { NULL, NULL, 0, 0, 0, 0, 0 }
135
136 typedef struct ggadget GGadget;
137 typedef struct ggadget *GGadgetSet;
138
139 enum sb_type { sb_upline, sb_downline, sb_uppage, sb_downpage, sb_track, sb_trackrelease };
140 struct scrollbarinit { int32_t sb_min, sb_max, sb_pagesize, sb_pos; };
141
142 typedef int (*GGadgetHandler)(GGadget *,GEvent *);
143 typedef unichar_t **(*GTextCompletionHandler)(GGadget *,int from_tab);
144
145 enum gg_flags { gg_none=0, gg_visible=1, gg_enabled=2, gg_pos_in_pixels=4,
146 gg_sb_vert=8, gg_line_vert=gg_sb_vert,
147 gg_but_default=0x10, gg_but_cancel=0x20,
148 gg_cb_on=0x40, gg_rad_startnew=0x80,
149 gg_rad_continueold=0x100, /* even if not previous */
150 gg_list_alphabetic=0x100, gg_list_multiplesel=0x200,
151 gg_list_exactlyone=0x400, gg_list_internal=0x800,
152 gg_group_prevlabel=0x1000, gg_group_end=0x2000,
153 gg_textarea_wrap=0x4000,
154 gg_tabset_scroll=0x8000, gg_tabset_filllines=0x10000, gg_tabset_fill1line = 0x20000,
155 gg_tabset_nowindow=gg_textarea_wrap,
156 gg_rowcol_alphabetic=gg_list_alphabetic,
157 gg_rowcol_vrules=0x40000, gg_rowcol_hrules=0x800000,
158 gg_rowcol_displayonly=0x1000000,
159 gg_dontcopybox=0x10000000,
160 gg_pos_use0=0x20000000, gg_pos_under=0x40000000,
161 gg_pos_newline = (int) 0x80000000,
162 /* Reuse some flag values for different widgets */
163 gg_file_pulldown=gg_sb_vert, gg_file_multiple = gg_list_multiplesel,
164 gg_text_xim = gg_tabset_scroll,
165 gg_tabset_vert = gg_sb_vert,
166 gg_s1_vert = gg_sb_vert,
167 gg_s1_flowalign = gg_list_alphabetic,
168 gg_s1_right = gg_list_multiplesel,
169 gg_s1_bottom = gg_s1_right,
170 gg_s1_center = gg_list_internal,
171 gg_s1_expand = gg_group_end,
172 gg_flow_vert = gg_s1_vert,
173 gg_flow_right = gg_s1_right,
174 gg_flow_bottom = gg_flow_right,
175 gg_flow_center = gg_s1_center,
176 gg_flow_expand = gg_s1_expand,
177 gg_flow_obottom = gg_list_exactlyone,
178 gg_flow_oright = gg_flow_obottom,
179 gg_flow_ocenter = gg_group_prevlabel,
180 gg_flow_lright = gg_rowcol_hrules,
181 gg_flow_lbottom = gg_dontcopybox,
182 gg_flow_lhcenter = gg_rowcol_displayonly,
183 gg_flow_lvcenter = gg_pos_use0,
184 gg_flow_noalignlabel = gg_tabset_scroll
185 };
186
187 #ifdef __cplusplus
188 extern "C++" {
189 inline enum gg_flags operator|(enum gg_flags lhs, enum gg_flags rhs) {
190 return static_cast<enum gg_flags>(static_cast<int>(lhs) |
191 static_cast<int>(rhs));
192 }
193 }
194 #endif
195
196 typedef struct ggadgetdata {
197 GRect pos;
198 GBox *box;
199 unichar_t mnemonic;
200 unichar_t shortcut;
201 uint8_t short_mask;
202 uint8_t cols; /* for rowcol */
203 short cid;
204 GTextInfo *label; /* Overloaded with a GGadgetCreateData * for hvboxes (their label is a gadget) */
205 union {
206 GTextInfo *list; /* for List Widgets (and ListButtons, RowCols etc) */
207 GTabInfo *tabs; /* for Tab Widgets */
208 GMenuItem *menu; /* for menus */
209 GMenuItem2 *menu2; /* for menus (alternate) */
210 struct ggadgetcreatedata **boxelements; /* An array of things to go in the box */
211 struct matrixinit *matrix;
212 GDrawEH drawable_e_h; /* Drawable event handler */
213 GTextCompletionHandler completion;
214 struct scrollbarinit *sbinit;
215 Color col;
216 int radiogroup;
217 } u;
218 enum gg_flags flags;
219 const char *popup_msg; /* Brief help message, utf-8 encoded */
220 GGadgetHandler handle_controlevent;
221 } GGadgetData;
222
223 #define GGADGETDATA_EMPTY { GRECT_EMPTY, NULL, '\0', '\0', 0, 0, 0, NULL, { NULL }, 0, NULL, NULL }
224
225
226 typedef struct ggadgetcreatedata {
227 GGadget *(*creator)(struct gwindow *base, GGadgetData *gd,void *data);
228 GGadgetData gd;
229 void *data;
230 GGadget *ret;
231 } GGadgetCreateData;
232
233 #define GGADGETCREATEDATA_EMPTY { NULL, GGADGETDATA_EMPTY, NULL, NULL }
234
235
236 #define GCD_Glue ((GGadgetCreateData *) -1) /* Special entries */
237 #define GCD_ColSpan ((GGadgetCreateData *) -2) /* for box elements */
238 #define GCD_RowSpan ((GGadgetCreateData *) -3)
239 #define GCD_HPad10 ((GGadgetCreateData *) -4)
240
241 enum ghvbox_expand { gb_expandglue=-4, gb_expandgluesame=-3, gb_samesize=-2,
242 gb_expandall=-1 };
243 enum editor_commands { ec_cut, ec_clear, ec_copy, ec_paste, ec_undo, ec_redo,
244 ec_selectall, ec_search, ec_backsearch, ec_backword, ec_deleteword,
245 ec_max };
246
247 /* return values from file chooser filter functions */
248 enum fchooserret { fc_hide, fc_show, fc_showdisabled };
249
250 enum me_type { me_int, me_enum, me_real, me_string, me_bigstr, me_func,
251 me_funcedit,
252 me_stringchoice, me_stringchoicetrans, me_stringchoicetag,
253 me_button,
254 me_hex, me_uhex, me_addr, me_onlyfuncedit };
255
256 struct col_init {
257 enum me_type me_type;
258 char *(*func)(GGadget *,int r,int c);
259 GTextInfo *enum_vals;
260 void (*enable_enum)(GGadget *,GMenuItem *, int r, int c);
261 char *title;
262 };
263
264 struct matrix_data {
265 union {
266 intptr_t md_ival;
267 double md_real;
268 char *md_str;
269 void *md_addr;
270 } u;
271 uint8_t frozen;
272 uint8_t user_bits;
273 uint8_t current;
274 };
275
276 struct matrixinit {
277 int col_cnt;
278 struct col_init *col_init;
279 int initial_row_cnt;
280 struct matrix_data *matrix_data;
281 void (*initrow)(GGadget *g,int row);
282 int (*candelete)(GGadget *g,int row);
283 void (*finishedit)(GGadget *g,int r, int c, int wasnew);
284 void (*popupmenu)(GGadget *g,GEvent *e,int row,int col);
285 int (*handle_key)(GGadget *g,GEvent *e);
286 char *(*bigedittitle)(GGadget *g,int r, int c);
287 };
288
289 #define COL_INIT_EMPTY { 0, NULL, NULL, NULL, NULL }
290 #define MATRIX_DATA_EMPTY { { 0 }, 0, 0, 0 }
291 #define MATRIXINIT_EMPTY { 0, NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL }
292
293 #define GME_NoChange 0x80000000
294
295 struct gdirentry {
296 const char *fullpath;
297 const char *name;
298 const char *mimetype;
299 bool isdir;
300 };
301 typedef enum fchooserret (*GFileChooserFilterType)(GGadget *g,
302 const struct gdirentry *ent, const char *dir);
303 typedef int (*GFileChooserInputFilenameFuncType)( GGadget *g,
304 const unichar_t ** currentFilename,
305 unichar_t* oldfilename );
306
307 #define _NUM_Buttonsize 0
308 #define _NUM_ScaleFactor 1
309 #define __NUM_LastStd 1
310
311 extern void GTextInfoFree(GTextInfo *ti);
312 extern void GTextInfoListFree(GTextInfo *ti);
313 extern void GTextInfoArrayFree(GTextInfo **ti);
314 extern GTextInfo **GTextInfoFromChars(char **array, int len);
315 extern int GGadgetScale(int xpos);
316 extern int GIntGetResource(int index);
317
318 void GGadgetDestroy(GGadget *g);
319 void GGadgetSetVisible(GGadget *g,int visible);
320 int GGadgetIsVisible(GGadget *g);
321 void GGadgetSetEnabled(GGadget *g,int enabled);
322 int GGadgetIsEnabled(GGadget *g);
323 GWindow GGadgetGetWindow(GGadget *g);
324 void *GGadgetGetUserData(GGadget *g);
325 void GGadgetSetUserData(GGadget *g, void *d);
326 void GGadgetSetPopupMsg(GGadget *g, const unichar_t *msg);
327 int GGadgetContains(GGadget *g, int x, int y );
328 int GGadgetContainsEventLocation(GGadget *g, GEvent* e );
329 GRect *GGadgetGetInnerSize(GGadget *g,GRect *rct);
330 GRect *GGadgetGetSize(GGadget *g,GRect *rct);
331 void GGadgetSetSize(GGadget *g,GRect *rct);
332 void GGadgetGetDesiredVisibleSize(GGadget *g,GRect *outer, GRect *inner);
333 void GGadgetGetDesiredSize(GGadget *g,GRect *outer, GRect *inner);
334 void GGadgetSetDesiredSize(GGadget *g,GRect *outer, GRect *inner);
335 int GGadgetGetCid(GGadget *g);
336 void GGadgetResize(GGadget *g,int32_t width, int32_t height );
337 void GGadgetMove(GGadget *g,int32_t x, int32_t y );
338 void GGadgetMoveAddToY(GGadget *g, int32_t yoffset );
339 int32_t GGadgetGetX(GGadget *g);
340 int32_t GGadgetGetY(GGadget *g);
341 void GGadgetSetY(GGadget *g, int32_t y );
342 void GGadgetRedraw(GGadget *g);
343 void GGadgetsCreate(GWindow base, GGadgetCreateData *gcd);
344 int GGadgetFillsWindow(GGadget *g);
345 int GGadgetIsDefault(GGadget *g);
346
347 void GGadgetSetTitle(GGadget *g,const unichar_t *title);
348 void GGadgetSetTitle8(GGadget *g,const char *title);
349 void GGadgetSetTitle8WithMn(GGadget *g,const char *title);
350 const unichar_t *_GGadgetGetTitle(GGadget *g); /* Do not free!!! */
351 unichar_t *GGadgetGetTitle(GGadget *g); /* Free the return */
352 char *GGadgetGetTitle8(GGadget *g); /* Free the return (utf8) */
353 void GGadgetSetFont(GGadget *g,GFont *font);
354 GFont *GGadgetGetFont(GGadget *g);
355 int GGadgetEditCmd(GGadget *g,enum editor_commands cmd);
356 int GGadgetActiveGadgetEditCmd(GWindow gw,enum editor_commands cmd);
357 void GGadgetSetHandler(GGadget *g, GGadgetHandler handler);
358 GGadgetHandler GGadgetGetHandler(GGadget *g);
359
360 void GTextFieldSelect(GGadget *g,int sel_start, int sel_end);
361 void GTextFieldShow(GGadget *g,int pos);
362 void GTextFieldReplace(GGadget *g,const unichar_t *txt);
363 bool GTextFieldIsEmpty(GGadget *g);
364 void GCompletionFieldSetCompletion(GGadget *g,GTextCompletionHandler completion);
365 void GCompletionFieldSetCompletionMode(GGadget *g,int enabled);
366 void GGadgetClearList(GGadget *g);
367 void GGadgetSetList(GGadget *g, GTextInfo **ti, int32_t copyit);
368 GTextInfo **GGadgetGetList(GGadget *g,int32_t *len); /* Do not free!!! */
369 GTextInfo *GGadgetGetListItem(GGadget *g,int32_t pos);
370 GTextInfo *GGadgetGetListItemSelected(GGadget *g);
371 void GGadgetSelectListItem(GGadget *g,int32_t pos,int32_t sel);
372 void GGadgetSelectOneListItem(GGadget *g,int32_t pos);
373 int32_t GGadgetIsListItemSelected(GGadget *g,int32_t pos);
374 int32_t GGadgetGetFirstListSelectedItem(GGadget *g);
375 void GGadgetScrollListToPos(GGadget *g,int32_t pos);
376 void GGadgetScrollListToText(GGadget *g,const unichar_t *lab,int32_t sel);
377 void GGadgetSetListOrderer(GGadget *g,int (*orderer)(const void *, const void *));
378
379 void GColorButtonSetColor(GGadget *g, Color col);
380 Color GColorButtonGetColor(GGadget *g);
381
382 void GGadgetSetChecked(GGadget *g, int ison);
383 int GGadgetIsChecked(GGadget *g);
384
385 int GListIndexFromY(GGadget *g,int y);
386 void GListSetSBAlwaysVisible(GGadget *g,int always);
387 void GListSetPopupCallback(GGadget *g,void (*callback)(GGadget *,int));
388
389 int GTabSetGetTabCount(GGadget *g);
390 int GTabSetGetSel(GGadget *g);
391 void GTabSetSetSel(GGadget *g,int sel);
392 void GTabSetSetEnabled(GGadget *g,int pos, int enabled);
393 GWindow GTabSetGetSubwindow(GGadget *g,int pos);
394 int GTabSetGetTabLines(GGadget *g);
395 void GTabSetSetClosable(GGadget *g, bool flag);
396 void GTabSetSetMovable(GGadget *g, bool flag);
397 void GTabSetSetNestedExpose(GGadget *g, void (*)(GWindow,GGadget *,GEvent *));
398 void GTabSetSetNestedMouse(GGadget *g, int (*)(GGadget *,GEvent *));
399 void GTabSetSetRemoveSync(GGadget *g, void (*rs)(GWindow gw, int pos));
400 void GTabSetSetSwapSync(GGadget *g, void (*ss)(GWindow gw, int pos_a, int pos_b));
401 void GTabSetChangeTabName(GGadget *g, const char *name, int pos);
402 void GTabSetRemetric(GGadget *g);
403 void GTabSetSwapTabs(GGadget *g, int pos_a, int pos_b);
404 void GTabSetRemoveTabByPos(GGadget *g, int pos);
405 void GTabSetRemoveTabByName(GGadget *g, char *name);
406
407 int32_t GScrollBarGetPos(GGadget *g);
408 int32_t GScrollBarSetPos(GGadget *g,int32_t pos);
409 int32_t GScrollBarAddToPos(GGadget *g,int32_t offset);
410 void GScrollBarSetMustShow(GGadget *g, int32_t sb_min, int32_t sb_max, int32_t sb_pagesize,
411 int32_t sb_mustshow);
412 void GScrollBarSetBounds(GGadget *g, int32_t sb_min, int32_t sb_max, int32_t sb_pagesize );
413 void GScrollBarGetBounds(GGadget *g, int32_t *sb_min, int32_t *sb_max, int32_t *sb_pagesize );
414
415 void GMenuBarSetItemChecked(GGadget *g, int mid, int check);
416 void GMenuBarSetItemEnabled(GGadget *g, int mid, int enabled);
417 void GMenuBarSetItemName(GGadget *g, int mid, const unichar_t *name);
418 void GMenuSetShortcutDomain(char *domain);
419 const char *GMenuGetShortcutDomain(void);
420 int GMenuIsCommand(GEvent *event,char *shortcut);
421 int GMenuMask(void);
422 int GMenuAnyUnmaskedShortcuts(GGadget *mb1, GGadget *mb2);
423
424
425 void GFileChooserPopupCheck(GGadget *g,GEvent *e);
426 void GFileChooserFilterIt(GGadget *g);
427 void GFileChooserRefreshList(GGadget *g);
428 int GFileChooserFilterEh(GGadget *g,GEvent *e);
429 void GFileChooserConnectButtons(GGadget *g,GGadget *ok, GGadget *filter);
430 void GFileChooserSetFilterText(GGadget *g, const unichar_t *wildcard);
431 void GFileChooserSetFilterText8(GGadget *g, const char *wildcard);
432 void GFileChooserSetFilterFunc(GGadget *g,GFileChooserFilterType filter);
433 void GFileChooserSetInputFilenameFunc(GGadget *g,GFileChooserInputFilenameFuncType filter);
434 int GFileChooserDefInputFilenameFunc( GGadget *g, const unichar_t** currentFilename, unichar_t* oldfilename );
435 GFileChooserInputFilenameFuncType GFileChooserGetInputFilenameFunc(GGadget *g);
436 void GFileChooserSetDir(GGadget *g,unichar_t *dir);
437 struct giocontrol *GFileChooserReplaceIO(GGadget *g,struct giocontrol *gc);
438 unichar_t *GFileChooserGetDir(GGadget *g);
439 unichar_t *GFileChooserGetFilterText(GGadget *g);
440 char *GFileChooserGetFilterText8(GGadget *g);
441 GFileChooserFilterType GFileChooserGetFilterFunc(GGadget *g);
442 void GFileChooserSetFilename(GGadget *g,const unichar_t *defaultfile);
443 void GFileChooserSetMimetypes(GGadget *g,unichar_t **mimetypes);
444 unichar_t **GFileChooserGetMimetypes(GGadget *g);
445 void GFileChooserGetChildren(GGadget *g,GGadget **pulldown, GGadget **list, GGadget **tf);
446 int GFileChooserPosIsDir(GGadget *g, int pos);
447 unichar_t *GFileChooserFileNameOfPos(GGadget *g, int pos);
448 void GFileChooserSetShowHidden(int sh);
449 int GFileChooserGetShowHidden(void);
450 void GFileChooserSetDirectoryPlacement(int dp);
451 int GFileChooserGetDirectoryPlacement(void);
452 void GFileChooserSetBookmarks(unichar_t **b);
453 void GFileChooserSetPaths(GGadget *g, const char* const* path);
454 unichar_t **GFileChooserGetBookmarks(void);
455 void GFileChooserSetPrefsChangedCallback(void *data, void (*p_c)(void *));
456 char **GFileChooserGetMultipleFiles(const char* multipath);
457
458 void GHVBoxSetExpandableCol(GGadget *g,int col);
459 void GHVBoxSetExpandableRow(GGadget *g,int row);
460 void GHVBoxSetPadding(GGadget *g,int hpad, int vpad);
461 void GHVBoxFitWindow(GGadget *g);
462 void GHVBoxFitWindowCentered(GGadget *g);
463 void GHVBoxReflow(GGadget *g);
464
465 void GFlowBoxSetPadding(GGadget *g, int vpad, int hpad, int lpad);
466 int GGadgetIsGFlowBox(GGadget *g);
467 int GFlowBoxGetLabelSize(GGadget *g);
468 void GFlowBoxSetLabelSize(GGadget *g, int size);
469 void GScroll1BoxSetPadding(GGadget *g, int pad);
470 void GScroll1BoxSetSBAlwaysVisible(GGadget *g,int always);
471 void _GScroll1BoxGetDesiredSize(GGadget *g,GRect *outer, GRect *inner, int big);
472 int GScroll1BoxMinOppoSize(GGadget *g);
473 //void GScroll1BoxFitWindow(GGadget *g);
474
475 void GMatrixEditSet(GGadget *g,struct matrix_data *data, int rows, int copy_it);
476 struct matrix_data *GMatrixEditGet(GGadget *g, int *rows);
477 struct matrix_data *_GMatrixEditGet(GGadget *g, int *rows);
478 GGadget *_GMatrixEditGetActiveTextField(GGadget *g);
479 int GMatrixEditGetColCnt(GGadget *g);
480 int GMatrixEditGetActiveRow(GGadget *g);
481 int GMatrixEditGetActiveCol(GGadget *g);
482 void GMatrixEditActivateRowCol(GGadget *g, int r, int c);
483 void GMatrixEditDeleteRow(GGadget *g,int row);
484 void GMatrixEditScrollToRowCol(GGadget *g,int r, int c);
485 int GMatrixEditStringDlg(GGadget *g,int row,int col);
486 void GMatrixEditSetNewText(GGadget *g, char *text);
487 void GMatrixEditSetOtherButtonEnable(GGadget *g, void (*sob)(GGadget *g, int r, int c));
488 void GMatrixEditSetMouseMoveReporter(GGadget *g, void (*rmm)(GGadget *g, int r, int c));
489 void GMatrixEditSetTextChangeReporter(GGadget *g, void (*tcr)(GGadget *g, int r, int c, GGadget *text));
490 void GMatrixEditSetValidateStr(GGadget *g, char *(*validate)(GGadget *g, int r, int c, int wasnew, char *str));
491 void GMatrixEditSetBeforeDelete(GGadget *g, void (*predelete)(GGadget *g, int r));
492 void GMatrixEditSetRowMotionCallback(GGadget *g, void (*rowmotion)(GGadget *g, int oldr, int newr));
493 void GMatrixEditUp(GGadget *g);
494 void GMatrixEditDown(GGadget *g);
495 enum gme_updown { ud_up_enabled=1, ud_down_enabled=2 };
496 void GMatrixEditSetCanUpDown(GGadget *g, enum gme_updown (*canupdown)(GGadget *g, int r));
497 void GMatrixEditSetUpDownVisible(GGadget *g, int visible);
498 void GMatrixEditAddButtons(GGadget *g, GGadgetCreateData *gcd);
499 void GMatrixEditEnableColumn(GGadget *g, int col, int enabled);
500 void GMatrixEditShowColumn(GGadget *g, int col, int visible);
501 void GMatrixEditSetColumnChoices(GGadget *g, int col, GTextInfo *ti);
502 GMenuItem *GMatrixEditGetColumnChoices(GGadget *g, int col);
503 void GMatrixEditSetColumnCompletion(GGadget *g, int col, GTextCompletionHandler completion);
504 void GMatrixEditSetEditable(GGadget *g, int editable);
505
506 GWindow GDrawableGetWindow(GGadget *g);
507
508
509 extern void GGadgetPreparePopupImage(GWindow base,const unichar_t *msg,
510 const void *data,
511 GImage *(*get_image)(const void *data),
512 void (*free_image)(const void *data,GImage *img));
513 extern void GGadgetPreparePopup(GWindow base,const unichar_t *msg);
514 extern void GGadgetPreparePopup8(GWindow base, const char *msg);
515 extern void GGadgetEndPopup(void);
516 extern void GGadgetPopupExternalEvent(GEvent *e);
517
518 extern int GGadgetDispatchEvent(GGadget *g,GEvent *e);
519 extern void GGadgetTakesKeyboard(GGadget *g, int takes_keyboard);
520
521 /* Handles *?{}[] wildcards */
522 int GGadgetWildMatch(unichar_t *pattern, unichar_t *name,int ignorecase);
523 enum fchooserret GFileChooserDefFilter(GGadget *g,const struct gdirentry *ent,
524 const char *dir);
525
526 GWindow GMenuCreatePopupMenu(GWindow owner,GEvent *event, GMenuItem *mi);
527 GWindow GMenuCreatePopupMenuWithName(GWindow owner,GEvent *event, char* subMenuName,GMenuItem *mi);
528 GWindow _GMenuCreatePopupMenu(GWindow owner,GEvent *event, GMenuItem *mi,
529 void (*donecallback)(GWindow owner));
530 GWindow _GMenuCreatePopupMenuWithName(GWindow owner,GEvent *event, GMenuItem *mi,
531 char* subMenuName,
532 void (*donecallback)(GWindow owner));
533
534
535 GGadget *GLineCreate(struct gwindow *base, GGadgetData *gd,void *data);
536 GGadget *GGroupCreate(struct gwindow *base, GGadgetData *gd,void *data);
537 GGadget *GSpacerCreate(struct gwindow *base, GGadgetData *gd,void *data);
538 GGadget *GLabelCreate(struct gwindow *base, GGadgetData *gd,void *data);
539 GGadget *GButtonCreate(struct gwindow *base, GGadgetData *gd,void *data);
540 GGadget *GImageButtonCreate(struct gwindow *base, GGadgetData *gd,void *data);
541 GGadget *GListButtonCreate(struct gwindow *base, GGadgetData *gd,void *data);
542 GGadget *GColorButtonCreate(struct gwindow *base, GGadgetData *gd,void *data);
543 GGadget *GRadioCreate(struct gwindow *base, GGadgetData *gd,void *data);
544 GGadget *GCheckBoxCreate(struct gwindow *base, GGadgetData *gd,void *data);
545 GGadget *GVisibilityBoxCreate(struct gwindow *base, GGadgetData *gd,void *data);
546 GGadget *GScrollBarCreate(struct gwindow *base, GGadgetData *gd,void *data);
547 GGadget *GListCreate(struct gwindow *base, GGadgetData *gd,void *data);
548 GGadget *GTextFieldCreate(struct gwindow *base, GGadgetData *gd,void *data);
549 GGadget *GPasswordCreate(struct gwindow *base, GGadgetData *gd,void *data);
550 GGadget *GNumericFieldCreate(struct gwindow *base, GGadgetData *gd,void *data);
551 GGadget *GTextCompletionCreate(struct gwindow *base, GGadgetData *gd,void *data);
552 GGadget *GTextAreaCreate(struct gwindow *base, GGadgetData *gd,void *data);
553 GGadget *GListFieldCreate(struct gwindow *base, GGadgetData *gd,void *data);
554 GGadget *GSimpleListFieldCreate(struct gwindow *base, GGadgetData *gd,void *data);
555 GGadget *GMenuBarCreate(struct gwindow *base, GGadgetData *gd,void *data);
556 GGadget *GMenu2BarCreate(struct gwindow *base, GGadgetData *gd,void *data);
557 GGadget *GTabSetCreate(struct gwindow *base, GGadgetData *gd,void *data);
558 GGadget *GFileChooserCreate(struct gwindow *base, GGadgetData *gd,void *data);
559 GGadget *GHBoxCreate(struct gwindow *base, GGadgetData *gd,void *data);
560 GGadget *GVBoxCreate(struct gwindow *base, GGadgetData *gd,void *data);
561 GGadget *GHVBoxCreate(struct gwindow *base, GGadgetData *gd,void *data);
562 GGadget *GHVGroupCreate(struct gwindow *base, GGadgetData *gd,void *data);
563 GGadget *GFlowBoxCreate(struct gwindow *base, GGadgetData *gd,void *data);
564 GGadget *GScroll1BoxCreate(struct gwindow *base, GGadgetData *gd,void *data);
565 GGadget *GMatrixEditCreate(struct gwindow *base, GGadgetData *gd,void *data);
566 GGadget *GDrawableCreate(struct gwindow *base, GGadgetData *gd,void *data);
567
568 GGadget *CreateSlider(struct gwindow *base, GGadgetData *gd,void *data);
569 GGadget *CreateFileChooser(struct gwindow *base, GGadgetData *gd,void *data);
570 GGadget *CreateGadgets(struct gwindow *base, GGadgetCreateData *gcd);
571
572 GTextInfo **GTextInfoArrayFromList(GTextInfo *ti, uint16_t *cnt);
573
574 void InitImageCache(void);
575 void ClearImageCache(void);
576 void GGadgetSetImageDir(const char *dir);
577 void GGadgetSetImagePath(const char *path);
578 GImage *GGadgetImageCache(const char *filename);
579 int TryGGadgetImageCache(GImage *image, const char *name);
580
581 extern unichar_t *utf82u_mncopy(const char *utf8buf,unichar_t *mn);
582
583 extern double GetCalmReal8(GWindow gw,int cid,char *namer,int *err);
584 extern double GetReal8(GWindow gw,int cid,char *namer,int *err);
585 extern int GetCalmInt8(GWindow gw,int cid,char *name,int *err);
586 extern int GetInt8(GWindow gw,int cid,char *namer,int *err);
587 extern int GetUnicodeChar8(GWindow gw,int cid,char *namer,int *err);
588 extern void GGadgetProtest8(const char *labelr);
589
590 extern void GMenuItemParseShortCut(GMenuItem *mi,char *shortcut);
591 extern int GMenuItemParseMask(char *shortcut);
592 extern int GGadgetUndoMacEnglishOptionCombinations(GEvent *event);
593
594 /* Among other things, this routine sets global icon cache up. */
595 extern void GGadgetInit(void);
596 extern void GTabSetInit();
597 extern int GGadgetWithin(GGadget *g, int x, int y);
598 extern void GMenuItemArrayFree(GMenuItem *mi);
599 extern void GMenuItem2ArrayFree(GMenuItem2 *mi);
600 extern GMenuItem *GMenuItemArrayCopy(GMenuItem *mi, uint16_t *cnt);
601 extern GMenuItem *GMenuItem2ArrayCopy(GMenuItem2 *mi, uint16_t *cnt);
602
603 extern void GVisibilityBoxSetToMinWH(GGadget *g);
604
605 extern void GGadgetSetSkipHotkeyProcessing( GGadget *g, int v );
606 extern int GGadgetGetSkipHotkeyProcessing( GGadget *g );
607 extern void GGadgetSetSkipUnQualifiedHotkeyProcessing( GGadget *g, int v );
608 extern int GGadgetGetSkipUnQualifiedHotkeyProcessing( GGadget *g );
609
610 #endif /* FONTFORGE_GGADGET_H */