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_GWIDGET_H 29 #define FONTFORGE_GWIDGET_H 30 31 #include "gdraw.h" 32 #include "ggadget.h" 33 #include "gprogress.h" 34 35 #include <stdarg.h> 36 37 struct ggadget; 38 struct ggadgetcreatedata; 39 struct gtimer; 40 41 typedef GWindow GWidget; 42 43 typedef struct gwidgetcreatedata { 44 GRect r; 45 struct ggadgetcreatedata *gcd; 46 struct gwidgetcreatedata *wcd; 47 unichar_t *title; 48 unsigned int trap_input: 1; 49 unsigned int tab_navigation: 1; 50 unsigned int arrow_navigation: 1; 51 unsigned int do_default: 1; 52 unsigned int do_cancel: 1; 53 Color fore, back; 54 void (*e_h)(GWindow, GEvent *); /* User's event function for window, our eh will call it */ 55 } GWidgetData; 56 57 typedef struct gwidgetcreatordata { 58 GWidget *(*creator)(GWidget *parent, GWidgetData *, void *data); 59 GWidgetData wd; 60 void *data; 61 } GWidgetCreateData; 62 63 extern GWindow GWidgetCreateTopWindow(GDisplay *gdisp, GRect *pos, int (*eh)(GWindow,GEvent *), void *user_data, GWindowAttrs *wattrs); 64 extern GWindow GWidgetCreateSubWindow(GWindow w, GRect *pos, int (*eh)(GWindow,GEvent *), void *user_data, GWindowAttrs *wattrs); 65 extern GWindow GWidgetCreatePalette(GWindow w, GRect *pos, int (*eh)(GWindow,GEvent *), void *user_data, GWindowAttrs *wattrs); 66 67 GWindow GWindowGetCurrentFocusTopWindow(void); 68 GWindow GWidgetGetCurrentFocusWindow(void); 69 GWindow GWidgetGetPreviousFocusTopWindow(void); 70 struct ggadget *GWindowGetCurrentFocusGadget(void); 71 struct ggadget *GWindowGetFocusGadgetOfWindow(GWindow gw); 72 void GWindowClearFocusGadgetOfWindow(GWindow gw); 73 void GWidgetIndicateFocusGadget(struct ggadget *g); 74 void GWidgetNextFocus(GWindow); 75 void GWidgetPrevFocus(GWindow); 76 void GWidgetRequestVisiblePalette(GWindow palette,int visible); 77 void GWidgetHidePalettes(void); 78 79 struct ggadget *GWidgetGetControl(GWindow gw, int cid); 80 struct ggadget *_GWidgetGetGadgets(GWindow gw); 81 GWindow GWidgetGetParent(GWindow gw); 82 GWindow GWidgetGetTopWidget(GWindow gw); 83 extern GDrawEH GWidgetGetEH(GWindow w); 84 extern void GWidgetSetEH(GWindow w,GDrawEH e_h); 85 extern void GWidgetFlowGadgets(GWindow gw); 86 extern void GWidgetToDesiredSize(GWindow gw); 87 88 /* Built in dialogs */ 89 unichar_t *GWidgetOpenFile(const unichar_t *title, const unichar_t *defaultfile, 90 const unichar_t *initial_filter, unichar_t **mimetypes,GFileChooserFilterType filter); 91 unichar_t *GWidgetSaveAsFile(const unichar_t *title, const unichar_t *defaultfile, 92 const unichar_t *initial_filter, unichar_t **mimetypes,GFileChooserFilterType filter ); 93 unichar_t *GWidgetSaveAsFileWithGadget(const unichar_t *title, const unichar_t *defaultfile, 94 const unichar_t *initial_filter, unichar_t **mimetypes, 95 GFileChooserFilterType filter, 96 GFileChooserInputFilenameFuncType filenamefunc, 97 GGadgetCreateData *optional_gcd); 98 char *GWidgetOpenFile8(const char *title, const char *defaultfile, 99 const char *initial_filter, char **mimetypes,GFileChooserFilterType filter); 100 char *GWidgetOpenFileWPath8(const char *title, const char *defaultfile, 101 const char *initial_filter, char **mimetypes,GFileChooserFilterType filter, const char* const* path); 102 char *GWidgetSaveAsFileWithGadget8(const char *title, const char *defaultfile, 103 const char *initial_filter, char **mimetypes, 104 GFileChooserFilterType filter, 105 GFileChooserInputFilenameFuncType filenamefunc, 106 GGadgetCreateData *optional_gcd); 107 char *GWidgetSaveAsFile8(const char *title, const char *defaultfile, 108 const char *initial_filter, char **mimetypes,GFileChooserFilterType filter ); 109 int GWidgetAsk(const unichar_t *title, const unichar_t **answers, const unichar_t *mn, 110 int def, int cancel,const unichar_t *question,...); 111 void GWidgetError(const unichar_t *title,const unichar_t *statement,...); 112 unichar_t *GWidgetAskStringR(int title, const unichar_t *def,int question,...); 113 int GWidgetAsk8(const char *title, const char **answers, 114 int def, int cancel,const char *question,...); 115 int GWidgetAskCentered8(const char *title, 116 const char ** answers, int def, int cancel,const char *question,...); 117 char *GWidgetAskString8(const char *title, 118 const char *def,const char *question,...); 119 char *GWidgetAskPassword8(const char *title, 120 const char *def,const char *question,...); 121 void GWidgetPostNotice8(const char *title,const char *statement,...); 122 void _GWidgetPostNotice8(const char *title,const char *statement,va_list ap,int timeout); 123 void GWidgetPostNoticeTimeout8(int timeout, const char *title,const char *statement,...); 124 int GWidgetPostNoticeActive8(const char *title); 125 void GWidgetError8(const char *title,const char *statement,...); 126 127 int GWidgetChoices8(const char *title, const char **choices,int cnt, int def, 128 const char *question,...); 129 int GWidgetChoicesB8(char *title, const char **choices, int cnt, int def, 130 char *buts[2], const char *question,...); 131 int GWidgetChoicesBM8(const char *title, const char **choices, char *sel, 132 int cnt, char *buts[2], const char *question,...); 133 134 extern struct hslrgb GWidgetColor(const char *title,struct hslrgb *defcol,struct hslrgb fontcols[6]); 135 extern struct hslrgba GWidgetColorA(const char *title,struct hslrgba *defcol,struct hslrgba fontcols[6]); 136 137 #define gwwv_choose_multiple GWidgetChoicesBM8 138 #define gwwv_choose_with_buttons GWidgetChoicesB8 139 #define gwwv_choose GWidgetChoices8 140 #define gwwv_ask_string GWidgetAskString8 141 #define gwwv_ask_password GWidgetAskPassword8 142 #define gwwv_ask GWidgetAsk8 143 #define gwwv_ask_centered GWidgetAskCentered8 144 #define gwwv_post_error GWidgetError8 145 #define gwwv_post_notice GWidgetPostNotice8 146 #define gwwv_post_notice_timeout GWidgetPostNoticeTimeout8 147 #define gwwv_open_filename(tit,def,filter,filtfunc) GWidgetOpenFile8(tit,def,filter,NULL,filtfunc) 148 #define gwwv_open_filename_with_path(tit,def,filter,filtfunc,path) GWidgetOpenFileWPath8(tit,def,filter,NULL,filtfunc,path) 149 #define gwwv_save_filename(tit,def,filter) GWidgetSaveAsFile8(tit,def,filter,NULL,NULL) 150 #define gwwv_save_filename_with_gadget(tit,def,filter,gcd) GWidgetSaveAsFileWithGadget8(tit,def,filter,NULL,NULL,NULL,gcd) 151 152 void GWidgetCreateInsChar(void); /* takes input even when a modal dlg is active */ 153 /* but is not modal itself */ 154 void GInsCharSetChar(unichar_t ch); /* Sets current selection in ins char dlg */ 155 156 extern GIC *GWidgetCreateInputContext(GWindow w,enum gic_style def_style); 157 extern GIC *GWidgetGetInputContext(GWindow w); 158 159 160 #endif /* FONTFORGE_GWIDGET_H */ 161