]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/gtk1/utilsgtk.cpp
Fix broken and missing DataView interface items for Phoenix
[wxWidgets.git] / src / gtk1 / utilsgtk.cpp
... / ...
CommitLineData
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
56extern GtkWidget *wxGetRootWindow();
57
58//----------------------------------------------------------------------------
59// misc.
60//----------------------------------------------------------------------------
61
62void wxBell()
63{
64 gdk_beep();
65}
66
67/* Don't synthesize KeyUp events holding down a key and producing
68 KeyDown events with autorepeat. */
69#ifdef HAVE_X11_XKBLIB_H
70bool wxSetDetectableAutoRepeat( bool flag )
71{
72 Bool result;
73 XkbSetDetectableAutoRepeat( GDK_DISPLAY(), flag, &result );
74 return result; /* true if keyboard hardware supports this mode */
75}
76#else
77bool wxSetDetectableAutoRepeat( bool WXUNUSED(flag) )
78{
79 return false;
80}
81#endif
82
83// ----------------------------------------------------------------------------
84// display characterstics
85// ----------------------------------------------------------------------------
86
87void *wxGetDisplay()
88{
89 return GDK_DISPLAY();
90}
91
92void wxDisplaySize( int *width, int *height )
93{
94 if (width) *width = gdk_screen_width();
95 if (height) *height = gdk_screen_height();
96}
97
98void wxDisplaySizeMM( int *width, int *height )
99{
100 if (width) *width = gdk_screen_width_mm();
101 if (height) *height = gdk_screen_height_mm();
102}
103
104void wxGetMousePosition( int* x, int* y )
105{
106 gdk_window_get_pointer( NULL, x, y, NULL );
107}
108
109bool wxColourDisplay()
110{
111 return true;
112}
113
114int wxDisplayDepth()
115{
116 return gdk_window_get_visual( wxGetRootWindow()->window )->depth;
117}
118
119wxWindow* wxFindWindowAtPoint(const wxPoint& pt)
120{
121 return wxGenericFindWindowAtPoint(pt);
122}
123
124
125// ----------------------------------------------------------------------------
126// subprocess routines
127// ----------------------------------------------------------------------------
128
129extern "C" {
130static
131void GTK_EndProcessDetector(gpointer data, gint source,
132 GdkInputCondition WXUNUSED(condition) )
133{
134 wxEndProcessData * const
135 proc_data = static_cast<wxEndProcessData *>(data);
136
137 // child exited, end waiting
138 close(source);
139
140 // don't call us again!
141 gdk_input_remove(proc_data->tag);
142
143 wxHandleProcessTermination(proc_data);
144}
145}
146
147int wxGUIAppTraits::AddProcessCallback(wxEndProcessData *proc_data, int fd)
148{
149 int tag = gdk_input_add(fd,
150 GDK_INPUT_READ,
151 GTK_EndProcessDetector,
152 (gpointer)proc_data);
153
154 return tag;
155}
156
157#if wxUSE_TIMER
158
159wxTimerImpl* wxGUIAppTraits::CreateTimerImpl(wxTimer *timer)
160{
161 return new wxGTKTimerImpl(timer);
162}
163
164#endif // wxUSE_TIMER
165
166// ----------------------------------------------------------------------------
167// wxPlatformInfo-related
168// ----------------------------------------------------------------------------
169
170wxPortId 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}
179
180wxEventLoopBase* wxGUIAppTraits::CreateEventLoop()
181{
182 return new wxEventLoop;
183}
184