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