#include "wx/dcclient.h"
#include "wx/timer.h"
#include "wx/settings.h"
+ #include "wx/msgdlg.h"
#endif
#include "wx/stockitem.h"
#include "wx/calctrl.h"
#include "wx/popupwin.h"
#include "wx/renderer.h"
+#include "wx/dcbuffer.h"
#include "wx/icon.h"
//-----------------------------------------------------------------------------
};
// ---------------------------------------------------------
-// wxDataViewCell
+// wxDataViewRenderer
// ---------------------------------------------------------
-IMPLEMENT_ABSTRACT_CLASS(wxDataViewCell, wxDataViewCellBase)
+IMPLEMENT_ABSTRACT_CLASS(wxDataViewRenderer, wxDataViewRendererBase)
-wxDataViewCell::wxDataViewCell( const wxString &varianttype, wxDataViewCellMode mode ) :
- wxDataViewCellBase( varianttype, mode )
+wxDataViewRenderer::wxDataViewRenderer( const wxString &varianttype, wxDataViewCellMode mode ) :
+ wxDataViewRendererBase( varianttype, mode )
{
m_dc = NULL;
}
-wxDataViewCell::~wxDataViewCell()
+wxDataViewRenderer::~wxDataViewRenderer()
{
if (m_dc)
delete m_dc;
}
-wxDC *wxDataViewCell::GetDC()
+wxDC *wxDataViewRenderer::GetDC()
{
if (m_dc == NULL)
{
}
// ---------------------------------------------------------
-// wxDataViewCustomCell
+// wxDataViewCustomRenderer
// ---------------------------------------------------------
-IMPLEMENT_ABSTRACT_CLASS(wxDataViewCustomCell, wxDataViewCell)
+IMPLEMENT_ABSTRACT_CLASS(wxDataViewCustomRenderer, wxDataViewRenderer)
-wxDataViewCustomCell::wxDataViewCustomCell( const wxString &varianttype,
+wxDataViewCustomRenderer::wxDataViewCustomRenderer( const wxString &varianttype,
wxDataViewCellMode mode ) :
- wxDataViewCell( varianttype, mode )
+ wxDataViewRenderer( varianttype, mode )
{
}
// ---------------------------------------------------------
-// wxDataViewTextCell
+// wxDataViewTextRenderer
// ---------------------------------------------------------
-IMPLEMENT_CLASS(wxDataViewTextCell, wxDataViewCustomCell)
+IMPLEMENT_CLASS(wxDataViewTextRenderer, wxDataViewCustomRenderer)
-wxDataViewTextCell::wxDataViewTextCell( const wxString &varianttype, wxDataViewCellMode mode ) :
- wxDataViewCustomCell( varianttype, mode )
+wxDataViewTextRenderer::wxDataViewTextRenderer( const wxString &varianttype, wxDataViewCellMode mode ) :
+ wxDataViewCustomRenderer( varianttype, mode )
{
}
-bool wxDataViewTextCell::SetValue( const wxVariant &value )
+bool wxDataViewTextRenderer::SetValue( const wxVariant &value )
{
m_text = value.GetString();
return true;
}
-bool wxDataViewTextCell::GetValue( wxVariant& WXUNUSED(value) )
+bool wxDataViewTextRenderer::GetValue( wxVariant& WXUNUSED(value) )
{
return false;
}
-bool wxDataViewTextCell::Render( wxRect cell, wxDC *dc, int WXUNUSED(state) )
+bool wxDataViewTextRenderer::Render( wxRect cell, wxDC *dc, int WXUNUSED(state) )
{
dc->DrawText( m_text, cell.x, cell.y );
return true;
}
-wxSize wxDataViewTextCell::GetSize()
+wxSize wxDataViewTextRenderer::GetSize()
{
return wxSize(80,20);
}
// ---------------------------------------------------------
-// wxDataViewBitmapCell
+// wxDataViewBitmapRenderer
// ---------------------------------------------------------
-IMPLEMENT_CLASS(wxDataViewBitmapCell, wxDataViewCustomCell)
+IMPLEMENT_CLASS(wxDataViewBitmapRenderer, wxDataViewCustomRenderer)
-wxDataViewBitmapCell::wxDataViewBitmapCell( const wxString &varianttype, wxDataViewCellMode mode ) :
- wxDataViewCustomCell( varianttype, mode )
+wxDataViewBitmapRenderer::wxDataViewBitmapRenderer( const wxString &varianttype, wxDataViewCellMode mode ) :
+ wxDataViewCustomRenderer( varianttype, mode )
{
}
-bool wxDataViewBitmapCell::SetValue( const wxVariant &value )
+bool wxDataViewBitmapRenderer::SetValue( const wxVariant &value )
{
if (value.GetType() == wxT("wxBitmap"))
m_bitmap << value;
return true;
}
-bool wxDataViewBitmapCell::GetValue( wxVariant& WXUNUSED(value) )
+bool wxDataViewBitmapRenderer::GetValue( wxVariant& WXUNUSED(value) )
{
return false;
}
-bool wxDataViewBitmapCell::Render( wxRect cell, wxDC *dc, int WXUNUSED(state) )
+bool wxDataViewBitmapRenderer::Render( wxRect cell, wxDC *dc, int WXUNUSED(state) )
{
if (m_bitmap.Ok())
dc->DrawBitmap( m_bitmap, cell.x, cell.y );
return true;
}
-wxSize wxDataViewBitmapCell::GetSize()
+wxSize wxDataViewBitmapRenderer::GetSize()
{
if (m_bitmap.Ok())
return wxSize( m_bitmap.GetWidth(), m_bitmap.GetHeight() );
}
// ---------------------------------------------------------
-// wxDataViewToggleCell
+// wxDataViewToggleRenderer
// ---------------------------------------------------------
-IMPLEMENT_ABSTRACT_CLASS(wxDataViewToggleCell, wxDataViewCustomCell)
+IMPLEMENT_ABSTRACT_CLASS(wxDataViewToggleRenderer, wxDataViewCustomRenderer)
-wxDataViewToggleCell::wxDataViewToggleCell( const wxString &varianttype,
+wxDataViewToggleRenderer::wxDataViewToggleRenderer( const wxString &varianttype,
wxDataViewCellMode mode ) :
- wxDataViewCustomCell( varianttype, mode )
+ wxDataViewCustomRenderer( varianttype, mode )
{
m_toggle = false;
}
-bool wxDataViewToggleCell::SetValue( const wxVariant &value )
+bool wxDataViewToggleRenderer::SetValue( const wxVariant &value )
{
m_toggle = value.GetBool();
return true;
}
-bool wxDataViewToggleCell::GetValue( wxVariant &WXUNUSED(value) )
+bool wxDataViewToggleRenderer::GetValue( wxVariant &WXUNUSED(value) )
{
return false;
}
-bool wxDataViewToggleCell::Render( wxRect cell, wxDC *dc, int WXUNUSED(state) )
+bool wxDataViewToggleRenderer::Render( wxRect cell, wxDC *dc, int WXUNUSED(state) )
{
// User wxRenderer here
return true;
}
-bool wxDataViewToggleCell::Activate( wxRect WXUNUSED(cell), wxDataViewListModel *model, unsigned int col, unsigned int row )
+bool wxDataViewToggleRenderer::Activate( wxRect WXUNUSED(cell), wxDataViewListModel *model, unsigned int col, unsigned int row )
{
bool value = !m_toggle;
wxVariant variant = value;
return true;
}
-wxSize wxDataViewToggleCell::GetSize()
+wxSize wxDataViewToggleRenderer::GetSize()
{
return wxSize(20,20);
}
// ---------------------------------------------------------
-// wxDataViewProgressCell
+// wxDataViewProgressRenderer
// ---------------------------------------------------------
-IMPLEMENT_ABSTRACT_CLASS(wxDataViewProgressCell, wxDataViewCustomCell)
+IMPLEMENT_ABSTRACT_CLASS(wxDataViewProgressRenderer, wxDataViewCustomRenderer)
-wxDataViewProgressCell::wxDataViewProgressCell( const wxString &label,
+wxDataViewProgressRenderer::wxDataViewProgressRenderer( const wxString &label,
const wxString &varianttype, wxDataViewCellMode mode ) :
- wxDataViewCustomCell( varianttype, mode )
+ wxDataViewCustomRenderer( varianttype, mode )
{
m_label = label;
m_value = 0;
}
-wxDataViewProgressCell::~wxDataViewProgressCell()
+wxDataViewProgressRenderer::~wxDataViewProgressRenderer()
{
}
-bool wxDataViewProgressCell::SetValue( const wxVariant &value )
+bool wxDataViewProgressRenderer::SetValue( const wxVariant &value )
{
m_value = (long) value;
return true;
}
-bool wxDataViewProgressCell::Render( wxRect cell, wxDC *dc, int WXUNUSED(state) )
+bool wxDataViewProgressRenderer::Render( wxRect cell, wxDC *dc, int WXUNUSED(state) )
{
double pct = (double)m_value / 100.0;
wxRect bar = cell;
return true;
}
-wxSize wxDataViewProgressCell::GetSize()
+wxSize wxDataViewProgressRenderer::GetSize()
{
return wxSize(40,12);
}
// ---------------------------------------------------------
-// wxDataViewDateCell
+// wxDataViewDateRenderer
// ---------------------------------------------------------
-class wxDataViewDateCellPopupTransient: public wxPopupTransientWindow
+#if wxUSE_CALENDARCTRL
+
+class wxDataViewDateRendererPopupTransient: public wxPopupTransientWindow
{
public:
- wxDataViewDateCellPopupTransient( wxWindow* parent, wxDateTime *value,
+ wxDataViewDateRendererPopupTransient( wxWindow* parent, wxDateTime *value,
wxDataViewListModel *model, unsigned int col, unsigned int row ) :
wxPopupTransientWindow( parent, wxBORDER_SIMPLE )
{
DECLARE_EVENT_TABLE()
};
-BEGIN_EVENT_TABLE(wxDataViewDateCellPopupTransient,wxPopupTransientWindow)
- EVT_CALENDAR( wxID_ANY, wxDataViewDateCellPopupTransient::OnCalendar )
+BEGIN_EVENT_TABLE(wxDataViewDateRendererPopupTransient,wxPopupTransientWindow)
+ EVT_CALENDAR( wxID_ANY, wxDataViewDateRendererPopupTransient::OnCalendar )
END_EVENT_TABLE()
-void wxDataViewDateCellPopupTransient::OnCalendar( wxCalendarEvent &event )
+void wxDataViewDateRendererPopupTransient::OnCalendar( wxCalendarEvent &event )
{
wxDateTime date = event.GetDate();
wxVariant value = date;
DismissAndNotify();
}
-IMPLEMENT_ABSTRACT_CLASS(wxDataViewDateCell, wxDataViewCustomCell)
+#endif // wxUSE_CALENDARCTRL
+
+IMPLEMENT_ABSTRACT_CLASS(wxDataViewDateRenderer, wxDataViewCustomRenderer)
-wxDataViewDateCell::wxDataViewDateCell( const wxString &varianttype,
+wxDataViewDateRenderer::wxDataViewDateRenderer( const wxString &varianttype,
wxDataViewCellMode mode ) :
- wxDataViewCustomCell( varianttype, mode )
+ wxDataViewCustomRenderer( varianttype, mode )
{
}
-bool wxDataViewDateCell::SetValue( const wxVariant &value )
+bool wxDataViewDateRenderer::SetValue( const wxVariant &value )
{
m_date = value.GetDateTime();
return true;
}
-bool wxDataViewDateCell::Render( wxRect cell, wxDC *dc, int WXUNUSED(state) )
+bool wxDataViewDateRenderer::Render( wxRect cell, wxDC *dc, int WXUNUSED(state) )
{
dc->SetFont( GetOwner()->GetOwner()->GetFont() );
wxString tmp = m_date.FormatDate();
return true;
}
-wxSize wxDataViewDateCell::GetSize()
+wxSize wxDataViewDateRenderer::GetSize()
{
wxDataViewCtrl* view = GetOwner()->GetOwner();
wxString tmp = m_date.FormatDate();
return wxSize(x,y+d);
}
-bool wxDataViewDateCell::Activate( wxRect WXUNUSED(cell), wxDataViewListModel *model, unsigned int col, unsigned int row )
+bool wxDataViewDateRenderer::Activate( wxRect WXUNUSED(cell), wxDataViewListModel *model, unsigned int col, unsigned int row )
{
wxVariant variant;
model->GetValue( variant, col, row );
wxDateTime value = variant.GetDateTime();
- wxDataViewDateCellPopupTransient *popup = new wxDataViewDateCellPopupTransient(
+#if wxUSE_CALENDARCTRL
+ wxDataViewDateRendererPopupTransient *popup = new wxDataViewDateRendererPopupTransient(
GetOwner()->GetOwner()->GetParent(), &value, model, col, row );
wxPoint pos = wxGetMousePosition();
popup->Move( pos );
popup->Layout();
popup->Popup( popup->m_cal );
-
+#else
+ wxMessageBox(value.Format());
+#endif
return true;
}
IMPLEMENT_ABSTRACT_CLASS(wxDataViewColumn, wxDataViewColumnBase)
-wxDataViewColumn::wxDataViewColumn( const wxString &title, wxDataViewCell *cell, unsigned int model_column,
+wxDataViewColumn::wxDataViewColumn( const wxString &title, wxDataViewRenderer *cell, unsigned int model_column,
int width, int flags ) :
wxDataViewColumnBase( title, cell, model_column, width, flags )
{
m_width = 80;
}
+wxDataViewColumn::wxDataViewColumn( const wxBitmap &bitmap, wxDataViewRenderer *cell, unsigned int model_column,
+ int width, int flags ) :
+ wxDataViewColumnBase( bitmap, cell, model_column, width, flags )
+{
+ m_width = width;
+ if (m_width < 0)
+ m_width = 30;
+}
+
+void wxDataViewColumn::SetAlignment( wxAlignment WXUNUSED(align) )
+{
+ // TODO
+}
+
+void wxDataViewColumn::SetSortable( bool WXUNUSED(sortable) )
+{
+ // TODO
+}
+
+bool wxDataViewColumn::GetSortable()
+{
+ // TODO
+ return false;
+}
+
+void wxDataViewColumn::SetSortOrder( bool WXUNUSED(ascending) )
+{
+ // TODO
+}
+
+bool wxDataViewColumn::IsSortOrderAscending()
+{
+ // TODO
+ return true;
+}
+
+
wxDataViewColumn::~wxDataViewColumn()
{
}
}
+void wxDataViewColumn::SetBitmap( const wxBitmap &bitmap )
+{
+ wxDataViewColumnBase::SetBitmap( bitmap );
+
+}
+
int wxDataViewColumn::GetWidth()
{
return m_width;
m_resizeCursor = new wxCursor( wxCURSOR_SIZEWE );
wxVisualAttributes attr = wxPanel::GetClassDefaultAttributes();
+ SetBackgroundStyle( wxBG_STYLE_CUSTOM );
SetOwnForegroundColour( attr.colFg );
SetOwnBackgroundColour( attr.colBg );
if (!m_hasFont)
int w, h;
GetClientSize( &w, &h );
- wxPaintDC dc( this );
+ wxAutoBufferedPaintDC dc( this );
+
+ dc.SetBackground(GetBackgroundColour());
+ dc.Clear();
int xpix;
m_owner->GetScrollPixelsPerUnit( &xpix, NULL );
m_hasFocus = false;
+ SetBackgroundStyle( wxBG_STYLE_CUSTOM );
SetBackgroundColour( *wxWHITE );
UpdateDisplay();
void wxDataViewMainWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
{
- wxPaintDC dc( this );
+ wxAutoBufferedPaintDC dc( this );
+
+ dc.SetBackground(GetBackgroundColour());
+ dc.Clear();
GetOwner()->PrepareDC( dc );
for (i = 0; i < cols; i++)
{
wxDataViewColumn *col = GetOwner()->GetColumn( i );
- wxDataViewCell *cell = col->GetCell();
+ wxDataViewRenderer *cell = col->GetRenderer();
cell_rect.width = col->GetWidth();
for (item = item_start; item < item_start+item_count; item++)
}
if (!col)
return;
- wxDataViewCell *cell = col->GetCell();
+ wxDataViewRenderer *cell = col->GetRenderer();
unsigned int current = y / m_lineHeight;
return true;
}
+void wxDataViewCtrl::SetSelection( int WXUNUSED(row) )
+{
+ // FIXME - TODO
+}
+
+void wxDataViewCtrl::SetSelectionRange( unsigned int WXUNUSED(from), unsigned int WXUNUSED(to) )
+{
+ // FIXME - TODO
+}
+
+void wxDataViewCtrl::SetSelections( const wxArrayInt& WXUNUSED(aSelections) )
+{
+ // FIXME - TODO
+}
+
+void wxDataViewCtrl::Unselect( unsigned int WXUNUSED(row) )
+{
+ // FIXME - TODO
+}
+
+bool wxDataViewCtrl::IsSelected( unsigned int WXUNUSED(row) ) const
+{
+ // FIXME - TODO
+
+ return false;
+}
+
+int wxDataViewCtrl::GetSelection() const
+{
+ // FIXME - TODO
+
+ return -1;
+}
+
+int wxDataViewCtrl::GetSelections(wxArrayInt& WXUNUSED(aSelections) ) const
+{
+ // FIXME - TODO
+
+ return 0;
+}
+
#endif
// !wxUSE_GENERICDATAVIEWCTRL