#ifdef __WXDEBUG__
void wxDataViewItem::Print(const wxString& text) const
{
- wxPrintf("item %s: %l\n", text, (long)m_id);
+ wxPrintf(wxT("item %s: %l\n"), text.GetData(), (long)m_id);
}
#endif
{
}
+void wxDataViewIndexListModel::Reset( unsigned int new_size )
+{
+ if (m_useHash)
+ {
+ m_hash.Clear();
+
+ // IDs are ordered until an item gets deleted or inserted
+ m_ordered = true;
+
+ // build initial index
+ unsigned int i;
+ for (i = 1; i < new_size+1; i++)
+ m_hash.Add( (void*) i );
+ m_lastIndex = new_size + 1;
+ }
+ else
+ {
+ m_lastIndex = new_size-1;
+ }
+
+ wxDataViewModel::Cleared();
+}
+
void wxDataViewIndexListModel::RowPrepended()
{
if (m_useHash)
{
if (m_useHash)
{
+ m_ordered = false;
+
wxDataViewItem item( m_hash[row] );
wxDataViewModel::ItemDeleted( wxDataViewItem(0), item );
m_hash.RemoveAt( row );
}
}
+static int my_sort( int *v1, int *v2 )
+{
+ return *v2-*v1;
+}
+
+void wxDataViewIndexListModel::RowsDeleted( const wxArrayInt &rows )
+{
+ wxArrayInt sorted = rows;
+ sorted.Sort( my_sort );
+
+ if (m_useHash)
+ {
+ m_ordered = false;
+
+ wxDataViewItemArray array;
+ unsigned int i;
+ for (i = 0; i < rows.GetCount(); i++)
+ {
+ wxDataViewItem item( m_hash[rows[i]] );
+ array.Add( item );
+ }
+ wxDataViewModel::ItemsDeleted( wxDataViewItem(0), array );
+
+ for (i = 0; i < sorted.GetCount(); i++)
+ m_hash.RemoveAt( sorted[i] );
+ }
+ else
+ {
+ wxDataViewItemArray array;
+ unsigned int i;
+ for (i = 0; i < sorted.GetCount(); i++)
+ {
+ wxDataViewItem item( (void*) sorted[i] );
+ array.Add( item );
+ }
+ wxDataViewModel::ItemsDeleted( wxDataViewItem(0), array );
+
+ m_lastIndex -= rows.GetCount();
+ }
+}
+
void wxDataViewIndexListModel::RowChanged( unsigned int row )
{
wxDataViewModel::ItemChanged( GetItem(row) );
return 0;
children = m_hash;
-
+
return m_hash.GetCount();
}
SetSortable((flags & wxDATAVIEW_COL_SORTABLE) != 0);
SetResizeable((flags & wxDATAVIEW_COL_RESIZABLE) != 0);
SetHidden((flags & wxDATAVIEW_COL_HIDDEN) != 0);
+ SetReorderable((flags & wxDATAVIEW_COL_REORDERABLE) != 0);
}
// ---------------------------------------------------------
DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED)
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU)
+
DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED)
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED)
// -------------------------------------
// -------------------------------------
wxDataViewSpinRenderer::wxDataViewSpinRenderer( int min, int max, wxDataViewCellMode mode, int alignment ) :
- wxDataViewCustomRenderer( "long", mode, alignment )
+ wxDataViewCustomRenderer(wxT("long"), mode, alignment )
{
m_min = min;
m_max = max;
wxControl* wxDataViewSpinRenderer::CreateEditorCtrl( wxWindow *parent, wxRect labelRect, const wxVariant &value )
{
long l = value;
- return new wxSpinCtrl( parent, wxID_ANY, wxEmptyString,
- labelRect.GetTopLeft(), labelRect.GetSize(), wxSP_ARROW_KEYS, m_min, m_max, l );
+ wxSize size = labelRect.GetSize();
+#ifdef __WXMAC__
+ size = wxSize( wxMax(70,labelRect.width ), -1 );
+#endif
+ wxString str;
+ str.Printf( wxT("%d\n"), (int) l );
+ wxSpinCtrl *sc = new wxSpinCtrl( parent, wxID_ANY, str,
+ labelRect.GetTopLeft(), size, wxSP_ARROW_KEYS, m_min, m_max, l );
+#ifdef __WXMAC__
+ size = sc->GetSize();
+ wxPoint pt = sc->GetPosition();
+ sc->SetSize( pt.x - 4, pt.y - 4, size.x, size.y );
+#endif
+
+ return sc;
}
bool wxDataViewSpinRenderer::GetValueFromEditorCtrl( wxControl* editor, wxVariant &value )
bool wxDataViewSpinRenderer::Render( wxRect rect, wxDC *dc, int state )
{
wxString str;
- str.Printf( "%d", (int) m_data );
+ str.Printf(wxT("%d"), (int) m_data );
RenderText( str, 0, rect, dc, state );
return true;
}
BEGIN_EVENT_TABLE(wxDataViewTreeCtrl,wxDataViewCtrl)
EVT_DATAVIEW_ITEM_EXPANDED(-1, wxDataViewTreeCtrl::OnExpanded)
EVT_DATAVIEW_ITEM_COLLAPSED(-1, wxDataViewTreeCtrl::OnCollapsed)
+ EVT_SIZE( wxDataViewTreeCtrl::OnSize )
END_EVENT_TABLE()
wxDataViewTreeCtrl::wxDataViewTreeCtrl()
wxDataViewTreeStore *store = new wxDataViewTreeStore;
AssociateModel( store );
store->DecRef();
- AppendIconTextColumn( "", 0, wxDATAVIEW_CELL_INERT, 200 );
+
+ AppendIconTextColumn(wxString(),0,wxDATAVIEW_CELL_INERT,-1);
}
wxDataViewTreeCtrl::~wxDataViewTreeCtrl()
return GetStore()->InsertContainer( parent, previous, text, icon, expanded, data );
}
-
void wxDataViewTreeCtrl::OnExpanded( wxDataViewEvent &event )
{
if (m_imageList) return;
GetStore()->ItemChanged( event.GetItem() );
}
-void wxDataViewTreeCtrl::OnSize( wxSizeEvent &WXUNUSED(event) )
+void wxDataViewTreeCtrl::OnSize( wxSizeEvent &event )
{
-#if !defined(__WXGTK20__)
+#if defined(wxUSE_GENERICDATAVIEWCTRL)
+ wxSize size = GetClientSize();
+ wxDataViewColumn *col = GetColumn( 0 );
+ if (col)
+ col->SetWidth( size.x );
#endif
+ event.Skip( true );
}
#endif // wxUSE_DATAVIEWCTRL