]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/platinfo.h
Document wxFileName::SetPath().
[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 89 wxARCH_32, //!< 32 bit
3b36f093 90 wxARCH_64, //!< 64 bit
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
23790a2a
FM
110/**
111 A structure containing informations about a Linux distribution as returned
112 by the @c lsb_release utility.
113
114 See wxGetLinuxDistributionInfo() or wxPlatformInfo::GetLinuxDistributionInfo()
115 for more info.
116*/
117struct wxLinuxDistributionInfo
118{
119 wxString Id; //!< The id of the distribution; e.g. "Ubuntu"
120 wxString Release; //!< The version of the distribution; e.g. "9.04"
121 wxString CodeName; //!< The code name of the distribution; e.g. "jaunty"
122 wxString Description; //!< The description of the distribution; e.g. "Ubuntu 9.04"
123
124 bool operator==(const wxLinuxDistributionInfo& ldi) const;
125 bool operator!=(const wxLinuxDistributionInfo& ldi) const;
126};
127
74bf4e64 128
4d7b68d1
FM
129/**
130 @class wxPlatformInfo
74bf4e64 131
3b36f093
FM
132 This class holds informations about the operating system, the toolkit and the
133 basic architecture of the machine where the application is currently running.
134
135 This class does not only have @e getters for the informations above, it also has
136 @e setters. This allows you to e.g. save the current platform informations in a
137 data file (maybe in string form) so that when you later load it, you can easily
23790a2a
FM
138 retrieve (see the static getters for string->enum conversion functions) and store
139 inside a wxPlatformInfo instance (using its setters) the signature of the system
140 which generated it.
141
142 In general however you only need to use the static Get() function and then
143 access the various informations for the current platform:
144 @code
145 wxLogMessage("This application is running under %s.",
146 wxPlatformInfo::Get().GetOperatingSystemIdName());
147 @endcode
74bf4e64 148
4d7b68d1 149 @library{wxbase}
3c99e2fd 150 @category{cfg}
74bf4e64 151
4d7b68d1 152 @see ::wxGetOsVersion(), wxIsPlatformLittleEndian(), wxIsPlatform64Bit(),
3b36f093 153 wxAppTraits, @ref group_funcmacro_networkuseros
23324ae1
FM
154*/
155class wxPlatformInfo : public wxObject
156{
157public:
74bf4e64 158
23324ae1 159 /**
74bf4e64
FM
160 Initializes the instance with the values corresponding to the currently
161 running platform.
162
163 This is a fast operation because it only requires to copy the values
164 internally cached for the currently running platform.
165
166 @see Get()
23324ae1
FM
167 */
168 wxPlatformInfo();
74bf4e64
FM
169
170 /**
171 Initializes the object using given values.
172 */
7c913512
FM
173 wxPlatformInfo(wxPortId pid = wxPORT_UNKNOWN,
174 int tkMajor = -1,
175 int tkMinor = -1,
176 wxOperatingSystemId id = wxOS_UNKNOWN,
177 int osMajor = -1,
178 int osMinor = -1,
179 wxArchitecture arch = wxARCH_INVALID,
180 wxEndianness endian = wxENDIAN_INVALID);
74bf4e64 181
23324ae1
FM
182
183 /**
184 Returns @true if the OS version is at least @c major.minor.
3c4f71cc 185
4cc4bfaf
FM
186 @see GetOSMajorVersion(), GetOSMinorVersion(),
187 CheckToolkitVersion()
23324ae1 188 */
328f5751 189 bool CheckOSVersion(int major, int minor) const;
23324ae1
FM
190
191 /**
192 Returns @true if the toolkit version is at least @c major.minor.
3c4f71cc 193
4cc4bfaf
FM
194 @see GetToolkitMajorVersion(),
195 GetToolkitMinorVersion(), CheckOSVersion()
23324ae1 196 */
328f5751 197 bool CheckToolkitVersion(int major, int minor) const;
3b36f093 198
23324ae1
FM
199
200 /**
3b36f093 201 Returns @true if this instance is fully initialized with valid values.
23324ae1 202 */
3b36f093 203 bool IsOk() const;
23324ae1
FM
204
205 /**
3b36f093 206 Returns @true if this wxPlatformInfo describes wxUniversal build.
23324ae1 207 */
3b36f093 208 bool IsUsingUniversalWidgets() const;
23324ae1 209
23324ae1 210 /**
3b36f093 211 Inequality operator. Tests all class' internal variables.
23324ae1 212 */
3b36f093 213 bool operator!=(const wxPlatformInfo& t) const;
74bf4e64
FM
214
215 /**
3b36f093 216 Equality operator. Tests all class' internal variables.
74bf4e64 217 */
3b36f093
FM
218 bool operator==(const wxPlatformInfo& t) const;
219
220 /**
221 Returns the global wxPlatformInfo object, initialized with the values
222 for the currently running platform.
223 */
224 static const wxPlatformInfo& Get();
225
226 /**
227 @name Static enum getters
228
229 These getters allow for easy string-to-enumeration-value conversion.
230 */
231 //@{
23324ae1
FM
232
233 /**
3b36f093
FM
234 Converts the given string to a wxArchitecture enum value or to
235 @c wxARCH_INVALID if the given string is not a valid architecture string
236 (i.e. does not contain nor @c 32 nor @c 64 strings).
23324ae1 237 */
3b36f093 238 static wxArchitecture GetArch(const wxString& arch);
23324ae1 239
23324ae1 240 /**
74bf4e64
FM
241 Converts the given string to a wxEndianness enum value or to
242 @c wxENDIAN_INVALID if the given string is not a valid endianness
243 string (i.e. does not contain nor little nor big strings).
23324ae1 244 */
57bf907d 245 static wxEndianness GetEndianness(const wxString& end);
74bf4e64
FM
246
247 /**
3b36f093
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.
74bf4e64 250 */
3b36f093 251 static wxOperatingSystemId GetOperatingSystemId(const wxString& name);
23324ae1 252
23324ae1 253 /**
3b36f093
FM
254 Converts the given string to a wxWidgets port ID value or to @c wxPORT_UNKNOWN
255 if the given string does not match any of the wxWidgets canonical name ports
256 ("wxGTK", "wxMSW", etc) nor any of the short wxWidgets name ports ("gtk", "msw", etc).
23324ae1 257 */
3b36f093
FM
258 static wxPortId GetPortId(const wxString& portname);
259
260 //@}
261
262
74bf4e64 263 /**
3b36f093
FM
264 @name Static string-form getters
265
266 These getters allow for easy enumeration-value-to-string conversion.
74bf4e64 267 */
3b36f093 268 //@{
23324ae1
FM
269
270 /**
3b36f093 271 Returns the name for the given wxArchitecture enumeration value.
23324ae1 272 */
3b36f093 273 static wxString GetArchName(wxArchitecture arch);
23324ae1
FM
274
275 /**
3b36f093 276 Returns name for the given wxEndianness enumeration value.
23324ae1 277 */
3b36f093
FM
278 static wxString GetEndiannessName(wxEndianness end);
279
74bf4e64
FM
280 /**
281 Returns the operating system family name for the given wxOperatingSystemId
282 enumeration value: @c Unix for @c wxOS_UNIX, @c Macintosh for @c wxOS_MAC,
283 @c Windows for @c wxOS_WINDOWS, @c DOS for @c wxOS_DOS, @c OS/2 for @c wxOS_OS2.
284 */
57bf907d 285 static wxString GetOperatingSystemFamilyName(wxOperatingSystemId os);
74bf4e64 286
23324ae1 287 /**
3b36f093 288 Returns the name for the given operating system ID value.
23324ae1 289
3b36f093
FM
290 This can be a long name (e.g. <tt>Microsoft Windows NT</tt>);
291 use GetOperatingSystemFamilyName() to retrieve a short, generic name.
23324ae1 292 */
3b36f093 293 static wxString GetOperatingSystemIdName(wxOperatingSystemId os);
74bf4e64
FM
294
295 /**
3b36f093
FM
296 Returns the name of the given wxWidgets port ID value.
297 The @a usingUniversal argument specifies whether the port is in its native
298 or wxUniversal variant.
299
300 The returned string always starts with the "wx" prefix and is a mixed-case string.
74bf4e64 301 */
3b36f093 302 static wxString GetPortIdName(wxPortId port, bool usingUniversal);
23324ae1 303
74bf4e64 304 /**
3b36f093
FM
305 Returns the short 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.
74bf4e64 308
3b36f093 309 The returned string does not start with the "wx" prefix and is always lower case.
74bf4e64 310 */
3b36f093
FM
311 static wxString GetPortIdShortName(wxPortId port,
312 bool usingUniversal);
74bf4e64 313
23790a2a
FM
314 /**
315 Returns the operating system directory.
316
317 See wxGetOSDirectory() for more info.
318 */
319 static wxString GetOperatingSystemDirectory();
320
3b36f093
FM
321 //@}
322
323
23324ae1 324 /**
3b36f093 325 @name Getters
23324ae1 326 */
3b36f093 327 //@{
74bf4e64 328
23324ae1 329 /**
3b36f093 330 Returns the architecture ID of this wxPlatformInfo instance.
23324ae1 331 */
3b36f093 332 wxArchitecture GetArchitecture() const;
74bf4e64
FM
333
334 /**
3b36f093 335 Returns the endianness ID of this wxPlatformInfo instance.
74bf4e64 336 */
3b36f093 337 wxEndianness GetEndianness() const;
23324ae1 338
74bf4e64 339 /**
3b36f093
FM
340 Returns the run-time major version of the OS associated with this
341 wxPlatformInfo instance.
74bf4e64 342
3b36f093 343 @see ::wxGetOsVersion(), CheckOSVersion()
74bf4e64 344 */
3b36f093 345 int GetOSMajorVersion() const;
74bf4e64 346
23324ae1 347 /**
3b36f093
FM
348 Returns the run-time minor version of the OS associated with this
349 wxPlatformInfo instance.
350
351 @see ::wxGetOsVersion(), CheckOSVersion()
23324ae1 352 */
3b36f093 353 int GetOSMinorVersion() const;
23324ae1 354
23324ae1 355 /**
3b36f093 356 Returns the operating system ID of this wxPlatformInfo instance.
23324ae1 357 */
3b36f093 358 wxOperatingSystemId GetOperatingSystemId() const;
23790a2a
FM
359
360 /**
361 Returns the description of the operating system of this wxPlatformInfo instance.
362
363 See wxGetOSDescription() for more info.
364 */
365 wxString GetOperatingSystemDescription() const;
74bf4e64
FM
366
367 /**
3b36f093 368 Returns the wxWidgets port ID associated with this wxPlatformInfo instance.
74bf4e64 369 */
3b36f093 370 wxPortId GetPortId() const;
23790a2a
FM
371
372 /**
373 Returns the Linux distribution info associated with this wxPlatformInfo instance.
374
375 See wxGetLinuxDistributionInfo() for more info.
376 */
377 wxLinuxDistributionInfo GetLinuxDistributionInfo() const;
378
379 /**
380 Returns the desktop environment associated with this wxPlatformInfo instance.
381
382 See wxAppTraits::GetDesktopEnvironment() for more info.
383 */
384 wxString GetDesktopEnvironment() const;
23324ae1
FM
385
386 /**
387 Returns the run-time major version of the toolkit associated with this
388 wxPlatformInfo instance.
74bf4e64
FM
389
390 Note that if GetPortId() returns @c wxPORT_BASE, then this value is zero
391 (unless externally modified with SetToolkitVersion()); that is, no native
392 toolkit is in use.
393 See wxAppTraits::GetToolkitVersion() for more info.
3c4f71cc 394
4cc4bfaf 395 @see CheckToolkitVersion()
23324ae1 396 */
328f5751 397 int GetToolkitMajorVersion() const;
23324ae1
FM
398
399 /**
400 Returns the run-time minor version of the toolkit associated with this
401 wxPlatformInfo instance.
74bf4e64
FM
402
403 Note that if GetPortId() returns @c wxPORT_BASE, then this value is zero
404 (unless externally modified with SetToolkitVersion()); that is, no native
405 toolkit is in use.
406 See wxAppTraits::GetToolkitVersion() for more info.
3c4f71cc 407
4cc4bfaf 408 @see CheckToolkitVersion()
23324ae1 409 */
328f5751 410 int GetToolkitMinorVersion() const;
3b36f093
FM
411
412 //@}
413
23324ae1
FM
414
415 /**
3b36f093 416 @name String-form getters
23324ae1 417 */
3b36f093 418 //@{
23324ae1
FM
419
420 /**
3b36f093 421 Returns the name for the architecture of this wxPlatformInfo instance.
23324ae1 422 */
3b36f093
FM
423 wxString GetArchName() const;
424
425 /**
426 Returns the name for the endianness of this wxPlatformInfo instance.
427 */
428 wxString GetEndiannessName() const;
23324ae1 429
3b36f093
FM
430 /**
431 Returns the operating system family name of the OS associated with this
432 wxPlatformInfo instance.
433 */
434 wxString GetOperatingSystemFamilyName() const;
435
436 /**
437 Returns the operating system name of the OS associated with this wxPlatformInfo
438 instance.
439 */
440 wxString GetOperatingSystemIdName() const;
441
442 /**
443 Returns the name of the wxWidgets port ID associated with this wxPlatformInfo
444 instance.
445 */
446 wxString GetPortIdName() const;
447
448 /**
449 Returns the short name of the wxWidgets port ID associated with this
450 wxPlatformInfo instance.
451 */
452 wxString GetPortIdShortName() const;
453
454 //@}
455
456
457
458 /**
459 @name Setters
460 */
461 //@{
462
23324ae1
FM
463 /**
464 Sets the architecture enum value associated with this wxPlatformInfo instance.
465 */
466 void SetArchitecture(wxArchitecture n);
467
468 /**
469 Sets the endianness enum value associated with this wxPlatformInfo instance.
470 */
471 void SetEndianness(wxEndianness n);
472
473 /**
474 Sets the version of the operating system associated with this wxPlatformInfo
475 instance.
476 */
477 void SetOSVersion(int major, int minor);
478
479 /**
480 Sets the operating system associated with this wxPlatformInfo instance.
481 */
482 void SetOperatingSystemId(wxOperatingSystemId n);
483
484 /**
485 Sets the wxWidgets port ID associated with this wxPlatformInfo instance.
486 */
487 void SetPortId(wxPortId n);
488
489 /**
490 Sets the version of the toolkit associated with this wxPlatformInfo instance.
491 */
492 void SetToolkitVersion(int major, int minor);
23790a2a
FM
493
494 /**
495 Sets the operating system description associated with this wxPlatformInfo instance.
496 */
497 void SetOperatingSystemDescription(const wxString& desc);
498
499 /**
500 Sets the desktop environment associated with this wxPlatformInfo instance.
501 */
502 void SetDesktopEnvironment(const wxString& de);
3b36f093 503
23790a2a
FM
504 /**
505 Sets the linux distribution info associated with this wxPlatformInfo instance.
506 */
507 void SetLinuxDistributionInfo(const wxLinuxDistributionInfo& di);
3b36f093 508
23790a2a 509 //@}
23324ae1 510};
e54c96f1 511