X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/276f3938c4ae6420a05ad2a7667fdf79261c33d6..07aaf32633ecf18ec3edfbb41793a112914792d0:/src/generic/treelist.cpp diff --git a/src/generic/treelist.cpp b/src/generic/treelist.cpp index 8672b6e611..ff07cd4222 100644 --- a/src/generic/treelist.cpp +++ b/src/generic/treelist.cpp @@ -3,7 +3,7 @@ // 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 $ +// RCS-ID: $Id$ // Copyright: (c) 2011 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -549,23 +549,17 @@ public: } // Event handlers toggling the items checkbox if it was clicked. - virtual bool Activate(const wxRect& WXUNUSED(cell), - wxDataViewModel* model, - const wxDataViewItem& item, - unsigned int WXUNUSED(col)) - { - static_cast(model)->ToggleItem(item); - return true; - } - - virtual bool LeftClick(const wxPoint& pos, - const wxRect& WXUNUSED(cell), - wxDataViewModel* model, - const wxDataViewItem& item, - unsigned int WXUNUSED(col)) + virtual bool ActivateCell(const wxRect& WXUNUSED(cell), + wxDataViewModel *model, + const wxDataViewItem & item, + unsigned int WXUNUSED(col), + const wxMouseEvent *mouseEvent) { - if ( !wxRect(GetCheckSize()).Contains(pos) ) - return false; + if ( mouseEvent ) + { + if ( !wxRect(GetCheckSize()).Contains(mouseEvent->GetPosition()) ) + return false; + } static_cast(model)->ToggleItem(item); return true; @@ -764,7 +758,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) @@ -1030,10 +1029,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; @@ -1660,7 +1663,7 @@ wxWindow* wxTreeListCtrl::GetView() const // wxTreeListEvent implementation // ============================================================================ -wxIMPLEMENT_ABSTRACT_CLASS(wxTreeListEvent, wxNotifyEvent) +wxIMPLEMENT_DYNAMIC_CLASS(wxTreeListEvent, wxNotifyEvent) #define wxDEFINE_TREELIST_EVENT(name) \ wxDEFINE_EVENT(wxEVT_COMMAND_TREELIST_##name, wxTreeListEvent)