X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/47908e25f992135fbc8c9573870784c62654e9e9..f0824a5a4a255989b5153945ade9e21232724980:/samples/toolbar/test.cpp diff --git a/samples/toolbar/test.cpp b/samples/toolbar/test.cpp index 842dbea3da..69bbfe4173 100644 --- a/samples/toolbar/test.cpp +++ b/samples/toolbar/test.cpp @@ -21,9 +21,11 @@ #endif #include "wx/toolbar.h" +#include + #include "test.h" -#ifdef __WXGTK__ +#if defined(__WXGTK__) || defined(__WXMOTIF__) #include "mondrian.xpm" #include "bitmaps/new.xpm" #include "bitmaps/open.xpm" @@ -38,24 +40,19 @@ IMPLEMENT_APP(MyApp) - // The `main program' equivalent, creating the windows and returning the // main frame bool MyApp::OnInit(void) { // Create the main frame window - MyFrame* frame = new MyFrame(NULL, -1, "wxToolBar Sample", + MyFrame* frame = new MyFrame((wxFrame *) NULL, -1, (const wxString) "wxToolBar Sample", wxPoint(100, 100), wxSize(450, 300)); // Give it a status line frame->CreateStatusBar(); // Give it an icon -#ifdef __WXMSW__ - frame->SetIcon(wxIcon("mondrian")); -#else - frame->SetIcon( wxIcon(mondrian_xpm) ); -#endif + frame->SetIcon(wxICON(mondrian)); // Make a menubar wxMenu *fileMenu = new wxMenu; @@ -79,7 +76,8 @@ bool MyApp::OnInit(void) // Force a resize. This should probably be replaced by a call to a wxFrame // function that lays out default decorations and the remaining content window. - frame->OnSize(wxSizeEvent(wxSize(-1, -1), frame->GetId())); + wxSizeEvent event(wxSize(-1, -1), frame->GetId()); + frame->OnSize(event); frame->Show(TRUE); frame->SetStatusText("Hello, wxWindows"); @@ -91,8 +89,6 @@ bool MyApp::OnInit(void) bool MyApp::InitToolbar(wxToolBar* toolBar) { - toolBar->SetMargins(5, 5); - // Set up toolbar wxBitmap* toolBarBitmaps[8]; @@ -124,24 +120,24 @@ bool MyApp::InitToolbar(wxToolBar* toolBar) #endif int currentX = 5; - toolBar->AddTool(wxID_NEW, *(toolBarBitmaps[0]), wxNullBitmap, FALSE, (float)currentX, -1, NULL, "New file"); + toolBar->AddTool(wxID_NEW, *(toolBarBitmaps[0]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "New file"); currentX += width + 5; - toolBar->AddTool(wxID_OPEN, *(toolBarBitmaps[1]), wxNullBitmap, FALSE, (float)currentX, -1, NULL, "Open file"); + toolBar->AddTool(wxID_OPEN, *(toolBarBitmaps[1]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Open file"); currentX += width + 5; - toolBar->AddTool(wxID_SAVE, *(toolBarBitmaps[2]), wxNullBitmap, FALSE, (float)currentX, -1, NULL, "Save file"); + toolBar->AddTool(wxID_SAVE, *(toolBarBitmaps[2]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Save file"); currentX += width + 5; toolBar->AddSeparator(); - toolBar->AddTool(wxID_COPY, *(toolBarBitmaps[3]), wxNullBitmap, FALSE, (float)currentX, -1, NULL, "Copy"); + toolBar->AddTool(wxID_COPY, *(toolBarBitmaps[3]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Copy"); currentX += width + 5; - toolBar->AddTool(wxID_CUT, *(toolBarBitmaps[4]), wxNullBitmap, FALSE, (float)currentX, -1, NULL, "Cut"); + toolBar->AddTool(wxID_CUT, *(toolBarBitmaps[4]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Cut"); currentX += width + 5; - toolBar->AddTool(wxID_PASTE, *(toolBarBitmaps[5]), wxNullBitmap, FALSE, (float)currentX, -1, NULL, "Paste"); + toolBar->AddTool(wxID_PASTE, *(toolBarBitmaps[5]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Paste"); currentX += width + 5; toolBar->AddSeparator(); - toolBar->AddTool(wxID_PRINT, *(toolBarBitmaps[6]), wxNullBitmap, FALSE, (float)currentX, -1, NULL, "Print"); + toolBar->AddTool(wxID_PRINT, *(toolBarBitmaps[6]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Print"); currentX += width + 5; toolBar->AddSeparator(); - toolBar->AddTool(wxID_HELP, *(toolBarBitmaps[7]), wxNullBitmap, FALSE, currentX, -1, NULL, "Help"); + toolBar->AddTool(wxID_HELP, *(toolBarBitmaps[7]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Help"); toolBar->Realize(); @@ -160,13 +156,13 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame) EVT_MENU(wxID_HELP, MyFrame::OnAbout) EVT_CLOSE(MyFrame::OnCloseWindow) EVT_TOOL_RANGE(wxID_OPEN, wxID_PASTE, MyFrame::OnToolLeftClick) - EVT_TOOL_ENTER(ID_TOOLBAR, MyFrame::OnToolEnter) + EVT_TOOL_ENTER(wxID_OPEN, MyFrame::OnToolEnter) 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) + wxFrame(parent, id, title, pos, size, style), m_timer(this) { m_textWindow = new wxTextCtrl(this, -1, "", wxPoint(0, 0), wxSize(-1, -1), wxTE_MULTILINE); } @@ -178,7 +174,10 @@ void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event)) { - (void)wxMessageBox("wxWindows wxToolBar demo\n", "About wxToolBar"); +// (void)wxMessageBox("wxWindows wxToolBar demo\n", "About wxToolBar"); + wxLogStatus("Started timer."); + + m_timer.Start(500, TRUE); } // Define the behaviour for the frame closing