]> git.saurik.com Git - wxWidgets.git/blame - include/wx/platinfo.h
Remove wxHeaderColumn::SetAsSortKey() and only use SetSortOrder().
[wxWidgets.git] / include / wx / platinfo.h
CommitLineData
8bb6b2c0
VZ
1///////////////////////////////////////////////////////////////////////////////
2// Name: wx/platinfo.h
3// Purpose: declaration of the wxPlatformInfo class
4// Author: Francesco Montorsi
5// Modified by:
6// Created: 07.07.2006 (based on wxToolkitInfo)
7// RCS-ID: $Id$
8// Copyright: (c) 2006 Francesco Montorsi
526954c5 9// Licence: wxWindows licence
8bb6b2c0
VZ
10///////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_PLATINFO_H_
13#define _WX_PLATINFO_H_
14
b20ca997 15#include "wx/string.h"
8bb6b2c0
VZ
16
17// ----------------------------------------------------------------------------
23790a2a 18// wxPlatformInfo enums & structs
8bb6b2c0
VZ
19// ----------------------------------------------------------------------------
20
21// VERY IMPORTANT: when changing these enum values, also change the relative
22// string tables in src/common/platinfo.cpp
23
24
25// families & sub-families of operating systems
26enum wxOperatingSystemId
27{
28 wxOS_UNKNOWN = 0, // returned on error
29
30 wxOS_MAC_OS = 1 << 0, // Apple Mac OS 8/9/X with Mac paths
31 wxOS_MAC_OSX_DARWIN = 1 << 1, // Apple Mac OS X with Unix paths
32 wxOS_MAC = wxOS_MAC_OS|wxOS_MAC_OSX_DARWIN,
33
34 wxOS_WINDOWS_9X = 1 << 2, // Windows 9x family (95/98/ME)
35 wxOS_WINDOWS_NT = 1 << 3, // Windows NT family (NT/2000/XP)
36 wxOS_WINDOWS_MICRO = 1 << 4, // MicroWindows
37 wxOS_WINDOWS_CE = 1 << 5, // Windows CE (Window Mobile)
38 wxOS_WINDOWS = wxOS_WINDOWS_9X |
39 wxOS_WINDOWS_NT |
40 wxOS_WINDOWS_MICRO |
41 wxOS_WINDOWS_CE,
42
43 wxOS_UNIX_LINUX = 1 << 6, // Linux
44 wxOS_UNIX_FREEBSD = 1 << 7, // FreeBSD
45 wxOS_UNIX_OPENBSD = 1 << 8, // OpenBSD
46 wxOS_UNIX_NETBSD = 1 << 9, // NetBSD
47 wxOS_UNIX_SOLARIS = 1 << 10, // SunOS
48 wxOS_UNIX_AIX = 1 << 11, // AIX
49 wxOS_UNIX_HPUX = 1 << 12, // HP/UX
50 wxOS_UNIX = wxOS_UNIX_LINUX |
51 wxOS_UNIX_FREEBSD |
52 wxOS_UNIX_OPENBSD |
53 wxOS_UNIX_NETBSD |
54 wxOS_UNIX_SOLARIS |
55 wxOS_UNIX_AIX |
56 wxOS_UNIX_HPUX,
57
58 // 1<<13 and 1<<14 available for other Unix flavours
59
60 wxOS_DOS = 1 << 15, // Microsoft DOS
027fe16c
VZ
61 wxOS_OS2 = 1 << 16, // OS/2
62
63 wxOS_PALM_OS = 1 << 17, // Pure Palm OS
64 wxOS_PALM_LINUX = 1 << 18, // Palm over linux
3be25921 65 wxOS_PALM = wxOS_PALM_OS | wxOS_PALM_LINUX
8bb6b2c0
VZ
66};
67
68// list of wxWidgets ports - some of them can be used with more than
69// a single toolkit.
70enum wxPortId
71{
72 wxPORT_UNKNOWN = 0, // returned on error
73
74 wxPORT_BASE = 1 << 0, // wxBase, no native toolkit used
75
76 wxPORT_MSW = 1 << 1, // wxMSW, native toolkit is Windows API
77 wxPORT_MOTIF = 1 << 2, // wxMotif, using [Open]Motif or Lesstif
78 wxPORT_GTK = 1 << 3, // wxGTK, using GTK+ 1.x, 2.x, GPE or Maemo
79 wxPORT_MGL = 1 << 4, // wxMGL, using wxUniversal
80 wxPORT_X11 = 1 << 5, // wxX11, using wxUniversal
8ab09e65
SN
81 wxPORT_PM = 1 << 6, // wxOS2, using OS/2 Presentation Manager
82 wxPORT_OS2 = wxPORT_PM, // wxOS2, using OS/2 Presentation Manager
ac9e3f1f
SC
83 wxPORT_MAC = 1 << 7, // wxOSX (former wxMac), using Cocoa, Carbon or iPhone API
84 wxPORT_OSX = wxPORT_MAC, // wxOSX, using Cocoa, Carbon or iPhone API
8bb6b2c0
VZ
85 wxPORT_COCOA = 1 << 8, // wxCocoa, using Cocoa NextStep/Mac API
86 wxPORT_WINCE = 1 << 9, // wxWinCE, toolkit is WinCE SDK API
b3c86150
VS
87 wxPORT_PALMOS = 1 << 10, // wxPalmOS, toolkit is PalmOS API
88 wxPORT_DFB = 1 << 11 // wxDFB, using wxUniversal
8bb6b2c0
VZ
89};
90
91// architecture of the operating system
92// (regardless of the build environment of wxWidgets library - see
93// wxIsPlatform64bit documentation for more info)
94enum wxArchitecture
95{
96 wxARCH_INVALID = -1, // returned on error
97
98 wxARCH_32, // 32 bit
99 wxARCH_64,
100
101 wxARCH_MAX
102};
103
104
105// endian-ness of the machine
106enum wxEndianness
107{
108 wxENDIAN_INVALID = -1, // returned on error
109
110 wxENDIAN_BIG, // 4321
111 wxENDIAN_LITTLE, // 1234
112 wxENDIAN_PDP, // 3412
113
114 wxENDIAN_MAX
115};
116
23790a2a
FM
117// informations about a linux distro returned by the lsb_release utility
118struct wxLinuxDistributionInfo
119{
120 wxString Id;
121 wxString Release;
122 wxString CodeName;
123 wxString Description;
03647350 124
23790a2a 125 bool operator==(const wxLinuxDistributionInfo& ldi) const
03647350 126 {
23790a2a
FM
127 return Id == ldi.Id &&
128 Release == ldi.Release &&
129 CodeName == ldi.CodeName &&
130 Description == ldi.Description;
131 }
03647350 132
23790a2a
FM
133 bool operator!=(const wxLinuxDistributionInfo& ldi) const
134 { return !(*this == ldi); }
135};
136
137
138// ----------------------------------------------------------------------------
139// wxPlatformInfo
140// ----------------------------------------------------------------------------
141
8bb6b2c0
VZ
142// Information about the toolkit that the app is running under and some basic
143// platform and architecture info
144class WXDLLIMPEXP_BASE wxPlatformInfo
145{
146public:
147 wxPlatformInfo();
148 wxPlatformInfo(wxPortId pid,
149 int tkMajor = -1, int tkMinor = -1,
150 wxOperatingSystemId id = wxOS_UNKNOWN,
151 int osMajor = -1, int osMinor = -1,
152 wxArchitecture arch = wxARCH_INVALID,
b98bd6af
VS
153 wxEndianness endian = wxENDIAN_INVALID,
154 bool usingUniversal = false);
8bb6b2c0
VZ
155
156 // default copy ctor, assignment operator and dtor are ok
157
158 bool operator==(const wxPlatformInfo &t) const;
159
160 bool operator!=(const wxPlatformInfo &t) const
161 { return !(*this == t); }
162
449090b5
VZ
163 // Gets a wxPlatformInfo already initialized with the values for
164 // the currently running platform.
165 static const wxPlatformInfo& Get();
166
167
8bb6b2c0
VZ
168
169 // string -> enum conversions
170 // ---------------------------------
171
172 static wxOperatingSystemId GetOperatingSystemId(const wxString &name);
173 static wxPortId GetPortId(const wxString &portname);
174
175 static wxArchitecture GetArch(const wxString &arch);
176 static wxEndianness GetEndianness(const wxString &end);
177
178 // enum -> string conversions
179 // ---------------------------------
180
181 static wxString GetOperatingSystemFamilyName(wxOperatingSystemId os);
182 static wxString GetOperatingSystemIdName(wxOperatingSystemId os);
b98bd6af
VS
183 static wxString GetPortIdName(wxPortId port, bool usingUniversal);
184 static wxString GetPortIdShortName(wxPortId port, bool usingUniversal);
8bb6b2c0
VZ
185
186 static wxString GetArchName(wxArchitecture arch);
187 static wxString GetEndiannessName(wxEndianness end);
188
03647350 189
8bb6b2c0
VZ
190 // getters
191 // -----------------
192
193 int GetOSMajorVersion() const
194 { return m_osVersionMajor; }
195 int GetOSMinorVersion() const
196 { return m_osVersionMinor; }
197
a24db82d
VZ
198 // return true if the OS version >= major.minor
199 bool CheckOSVersion(int major, int minor) const
200 {
201 return DoCheckVersion(GetOSMajorVersion(),
202 GetOSMinorVersion(),
203 major,
204 minor);
205 }
206
8bb6b2c0
VZ
207 int GetToolkitMajorVersion() const
208 { return m_tkVersionMajor; }
209 int GetToolkitMinorVersion() const
210 { return m_tkVersionMinor; }
211
a24db82d
VZ
212 bool CheckToolkitVersion(int major, int minor) const
213 {
214 return DoCheckVersion(GetToolkitMajorVersion(),
215 GetToolkitMinorVersion(),
216 major,
217 minor);
218 }
219
b98bd6af
VS
220 bool IsUsingUniversalWidgets() const
221 { return m_usingUniversal; }
222
8bb6b2c0
VZ
223 wxOperatingSystemId GetOperatingSystemId() const
224 { return m_os; }
23790a2a
FM
225 wxLinuxDistributionInfo GetLinuxDistributionInfo() const
226 { return m_ldi; }
8bb6b2c0
VZ
227 wxPortId GetPortId() const
228 { return m_port; }
229 wxArchitecture GetArchitecture() const
230 { return m_arch; }
231 wxEndianness GetEndianness() const
232 { return m_endian; }
233
234
235 // string getters
236 // -----------------
237
238 wxString GetOperatingSystemFamilyName() const
239 { return GetOperatingSystemFamilyName(m_os); }
240 wxString GetOperatingSystemIdName() const
241 { return GetOperatingSystemIdName(m_os); }
242 wxString GetPortIdName() const
b98bd6af 243 { return GetPortIdName(m_port, m_usingUniversal); }
8bb6b2c0 244 wxString GetPortIdShortName() const
b98bd6af 245 { return GetPortIdShortName(m_port, m_usingUniversal); }
8bb6b2c0
VZ
246 wxString GetArchName() const
247 { return GetArchName(m_arch); }
248 wxString GetEndiannessName() const
249 { return GetEndiannessName(m_endian); }
23790a2a
FM
250 wxString GetOperatingSystemDescription() const
251 { return m_osDesc; }
252 wxString GetDesktopEnvironment() const
253 { return m_desktopEnv; }
03647350 254
23790a2a
FM
255 static wxString GetOperatingSystemDirectory();
256 // doesn't make sense to store inside wxPlatformInfo the OS directory,
257 // thus this function is static; note that this function simply calls
03647350 258 // wxGetOSDirectory() and is here just to make it easier for the user to
23790a2a 259 // find it that feature (global functions can be difficult to find in the docs)
8bb6b2c0
VZ
260
261 // setters
262 // -----------------
263
264 void SetOSVersion(int major, int minor)
265 { m_osVersionMajor=major; m_osVersionMinor=minor; }
266 void SetToolkitVersion(int major, int minor)
267 { m_tkVersionMajor=major; m_tkVersionMinor=minor; }
268
269 void SetOperatingSystemId(wxOperatingSystemId n)
a24db82d 270 { m_os = n; }
23790a2a
FM
271 void SetOperatingSystemDescription(const wxString& desc)
272 { m_osDesc = desc; }
8bb6b2c0 273 void SetPortId(wxPortId n)
a24db82d 274 { m_port = n; }
8bb6b2c0 275 void SetArchitecture(wxArchitecture n)
a24db82d 276 { m_arch = n; }
8bb6b2c0 277 void SetEndianness(wxEndianness n)
a24db82d 278 { m_endian = n; }
03647350 279
23790a2a
FM
280 void SetDesktopEnvironment(const wxString& de)
281 { m_desktopEnv = de; }
282 void SetLinuxDistributionInfo(const wxLinuxDistributionInfo& di)
283 { m_ldi = di; }
284
8bb6b2c0
VZ
285
286 // miscellaneous
287 // -----------------
288
289 bool IsOk() const
290 {
291 return m_osVersionMajor != -1 && m_osVersionMinor != -1 &&
292 m_os != wxOS_UNKNOWN &&
23790a2a 293 !m_osDesc.IsEmpty() &&
8bb6b2c0
VZ
294 m_tkVersionMajor != -1 && m_tkVersionMinor != -1 &&
295 m_port != wxPORT_UNKNOWN &&
03647350 296 m_arch != wxARCH_INVALID &&
23790a2a 297 m_endian != wxENDIAN_INVALID;
03647350 298
23790a2a 299 // do not check linux-specific info; it's ok to have them empty
8bb6b2c0
VZ
300 }
301
8bb6b2c0
VZ
302
303protected:
a24db82d
VZ
304 static bool DoCheckVersion(int majorCur, int minorCur, int major, int minor)
305 {
306 return majorCur > major || (majorCur == major && minorCur >= minor);
307 }
308
449090b5
VZ
309 void InitForCurrentPlatform();
310
311
8bb6b2c0
VZ
312 // OS stuff
313 // -----------------
314
315 // Version of the OS; valid if m_os != wxOS_UNKNOWN
316 // (-1 means not initialized yet).
a24db82d
VZ
317 int m_osVersionMajor,
318 m_osVersionMinor;
8bb6b2c0
VZ
319
320 // Operating system ID.
321 wxOperatingSystemId m_os;
03647350 322
23790a2a
FM
323 // Operating system description.
324 wxString m_osDesc;
03647350
VZ
325
326
23790a2a
FM
327 // linux-specific
328 // -----------------
03647350 329
23790a2a
FM
330 wxString m_desktopEnv;
331 wxLinuxDistributionInfo m_ldi;
8bb6b2c0
VZ
332
333
334 // toolkit
335 // -----------------
336
337 // Version of the underlying toolkit
338 // (-1 means not initialized yet; zero means no toolkit).
339 int m_tkVersionMajor, m_tkVersionMinor;
340
341 // name of the wxWidgets port
342 wxPortId m_port;
343
b98bd6af
VS
344 // is using wxUniversal widgets?
345 bool m_usingUniversal;
346
8bb6b2c0
VZ
347
348 // others
349 // -----------------
350
23790a2a 351 // architecture of the OS/machine
8bb6b2c0
VZ
352 wxArchitecture m_arch;
353
354 // endianness of the machine
355 wxEndianness m_endian;
356};
357
358
359#if WXWIN_COMPATIBILITY_2_6
360 #define wxUNKNOWN_PLATFORM wxOS_UNKNOWN
361 #define wxUnix wxOS_UNIX
362 #define wxWin95 wxOS_WINDOWS_9X
363 #define wxWIN95 wxOS_WINDOWS_9X
364 #define wxWINDOWS_NT wxOS_WINDOWS_NT
365 #define wxMSW wxOS_WINDOWS
366 #define wxWinCE wxOS_WINDOWS_CE
367 #define wxWIN32S wxOS_WINDOWS_9X
368
369 #define wxPalmOS wxPORT_PALMOS
370 #define wxOS2 wxPORT_OS2
371 #define wxMGL wxPORT_MGL
372 #define wxCocoa wxPORT_MAC
373 #define wxMac wxPORT_MAC
374 #define wxMotif wxPORT_MOTIF
375 #define wxGTK wxPORT_GTK
376#endif // WXWIN_COMPATIBILITY_2_6
377
378#endif // _WX_PLATINFO_H_