]> git.saurik.com Git - wxWidgets.git/blob - include/wx/process.h
a more easy to use version of wxGetHomeDir() added
[wxWidgets.git] / include / wx / process.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: process.h
3 // Purpose: wxProcess class
4 // Author: Guilhem Lavaux
5 // Modified by: Vadim Zeitlin to check error codes, added Detach() method
6 // Created: 24/06/98
7 // RCS-ID: $Id$
8 // Copyright: (c) 1998 Guilhem Lavaux
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_PROCESSH__
13 #define _WX_PROCESSH__
14
15 #ifdef __GNUG__
16 #pragma interface "process.h"
17 #endif
18
19 #include "wx/defs.h"
20 #include "wx/object.h"
21 #include "wx/event.h"
22
23 // Process Event handling
24 class WXDLLEXPORT wxProcessEvent : public wxEvent
25 {
26 DECLARE_DYNAMIC_CLASS(wxProcessEvent)
27
28 public:
29 wxProcessEvent(int id = 0, int pid = 0, int exitcode = 0) : wxEvent(id)
30 {
31 m_eventType = wxEVT_END_PROCESS;
32 m_pid = pid;
33 m_exitcode = exitcode;
34 }
35
36 // accessors
37 // PID of process which terminated
38 int GetPid() { return m_pid; }
39
40 // the exit code
41 int GetExitCode() { return m_exitcode; }
42
43 public:
44 int m_pid, m_exitcode;
45 };
46
47 // A wxProcess object should be passed to wxExecute - than its OnTerminate()
48 // function will be called when the process terminates.
49 class WXDLLEXPORT wxProcess : public wxEvtHandler
50 {
51 DECLARE_DYNAMIC_CLASS(wxProcess)
52
53 public:
54 wxProcess(wxEvtHandler *parent = (wxEvtHandler *) NULL, int id = -1);
55
56 virtual void OnTerminate(int pid, int status);
57
58 // detach from the parent - should be called by the parent if it's deleted
59 // before the process it started terminates
60 void Detach();
61
62 protected:
63 int m_id;
64 };
65
66 typedef void (wxObject::*wxProcessEventFunction)(wxProcessEvent&);
67
68 #define EVT_END_PROCESS(id, func) { wxEVT_END_PROCESS, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxProcessEventFunction) & func, NULL},
69
70 #endif
71 // _WX_PROCESSH__