]>
Commit | Line | Data |
---|---|---|
c801d85f | 1 | ///////////////////////////////////////////////////////////////////////////// |
3cbab641 | 2 | // Name: src/gtk1/utilsgtk.cpp |
c801d85f KB |
3 | // Purpose: |
4 | // Author: Robert Roebling | |
dfcb1ae0 | 5 | // Id: $Id$ |
6c9a19aa | 6 | // Copyright: (c) 1998 Robert Roebling |
65571936 | 7 | // Licence: wxWindows licence |
c801d85f KB |
8 | ///////////////////////////////////////////////////////////////////////////// |
9 | ||
14f355c2 VS |
10 | // For compilers that support precompilation, includes "wx.h". |
11 | #include "wx/wxprec.h" | |
12 | ||
c801d85f | 13 | #include "wx/utils.h" |
df91131c WS |
14 | |
15 | #ifndef WX_PRECOMP | |
16 | #include "wx/string.h" | |
88a7a4e1 | 17 | #include "wx/intl.h" |
e4db172a | 18 | #include "wx/log.h" |
df91131c | 19 | #endif |
c801d85f | 20 | |
46446cc2 | 21 | #include "wx/apptrait.h" |
c2ca375c | 22 | #include "wx/gtk1/private/timer.h" |
b46b1d59 | 23 | #include "wx/evtloop.h" |
5336ece4 VZ |
24 | #include "wx/process.h" |
25 | ||
518b5d2f VZ |
26 | #include "wx/unix/execute.h" |
27 | ||
c801d85f | 28 | #include <stdarg.h> |
c801d85f KB |
29 | #include <string.h> |
30 | #include <sys/stat.h> | |
31 | #include <sys/types.h> | |
dbd25330 | 32 | #include <sys/wait.h> // for WNOHANG |
c801d85f | 33 | #include <unistd.h> |
91b8de8d RR |
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" | |
88ac883a | 40 | |
27933891 | 41 | #ifdef HAVE_X11_XKBLIB_H |
154c4aa1 VZ |
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. */ | |
88ac883a | 45 | #define explicit __wx_explicit |
ec5d7799 | 46 | |
154c4aa1 | 47 | #include "X11/XKBlib.h" |
ec5d7799 | 48 | |
88ac883a | 49 | #undef explicit |
27933891 | 50 | #endif // HAVE_X11_XKBLIB_H |
dfcb1ae0 | 51 | |
d76fe38b RR |
52 | //----------------------------------------------------------------------------- |
53 | // data | |
54 | //----------------------------------------------------------------------------- | |
55 | ||
c2fa61e8 | 56 | extern GtkWidget *wxGetRootWindow(); |
d76fe38b RR |
57 | |
58 | //---------------------------------------------------------------------------- | |
c801d85f | 59 | // misc. |
d76fe38b | 60 | //---------------------------------------------------------------------------- |
c801d85f | 61 | |
518b5d2f | 62 | void wxBell() |
c801d85f | 63 | { |
e52f60e6 RR |
64 | gdk_beep(); |
65 | } | |
c801d85f | 66 | |
27933891 RR |
67 | /* Don't synthesize KeyUp events holding down a key and producing |
68 | KeyDown events with autorepeat. */ | |
69 | #ifdef HAVE_X11_XKBLIB_H | |
f0492f7d RR |
70 | bool wxSetDetectableAutoRepeat( bool flag ) |
71 | { | |
72 | Bool result; | |
73 | XkbSetDetectableAutoRepeat( GDK_DISPLAY(), flag, &result ); | |
df91131c | 74 | return result; /* true if keyboard hardware supports this mode */ |
27933891 RR |
75 | } |
76 | #else | |
77 | bool wxSetDetectableAutoRepeat( bool WXUNUSED(flag) ) | |
78 | { | |
df91131c | 79 | return false; |
f0492f7d | 80 | } |
27933891 | 81 | #endif |
f0492f7d | 82 | |
518b5d2f VZ |
83 | // ---------------------------------------------------------------------------- |
84 | // display characterstics | |
85 | // ---------------------------------------------------------------------------- | |
82052aff | 86 | |
d111a89a VZ |
87 | void *wxGetDisplay() |
88 | { | |
27df579a | 89 | return GDK_DISPLAY(); |
d111a89a VZ |
90 | } |
91 | ||
c0392997 RR |
92 | void wxDisplaySize( int *width, int *height ) |
93 | { | |
e52f60e6 RR |
94 | if (width) *width = gdk_screen_width(); |
95 | if (height) *height = gdk_screen_height(); | |
c0392997 RR |
96 | } |
97 | ||
904a68b6 RL |
98 | void wxDisplaySizeMM( int *width, int *height ) |
99 | { | |
100 | if (width) *width = gdk_screen_width_mm(); | |
101 | if (height) *height = gdk_screen_height_mm(); | |
102 | } | |
103 | ||
6de97a3b RR |
104 | void wxGetMousePosition( int* x, int* y ) |
105 | { | |
d3b9f782 | 106 | gdk_window_get_pointer( NULL, x, y, NULL ); |
e52f60e6 | 107 | } |
6de97a3b | 108 | |
518b5d2f | 109 | bool wxColourDisplay() |
6de97a3b | 110 | { |
df91131c | 111 | return true; |
6de97a3b RR |
112 | } |
113 | ||
518b5d2f | 114 | int wxDisplayDepth() |
6de97a3b | 115 | { |
c2fa61e8 | 116 | return gdk_window_get_visual( wxGetRootWindow()->window )->depth; |
6de97a3b RR |
117 | } |
118 | ||
57591e0e JS |
119 | wxWindow* wxFindWindowAtPoint(const wxPoint& pt) |
120 | { | |
121 | return wxGenericFindWindowAtPoint(pt); | |
122 | } | |
123 | ||
124 | ||
518b5d2f | 125 | // ---------------------------------------------------------------------------- |
c801d85f | 126 | // subprocess routines |
518b5d2f | 127 | // ---------------------------------------------------------------------------- |
cf447356 | 128 | |
865bb325 VZ |
129 | extern "C" { |
130 | static | |
90350682 VZ |
131 | void GTK_EndProcessDetector(gpointer data, gint source, |
132 | GdkInputCondition WXUNUSED(condition) ) | |
cf447356 | 133 | { |
b827d647 | 134 | wxEndProcessData * const |
5c33522f | 135 | proc_data = static_cast<wxEndProcessData *>(data); |
dbd25330 | 136 | |
b827d647 VZ |
137 | // child exited, end waiting |
138 | close(source); | |
447f908a | 139 | |
b827d647 VZ |
140 | // don't call us again! |
141 | gdk_input_remove(proc_data->tag); | |
dbd25330 | 142 | |
b827d647 | 143 | wxHandleProcessTermination(proc_data); |
3069ac4e | 144 | } |
865bb325 | 145 | } |
cf447356 | 146 | |
1d043598 | 147 | int wxGUIAppTraits::AddProcessCallback(wxEndProcessData *proc_data, int fd) |
c801d85f | 148 | { |
518b5d2f VZ |
149 | int tag = gdk_input_add(fd, |
150 | GDK_INPUT_READ, | |
151 | GTK_EndProcessDetector, | |
152 | (gpointer)proc_data); | |
c801d85f | 153 | |
518b5d2f | 154 | return tag; |
3069ac4e | 155 | } |
8bb6b2c0 | 156 | |
1d043598 VZ |
157 | #if wxUSE_TIMER |
158 | ||
c2ca375c VZ |
159 | wxTimerImpl* wxGUIAppTraits::CreateTimerImpl(wxTimer *timer) |
160 | { | |
161 | return new wxGTKTimerImpl(timer); | |
162 | } | |
163 | ||
1d043598 VZ |
164 | #endif // wxUSE_TIMER |
165 | ||
8bb6b2c0 VZ |
166 | // ---------------------------------------------------------------------------- |
167 | // wxPlatformInfo-related | |
168 | // ---------------------------------------------------------------------------- | |
169 | ||
170 | wxPortId wxGUIAppTraits::GetToolkitVersion(int *verMaj, int *verMin) const | |
171 | { | |
172 | if ( verMaj ) | |
173 | *verMaj = gtk_major_version; | |
174 | if ( verMin ) | |
175 | *verMin = gtk_minor_version; | |
176 | ||
177 | return wxPORT_GTK; | |
178 | } | |
61ecd225 | 179 | |
2ddff00c | 180 | wxEventLoopBase* wxGUIAppTraits::CreateEventLoop() |
61ecd225 | 181 | { |
b46b1d59 | 182 | return new wxEventLoop; |
61ecd225 | 183 | } |
a1f1afe4 | 184 | |
6c4f5ea5 | 185 | #if wxUSE_INTL |
a1f1afe4 VZ |
186 | void wxGUIAppTraits::SetLocale() |
187 | { | |
188 | gtk_set_locale(); | |
189 | } | |
6c4f5ea5 | 190 | #endif |
a1f1afe4 | 191 |