Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wx-event-test
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Stas Korobeynikov
wx-event-test
Commits
d30fd10b
Commit
d30fd10b
authored
Nov 18, 2016
by
Stas Korobeynikov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add event
parent
609a279e
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
12 deletions
+26
-12
asyncprocess.cpp
asyncprocess.cpp
+11
-5
asyncprocess.h
asyncprocess.h
+7
-5
opennxtestevent.cpp
opennxtestevent.cpp
+7
-2
opennxtestevent.h
opennxtestevent.h
+1
-0
No files found.
asyncprocess.cpp
View file @
d30fd10b
#if defined(__GNUG__) && !defined(__APPLE__)
#pragma implementation "asyncprocess.h"
#endif
#include "wx/wxprec.h"
#include "stdio.h"
...
...
@@ -12,10 +8,14 @@
#include "asyncprocess.h"
DEFINE_LOCAL_EVENT_TYPE
(
wxEVT_PROCESS_STDOUT
);
IMPLEMENT_DYNAMIC_CLASS
(
AsyncProcess
,
wxProcess
)
AsyncProcess
::
AsyncProcess
()
:
wxProcess
(),
wxThreadHelper
()
{
AsyncProcess
::
AsyncProcess
()
:
m_pEvtHandler
(
NULL
)
{
}
AsyncProcess
::
AsyncProcess
(
wxEvtHandler
*
evtHandler
)
:
wxProcess
(),
wxThreadHelper
(),
m_pEvtHandler
(
evtHandler
)
{
Redirect
();
}
...
...
@@ -33,6 +33,12 @@ wxThread::ExitCode AsyncProcess::Entry() {
while
(
IsInputAvailable
())
{
char
c
=
GetInputStream
()
->
GetC
();
printf
(
"%c"
,
c
);
if
(
c
==
'\n'
)
{
wxCommandEvent
event
(
wxEVT_PROCESS_STDOUT
,
wxID_ANY
);
event
.
SetString
(
"String compleate
\n
"
);
event
.
SetClientData
(
this
);
m_pEvtHandler
->
AddPendingEvent
(
event
);
}
}
}
}
...
...
asyncprocess.h
View file @
d30fd10b
...
...
@@ -5,21 +5,22 @@
#include <wx/process.h>
#include <wx/thread.h>
#if defined(__GNUG__) && !defined(__APPLE__)
#pragma interface "AsyncProcess.cpp"
#endif
DECLARE_LOCAL_EVENT_TYPE
(
wxEVT_PROCESS_STDOUT
,
-
3
);
class
AsyncProcess
:
public
wxProcess
,
public
wxThreadHelper
{
DECLARE_DYNAMIC_CLASS
(
AsyncProcess
)
public
:
AsyncProcess
();
AsyncProcess
();
AsyncProcess
(
wxEvtHandler
*
m_pEvtHandler
);
void
start
();
virtual
~
AsyncProcess
();
private
:
virtual
wxThread
::
ExitCode
Entry
();
virtual
void
OnTerminate
(
int
pid
,
int
status
);
wxEvtHandler
*
m_pEvtHandler
;
};
#endif
\ No newline at end of file
opennxtestevent.cpp
View file @
d30fd10b
...
...
@@ -10,13 +10,13 @@
IMPLEMENT_APP
(
OpennxTestEvent
)
BEGIN_EVENT_TABLE
(
OpennxTestEvent
,
wxEvtHandler
)
EVT_COMMAND
(
wxID_ANY
,
wxEVT_PROCESS_STDOUT
,
OpennxTestEvent
::
OnOutReceived
)
END_EVENT_TABLE
();
// This is executed upon startup, like 'main()' in non-wxWidgets programs.
bool
OpennxTestEvent
::
OnInit
()
{
AsyncProcess
*
ap
=
new
AsyncProcess
();
AsyncProcess
*
ap
=
new
AsyncProcess
(
this
);
wxFrame
*
frame
=
new
wxFrame
((
wxFrame
*
)
NULL
,
-
1
,
_T
(
"Test opennx event"
));
frame
->
CreateStatusBar
();
frame
->
SetStatusText
(
_T
(
"Test opennx event"
));
...
...
@@ -26,4 +26,8 @@ bool OpennxTestEvent::OnInit()
ap
->
start
();
return
true
;
}
void
OpennxTestEvent
::
OnOutReceived
(
wxCommandEvent
&
event
)
{
printf
(
"event received"
);
}
\ No newline at end of file
opennxtestevent.h
View file @
d30fd10b
...
...
@@ -6,6 +6,7 @@ class OpennxTestEvent : public wxApp
DECLARE_EVENT_TABLE
();
public
:
virtual
bool
OnInit
();
void
OnOutReceived
(
wxCommandEvent
&
event
);
};
DECLARE_APP
(
OpennxTestEvent
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment