From 6621957fe205da0518e56bb47dd5074eb870d35e Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 12 Feb 2008 23:06:09 +0000 Subject: [PATCH] use platform-specific styles in xTR_DEFAULT_STYLE but don't impose them forcefully in wxGenericTreeCtrl ctor as this prevents people from using them even if they explicitly want to do it git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@51744 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/treebase.h | 11 ++++++++--- src/generic/treectlg.cpp | 27 +++++++++------------------ 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/include/wx/treebase.h b/include/wx/treebase.h index 1d582f3e6e..54582f8a0b 100644 --- a/include/wx/treebase.h +++ b/include/wx/treebase.h @@ -175,10 +175,15 @@ enum wxTreeItemIcon #define wxTR_FULL_ROW_HIGHLIGHT 0x2000 // highlight full horz space -#ifdef __WXGTK20__ -#define wxTR_DEFAULT_STYLE (wxTR_HAS_BUTTONS | wxTR_NO_LINES) +// make the default control appearance look more native-like depending on the +// platform +#if defined(__WXGTK20__) + #define wxTR_DEFAULT_STYLE (wxTR_HAS_BUTTONS | wxTR_NO_LINES) +#elif defined(__WXMAC__) + #define wxTR_DEFAULT_STYLE \ + (wxTR_HAS_BUTTONS | wxTR_NO_LINES | wxTR_FULL_ROW_HIGHLIGHT) #else -#define wxTR_DEFAULT_STYLE (wxTR_HAS_BUTTONS | wxTR_LINES_AT_ROOT) + #define wxTR_DEFAULT_STYLE (wxTR_HAS_BUTTONS | wxTR_LINES_AT_ROOT) #endif #if WXWIN_COMPATIBILITY_2_6 diff --git a/src/generic/treectlg.cpp b/src/generic/treectlg.cpp index 400b96f239..65a7ffa574 100644 --- a/src/generic/treectlg.cpp +++ b/src/generic/treectlg.cpp @@ -93,7 +93,7 @@ public: wxTreeTextCtrl(wxGenericTreeCtrl *owner, wxGenericTreeItem *item); void EndEdit( bool discardChanges ); - + const wxGenericTreeItem* item() const { return m_itemEdited; } protected: @@ -387,11 +387,11 @@ wxTreeTextCtrl::wxTreeTextCtrl(wxGenericTreeCtrl *owner, void wxTreeTextCtrl::EndEdit(bool discardChanges) { m_aboutToFinish = true; - + if ( discardChanges ) { m_owner->OnRenameCancelled(m_itemEdited); - + Finish( true ); } else @@ -485,7 +485,7 @@ void wxTreeTextCtrl::OnKillFocus( wxFocusEvent &event ) { if ( !AcceptChanges() ) m_owner->OnRenameCancelled( m_itemEdited ); - + Finish( false ); } @@ -802,21 +802,12 @@ bool wxGenericTreeCtrl::Create(wxWindow *parent, const wxString& name ) { #ifdef __WXMAC__ - int major,minor; - wxGetOsVersion( &major, &minor ); + int major, minor; + wxGetOsVersion(&major, &minor); - style &= ~wxTR_LINES_AT_ROOT; - style |= wxTR_NO_LINES; if (major < 10) style |= wxTR_ROW_LINES; - - if (style == 0 || style & wxTR_DEFAULT_STYLE) - style |= wxTR_FULL_ROW_HIGHLIGHT; - #endif // __WXMAC__ -#ifdef __WXGTK20__ - style |= wxTR_NO_LINES; -#endif if ( !wxControl::Create( parent, id, pos, size, style|wxHSCROLL|wxVSCROLL, @@ -1906,7 +1897,7 @@ void wxGenericTreeCtrl::SelectItem(const wxTreeItemId& itemId, bool select) { wxGenericTreeItem *item = (wxGenericTreeItem*) itemId.m_pItem; wxCHECK_RET( item, wxT("SelectItem(): invalid tree item") ); - + wxTreeEvent event(wxEVT_COMMAND_TREE_SEL_CHANGING, this, item); if ( GetEventHandler()->ProcessEvent( event ) && !event.IsAllowed() ) return; @@ -2264,7 +2255,7 @@ void wxGenericTreeCtrl::PaintItem(wxGenericTreeItem *item, wxDC& dc) #else rect.x -= 1; rect.width += 2; - + int flags = wxCONTROL_SELECTED; if (m_hasFocus) flags |= wxCONTROL_FOCUSED; @@ -2291,7 +2282,7 @@ void wxGenericTreeCtrl::PaintItem(wxGenericTreeItem *item, wxDC& dc) { rect.x -= 1; rect.width += 2; - + int flags = wxCONTROL_SELECTED; if (m_hasFocus) flags |= wxCONTROL_FOCUSED; -- 2.45.2