+// ---------------------------------------------------------
+// wxDataViewProgressRenderer
+// ---------------------------------------------------------
+
+IMPLEMENT_CLASS(wxDataViewProgressRenderer, wxDataViewCustomRenderer)
+
+wxDataViewProgressRenderer::wxDataViewProgressRenderer( const wxString &label,
+ const wxString &varianttype, wxDataViewCellMode mode, int align ) :
+ wxDataViewCustomRenderer( varianttype, mode, align, true )
+{
+ m_label = label;
+ m_value = 0;
+
+#ifdef __WXGTK26__
+ if (!gtk_check_version(2,6,0))
+ {
+ m_renderer = (GtkWidget*) gtk_cell_renderer_progress_new();
+
+ GValue gvalue = { 0, };
+ g_value_init( &gvalue, G_TYPE_STRING );
+
+ // FIXME: font encoding support
+ g_value_set_string( &gvalue, wxGTK_CONV_SYS(m_label) );
+ g_object_set_property( G_OBJECT(m_renderer), "text", &gvalue );
+ g_value_unset( &gvalue );
+
+ SetMode(mode);
+ SetAlignment(align);
+ }
+ else
+#endif
+ {
+ // Use custom cell code
+ wxDataViewCustomRenderer::Init(mode, align);
+ }
+}
+
+wxDataViewProgressRenderer::~wxDataViewProgressRenderer()
+{
+}
+
+bool wxDataViewProgressRenderer::SetValue( const wxVariant &value )
+{
+#ifdef __WXGTK26__
+ if (!gtk_check_version(2,6,0))
+ {
+ gint tmp = (long) value;
+ GValue gvalue = { 0, };
+ g_value_init( &gvalue, G_TYPE_INT );
+ g_value_set_int( &gvalue, tmp );
+ g_object_set_property( G_OBJECT(m_renderer), "value", &gvalue );
+ g_value_unset( &gvalue );
+ }
+ else
+#endif
+ {
+ m_value = (long) value;
+
+ if (m_value < 0) m_value = 0;
+ if (m_value > 100) m_value = 100;
+ }
+
+ return true;
+}
+
+bool wxDataViewProgressRenderer::GetValue( wxVariant &value ) const
+{
+ return false;
+}
+
+bool wxDataViewProgressRenderer::Render( wxRect cell, wxDC *dc, int state )
+{
+ double pct = (double)m_value / 100.0;
+ wxRect bar = cell;
+ bar.width = (int)(cell.width * pct);
+ dc->SetPen( *wxTRANSPARENT_PEN );
+ dc->SetBrush( *wxBLUE_BRUSH );
+ dc->DrawRectangle( bar );
+
+ dc->SetBrush( *wxTRANSPARENT_BRUSH );
+ dc->SetPen( *wxBLACK_PEN );
+ dc->DrawRectangle( cell );
+
+ return true;
+}
+
+wxSize wxDataViewProgressRenderer::GetSize() const
+{
+ return wxSize(40,12);
+}
+
+// ---------------------------------------------------------
+// wxDataViewDateRenderer
+// ---------------------------------------------------------
+
+class wxDataViewDateRendererPopupTransient: public wxPopupTransientWindow
+{
+public:
+ wxDataViewDateRendererPopupTransient( wxWindow* parent, wxDateTime *value,
+ wxDataViewListModel *model, unsigned int col, unsigned int row ) :
+ wxPopupTransientWindow( parent, wxBORDER_SIMPLE )
+ {
+ m_model = model;
+ m_col = col;
+ m_row = row;
+ m_cal = new wxCalendarCtrl( this, -1, *value );
+ wxBoxSizer *sizer = new wxBoxSizer( wxHORIZONTAL );
+ sizer->Add( m_cal, 1, wxGROW );
+ SetSizer( sizer );
+ sizer->Fit( this );
+ }
+
+ virtual void OnDismiss()
+ {
+ }
+
+ void OnCalendar( wxCalendarEvent &event );
+
+ wxCalendarCtrl *m_cal;
+ wxDataViewListModel *m_model;
+ unsigned int m_col;
+ unsigned int m_row;
+
+private:
+ DECLARE_EVENT_TABLE()
+};
+
+BEGIN_EVENT_TABLE(wxDataViewDateRendererPopupTransient,wxPopupTransientWindow)
+ EVT_CALENDAR( -1, wxDataViewDateRendererPopupTransient::OnCalendar )
+END_EVENT_TABLE()
+
+void wxDataViewDateRendererPopupTransient::OnCalendar( wxCalendarEvent &event )
+{
+ wxDateTime date = event.GetDate();
+ wxVariant value = date;
+ m_model->SetValue( value, m_col, m_row );
+ m_model->ValueChanged( m_col, m_row );
+ DismissAndNotify();
+}
+
+IMPLEMENT_CLASS(wxDataViewDateRenderer, wxDataViewCustomRenderer)
+
+wxDataViewDateRenderer::wxDataViewDateRenderer( const wxString &varianttype,
+ wxDataViewCellMode mode, int align ) :
+ wxDataViewCustomRenderer( varianttype, mode, align )
+{
+ SetMode(mode);
+ SetAlignment(align);
+}
+
+bool wxDataViewDateRenderer::SetValue( const wxVariant &value )
+{
+ m_date = value.GetDateTime();
+
+ return true;
+}
+
+bool wxDataViewDateRenderer::GetValue( wxVariant &value ) const
+{
+ return false;
+}
+
+bool wxDataViewDateRenderer::Render( wxRect cell, wxDC *dc, int state )
+{
+ dc->SetFont( GetOwner()->GetOwner()->GetFont() );
+ wxString tmp = m_date.FormatDate();
+ dc->DrawText( tmp, cell.x, cell.y );
+
+ return true;
+}
+
+wxSize wxDataViewDateRenderer::GetSize() const
+{
+ wxString tmp = m_date.FormatDate();
+ wxCoord x,y,d;
+ GetView()->GetTextExtent( tmp, &x, &y, &d );
+ return wxSize(x,y+d);
+}
+
+bool wxDataViewDateRenderer::Activate( wxRect cell, wxDataViewListModel *model,
+ unsigned int col, unsigned int row )
+{
+ wxVariant variant;
+ model->GetValue( variant, col, row );
+ wxDateTime value = variant.GetDateTime();
+
+ wxDataViewDateRendererPopupTransient *popup = new wxDataViewDateRendererPopupTransient(
+ GetOwner()->GetOwner()->GetParent(), &value, model, col, row );
+ wxPoint pos = wxGetMousePosition();
+ popup->Move( pos );
+ popup->Layout();
+ popup->Popup( popup->m_cal );
+
+ return true;
+}
+
+// ---------------------------------------------------------
+// wxDataViewColumn
+// ---------------------------------------------------------
+
+
+static gboolean
+gtk_dataview_header_button_press_callback( GtkWidget *widget,
+ GdkEventButton *gdk_event,
+ wxDataViewColumn *column )
+{
+ if (gdk_event->type != GDK_BUTTON_PRESS)
+ return TRUE;
+
+ if (gdk_event->button == 1)
+ {
+ wxDataViewCtrl *dv = column->GetOwner();
+ wxDataViewEvent event( wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK, dv->GetId() );
+ event.SetDataViewColumn( column );
+ event.SetModel( dv->GetModel() );
+ dv->GetEventHandler()->ProcessEvent( event );
+ }
+
+ return TRUE;
+}
+
+extern "C" {
+static void wxGtkTreeCellDataFunc( GtkTreeViewColumn *column,
+ GtkCellRenderer *cell,