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
This commit is contained in:
Vadim Zeitlin
2008-02-12 23:06:09 +00:00
parent 522a028a17
commit 6621957fe2
2 changed files with 17 additions and 21 deletions

View File

@@ -175,10 +175,15 @@ enum wxTreeItemIcon
#define wxTR_FULL_ROW_HIGHLIGHT 0x2000 // highlight full horz space #define wxTR_FULL_ROW_HIGHLIGHT 0x2000 // highlight full horz space
#ifdef __WXGTK20__ // make the default control appearance look more native-like depending on the
#define wxTR_DEFAULT_STYLE (wxTR_HAS_BUTTONS | wxTR_NO_LINES) // 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 #else
#define wxTR_DEFAULT_STYLE (wxTR_HAS_BUTTONS | wxTR_LINES_AT_ROOT) #define wxTR_DEFAULT_STYLE (wxTR_HAS_BUTTONS | wxTR_LINES_AT_ROOT)
#endif #endif
#if WXWIN_COMPATIBILITY_2_6 #if WXWIN_COMPATIBILITY_2_6

View File

@@ -93,7 +93,7 @@ public:
wxTreeTextCtrl(wxGenericTreeCtrl *owner, wxGenericTreeItem *item); wxTreeTextCtrl(wxGenericTreeCtrl *owner, wxGenericTreeItem *item);
void EndEdit( bool discardChanges ); void EndEdit( bool discardChanges );
const wxGenericTreeItem* item() const { return m_itemEdited; } const wxGenericTreeItem* item() const { return m_itemEdited; }
protected: protected:
@@ -387,11 +387,11 @@ wxTreeTextCtrl::wxTreeTextCtrl(wxGenericTreeCtrl *owner,
void wxTreeTextCtrl::EndEdit(bool discardChanges) void wxTreeTextCtrl::EndEdit(bool discardChanges)
{ {
m_aboutToFinish = true; m_aboutToFinish = true;
if ( discardChanges ) if ( discardChanges )
{ {
m_owner->OnRenameCancelled(m_itemEdited); m_owner->OnRenameCancelled(m_itemEdited);
Finish( true ); Finish( true );
} }
else else
@@ -485,7 +485,7 @@ void wxTreeTextCtrl::OnKillFocus( wxFocusEvent &event )
{ {
if ( !AcceptChanges() ) if ( !AcceptChanges() )
m_owner->OnRenameCancelled( m_itemEdited ); m_owner->OnRenameCancelled( m_itemEdited );
Finish( false ); Finish( false );
} }
@@ -802,21 +802,12 @@ bool wxGenericTreeCtrl::Create(wxWindow *parent,
const wxString& name ) const wxString& name )
{ {
#ifdef __WXMAC__ #ifdef __WXMAC__
int major,minor; int major, minor;
wxGetOsVersion( &major, &minor ); wxGetOsVersion(&major, &minor);
style &= ~wxTR_LINES_AT_ROOT;
style |= wxTR_NO_LINES;
if (major < 10) if (major < 10)
style |= wxTR_ROW_LINES; style |= wxTR_ROW_LINES;
if (style == 0 || style & wxTR_DEFAULT_STYLE)
style |= wxTR_FULL_ROW_HIGHLIGHT;
#endif // __WXMAC__ #endif // __WXMAC__
#ifdef __WXGTK20__
style |= wxTR_NO_LINES;
#endif
if ( !wxControl::Create( parent, id, pos, size, if ( !wxControl::Create( parent, id, pos, size,
style|wxHSCROLL|wxVSCROLL, style|wxHSCROLL|wxVSCROLL,
@@ -1906,7 +1897,7 @@ void wxGenericTreeCtrl::SelectItem(const wxTreeItemId& itemId, bool select)
{ {
wxGenericTreeItem *item = (wxGenericTreeItem*) itemId.m_pItem; wxGenericTreeItem *item = (wxGenericTreeItem*) itemId.m_pItem;
wxCHECK_RET( item, wxT("SelectItem(): invalid tree item") ); wxCHECK_RET( item, wxT("SelectItem(): invalid tree item") );
wxTreeEvent event(wxEVT_COMMAND_TREE_SEL_CHANGING, this, item); wxTreeEvent event(wxEVT_COMMAND_TREE_SEL_CHANGING, this, item);
if ( GetEventHandler()->ProcessEvent( event ) && !event.IsAllowed() ) if ( GetEventHandler()->ProcessEvent( event ) && !event.IsAllowed() )
return; return;
@@ -2264,7 +2255,7 @@ void wxGenericTreeCtrl::PaintItem(wxGenericTreeItem *item, wxDC& dc)
#else #else
rect.x -= 1; rect.x -= 1;
rect.width += 2; rect.width += 2;
int flags = wxCONTROL_SELECTED; int flags = wxCONTROL_SELECTED;
if (m_hasFocus) if (m_hasFocus)
flags |= wxCONTROL_FOCUSED; flags |= wxCONTROL_FOCUSED;
@@ -2291,7 +2282,7 @@ void wxGenericTreeCtrl::PaintItem(wxGenericTreeItem *item, wxDC& dc)
{ {
rect.x -= 1; rect.x -= 1;
rect.width += 2; rect.width += 2;
int flags = wxCONTROL_SELECTED; int flags = wxCONTROL_SELECTED;
if (m_hasFocus) if (m_hasFocus)
flags |= wxCONTROL_FOCUSED; flags |= wxCONTROL_FOCUSED;