]> git.saurik.com Git - wxWidgets.git/commitdiff
Suppressed some flicker in standard wxToolBar
authorJulian Smart <julian@anthemion.co.uk>
Thu, 31 Jul 2003 11:33:39 +0000 (11:33 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Thu, 31 Jul 2003 11:33:39 +0000 (11:33 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@22410 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

samples/toolbar/toolbar.cpp
src/msw/frame.cpp
src/msw/tbar95.cpp

index cda93e9e868f18b3dd2c21af6e7d29efe555c3e8..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();
 
@@ -267,6 +267,7 @@ 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
@@ -611,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))
index 0d51775ff855cc6bf8a837077f2e5a9a7a94ac74..62e85fbec7b6e3f88b5f8fae227bec6c4f728d15 100644 (file)
@@ -474,23 +474,63 @@ void wxFrame::PositionToolBar()
         }
 #endif // wxUSE_STATUSBAR
 
+        int tx, ty;
         int tw, th;
+        toolbar->GetPosition(&tx, &ty);
         toolbar->GetSize(&tw, &th);
+        
+        // Adjust
+        if (ty < 0 && (-ty == th))
+            ty = 0;
+        if (tx < 0 && (-tx == tw))
+            tx = 0;        
+        
+        int desiredW = tw;
+        int desiredH = th;
 
         if ( toolbar->GetWindowStyleFlag() & wxTB_VERTICAL )
         {
-            th = height;
+            desiredH = height;
         }
         else
         {
-            tw = width;
-            if ( toolbar->GetWindowStyleFlag() & wxTB_FLAT )
-                th -= 3;
-        }
+            desiredW = width;
+//            if ( toolbar->GetWindowStyleFlag() & wxTB_FLAT )
+//                desiredW -= 3;
+        }        
 
         // use the 'real' MSW position here, don't offset relativly to the
         // client area origin
-        toolbar->SetSize(0, 0, tw, th, wxSIZE_NO_ADJUSTMENTS);
+
+        // Optimise such that we don't have to always resize the toolbar
+        // when the frame changes, otherwise we'll get a lot of flicker.        
+        bool heightChanging = TRUE;
+        bool widthChanging = TRUE;
+        
+        if ( toolbar->GetWindowStyleFlag() & wxTB_VERTICAL )
+        {
+            // It's OK if the current height is greater than what can be shown.
+            heightChanging = (desiredH > th) ;
+            widthChanging = (desiredW != tw) ;
+            
+            // The next time around, we may not have to set the size            
+            if (heightChanging)
+                desiredH = desiredH + 200;
+        }
+        else
+        {
+            // It's OK if the current width is greater than what can be shown.
+            widthChanging = (desiredW > tw) ;
+            heightChanging = (desiredH != th) ;
+
+            // The next time around, we may not have to set the size            
+            if (widthChanging)
+                desiredW = desiredW + 200;
+        }
+        
+        if (tx != 0 || ty != 0 || widthChanging || heightChanging)
+            toolbar->SetSize(0, 0, desiredW, desiredH, wxSIZE_NO_ADJUSTMENTS);
+        
 #endif // __WXWINCE__
     }
 }
index 0307c1eff2e9197a8f4045bc9fac838ffbbf8331..f6fd243ceb1754cfdf7a16353892b920de7f8d32 100644 (file)
@@ -1311,6 +1311,10 @@ bool wxToolBar::HandlePaint(WXWPARAM wParam, WXLPARAM lParam)
                 {
                     // yes, do erase it!
                     dc.DrawRectangle(rectItem);
+                    
+                    // Necessary in case we use a no-paint-on-size
+                    // style in the parent: the controls can disappear
+                    control->Refresh(FALSE);
                 }
             }
         }