#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";
void wxDataViewCtrlBase::ExpandAncestors( const wxDataViewItem & item )
{
if (!m_model) return;
-
+
if (!item.IsOk()) return;
wxVector<wxDataViewItem> parentChain;
-
+
// at first we get all the parents of the selected item
wxDataViewItem parent = m_model->GetParent(item);
while (parent.IsOk())
parentChain.push_back(parent);
parent = m_model->GetParent(parent);
}
-
+
// then we expand the parents, starting at the root
while (!parentChain.empty())
{
wxDataViewCtrlBase::AppendToggleColumn( const wxString &label, unsigned int model_column,
wxDataViewCellMode mode, int width, wxAlignment align, int flags )
{
-
wxDataViewColumn *ret = new wxDataViewColumn( label,
new wxDataViewToggleRenderer( wxT("bool"), mode ),
model_column, width, align, flags );
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_DROP_POSSIBLE, wxDataViewEvent )
+wxDEFINE_EVENT( wxEVT_COMMAND_DATAVIEW_ITEM_DROP, wxDataViewEvent )
// -------------------------------------
// wxDataViewSpinRenderer
{
return m_cols[pos];
}
-
+
void wxDataViewListStore::AppendItem( const wxVector<wxVariant> &values, wxClientData *data )
{
wxDataViewListStoreLine *line = new wxDataViewListStoreLine( data );
line->m_values = values;
m_data.push_back( line );
-
+
RowAppended();
}
wxDataViewListStoreLine *line = new wxDataViewListStoreLine( data );
line->m_values = values;
m_data.insert( m_data.begin(), line );
-
+
RowPrepended();
}
wxDataViewListStoreLine *line = new wxDataViewListStoreLine( data );
line->m_values = values;
m_data.insert( m_data.begin()+row, line );
-
+
RowInserted( row );
}
{
wxVector<wxDataViewListStoreLine*>::iterator it = m_data.begin() + row;
m_data.erase( it );
-
+
RowDeleted( row );
}
wxDataViewListStoreLine* line = *it;
delete line;
}
-
+
Reset( 0 );
}
{
wxDataViewListStoreLine *line = m_data[row];
line->m_values[col] = value;
-
+
return true;
}
return wxDataViewCtrl::Create( parent, id, pos, size, style, validator );
}
-void wxDataViewListCtrl::AppendCol( wxDataViewColumn *column, const wxString &varianttype )
+bool wxDataViewListCtrl::AppendColumn( wxDataViewColumn *column, const wxString &varianttype )
{
GetStore()->AppendColumn( varianttype );
- AppendColumn( column );
+ return wxDataViewCtrl::AppendColumn( column );
}
-void wxDataViewListCtrl::PrependCol( wxDataViewColumn *column, const wxString &varianttype )
+bool wxDataViewListCtrl::PrependColumn( wxDataViewColumn *column, const wxString &varianttype )
{
GetStore()->PrependColumn( varianttype );
- PrependColumn( column );
+ return wxDataViewCtrl::PrependColumn( column );
}
-void wxDataViewListCtrl::InsertCol( unsigned int pos, wxDataViewColumn *column, const wxString &varianttype )
+bool wxDataViewListCtrl::InsertColumn( unsigned int pos, wxDataViewColumn *column, const wxString &varianttype )
{
GetStore()->InsertColumn( pos, varianttype );
- InsertColumn( pos, column );
+ return wxDataViewCtrl::InsertColumn( pos, column );
+}
+
+bool wxDataViewListCtrl::PrependColumn( wxDataViewColumn *col )
+{
+ return PrependColumn( col, "string" );
+}
+
+bool wxDataViewListCtrl::InsertColumn( unsigned int pos, wxDataViewColumn *col )
+{
+ return InsertColumn( pos, col, "string" );
}
-
-wxDataViewColumn *wxDataViewListCtrl::AppendTextCol( const wxString &label,
+
+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") );
- return AppendTextColumn( label, GetStore()->GetColumnCount()-1, mode, width, align, flags );
+
+ wxDataViewColumn *ret = new wxDataViewColumn( label,
+ new wxDataViewTextRenderer( wxT("string"), mode ),
+ GetStore()->GetColumnCount()-1, width, align, flags );
+
+ wxDataViewCtrl::AppendColumn( ret );
+
+ return ret;
}
-wxDataViewColumn *wxDataViewListCtrl::AppendToggleCol( const wxString &label,
+wxDataViewColumn *wxDataViewListCtrl::AppendToggleColumn( const wxString &label,
wxDataViewCellMode mode, int width, wxAlignment align, int flags )
{
GetStore()->AppendColumn( wxT("bool") );
- return AppendToggleColumn( label, GetStore()->GetColumnCount()-1, mode, width, align, flags );
+
+ wxDataViewColumn *ret = new wxDataViewColumn( label,
+ new wxDataViewToggleRenderer( wxT("bool"), mode ),
+ GetStore()->GetColumnCount()-1, width, align, flags );
+
+ wxDataViewCtrl::AppendColumn( ret );
+
+ return ret;
}
-wxDataViewColumn *wxDataViewListCtrl::AppendProgressCol( const wxString &label,
+wxDataViewColumn *wxDataViewListCtrl::AppendProgressColumn( const wxString &label,
wxDataViewCellMode mode, int width, wxAlignment align, int flags )
{
GetStore()->AppendColumn( wxT("long") );
- return AppendProgressColumn( label, GetStore()->GetColumnCount()-1, mode, width, align, flags );
+
+ wxDataViewColumn *ret = new wxDataViewColumn( label,
+ new wxDataViewProgressRenderer( wxEmptyString, wxT("long"), mode ),
+ GetStore()->GetColumnCount()-1, width, align, flags );
+
+ wxDataViewCtrl::AppendColumn( ret );
+
+ return ret;
}
-wxDataViewColumn *wxDataViewListCtrl::AppendIconTextCol( const wxString &label,
+wxDataViewColumn *wxDataViewListCtrl::AppendIconTextColumn( const wxString &label,
wxDataViewCellMode mode, int width, wxAlignment align, int flags )
{
GetStore()->AppendColumn( wxT("wxDataViewIconText") );
- return AppendIconTextColumn( label, GetStore()->GetColumnCount()-1, mode, width, align, flags );
+
+ wxDataViewColumn *ret = new wxDataViewColumn( label,
+ new wxDataViewIconTextRenderer( wxT("wxDataViewIconText"), mode ),
+ GetStore()->GetColumnCount()-1, width, align, flags );
+
+ wxDataViewCtrl::AppendColumn( ret );
+
+ return ret;
}
void wxDataViewListCtrl::OnSize( wxSizeEvent &event )
{
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 );
icon = m_imageList->GetIcon( iconIndex );
wxDataViewItem res = GetStore()->AppendItem( parent, text, icon, data );
-
+
GetStore()->ItemAdded( parent, res );
-
+
return res;
}
icon = m_imageList->GetIcon( iconIndex );
wxDataViewItem res = GetStore()->PrependItem( parent, text, icon, data );
-
+
GetStore()->ItemAdded( parent, res );
-
+
return res;
}
icon = m_imageList->GetIcon( iconIndex );
wxDataViewItem res = GetStore()->InsertItem( parent, previous, text, icon, data );
-
+
GetStore()->ItemAdded( parent, res );
-
+
return res;
}
expanded = m_imageList->GetIcon( expandedIndex );
wxDataViewItem res = GetStore()->PrependContainer( parent, text, icon, expanded, data );
-
+
GetStore()->ItemAdded( parent, res );
-
+
return res;
}
expanded = m_imageList->GetIcon( expandedIndex );
wxDataViewItem res = GetStore()->AppendContainer( parent, text, icon, expanded, data );
-
+
GetStore()->ItemAdded( parent, res );
-
+
return res;
}
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 );
}
void wxDataViewTreeCtrl::SetItemIcon( const wxDataViewItem& item, const wxIcon &icon )
{
GetStore()->SetItemIcon(item,icon);
-
+
// notify control
GetStore()->ValueChanged( item, 0 );
}
void wxDataViewTreeCtrl::SetItemExpandedIcon( const wxDataViewItem& item, const wxIcon &icon )
{
GetStore()->SetItemExpandedIcon(item,icon);
-
+
// notify control
GetStore()->ValueChanged( item, 0 );
}
wxDataViewItem parent_item = GetStore()->GetParent( item );
GetStore()->DeleteItem(item);
-
+
// notify control
GetStore()->ItemDeleted( parent_item, item );
}
void wxDataViewTreeCtrl::DeleteAllItems()
{
GetStore()->DeleteAllItems();
-
+
GetStore()->Cleared();
}
if (!container) return;
container->SetExpanded( true );
-
+
GetStore()->ItemChanged( event.GetItem() );
}
if (!container) return;
container->SetExpanded( false );
-
+
GetStore()->ItemChanged( event.GetItem() );
}