]> git.saurik.com Git - wxWidgets.git/blob - include/wx/utils.h
Easier platform testing class and function
[wxWidgets.git] / include / wx / utils.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/utils.h
3 // Purpose: Miscellaneous utilities
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 29/01/98
7 // RCS-ID: $Id$
8 // Copyright: (c) 1998 Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_UTILSH__
13 #define _WX_UTILSH__
14
15 // ----------------------------------------------------------------------------
16 // headers
17 // ----------------------------------------------------------------------------
18
19 #include "wx/object.h"
20 #include "wx/list.h"
21 #include "wx/filefn.h"
22
23 class WXDLLIMPEXP_BASE wxArrayString;
24 class WXDLLIMPEXP_BASE wxArrayInt;
25
26 // need this for wxGetDiskSpace() as we can't, unfortunately, forward declare
27 // wxLongLong
28 #include "wx/longlong.h"
29
30 #ifdef __WATCOMC__
31 #include <direct.h>
32 #elif defined(__X__)
33 #include <dirent.h>
34 #include <unistd.h>
35 #endif
36
37 #include <stdio.h>
38
39 // ----------------------------------------------------------------------------
40 // Forward declaration
41 // ----------------------------------------------------------------------------
42
43 class WXDLLIMPEXP_CORE wxProcess;
44 class WXDLLIMPEXP_CORE wxFrame;
45 class WXDLLIMPEXP_CORE wxWindow;
46 class WXDLLIMPEXP_CORE wxWindowList;
47 class WXDLLIMPEXP_CORE wxPoint;
48
49 // ----------------------------------------------------------------------------
50 // Macros
51 // ----------------------------------------------------------------------------
52
53 #define wxMax(a,b) (((a) > (b)) ? (a) : (b))
54 #define wxMin(a,b) (((a) < (b)) ? (a) : (b))
55
56 // wxGetFreeMemory can return huge amount of memory on 32-bit platforms as well
57 // so to always use long long for its result type on all platforms which
58 // support it
59 #if wxUSE_LONGLONG
60 typedef wxLongLong wxMemorySize;
61 #else
62 typedef long wxMemorySize;
63 #endif
64
65 // ----------------------------------------------------------------------------
66 // String functions (deprecated, use wxString)
67 // ----------------------------------------------------------------------------
68
69 // Make a copy of this string using 'new'
70 #if WXWIN_COMPATIBILITY_2_4
71 wxDEPRECATED( WXDLLIMPEXP_BASE wxChar* copystring(const wxChar *s) );
72 #endif
73
74 // A shorter way of using strcmp
75 #define wxStringEq(s1, s2) (s1 && s2 && (wxStrcmp(s1, s2) == 0))
76
77 // ----------------------------------------------------------------------------
78 // Miscellaneous functions
79 // ----------------------------------------------------------------------------
80
81 // Sound the bell
82 #if !defined __EMX__ && \
83 (defined __WXMOTIF__ || defined __WXGTK__ || defined __WXX11__)
84 WXDLLIMPEXP_CORE void wxBell();
85 #else
86 WXDLLIMPEXP_BASE void wxBell();
87 #endif
88
89 // Get OS description as a user-readable string
90 WXDLLIMPEXP_BASE wxString wxGetOsDescription();
91
92 // Get OS version
93 WXDLLIMPEXP_BASE int wxGetOsVersion(int *majorVsn = (int *) NULL,
94 int *minorVsn = (int *) NULL);
95
96 // Return a string with the current date/time
97 WXDLLIMPEXP_BASE wxString wxNow();
98
99 // Return path where wxWidgets is installed (mostly useful in Unices)
100 WXDLLIMPEXP_BASE const wxChar *wxGetInstallPrefix();
101 // Return path to wxWin data (/usr/share/wx/%{version}) (Unices)
102 WXDLLIMPEXP_BASE wxString wxGetDataDir();
103
104 /*
105 * Class to make it easier to specify platform-dependent values
106 *
107 * Examples:
108 * long val = wxPlatform(3).Is(wxMac, 1).Is(wxGTK, 2).Is(stPDA, 5);
109 * wxString strVal = wxPlatform(wxT("Hello")).Is(wxMac, wxT("Mac")).Is(wxMSW, wxT("MSW"));
110 *
111 * A custom platform symbol:
112 *
113 * #define stPDA 100
114 * #ifdef __WXWINCE__
115 * wxPlatform::AddPlatform(stPDA);
116 * #endif
117 *
118 * long windowStyle = wxCAPTION | (long) wxPlatform().IsNot(stPDA, wxRESIZE_BORDER);
119 *
120 */
121
122 class WXDLLIMPEXP_BASE wxPlatform
123 {
124 public:
125 wxPlatform() { m_longValue = 0; m_doubleValue = 0.0; }
126
127 // Specify an optional default value
128 wxPlatform(long defValue) { m_longValue = defValue; m_doubleValue = 0.0; }
129 wxPlatform(const wxString& defValue) { m_stringValue = defValue; m_longValue = 0; m_doubleValue = 0.0; }
130 wxPlatform(double defValue) { m_longValue = 0; m_doubleValue = defValue; }
131
132 wxPlatform& Is(int platform, long value);
133 wxPlatform& IsNot(int platform, long value);
134
135 wxPlatform& Is(int platform, int value) { return Is(platform, (long) value); }
136 wxPlatform& IsNot(int platform, int value) { return IsNot(platform, (long) value); }
137
138 wxPlatform& Is(int platform, const wxString& value);
139 wxPlatform& IsNot(int platform, const wxString& value);
140
141 wxPlatform& Is(int platform, double value);
142 wxPlatform& IsNot(int platform, double value);
143
144 // This should be specified first to set the default value, or simply
145 // pass the value to the constructor
146 wxPlatform& Default(long value);
147 wxPlatform& Default(const wxString& value);
148 wxPlatform& Default(double value);
149
150 long GetInteger() const { return m_longValue; }
151 const wxString& GetString() const { return m_stringValue; }
152 double GetDouble() const { return m_doubleValue; }
153
154 operator int() const { return (int) GetInteger(); }
155 operator long() const { return GetInteger(); }
156 operator double() const { return GetDouble(); }
157 operator const wxString() const { return GetString(); }
158 operator const wxChar*() const { return (const wxChar*) GetString(); }
159
160 static void AddPlatform(int platform);
161 static bool PlatformIs(int platform);
162 static void ClearPlatforms();
163
164 private:
165 long m_longValue;
166 double m_doubleValue;
167 wxString m_stringValue;
168 static wxArrayInt* sm_customPlatforms;
169 };
170
171 /// Function for testing current platform
172 inline bool wxPlatformIs(int platform) { return wxPlatform::PlatformIs(platform); }
173
174 #if wxUSE_GUI
175
176 // Get the state of a key (true if pressed, false if not)
177 // This is generally most useful getting the state of
178 // the modifier or toggle keys.
179 WXDLLEXPORT bool wxGetKeyState(wxKeyCode key);
180
181
182 // Don't synthesize KeyUp events holding down a key and producing
183 // KeyDown events with autorepeat. On by default and always on
184 // in wxMSW.
185 WXDLLEXPORT bool wxSetDetectableAutoRepeat( bool flag );
186
187
188 // wxMouseState is used to hold information about button and modifier state
189 // and is what is returned from wxGetMouseState.
190 class WXDLLEXPORT wxMouseState
191 {
192 public:
193 wxMouseState()
194 : m_x(0), m_y(0),
195 m_leftDown(false), m_middleDown(false), m_rightDown(false),
196 m_controlDown(false), m_shiftDown(false), m_altDown(false),
197 m_metaDown(false)
198 {}
199
200 wxCoord GetX() { return m_x; }
201 wxCoord GetY() { return m_y; }
202
203 bool LeftDown() { return m_leftDown; }
204 bool MiddleDown() { return m_middleDown; }
205 bool RightDown() { return m_rightDown; }
206
207 bool ControlDown() { return m_controlDown; }
208 bool ShiftDown() { return m_shiftDown; }
209 bool AltDown() { return m_altDown; }
210 bool MetaDown() { return m_metaDown; }
211 bool CmdDown()
212 {
213 #if defined(__WXMAC__) || defined(__WXCOCOA__)
214 return MetaDown();
215 #else
216 return ControlDown();
217 #endif
218 }
219
220 void SetX(wxCoord x) { m_x = x; }
221 void SetY(wxCoord y) { m_y = y; }
222
223 void SetLeftDown(bool down) { m_leftDown = down; }
224 void SetMiddleDown(bool down) { m_middleDown = down; }
225 void SetRightDown(bool down) { m_rightDown = down; }
226
227 void SetControlDown(bool down) { m_controlDown = down; }
228 void SetShiftDown(bool down) { m_shiftDown = down; }
229 void SetAltDown(bool down) { m_altDown = down; }
230 void SetMetaDown(bool down) { m_metaDown = down; }
231
232 private:
233 wxCoord m_x;
234 wxCoord m_y;
235
236 bool m_leftDown;
237 bool m_middleDown;
238 bool m_rightDown;
239
240 bool m_controlDown;
241 bool m_shiftDown;
242 bool m_altDown;
243 bool m_metaDown;
244 };
245
246
247 // Returns the current state of the mouse position, buttons and modifers
248 WXDLLEXPORT wxMouseState wxGetMouseState();
249
250
251 // ----------------------------------------------------------------------------
252 // Window ID management
253 // ----------------------------------------------------------------------------
254
255 // Generate a unique ID
256 WXDLLEXPORT long wxNewId();
257
258 // Ensure subsequent IDs don't clash with this one
259 WXDLLEXPORT void wxRegisterId(long id);
260
261 // Return the current ID
262 WXDLLEXPORT long wxGetCurrentId();
263
264 #endif // wxUSE_GUI
265
266 // ----------------------------------------------------------------------------
267 // Various conversions
268 // ----------------------------------------------------------------------------
269
270 // these functions are deprecated, use wxString methods instead!
271 #if WXWIN_COMPATIBILITY_2_4
272
273 extern WXDLLIMPEXP_DATA_BASE(const wxChar*) wxFloatToStringStr;
274 extern WXDLLIMPEXP_DATA_BASE(const wxChar*) wxDoubleToStringStr;
275
276 wxDEPRECATED( WXDLLIMPEXP_BASE void StringToFloat(const wxChar *s, float *number) );
277 wxDEPRECATED( WXDLLIMPEXP_BASE wxChar* FloatToString(float number, const wxChar *fmt = wxFloatToStringStr) );
278 wxDEPRECATED( WXDLLIMPEXP_BASE void StringToDouble(const wxChar *s, double *number) );
279 wxDEPRECATED( WXDLLIMPEXP_BASE wxChar* DoubleToString(double number, const wxChar *fmt = wxDoubleToStringStr) );
280 wxDEPRECATED( WXDLLIMPEXP_BASE void StringToInt(const wxChar *s, int *number) );
281 wxDEPRECATED( WXDLLIMPEXP_BASE void StringToLong(const wxChar *s, long *number) );
282 wxDEPRECATED( WXDLLIMPEXP_BASE wxChar* IntToString(int number) );
283 wxDEPRECATED( WXDLLIMPEXP_BASE wxChar* LongToString(long number) );
284
285 #endif // WXWIN_COMPATIBILITY_2_4
286
287 // Convert 2-digit hex number to decimal
288 WXDLLIMPEXP_BASE int wxHexToDec(const wxString& buf);
289
290 // Convert decimal integer to 2-character hex string
291 WXDLLIMPEXP_BASE void wxDecToHex(int dec, wxChar *buf);
292 WXDLLIMPEXP_BASE wxString wxDecToHex(int dec);
293
294 // ----------------------------------------------------------------------------
295 // Process management
296 // ----------------------------------------------------------------------------
297
298 // NB: for backwards compatibility reasons the values of wxEXEC_[A]SYNC *must*
299 // be 0 and 1, don't change!
300
301 enum
302 {
303 // execute the process asynchronously
304 wxEXEC_ASYNC = 0,
305
306 // execute it synchronously, i.e. wait until it finishes
307 wxEXEC_SYNC = 1,
308
309 // under Windows, don't hide the child even if it's IO is redirected (this
310 // is done by default)
311 wxEXEC_NOHIDE = 2,
312
313 // under Unix, if the process is the group leader then passing wxKILL_CHILDREN to wxKill
314 // kills all children as well as pid
315 wxEXEC_MAKE_GROUP_LEADER = 4,
316
317 // by default synchronous execution disables all program windows to avoid
318 // that the user interacts with the program while the child process is
319 // running, you can use this flag to prevent this from happening
320 wxEXEC_NODISABLE = 8
321 };
322
323 // Execute another program.
324 //
325 // If flags contain wxEXEC_SYNC, return -1 on failure and the exit code of the
326 // process if everything was ok. Otherwise (i.e. if wxEXEC_ASYNC), return 0 on
327 // failure and the PID of the launched process if ok.
328 WXDLLIMPEXP_BASE long wxExecute(wxChar **argv, int flags = wxEXEC_ASYNC,
329 wxProcess *process = (wxProcess *) NULL);
330 WXDLLIMPEXP_BASE long wxExecute(const wxString& command, int flags = wxEXEC_ASYNC,
331 wxProcess *process = (wxProcess *) NULL);
332
333 // execute the command capturing its output into an array line by line, this is
334 // always synchronous
335 WXDLLIMPEXP_BASE long wxExecute(const wxString& command,
336 wxArrayString& output,
337 int flags = 0);
338
339 // also capture stderr (also synchronous)
340 WXDLLIMPEXP_BASE long wxExecute(const wxString& command,
341 wxArrayString& output,
342 wxArrayString& error,
343 int flags = 0);
344
345 #if defined(__WXMSW__) && wxUSE_IPC
346 // ask a DDE server to execute the DDE request with given parameters
347 WXDLLIMPEXP_BASE bool wxExecuteDDE(const wxString& ddeServer,
348 const wxString& ddeTopic,
349 const wxString& ddeCommand);
350 #endif // __WXMSW__ && wxUSE_IPC
351
352 enum wxSignal
353 {
354 wxSIGNONE = 0, // verify if the process exists under Unix
355 wxSIGHUP,
356 wxSIGINT,
357 wxSIGQUIT,
358 wxSIGILL,
359 wxSIGTRAP,
360 wxSIGABRT,
361 wxSIGIOT = wxSIGABRT, // another name
362 wxSIGEMT,
363 wxSIGFPE,
364 wxSIGKILL,
365 wxSIGBUS,
366 wxSIGSEGV,
367 wxSIGSYS,
368 wxSIGPIPE,
369 wxSIGALRM,
370 wxSIGTERM
371
372 // further signals are different in meaning between different Unix systems
373 };
374
375 enum wxKillError
376 {
377 wxKILL_OK, // no error
378 wxKILL_BAD_SIGNAL, // no such signal
379 wxKILL_ACCESS_DENIED, // permission denied
380 wxKILL_NO_PROCESS, // no such process
381 wxKILL_ERROR // another, unspecified error
382 };
383
384 enum wxKillFlags
385 {
386 wxKILL_NOCHILDREN = 0, // don't kill children
387 wxKILL_CHILDREN = 1 // kill children
388 };
389
390 enum wxShutdownFlags
391 {
392 wxSHUTDOWN_POWEROFF, // power off the computer
393 wxSHUTDOWN_REBOOT // shutdown and reboot
394 };
395
396 // Shutdown or reboot the PC
397 WXDLLIMPEXP_BASE bool wxShutdown(wxShutdownFlags wFlags);
398
399 enum wxPowerType
400 {
401 wxPOWER_SOCKET,
402 wxPOWER_BATTERY,
403 wxPOWER_UNKNOWN
404 };
405
406 WXDLLIMPEXP_BASE wxPowerType wxGetPowerType();
407
408 enum wxBatteryState
409 {
410 wxBATTERY_NORMAL_STATE, // system is fully usable
411 wxBATTERY_LOW_STATE, // start to worry
412 wxBATTERY_CRITICAL_STATE, // save quickly
413 wxBATTERY_SHUTDOWN_STATE, // too late
414 wxBATTERY_UNKNOWN_STATE
415 };
416
417 WXDLLIMPEXP_BASE wxBatteryState wxGetBatteryState();
418
419 // send the given signal to the process (only NONE and KILL are supported under
420 // Windows, all others mean TERM), return 0 if ok and -1 on error
421 //
422 // return detailed error in rc if not NULL
423 WXDLLIMPEXP_BASE int wxKill(long pid,
424 wxSignal sig = wxSIGTERM,
425 wxKillError *rc = NULL,
426 int flags = wxKILL_NOCHILDREN);
427
428 // Execute a command in an interactive shell window (always synchronously)
429 // If no command then just the shell
430 WXDLLIMPEXP_BASE bool wxShell(const wxString& command = wxEmptyString);
431
432 // As wxShell(), but must give a (non interactive) command and its output will
433 // be returned in output array
434 WXDLLIMPEXP_BASE bool wxShell(const wxString& command, wxArrayString& output);
435
436 // Sleep for nSecs seconds
437 WXDLLIMPEXP_BASE void wxSleep(int nSecs);
438
439 // Sleep for a given amount of milliseconds
440 WXDLLIMPEXP_BASE void wxMilliSleep(unsigned long milliseconds);
441
442 // Sleep for a given amount of microseconds
443 WXDLLIMPEXP_BASE void wxMicroSleep(unsigned long microseconds);
444
445 // Sleep for a given amount of milliseconds (old, bad name), use wxMilliSleep
446 wxDEPRECATED( WXDLLIMPEXP_BASE void wxUsleep(unsigned long milliseconds) );
447
448 // Get the process id of the current process
449 WXDLLIMPEXP_BASE unsigned long wxGetProcessId();
450
451 // Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX)
452 WXDLLIMPEXP_BASE wxMemorySize wxGetFreeMemory();
453
454 #if wxUSE_ON_FATAL_EXCEPTION
455
456 // should wxApp::OnFatalException() be called?
457 WXDLLIMPEXP_BASE bool wxHandleFatalExceptions(bool doit = true);
458
459 #endif // wxUSE_ON_FATAL_EXCEPTION
460
461 // flags for wxLaunchDefaultBrowser
462 enum
463 {
464 wxBROWSER_NEW_WINDOW = 1
465 };
466
467 // Launch url in the user's default internet browser
468 WXDLLIMPEXP_BASE bool wxLaunchDefaultBrowser(const wxString& url, int flags = 0);
469
470 // ----------------------------------------------------------------------------
471 // Environment variables
472 // ----------------------------------------------------------------------------
473
474 // returns true if variable exists (value may be NULL if you just want to check
475 // for this)
476 WXDLLIMPEXP_BASE bool wxGetEnv(const wxString& var, wxString *value);
477
478 // set the env var name to the given value, return true on success
479 WXDLLIMPEXP_BASE bool wxSetEnv(const wxString& var, const wxChar *value);
480
481 // remove the env var from environment
482 inline bool wxUnsetEnv(const wxString& var) { return wxSetEnv(var, NULL); }
483
484 // ----------------------------------------------------------------------------
485 // Network and username functions.
486 // ----------------------------------------------------------------------------
487
488 // NB: "char *" functions are deprecated, use wxString ones!
489
490 // Get eMail address
491 WXDLLIMPEXP_BASE bool wxGetEmailAddress(wxChar *buf, int maxSize);
492 WXDLLIMPEXP_BASE wxString wxGetEmailAddress();
493
494 // Get hostname.
495 WXDLLIMPEXP_BASE bool wxGetHostName(wxChar *buf, int maxSize);
496 WXDLLIMPEXP_BASE wxString wxGetHostName();
497
498 // Get FQDN
499 WXDLLIMPEXP_BASE wxString wxGetFullHostName();
500 WXDLLIMPEXP_BASE bool wxGetFullHostName(wxChar *buf, int maxSize);
501
502 // Get user ID e.g. jacs (this is known as login name under Unix)
503 WXDLLIMPEXP_BASE bool wxGetUserId(wxChar *buf, int maxSize);
504 WXDLLIMPEXP_BASE wxString wxGetUserId();
505
506 // Get user name e.g. Julian Smart
507 WXDLLIMPEXP_BASE bool wxGetUserName(wxChar *buf, int maxSize);
508 WXDLLIMPEXP_BASE wxString wxGetUserName();
509
510 // Get current Home dir and copy to dest (returns pstr->c_str())
511 WXDLLIMPEXP_BASE wxString wxGetHomeDir();
512 WXDLLIMPEXP_BASE const wxChar* wxGetHomeDir(wxString *pstr);
513
514 // Get the user's home dir (caller must copy --- volatile)
515 // returns NULL is no HOME dir is known
516 #if defined(__UNIX__) && wxUSE_UNICODE
517 WXDLLIMPEXP_BASE const wxMB2WXbuf wxGetUserHome(const wxString& user = wxEmptyString);
518 #else
519 WXDLLIMPEXP_BASE wxChar* wxGetUserHome(const wxString& user = wxEmptyString);
520 #endif
521
522 #if wxUSE_LONGLONG
523 typedef wxLongLong wxDiskspaceSize_t;
524 #else
525 typedef long wxDiskspaceSize_t;
526 #endif
527
528 // get number of total/free bytes on the disk where path belongs
529 WXDLLIMPEXP_BASE bool wxGetDiskSpace(const wxString& path,
530 wxDiskspaceSize_t *pTotal = NULL,
531 wxDiskspaceSize_t *pFree = NULL);
532
533 #if wxUSE_GUI // GUI only things from now on
534
535 // ----------------------------------------------------------------------------
536 // Menu accelerators related things
537 // ----------------------------------------------------------------------------
538
539 WXDLLEXPORT wxChar* wxStripMenuCodes(const wxChar *in, wxChar *out = (wxChar *) NULL);
540 WXDLLEXPORT wxString wxStripMenuCodes(const wxString& str);
541
542 #if wxUSE_ACCEL
543 class WXDLLEXPORT wxAcceleratorEntry;
544 WXDLLEXPORT wxAcceleratorEntry *wxGetAccelFromString(const wxString& label);
545 #endif // wxUSE_ACCEL
546
547 // ----------------------------------------------------------------------------
548 // Window search
549 // ----------------------------------------------------------------------------
550
551 // Returns menu item id or wxNOT_FOUND if none.
552 WXDLLEXPORT int wxFindMenuItemId(wxFrame *frame, const wxString& menuString, const wxString& itemString);
553
554 // Find the wxWindow at the given point. wxGenericFindWindowAtPoint
555 // is always present but may be less reliable than a native version.
556 WXDLLEXPORT wxWindow* wxGenericFindWindowAtPoint(const wxPoint& pt);
557 WXDLLEXPORT wxWindow* wxFindWindowAtPoint(const wxPoint& pt);
558
559 // NB: this function is obsolete, use wxWindow::FindWindowByLabel() instead
560 //
561 // Find the window/widget with the given title or label.
562 // Pass a parent to begin the search from, or NULL to look through
563 // all windows.
564 WXDLLEXPORT wxWindow* wxFindWindowByLabel(const wxString& title, wxWindow *parent = (wxWindow *) NULL);
565
566 // NB: this function is obsolete, use wxWindow::FindWindowByName() instead
567 //
568 // Find window by name, and if that fails, by label.
569 WXDLLEXPORT wxWindow* wxFindWindowByName(const wxString& name, wxWindow *parent = (wxWindow *) NULL);
570
571 // ----------------------------------------------------------------------------
572 // Message/event queue helpers
573 // ----------------------------------------------------------------------------
574
575 // Yield to other apps/messages and disable user input
576 WXDLLEXPORT bool wxSafeYield(wxWindow *win = NULL, bool onlyIfNeeded = false);
577
578 // Enable or disable input to all top level windows
579 WXDLLEXPORT void wxEnableTopLevelWindows(bool enable = true);
580
581 // Check whether this window wants to process messages, e.g. Stop button
582 // in long calculations.
583 WXDLLEXPORT bool wxCheckForInterrupt(wxWindow *wnd);
584
585 // Consume all events until no more left
586 WXDLLEXPORT void wxFlushEvents();
587
588 // a class which disables all windows (except, may be, thegiven one) in its
589 // ctor and enables them back in its dtor
590 class WXDLLEXPORT wxWindowDisabler
591 {
592 public:
593 wxWindowDisabler(wxWindow *winToSkip = (wxWindow *)NULL);
594 ~wxWindowDisabler();
595
596 private:
597 wxWindowList *m_winDisabled;
598
599 DECLARE_NO_COPY_CLASS(wxWindowDisabler)
600 };
601
602 // ----------------------------------------------------------------------------
603 // Cursors
604 // ----------------------------------------------------------------------------
605
606 // Set the cursor to the busy cursor for all windows
607 class WXDLLEXPORT wxCursor;
608 extern WXDLLEXPORT_DATA(wxCursor*) wxHOURGLASS_CURSOR;
609 WXDLLEXPORT void wxBeginBusyCursor(wxCursor *cursor = wxHOURGLASS_CURSOR);
610
611 // Restore cursor to normal
612 WXDLLEXPORT void wxEndBusyCursor();
613
614 // true if we're between the above two calls
615 WXDLLEXPORT bool wxIsBusy();
616
617 // Convenience class so we can just create a wxBusyCursor object on the stack
618 class WXDLLEXPORT wxBusyCursor
619 {
620 public:
621 wxBusyCursor(wxCursor* cursor = wxHOURGLASS_CURSOR)
622 { wxBeginBusyCursor(cursor); }
623 ~wxBusyCursor()
624 { wxEndBusyCursor(); }
625
626 // FIXME: These two methods are currently only implemented (and needed?)
627 // in wxGTK. BusyCursor handling should probably be moved to
628 // common code since the wxGTK and wxMSW implementations are very
629 // similar except for wxMSW using HCURSOR directly instead of
630 // wxCursor.. -- RL.
631 static const wxCursor &GetStoredCursor();
632 static const wxCursor GetBusyCursor();
633 };
634
635
636 // ----------------------------------------------------------------------------
637 // Reading and writing resources (eg WIN.INI, .Xdefaults)
638 // ----------------------------------------------------------------------------
639
640 #if wxUSE_RESOURCES
641 WXDLLEXPORT bool wxWriteResource(const wxString& section, const wxString& entry, const wxString& value, const wxString& file = wxEmptyString);
642 WXDLLEXPORT bool wxWriteResource(const wxString& section, const wxString& entry, float value, const wxString& file = wxEmptyString);
643 WXDLLEXPORT bool wxWriteResource(const wxString& section, const wxString& entry, long value, const wxString& file = wxEmptyString);
644 WXDLLEXPORT bool wxWriteResource(const wxString& section, const wxString& entry, int value, const wxString& file = wxEmptyString);
645
646 WXDLLEXPORT bool wxGetResource(const wxString& section, const wxString& entry, wxChar **value, const wxString& file = wxEmptyString);
647 WXDLLEXPORT bool wxGetResource(const wxString& section, const wxString& entry, float *value, const wxString& file = wxEmptyString);
648 WXDLLEXPORT bool wxGetResource(const wxString& section, const wxString& entry, long *value, const wxString& file = wxEmptyString);
649 WXDLLEXPORT bool wxGetResource(const wxString& section, const wxString& entry, int *value, const wxString& file = wxEmptyString);
650 #endif // wxUSE_RESOURCES
651
652 void WXDLLEXPORT wxGetMousePosition( int* x, int* y );
653
654 // MSW only: get user-defined resource from the .res file.
655 // Returns NULL or newly-allocated memory, so use delete[] to clean up.
656 #ifdef __WXMSW__
657 extern WXDLLEXPORT const wxChar* wxUserResourceStr;
658 WXDLLEXPORT wxChar* wxLoadUserResource(const wxString& resourceName, const wxString& resourceType = wxUserResourceStr);
659 #endif // MSW
660
661 // ----------------------------------------------------------------------------
662 // Display and colorss (X only)
663 // ----------------------------------------------------------------------------
664
665 #ifdef __WXGTK__
666 void *wxGetDisplay();
667 #endif
668
669 #ifdef __X__
670 WXDLLIMPEXP_CORE WXDisplay *wxGetDisplay();
671 WXDLLIMPEXP_CORE bool wxSetDisplay(const wxString& display_name);
672 WXDLLIMPEXP_CORE wxString wxGetDisplayName();
673 #endif // X or GTK+
674
675 #ifdef __X__
676
677 #ifdef __VMS__ // Xlib.h for VMS is not (yet) compatible with C++
678 // The resulting warnings are switched off here
679 #pragma message disable nosimpint
680 #endif
681 // #include <X11/Xlib.h>
682 #ifdef __VMS__
683 #pragma message enable nosimpint
684 #endif
685
686 #endif //__X__
687
688 #endif // wxUSE_GUI
689
690 // ----------------------------------------------------------------------------
691 // wxYield(): these functions are obsolete, please use wxApp methods instead!
692 // ----------------------------------------------------------------------------
693
694 // Yield to other apps/messages
695 WXDLLIMPEXP_BASE bool wxYield();
696
697 // Like wxYield, but fails silently if the yield is recursive.
698 WXDLLIMPEXP_BASE bool wxYieldIfNeeded();
699
700 // ----------------------------------------------------------------------------
701 // Error message functions used by wxWidgets (deprecated, use wxLog)
702 // ----------------------------------------------------------------------------
703
704 #endif
705 // _WX_UTILSH__