]> git.saurik.com Git - wxWidgets.git/blob - src/gtk1/utilsgtk.cpp
supporting full style mask
[wxWidgets.git] / src / gtk1 / utilsgtk.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/gtk1/utilsgtk.cpp
3 // Purpose:
4 // Author: Robert Roebling
5 // Id: $Id$
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10 // For compilers that support precompilation, includes "wx.h".
11 #include "wx/wxprec.h"
12
13 #include "wx/utils.h"
14
15 #ifndef WX_PRECOMP
16 #include "wx/string.h"
17 #include "wx/intl.h"
18 #include "wx/log.h"
19 #endif
20
21 #include "wx/apptrait.h"
22 #include "wx/gtk1/private/timer.h"
23 #include "wx/evtloop.h"
24 #include "wx/process.h"
25
26 #include "wx/unix/execute.h"
27
28 #include <stdarg.h>
29 #include <string.h>
30 #include <sys/stat.h>
31 #include <sys/types.h>
32 #include <sys/wait.h> // for WNOHANG
33 #include <unistd.h>
34
35 #include "glib.h"
36 #include "gdk/gdk.h"
37 #include "gtk/gtk.h"
38 #include "gtk/gtkfeatures.h"
39 #include "gdk/gdkx.h"
40
41 #ifdef HAVE_X11_XKBLIB_H
42 /* under HP-UX and Solaris 2.6, at least, XKBlib.h defines structures with
43 * field named "explicit" - which is, of course, an error for a C++
44 * compiler. To be on the safe side, just redefine it everywhere. */
45 #define explicit __wx_explicit
46
47 #include "X11/XKBlib.h"
48
49 #undef explicit
50 #endif // HAVE_X11_XKBLIB_H
51
52 //-----------------------------------------------------------------------------
53 // data
54 //-----------------------------------------------------------------------------
55
56 extern GtkWidget *wxGetRootWindow();
57
58 //----------------------------------------------------------------------------
59 // misc.
60 //----------------------------------------------------------------------------
61 #ifndef __EMX__
62 // on OS/2, we use the wxBell from wxBase library
63
64 void wxBell()
65 {
66 gdk_beep();
67 }
68 #endif
69
70 /* Don't synthesize KeyUp events holding down a key and producing
71 KeyDown events with autorepeat. */
72 #ifdef HAVE_X11_XKBLIB_H
73 bool wxSetDetectableAutoRepeat( bool flag )
74 {
75 Bool result;
76 XkbSetDetectableAutoRepeat( GDK_DISPLAY(), flag, &result );
77 return result; /* true if keyboard hardware supports this mode */
78 }
79 #else
80 bool wxSetDetectableAutoRepeat( bool WXUNUSED(flag) )
81 {
82 return false;
83 }
84 #endif
85
86 // ----------------------------------------------------------------------------
87 // display characterstics
88 // ----------------------------------------------------------------------------
89
90 void *wxGetDisplay()
91 {
92 return GDK_DISPLAY();
93 }
94
95 void wxDisplaySize( int *width, int *height )
96 {
97 if (width) *width = gdk_screen_width();
98 if (height) *height = gdk_screen_height();
99 }
100
101 void wxDisplaySizeMM( int *width, int *height )
102 {
103 if (width) *width = gdk_screen_width_mm();
104 if (height) *height = gdk_screen_height_mm();
105 }
106
107 void wxGetMousePosition( int* x, int* y )
108 {
109 gdk_window_get_pointer( NULL, x, y, NULL );
110 }
111
112 bool wxColourDisplay()
113 {
114 return true;
115 }
116
117 int wxDisplayDepth()
118 {
119 return gdk_window_get_visual( wxGetRootWindow()->window )->depth;
120 }
121
122 wxWindow* wxFindWindowAtPoint(const wxPoint& pt)
123 {
124 return wxGenericFindWindowAtPoint(pt);
125 }
126
127
128 // ----------------------------------------------------------------------------
129 // subprocess routines
130 // ----------------------------------------------------------------------------
131
132 extern "C" {
133 static
134 void GTK_EndProcessDetector(gpointer data, gint source,
135 GdkInputCondition WXUNUSED(condition) )
136 {
137 wxEndProcessData * const
138 proc_data = static_cast<wxEndProcessData *>(data);
139
140 // child exited, end waiting
141 close(source);
142
143 // don't call us again!
144 gdk_input_remove(proc_data->tag);
145
146 wxHandleProcessTermination(proc_data);
147 }
148 }
149
150 int wxGUIAppTraits::AddProcessCallback(wxEndProcessData *proc_data, int fd)
151 {
152 int tag = gdk_input_add(fd,
153 GDK_INPUT_READ,
154 GTK_EndProcessDetector,
155 (gpointer)proc_data);
156
157 return tag;
158 }
159
160 #if wxUSE_TIMER
161
162 wxTimerImpl* wxGUIAppTraits::CreateTimerImpl(wxTimer *timer)
163 {
164 return new wxGTKTimerImpl(timer);
165 }
166
167 #endif // wxUSE_TIMER
168
169 // ----------------------------------------------------------------------------
170 // wxPlatformInfo-related
171 // ----------------------------------------------------------------------------
172
173 wxPortId wxGUIAppTraits::GetToolkitVersion(int *verMaj, int *verMin) const
174 {
175 if ( verMaj )
176 *verMaj = gtk_major_version;
177 if ( verMin )
178 *verMin = gtk_minor_version;
179
180 return wxPORT_GTK;
181 }
182
183 wxEventLoopBase* wxGUIAppTraits::CreateEventLoop()
184 {
185 return new wxEventLoop;
186 }
187
188 #if wxUSE_INTL
189 void wxGUIAppTraits::SetLocale()
190 {
191 gtk_set_locale();
192 }
193 #endif
194