]>
Commit | Line | Data |
---|---|---|
c801d85f | 1 | ///////////////////////////////////////////////////////////////////////////// |
3cbab641 | 2 | // Name: src/gtk1/utilsgtk.cpp |
c801d85f KB |
3 | // Purpose: |
4 | // Author: Robert Roebling | |
6c9a19aa | 5 | // Copyright: (c) 1998 Robert Roebling |
65571936 | 6 | // Licence: wxWindows licence |
c801d85f KB |
7 | ///////////////////////////////////////////////////////////////////////////// |
8 | ||
14f355c2 VS |
9 | // For compilers that support precompilation, includes "wx.h". |
10 | #include "wx/wxprec.h" | |
11 | ||
c801d85f | 12 | #include "wx/utils.h" |
df91131c WS |
13 | |
14 | #ifndef WX_PRECOMP | |
15 | #include "wx/string.h" | |
88a7a4e1 | 16 | #include "wx/intl.h" |
e4db172a | 17 | #include "wx/log.h" |
df91131c | 18 | #endif |
c801d85f | 19 | |
46446cc2 | 20 | #include "wx/apptrait.h" |
c2ca375c | 21 | #include "wx/gtk1/private/timer.h" |
b46b1d59 | 22 | #include "wx/evtloop.h" |
5336ece4 VZ |
23 | #include "wx/process.h" |
24 | ||
c801d85f | 25 | #include <stdarg.h> |
c801d85f KB |
26 | #include <string.h> |
27 | #include <sys/stat.h> | |
28 | #include <sys/types.h> | |
dbd25330 | 29 | #include <sys/wait.h> // for WNOHANG |
c801d85f | 30 | #include <unistd.h> |
91b8de8d RR |
31 | |
32 | #include "glib.h" | |
33 | #include "gdk/gdk.h" | |
34 | #include "gtk/gtk.h" | |
35 | #include "gtk/gtkfeatures.h" | |
36 | #include "gdk/gdkx.h" | |
88ac883a | 37 | |
27933891 | 38 | #ifdef HAVE_X11_XKBLIB_H |
154c4aa1 VZ |
39 | /* under HP-UX and Solaris 2.6, at least, XKBlib.h defines structures with |
40 | * field named "explicit" - which is, of course, an error for a C++ | |
41 | * compiler. To be on the safe side, just redefine it everywhere. */ | |
88ac883a | 42 | #define explicit __wx_explicit |
ec5d7799 | 43 | |
154c4aa1 | 44 | #include "X11/XKBlib.h" |
ec5d7799 | 45 | |
88ac883a | 46 | #undef explicit |
27933891 | 47 | #endif // HAVE_X11_XKBLIB_H |
dfcb1ae0 | 48 | |
d76fe38b RR |
49 | //----------------------------------------------------------------------------- |
50 | // data | |
51 | //----------------------------------------------------------------------------- | |
52 | ||
c2fa61e8 | 53 | extern GtkWidget *wxGetRootWindow(); |
d76fe38b RR |
54 | |
55 | //---------------------------------------------------------------------------- | |
c801d85f | 56 | // misc. |
d76fe38b | 57 | //---------------------------------------------------------------------------- |
c801d85f | 58 | |
518b5d2f | 59 | void wxBell() |
c801d85f | 60 | { |
e52f60e6 RR |
61 | gdk_beep(); |
62 | } | |
c801d85f | 63 | |
27933891 RR |
64 | /* Don't synthesize KeyUp events holding down a key and producing |
65 | KeyDown events with autorepeat. */ | |
66 | #ifdef HAVE_X11_XKBLIB_H | |
f0492f7d RR |
67 | bool wxSetDetectableAutoRepeat( bool flag ) |
68 | { | |
69 | Bool result; | |
70 | XkbSetDetectableAutoRepeat( GDK_DISPLAY(), flag, &result ); | |
df91131c | 71 | return result; /* true if keyboard hardware supports this mode */ |
27933891 RR |
72 | } |
73 | #else | |
74 | bool wxSetDetectableAutoRepeat( bool WXUNUSED(flag) ) | |
75 | { | |
df91131c | 76 | return false; |
f0492f7d | 77 | } |
27933891 | 78 | #endif |
f0492f7d | 79 | |
518b5d2f VZ |
80 | // ---------------------------------------------------------------------------- |
81 | // display characterstics | |
82 | // ---------------------------------------------------------------------------- | |
82052aff | 83 | |
d111a89a VZ |
84 | void *wxGetDisplay() |
85 | { | |
27df579a | 86 | return GDK_DISPLAY(); |
d111a89a VZ |
87 | } |
88 | ||
c0392997 RR |
89 | void wxDisplaySize( int *width, int *height ) |
90 | { | |
e52f60e6 RR |
91 | if (width) *width = gdk_screen_width(); |
92 | if (height) *height = gdk_screen_height(); | |
c0392997 RR |
93 | } |
94 | ||
904a68b6 RL |
95 | void wxDisplaySizeMM( int *width, int *height ) |
96 | { | |
97 | if (width) *width = gdk_screen_width_mm(); | |
98 | if (height) *height = gdk_screen_height_mm(); | |
99 | } | |
100 | ||
6de97a3b RR |
101 | void wxGetMousePosition( int* x, int* y ) |
102 | { | |
d3b9f782 | 103 | gdk_window_get_pointer( NULL, x, y, NULL ); |
e52f60e6 | 104 | } |
6de97a3b | 105 | |
518b5d2f | 106 | bool wxColourDisplay() |
6de97a3b | 107 | { |
df91131c | 108 | return true; |
6de97a3b RR |
109 | } |
110 | ||
518b5d2f | 111 | int wxDisplayDepth() |
6de97a3b | 112 | { |
c2fa61e8 | 113 | return gdk_window_get_visual( wxGetRootWindow()->window )->depth; |
6de97a3b RR |
114 | } |
115 | ||
57591e0e JS |
116 | wxWindow* wxFindWindowAtPoint(const wxPoint& pt) |
117 | { | |
118 | return wxGenericFindWindowAtPoint(pt); | |
119 | } | |
120 | ||
121 | ||
518b5d2f | 122 | // ---------------------------------------------------------------------------- |
c801d85f | 123 | // subprocess routines |
518b5d2f | 124 | // ---------------------------------------------------------------------------- |
cf447356 | 125 | |
1d043598 VZ |
126 | #if wxUSE_TIMER |
127 | ||
c2ca375c VZ |
128 | wxTimerImpl* wxGUIAppTraits::CreateTimerImpl(wxTimer *timer) |
129 | { | |
130 | return new wxGTKTimerImpl(timer); | |
131 | } | |
132 | ||
1d043598 VZ |
133 | #endif // wxUSE_TIMER |
134 | ||
8bb6b2c0 VZ |
135 | // ---------------------------------------------------------------------------- |
136 | // wxPlatformInfo-related | |
137 | // ---------------------------------------------------------------------------- | |
138 | ||
139 | wxPortId wxGUIAppTraits::GetToolkitVersion(int *verMaj, int *verMin) const | |
140 | { | |
141 | if ( verMaj ) | |
142 | *verMaj = gtk_major_version; | |
143 | if ( verMin ) | |
144 | *verMin = gtk_minor_version; | |
145 | ||
146 | return wxPORT_GTK; | |
147 | } | |
61ecd225 | 148 | |
2ddff00c | 149 | wxEventLoopBase* wxGUIAppTraits::CreateEventLoop() |
61ecd225 | 150 | { |
b46b1d59 | 151 | return new wxEventLoop; |
61ecd225 | 152 | } |
a1f1afe4 | 153 |