* Fixed Async -> sync in wxExecute
* Added documentation about wxProcess, ... * Added wxDataStream::WriteString and wxDataStream::ReadString git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@178 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
884360bc11
commit
eafc087e69
@ -120,6 +120,7 @@ $$\image{14cm;0cm}{wxclass.ps}$$
|
||||
\input point.tex
|
||||
\input prevwin.tex
|
||||
\input print.tex
|
||||
\input process.tex
|
||||
\input postscpt.tex
|
||||
\input query.tex
|
||||
\input radiobox.tex
|
||||
|
@ -905,9 +905,9 @@ See also \helpref{wxIsBusy}{wxisbusy}.
|
||||
|
||||
\membersection{::wxExecute}\label{wxexecute}
|
||||
|
||||
\func{long}{wxExecute}{\param{const wxString\& }{command}, \param{bool }{sync = FALSE}}
|
||||
\func{long}{wxExecute}{\param{const wxString\& }{command}, \param{bool }{sync = FALSE}, \param{wxProcess *}{callback = NULL}}
|
||||
|
||||
\func{long}{wxExecute}{\param{const wxString\& *}{argv}, \param{bool }{sync = FALSE}}
|
||||
\func{long}{wxExecute}{\param{const wxString\& *}{argv}, \param{bool }{sync = FALSE}, \param{wxProcess *}{callback = NULL}}
|
||||
|
||||
Executes another program in UNIX or Windows.
|
||||
|
||||
@ -923,7 +923,11 @@ If execution is asynchronous, the return value is the process id,
|
||||
otherwise it is a status value. A zero value indicates that the command could not
|
||||
be executed.
|
||||
|
||||
See also \helpref{wxShell}{wxshell}.
|
||||
If callback isn't NULL and if execution is asynchronous,
|
||||
\helpref{wxProcess::OnTerminate}{wxprocessonterminate} will be called when
|
||||
the process finishes.
|
||||
|
||||
See also \helpref{wxShell}{wxshell}, \helpref{wxProcess}{wxprocess}.
|
||||
|
||||
\membersection{::wxExit}\label{wxexit}
|
||||
|
||||
|
39
docs/latex/wx/process.tex
Normal file
39
docs/latex/wx/process.tex
Normal file
@ -0,0 +1,39 @@
|
||||
\section{\class{wxProcess}}\label{wxprocess}
|
||||
|
||||
This class contains a method which is invoked when a process finishes.
|
||||
It can raise a \helpref{wxProcessEvent}{wxprocessevent} if wxProcess::OnTerminate
|
||||
isn't overriden.
|
||||
|
||||
\wxheading{Derived from}
|
||||
|
||||
\helpref{wxEvtHandler}{wxevthandler}
|
||||
|
||||
\latexignore{\rtfignore{\wxheading{Members}}}
|
||||
|
||||
\membersection{wxProcess::wxProcess}\label{wxprocessconstr}
|
||||
|
||||
\func{}{wxProcess}{\param{wxEvtHandler *}{ parent = NULL}, \param{int}{ id = -1}}
|
||||
|
||||
Constructs a process object. {\it id} is only used in the case you want to
|
||||
use wxWindows events.
|
||||
|
||||
\wxheading{Parameters}
|
||||
|
||||
\docparam{parent}{The event handler parent.}
|
||||
|
||||
\docparam{id}{id of an event.}
|
||||
|
||||
\membersection{wxProcess::\destruct{wxProcess}}
|
||||
|
||||
\func{}{\destruct{wxProcess}}{\void}
|
||||
|
||||
Destroys the wxProcess object.
|
||||
|
||||
\membersection{wxProcess::OnTerminate}\label{wxprocessonterminate}
|
||||
|
||||
\constfunc{void}{OnTerminate}{\param{int}{ pid}}
|
||||
|
||||
It is called when the process with the pid {\it pid} finishes.
|
||||
It raises a wxWindows event when it isn't overriden.
|
||||
|
||||
\docparam{pid}{The pid of the process which ends.}
|
@ -31,12 +31,14 @@ public:
|
||||
unsigned char Read8();
|
||||
double ReadDouble();
|
||||
wxString ReadLine();
|
||||
wxString ReadString();
|
||||
|
||||
void Write32(unsigned long i);
|
||||
void Write16(unsigned short i);
|
||||
void Write8(unsigned char i);
|
||||
void WriteDouble(double d);
|
||||
void WriteLine(const wxString& line);
|
||||
void WriteString(const wxString& string);
|
||||
protected:
|
||||
istream *m_istream;
|
||||
ostream *m_ostream;
|
||||
|
@ -116,6 +116,27 @@ wxString wxDataStream::ReadLine()
|
||||
return i_strg;
|
||||
}
|
||||
|
||||
wxString wxDataStream::ReadString()
|
||||
{
|
||||
wxString wx_string;
|
||||
char *string;
|
||||
unsigned long len;
|
||||
|
||||
if (!m_istream)
|
||||
return "";
|
||||
|
||||
len = Read32();
|
||||
string = new char[len+1];
|
||||
|
||||
m_istream->read(string, len);
|
||||
|
||||
string[len] = 0;
|
||||
wx_string = string;
|
||||
delete string;
|
||||
|
||||
return wx_string;
|
||||
}
|
||||
|
||||
void wxDataStream::Write32(unsigned long i)
|
||||
{
|
||||
char buf[4];
|
||||
@ -152,7 +173,11 @@ void wxDataStream::Write8(unsigned char i)
|
||||
|
||||
void wxDataStream::WriteLine(const wxString& line)
|
||||
{
|
||||
#ifdef __WINDOWS__
|
||||
wxString tmp_string = line + "\r\n";
|
||||
#else
|
||||
wxString tmp_string = line + '\n';
|
||||
#endif
|
||||
|
||||
if (!m_ostream)
|
||||
return;
|
||||
@ -160,6 +185,15 @@ void wxDataStream::WriteLine(const wxString& line)
|
||||
m_ostream->write((const char *) tmp_string, tmp_string.Length());
|
||||
}
|
||||
|
||||
void wxDataStream::WriteString(const wxString& string)
|
||||
{
|
||||
if (!m_ostream)
|
||||
return;
|
||||
|
||||
Write32(tmp_string.Length());
|
||||
m_ostream->write((const char *) tmp_string, tmp_string.Length());
|
||||
}
|
||||
|
||||
// Must be at global scope for VC++ 5
|
||||
extern "C" void ConvertToIeeeExtended(double num, unsigned char *bytes);
|
||||
|
||||
|
@ -364,7 +364,7 @@ static void GTK_EndProcessDetector(gpointer data, gint source,
|
||||
proc_data->pid = 0;
|
||||
};
|
||||
|
||||
long wxExecute( char **argv, bool Async, wxProcess *process )
|
||||
long wxExecute( char **argv, bool sync, wxProcess *process )
|
||||
{
|
||||
wxEndProcessData *data = new wxEndProcessData;
|
||||
int end_proc_detect[2];
|
||||
@ -409,7 +409,7 @@ long wxExecute( char **argv, bool Async, wxProcess *process )
|
||||
data->tag = gdk_input_add(end_proc_detect[0], GDK_INPUT_READ,
|
||||
GTK_EndProcessDetector, (gpointer)data);
|
||||
data->pid = pid;
|
||||
if (Async) {
|
||||
if (!sync) {
|
||||
data->process = process;
|
||||
} else {
|
||||
data->process = NULL;
|
||||
@ -424,7 +424,7 @@ long wxExecute( char **argv, bool Async, wxProcess *process )
|
||||
return pid;
|
||||
};
|
||||
|
||||
long wxExecute( const wxString& command, bool Async, wxProcess *process )
|
||||
long wxExecute( const wxString& command, bool sync, wxProcess *process )
|
||||
{
|
||||
if (command.IsNull() || command == "") return FALSE;
|
||||
|
||||
@ -438,6 +438,6 @@ long wxExecute( const wxString& command, bool Async, wxProcess *process )
|
||||
argv[argc++] = strtok (tmp, IFS);
|
||||
while ((argv[argc++] = strtok(NULL, IFS)) != NULL)
|
||||
/* loop */ ;
|
||||
return wxExecute(argv, Async, process);
|
||||
return wxExecute(argv, sync, process);
|
||||
};
|
||||
|
||||
|
@ -364,7 +364,7 @@ static void GTK_EndProcessDetector(gpointer data, gint source,
|
||||
proc_data->pid = 0;
|
||||
};
|
||||
|
||||
long wxExecute( char **argv, bool Async, wxProcess *process )
|
||||
long wxExecute( char **argv, bool sync, wxProcess *process )
|
||||
{
|
||||
wxEndProcessData *data = new wxEndProcessData;
|
||||
int end_proc_detect[2];
|
||||
@ -409,7 +409,7 @@ long wxExecute( char **argv, bool Async, wxProcess *process )
|
||||
data->tag = gdk_input_add(end_proc_detect[0], GDK_INPUT_READ,
|
||||
GTK_EndProcessDetector, (gpointer)data);
|
||||
data->pid = pid;
|
||||
if (Async) {
|
||||
if (!sync) {
|
||||
data->process = process;
|
||||
} else {
|
||||
data->process = NULL;
|
||||
@ -424,7 +424,7 @@ long wxExecute( char **argv, bool Async, wxProcess *process )
|
||||
return pid;
|
||||
};
|
||||
|
||||
long wxExecute( const wxString& command, bool Async, wxProcess *process )
|
||||
long wxExecute( const wxString& command, bool sync, wxProcess *process )
|
||||
{
|
||||
if (command.IsNull() || command == "") return FALSE;
|
||||
|
||||
@ -438,6 +438,6 @@ long wxExecute( const wxString& command, bool Async, wxProcess *process )
|
||||
argv[argc++] = strtok (tmp, IFS);
|
||||
while ((argv[argc++] = strtok(NULL, IFS)) != NULL)
|
||||
/* loop */ ;
|
||||
return wxExecute(argv, Async, process);
|
||||
return wxExecute(argv, sync, process);
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user