]> git.saurik.com Git - wxWidgets.git/blob - src/gtk1/utilsgtk.cpp
Made tearoff menus work for gtk :-)
[wxWidgets.git] / src / gtk1 / utilsgtk.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: utils.cpp
3 // Purpose:
4 // Author: Robert Roebling
5 // Id: $Id$
6 // Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10 #include "wx/utils.h"
11 #include "wx/string.h"
12
13 #include "wx/intl.h"
14 #include "wx/log.h"
15
16 #include "wx/process.h"
17
18 #include "wx/unix/execute.h"
19
20 #include <stdarg.h>
21 #include <string.h>
22 #include <sys/stat.h>
23 #include <sys/types.h>
24 #include <unistd.h>
25
26 #include "glib.h"
27 #include "gdk/gdk.h"
28 #include "gtk/gtk.h"
29 #include "gtk/gtkfeatures.h"
30 #include "gdk/gdkx.h"
31
32 #ifdef HAVE_X11_XKBLIB_H
33 #ifdef __HPUX__
34 /* under HP-UX XKBlib.h defines structures with field named "explicit" -
35 * which is, of course, an error for a C++ compiler */
36 #define explicit __wx_explicit
37 #endif
38
39 #include "X11/XKBlib.h"
40
41 #ifdef __HPUX__
42 #undef explicit
43 #endif // __HPUX__
44 #endif // HAVE_X11_XKBLIB_H
45
46 // ----------------------------------------------------------------------------
47 // misc.
48 // ----------------------------------------------------------------------------
49
50 void wxBell()
51 {
52 gdk_beep();
53 }
54
55 /* Don't synthesize KeyUp events holding down a key and producing
56 KeyDown events with autorepeat. */
57 #ifdef HAVE_X11_XKBLIB_H
58 bool wxSetDetectableAutoRepeat( bool flag )
59 {
60 Bool result;
61 XkbSetDetectableAutoRepeat( GDK_DISPLAY(), flag, &result );
62 return result; /* TRUE if keyboard hardware supports this mode */
63 }
64 #else
65 bool wxSetDetectableAutoRepeat( bool WXUNUSED(flag) )
66 {
67 return FALSE;
68 }
69 #endif
70
71 // ----------------------------------------------------------------------------
72 // display characterstics
73 // ----------------------------------------------------------------------------
74
75 void wxDisplaySize( int *width, int *height )
76 {
77 if (width) *width = gdk_screen_width();
78 if (height) *height = gdk_screen_height();
79 }
80
81 void wxGetMousePosition( int* x, int* y )
82 {
83 gdk_window_get_pointer( (GdkWindow*) NULL, x, y, (GdkModifierType*) NULL );
84 }
85
86 bool wxColourDisplay()
87 {
88 return TRUE;
89 }
90
91 int wxDisplayDepth()
92 {
93 return gdk_window_get_visual( (GdkWindow*) &gdk_root_parent )->depth;
94 }
95
96 int wxGetOsVersion(int *majorVsn, int *minorVsn)
97 {
98 if (majorVsn) *majorVsn = GTK_MAJOR_VERSION;
99 if (minorVsn) *minorVsn = GTK_MINOR_VERSION;
100
101 return wxGTK;
102 }
103
104 // ----------------------------------------------------------------------------
105 // subprocess routines
106 // ----------------------------------------------------------------------------
107
108 static void GTK_EndProcessDetector(gpointer data, gint source,
109 GdkInputCondition WXUNUSED(condition) )
110 {
111 wxEndProcessData *proc_data = (wxEndProcessData *)data;
112
113 wxHandleProcessTermination(proc_data);
114
115 close(source);
116 gdk_input_remove(proc_data->tag);
117 }
118
119 int wxAddProcessCallback(wxEndProcessData *proc_data, int fd)
120 {
121 int tag = gdk_input_add(fd,
122 GDK_INPUT_READ,
123 GTK_EndProcessDetector,
124 (gpointer)proc_data);
125
126 return tag;
127 }
128