From ed9a7a63b811a49214bb97d41cb464d4877da5d7 Mon Sep 17 00:00:00 2001 From: Kevin Ollivier Date: Sun, 7 Jan 2007 01:15:20 +0000 Subject: [PATCH] Generic list and tree ctrl should not use the focused selection color when the top level window is not active. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@44108 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/generic/listctrl.cpp | 18 +++++++++++++++--- src/generic/treectlg.cpp | 8 ++++++-- src/mac/carbon/window.cpp | 15 +++++++++++++++ 3 files changed, 36 insertions(+), 5 deletions(-) diff --git a/src/generic/listctrl.cpp b/src/generic/listctrl.cpp index a7485c2a2e..c485403edb 100644 --- a/src/generic/listctrl.cpp +++ b/src/generic/listctrl.cpp @@ -1410,7 +1410,11 @@ bool wxListLineData::SetAttributes(wxDC *dc, if ( highlighted ) #ifdef __WXMAC__ { - if (m_owner->HasFocus()) + if (m_owner->HasFocus() +#ifdef __WXMAC__ + && IsControlActive( (ControlRef)m_owner->GetHandle() ) +#endif + ) colText = *wxWHITE; else colText = *wxBLACK; @@ -1470,7 +1474,11 @@ void wxListLineData::Draw( wxDC *dc ) if (highlighted) { int flags = wxCONTROL_SELECTED; - if (m_owner->HasFocus()) + if (m_owner->HasFocus() +#ifdef __WXMAC__ + && IsControlActive( (ControlRef)m_owner->GetHandle() ) +#endif + ) flags |= wxCONTROL_FOCUSED; wxRendererNative::Get().DrawItemSelectionRect( m_owner, *dc, m_gi->m_rectHighlight, flags ); @@ -1529,7 +1537,11 @@ void wxListLineData::DrawInReportMode( wxDC *dc, if (highlighted) { int flags = wxCONTROL_SELECTED; - if (m_owner->HasFocus()) + if (m_owner->HasFocus() +#ifdef __WXMAC__ + && IsControlActive( (ControlRef)m_owner->GetHandle() ) +#endif + ) flags |= wxCONTROL_FOCUSED; wxRendererNative::Get().DrawItemSelectionRect( m_owner, *dc, rectHL, flags ); } diff --git a/src/generic/treectlg.cpp b/src/generic/treectlg.cpp index 7b29dca54f..98097d6a8e 100644 --- a/src/generic/treectlg.cpp +++ b/src/generic/treectlg.cpp @@ -2232,7 +2232,11 @@ void wxGenericTreeCtrl::PaintItem(wxGenericTreeItem *item, wxDC& dc) else { int flags = wxCONTROL_SELECTED; - if (m_hasFocus) + if (m_hasFocus +#ifdef __WXMAC__ + && IsControlActive( (ControlRef)GetHandle() ) +#endif + ) flags |= wxCONTROL_FOCUSED; if ((item == m_current) && (m_hasFocus)) flags |= wxCONTROL_CURRENT; @@ -2374,7 +2378,7 @@ void wxGenericTreeCtrl::PaintLevel( wxGenericTreeItem *item, wxDC &dc, int level // rectangle, so we want to make sure that the text is visible // against the normal background, not the highlightbackground, so // don't use the highlight text colour unless we have the focus. - && m_hasFocus + && m_hasFocus && IsControlActive( (ControlRef)GetHandle() ) #endif ) { diff --git a/src/mac/carbon/window.cpp b/src/mac/carbon/window.cpp index 5764a89abf..b8a268cd53 100644 --- a/src/mac/carbon/window.cpp +++ b/src/mac/carbon/window.cpp @@ -33,6 +33,8 @@ #include "wx/layout.h" #include "wx/statusbr.h" #include "wx/menuitem.h" + #include "wx/treectrl.h" + #include "wx/listctrl.h" #endif #include "wx/tooltip.h" @@ -167,6 +169,9 @@ static const EventTypeSpec eventList[] = { kEventClassControl , kEventControlVisibilityChanged } , { kEventClassControl , kEventControlEnabledStateChanged } , { kEventClassControl , kEventControlHiliteChanged } , + + { kEventClassControl , kEventControlActivate } , + { kEventClassControl , kEventControlDeactivate } , #endif { kEventClassControl , kEventControlSetFocusPart } , @@ -294,6 +299,16 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl case kEventControlHiliteChanged : thisWindow->MacHiliteChanged() ; break ; + + case kEventControlActivate : + case kEventControlDeactivate : + if ( thisWindow->IsKindOf( CLASSINFO( wxTreeCtrl ) ) + || thisWindow->IsKindOf( CLASSINFO( wxListCtrl ) ) + ) + thisWindow->Refresh(); + + //thisWindow->MacActivateStateChanged() ; + break ; #endif // we emulate this event under Carbon CFM -- 2.45.2