Debian Codegraph @

src/af/xap/gtk/xap_UnixDialogHelper.h

raw
1 /* AbiSource Program Utilities
2 * Copyright (C) 1998 AbiSource, Inc.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 * 02110-1301 USA.
18 */
19
20 #ifndef UT_DIALOGHELPER_H
21 #define UT_DIALOGHELPER_H
22
23
24 #include <gtk/gtk.h>
25 #include <gdk/gdk.h>
26
27 #include <functional>
28
29 #include "ut_types.h"
30 #include "xap_Strings.h"
31
32 class XAP_Frame;
33 class XAP_FrameHelper;
34 class XAP_App;
35 class XAP_Dialog;
36
37 // This macro sets up stack pointers to be used with the ConvertToUnixString
38 // macro.
39 #define SETUP_UNIX_STRING gchar * newstr = NULL;
40
41 // This macro is for use in Unix dialogs where the strings are to
42 // be stripped of ampersands (Windows accelerator characters).
43 #define CONVERT_TO_UNIX_STRING(str, id, newstr) do { \
44 FREEP(newstr); \
45 std::string _s; \
46 pSS->getValueUTF8(id,_s); \
47 UT_XML_cloneNoAmpersands(newstr, _s.c_str()); \
48 } while (0);
49
50 // This macro is for use in Unix dialogs where the accelerator characters
51 // strings need to be converted to underscores.
52 #define CONVERT_TO_ACC_STRING(str, id, newstr) do { \
53 FREEP(newstr); \
54 std::string _s; \
55 pSS->getValueUTF8(id,_s); \
56 UT_XML_cloneConvAmpersands(newstr, _s.c_str()); \
57 } while (0);
58
59
60 /** load a GtkBuilder for a dialog using the standard path.
61 * @param name the filename of the dialog (no path)
62 * @return the GtkBuilder or NULL. The returned object my be freed as usual.
63 */
64 GtkBuilder * newDialogBuilder(const char * name);
65 void connectFocus(GtkWidget *widget,const XAP_Frame *frame);
66 void connectFocusModeless(GtkWidget *widget,const XAP_App *pApp);
67 void connectFocusModelessOther(GtkWidget *widget, const XAP_App *pApp,
68 std::pointer_to_unary_function<int, gboolean> *other_function);
69 bool isTransientWindow(GtkWindow *window,GtkWindow *parent);
70
71 // This is a very thin message box; only use it for startup errors
72 // or places where you can't use the message box class (like when
73 // you don't have a frame yet).
74 void messageBoxOK(const char * message);
75
76 // Centers a GTK window inside a parent window
77 void centerDialog(GtkWidget * parent, GtkWidget * child, bool set_transient_for = true);
78
79 #if !GTK_CHECK_VERSION(3,0,0)
80 GtkStyle * get_ensured_style (GtkWidget * w);
81 #endif
82
83 // creates a GtkDrawingArea, and pushes/pops correct visual and colormap
84 GtkWidget *createDrawingArea ();
85
86 void abiSetupModalDialog(GtkDialog * me, XAP_Frame *pFrame, XAP_Dialog * pDlg, gint dfl_id);
87 gint abiRunModalDialog(GtkDialog * me, bool destroyDialog, AtkRole role = ATK_ROLE_DIALOG);
88 gint abiRunModalDialog(GtkDialog * me, XAP_Frame *pFrame, XAP_Dialog * pDlg, gint dfl_id, bool destroyDialog, AtkRole role = ATK_ROLE_DIALOG);
89 void abiSetupModelessDialog(GtkDialog * me, XAP_Frame * pFrame, XAP_Dialog * pDlg, gint dfl_id, bool abi_modeless = true, AtkRole role = ATK_ROLE_DIALOG);
90 void abiDestroyWidget(GtkWidget * me);
91
92 GtkWidget* abiAddStockButton (GtkDialog * me, const gchar * btn_id,
93 gint response_id) ;
94 GtkWidget* abiAddButton(GtkDialog * me, const gchar * btn_id,
95 gint response_id);
96
97 GtkWidget * abiDialogNew(const char * role, gboolean resizable = FALSE);
98 GtkWidget * abiDialogNew(const char * role, gboolean resizable, const char * title, ...);
99 GtkWidget * abiGtkMenuFromCStrVector(const UT_GenericVector<const char*> & vec, GCallback cb, gpointer data);
100
101 void abiDialogSetTitle(GtkWidget * dlg, const char * title, ...)
102 ABI_PRINTF_FORMAT(2,3);
103
104 void convertMnemonics(gchar * s);
105 std::string & convertMnemonics(std::string & s);
106
107 void localizeLabel(GtkWidget * widget, const XAP_StringSet * pSS, XAP_String_Id id);
108 void localizeLabelUnderline(GtkWidget * widget, const XAP_StringSet * pSS, XAP_String_Id id);
109 void localizeLabelMarkup(GtkWidget * widget, const XAP_StringSet * pSS, XAP_String_Id id);
110 void localizeButton(GtkWidget * widget, const XAP_StringSet * pSS, XAP_String_Id id);
111 void localizeButtonUnderline(GtkWidget * widget, const XAP_StringSet * pSS, XAP_String_Id id);
112 void localizeButtonMarkup(GtkWidget * widget, const XAP_StringSet * pSS, XAP_String_Id id);
113 void localizeMenu(GtkWidget * widget, const XAP_StringSet * pSS, XAP_String_Id id);
114 void localizeMenuItem(GtkWidget * widget, const XAP_StringSet * pSS, XAP_String_Id id);
115 void setLabelMarkup(GtkWidget * widget, const gchar * str);
116
117
118 // Returns the root window of the X display, useful for doing
119 // pointer or coordinate measurement on an absolute scale.
120 GdkWindow * getRootWindow(GtkWidget * widget);
121
122 void abiSetActivateOnWidgetToActivateButton( GtkWidget* source, GtkWidget* button );
123
124 #endif /* UT_DIALOGHELPER_H */