]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/platinfo.h
support for iPhone callbacks
[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$
526954c5 6// Licence: wxWindows licence
23324ae1
FM
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;
9bbb78b9
FM
15 this allows to check for operating system families like e.g. @c wxOS_MAC and @c wxOS_UNIX.
16
17 Note that you can obtain more detailed informations about the current OS
18 version in use by checking the major and minor version numbers returned
19 by ::wxGetOsVersion() or by wxPlatformInfo::GetOSMajorVersion(),
20 wxPlatformInfo::GetOSMinorVersion().
4d7b68d1
FM
21*/
22enum wxOperatingSystemId
23{
24 wxOS_UNKNOWN = 0, //!< returned on error
25
26 wxOS_MAC_OS = 1 << 0, //!< Apple Mac OS 8/9/X with Mac paths
27 wxOS_MAC_OSX_DARWIN = 1 << 1, //!< Apple Mac OS X with Unix paths
9bbb78b9
FM
28
29 //! A combination of all @c wxOS_MAC_* values previously listed.
4d7b68d1
FM
30 wxOS_MAC = wxOS_MAC_OS|wxOS_MAC_OSX_DARWIN,
31
32 wxOS_WINDOWS_9X = 1 << 2, //!< Windows 9x family (95/98/ME)
9bbb78b9 33 wxOS_WINDOWS_NT = 1 << 3, //!< Windows NT family (NT/2000/XP/Vista/7)
4d7b68d1
FM
34 wxOS_WINDOWS_MICRO = 1 << 4, //!< MicroWindows
35 wxOS_WINDOWS_CE = 1 << 5, //!< Windows CE (Window Mobile)
9bbb78b9
FM
36
37 //! A combination of all @c wxOS_WINDOWS_* values previously listed.
4d7b68d1
FM
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
9bbb78b9
FM
50
51 //! A combination of all @c wxOS_UNIX_* values previously listed.
4d7b68d1
FM
52 wxOS_UNIX = wxOS_UNIX_LINUX |
53 wxOS_UNIX_FREEBSD |
54 wxOS_UNIX_OPENBSD |
55 wxOS_UNIX_NETBSD |
56 wxOS_UNIX_SOLARIS |
57 wxOS_UNIX_AIX |
58 wxOS_UNIX_HPUX,
59
60 wxOS_DOS = 1 << 15, //!< Microsoft DOS
61 wxOS_OS2 = 1 << 16 //!< OS/2
62};
74bf4e64 63
4d7b68d1 64/**
74bf4e64 65 The list of wxWidgets ports.
4d7b68d1 66
74bf4e64
FM
67 Some of them can be used with more than a single (native) toolkit;
68 e.g. wxWinCE port sources can be used with smartphones, pocket PCs
69 and handheld devices SDKs.
4d7b68d1
FM
70*/
71enum wxPortId
72{
73 wxPORT_UNKNOWN = 0, //!< returned on error
74bf4e64 74
4d7b68d1 75 wxPORT_BASE = 1 << 0, //!< wxBase, no native toolkit used
74bf4e64 76
4d7b68d1
FM
77 wxPORT_MSW = 1 << 1, //!< wxMSW, native toolkit is Windows API
78 wxPORT_MOTIF = 1 << 2, //!< wxMotif, using [Open]Motif or Lesstif
79 wxPORT_GTK = 1 << 3, //!< wxGTK, using GTK+ 1.x, 2.x, GPE or Maemo
0e1f8ea4 80 wxPORT_DFB = 1 << 4, //!< wxDFB, using wxUniversal
4d7b68d1
FM
81 wxPORT_X11 = 1 << 5, //!< wxX11, using wxUniversal
82 wxPORT_OS2 = 1 << 6, //!< wxOS2, using OS/2 Presentation Manager
83 wxPORT_MAC = 1 << 7, //!< wxMac, using Carbon or Classic Mac API
84 wxPORT_COCOA = 1 << 8, //!< wxCocoa, using Cocoa NextStep/Mac API
0e1f8ea4 85 wxPORT_WINCE = 1 << 9 //!< wxWinCE, toolkit is WinCE SDK API
4d7b68d1 86};
74bf4e64 87
74bf4e64 88
4d7b68d1 89/**
74bf4e64 90 The architecture of the operating system
b2025b31 91 (regardless of the build environment of wxWidgets library - see ::wxIsPlatform64Bit()
b1b95a65 92 documentation for more info).
4d7b68d1
FM
93*/
94enum wxArchitecture
95{
96 wxARCH_INVALID = -1, //!< returned on error
74bf4e64 97
4d7b68d1 98 wxARCH_32, //!< 32 bit
3b36f093 99 wxARCH_64, //!< 64 bit
74bf4e64 100
4d7b68d1 101 wxARCH_MAX
3a7fb603 102};
74bf4e64 103
74bf4e64 104
4d7b68d1 105/**
74bf4e64 106 The endian-ness of the machine.
4d7b68d1
FM
107*/
108enum wxEndianness
109{
110 wxENDIAN_INVALID = -1, //!< returned on error
74bf4e64 111
4d7b68d1
FM
112 wxENDIAN_BIG, //!< 4321
113 wxENDIAN_LITTLE, //!< 1234
114 wxENDIAN_PDP, //!< 3412
74bf4e64 115
4d7b68d1 116 wxENDIAN_MAX
3a7fb603 117};
74bf4e64 118
23790a2a
FM
119/**
120 A structure containing informations about a Linux distribution as returned
121 by the @c lsb_release utility.
122
123 See wxGetLinuxDistributionInfo() or wxPlatformInfo::GetLinuxDistributionInfo()
124 for more info.
125*/
126struct wxLinuxDistributionInfo
127{
128 wxString Id; //!< The id of the distribution; e.g. "Ubuntu"
129 wxString Release; //!< The version of the distribution; e.g. "9.04"
130 wxString CodeName; //!< The code name of the distribution; e.g. "jaunty"
131 wxString Description; //!< The description of the distribution; e.g. "Ubuntu 9.04"
132
133 bool operator==(const wxLinuxDistributionInfo& ldi) const;
134 bool operator!=(const wxLinuxDistributionInfo& ldi) const;
135};
136
74bf4e64 137
4d7b68d1
FM
138/**
139 @class wxPlatformInfo
74bf4e64 140
3b36f093
FM
141 This class holds informations about the operating system, the toolkit and the
142 basic architecture of the machine where the application is currently running.
143
144 This class does not only have @e getters for the informations above, it also has
145 @e setters. This allows you to e.g. save the current platform informations in a
146 data file (maybe in string form) so that when you later load it, you can easily
23790a2a
FM
147 retrieve (see the static getters for string->enum conversion functions) and store
148 inside a wxPlatformInfo instance (using its setters) the signature of the system
149 which generated it.
150
151 In general however you only need to use the static Get() function and then
152 access the various informations for the current platform:
153 @code
154 wxLogMessage("This application is running under %s.",
155 wxPlatformInfo::Get().GetOperatingSystemIdName());
156 @endcode
74bf4e64 157
4d7b68d1 158 @library{wxbase}
3c99e2fd 159 @category{cfg}
74bf4e64 160
4d7b68d1 161 @see ::wxGetOsVersion(), wxIsPlatformLittleEndian(), wxIsPlatform64Bit(),
3b36f093 162 wxAppTraits, @ref group_funcmacro_networkuseros
23324ae1 163*/
a3b14191 164class wxPlatformInfo
23324ae1
FM
165{
166public:
74bf4e64 167
23324ae1 168 /**
74bf4e64
FM
169 Initializes the instance with the values corresponding to the currently
170 running platform.
171
172 This is a fast operation because it only requires to copy the values
173 internally cached for the currently running platform.
174
175 @see Get()
23324ae1
FM
176 */
177 wxPlatformInfo();
74bf4e64
FM
178
179 /**
180 Initializes the object using given values.
181 */
5e0e1372 182 wxPlatformInfo(wxPortId pid,
7c913512
FM
183 int tkMajor = -1,
184 int tkMinor = -1,
185 wxOperatingSystemId id = wxOS_UNKNOWN,
186 int osMajor = -1,
187 int osMinor = -1,
188 wxArchitecture arch = wxARCH_INVALID,
189 wxEndianness endian = wxENDIAN_INVALID);
74bf4e64 190
23324ae1
FM
191
192 /**
193 Returns @true if the OS version is at least @c major.minor.
3c4f71cc 194
4cc4bfaf
FM
195 @see GetOSMajorVersion(), GetOSMinorVersion(),
196 CheckToolkitVersion()
23324ae1 197 */
328f5751 198 bool CheckOSVersion(int major, int minor) const;
23324ae1
FM
199
200 /**
201 Returns @true if the toolkit version is at least @c major.minor.
3c4f71cc 202
4cc4bfaf
FM
203 @see GetToolkitMajorVersion(),
204 GetToolkitMinorVersion(), CheckOSVersion()
23324ae1 205 */
328f5751 206 bool CheckToolkitVersion(int major, int minor) const;
3b36f093 207
23324ae1
FM
208
209 /**
3b36f093 210 Returns @true if this instance is fully initialized with valid values.
23324ae1 211 */
3b36f093 212 bool IsOk() const;
23324ae1
FM
213
214 /**
3b36f093 215 Returns @true if this wxPlatformInfo describes wxUniversal build.
23324ae1 216 */
3b36f093 217 bool IsUsingUniversalWidgets() const;
23324ae1 218
23324ae1 219 /**
3b36f093 220 Inequality operator. Tests all class' internal variables.
23324ae1 221 */
3b36f093 222 bool operator!=(const wxPlatformInfo& t) const;
74bf4e64
FM
223
224 /**
3b36f093 225 Equality operator. Tests all class' internal variables.
74bf4e64 226 */
3b36f093
FM
227 bool operator==(const wxPlatformInfo& t) const;
228
229 /**
230 Returns the global wxPlatformInfo object, initialized with the values
231 for the currently running platform.
232 */
233 static const wxPlatformInfo& Get();
234
235 /**
236 @name Static enum getters
237
238 These getters allow for easy string-to-enumeration-value conversion.
239 */
240 //@{
23324ae1
FM
241
242 /**
3b36f093
FM
243 Converts the given string to a wxArchitecture enum value or to
244 @c wxARCH_INVALID if the given string is not a valid architecture string
245 (i.e. does not contain nor @c 32 nor @c 64 strings).
23324ae1 246 */
3b36f093 247 static wxArchitecture GetArch(const wxString& arch);
23324ae1 248
23324ae1 249 /**
74bf4e64
FM
250 Converts the given string to a wxEndianness enum value or to
251 @c wxENDIAN_INVALID if the given string is not a valid endianness
252 string (i.e. does not contain nor little nor big strings).
23324ae1 253 */
57bf907d 254 static wxEndianness GetEndianness(const wxString& end);
74bf4e64
FM
255
256 /**
3b36f093
FM
257 Converts the given string to a wxOperatingSystemId enum value or to @c
258 wxOS_UNKNOWN if the given string is not a valid operating system name.
74bf4e64 259 */
3b36f093 260 static wxOperatingSystemId GetOperatingSystemId(const wxString& name);
23324ae1 261
23324ae1 262 /**
3b36f093
FM
263 Converts the given string to a wxWidgets port ID value or to @c wxPORT_UNKNOWN
264 if the given string does not match any of the wxWidgets canonical name ports
265 ("wxGTK", "wxMSW", etc) nor any of the short wxWidgets name ports ("gtk", "msw", etc).
23324ae1 266 */
3b36f093
FM
267 static wxPortId GetPortId(const wxString& portname);
268
269 //@}
270
271
74bf4e64 272 /**
3b36f093
FM
273 @name Static string-form getters
274
275 These getters allow for easy enumeration-value-to-string conversion.
74bf4e64 276 */
3b36f093 277 //@{
23324ae1
FM
278
279 /**
3b36f093 280 Returns the name for the given wxArchitecture enumeration value.
23324ae1 281 */
3b36f093 282 static wxString GetArchName(wxArchitecture arch);
23324ae1
FM
283
284 /**
3b36f093 285 Returns name for the given wxEndianness enumeration value.
23324ae1 286 */
3b36f093
FM
287 static wxString GetEndiannessName(wxEndianness end);
288
74bf4e64
FM
289 /**
290 Returns the operating system family name for the given wxOperatingSystemId
291 enumeration value: @c Unix for @c wxOS_UNIX, @c Macintosh for @c wxOS_MAC,
292 @c Windows for @c wxOS_WINDOWS, @c DOS for @c wxOS_DOS, @c OS/2 for @c wxOS_OS2.
293 */
57bf907d 294 static wxString GetOperatingSystemFamilyName(wxOperatingSystemId os);
74bf4e64 295
23324ae1 296 /**
3b36f093 297 Returns the name for the given operating system ID value.
23324ae1 298
3b36f093
FM
299 This can be a long name (e.g. <tt>Microsoft Windows NT</tt>);
300 use GetOperatingSystemFamilyName() to retrieve a short, generic name.
23324ae1 301 */
3b36f093 302 static wxString GetOperatingSystemIdName(wxOperatingSystemId os);
74bf4e64
FM
303
304 /**
3b36f093
FM
305 Returns the name of the given wxWidgets port ID value.
306 The @a usingUniversal argument specifies whether the port is in its native
307 or wxUniversal variant.
308
309 The returned string always starts with the "wx" prefix and is a mixed-case string.
74bf4e64 310 */
3b36f093 311 static wxString GetPortIdName(wxPortId port, bool usingUniversal);
23324ae1 312
74bf4e64 313 /**
3b36f093
FM
314 Returns the short name of the given wxWidgets port ID value.
315 The @a usingUniversal argument specifies whether the port is in its native
316 or wxUniversal variant.
74bf4e64 317
3b36f093 318 The returned string does not start with the "wx" prefix and is always lower case.
74bf4e64 319 */
3b36f093
FM
320 static wxString GetPortIdShortName(wxPortId port,
321 bool usingUniversal);
74bf4e64 322
23790a2a
FM
323 /**
324 Returns the operating system directory.
325
326 See wxGetOSDirectory() for more info.
327 */
328 static wxString GetOperatingSystemDirectory();
329
3b36f093
FM
330 //@}
331
332
23324ae1 333 /**
3b36f093 334 @name Getters
23324ae1 335 */
3b36f093 336 //@{
74bf4e64 337
23324ae1 338 /**
3b36f093 339 Returns the architecture ID of this wxPlatformInfo instance.
23324ae1 340 */
3b36f093 341 wxArchitecture GetArchitecture() const;
74bf4e64
FM
342
343 /**
3b36f093 344 Returns the endianness ID of this wxPlatformInfo instance.
74bf4e64 345 */
3b36f093 346 wxEndianness GetEndianness() const;
23324ae1 347
74bf4e64 348 /**
3b36f093
FM
349 Returns the run-time major version of the OS associated with this
350 wxPlatformInfo instance.
74bf4e64 351
3b36f093 352 @see ::wxGetOsVersion(), CheckOSVersion()
74bf4e64 353 */
3b36f093 354 int GetOSMajorVersion() const;
74bf4e64 355
23324ae1 356 /**
3b36f093
FM
357 Returns the run-time minor version of the OS associated with this
358 wxPlatformInfo instance.
359
360 @see ::wxGetOsVersion(), CheckOSVersion()
23324ae1 361 */
3b36f093 362 int GetOSMinorVersion() const;
23324ae1 363
23324ae1 364 /**
3b36f093 365 Returns the operating system ID of this wxPlatformInfo instance.
9bbb78b9
FM
366
367 See wxGetOsVersion() for more info.
23324ae1 368 */
3b36f093 369 wxOperatingSystemId GetOperatingSystemId() const;
23790a2a
FM
370
371 /**
372 Returns the description of the operating system of this wxPlatformInfo instance.
373
374 See wxGetOSDescription() for more info.
375 */
376 wxString GetOperatingSystemDescription() const;
74bf4e64
FM
377
378 /**
3b36f093 379 Returns the wxWidgets port ID associated with this wxPlatformInfo instance.
74bf4e64 380 */
3b36f093 381 wxPortId GetPortId() const;
23790a2a
FM
382
383 /**
384 Returns the Linux distribution info associated with this wxPlatformInfo instance.
385
386 See wxGetLinuxDistributionInfo() for more info.
387 */
388 wxLinuxDistributionInfo GetLinuxDistributionInfo() const;
389
390 /**
391 Returns the desktop environment associated with this wxPlatformInfo instance.
392
393 See wxAppTraits::GetDesktopEnvironment() for more info.
394 */
395 wxString GetDesktopEnvironment() const;
23324ae1
FM
396
397 /**
398 Returns the run-time major version of the toolkit associated with this
399 wxPlatformInfo instance.
74bf4e64
FM
400
401 Note that if GetPortId() returns @c wxPORT_BASE, then this value is zero
402 (unless externally modified with SetToolkitVersion()); that is, no native
403 toolkit is in use.
404 See wxAppTraits::GetToolkitVersion() for more info.
3c4f71cc 405
4cc4bfaf 406 @see CheckToolkitVersion()
23324ae1 407 */
328f5751 408 int GetToolkitMajorVersion() const;
23324ae1
FM
409
410 /**
411 Returns the run-time minor version of the toolkit associated with this
412 wxPlatformInfo instance.
74bf4e64
FM
413
414 Note that if GetPortId() returns @c wxPORT_BASE, then this value is zero
415 (unless externally modified with SetToolkitVersion()); that is, no native
416 toolkit is in use.
417 See wxAppTraits::GetToolkitVersion() for more info.
3c4f71cc 418
4cc4bfaf 419 @see CheckToolkitVersion()
23324ae1 420 */
328f5751 421 int GetToolkitMinorVersion() const;
3b36f093
FM
422
423 //@}
424
23324ae1
FM
425
426 /**
3b36f093 427 @name String-form getters
23324ae1 428 */
3b36f093 429 //@{
23324ae1
FM
430
431 /**
3b36f093 432 Returns the name for the architecture of this wxPlatformInfo instance.
23324ae1 433 */
3b36f093
FM
434 wxString GetArchName() const;
435
436 /**
437 Returns the name for the endianness of this wxPlatformInfo instance.
438 */
439 wxString GetEndiannessName() const;
23324ae1 440
3b36f093
FM
441 /**
442 Returns the operating system family name of the OS associated with this
443 wxPlatformInfo instance.
444 */
445 wxString GetOperatingSystemFamilyName() const;
446
447 /**
448 Returns the operating system name of the OS associated with this wxPlatformInfo
449 instance.
450 */
451 wxString GetOperatingSystemIdName() const;
452
453 /**
454 Returns the name of the wxWidgets port ID associated with this wxPlatformInfo
455 instance.
456 */
457 wxString GetPortIdName() const;
458
459 /**
460 Returns the short name of the wxWidgets port ID associated with this
461 wxPlatformInfo instance.
462 */
463 wxString GetPortIdShortName() const;
464
465 //@}
466
467
468
469 /**
470 @name Setters
471 */
472 //@{
473
23324ae1
FM
474 /**
475 Sets the architecture enum value associated with this wxPlatformInfo instance.
476 */
477 void SetArchitecture(wxArchitecture n);
478
479 /**
480 Sets the endianness enum value associated with this wxPlatformInfo instance.
481 */
482 void SetEndianness(wxEndianness n);
483
484 /**
485 Sets the version of the operating system associated with this wxPlatformInfo
486 instance.
487 */
488 void SetOSVersion(int major, int minor);
489
490 /**
491 Sets the operating system associated with this wxPlatformInfo instance.
492 */
493 void SetOperatingSystemId(wxOperatingSystemId n);
494
495 /**
496 Sets the wxWidgets port ID associated with this wxPlatformInfo instance.
497 */
498 void SetPortId(wxPortId n);
499
500 /**
501 Sets the version of the toolkit associated with this wxPlatformInfo instance.
502 */
503 void SetToolkitVersion(int major, int minor);
23790a2a
FM
504
505 /**
506 Sets the operating system description associated with this wxPlatformInfo instance.
507 */
508 void SetOperatingSystemDescription(const wxString& desc);
509
510 /**
511 Sets the desktop environment associated with this wxPlatformInfo instance.
512 */
513 void SetDesktopEnvironment(const wxString& de);
3b36f093 514
23790a2a
FM
515 /**
516 Sets the linux distribution info associated with this wxPlatformInfo instance.
517 */
518 void SetLinuxDistributionInfo(const wxLinuxDistributionInfo& di);
3b36f093 519
23790a2a 520 //@}
23324ae1 521};
e54c96f1 522