]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - radiant/gtkmisc.h
uncrustify! now the code is only ugly on the *inside*
[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         win32_get_window_pos( wnd, x, y );
40 }
41
42 #else
43
44 inline void get_window_pos( GtkWidget *wnd, int* x, int* y ){
45         gdk_window_get_root_origin( wnd->window, x, y );
46 }
47
48 #endif
49
50
51 struct window_position_t
52 {
53         int x, y, w, h;
54 };
55
56 void save_window_pos( GtkWidget *wnd, window_position_t& pos );
57 void load_window_pos( GtkWidget *wnd, window_position_t& pos );
58 gint widget_delete_hide( GtkWidget *widget );
59
60 // GdkPixmap **gdkpixmap, GdkBitmap **mask
61 bool WINAPI load_plugin_bitmap( const char* filename, void **gdkpixmap, void **mask );
62 void load_pixmap( const char* filename, GtkWidget* widget, GdkPixmap **gdkpixmap, GdkBitmap **mask );
63 GtkWidget* new_pixmap( GtkWidget* widget, const char* filename );
64
65 GtkWidget* menu_separator( GtkWidget *menu );
66 GtkWidget* menu_tearoff( GtkWidget *menu );
67 GtkWidget* create_sub_menu_with_mnemonic( GtkWidget *bar, const gchar *mnemonic );
68 GtkWidget* create_menu_item_with_mnemonic( GtkWidget *menu, const gchar *mnemonic, GtkSignalFunc func, int id );
69 GtkWidget* create_check_menu_item_with_mnemonic( GtkWidget *menu, const gchar *mnemonic, GtkSignalFunc func, int id, gboolean active );
70 GtkWidget* create_radio_menu_item_with_mnemonic( GtkWidget *menu, GtkWidget *last, const gchar *mnemonic, GtkSignalFunc func, int id, gboolean state );
71 GtkWidget* create_menu_in_menu_with_mnemonic( GtkWidget *menu, const gchar *mnemonic );
72
73
74 /*!
75    \fn gtk_MessageBox
76    do various message boxes, IDOK .. IDNO
77    URL adds an optional 'go to URL' button
78  */
79 int WINAPI gtk_MessageBox( void *parent, const char* lpText, const char* lpCaption = "Radiant", guint32 uType = MB_OK, const char* URL = NULL );
80 // NOTE: the returned filename is allocated with g_malloc and MUST be freed with g_free (both for win32 and Gtk dialogs)
81 // GtkWidget *parent
82 const gchar* file_dialog( void *parent, gboolean open, const char* title, const char* path = (char*)NULL, const char* pattern = NULL, const char *baseSubDir = NULL );
83
84 /*!
85    \fn dir_dialog, prompts for a directory
86  */
87 char* WINAPI dir_dialog( void *parent, const char* title = "Choose Directory", const char* path = (char*)NULL );
88 // GtkWidget *parent
89 bool WINAPI color_dialog( void *parent, float *color, const char* title = "Choose Color" );
90
91 void dialog_button_callback( GtkWidget *widget, gpointer data );
92 gint dialog_delete_callback( GtkWidget *widget, GdkEvent* event, gpointer data );
93
94 void OpenURL( const char *url );
95
96 void CheckMenuSplitting( GtkWidget *&menu );
97
98 #endif // _GTK_MISC_H_