Suppressed some flicker in standard wxToolBar
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@22410 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
a9d3371aec
commit
229de929f3
@ -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))
|
||||
|
@ -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__
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user