minor samples fixes
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1389 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
73c700fdee
commit
1d5b7a0be4
@ -29,18 +29,16 @@ class MyApp;
|
||||
|
||||
class MyCanvas: public wxScrolledWindow
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(MyCanvas)
|
||||
|
||||
public:
|
||||
|
||||
MyCanvas(void) {};
|
||||
MyCanvas() {};
|
||||
MyCanvas( wxWindow *parent, wxWindowID, const wxPoint &pos, const wxSize &size );
|
||||
~MyCanvas(void);
|
||||
~MyCanvas();
|
||||
void OnPaint( wxPaintEvent &event );
|
||||
|
||||
wxBitmap *my_horse;
|
||||
wxBitmap *my_square;
|
||||
|
||||
DECLARE_DYNAMIC_CLASS(MyCanvas)
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
@ -48,17 +46,15 @@ class MyCanvas: public wxScrolledWindow
|
||||
|
||||
class MyFrame: public wxFrame
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(MyFrame)
|
||||
|
||||
public:
|
||||
MyFrame();
|
||||
|
||||
MyFrame(void);
|
||||
void OnSize( wxSizeEvent &event );
|
||||
void OnAbout( wxCommandEvent &event );
|
||||
void OnQuit( wxCommandEvent &event );
|
||||
|
||||
MyCanvas *m_canvas;
|
||||
|
||||
DECLARE_DYNAMIC_CLASS(MyFrame)
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
@ -67,9 +63,7 @@ class MyFrame: public wxFrame
|
||||
class MyApp: public wxApp
|
||||
{
|
||||
public:
|
||||
|
||||
MyApp(void);
|
||||
virtual bool OnInit(void);
|
||||
virtual bool OnInit();
|
||||
};
|
||||
|
||||
// main program
|
||||
@ -84,7 +78,8 @@ BEGIN_EVENT_TABLE(MyCanvas,wxScrolledWindow)
|
||||
EVT_PAINT(MyCanvas::OnPaint)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
MyCanvas::MyCanvas( wxWindow *parent, const wxWindowID id, const wxPoint &pos, const wxSize &size )
|
||||
MyCanvas::MyCanvas( wxWindow *parent, const wxWindowID id,
|
||||
const wxPoint &pos, const wxSize &size )
|
||||
: wxScrolledWindow( parent, id, pos, size, wxSUNKEN_BORDER )
|
||||
{
|
||||
SetBackgroundColour(* wxWHITE);
|
||||
@ -117,7 +112,7 @@ MyCanvas::MyCanvas( wxWindow *parent, const wxWindowID id, const wxPoint &pos, c
|
||||
my_square = new wxBitmap( image.ConvertToBitmap() );
|
||||
}
|
||||
|
||||
MyCanvas::~MyCanvas(void)
|
||||
MyCanvas::~MyCanvas()
|
||||
{
|
||||
delete my_horse;
|
||||
delete my_square;
|
||||
@ -149,11 +144,11 @@ IMPLEMENT_DYNAMIC_CLASS( MyFrame, wxFrame )
|
||||
BEGIN_EVENT_TABLE(MyFrame,wxFrame)
|
||||
EVT_MENU (ID_ABOUT, MyFrame::OnAbout)
|
||||
EVT_MENU (ID_QUIT, MyFrame::OnQuit)
|
||||
EVT_SIZE (MyFrame::OnSize)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
MyFrame::MyFrame(void) :
|
||||
wxFrame( (wxFrame *) NULL, -1, "wxImage sample", wxPoint(20,20), wxSize(470,360) )
|
||||
MyFrame::MyFrame()
|
||||
: wxFrame( (wxFrame *)NULL, -1, "wxImage sample",
|
||||
wxPoint(20,20), wxSize(470,360) )
|
||||
{
|
||||
wxMenu *file_menu = new wxMenu();
|
||||
file_menu->Append( ID_ABOUT, "About..");
|
||||
@ -179,27 +174,16 @@ void MyFrame::OnQuit( wxCommandEvent &WXUNUSED(event) )
|
||||
|
||||
void MyFrame::OnAbout( wxCommandEvent &WXUNUSED(event) )
|
||||
{
|
||||
(void) wxMessageBox( "wxImage demo\nRobert Roebling (c) 1998", "About wxImage Demo", wxOK );
|
||||
}
|
||||
|
||||
void MyFrame::OnSize( wxSizeEvent &WXUNUSED(event) )
|
||||
{
|
||||
int w,h;
|
||||
GetClientSize( &w, &h );
|
||||
if (m_canvas)
|
||||
m_canvas->SetSize( w, h );
|
||||
(void)wxMessageBox( "wxImage demo\n"
|
||||
"Robert Roebling (c) 1998",
|
||||
"About wxImage Demo", wxICON_INFORMATION | wxOK );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// MyApp
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
MyApp::MyApp(void) :
|
||||
wxApp( )
|
||||
{
|
||||
}
|
||||
|
||||
bool MyApp::OnInit(void)
|
||||
bool MyApp::OnInit()
|
||||
{
|
||||
wxImage::AddHandler( new wxPNGHandler );
|
||||
|
||||
|
@ -97,18 +97,6 @@ bool MyApp::OnInit(void)
|
||||
// Give it a status line
|
||||
frame->CreateStatusBar(2);
|
||||
|
||||
/*
|
||||
// Make a menubar
|
||||
wxMenu *file_menu = new wxMenu;
|
||||
|
||||
file_menu->Append(RESOURCE_TEST1, "&Dialog box test", "Test dialog box resource");
|
||||
file_menu->Append(RESOURCE_QUIT, "E&xit", "Quit program");
|
||||
|
||||
wxMenuBar *menu_bar = new wxMenuBar;
|
||||
|
||||
menu_bar->Append(file_menu, "&File");
|
||||
*/
|
||||
|
||||
wxMenuBar *menu_bar = wxResourceCreateMenuBar("menu1");
|
||||
|
||||
// Associate the menu bar with the frame
|
||||
@ -123,6 +111,12 @@ bool MyApp::OnInit(void)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
MyApp::~MyApp()
|
||||
{
|
||||
delete dialog1;
|
||||
delete menu1;
|
||||
}
|
||||
|
||||
BEGIN_EVENT_TABLE(MyPanel, wxPanel)
|
||||
EVT_LEFT_DOWN( MyPanel::OnClick)
|
||||
END_EVENT_TABLE()
|
||||
@ -133,17 +127,18 @@ MyPanel::MyPanel( wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxS
|
||||
{
|
||||
}
|
||||
|
||||
void MyPanel::OnClick( wxMouseEvent &WXUNUSED(event) )
|
||||
void MyPanel::OnClick( wxMouseEvent &WXUNUSED(event2) )
|
||||
{
|
||||
MyFrame *frame = (MyFrame*)(wxTheApp->GetTopWindow());
|
||||
wxCommandEvent event;
|
||||
frame->OnTest1( event );
|
||||
frame->OnTestDialog( event );
|
||||
}
|
||||
|
||||
|
||||
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
||||
EVT_MENU(RESOURCE_ABOUT, MyFrame::OnAbout)
|
||||
EVT_MENU(RESOURCE_QUIT, MyFrame::OnQuit)
|
||||
EVT_MENU(RESOURCE_TEST1, MyFrame::OnTest1)
|
||||
EVT_MENU(RESOURCE_TESTDIALOG, MyFrame::OnTestDialog)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
// Define my frame constructor
|
||||
@ -153,12 +148,19 @@ MyFrame::MyFrame(wxWindow *parent, const wxWindowID id, const wxString& title, c
|
||||
panel = (wxWindow *) NULL;
|
||||
}
|
||||
|
||||
void MyFrame::OnAbout( wxCommandEvent& WXUNUSED(event) )
|
||||
{
|
||||
wxMessageBox("wxWindows resource sample.\n"
|
||||
"(c) Julian Smart", "About wxWindows sample",
|
||||
wxICON_INFORMATION | wxOK);
|
||||
}
|
||||
|
||||
void MyFrame::OnQuit( wxCommandEvent& WXUNUSED(event) )
|
||||
{
|
||||
Close(TRUE);
|
||||
}
|
||||
|
||||
void MyFrame::OnTest1(wxCommandEvent& WXUNUSED(event) )
|
||||
void MyFrame::OnTestDialog(wxCommandEvent& WXUNUSED(event) )
|
||||
{
|
||||
MyDialog *dialog = new MyDialog;
|
||||
if (dialog->LoadFromResource(this, "dialog1"))
|
||||
|
@ -17,29 +17,37 @@
|
||||
class MyApp: public wxApp
|
||||
{
|
||||
public:
|
||||
MyApp(void) ;
|
||||
bool OnInit(void);
|
||||
MyApp();
|
||||
|
||||
virtual bool OnInit();
|
||||
|
||||
virtual ~MyApp();
|
||||
};
|
||||
|
||||
class MyPanel: public wxPanel
|
||||
{
|
||||
public:
|
||||
MyPanel( wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
|
||||
int style, const wxString &name );
|
||||
MyPanel(wxWindow *parent, wxWindowID id, const wxPoint& pos,
|
||||
const wxSize& size, int style, const wxString &name);
|
||||
void OnClick(wxMouseEvent &event);
|
||||
|
||||
private:
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
class MyFrame: public wxFrame
|
||||
{
|
||||
public:
|
||||
wxWindow *panel;
|
||||
MyFrame(wxWindow *parent, const wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size);
|
||||
bool OnClose(void);
|
||||
MyFrame(wxWindow *parent, const wxWindowID id, const wxString& title,
|
||||
const wxPoint& pos, const wxSize& size);
|
||||
bool OnClose();
|
||||
void OnQuit(wxCommandEvent& event);
|
||||
void OnTest1(wxCommandEvent& event);
|
||||
void OnAbout(wxCommandEvent& event);
|
||||
void OnTestDialog(wxCommandEvent& event);
|
||||
|
||||
wxWindow *panel;
|
||||
|
||||
private:
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
@ -49,13 +57,14 @@ class MyDialog : public wxDialog
|
||||
void OnOk(wxCommandEvent& event);
|
||||
void OnCancel(wxCommandEvent& event);
|
||||
|
||||
private:
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
#define RESOURCE_QUIT 4
|
||||
#define RESOURCE_TEST1 2
|
||||
|
||||
/*
|
||||
#define RESOURCE_OK 1
|
||||
#define RESOURCE_CANCEL 2
|
||||
*/
|
||||
// the values should be the same as in menu.wxr file!
|
||||
enum
|
||||
{
|
||||
RESOURCE_TESTDIALOG = 2,
|
||||
RESOURCE_QUIT = 4,
|
||||
RESOURCE_ABOUT = 6
|
||||
};
|
||||
|
@ -164,7 +164,7 @@ END_EVENT_TABLE()
|
||||
// Define my frame constructor
|
||||
MyFrame::MyFrame(wxFrame* parent, wxWindowID id, const wxString& title, const wxPoint& pos,
|
||||
const wxSize& size, long style):
|
||||
wxFrame(parent, id, title, pos, size, style), m_timer(this)
|
||||
wxFrame(parent, id, title, pos, size, style)
|
||||
{
|
||||
m_textWindow = new wxTextCtrl(this, -1, "", wxPoint(0, 0), wxSize(-1, -1), wxTE_MULTILINE);
|
||||
}
|
||||
@ -176,10 +176,7 @@ void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
|
||||
|
||||
void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
// (void)wxMessageBox("wxWindows wxToolBar demo\n", "About wxToolBar");
|
||||
wxLogStatus("Started timer.");
|
||||
|
||||
m_timer.Start(500, TRUE);
|
||||
(void)wxMessageBox("wxWindows toolbar sample", "About wxToolBar");
|
||||
}
|
||||
|
||||
// Define the behaviour for the frame closing
|
||||
|
@ -45,8 +45,6 @@ public:
|
||||
private:
|
||||
wxTextCtrl* m_textWindow;
|
||||
|
||||
MyTimer m_timer;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user