]> git.saurik.com Git - wxWidgets.git/blame - src/gtk1/utilsgtk.cpp
Small makefile corrections.
[wxWidgets.git] / src / gtk1 / utilsgtk.cpp
CommitLineData
c801d85f
KB
1/////////////////////////////////////////////////////////////////////////////
2// Name: utils.cpp
3// Purpose:
4// Author: Robert Roebling
dfcb1ae0 5// Id: $Id$
c801d85f 6// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
518b5d2f 7// Licence: wxWindows licence
c801d85f
KB
8/////////////////////////////////////////////////////////////////////////////
9
c801d85f
KB
10#include "wx/utils.h"
11#include "wx/string.h"
12
02847e59
VZ
13#include "wx/intl.h"
14#include "wx/log.h"
15
5336ece4
VZ
16#include "wx/process.h"
17
518b5d2f
VZ
18#include "wx/unix/execute.h"
19
c801d85f
KB
20#include <stdarg.h>
21#include <dirent.h>
22#include <string.h>
23#include <sys/stat.h>
24#include <sys/types.h>
25#include <unistd.h>
26#include <sys/wait.h>
27#include <pwd.h>
28#include <errno.h>
29#include <netdb.h>
82052aff 30#include <signal.h>
4e13eb84 31#include <fcntl.h> // for O_WRONLY and friends
c801d85f 32
afb74891
VZ
33#include <glib.h>
34#include <gdk/gdk.h>
35#include <gtk/gtk.h>
36#include <gtk/gtkfeatures.h>
37#include <gdk/gdkx.h>
88ac883a
VZ
38
39#ifdef __HPUX__
40 // under HP-UX XKBlib.h defines structures with field named "explicit" -
41 // which is, of course, an error for a C++ compiler
42 #define explicit __wx_explicit
09fbacf7 43#endif
88ac883a 44 #include "X11/XKBlib.h"
09fbacf7 45#ifdef __HPUX__
88ac883a
VZ
46 #undef explicit
47#endif // __HPUX__
dfcb1ae0 48
518b5d2f 49// ----------------------------------------------------------------------------
c801d85f 50// misc.
518b5d2f 51// ----------------------------------------------------------------------------
c801d85f 52
518b5d2f 53void wxBell()
c801d85f 54{
e52f60e6
RR
55 gdk_beep();
56}
c801d85f 57
f0492f7d
RR
58// Synthesize KeyUp events holding down a key and producing
59// KeyDown events with autorepeat.
60bool wxSetDetectableAutoRepeat( bool flag )
61{
62 Bool result;
63 XkbSetDetectableAutoRepeat( GDK_DISPLAY(), flag, &result );
64 return result; // true if keyboard hardware supports this mode
65}
66
518b5d2f
VZ
67// ----------------------------------------------------------------------------
68// display characterstics
69// ----------------------------------------------------------------------------
82052aff 70
c0392997
RR
71void wxDisplaySize( int *width, int *height )
72{
e52f60e6
RR
73 if (width) *width = gdk_screen_width();
74 if (height) *height = gdk_screen_height();
c0392997
RR
75}
76
6de97a3b
RR
77void wxGetMousePosition( int* x, int* y )
78{
bbe0af5b 79 gdk_window_get_pointer( (GdkWindow*) NULL, x, y, (GdkModifierType*) NULL );
e52f60e6 80}
6de97a3b 81
518b5d2f 82bool wxColourDisplay()
6de97a3b 83{
e52f60e6 84 return TRUE;
6de97a3b
RR
85}
86
518b5d2f 87int wxDisplayDepth()
6de97a3b 88{
2d17d68f 89 return gdk_window_get_visual( (GdkWindow*) &gdk_root_parent )->depth;
6de97a3b
RR
90}
91
bbe0af5b
RR
92int wxGetOsVersion(int *majorVsn, int *minorVsn)
93{
94 if (majorVsn) *majorVsn = GTK_MAJOR_VERSION;
95 if (minorVsn) *minorVsn = GTK_MINOR_VERSION;
7e84f02d 96
bbe0af5b
RR
97 return wxGTK;
98}
99
518b5d2f 100// ----------------------------------------------------------------------------
c801d85f 101// subprocess routines
518b5d2f 102// ----------------------------------------------------------------------------
cf447356
GL
103
104static void GTK_EndProcessDetector(gpointer data, gint source,
e3e65dac 105 GdkInputCondition WXUNUSED(condition) )
cf447356 106{
bbe0af5b 107 wxEndProcessData *proc_data = (wxEndProcessData *)data;
cf447356 108
518b5d2f 109 wxHandleProcessTermination(proc_data);
cf447356 110
bbe0af5b
RR
111 close(source);
112 gdk_input_remove(proc_data->tag);
3069ac4e 113}
cf447356 114
518b5d2f 115int wxAddProcessCallback(wxEndProcessData *proc_data, int fd)
c801d85f 116{
518b5d2f
VZ
117 int tag = gdk_input_add(fd,
118 GDK_INPUT_READ,
119 GTK_EndProcessDetector,
120 (gpointer)proc_data);
c801d85f 121
518b5d2f 122 return tag;
3069ac4e 123}
c801d85f 124