X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f81ccc1148c5a1f4ca14e2ad25280f7a6731593c..36a0190ebd5bd9a7302f60f6dcd608b80574e21c:/src/generic/treelist.cpp?ds=inline diff --git a/src/generic/treelist.cpp b/src/generic/treelist.cpp index f7aca4aabb..4d249c2cb5 100644 --- a/src/generic/treelist.cpp +++ b/src/generic/treelist.cpp @@ -3,7 +3,6 @@ // Purpose: Generic wxTreeListCtrl implementation. // Author: Vadim Zeitlin // Created: 2011-08-19 -// RCS-ID: $Id: wxhead.cpp,v 1.11 2010-04-22 12:44:51 zeitlin Exp $ // Copyright: (c) 2011 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -758,7 +757,12 @@ const wxString& wxTreeListModel::GetItemText(Node* item, unsigned col) const // empty string we can return reference to. wxCHECK_MSG( item, m_root->m_text, "Invalid item" ); - return col == 0 ? item->m_text : item->GetColumnText(col); + // Notice that asking for the text of a column of an item that doesn't have + // any column texts is not an error so we simply return an empty string in + // this case. + return col == 0 ? item->m_text + : item->HasColumnsTexts() ? item->GetColumnText(col) + : m_root->m_text; } void wxTreeListModel::SetItemText(Node* item, unsigned col, const wxString& text) @@ -1024,10 +1028,14 @@ bool wxTreeListCtrl::Create(wxWindow* parent, } m_view = new wxDataViewCtrl; + long styleDataView = HasFlag(wxTL_MULTIPLE) ? wxDV_MULTIPLE + : wxDV_SINGLE; + if ( HasFlag(wxTL_NO_HEADER) ) + styleDataView |= wxDV_NO_HEADER; + if ( !m_view->Create(this, wxID_ANY, wxPoint(0, 0), GetClientSize(), - HasFlag(wxTL_MULTIPLE) ? wxDV_MULTIPLE - : wxDV_SINGLE) ) + styleDataView) ) { delete m_view; m_view = NULL; @@ -1556,7 +1564,7 @@ void wxTreeListCtrl::SendColumnEvent(wxEventType evt, wxDataViewEvent& eventDV) void wxTreeListCtrl::OnItemToggled(wxTreeListItem item, wxCheckBoxState stateOld) { - wxTreeListEvent event(wxEVT_COMMAND_TREELIST_ITEM_CHECKED, this, item); + wxTreeListEvent event(wxEVT_TREELIST_ITEM_CHECKED, this, item); event.SetOldCheckedState(stateOld); ProcessWindowEvent(event); @@ -1564,32 +1572,32 @@ wxTreeListCtrl::OnItemToggled(wxTreeListItem item, wxCheckBoxState stateOld) void wxTreeListCtrl::OnSelectionChanged(wxDataViewEvent& event) { - SendItemEvent(wxEVT_COMMAND_TREELIST_SELECTION_CHANGED, event); + SendItemEvent(wxEVT_TREELIST_SELECTION_CHANGED, event); } void wxTreeListCtrl::OnItemExpanding(wxDataViewEvent& event) { - SendItemEvent(wxEVT_COMMAND_TREELIST_ITEM_EXPANDING, event); + SendItemEvent(wxEVT_TREELIST_ITEM_EXPANDING, event); } void wxTreeListCtrl::OnItemExpanded(wxDataViewEvent& event) { - SendItemEvent(wxEVT_COMMAND_TREELIST_ITEM_EXPANDED, event); + SendItemEvent(wxEVT_TREELIST_ITEM_EXPANDED, event); } void wxTreeListCtrl::OnItemActivated(wxDataViewEvent& event) { - SendItemEvent(wxEVT_COMMAND_TREELIST_ITEM_ACTIVATED, event); + SendItemEvent(wxEVT_TREELIST_ITEM_ACTIVATED, event); } void wxTreeListCtrl::OnItemContextMenu(wxDataViewEvent& event) { - SendItemEvent(wxEVT_COMMAND_TREELIST_ITEM_CONTEXT_MENU, event); + SendItemEvent(wxEVT_TREELIST_ITEM_CONTEXT_MENU, event); } void wxTreeListCtrl::OnColumnSorted(wxDataViewEvent& event) { - SendColumnEvent(wxEVT_COMMAND_TREELIST_COLUMN_SORTED, event); + SendColumnEvent(wxEVT_TREELIST_COLUMN_SORTED, event); } // ---------------------------------------------------------------------------- @@ -1657,7 +1665,7 @@ wxWindow* wxTreeListCtrl::GetView() const wxIMPLEMENT_DYNAMIC_CLASS(wxTreeListEvent, wxNotifyEvent) #define wxDEFINE_TREELIST_EVENT(name) \ - wxDEFINE_EVENT(wxEVT_COMMAND_TREELIST_##name, wxTreeListEvent) + wxDEFINE_EVENT(wxEVT_TREELIST_##name, wxTreeListEvent) wxDEFINE_TREELIST_EVENT(SELECTION_CHANGED); wxDEFINE_TREELIST_EVENT(ITEM_EXPANDING);