1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
|
#include <wx/wx.h>
class
Exempleapp : public wxApp
{
public:
virtual bool OnInit();
};
class
ExempleFrame : public wxFrame
{
public:
ExempleFrame( const wxString& title, const wxPoint& pos, const wxSize& pos );
void OnQuit( wxCommandEvent& event );
void OnAbout( wxCommandEvent& event );
void OnStart( wxCommandEvent& event );
void OnTimer(wxTimerEvent&);
private:
wxTextCtrl *mlTextCtrl;
wxTimer *MonTimer;
DECLARE_EVENT_TABLE()
};
enum
{
Menu_File_Quit = 100,
Menu_File_About,
Menu_File_Start,
Id_TextEdit,
Id_Timer
};
BEGIN_EVENT_TABLE( ExempleFrame, wxFrame )
EVT_MENU( Menu_File_Quit, ExempleFrame::OnQuit )
EVT_MENU( Menu_File_About, ExempleFrame::OnAbout )
EVT_MENU( Menu_File_Start, ExempleFrame::OnStart )
EVT_TIMER(Id_Timer, ExempleFrame::OnTimer)
END_EVENT_TABLE()
IMPLEMENT_APP(Exempleapp)
bool
Exempleapp::OnInit()
{
ExempleFrame *frame = new ExempleFrame( wxT( "Hello World" ), wxPoint(50,50), wxSize(450,340) );
frame->Show(TRUE);
SetTopWindow(frame);
return TRUE;
}
ExempleFrame::ExempleFrame( const wxString& title, const wxPoint& pos, const wxSize& size )
: wxFrame((wxFrame *)NULL, -1, title, pos, size)
{
wxMenu *menuFile = new wxMenu;
menuFile->Append( Menu_File_Start, wxT( "Start !" ) );
menuFile->AppendSeparator();
menuFile->Append( Menu_File_About, wxT( "&About..." ) );
menuFile->AppendSeparator();
menuFile->Append( Menu_File_Quit, wxT( "E&xit" ) );
wxMenuBar *menuBar = new wxMenuBar;
menuBar->Append( menuFile, wxT( "&File" ) );
SetMenuBar( menuBar );
CreateStatusBar();
SetStatusText( wxT( "Welcome to Kdevelop wxWidgets app!" ) );
mlTextCtrl = new wxTextCtrl(this, Id_TextEdit, _T(""), wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE);// wxTE_MULTILINE | wxTE_CHARWRAP | wxTE_READONLY);
MonTimer = new wxTimer(this,Id_Timer);
}
void
ExempleFrame::OnTimer(wxTimerEvent& event) {
mlTextCtrl->AppendText(wxT("Test"));
}
void
ExempleFrame::OnQuit( wxCommandEvent& WXUNUSED( event ) )
{
Close(TRUE);
}
void
ExempleFrame::OnStart( wxCommandEvent& WXUNUSED( event ) )
{
MonTimer->Start(100);
}
void
ExempleFrame::OnAbout( wxCommandEvent& WXUNUSED( event ) )
{
wxMessageBox( wxT( "This is a wxWidgets Hello world sample" ),
wxT( "About Hello World" ), wxOK | wxICON_INFORMATION, this );
} |
Partager