]> git.saurik.com Git - wxWidgets.git/blame - interface/utils.h
@wxsince -> @since in Doxygen docs
[wxWidgets.git] / interface / utils.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: utils.h
e54c96f1 3// Purpose: interface of wxWindowDisabler
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
6// Licence: wxWindows license
7/////////////////////////////////////////////////////////////////////////////
8
9/**
10 @class wxWindowDisabler
11 @wxheader{utils.h}
7c913512 12
23324ae1
FM
13 This class disables all windows of the application (may be with the exception
14 of one of them) in its constructor and enables them back in its destructor.
2ecd1756
VZ
15
16 This is useful when you want to indicate to the user that the application
23324ae1 17 is currently busy and cannot respond to user input.
7c913512 18
23324ae1
FM
19 @library{wxcore}
20 @category{FIXME}
7c913512 21
e54c96f1 22 @see wxBusyCursor
23324ae1 23*/
7c913512 24class wxWindowDisabler
23324ae1
FM
25{
26public:
2ecd1756
VZ
27 /**
28 Disables all top level windows of the applications.
29
30 If @a disable is @c false nothing is done. This can be convenient if
31 the windows should be disabled depending on some condition.
32
33 @since 2.9.0
34 */
35 wxWindowDisabler(bool disable = true);
36
23324ae1 37 /**
7c913512 38 Disables all top level windows of the applications with the exception of
4cc4bfaf 39 @a winToSkip if it is not @NULL.
23324ae1 40 */
2ecd1756 41 wxWindowDisabler(wxWindow* winToSkip);
23324ae1
FM
42
43 /**
44 Reenables back the windows disabled by the constructor.
45 */
46 ~wxWindowDisabler();
47};
48
49
e54c96f1 50
23324ae1
FM
51/**
52 @class wxBusyCursor
53 @wxheader{utils.h}
7c913512 54
23324ae1
FM
55 This class makes it easy to tell your user that the program is temporarily busy.
56 Just create a wxBusyCursor object on the stack, and within the current scope,
57 the hourglass will be shown.
7c913512 58
23324ae1 59 For example:
7c913512 60
23324ae1
FM
61 @code
62 wxBusyCursor wait;
7c913512 63
23324ae1
FM
64 for (int i = 0; i 100000; i++)
65 DoACalculation();
66 @endcode
7c913512 67
e54c96f1
FM
68 It works by calling wxBeginBusyCursor() in the constructor,
69 and wxEndBusyCursor() in the destructor.
7c913512 70
23324ae1
FM
71 @library{wxcore}
72 @category{FIXME}
7c913512 73
e54c96f1 74 @see wxBeginBusyCursor(), wxEndBusyCursor(), wxWindowDisabler
23324ae1 75*/
7c913512 76class wxBusyCursor
23324ae1
FM
77{
78public:
79 /**
e54c96f1 80 Constructs a busy cursor object, calling wxBeginBusyCursor().
23324ae1
FM
81 */
82 wxBusyCursor(wxCursor* cursor = wxHOURGLASS_CURSOR);
83
84 /**
e54c96f1 85 Destroys the busy cursor object, calling wxEndBusyCursor().
23324ae1
FM
86 */
87 ~wxBusyCursor();
88};
89
90
6e351537
VZ
91/**
92 @class wxMouseState
93 @wxheader{utils.h}
94
95 Represents the mouse state.
96
97 The methods of this class generally mirror the corresponding methods of
98 wxMouseEvent.
99
100 @see wxGetMouseState()
101 */
102class wxMouseState
103{
104public:
105 /// Returns X coordinate of the physical mouse event position.
106 wxCoord GetX() const;
6e351537
VZ
107 /// Returns Y coordinate of the physical mouse event position.
108 wxCoord GetY() const;
e38ce1bc
VZ
109 /// Returns the physical mouse position.
110 wxPoint GetPosition() const;
6e351537
VZ
111
112 /// Returns @true if the left mouse button changed to down.
113 bool LeftDown() const;
114 /// Returns @true if the middle mouse button changed to down.
115 bool MiddleDown() const;
116 /// Returns @true if the right mouse button changed to down.
117 bool RightDown() const;
118 /// Returns @true if the first extra button mouse button changed to down.
119 bool Aux1Down() const;
120 /// Returns @true if the second extra button mouse button changed to down.
121 bool Aux2Down() const;
122
123 /// Returns @true if the control key is down.
124 bool ControlDown() const;
125 /// Returns @true if the shift key is down.
126 bool ShiftDown() const;
127 /// Returns @true if the alt key is down.
128 bool AltDown() const;
129 /// Returns @true if the meta key is down.
130 bool MetaDown() const;
131 /// Same as MetaDown() under Mac systems, ControlDown() for the others.
132 bool CmdDown() const;
133};
134
e54c96f1 135
23324ae1
FM
136// ============================================================================
137// Global functions/macros
138// ============================================================================
139
ba2874ff
BP
140
141/** @ingroup group_funcmacro_dialog */
142//@{
143
144/**
145 Changes the cursor to the given cursor for all windows in the application.
146 Use wxEndBusyCursor() to revert the cursor back to its previous state.
147 These two calls can be nested, and a counter ensures that only the outer
148 calls take effect.
149
150 @see wxIsBusy(), wxBusyCursor
151
152 @header{wx/utils.h}
153*/
154void wxBeginBusyCursor(wxCursor* cursor = wxHOURGLASS_CURSOR);
155
156/**
157 Changes the cursor back to the original cursor, for all windows in the
158 application. Use with wxBeginBusyCursor().
159
160 @see wxIsBusy(), wxBusyCursor
161
162 @header{wx/utils.h}
163*/
164void wxEndBusyCursor();
165
166/**
167 Returns @true if between two wxBeginBusyCursor() and wxEndBusyCursor()
168 calls.
169
170 @see wxBusyCursor.
171
172 @header{wx/utils.h}
173*/
174bool wxIsBusy();
175
176/**
177 Ring the system bell.
178
179 @note This function is categorized as a GUI one and so is not thread-safe.
180
181 @header{wx/utils.h}
182*/
183void wxBell();
184
185/**
186 Shows a message box with the information about the wxWidgets build used,
187 including its version, most important build parameters and the version of
188 the underlying GUI toolkit. This is mainly used for diagnostic purposes
189 and can be invoked by Ctrl-Alt-middle clicking on any wxWindow which
190 doesn't otherwise handle this event.
191
1e24c2af 192 @since 2.9.0
ba2874ff
BP
193
194 @header{wx/utils.h}
195*/
196void wxInfoMessageBox(wxWindow parent = NULL);
197
198//@}
199
200
201
1ba0de2e
BP
202/** @ingroup group_funcmacro_env */
203//@{
204
205/**
206 This is a macro defined as @c getenv() or its wide char version in Unicode
207 mode.
208
209 Note that under Win32 it may not return correct value for the variables set
210 with wxSetEnv(), use wxGetEnv() function instead.
211
212 @header{wx/utils.h}
213*/
214wxChar* wxGetenv(const wxString& var);
215
216/**
217 Returns the current value of the environment variable @c var in @c value.
218 @c value may be @NULL if you just want to know if the variable exists and
219 are not interested in its value.
220
221 Returns @true if the variable exists, @false otherwise.
222
223 @header{wx/utils.h}
224*/
225bool wxGetEnv(const wxString& var, wxString* value);
226
227/**
228 Sets the value of the environment variable @c var (adding it if necessary)
229 to @c value.
230
231 Returns @true on success.
232
233 @see wxUnsetEnv()
234
235 @header{wx/utils.h}
236*/
237bool wxSetEnv(const wxString& var, const wxString& value);
238
239/**
240 Removes the variable @c var from the environment. wxGetEnv() will return
241 @NULL after the call to this function.
242
243 Returns @true on success.
244
245 @header{wx/utils.h}
246*/
247bool wxUnsetEnv(const wxString& var);
248
249//@}
250
251
252
7fa7088e
BP
253/** @ingroup group_funcmacro_misc */
254//@{
255
23324ae1 256/**
7fa7088e
BP
257 Returns battery state as one of @c wxBATTERY_NORMAL_STATE,
258 @c wxBATTERY_LOW_STATE, @c wxBATTERY_CRITICAL_STATE,
259 @c wxBATTERY_SHUTDOWN_STATE or @c wxBATTERY_UNKNOWN_STATE.
260 @c wxBATTERY_UNKNOWN_STATE is also the default on platforms where this
23324ae1 261 feature is not implemented (currently everywhere but MS Windows).
ba2874ff
BP
262
263 @header{wx/utils.h}
23324ae1 264*/
7fa7088e 265wxBatteryState wxGetBatteryState();
23324ae1 266
23324ae1 267/**
7fa7088e
BP
268 Returns the type of power source as one of @c wxPOWER_SOCKET,
269 @c wxPOWER_BATTERY or @c wxPOWER_UNKNOWN. @c wxPOWER_UNKNOWN is also the
270 default on platforms where this feature is not implemented (currently
271 everywhere but MS Windows).
ba2874ff
BP
272
273 @header{wx/utils.h}
23324ae1 274*/
7fa7088e 275wxPowerType wxGetPowerType();
ce323d38
VS
276
277/**
7fa7088e 278 Under X only, returns the current display name.
ce323d38 279
7fa7088e 280 @see wxSetDisplayName()
ce323d38 281
7fa7088e
BP
282 @header{wx/utils.h}
283*/
284wxString wxGetDisplayName();
23324ae1 285
23324ae1 286/**
7fa7088e
BP
287 For normal keys, returns @true if the specified key is currently down.
288
289 For togglable keys (Caps Lock, Num Lock and Scroll Lock), returns @true if
290 the key is toggled such that its LED indicator is lit. There is currently
291 no way to test whether togglable keys are up or down.
292
293 Even though there are virtual key codes defined for mouse buttons, they
294 cannot be used with this function currently.
ba2874ff
BP
295
296 @header{wx/utils.h}
23324ae1 297*/
7fa7088e 298bool wxGetKeyState(wxKeyCode key);
23324ae1
FM
299
300/**
7fa7088e 301 Returns the mouse position in screen coordinates.
ba2874ff
BP
302
303 @header{wx/utils.h}
23324ae1 304*/
7fa7088e 305wxPoint wxGetMousePosition();
23324ae1 306
23324ae1 307/**
7fa7088e
BP
308 Returns the current state of the mouse. Returns a wxMouseState instance
309 that contains the current position of the mouse pointer in screen
310 coordinates, as well as boolean values indicating the up/down status of the
311 mouse buttons and the modifier keys.
ba2874ff
BP
312
313 @header{wx/utils.h}
23324ae1 314*/
7fa7088e 315wxMouseState wxGetMouseState();
23324ae1
FM
316
317/**
7fa7088e
BP
318 This function enables or disables all top level windows. It is used by
319 wxSafeYield().
ba2874ff
BP
320
321 @header{wx/utils.h}
23324ae1 322*/
7fa7088e 323void wxEnableTopLevelWindows(bool enable = true);
23324ae1 324
23324ae1 325/**
7fa7088e
BP
326 Find the deepest window at the given mouse position in screen coordinates,
327 returning the window if found, or @NULL if not.
ba2874ff
BP
328
329 @header{wx/utils.h}
23324ae1 330*/
7fa7088e 331wxWindow* wxFindWindowAtPoint(const wxPoint& pt);
23324ae1
FM
332
333/**
7fa7088e 334 @deprecated Replaced by wxWindow::FindWindowByLabel().
7c913512 335
7fa7088e
BP
336 Find a window by its label. Depending on the type of window, the label may
337 be a window title or panel item label. If @a parent is @NULL, the search
338 will start from all top-level frames and dialog boxes; if non-@NULL, the
339 search will be limited to the given window hierarchy. The search is
340 recursive in both cases.
ba2874ff
BP
341
342 @header{wx/utils.h}
23324ae1 343*/
7fa7088e
BP
344wxWindow* wxFindWindowByLabel(const wxString& label,
345 wxWindow* parent = NULL);
23324ae1
FM
346
347/**
7fa7088e 348 @deprecated Replaced by wxWindow::FindWindowByName().
7c913512 349
7fa7088e
BP
350 Find a window by its name (as given in a window constructor or @e Create
351 function call). If @a parent is @NULL, the search will start from all
352 top-level frames and dialog boxes; if non-@NULL, the search will be limited
353 to the given window hierarchy. The search is recursive in both cases.
354
355 If no such named window is found, wxFindWindowByLabel() is called.
ba2874ff
BP
356
357 @header{wx/utils.h}
23324ae1 358*/
7fa7088e 359wxWindow* wxFindWindowByName(const wxString& name, wxWindow* parent = NULL);
23324ae1
FM
360
361/**
7fa7088e 362 Find a menu item identifier associated with the given frame's menu bar.
ba2874ff
BP
363
364 @header{wx/utils.h}
23324ae1 365*/
7fa7088e
BP
366int wxFindMenuItemId(wxFrame* frame, const wxString& menuString,
367 const wxString& itemString);
23324ae1
FM
368
369/**
7fa7088e
BP
370 @deprecated Ids generated by it can conflict with the Ids defined by the
371 user code, use @c wxID_ANY to assign ids which are guaranteed
372 to not conflict with the user-defined ids for the controls and
373 menu items you create instead of using this function.
374
375 Generates an integer identifier unique to this run of the program.
ba2874ff
BP
376
377 @header{wx/utils.h}
23324ae1 378*/
7fa7088e 379long wxNewId();
23324ae1 380
7fa7088e
BP
381/**
382 Ensures that Ids subsequently generated by wxNewId() do not clash with the
383 given @a id.
384
385 @header{wx/utils.h}
386*/
387void wxRegisterId(long id);
23324ae1 388
39fb8056 389/**
7fa7088e
BP
390 Opens the @a url in user's default browser. If the @a flags parameter
391 contains @c wxBROWSER_NEW_WINDOW flag, a new window is opened for the URL
392 (currently this is only supported under Windows). The @a url may also be a
393 local file path (with or without the "file://" prefix), if it doesn't
394 correspond to an existing file and the URL has no scheme "http://" is
395 prepended to it by default.
396
397 Returns @true if the application was successfully launched.
398
399 @note For some configurations of the running user, the application which is
400 launched to open the given URL may be URL-dependent (e.g. a browser
401 may be used for local URLs while another one may be used for remote
402 URLs).
ba2874ff
BP
403
404 @header{wx/utils.h}
39fb8056 405*/
7fa7088e 406bool wxLaunchDefaultBrowser(const wxString& url, int flags = 0);
39fb8056
FM
407
408/**
7fa7088e
BP
409 Loads a user-defined Windows resource as a string. If the resource is
410 found, the function creates a new character array and copies the data into
411 it. A pointer to this data is returned. If unsuccessful, @NULL is returned.
412
413 The resource must be defined in the @c .rc file using the following syntax:
414
415 @code
416 myResource TEXT file.ext
417 @endcode
418
419 Where @c file.ext is a file that the resource compiler can find.
420
421 This function is available under Windows only.
ba2874ff
BP
422
423 @header{wx/utils.h}
39fb8056 424*/
7fa7088e
BP
425wxString wxLoadUserResource(const wxString& resourceName,
426 const wxString& resourceType = "TEXT");
39fb8056
FM
427
428/**
7fa7088e
BP
429 @deprecated Replaced by wxWindow::Close(). See the
430 @ref overview_windowdeletion "window deletion overview".
431
432 Tells the system to delete the specified object when all other events have
433 been processed. In some environments, it is necessary to use this instead
434 of deleting a frame directly with the delete operator, because some GUIs
435 will still send events to a deleted window.
ba2874ff
BP
436
437 @header{wx/utils.h}
39fb8056 438*/
7fa7088e 439void wxPostDelete(wxObject* object);
39fb8056 440
39fb8056 441/**
7fa7088e
BP
442 Under X only, sets the current display name. This is the X host and display
443 name such as "colonsay:0.0", and the function indicates which display
444 should be used for creating windows from this point on. Setting the display
445 within an application allows multiple displays to be used.
446
447 @see wxGetDisplayName()
ba2874ff
BP
448
449 @header{wx/utils.h}
39fb8056 450*/
7fa7088e 451void wxSetDisplayName(const wxString& displayName);
39fb8056
FM
452
453/**
7fa7088e
BP
454 Strips any menu codes from @a str and returns the result.
455
456 By default, the functions strips both the mnemonics character (@c '&')
457 which is used to indicate a keyboard shortkey, and the accelerators, which
458 are used only in the menu items and are separated from the main text by the
459 @c \t (TAB) character. By using @a flags of @c wxStrip_Mnemonics or
460 @c wxStrip_Accel to strip only the former or the latter part, respectively.
461
462 Notice that in most cases wxMenuItem::GetLabelFromText() or
463 wxControl::GetLabelText() can be used instead.
ba2874ff
BP
464
465 @header{wx/utils.h}
39fb8056 466*/
7fa7088e
BP
467wxString wxStripMenuCodes(const wxString& str, int flags = wxStrip_All);
468
469//@}
470
471
472
3950d49c
BP
473/** @ingroup group_funcmacro_networkuseros */
474//@{
7fa7088e 475
3950d49c
BP
476/**
477 Copies the user's email address into the supplied buffer, by concatenating
478 the values returned by wxGetFullHostName() and wxGetUserId().
7fa7088e 479
3950d49c
BP
480 @returns @true if successful, @false otherwise.
481
482 @header{wx/utils.h}
483*/
484wxString wxGetEmailAddress();
39fb8056
FM
485
486/**
3950d49c 487 @deprecated Use wxGetEmailAddress() instead.
39fb8056 488
3950d49c
BP
489 @param buf Buffer to store the email address in.
490 @param sz Size of the buffer.
7fa7088e 491
3950d49c 492 @returns @true if successful, @false otherwise.
ba2874ff
BP
493
494 @header{wx/utils.h}
39fb8056 495*/
3950d49c
BP
496bool wxGetEmailAddress(char* buf, int sz);
497
498/**
499 Returns the amount of free memory in bytes under environments which support
500 it, and -1 if not supported or failed to perform measurement.
501
502 @header{wx/utils.h}
503*/
504wxMemorySize wxGetFreeMemory();
505
506/**
507 Return the (current) user's home directory.
508
509 @see wxGetUserHome(), wxStandardPaths
510
511 @header{wx/utils.h}
512*/
513wxString wxGetHomeDir();
514
515/**
516 Copies the current host machine's name into the supplied buffer. Please
517 note that the returned name is @e not fully qualified, i.e. it does not
518 include the domain name.
519
520 Under Windows or NT, this function first looks in the environment variable
521 SYSTEM_NAME; if this is not found, the entry @b HostName in the wxWidgets
522 section of the WIN.INI file is tried.
523
524 @returns The hostname if successful or an empty string otherwise.
525
526 @see wxGetFullHostName()
527
528 @header{wx/utils.h}
529*/
530wxString wxGetHostName();
39fb8056
FM
531
532/**
3950d49c 533 @deprecated Use wxGetHostName() instead.
39fb8056 534
3950d49c 535 @param buf Buffer to store the host name in.
7fa7088e
BP
536 @param sz Size of the buffer.
537
3950d49c
BP
538 @returns @true if successful, @false otherwise.
539
540 @header{wx/utils.h}
541*/
542bool wxGetHostName(char* buf, int sz);
7fa7088e
BP
543
544/**
3950d49c
BP
545 Returns the FQDN (fully qualified domain host name) or an empty string on
546 error.
7fa7088e 547
3950d49c 548 @see wxGetHostName()
39fb8056 549
ba2874ff 550 @header{wx/utils.h}
39fb8056 551*/
3950d49c 552wxString wxGetFullHostName();
39fb8056
FM
553
554/**
3950d49c
BP
555 Returns the home directory for the given user. If the @a user is empty
556 (default value), this function behaves like wxGetHomeDir() (i.e. returns
557 the current user home directory).
7fa7088e 558
3950d49c 559 If the home directory couldn't be determined, an empty string is returned.
ba2874ff
BP
560
561 @header{wx/utils.h}
39fb8056 562*/
3950d49c 563wxString wxGetUserHome(const wxString& user = "");
39fb8056
FM
564
565/**
3950d49c
BP
566 This function returns the "user id" also known as "login name" under Unix
567 (i.e. something like "jsmith"). It uniquely identifies the current user (on
568 this system). Under Windows or NT, this function first looks in the
569 environment variables USER and LOGNAME; if neither of these is found, the
570 entry @b UserId in the @b wxWidgets section of the WIN.INI file is tried.
571
572 @returns The login name if successful or an empty string otherwise.
573
574 @see wxGetUserName()
ba2874ff
BP
575
576 @header{wx/utils.h}
39fb8056 577*/
3950d49c 578wxString wxGetUserId();
39fb8056 579
7fa7088e 580/**
3950d49c
BP
581 @deprecated Use wxGetUserId() instead.
582
583 @param buf Buffer to store the login name in.
584 @param sz Size of the buffer.
585
586 @returns @true if successful, @false otherwise.
7fa7088e
BP
587
588 @header{wx/utils.h}
589*/
3950d49c 590bool wxGetUserId(char* buf, int sz);
39fb8056
FM
591
592/**
3950d49c
BP
593 This function returns the full user name (something like "Mr. John Smith").
594
595 Under Windows or NT, this function looks for the entry UserName in the
596 wxWidgets section of the WIN.INI file. If PenWindows is running, the entry
597 Current in the section User of the PENWIN.INI file is used.
598
599 @returns The full user name if successful or an empty string otherwise.
600
601 @see wxGetUserId()
ba2874ff
BP
602
603 @header{wx/utils.h}
39fb8056 604*/
3950d49c 605wxString wxGetUserName();
39fb8056
FM
606
607/**
3950d49c
BP
608 @deprecated Use wxGetUserName() instead.
609
610 @param buf Buffer to store the full user name in.
611 @param sz Size of the buffer.
39fb8056 612
3950d49c 613 @returns @true if successful, @false otherwise.
39fb8056 614
7fa7088e
BP
615 @header{wx/utils.h}
616*/
3950d49c 617bool wxGetUserName(char* buf, int sz);
7fa7088e
BP
618
619/**
3950d49c
BP
620 Returns the string containing the description of the current platform in a
621 user-readable form. For example, this function may return strings like
622 "Windows NT Version 4.0" or "Linux 2.2.2 i386".
7fa7088e 623
3950d49c 624 @see wxGetOsVersion()
ba2874ff
BP
625
626 @header{wx/utils.h}
39fb8056 627*/
3950d49c 628wxString wxGetOsDescription();
39fb8056
FM
629
630/**
3950d49c
BP
631 Gets the version and the operating system ID for currently running OS. See
632 wxPlatformInfo for more details about wxOperatingSystemId.
633
634 @see wxGetOsDescription(), wxPlatformInfo
635
636 @header{wx/utils.h}
39fb8056 637*/
3950d49c 638wxOperatingSystemId wxGetOsVersion(int* major = NULL, int* minor = NULL);
39fb8056 639
39fb8056 640/**
3950d49c
BP
641 Returns @true if the operating system the program is running under is 64
642 bit. The check is performed at run-time and may differ from the value
643 available at compile-time (at compile-time you can just check if
644 <tt>sizeof(void*) == 8</tt>) since the program could be running in
645 emulation mode or in a mixed 32/64 bit system (bi-architecture operating
646 system).
39fb8056 647
3950d49c
BP
648 @note This function is not 100% reliable on some systems given the fact
649 that there isn't always a standard way to do a reliable check on the
650 OS architecture.
ba2874ff
BP
651
652 @header{wx/utils.h}
39fb8056 653*/
3950d49c 654bool wxIsPlatform64Bit();
23324ae1 655
39fb8056 656/**
3950d49c
BP
657 Returns @true if the current platform is little endian (instead of big
658 endian). The check is performed at run-time.
659
660 @see @ref group_funcmacro_byteorder "Byte Order Functions and Macros"
ba2874ff
BP
661
662 @header{wx/utils.h}
39fb8056 663*/
3950d49c 664bool wxIsPlatformLittleEndian();
23324ae1 665
3950d49c
BP
666//@}
667
668
669
670/** @ingroup group_funcmacro_procctrl */
23324ae1 671//@{
3950d49c 672
39fb8056 673/**
39fb8056 674 Executes another program in Unix or Windows.
3950d49c
BP
675
676 In the overloaded versions of this function, if @a flags parameter contains
677 @c wxEXEC_ASYNC flag (the default), flow of control immediately returns. If
678 it contains @c wxEXEC_SYNC, the current application waits until the other
679 program has terminated.
680
39fb8056 681 In the case of synchronous execution, the return value is the exit code of
3950d49c
BP
682 the process (which terminates by the moment the function returns) and will
683 be -1 if the process couldn't be started and typically 0 if the process
684 terminated successfully. Also, while waiting for the process to terminate,
685 wxExecute() will call wxYield(). Because of this, by default this function
686 disables all application windows to avoid unexpected reentrancies which
687 could result from the users interaction with the program while the child
688 process is running. If you are sure that it is safe to not disable the
689 program windows, you may pass @c wxEXEC_NODISABLE flag to prevent this
690 automatic disabling from happening.
691
39fb8056
FM
692 For asynchronous execution, however, the return value is the process id and
693 zero value indicates that the command could not be executed. As an added
694 complication, the return value of -1 in this case indicates that we didn't
3950d49c
BP
695 launch a new process, but connected to the running one (this can only
696 happen when using DDE under Windows for command execution). In particular,
697 in this case only, the calling code will not get the notification about
39fb8056 698 process termination.
3950d49c
BP
699
700 If @a callback isn't @NULL and if execution is asynchronous,
701 wxProcess::OnTerminate() will be called when the process finishes.
702 Specifying this parameter also allows you to redirect the standard input
703 and/or output of the process being launched by calling
704 wxProcess::Redirect(). If the child process IO is redirected, under Windows
705 the process window is not shown by default (this avoids having to flush an
706 unnecessary console for the processes which don't create any windows
39fb8056 707 anyhow) but a @c wxEXEC_NOHIDE flag can be used to prevent this from
3950d49c
BP
708 happening, i.e. with this flag the child process window will be shown
709 normally.
710
711 Under Unix the flag @c wxEXEC_MAKE_GROUP_LEADER may be used to ensure that
712 the new process is a group leader (this will create a new session if
713 needed). Calling wxKill() passing wxKILL_CHILDREN will kill this process as
714 well as all of its children (except those which have started their own
715 session).
716
39fb8056
FM
717 The @c wxEXEC_NOEVENTS flag prevents processing of any events from taking
718 place while the child process is running. It should be only used for very
719 short-lived processes as otherwise the application windows risk becoming
3950d49c
BP
720 unresponsive from the users point of view. As this flag only makes sense
721 with @c wxEXEC_SYNC, @c wxEXEC_BLOCK equal to the sum of both of these
722 flags is provided as a convenience.
723
724 @note Currently wxExecute() can only be used from the main thread, calling
725 this function from another thread will result in an assert failure in
726 debug build and won't work.
39fb8056
FM
727
728 @param command
3950d49c
BP
729 The command to execute and any parameters to pass to it as a single
730 string, i.e. "emacs file.txt".
731 @param flags
732 Must include either wxEXEC_ASYNC or wxEXEC_SYNC and can also include
733 wxEXEC_NOHIDE, wxEXEC_MAKE_GROUP_LEADER (in either case) or
734 wxEXEC_NODISABLE and wxEXEC_NOEVENTS or wxEXEC_BLOCK, which is equal to
735 their combination, in wxEXEC_SYNC case.
736 @param callback
737 An optional pointer to wxProcess.
738
739 @see wxShell(), wxProcess, @ref page_samples_exec
740
741 @header{wx/utils.h}
742
743 @beginWxPerlOnly
744 This function is called @c Wx::ExecuteStdoutStderr and it only takes the
745 @a command argument, and returns a 3-element list (@c status, @c output,
746 @c errors), where @c output and @c errors are array references.
747 @endWxPerlOnly
748*/
749long wxExecute(const wxString& command, int flags = wxEXEC_ASYNC,
750 wxProcess* callback = NULL);
751
752//@}
753
754/** @ingroup group_funcmacro_procctrl */
755//@{
756/**
757 This is an overloaded version of wxExecute(const wxString&,int,wxProcess*),
758 please see its documentation for general information.
759
760 This version takes an array of values: a command, any number of arguments,
761 terminated by @NULL.
762
39fb8056 763 @param argv
3950d49c
BP
764 The command to execute should be the first element of this array, any
765 additional ones are the command parameters and the array must be
39fb8056
FM
766 terminated with a @NULL pointer.
767 @param flags
05718a98
VZ
768 Must include either wxEXEC_ASYNC or wxEXEC_SYNC and can also include
769 wxEXEC_NOHIDE, wxEXEC_MAKE_GROUP_LEADER (in either case) or
770 wxEXEC_NODISABLE and wxEXEC_NOEVENTS or wxEXEC_BLOCK, which is equal to
771 their combination, in wxEXEC_SYNC case.
39fb8056 772 @param callback
3950d49c
BP
773 An optional pointer to wxProcess.
774
775 @header{wx/utils.h}
776*/
777long wxExecute(char** argv, int flags = wxEXEC_ASYNC,
778 wxProcess* callback = NULL);
779long wxExecute(wchar_t** argv, int flags = wxEXEC_ASYNC,
780 wxProcess* callback = NULL);
23324ae1
FM
781//@}
782
3950d49c
BP
783/** @ingroup group_funcmacro_procctrl */
784//@{
785
39fb8056 786/**
3950d49c
BP
787 This is an overloaded version of wxExecute(const wxString&,int,wxProcess*),
788 please see its documentation for general information.
789
790 This version can be used to execute a process (always synchronously, the
791 contents of @a flags is or'd with @c wxEXEC_SYNC) and capture its output in
792 the array @e output.
793
794 @param command
795 The command to execute and any parameters to pass to it as a single
796 string.
797 @param flags
798 Must include either wxEXEC_ASYNC or wxEXEC_SYNC and can also include
799 wxEXEC_NOHIDE, wxEXEC_MAKE_GROUP_LEADER (in either case) or
800 wxEXEC_NODISABLE and wxEXEC_NOEVENTS or wxEXEC_BLOCK, which is equal to
801 their combination, in wxEXEC_SYNC case.
ba2874ff
BP
802
803 @header{wx/utils.h}
39fb8056 804*/
3950d49c
BP
805long wxExecute(const wxString& command, wxArrayString& output,
806 int flags = 0);
39fb8056
FM
807
808/**
3950d49c
BP
809 This is an overloaded version of wxExecute(const wxString&,int,wxProcess*),
810 please see its documentation for general information.
811
812 This version adds the possibility to additionally capture the messages from
813 standard error output in the @a errors array.
814
815 @param command
816 The command to execute and any parameters to pass to it as a single
817 string.
818 @param flags
819 Must include either wxEXEC_ASYNC or wxEXEC_SYNC and can also include
820 wxEXEC_NOHIDE, wxEXEC_MAKE_GROUP_LEADER (in either case) or
821 wxEXEC_NODISABLE and wxEXEC_NOEVENTS or wxEXEC_BLOCK, which is equal to
822 their combination, in wxEXEC_SYNC case.
ba2874ff
BP
823
824 @header{wx/utils.h}
39fb8056 825*/
3950d49c
BP
826long wxExecute(const wxString& command, wxArrayString& output,
827 wxArrayString& errors, int flags = 0);
39fb8056
FM
828
829/**
830 Returns the number uniquely identifying the current process in the system.
831 If an error occurs, 0 is returned.
ba2874ff
BP
832
833 @header{wx/utils.h}
39fb8056
FM
834*/
835unsigned long wxGetProcessId();
836
837/**
838 Equivalent to the Unix kill function: send the given signal @a sig to the
3950d49c 839 process with PID @a pid. The valid signal values are:
39fb8056
FM
840
841 @code
842 enum wxSignal
843 {
3950d49c 844 wxSIGNONE = 0, // verify if the process exists under Unix
39fb8056
FM
845 wxSIGHUP,
846 wxSIGINT,
847 wxSIGQUIT,
848 wxSIGILL,
849 wxSIGTRAP,
850 wxSIGABRT,
851 wxSIGEMT,
852 wxSIGFPE,
3950d49c 853 wxSIGKILL, // forcefully kill, dangerous!
39fb8056
FM
854 wxSIGBUS,
855 wxSIGSEGV,
856 wxSIGSYS,
857 wxSIGPIPE,
858 wxSIGALRM,
3950d49c 859 wxSIGTERM // terminate the process gently
39fb8056
FM
860 };
861 @endcode
862
3950d49c
BP
863 @c wxSIGNONE, @c wxSIGKILL and @c wxSIGTERM have the same meaning under
864 both Unix and Windows but all the other signals are equivalent to
39fb8056 865 @c wxSIGTERM under Windows.
3950d49c
BP
866
867 Returns 0 on success, -1 on failure. If the @a rc parameter is not @NULL,
868 it will be filled with a value of the the @c wxKillError enum:
39fb8056
FM
869
870 @code
871 enum wxKillError
872 {
3950d49c
BP
873 wxKILL_OK, // no error
874 wxKILL_BAD_SIGNAL, // no such signal
875 wxKILL_ACCESS_DENIED, // permission denied
876 wxKILL_NO_PROCESS, // no such process
877 wxKILL_ERROR // another, unspecified error
39fb8056
FM
878 };
879 @endcode
880
3950d49c
BP
881 The @a flags parameter can be wxKILL_NOCHILDREN (the default), or
882 wxKILL_CHILDREN, in which case the child processes of this process will be
883 killed too. Note that under Unix, for wxKILL_CHILDREN to work you should
884 have created the process by passing wxEXEC_MAKE_GROUP_LEADER to
885 wxExecute().
39fb8056 886
3950d49c 887 @see wxProcess::Kill(), wxProcess::Exists(), @ref page_samples_exec
ba2874ff
BP
888
889 @header{wx/utils.h}
39fb8056 890*/
3950d49c
BP
891int wxKill(long pid, int sig = wxSIGTERM,
892 wxKillError rc = NULL, int flags = 0);
39fb8056 893
39fb8056 894/**
3950d49c
BP
895 Executes a command in an interactive shell window. If no command is
896 specified, then just the shell is spawned.
897
898 @see wxExecute(), @ref page_samples_exec
ba2874ff
BP
899
900 @header{wx/utils.h}
39fb8056 901*/
3950d49c
BP
902bool wxShell(const wxString& command = NULL);
903
904/**
905 This function shuts down or reboots the computer depending on the value of
906 the @a flags.
907
908 @note Doing this requires the corresponding access rights (superuser under
909 Unix, SE_SHUTDOWN privilege under Windows NT) and that this function
910 is only implemented under Unix and Win32.
911
912 @param flags
913 Either wxSHUTDOWN_POWEROFF or wxSHUTDOWN_REBOOT
914
915 @returns @true on success, @false if an error occurred.
916
917 @header{wx/utils.h}
918*/
919bool wxShutdown(wxShutdownFlags flags);
920
7c913512 921//@}
23324ae1 922
3950d49c
BP
923
924
925/** @ingroup group_funcmacro_time */
926//@{
927
928/**
929 Sleeps for the specified number of microseconds. The microsecond resolution
930 may not, in fact, be available on all platforms (currently only Unix
931 platforms with nanosleep(2) may provide it) in which case this is the same
932 as calling wxMilliSleep() with the argument of @e microseconds/1000.
933
934 @header{wx/utils.h}
935*/
936void wxMicroSleep(unsigned long microseconds);
937
938/**
939 Sleeps for the specified number of milliseconds. Notice that usage of this
940 function is encouraged instead of calling usleep(3) directly because the
941 standard @e usleep() function is not MT safe.
942
943 @header{wx/utils.h}
944*/
945void wxMilliSleep(unsigned long milliseconds);
946
947/**
948 Returns a string representing the current date and time.
949
950 @header{wx/utils.h}
951*/
952wxString wxNow();
953
39fb8056
FM
954/**
955 Sleeps for the specified number of seconds.
ba2874ff
BP
956
957 @header{wx/utils.h}
39fb8056
FM
958*/
959void wxSleep(int secs);
960
39fb8056 961/**
3950d49c
BP
962 @deprecated This function is deprecated because its name is misleading:
963 notice that the argument is in milliseconds, not microseconds.
964 Please use either wxMilliSleep() or wxMicroSleep() depending on
965 the resolution you need.
39fb8056 966
3950d49c 967 Sleeps for the specified number of milliseconds.
ba2874ff
BP
968
969 @header{wx/utils.h}
39fb8056 970*/
3950d49c
BP
971void wxUsleep(unsigned long milliseconds);
972
973//@}
39fb8056 974