]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/platinfo.h
add alignment flags support to wxSpinCtrl[Double] (closes #10621)
[wxWidgets.git] / interface / wx / platinfo.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: platinfo.h
e54c96f1 3// Purpose: interface of wxPlatformInfo
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
6// Licence: wxWindows license
7/////////////////////////////////////////////////////////////////////////////
8
74bf4e64 9
4d7b68d1 10/**
74bf4e64
FM
11 The following are the operating systems which are recognized by wxWidgets and
12 whose version can be detected at run-time.
4d7b68d1 13
74bf4e64 14 The values of the constants are chosen so that they can be combined as flags;
4d7b68d1
FM
15 this allows to check for operating system families like e.g. wxOS_MAC and wxOS_UNIX.
16*/
17enum wxOperatingSystemId
18{
19 wxOS_UNKNOWN = 0, //!< returned on error
20
21 wxOS_MAC_OS = 1 << 0, //!< Apple Mac OS 8/9/X with Mac paths
22 wxOS_MAC_OSX_DARWIN = 1 << 1, //!< Apple Mac OS X with Unix paths
23 wxOS_MAC = wxOS_MAC_OS|wxOS_MAC_OSX_DARWIN,
24
25 wxOS_WINDOWS_9X = 1 << 2, //!< Windows 9x family (95/98/ME)
26 wxOS_WINDOWS_NT = 1 << 3, //!< Windows NT family (NT/2000/XP)
27 wxOS_WINDOWS_MICRO = 1 << 4, //!< MicroWindows
28 wxOS_WINDOWS_CE = 1 << 5, //!< Windows CE (Window Mobile)
29 wxOS_WINDOWS = wxOS_WINDOWS_9X |
30 wxOS_WINDOWS_NT |
31 wxOS_WINDOWS_MICRO |
32 wxOS_WINDOWS_CE,
33
34 wxOS_UNIX_LINUX = 1 << 6, //!< Linux
35 wxOS_UNIX_FREEBSD = 1 << 7, //!< FreeBSD
36 wxOS_UNIX_OPENBSD = 1 << 8, //!< OpenBSD
37 wxOS_UNIX_NETBSD = 1 << 9, //!< NetBSD
38 wxOS_UNIX_SOLARIS = 1 << 10, //!< SunOS
39 wxOS_UNIX_AIX = 1 << 11, //!< AIX
40 wxOS_UNIX_HPUX = 1 << 12, //!< HP/UX
41 wxOS_UNIX = wxOS_UNIX_LINUX |
42 wxOS_UNIX_FREEBSD |
43 wxOS_UNIX_OPENBSD |
44 wxOS_UNIX_NETBSD |
45 wxOS_UNIX_SOLARIS |
46 wxOS_UNIX_AIX |
47 wxOS_UNIX_HPUX,
48
49 wxOS_DOS = 1 << 15, //!< Microsoft DOS
50 wxOS_OS2 = 1 << 16 //!< OS/2
51};
74bf4e64 52
4d7b68d1 53/**
74bf4e64 54 The list of wxWidgets ports.
4d7b68d1 55
74bf4e64
FM
56 Some of them can be used with more than a single (native) toolkit;
57 e.g. wxWinCE port sources can be used with smartphones, pocket PCs
58 and handheld devices SDKs.
4d7b68d1
FM
59*/
60enum wxPortId
61{
62 wxPORT_UNKNOWN = 0, //!< returned on error
74bf4e64 63
4d7b68d1 64 wxPORT_BASE = 1 << 0, //!< wxBase, no native toolkit used
74bf4e64 65
4d7b68d1
FM
66 wxPORT_MSW = 1 << 1, //!< wxMSW, native toolkit is Windows API
67 wxPORT_MOTIF = 1 << 2, //!< wxMotif, using [Open]Motif or Lesstif
68 wxPORT_GTK = 1 << 3, //!< wxGTK, using GTK+ 1.x, 2.x, GPE or Maemo
69 wxPORT_MGL = 1 << 4, //!< wxMGL, using wxUniversal
70 wxPORT_X11 = 1 << 5, //!< wxX11, using wxUniversal
71 wxPORT_OS2 = 1 << 6, //!< wxOS2, using OS/2 Presentation Manager
72 wxPORT_MAC = 1 << 7, //!< wxMac, using Carbon or Classic Mac API
73 wxPORT_COCOA = 1 << 8, //!< wxCocoa, using Cocoa NextStep/Mac API
74 wxPORT_WINCE = 1 << 9, //!< wxWinCE, toolkit is WinCE SDK API
75 wxPORT_PALMOS = 1 << 10, //!< wxPalmOS, toolkit is PalmOS API
76 wxPORT_DFB = 1 << 11 //!< wxDFB, using wxUniversal
77};
74bf4e64 78
74bf4e64 79
4d7b68d1 80/**
74bf4e64 81 The architecture of the operating system
b1b95a65
FM
82 (regardless of the build environment of wxWidgets library - see ::wxIsPlatform64bit()
83 documentation for more info).
4d7b68d1
FM
84*/
85enum wxArchitecture
86{
87 wxARCH_INVALID = -1, //!< returned on error
74bf4e64 88
4d7b68d1
FM
89 wxARCH_32, //!< 32 bit
90 wxARCH_64,
74bf4e64 91
4d7b68d1 92 wxARCH_MAX
3a7fb603 93};
74bf4e64 94
74bf4e64 95
4d7b68d1 96/**
74bf4e64 97 The endian-ness of the machine.
4d7b68d1
FM
98*/
99enum wxEndianness
100{
101 wxENDIAN_INVALID = -1, //!< returned on error
74bf4e64 102
4d7b68d1
FM
103 wxENDIAN_BIG, //!< 4321
104 wxENDIAN_LITTLE, //!< 1234
105 wxENDIAN_PDP, //!< 3412
74bf4e64 106
4d7b68d1 107 wxENDIAN_MAX
3a7fb603 108};
74bf4e64 109
74bf4e64 110
4d7b68d1
FM
111/**
112 @class wxPlatformInfo
74bf4e64 113
4d7b68d1
FM
114 This class holds informations about the operating system and the toolkit that
115 the application is running under and some basic architecture info of the machine
116 where it's running.
74bf4e64 117
4d7b68d1 118 @library{wxbase}
3c99e2fd 119 @category{cfg}
74bf4e64 120
4d7b68d1
FM
121 @see ::wxGetOsVersion(), wxIsPlatformLittleEndian(), wxIsPlatform64Bit(),
122 wxAppTraits
23324ae1
FM
123*/
124class wxPlatformInfo : public wxObject
125{
126public:
74bf4e64 127
23324ae1 128 /**
74bf4e64
FM
129 Initializes the instance with the values corresponding to the currently
130 running platform.
131
132 This is a fast operation because it only requires to copy the values
133 internally cached for the currently running platform.
134
135 @see Get()
23324ae1
FM
136 */
137 wxPlatformInfo();
74bf4e64
FM
138
139 /**
140 Initializes the object using given values.
141 */
7c913512
FM
142 wxPlatformInfo(wxPortId pid = wxPORT_UNKNOWN,
143 int tkMajor = -1,
144 int tkMinor = -1,
145 wxOperatingSystemId id = wxOS_UNKNOWN,
146 int osMajor = -1,
147 int osMinor = -1,
148 wxArchitecture arch = wxARCH_INVALID,
149 wxEndianness endian = wxENDIAN_INVALID);
74bf4e64 150
23324ae1
FM
151
152 /**
153 Returns @true if the OS version is at least @c major.minor.
3c4f71cc 154
4cc4bfaf
FM
155 @see GetOSMajorVersion(), GetOSMinorVersion(),
156 CheckToolkitVersion()
23324ae1 157 */
328f5751 158 bool CheckOSVersion(int major, int minor) const;
23324ae1
FM
159
160 /**
161 Returns @true if the toolkit version is at least @c major.minor.
3c4f71cc 162
4cc4bfaf
FM
163 @see GetToolkitMajorVersion(),
164 GetToolkitMinorVersion(), CheckOSVersion()
23324ae1 165 */
328f5751 166 bool CheckToolkitVersion(int major, int minor) const;
23324ae1
FM
167
168 /**
74bf4e64
FM
169 Returns the global wxPlatformInfo object, initialized with the values
170 for the currently running platform.
23324ae1 171 */
382f12e4 172 static const wxPlatformInfo& Get();
23324ae1
FM
173
174 /**
175 Converts the given string to a wxArchitecture enum value or to
74bf4e64 176 @c wxARCH_INVALID if the given string is not a valid architecture string
23324ae1
FM
177 (i.e. does not contain nor @c 32 nor @c 64 strings).
178 */
179 static wxArchitecture GetArch(const wxString& arch);
180
23324ae1 181 /**
74bf4e64 182 Returns the name for the given wxArchitecture enumeration value.
23324ae1 183 */
57bf907d 184 static wxString GetArchName(wxArchitecture arch);
74bf4e64
FM
185
186 /**
187 Returns the name for the architecture of this wxPlatformInfo instance.
188 */
328f5751 189 wxString GetArchName() const;
23324ae1
FM
190
191 /**
192 Returns the architecture ID of this wxPlatformInfo instance.
193 */
328f5751 194 wxArchitecture GetArchitecture() const;
23324ae1 195
23324ae1 196 /**
74bf4e64
FM
197 Converts the given string to a wxEndianness enum value or to
198 @c wxENDIAN_INVALID if the given string is not a valid endianness
199 string (i.e. does not contain nor little nor big strings).
23324ae1 200 */
57bf907d 201 static wxEndianness GetEndianness(const wxString& end);
74bf4e64
FM
202
203 /**
204 Returns the endianness ID of this wxPlatformInfo instance.
205 */
328f5751 206 wxEndianness GetEndianness() const;
23324ae1 207
23324ae1 208 /**
74bf4e64 209 Returns name for the given wxEndianness enumeration value.
23324ae1 210 */
57bf907d 211 static wxString GetEndiannessName(wxEndianness end);
74bf4e64
FM
212
213 /**
214 Returns the name for the endianness of this wxPlatformInfo instance.
215 */
328f5751 216 wxString GetEndiannessName() const;
23324ae1
FM
217
218 /**
219 Returns the run-time major version of the OS associated with this
220 wxPlatformInfo instance.
3c4f71cc 221
74bf4e64 222 @see ::wxGetOsVersion(), CheckOSVersion()
23324ae1 223 */
328f5751 224 int GetOSMajorVersion() const;
23324ae1
FM
225
226 /**
227 Returns the run-time minor version of the OS associated with this
228 wxPlatformInfo instance.
3c4f71cc 229
74bf4e64 230 @see ::wxGetOsVersion(), CheckOSVersion()
23324ae1 231 */
328f5751 232 int GetOSMinorVersion() const;
23324ae1 233
74bf4e64
FM
234 /**
235 Returns the operating system family name for the given wxOperatingSystemId
236 enumeration value: @c Unix for @c wxOS_UNIX, @c Macintosh for @c wxOS_MAC,
237 @c Windows for @c wxOS_WINDOWS, @c DOS for @c wxOS_DOS, @c OS/2 for @c wxOS_OS2.
238 */
57bf907d 239 static wxString GetOperatingSystemFamilyName(wxOperatingSystemId os);
74bf4e64 240
23324ae1
FM
241 /**
242 Returns the operating system family name of the OS associated with this
243 wxPlatformInfo instance.
244 */
328f5751 245 wxString GetOperatingSystemFamilyName() const;
23324ae1 246
23324ae1 247 /**
74bf4e64
FM
248 Converts the given string to a wxOperatingSystemId enum value or to @c
249 wxOS_UNKNOWN if the given string is not a valid operating system name.
23324ae1 250 */
57bf907d 251 static wxOperatingSystemId GetOperatingSystemId(const wxString& name);
74bf4e64
FM
252
253 /**
254 Returns the operating system ID of this wxPlatformInfo instance.
255 */
328f5751 256 wxOperatingSystemId GetOperatingSystemId() const;
23324ae1 257
74bf4e64
FM
258 /**
259 Returns the name for the given operating system ID value.
260
261 This can be a long name (e.g. <tt>Microsoft Windows NT</tt>);
262 use GetOperatingSystemFamilyName() to retrieve a short, generic name.
263 */
57bf907d 264 static wxString GetOperatingSystemIdName(wxOperatingSystemId os);
74bf4e64 265
23324ae1
FM
266 /**
267 Returns the operating system name of the OS associated with this wxPlatformInfo
268 instance.
269 */
328f5751 270 wxString GetOperatingSystemIdName() const;
23324ae1 271
74bf4e64 272
23324ae1 273 /**
74bf4e64
FM
274 Converts the given string to a wxWidgets port ID value or to @c wxPORT_UNKNOWN
275 if the given string does not match any of the wxWidgets canonical name ports
276 ("wxGTK", "wxMSW", etc) nor any of the short wxWidgets name ports ("gtk", "msw", etc).
23324ae1 277 */
57bf907d 278 static wxPortId GetPortId(const wxString& portname);
74bf4e64
FM
279
280 /**
281 Returns the wxWidgets port ID associated with this wxPlatformInfo instance.
282 */
328f5751 283 wxPortId GetPortId() const;
23324ae1 284
74bf4e64
FM
285 /**
286 Returns the name of the given wxWidgets port ID value.
287 The @a usingUniversal argument specifies whether the port is in its native
288 or wxUniversal variant.
289
290 The returned string always starts with the "wx" prefix and is a mixed-case string.
291 */
57bf907d 292 static wxString GetPortIdName(wxPortId port, bool usingUniversal);
74bf4e64 293
23324ae1
FM
294 /**
295 Returns the name of the wxWidgets port ID associated with this wxPlatformInfo
296 instance.
297 */
328f5751 298 wxString GetPortIdName() const;
23324ae1 299
23324ae1 300 /**
74bf4e64
FM
301 Returns the short name of the given wxWidgets port ID value.
302 The @a usingUniversal argument specifies whether the port is in its native
303 or wxUniversal variant.
304
4d7b68d1 305 The returned string does not start with the "wx" prefix and is always lower case.
23324ae1
FM
306 */
307 static wxString GetPortIdShortName(wxPortId port,
57bf907d 308 bool usingUniversal);
74bf4e64
FM
309
310 /**
311 Returns the short name of the wxWidgets port ID associated with this
312 wxPlatformInfo instance.
313 */
328f5751 314 wxString GetPortIdShortName() const;
23324ae1
FM
315
316 /**
317 Returns the run-time major version of the toolkit associated with this
318 wxPlatformInfo instance.
74bf4e64
FM
319
320 Note that if GetPortId() returns @c wxPORT_BASE, then this value is zero
321 (unless externally modified with SetToolkitVersion()); that is, no native
322 toolkit is in use.
323 See wxAppTraits::GetToolkitVersion() for more info.
3c4f71cc 324
4cc4bfaf 325 @see CheckToolkitVersion()
23324ae1 326 */
328f5751 327 int GetToolkitMajorVersion() const;
23324ae1
FM
328
329 /**
330 Returns the run-time minor version of the toolkit associated with this
331 wxPlatformInfo instance.
74bf4e64
FM
332
333 Note that if GetPortId() returns @c wxPORT_BASE, then this value is zero
334 (unless externally modified with SetToolkitVersion()); that is, no native
335 toolkit is in use.
336 See wxAppTraits::GetToolkitVersion() for more info.
3c4f71cc 337
4cc4bfaf 338 @see CheckToolkitVersion()
23324ae1 339 */
328f5751 340 int GetToolkitMinorVersion() const;
23324ae1
FM
341
342 /**
343 Returns @true if this instance is fully initialized with valid values.
344 */
328f5751 345 bool IsOk() const;
23324ae1
FM
346
347 /**
348 Returns @true if this wxPlatformInfo describes wxUniversal build.
349 */
328f5751 350 bool IsUsingUniversalWidgets() const;
23324ae1
FM
351
352 /**
353 Sets the architecture enum value associated with this wxPlatformInfo instance.
354 */
355 void SetArchitecture(wxArchitecture n);
356
357 /**
358 Sets the endianness enum value associated with this wxPlatformInfo instance.
359 */
360 void SetEndianness(wxEndianness n);
361
362 /**
363 Sets the version of the operating system associated with this wxPlatformInfo
364 instance.
365 */
366 void SetOSVersion(int major, int minor);
367
368 /**
369 Sets the operating system associated with this wxPlatformInfo instance.
370 */
371 void SetOperatingSystemId(wxOperatingSystemId n);
372
373 /**
374 Sets the wxWidgets port ID associated with this wxPlatformInfo instance.
375 */
376 void SetPortId(wxPortId n);
377
378 /**
379 Sets the version of the toolkit associated with this wxPlatformInfo instance.
380 */
381 void SetToolkitVersion(int major, int minor);
382
383 /**
384 Inequality operator. Tests all class' internal variables.
385 */
328f5751 386 bool operator!=(const wxPlatformInfo& t) const;
23324ae1
FM
387
388 /**
389 Equality operator. Tests all class' internal variables.
390 */
328f5751 391 bool operator==(const wxPlatformInfo& t) const;
23324ae1 392};
e54c96f1 393