X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c801d85f158c4cba50b588807daabdcbd0ed3853..34a1d7328f198b5ad31c33a07a6078f089feb45f:/user/wxTest/wxTest.cpp diff --git a/user/wxTest/wxTest.cpp b/user/wxTest/wxTest.cpp index c9d48c2045..a43d89fda8 100644 --- a/user/wxTest/wxTest.cpp +++ b/user/wxTest/wxTest.cpp @@ -28,6 +28,7 @@ #include "folder.xpm" #include "list.xpm" +#include "test.xpm" //----------------------------------------------------------------------------- // main program @@ -39,32 +40,32 @@ IMPLEMENT_APP(MyApp) // MyDialog //----------------------------------------------------------------------------- -const ID_RETURN = 100; -const ID_HELLO = 101; +const int ID_RETURN = 100; +const int ID_HELLO = 101; -const ID_CHECKBOX = 110; -const ID_CHECKBOX_CHECK = 110; -const ID_CHECKBOX_UNCHECK = 112; +const int ID_CHECKBOX = 110; +const int ID_CHECKBOX_CHECK = 110; +const int ID_CHECKBOX_UNCHECK = 112; -const ID_TEXTCTRL = 115; -const ID_TEXTCTRL_SET = 116; -const ID_TEXTCTRL_DEL = 117; +const int ID_TEXTCTRL = 115; +const int ID_TEXTCTRL_SET = 116; +const int ID_TEXTCTRL_DEL = 117; -const ID_CHOICE = 120; -const ID_CHOICE_SEL_NUM = 121; -const ID_CHOICE_SEL_STR = 122; -const ID_CHOICE_CLEAR = 123; -const ID_CHOICE_APPEND = 124; +const int ID_CHOICE = 120; +const int ID_CHOICE_SEL_NUM = 121; +const int ID_CHOICE_SEL_STR = 122; +const int ID_CHOICE_CLEAR = 123; +const int ID_CHOICE_APPEND = 124; -const ID_LISTBOX = 130; -const ID_LISTBOX_SEL_NUM = 131; -const ID_LISTBOX_SEL_STR = 132; -const ID_LISTBOX_CLEAR = 133; -const ID_LISTBOX_APPEND = 134; +const int ID_LISTBOX = 130; +const int ID_LISTBOX_SEL_NUM = 131; +const int ID_LISTBOX_SEL_STR = 132; +const int ID_LISTBOX_CLEAR = 133; +const int ID_LISTBOX_APPEND = 134; -const ID_RADIOBOX = 130; -const ID_RADIOBOX_SEL_NUM = 131; -const ID_RADIOBOX_SEL_STR = 132; +const int ID_RADIOBOX = 130; +const int ID_RADIOBOX_SEL_NUM = 131; +const int ID_RADIOBOX_SEL_STR = 132; BEGIN_EVENT_TABLE(MyDialog,wxDialog) EVT_BUTTON (ID_RETURN, MyDialog::OnReturnButton) @@ -97,8 +98,8 @@ IMPLEMENT_DYNAMIC_CLASS(MyDialog, wxDialog) MyDialog::MyDialog( wxWindow *parent ) : wxDialog( parent, -1, "TestDialog", wxPoint(20,100), wxSize(700,400), wxDIALOG_MODAL ) { - m_text1 = NULL; - m_text2 = NULL; + m_text1 = (wxStaticText *) NULL; + m_text2 = (wxStaticText *) NULL; (void)new wxStaticBox( this, -1, "CheckBox group", wxPoint(20,10), wxSize(140,180) ); m_checkbox = new wxCheckBox( this, ID_CHECKBOX, "CheckBox", wxPoint(40,35), wxSize(100,30) ); @@ -160,7 +161,7 @@ void MyDialog::OnTextCtrlButtons( wxCommandEvent &event ) }; case ID_TEXTCTRL_DEL: { - m_textctrl->Delete(); + m_textctrl->Clear(); break; }; }; @@ -289,7 +290,7 @@ void MyDialog::OnHelloButton( wxCommandEvent &WXUNUSED(event) ) { wxMessageDialog *dialog; dialog = new wxMessageDialog( this, "Now, I will paint on Screen.", "wxGTK" ); - dialog->ShowModal(); + dialog->ShowModal(); delete dialog; wxScreenDC dc; @@ -324,8 +325,7 @@ MyCanvas::MyCanvas( wxWindow *parent, const wxWindowID id, const wxPoint &pos, c : wxScrolledWindow( parent, id, pos, size, wxSUNKEN_BORDER ) { my_bitmap = new wxBitmap( folder_xpm ); - my_horse = new wxBitmap(); - my_horse->LoadFile( "horse.png", 0 ); + my_horse = new wxBitmap( test_xpm); my_backstore = new wxBitmap( 150, 150 ); my_font = new wxFont( 20, wxROMAN, wxNORMAL, wxNORMAL ); m_isCreated = FALSE; @@ -348,6 +348,7 @@ void MyCanvas::OnPaint( wxPaintEvent &WXUNUSED(event) ) wxMemoryDC memDC; memDC.SelectObject( *my_backstore ); + memDC.Clear(); memDC.SetBrush( *wxBLACK_BRUSH ); memDC.SetPen( *wxWHITE_PEN ); memDC.DrawRectangle( 0, 0, 150, 150 ); @@ -433,7 +434,6 @@ const ID_ABOUT = 109; IMPLEMENT_DYNAMIC_CLASS( MyFrame, wxFrame ) BEGIN_EVENT_TABLE(MyFrame,wxFrame) - EVT_SIZE (MyFrame::OnSize) EVT_MENU (ID_OPEN, MyFrame::OnOpenDialog) EVT_MENU (ID_FONT, MyFrame::OnFontDialog) EVT_MENU (ID_MSG, MyFrame::OnMsg) @@ -443,8 +443,9 @@ BEGIN_EVENT_TABLE(MyFrame,wxFrame) END_EVENT_TABLE() MyFrame::MyFrame(void) : - wxFrame( NULL, -1, "Robert's Test application", wxPoint(20,20), wxSize(470,360) ) + wxFrame( (wxFrame *) NULL, -1, (char *) "Robert's Test application", wxPoint(20,20), wxSize(470,360) ) { +/* wxMenu *file_menu = new wxMenu( "Test" ); file_menu->Append( ID_OPEN, "Open.."); file_menu->Append( ID_MSG, "MessageBox.."); @@ -460,6 +461,7 @@ MyFrame::MyFrame(void) : menu_bar->Show( TRUE ); SetMenuBar( menu_bar ); +*/ CreateStatusBar( 2 ); @@ -469,34 +471,19 @@ MyFrame::MyFrame(void) : m_canvas = new MyCanvas( this, -1, wxPoint(2,62), wxSize(300-4,120-4) ); m_canvas->SetScrollbars( 10, 10, 50, 50 ); - m_tb = new wxToolBarGTK( this, -1, wxPoint(2,60), wxSize(300-4,26) ); - m_tb->SetMargins( 2, 2 ); - - wxBitmap *bm = new wxBitmap( list_xpm ); - m_tb->AddTool( 0, *bm, wxNullBitmap, FALSE, -1, -1, NULL, "This is a button" ); - bm = new wxBitmap( folder_xpm ); - m_tb->AddTool( 0, *bm, wxNullBitmap, TRUE, -1, -1, NULL, "This is a toggle" ); - - m_tb->Layout(); - m_tb->Show( TRUE ); + m_tb = CreateToolBar(); + m_tb->AddTool( 0, wxBitmap( list_xpm ), wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, "This is a button" ); + m_tb->AddTool( 0, wxBitmap( folder_xpm ), wxNullBitmap, TRUE, -1, -1, (wxObject *) NULL, "This is a toggle" ); + m_tb->Realize(); // m_timer.Start( 1000, TRUE ); }; -void MyFrame::OnSize( wxSizeEvent &WXUNUSED(event) ) -{ - int x = 0; - int y = 0; - GetClientSize( &x, &y ); - - m_tb->SetSize( 1, 0, x-2, 42 ); - m_canvas-> SetSize( 0, 42, x, y-42 ); -}; - void MyFrame::OnDialog( wxCommandEvent &WXUNUSED(event) ) { - MyDialog dialog( this ); - dialog.ShowModal(); + MyDialog *dialog = new MyDialog( this ); + dialog->ShowModal(); + dialog->Close( TRUE ); }; void MyFrame::OnFontDialog( wxCommandEvent &WXUNUSED(event) )