]> git.saurik.com Git - wxWidgets.git/blob - src/gtk1/utilsgtk.cpp
Replace wxFONTFAMILY_DEFAULT with wxFONTFAMILY_SWISS when comparing fonts.
[wxWidgets.git] / src / gtk1 / utilsgtk.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/gtk1/utilsgtk.cpp
3 // Purpose:
4 // Author: Robert Roebling
5 // Copyright: (c) 1998 Robert Roebling
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
8
9 // For compilers that support precompilation, includes "wx.h".
10 #include "wx/wxprec.h"
11
12 #include "wx/utils.h"
13
14 #ifndef WX_PRECOMP
15 #include "wx/string.h"
16 #include "wx/intl.h"
17 #include "wx/log.h"
18 #endif
19
20 #include "wx/apptrait.h"
21 #include "wx/gtk1/private/timer.h"
22 #include "wx/evtloop.h"
23 #include "wx/process.h"
24
25 #include <stdarg.h>
26 #include <string.h>
27 #include <sys/stat.h>
28 #include <sys/types.h>
29 #include <sys/wait.h> // for WNOHANG
30 #include <unistd.h>
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"
37
38 #ifdef HAVE_X11_XKBLIB_H
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. */
42 #define explicit __wx_explicit
43
44 #include "X11/XKBlib.h"
45
46 #undef explicit
47 #endif // HAVE_X11_XKBLIB_H
48
49 //-----------------------------------------------------------------------------
50 // data
51 //-----------------------------------------------------------------------------
52
53 extern GtkWidget *wxGetRootWindow();
54
55 //----------------------------------------------------------------------------
56 // misc.
57 //----------------------------------------------------------------------------
58
59 void wxBell()
60 {
61 gdk_beep();
62 }
63
64 /* Don't synthesize KeyUp events holding down a key and producing
65 KeyDown events with autorepeat. */
66 #ifdef HAVE_X11_XKBLIB_H
67 bool wxSetDetectableAutoRepeat( bool flag )
68 {
69 Bool result;
70 XkbSetDetectableAutoRepeat( GDK_DISPLAY(), flag, &result );
71 return result; /* true if keyboard hardware supports this mode */
72 }
73 #else
74 bool wxSetDetectableAutoRepeat( bool WXUNUSED(flag) )
75 {
76 return false;
77 }
78 #endif
79
80 // ----------------------------------------------------------------------------
81 // display characterstics
82 // ----------------------------------------------------------------------------
83
84 void *wxGetDisplay()
85 {
86 return GDK_DISPLAY();
87 }
88
89 void wxDisplaySize( int *width, int *height )
90 {
91 if (width) *width = gdk_screen_width();
92 if (height) *height = gdk_screen_height();
93 }
94
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
101 void wxGetMousePosition( int* x, int* y )
102 {
103 gdk_window_get_pointer( NULL, x, y, NULL );
104 }
105
106 bool wxColourDisplay()
107 {
108 return true;
109 }
110
111 int wxDisplayDepth()
112 {
113 return gdk_window_get_visual( wxGetRootWindow()->window )->depth;
114 }
115
116 wxWindow* wxFindWindowAtPoint(const wxPoint& pt)
117 {
118 return wxGenericFindWindowAtPoint(pt);
119 }
120
121
122 // ----------------------------------------------------------------------------
123 // subprocess routines
124 // ----------------------------------------------------------------------------
125
126 #if wxUSE_TIMER
127
128 wxTimerImpl* wxGUIAppTraits::CreateTimerImpl(wxTimer *timer)
129 {
130 return new wxGTKTimerImpl(timer);
131 }
132
133 #endif // wxUSE_TIMER
134
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 }
148
149 wxEventLoopBase* wxGUIAppTraits::CreateEventLoop()
150 {
151 return new wxEventLoop;
152 }
153