]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - radiant/gtkmisc.h
ported over the 1.5 branch version of q3map2 which is newer
[xonotic/netradiant.git] / radiant / gtkmisc.h
1 /*
2 Copyright (c) 2001, Loki software, inc.
3 All rights reserved.
4
5 Redistribution and use in source and binary forms, with or without modification,
6 are permitted provided that the following conditions are met:
7
8 Redistributions of source code must retain the above copyright notice, this list
9 of conditions and the following disclaimer.
10
11 Redistributions in binary form must reproduce the above copyright notice, this
12 list of conditions and the following disclaimer in the documentation and/or
13 other materials provided with the distribution.
14
15 Neither the name of Loki software nor the names of its contributors may be used
16 to endorse or promote products derived from this software without specific prior
17 written permission.
18
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
20 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
23 DIRECT,INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 #ifndef _GTK_MISC_H_
32 #define _GTK_MISC_H_
33
34 #ifdef _WIN32
35
36 void win32_get_window_pos(GtkWidget *widget, gint *x, gint *y);
37
38 inline void get_window_pos(GtkWidget *wnd, int* x, int* y)
39 {
40   win32_get_window_pos(wnd, x, y);
41 }
42
43 #else
44
45 inline void get_window_pos(GtkWidget *wnd, int* x, int* y)
46 {
47   gdk_window_get_root_origin (wnd->window, x, y);
48 }
49
50 #endif
51
52
53 struct window_position_t
54 {
55   int x, y, w, h;
56 };
57
58 void save_window_pos (GtkWidget *wnd, window_position_t& pos);
59 void load_window_pos (GtkWidget *wnd, window_position_t& pos);
60 gint widget_delete_hide (GtkWidget *widget);
61
62 // GdkPixmap **gdkpixmap, GdkBitmap **mask
63 bool WINAPI load_plugin_bitmap (const char* filename, void **gdkpixmap, void **mask);
64 void load_pixmap (const char* filename, GtkWidget* widget, GdkPixmap **gdkpixmap, GdkBitmap **mask);
65 GtkWidget* new_pixmap (GtkWidget* widget, const char* filename);
66
67 GtkWidget* menu_separator (GtkWidget *menu);
68 GtkWidget* menu_tearoff (GtkWidget *menu);
69 GtkWidget* create_sub_menu_with_mnemonic (GtkWidget *bar, const gchar *mnemonic);
70 GtkWidget* create_menu_item_with_mnemonic (GtkWidget *menu, const gchar *mnemonic, GtkSignalFunc func, int id);
71 GtkWidget* create_check_menu_item_with_mnemonic (GtkWidget *menu, const gchar *mnemonic, GtkSignalFunc func, int id, gboolean active);
72 GtkWidget* create_radio_menu_item_with_mnemonic (GtkWidget *menu, GtkWidget *last, const gchar *mnemonic, GtkSignalFunc func, int id, gboolean state);
73 GtkWidget* create_menu_in_menu_with_mnemonic (GtkWidget *menu, const gchar *mnemonic);
74
75
76 /*!
77 \fn gtk_MessageBox
78 do various message boxes, IDOK .. IDNO
79 URL adds an optional 'go to URL' button
80 */
81 int WINAPI gtk_MessageBox (void *parent, const char* lpText, const char* lpCaption = "Radiant", guint32 uType = MB_OK, const char* URL = NULL);
82 // NOTE: the returned filename is allocated with g_malloc and MUST be freed with g_free (both for win32 and Gtk dialogs)
83 // GtkWidget *parent
84 const gchar* file_dialog (void *parent, gboolean open, const char* title, const char* path = (char*)NULL, const char* pattern = NULL, const char *baseSubDir = NULL);
85
86 /*!
87 \fn dir_dialog, prompts for a directory
88 */
89 char* WINAPI dir_dialog (void *parent, const char* title = "Choose Directory", const char* path = (char*)NULL);
90 // GtkWidget *parent
91 bool WINAPI color_dialog (void *parent, float *color, const char* title = "Choose Color");
92
93 void dialog_button_callback (GtkWidget *widget, gpointer data);
94 gint dialog_delete_callback (GtkWidget *widget, GdkEvent* event, gpointer data);
95
96 void OpenURL(const char *url);
97
98 void CheckMenuSplitting (GtkWidget *&menu);
99
100 #endif // _GTK_MISC_H_