diff --git a/common/widgets/bitmap_button.cpp b/common/widgets/bitmap_button.cpp index aaa28e0944..86cb22f509 100644 --- a/common/widgets/bitmap_button.cpp +++ b/common/widgets/bitmap_button.cpp @@ -115,24 +115,36 @@ void BITMAP_BUTTON::AcceptDragInAsClick( bool aAcceptDragIn ) void BITMAP_BUTTON::OnMouseLeave( wxEvent& aEvent ) { - clearFlag( wxCONTROL_CURRENT | wxCONTROL_PRESSED ); - Refresh(); + if( hasFlag( wxCONTROL_CURRENT | wxCONTROL_PRESSED ) ) + { + clearFlag( wxCONTROL_CURRENT | wxCONTROL_PRESSED ); + Refresh(); + } + aEvent.Skip(); } void BITMAP_BUTTON::OnMouseEnter( wxEvent& aEvent ) { - setFlag( wxCONTROL_CURRENT ); - Refresh(); + if( !hasFlag( wxCONTROL_CURRENT ) ) + { + setFlag( wxCONTROL_CURRENT ); + Refresh(); + } + aEvent.Skip(); } void BITMAP_BUTTON::OnKillFocus( wxEvent& aEvent ) { - clearFlag( wxCONTROL_FOCUSED ); - Refresh(); + if( hasFlag( wxCONTROL_FOCUSED | wxCONTROL_CURRENT | wxCONTROL_PRESSED ) ) + { + clearFlag( wxCONTROL_FOCUSED | wxCONTROL_CURRENT | wxCONTROL_PRESSED ); + Refresh(); + } + aEvent.Skip(); } @@ -140,9 +152,14 @@ void BITMAP_BUTTON::OnKillFocus( wxEvent& aEvent ) void BITMAP_BUTTON::OnSetFocus( wxEvent& aEvent ) { if( !hasFlag( wxCONTROL_CHECKABLE ) ) - setFlag( wxCONTROL_FOCUSED ); + { + if( !hasFlag( wxCONTROL_FOCUSED ) ) + { + setFlag( wxCONTROL_FOCUSED ); + Refresh(); + } + } - Refresh(); aEvent.Skip(); } @@ -288,12 +305,17 @@ bool BITMAP_BUTTON::Enable( bool aEnable ) wxPanel::Enable( aEnable ); - if( aEnable ) + if( aEnable && hasFlag( wxCONTROL_DISABLED ) ) + { clearFlag( wxCONTROL_DISABLED ); - else - setFlag( wxCONTROL_DISABLED ); + Refresh(); + } - Refresh(); + if( !aEnable && !hasFlag( wxCONTROL_DISABLED ) ) + { + setFlag( wxCONTROL_DISABLED ); + Refresh(); + } return true; } @@ -323,12 +345,17 @@ void BITMAP_BUTTON::Check( bool aCheck ) { wxASSERT_MSG( hasFlag( wxCONTROL_CHECKABLE ), "Button is not a checkButton." ); - if( aCheck ) + if( aCheck && !hasFlag( wxCONTROL_CHECKED ) ) + { setFlag( wxCONTROL_CHECKED ); - else - clearFlag( wxCONTROL_CHECKED ); + Refresh(); + } - Refresh(); + if( !aCheck && hasFlag( wxCONTROL_CHECKED ) ) + { + clearFlag( wxCONTROL_CHECKED ); + Refresh(); + } } diff --git a/common/widgets/split_button.cpp b/common/widgets/split_button.cpp index 01ff174da1..6a9fb74e72 100644 --- a/common/widgets/split_button.cpp +++ b/common/widgets/split_button.cpp @@ -103,8 +103,11 @@ void SPLIT_BUTTON::SetBitmap( const wxBitmap& aBmp ) void SPLIT_BUTTON::SetLabel( const wxString& aLabel ) { - m_label = aLabel; - Refresh(); + if( m_label != aLabel ) + { + m_label = aLabel; + Refresh(); + } } @@ -116,9 +119,12 @@ wxMenu* SPLIT_BUTTON::GetSplitButtonMenu() void SPLIT_BUTTON::OnKillFocus( wxFocusEvent& aEvent ) { - m_stateButton = wxCONTROL_CURRENT; - m_stateMenu = wxCONTROL_CURRENT; - Refresh(); + if( m_stateButton != 0 || m_stateMenu != 0 ) + { + m_stateButton = 0; + m_stateMenu = 0; + Refresh(); + } aEvent.Skip(); } @@ -126,9 +132,12 @@ void SPLIT_BUTTON::OnKillFocus( wxFocusEvent& aEvent ) void SPLIT_BUTTON::OnMouseLeave( wxMouseEvent& aEvent ) { - m_stateButton = 0; - m_stateMenu = 0; - Refresh(); + if( m_stateButton != 0 || m_stateMenu != 0 ) + { + m_stateButton = 0; + m_stateMenu = 0; + Refresh(); + } aEvent.Skip(); } @@ -136,9 +145,12 @@ void SPLIT_BUTTON::OnMouseLeave( wxMouseEvent& aEvent ) void SPLIT_BUTTON::OnMouseEnter( wxMouseEvent& aEvent ) { - m_stateButton = wxCONTROL_CURRENT; - m_stateMenu = wxCONTROL_CURRENT; - Refresh(); + if( m_stateButton != wxCONTROL_CURRENT || m_stateMenu != wxCONTROL_CURRENT ) + { + m_stateButton = wxCONTROL_CURRENT; + m_stateMenu = wxCONTROL_CURRENT; + Refresh(); + } aEvent.Skip(); } @@ -313,18 +325,21 @@ bool SPLIT_BUTTON::Enable( bool aEnable ) m_bIsEnable = aEnable; wxPanel::Enable( m_bIsEnable ); - if( m_bIsEnable ) + if( m_bIsEnable + && ( m_stateButton == wxCONTROL_DISABLED || m_stateMenu == wxCONTROL_DISABLED ) ) { m_stateButton = 0; m_stateMenu = 0; + Refresh(); } - else + + if( !m_bIsEnable + && ( m_stateButton != wxCONTROL_DISABLED || m_stateMenu != wxCONTROL_DISABLED ) ) { m_stateButton = wxCONTROL_DISABLED; m_stateMenu = wxCONTROL_DISABLED; + Refresh(); } - Refresh(); - return aEnable; } diff --git a/common/widgets/std_bitmap_button.cpp b/common/widgets/std_bitmap_button.cpp index affba224a7..d079f75e23 100644 --- a/common/widgets/std_bitmap_button.cpp +++ b/common/widgets/std_bitmap_button.cpp @@ -83,8 +83,11 @@ void STD_BITMAP_BUTTON::SetBitmap( const wxBitmap& aBmp ) void STD_BITMAP_BUTTON::OnKillFocus( wxFocusEvent& aEvent ) { - m_stateButton = wxCONTROL_CURRENT; - Refresh(); + if( m_stateButton != 0 ) + { + m_stateButton = 0; + Refresh(); + } aEvent.Skip(); } @@ -92,8 +95,11 @@ void STD_BITMAP_BUTTON::OnKillFocus( wxFocusEvent& aEvent ) void STD_BITMAP_BUTTON::OnMouseLeave( wxMouseEvent& aEvent ) { - m_stateButton = 0; - Refresh(); + if( m_stateButton != 0 ) + { + m_stateButton = 0; + Refresh(); + } aEvent.Skip(); } @@ -101,8 +107,11 @@ void STD_BITMAP_BUTTON::OnMouseLeave( wxMouseEvent& aEvent ) void STD_BITMAP_BUTTON::OnMouseEnter( wxMouseEvent& aEvent ) { - m_stateButton = wxCONTROL_CURRENT; - Refresh(); + if( m_stateButton != wxCONTROL_CURRENT ) + { + m_stateButton = wxCONTROL_CURRENT; + Refresh(); + } aEvent.Skip(); } @@ -213,12 +222,17 @@ bool STD_BITMAP_BUTTON::Enable( bool aEnable ) m_bIsEnable = aEnable; wxPanel::Enable( m_bIsEnable ); - if( m_bIsEnable ) + if( m_bIsEnable && m_stateButton == wxCONTROL_DISABLED ) + { m_stateButton = 0; - else - m_stateButton = wxCONTROL_DISABLED; + Refresh(); + } - Refresh(); + if( !m_bIsEnable && m_stateButton != wxCONTROL_DISABLED ) + { + m_stateButton = wxCONTROL_DISABLED; + Refresh(); + } return aEnable; }