X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/591cc82deb5bc6dd0af6047ecfa7ce7cf4f8d859..8cbc59fe84f046685b873cf58f6c56debe59de1c:/src/common/datavcmn.cpp diff --git a/src/common/datavcmn.cpp b/src/common/datavcmn.cpp index 2bc6102f0f..74021deb98 100644 --- a/src/common/datavcmn.cpp +++ b/src/common/datavcmn.cpp @@ -18,20 +18,18 @@ #if wxUSE_DATAVIEWCTRL #include "wx/dataview.h" -#include "wx/spinctrl.h" -#include "wx/choice.h" - -#include "wx/weakref.h" -#include "wx/vector.h" #ifndef WX_PRECOMP #include "wx/dc.h" #include "wx/settings.h" #include "wx/log.h" - #include "wx/icon.h" #include "wx/crt.h" #endif +#include "wx/spinctrl.h" +#include "wx/choice.h" +#include "wx/imaglist.h" + const char wxDataViewCtrlNameStr[] = "dataviewCtrl"; @@ -896,19 +894,14 @@ const wxDataViewModel* wxDataViewCtrlBase::GetModel() const return m_model; } -bool wxDataViewCtrlBase::EnableDragSource( const wxDataFormat &WXUNUSED(format) ) -{ - return false; -} - void wxDataViewCtrlBase::ExpandAncestors( const wxDataViewItem & item ) { if (!m_model) return; - + if (!item.IsOk()) return; wxVector parentChain; - + // at first we get all the parents of the selected item wxDataViewItem parent = m_model->GetParent(item); while (parent.IsOk()) @@ -916,7 +909,7 @@ void wxDataViewCtrlBase::ExpandAncestors( const wxDataViewItem & item ) parentChain.push_back(parent); parent = m_model->GetParent(parent); } - + // then we expand the parents, starting at the root while (!parentChain.empty()) { @@ -1217,25 +1210,27 @@ wxDataViewCtrlBase::InsertColumn( unsigned int WXUNUSED(pos), wxDataViewColumn * IMPLEMENT_DYNAMIC_CLASS(wxDataViewEvent,wxNotifyEvent) -wxDEFINE_EVENT( wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED, wxDataViewEvent ) +wxDEFINE_EVENT( wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED, wxDataViewEvent ); -wxDEFINE_EVENT( wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED, wxDataViewEvent ) -wxDEFINE_EVENT( wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING, wxDataViewEvent ) -wxDEFINE_EVENT( wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED, wxDataViewEvent ) -wxDEFINE_EVENT( wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING, wxDataViewEvent ) -wxDEFINE_EVENT( wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED, wxDataViewEvent ) -wxDEFINE_EVENT( wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED, wxDataViewEvent ) -wxDEFINE_EVENT( wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE, wxDataViewEvent ) -wxDEFINE_EVENT( wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED, wxDataViewEvent ) +wxDEFINE_EVENT( wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED, wxDataViewEvent ); +wxDEFINE_EVENT( wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING, wxDataViewEvent ); +wxDEFINE_EVENT( wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED, wxDataViewEvent ); +wxDEFINE_EVENT( wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING, wxDataViewEvent ); +wxDEFINE_EVENT( wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED, wxDataViewEvent ); +wxDEFINE_EVENT( wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED, wxDataViewEvent ); +wxDEFINE_EVENT( wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE, wxDataViewEvent ); +wxDEFINE_EVENT( wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED, wxDataViewEvent ); -wxDEFINE_EVENT( wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU, wxDataViewEvent ) +wxDEFINE_EVENT( wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU, wxDataViewEvent ); -wxDEFINE_EVENT( wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK, wxDataViewEvent ) -wxDEFINE_EVENT( wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK, wxDataViewEvent ) -wxDEFINE_EVENT( wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED, wxDataViewEvent ) -wxDEFINE_EVENT( wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED, wxDataViewEvent ) +wxDEFINE_EVENT( wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK, wxDataViewEvent ); +wxDEFINE_EVENT( wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK, wxDataViewEvent ); +wxDEFINE_EVENT( wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED, wxDataViewEvent ); +wxDEFINE_EVENT( wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED, wxDataViewEvent ); -wxDEFINE_EVENT( wxEVT_COMMAND_DATAVIEW_ITEM_BEGIN_DRAG, wxDataViewEvent ) +wxDEFINE_EVENT( wxEVT_COMMAND_DATAVIEW_ITEM_BEGIN_DRAG, wxDataViewEvent ); +wxDEFINE_EVENT( wxEVT_COMMAND_DATAVIEW_ITEM_DROP_POSSIBLE, wxDataViewEvent ); +wxDEFINE_EVENT( wxEVT_COMMAND_DATAVIEW_ITEM_DROP, wxDataViewEvent ); // ------------------------------------- // wxDataViewSpinRenderer @@ -1401,13 +1396,13 @@ wxString wxDataViewListStore::GetColumnType( unsigned int pos ) const { return m_cols[pos]; } - + void wxDataViewListStore::AppendItem( const wxVector &values, wxClientData *data ) { wxDataViewListStoreLine *line = new wxDataViewListStoreLine( data ); line->m_values = values; m_data.push_back( line ); - + RowAppended(); } @@ -1416,7 +1411,7 @@ void wxDataViewListStore::PrependItem( const wxVector &values, wxClie wxDataViewListStoreLine *line = new wxDataViewListStoreLine( data ); line->m_values = values; m_data.insert( m_data.begin(), line ); - + RowPrepended(); } @@ -1425,7 +1420,7 @@ void wxDataViewListStore::InsertItem( unsigned int row, const wxVectorm_values = values; m_data.insert( m_data.begin()+row, line ); - + RowInserted( row ); } @@ -1433,7 +1428,7 @@ void wxDataViewListStore::DeleteItem( unsigned row ) { wxVector::iterator it = m_data.begin() + row; m_data.erase( it ); - + RowDeleted( row ); } @@ -1445,7 +1440,7 @@ void wxDataViewListStore::DeleteAllItems() wxDataViewListStoreLine* line = *it; delete line; } - + Reset( 0 ); } @@ -1459,7 +1454,7 @@ bool wxDataViewListStore::SetValueByRow( const wxVariant &value, unsigned int ro { wxDataViewListStoreLine *line = m_data[row]; line->m_values[col] = value; - + return true; } @@ -1532,18 +1527,18 @@ bool wxDataViewListCtrl::AppendColumn( wxDataViewColumn *col ) { return AppendColumn( col, "string" ); } - + wxDataViewColumn *wxDataViewListCtrl::AppendTextColumn( const wxString &label, wxDataViewCellMode mode, int width, wxAlignment align, int flags ) { GetStore()->AppendColumn( wxT("string") ); - + wxDataViewColumn *ret = new wxDataViewColumn( label, new wxDataViewTextRenderer( wxT("string"), mode ), GetStore()->GetColumnCount()-1, width, align, flags ); - + wxDataViewCtrl::AppendColumn( ret ); - + return ret; } @@ -1551,13 +1546,13 @@ wxDataViewColumn *wxDataViewListCtrl::AppendToggleColumn( const wxString &label, wxDataViewCellMode mode, int width, wxAlignment align, int flags ) { GetStore()->AppendColumn( wxT("bool") ); - + wxDataViewColumn *ret = new wxDataViewColumn( label, new wxDataViewToggleRenderer( wxT("bool"), mode ), GetStore()->GetColumnCount()-1, width, align, flags ); - + wxDataViewCtrl::AppendColumn( ret ); - + return ret; } @@ -1565,13 +1560,13 @@ wxDataViewColumn *wxDataViewListCtrl::AppendProgressColumn( const wxString &labe wxDataViewCellMode mode, int width, wxAlignment align, int flags ) { GetStore()->AppendColumn( wxT("long") ); - + wxDataViewColumn *ret = new wxDataViewColumn( label, new wxDataViewProgressRenderer( wxEmptyString, wxT("long"), mode ), GetStore()->GetColumnCount()-1, width, align, flags ); - + wxDataViewCtrl::AppendColumn( ret ); - + return ret; } @@ -1579,13 +1574,13 @@ wxDataViewColumn *wxDataViewListCtrl::AppendIconTextColumn( const wxString &labe wxDataViewCellMode mode, int width, wxAlignment align, int flags ) { GetStore()->AppendColumn( wxT("wxDataViewIconText") ); - + wxDataViewColumn *ret = new wxDataViewColumn( label, new wxDataViewIconTextRenderer( wxT("wxDataViewIconText"), mode ), GetStore()->GetColumnCount()-1, width, align, flags ); - + wxDataViewCtrl::AppendColumn( ret ); - + return ret; } @@ -1731,11 +1726,11 @@ wxDataViewTreeStore::InsertContainer(const wxDataViewItem& parent, { wxDataViewTreeStoreContainerNode *parent_node = FindContainerNode( parent ); if (!parent_node) return wxDataViewItem(0); - + wxDataViewTreeStoreNode *previous_node = FindNode( previous ); int pos = parent_node->GetChildren().IndexOf( previous_node ); if (pos == wxNOT_FOUND) return wxDataViewItem(0); - + wxDataViewTreeStoreContainerNode *node = new wxDataViewTreeStoreContainerNode( parent_node, text, icon, expanded, data ); parent_node->GetChildren().Insert( (size_t) pos, node ); @@ -2047,9 +2042,9 @@ wxDataViewItem wxDataViewTreeCtrl::AppendItem( const wxDataViewItem& parent, icon = m_imageList->GetIcon( iconIndex ); wxDataViewItem res = GetStore()->AppendItem( parent, text, icon, data ); - + GetStore()->ItemAdded( parent, res ); - + return res; } @@ -2061,9 +2056,9 @@ wxDataViewItem wxDataViewTreeCtrl::PrependItem( const wxDataViewItem& parent, icon = m_imageList->GetIcon( iconIndex ); wxDataViewItem res = GetStore()->PrependItem( parent, text, icon, data ); - + GetStore()->ItemAdded( parent, res ); - + return res; } @@ -2075,9 +2070,9 @@ wxDataViewItem wxDataViewTreeCtrl::InsertItem( const wxDataViewItem& parent, con icon = m_imageList->GetIcon( iconIndex ); wxDataViewItem res = GetStore()->InsertItem( parent, previous, text, icon, data ); - + GetStore()->ItemAdded( parent, res ); - + return res; } @@ -2093,9 +2088,9 @@ wxDataViewItem wxDataViewTreeCtrl::PrependContainer( const wxDataViewItem& paren expanded = m_imageList->GetIcon( expandedIndex ); wxDataViewItem res = GetStore()->PrependContainer( parent, text, icon, expanded, data ); - + GetStore()->ItemAdded( parent, res ); - + return res; } @@ -2111,9 +2106,9 @@ wxDataViewItem wxDataViewTreeCtrl::AppendContainer( const wxDataViewItem& parent expanded = m_imageList->GetIcon( expandedIndex ); wxDataViewItem res = GetStore()->AppendContainer( parent, text, icon, expanded, data ); - + GetStore()->ItemAdded( parent, res ); - + return res; } @@ -2129,16 +2124,16 @@ wxDataViewItem wxDataViewTreeCtrl::InsertContainer( const wxDataViewItem& parent expanded = m_imageList->GetIcon( expandedIndex ); wxDataViewItem res = GetStore()->InsertContainer( parent, previous, text, icon, expanded, data ); - + GetStore()->ItemAdded( parent, res ); - + return res; } void wxDataViewTreeCtrl::SetItemText( const wxDataViewItem& item, const wxString &text ) { GetStore()->SetItemText(item,text); - + // notify control GetStore()->ValueChanged( item, 0 ); } @@ -2146,7 +2141,7 @@ void wxDataViewTreeCtrl::SetItemText( const wxDataViewItem& item, const wxString void wxDataViewTreeCtrl::SetItemIcon( const wxDataViewItem& item, const wxIcon &icon ) { GetStore()->SetItemIcon(item,icon); - + // notify control GetStore()->ValueChanged( item, 0 ); } @@ -2154,7 +2149,7 @@ void wxDataViewTreeCtrl::SetItemIcon( const wxDataViewItem& item, const wxIcon & void wxDataViewTreeCtrl::SetItemExpandedIcon( const wxDataViewItem& item, const wxIcon &icon ) { GetStore()->SetItemExpandedIcon(item,icon); - + // notify control GetStore()->ValueChanged( item, 0 ); } @@ -2164,7 +2159,7 @@ void wxDataViewTreeCtrl::DeleteItem( const wxDataViewItem& item ) wxDataViewItem parent_item = GetStore()->GetParent( item ); GetStore()->DeleteItem(item); - + // notify control GetStore()->ItemDeleted( parent_item, item ); } @@ -2191,7 +2186,7 @@ void wxDataViewTreeCtrl::DeleteChildren( const wxDataViewItem& item ) void wxDataViewTreeCtrl::DeleteAllItems() { GetStore()->DeleteAllItems(); - + GetStore()->Cleared(); } @@ -2203,7 +2198,7 @@ void wxDataViewTreeCtrl::OnExpanded( wxDataViewEvent &event ) if (!container) return; container->SetExpanded( true ); - + GetStore()->ItemChanged( event.GetItem() ); } @@ -2215,7 +2210,7 @@ void wxDataViewTreeCtrl::OnCollapsed( wxDataViewEvent &event ) if (!container) return; container->SetExpanded( false ); - + GetStore()->ItemChanged( event.GetItem() ); }