]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/toolbar/toolbar.cpp
added wxAdvanced
[wxWidgets.git] / samples / toolbar / toolbar.cpp
index 66aaa9f85e23c213f017f12b0b0f42ef48e279c3..407143684782e8cf1562085eb7f0f2ee94dc2c2e 100644 (file)
@@ -92,7 +92,7 @@ public:
             const wxString& title = _T("wxToolBar Sample"),
             const wxPoint& pos = wxDefaultPosition,
             const wxSize& size = wxDefaultSize,
-            long style = wxDEFAULT_FRAME_STYLE);
+            long style = wxDEFAULT_FRAME_STYLE|wxCLIP_CHILDREN|wxNO_FULL_REPAINT_ON_RESIZE);
 
     void RecreateToolbar();
 
@@ -233,7 +233,12 @@ bool MyApp::OnInit()
     // Create the main frame window
     MyFrame* frame = new MyFrame((wxFrame *) NULL, -1,
                                  _T("wxToolBar Sample"),
-                                 wxPoint(100, 100), wxSize(550, 300));
+#ifdef __WXWINCE__
+                                 wxPoint(0, 0), wxDefaultSize, wxNO_BORDER
+#else
+                                 wxPoint(100, 100), wxSize(550, 300)
+#endif
+                                 );
 
     frame->Show(TRUE);
 
@@ -246,6 +251,12 @@ bool MyApp::OnInit()
 
 void MyFrame::RecreateToolbar()
 {
+#ifdef __WXWINCE__
+    // On Windows CE, we should not delete the
+    // previous toolbar in case it contains the menubar.
+    // We'll try to accomodate this usage in due course.
+    wxToolBar* toolBar = CreateToolBar();
+#else
     // delete and recreate the toolbar
     wxToolBarBase *toolBar = GetToolBar();
     long style = toolBar ? toolBar->GetWindowStyle() : TOOLBAR_STYLE;
@@ -256,8 +267,10 @@ void MyFrame::RecreateToolbar()
 
     style &= ~(wxTB_HORIZONTAL | wxTB_VERTICAL);
     style |= m_horzToolbar ? wxTB_HORIZONTAL : wxTB_VERTICAL;
+    style |= wxNO_FULL_REPAINT_ON_RESIZE ;
 
     toolBar = CreateToolBar(style, ID_TOOLBAR);
+#endif
 
     // Set up toolbar
     wxBitmap toolBarBitmaps[8];
@@ -298,8 +311,8 @@ void MyFrame::RecreateToolbar()
     toolBar->AddTool(wxID_NEW, _T("New"), toolBarBitmaps[0], _T("New file"));
     toolBar->AddTool(wxID_OPEN, _T("Open"), toolBarBitmaps[1], _T("Open file"));
 
-    // neither the generic nor Motif native toolbars really support this
-#if (wxUSE_TOOLBAR_NATIVE && !USE_GENERIC_TBAR) && !defined(__WXMOTIF__) && !defined(__WXX11__)
+    // the generic toolbar doesn't really support this
+#if (wxUSE_TOOLBAR_NATIVE && !USE_GENERIC_TBAR) && !defined(__WXX11__) || defined(__WXUNIVERSAL__)
     // adding a combo to a vertical toolbar is not very smart
     if ( m_horzToolbar )
     {
@@ -349,8 +362,10 @@ MyFrame::MyFrame(wxFrame* parent,
     m_rows = 1;
     m_nPrint = 1;
 
+#ifndef __WXWINCE__
     // Give it a status line
     CreateStatusBar();
+#endif
 
     // Give it an icon
     SetIcon(wxICON(mondrian));
@@ -532,8 +547,13 @@ void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
     Close(TRUE);
 }
 
-void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
+void MyFrame::OnAbout(wxCommandEvent& event)
 {
+    if ( event.IsChecked() )
+        m_textWindow->WriteText( _T("Help button down now.\n") );
+    else
+        m_textWindow->WriteText( _T("Help button up now.\n") );
+
     (void)wxMessageBox(_T("wxWindows toolbar sample"), _T("About wxToolBar"));
 }
 
@@ -543,14 +563,6 @@ void MyFrame::OnToolLeftClick(wxCommandEvent& event)
     str.Printf( _T("Clicked on tool %d\n"), event.GetId());
     m_textWindow->WriteText( str );
 
-    if (event.GetId() == wxID_HELP)
-    {
-        if ( event.GetExtraLong() != 0 )
-            m_textWindow->WriteText( _T("Help button down now.\n") );
-        else
-            m_textWindow->WriteText( _T("Help button up now.\n") );
-    }
-
     if (event.GetId() == wxID_COPY)
     {
         DoEnablePrint();
@@ -600,7 +612,8 @@ void MyFrame::DoToggleHelp()
 
 void MyFrame::OnUpdateCopyAndCut(wxUpdateUIEvent& event)
 {
-    event.Enable( m_textWindow->CanCopy() );
+    if (m_textWindow)
+        event.Enable( m_textWindow->CanCopy() );
 }
 
 void MyFrame::OnChangeToolTip(wxCommandEvent& WXUNUSED(event))