#include "wx/crt.h"
#endif
+#include "wx/datectrl.h"
#include "wx/spinctrl.h"
#include "wx/choice.h"
#include "wx/imaglist.h"
m_ordered = false;
wxDataViewItem item( m_hash[row] );
- /* wxDataViewModel:: */ ItemDeleted( wxDataViewItem(0), item );
m_hash.RemoveAt( row );
+ /* wxDataViewModel:: */ ItemDeleted( wxDataViewItem(0), item );
}
void wxDataViewIndexListModel::RowsDeleted( const wxArrayInt &rows )
{
- wxArrayInt sorted = rows;
- sorted.Sort( my_sort );
-
m_ordered = false;
wxDataViewItemArray array;
wxDataViewItem item( m_hash[rows[i]] );
array.Add( item );
}
- /* wxDataViewModel:: */ ItemsDeleted( wxDataViewItem(0), array );
+ wxArrayInt sorted = rows;
+ sorted.Sort( my_sort );
for (i = 0; i < sorted.GetCount(); i++)
m_hash.RemoveAt( sorted[i] );
+
+ /* wxDataViewModel:: */ ItemsDeleted( wxDataViewItem(0), array );
}
void wxDataViewIndexListModel::RowChanged( unsigned int row )
wxDataViewRendererBase::~wxDataViewRendererBase()
{
+ if ( m_editorCtrl )
+ DestroyEditControl();
}
-const wxDataViewCtrl* wxDataViewRendererBase::GetView() const
+wxDataViewCtrl* wxDataViewRendererBase::GetView() const
{
return const_cast<wxDataViewRendererBase*>(this)->GetOwner()->GetOwner();
}
wxDataViewCtrl* dv_ctrl = GetOwner()->GetOwner();
- dv_ctrl->GetMainWindow()->SetFocus();
-
DestroyEditControl();
+ dv_ctrl->GetMainWindow()->SetFocus();
+
bool isValid = Validate(value);
unsigned int col = GetOwner()->GetModelColumn();
// wxDataViewCustomRendererBase
// ----------------------------------------------------------------------------
+bool wxDataViewCustomRendererBase::ActivateCell(const wxRect& cell,
+ wxDataViewModel *model,
+ const wxDataViewItem & item,
+ unsigned int col,
+ const wxMouseEvent* mouseEvent)
+{
+ // Compatibility code
+ if ( mouseEvent )
+ return LeftClick(mouseEvent->GetPosition(), cell, model, item, col);
+ else
+ return Activate(cell, model, item, col);
+}
+
+void wxDataViewCustomRendererBase::RenderBackground(wxDC* dc, const wxRect& rect)
+{
+ if ( !m_attr.HasBackgroundColour() )
+ return;
+
+ const wxColour& colour = m_attr.GetBackgroundColour();
+ wxDCPenChanger changePen(*dc, colour);
+ wxDCBrushChanger changeBrush(*dc, colour);
+
+ dc->DrawRectangle(rect);
+}
+
void
wxDataViewCustomRendererBase::WXCallRender(wxRect rectCell, wxDC *dc, int state)
{
Select(item);
}
+wxDataViewItem wxDataViewCtrlBase::GetSelection() const
+{
+ if ( GetSelectedItemsCount() != 1 )
+ return wxDataViewItem();
+
+ wxDataViewItemArray selections;
+ GetSelections(selections);
+ return selections[0];
+}
+
wxDataViewColumn *
wxDataViewCtrlBase::AppendTextColumn( const wxString &label, unsigned int model_column,
wxDataViewCellMode mode, int width, wxAlignment align, int flags )
return true;
}
+void wxDataViewCtrlBase::StartEditor(const wxDataViewItem& item, unsigned int column)
+{
+ EditItem(item, GetColumn(column));
+}
+
// ---------------------------------------------------------
// wxDataViewEvent
// ---------------------------------------------------------
#endif
+// ---------------------------------------------------------
+// wxDataViewDateRenderer
+// ---------------------------------------------------------
+
+#if (defined(wxHAS_GENERIC_DATAVIEWCTRL) || defined(__WXGTK__)) && wxUSE_DATEPICKCTRL
+
+wxDataViewDateRenderer::wxDataViewDateRenderer(const wxString& varianttype,
+ wxDataViewCellMode mode, int align)
+ : wxDataViewCustomRenderer(varianttype, mode, align)
+{
+}
+
+wxWindow *
+wxDataViewDateRenderer::CreateEditorCtrl(wxWindow *parent, wxRect labelRect, const wxVariant& value)
+{
+ return new wxDatePickerCtrl
+ (
+ parent,
+ wxID_ANY,
+ value.GetDateTime(),
+ labelRect.GetTopLeft(),
+ labelRect.GetSize()
+ );
+}
+
+bool wxDataViewDateRenderer::GetValueFromEditorCtrl(wxWindow *editor, wxVariant& value)
+{
+ wxDatePickerCtrl *ctrl = static_cast<wxDatePickerCtrl*>(editor);
+ value = ctrl->GetValue();
+ return true;
+}
+
+bool wxDataViewDateRenderer::SetValue(const wxVariant& value)
+{
+ m_date = value.GetDateTime();
+ return true;
+}
+
+bool wxDataViewDateRenderer::GetValue(wxVariant& value) const
+{
+ value = m_date;
+ return true;
+}
+
+bool wxDataViewDateRenderer::Render(wxRect cell, wxDC* dc, int state)
+{
+ wxString tmp = m_date.FormatDate();
+ RenderText( tmp, 0, cell, dc, state );
+ return true;
+}
+
+wxSize wxDataViewDateRenderer::GetSize() const
+{
+ return GetTextExtent(m_date.FormatDate());
+}
+
+#endif // (defined(wxHAS_GENERIC_DATAVIEWCTRL) || defined(__WXGTK__)) && wxUSE_DATEPICKCTRL
+
//-----------------------------------------------------------------------------
// wxDataViewListStore
//-----------------------------------------------------------------------------