X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6ff7eee7ea3fc4fe88156dcf9d946be1cb0563b6..032bc940fcde34cc649eaa111cd6aff1cda66104:/src/generic/datavgen.cpp?ds=sidebyside diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index d7a1dde330..771dab7a47 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -29,12 +29,14 @@ #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" //----------------------------------------------------------------------------- @@ -252,24 +254,24 @@ public: }; // --------------------------------------------------------- -// 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) { @@ -284,64 +286,64 @@ wxDC *wxDataViewCell::GetDC() } // --------------------------------------------------------- -// 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; @@ -351,12 +353,12 @@ bool wxDataViewBitmapCell::SetValue( const wxVariant &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 ); @@ -366,7 +368,7 @@ bool wxDataViewBitmapCell::Render( wxRect cell, wxDC *dc, int WXUNUSED(state) ) return true; } -wxSize wxDataViewBitmapCell::GetSize() +wxSize wxDataViewBitmapRenderer::GetSize() { if (m_bitmap.Ok()) return wxSize( m_bitmap.GetWidth(), m_bitmap.GetHeight() ); @@ -377,31 +379,31 @@ wxSize wxDataViewBitmapCell::GetSize() } // --------------------------------------------------------- -// 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 @@ -426,7 +428,7 @@ bool wxDataViewToggleCell::Render( wxRect cell, wxDC *dc, int WXUNUSED(state) ) 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; @@ -435,30 +437,30 @@ bool wxDataViewToggleCell::Activate( wxRect WXUNUSED(cell), wxDataViewListModel 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; @@ -468,7 +470,7 @@ bool wxDataViewProgressCell::SetValue( const wxVariant &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; @@ -484,19 +486,21 @@ bool wxDataViewProgressCell::Render( wxRect cell, wxDC *dc, int WXUNUSED(state) 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 ) { @@ -526,11 +530,11 @@ private: 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; @@ -539,22 +543,24 @@ void wxDataViewDateCellPopupTransient::OnCalendar( wxCalendarEvent &event ) 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(); @@ -563,7 +569,7 @@ bool wxDataViewDateCell::Render( wxRect cell, wxDC *dc, int WXUNUSED(state) ) return true; } -wxSize wxDataViewDateCell::GetSize() +wxSize wxDataViewDateRenderer::GetSize() { wxDataViewCtrl* view = GetOwner()->GetOwner(); wxString tmp = m_date.FormatDate(); @@ -572,19 +578,22 @@ wxSize wxDataViewDateCell::GetSize() 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; } @@ -594,7 +603,7 @@ bool wxDataViewDateCell::Activate( wxRect WXUNUSED(cell), wxDataViewListModel *m 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 ) { @@ -603,6 +612,43 @@ wxDataViewColumn::wxDataViewColumn( const wxString &title, wxDataViewCell *cell, 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() { } @@ -613,6 +659,12 @@ void wxDataViewColumn::SetTitle( const wxString &title ) } +void wxDataViewColumn::SetBitmap( const wxBitmap &bitmap ) +{ + wxDataViewColumnBase::SetBitmap( bitmap ); + +} + int wxDataViewColumn::GetWidth() { return m_width; @@ -639,6 +691,7 @@ wxDataViewHeaderWindow::wxDataViewHeaderWindow( wxDataViewCtrl *parent, wxWindow m_resizeCursor = new wxCursor( wxCURSOR_SIZEWE ); wxVisualAttributes attr = wxPanel::GetClassDefaultAttributes(); + SetBackgroundStyle( wxBG_STYLE_CUSTOM ); SetOwnForegroundColour( attr.colFg ); SetOwnBackgroundColour( attr.colBg ); if (!m_hasFont) @@ -655,7 +708,10 @@ void wxDataViewHeaderWindow::OnPaint( wxPaintEvent &WXUNUSED(event) ) int w, h; GetClientSize( &w, &h ); - wxPaintDC dc( this ); + wxAutoBufferedPaintDC dc( this ); + + dc.SetBackground(GetBackgroundColour()); + dc.Clear(); int xpix; m_owner->GetScrollPixelsPerUnit( &xpix, NULL ); @@ -910,6 +966,7 @@ wxDataViewMainWindow::wxDataViewMainWindow( wxDataViewCtrl *parent, wxWindowID i m_hasFocus = false; + SetBackgroundStyle( wxBG_STYLE_CUSTOM ); SetBackgroundColour( *wxWHITE ); UpdateDisplay(); @@ -1051,7 +1108,10 @@ void wxDataViewMainWindow::ScrollWindow( int dx, int dy, const wxRect *rect ) void wxDataViewMainWindow::OnPaint( wxPaintEvent &WXUNUSED(event) ) { - wxPaintDC dc( this ); + wxAutoBufferedPaintDC dc( this ); + + dc.SetBackground(GetBackgroundColour()); + dc.Clear(); GetOwner()->PrepareDC( dc ); @@ -1115,7 +1175,7 @@ void wxDataViewMainWindow::OnPaint( wxPaintEvent &WXUNUSED(event) ) 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++) @@ -1475,7 +1535,7 @@ void wxDataViewMainWindow::OnMouse( wxMouseEvent &event ) } if (!col) return; - wxDataViewCell *cell = col->GetCell(); + wxDataViewRenderer *cell = col->GetRenderer(); unsigned int current = y / m_lineHeight; @@ -1797,30 +1857,44 @@ bool wxDataViewCtrl::AppendColumn( wxDataViewColumn *col ) return true; } -void wxDataViewCtrl::SetSelection( int row ) +void wxDataViewCtrl::SetSelection( int WXUNUSED(row) ) +{ + // FIXME - TODO +} + +void wxDataViewCtrl::SetSelectionRange( unsigned int WXUNUSED(from), unsigned int WXUNUSED(to) ) { + // FIXME - TODO } -void wxDataViewCtrl::SetSelectionRange( unsigned int from, unsigned int to ) +void wxDataViewCtrl::SetSelections( const wxArrayInt& WXUNUSED(aSelections) ) { + // FIXME - TODO } -void wxDataViewCtrl::SetSelections( const wxArrayInt& aSelections) +void wxDataViewCtrl::Unselect( unsigned int WXUNUSED(row) ) { + // FIXME - TODO } - -bool wxDataViewCtrl::IsSelected( unsigned int row ) const + +bool wxDataViewCtrl::IsSelected( unsigned int WXUNUSED(row) ) const { + // FIXME - TODO + return false; } int wxDataViewCtrl::GetSelection() const { + // FIXME - TODO + return -1; } -int wxDataViewCtrl::GetSelections(wxArrayInt& aSelections) const +int wxDataViewCtrl::GetSelections(wxArrayInt& WXUNUSED(aSelections) ) const { + // FIXME - TODO + return 0; }