]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: utils.cpp | |
3 | // Purpose: | |
4 | // Author: Robert Roebling | |
5 | // Id: $Id$ | |
6 | // Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem | |
7 | // Licence: wxWindows licence | |
8 | ///////////////////////////////////////////////////////////////////////////// | |
9 | ||
10 | #include "wx/utils.h" | |
11 | #include "wx/string.h" | |
12 | ||
13 | #include "wx/intl.h" | |
14 | #include "wx/log.h" | |
15 | ||
16 | #include "wx/process.h" | |
17 | ||
18 | #include "wx/unix/execute.h" | |
19 | ||
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> | |
30 | #include <signal.h> | |
31 | #include <fcntl.h> // for O_WRONLY and friends | |
32 | ||
33 | #include <glib.h> | |
34 | #include <gdk/gdk.h> | |
35 | #include <gtk/gtk.h> | |
36 | #include <gtk/gtkfeatures.h> | |
37 | #include <gdk/gdkx.h> | |
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 | |
43 | #endif | |
44 | #include "X11/XKBlib.h" | |
45 | #ifdef __HPUX__ | |
46 | #undef explicit | |
47 | #endif // __HPUX__ | |
48 | ||
49 | // ---------------------------------------------------------------------------- | |
50 | // misc. | |
51 | // ---------------------------------------------------------------------------- | |
52 | ||
53 | void wxBell() | |
54 | { | |
55 | gdk_beep(); | |
56 | } | |
57 | ||
58 | // Synthesize KeyUp events holding down a key and producing | |
59 | // KeyDown events with autorepeat. | |
60 | bool 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 | ||
67 | // ---------------------------------------------------------------------------- | |
68 | // display characterstics | |
69 | // ---------------------------------------------------------------------------- | |
70 | ||
71 | void wxDisplaySize( int *width, int *height ) | |
72 | { | |
73 | if (width) *width = gdk_screen_width(); | |
74 | if (height) *height = gdk_screen_height(); | |
75 | } | |
76 | ||
77 | void wxGetMousePosition( int* x, int* y ) | |
78 | { | |
79 | gdk_window_get_pointer( (GdkWindow*) NULL, x, y, (GdkModifierType*) NULL ); | |
80 | } | |
81 | ||
82 | bool wxColourDisplay() | |
83 | { | |
84 | return TRUE; | |
85 | } | |
86 | ||
87 | int wxDisplayDepth() | |
88 | { | |
89 | return gdk_window_get_visual( (GdkWindow*) &gdk_root_parent )->depth; | |
90 | } | |
91 | ||
92 | int wxGetOsVersion(int *majorVsn, int *minorVsn) | |
93 | { | |
94 | if (majorVsn) *majorVsn = GTK_MAJOR_VERSION; | |
95 | if (minorVsn) *minorVsn = GTK_MINOR_VERSION; | |
96 | ||
97 | return wxGTK; | |
98 | } | |
99 | ||
100 | // ---------------------------------------------------------------------------- | |
101 | // subprocess routines | |
102 | // ---------------------------------------------------------------------------- | |
103 | ||
104 | static void GTK_EndProcessDetector(gpointer data, gint source, | |
105 | GdkInputCondition WXUNUSED(condition) ) | |
106 | { | |
107 | wxEndProcessData *proc_data = (wxEndProcessData *)data; | |
108 | ||
109 | wxHandleProcessTermination(proc_data); | |
110 | ||
111 | close(source); | |
112 | gdk_input_remove(proc_data->tag); | |
113 | } | |
114 | ||
115 | int wxAddProcessCallback(wxEndProcessData *proc_data, int fd) | |
116 | { | |
117 | int tag = gdk_input_add(fd, | |
118 | GDK_INPUT_READ, | |
119 | GTK_EndProcessDetector, | |
120 | (gpointer)proc_data); | |
121 | ||
122 | return tag; | |
123 | } | |
124 |