]>
Commit | Line | Data |
---|---|---|
32b8ec41 VZ |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: utils.cpp | |
3 | // Purpose: | |
4 | // Author: Vaclav Slavik | |
5 | // Id: $Id$ | |
c41c20a5 | 6 | // Copyright: (c) 2001-2002 SciTech Software, Inc. (www.scitechsoft.com) |
65571936 | 7 | // Licence: wxWindows licence |
32b8ec41 VZ |
8 | ///////////////////////////////////////////////////////////////////////////// |
9 | ||
a246f95e VS |
10 | // For compilers that support precompilation, includes "wx.h". |
11 | #include "wx/wxprec.h" | |
12 | ||
13 | #ifdef __BORLANDC__ | |
14 | #pragma hdrstop | |
15 | #endif | |
16 | ||
32b8ec41 VZ |
17 | #include "wx/utils.h" |
18 | #include "wx/string.h" | |
19 | ||
20 | #include "wx/intl.h" | |
cd478a95 | 21 | #include "wx/apptrait.h" |
32b8ec41 | 22 | #include "wx/log.h" |
32b8ec41 VZ |
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 <unistd.h> | |
30 | #include <mgraph.hpp> | |
31 | ||
32 | #ifdef __UNIX__ | |
33 | #include "wx/unix/execute.h" | |
34 | #endif | |
35 | ||
a4bbc9f7 VS |
36 | #include "wx/mgl/private.h" |
37 | ||
32b8ec41 VZ |
38 | //---------------------------------------------------------------------------- |
39 | // misc. | |
40 | //---------------------------------------------------------------------------- | |
41 | ||
42 | void wxBell() | |
43 | { | |
44 | // FIXME_MGL | |
45 | } | |
46 | ||
47 | // ---------------------------------------------------------------------------- | |
48 | // display characterstics | |
49 | // ---------------------------------------------------------------------------- | |
50 | ||
a4bbc9f7 | 51 | void wxDisplaySize(int *width, int *height) |
32b8ec41 | 52 | { |
9210a48a | 53 | wxASSERT_MSG( g_displayDC, wxT("You must call wxApp::SetDisplayMode before using this function") ); |
b8c0528d VS |
54 | if (width) *width = g_displayDC->sizex()+1; |
55 | if (height) *height = g_displayDC->sizey()+1; | |
32b8ec41 VZ |
56 | } |
57 | ||
7bdc1879 | 58 | void wxDisplaySizeMM(int *width, int *height) |
32b8ec41 | 59 | { |
1f43b5c9 | 60 | wxASSERT_MSG( g_displayDC, wxT("You must call wxApp::SetDisplayMode before using this function") ); |
39578f9c VS |
61 | |
62 | int xDPI, yDPI; | |
99f0cdf2 WS |
63 | MGL_getDotsPerInch(&xDPI, &yDPI); |
64 | ||
65 | if ( width ) | |
39578f9c | 66 | *width = (int)((g_displayDC->sizex()+1) * 25.4 / xDPI); |
99f0cdf2 | 67 | if ( height ) |
39578f9c | 68 | *height = (int)((g_displayDC->sizey()+1) * 25.4 / yDPI); |
a4bbc9f7 VS |
69 | } |
70 | ||
7bdc1879 | 71 | void wxClientDisplayRect(int *x, int *y, int *width, int *height) |
a4bbc9f7 | 72 | { |
58061670 VS |
73 | if ( x ) *x = 0; |
74 | if ( y ) *y = 0; | |
7bdc1879 | 75 | wxDisplaySize(width, height); |
58061670 | 76 | // FIXME_MGL - windowed version needs different handling |
32b8ec41 VZ |
77 | } |
78 | ||
79 | bool wxColourDisplay() | |
80 | { | |
1f43b5c9 | 81 | wxASSERT_MSG( g_displayDC, wxT("You must call wxApp::SetDisplayMode before using this function") ); |
99f0cdf2 | 82 | |
32b8ec41 VZ |
83 | return (wxDisplayDepth() > 1); |
84 | } | |
85 | ||
86 | int wxDisplayDepth() | |
87 | { | |
1f43b5c9 | 88 | wxASSERT_MSG( g_displayDC, wxT("You must call wxApp::SetDisplayMode before using this function") ); |
32b8ec41 VZ |
89 | |
90 | return g_displayDC->getBitsPerPixel(); | |
91 | } | |
92 | ||
99f0cdf2 WS |
93 | wxString wxGetOsDescription() |
94 | { | |
95 | wxString osname( | |
96 | ||
97 | #if defined(__UNIX__) | |
98 | _T("Unix") | |
99 | #elif defined(__OS2__) | |
100 | _T("OS/2") | |
101 | #elif defined(__WIN32__) | |
102 | _T("Windows") | |
103 | #elif defined(__DOS__) | |
104 | _T("DOS") | |
105 | #else | |
106 | _T("unknown") | |
107 | #endif | |
108 | ||
109 | ); | |
110 | ||
111 | return osname; | |
112 | } | |
113 | ||
1c53456f VS |
114 | #if wxUSE_GUI |
115 | ||
752464f9 | 116 | wxToolkitInfo& wxGUIAppTraits::GetToolkitInfo() |
32b8ec41 | 117 | { |
752464f9 VS |
118 | static wxToolkitInfo info; |
119 | info.shortName = _T("mgluniv"); | |
120 | info.name = _T("wxMGL"); | |
121 | info.versionMajor = MGL_RELEASE_MAJOR; | |
122 | info.versionMinor = MGL_RELEASE_MINOR; | |
123 | info.os = wxGTK; | |
2343d81b | 124 | #if defined(__UNIX__) |
752464f9 | 125 | info.os = wxMGL_UNIX; |
2343d81b | 126 | #elif defined(__OS2__) |
752464f9 | 127 | info.os = wxMGL_OS2; |
2343d81b | 128 | #elif defined(__WIN32__) |
752464f9 | 129 | info.os = wxMGL_WIN32; |
a246f95e | 130 | #elif defined(__DOS__) |
752464f9 | 131 | info.os = wxMGL_DOS; |
a246f95e VS |
132 | #else |
133 | #error Platform not supported by wxMGL! | |
32b8ec41 | 134 | #endif |
752464f9 | 135 | return info; |
32b8ec41 VZ |
136 | } |
137 | ||
1c53456f VS |
138 | #endif |
139 | ||
83d8eb47 | 140 | #if 0 |
1c53456f VS |
141 | wxToolkitInfo& wxConsoleAppTraits::GetToolkitInfo() |
142 | { | |
143 | static wxToolkitInfo info; | |
144 | info.shortName = _T("mglbase"); | |
145 | info.versionMajor = MGL_RELEASE_MAJOR; | |
146 | info.versionMinor = MGL_RELEASE_MINOR; | |
147 | info.name = _T("wxBase"); | |
148 | info.os = wxGTK; | |
149 | #if defined(__UNIX__) | |
150 | info.os = wxMGL_UNIX; | |
151 | #elif defined(__OS2__) | |
152 | info.os = wxMGL_OS2; | |
153 | #elif defined(__WIN32__) | |
154 | info.os = wxMGL_WIN32; | |
155 | #elif defined(__DOS__) | |
156 | info.os = wxMGL_DOS; | |
157 | #else | |
158 | #error Platform not supported by wxMGL! | |
159 | #endif | |
160 | return info; | |
161 | } | |
83d8eb47 | 162 | #endif |
32b8ec41 | 163 | |
7bdc1879 VS |
164 | void wxGetMousePosition(int* x, int* y) |
165 | { | |
166 | MS_getPos(x, y); | |
167 | } | |
168 | ||
169 | wxPoint wxGetMousePosition() | |
170 | { | |
171 | wxPoint pt; | |
172 | wxGetMousePosition(&pt.x, &pt.y); | |
173 | return pt; | |
174 | } | |
175 | ||
176 | ||
177 | ||
32b8ec41 VZ |
178 | #ifdef __UNIX__ |
179 | ||
180 | int wxAddProcessCallback(wxEndProcessData *proc_data, int fd) | |
181 | { | |
2343d81b VS |
182 | wxFAIL_MSG(wxT("wxAddProcessCallback not implemented in wxMGL!")); |
183 | return 0; | |
32b8ec41 VZ |
184 | #if 0 // FIXME_MGL -do we need it at all? |
185 | int tag = gdk_input_add(fd, | |
186 | GDK_INPUT_READ, | |
187 | GTK_EndProcessDetector, | |
188 | (gpointer)proc_data); | |
189 | ||
190 | return tag; | |
191 | #endif | |
192 | } | |
193 | ||
194 | #endif |