Some restructuring, beginning of wxDataViewDateCell.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@37741 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
		@@ -203,6 +203,7 @@ public:
 | 
				
			|||||||
    virtual bool AppendTextColumn( const wxString &label, size_t model_column );
 | 
					    virtual bool AppendTextColumn( const wxString &label, size_t model_column );
 | 
				
			||||||
    virtual bool AppendToggleColumn( const wxString &label, size_t model_column );
 | 
					    virtual bool AppendToggleColumn( const wxString &label, size_t model_column );
 | 
				
			||||||
    virtual bool AppendProgressColumn( const wxString &label, size_t model_column );
 | 
					    virtual bool AppendProgressColumn( const wxString &label, size_t model_column );
 | 
				
			||||||
 | 
					    virtual bool AppendDateColumn( const wxString &label, size_t model_column );
 | 
				
			||||||
    virtual bool AppendColumn( wxDataViewColumn *col );    
 | 
					    virtual bool AppendColumn( wxDataViewColumn *col );    
 | 
				
			||||||
    virtual size_t GetNumberOfColumns();
 | 
					    virtual size_t GetNumberOfColumns();
 | 
				
			||||||
    virtual bool DeleteColumn( size_t pos );
 | 
					    virtual bool DeleteColumn( size_t pos );
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -90,7 +90,20 @@ public:
 | 
				
			|||||||
    
 | 
					    
 | 
				
			||||||
    virtual bool Render( wxRect cell, wxDC *dc, int state ) = 0;
 | 
					    virtual bool Render( wxRect cell, wxDC *dc, int state ) = 0;
 | 
				
			||||||
    virtual wxSize GetSize() = 0;
 | 
					    virtual wxSize GetSize() = 0;
 | 
				
			||||||
    virtual bool Activate( wxRect cell ) { return false; };
 | 
					    
 | 
				
			||||||
 | 
					    virtual bool Activate( wxRect cell,
 | 
				
			||||||
 | 
					                           wxDataViewListModel *model, size_t col, size_t row )   
 | 
				
			||||||
 | 
					                           { return false; }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    virtual bool LeftClick( wxPoint cursor, wxRect cell, 
 | 
				
			||||||
 | 
					                           wxDataViewListModel *model, size_t col, size_t row )   
 | 
				
			||||||
 | 
					                           { return false; }
 | 
				
			||||||
 | 
					    virtual bool RightClick( wxPoint cursor, wxRect cell,
 | 
				
			||||||
 | 
					                           wxDataViewListModel *model, size_t col, size_t row )   
 | 
				
			||||||
 | 
					                           { return false; }
 | 
				
			||||||
 | 
					    virtual bool StartDrag( wxPoint cursor, wxRect cell, 
 | 
				
			||||||
 | 
					                           wxDataViewListModel *model, size_t col, size_t row )   
 | 
				
			||||||
 | 
					                           { return false; }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    // Create DC on request
 | 
					    // Create DC on request
 | 
				
			||||||
    virtual wxDC *GetDC();
 | 
					    virtual wxDC *GetDC();
 | 
				
			||||||
@@ -127,6 +140,30 @@ protected:
 | 
				
			|||||||
    DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewProgressCell)
 | 
					    DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewProgressCell)
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
 | 
					// --------------------------------------------------------- 
 | 
				
			||||||
 | 
					// wxDataViewDateCell
 | 
				
			||||||
 | 
					// --------------------------------------------------------- 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class wxDataViewDateCell: public wxDataViewCustomCell
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					    wxDataViewDateCell( const wxString &varianttype = wxT("datetime"), 
 | 
				
			||||||
 | 
					                        wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE );
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    bool SetValue( const wxVariant &value );
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    virtual bool Render( wxRect cell, wxDC *dc, int state );
 | 
				
			||||||
 | 
					    virtual wxSize GetSize();
 | 
				
			||||||
 | 
					    virtual bool Activate( wxRect cell,
 | 
				
			||||||
 | 
					                           wxDataViewListModel *model, size_t col, size_t row );
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					private:
 | 
				
			||||||
 | 
					    wxDateTime    m_date;
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					protected:
 | 
				
			||||||
 | 
					    DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewDateCell)
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
// --------------------------------------------------------- 
 | 
					// --------------------------------------------------------- 
 | 
				
			||||||
// wxDataViewColumn
 | 
					// wxDataViewColumn
 | 
				
			||||||
// --------------------------------------------------------- 
 | 
					// --------------------------------------------------------- 
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -30,6 +30,10 @@
 | 
				
			|||||||
// MyTextModel
 | 
					// MyTextModel
 | 
				
			||||||
// -------------------------------------
 | 
					// -------------------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					WX_DECLARE_LIST(wxDateTime,wxArrayDate);
 | 
				
			||||||
 | 
					#include <wx/listimpl.cpp>
 | 
				
			||||||
 | 
					WX_DEFINE_LIST(wxArrayDate);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class MyTextModel: public wxDataViewListModel
 | 
					class MyTextModel: public wxDataViewListModel
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
@@ -44,16 +48,24 @@ public:
 | 
				
			|||||||
            { m_colours.Add( wxT("red") ); m_colours.Add( wxT("green") ); }
 | 
					            { m_colours.Add( wxT("red") ); m_colours.Add( wxT("green") ); }
 | 
				
			||||||
        for (i = 0; i < 1000; i++)
 | 
					        for (i = 0; i < 1000; i++)
 | 
				
			||||||
            { m_progress.Add( i/10 ); }
 | 
					            { m_progress.Add( i/10 ); }
 | 
				
			||||||
 | 
					        for (i = 0; i < 1000; i++)
 | 
				
			||||||
 | 
					            { 
 | 
				
			||||||
 | 
					                wxDateTime *date = new wxDateTime( wxDateTime::Now() );
 | 
				
			||||||
 | 
					                m_dates.Append( date ); 
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    virtual size_t GetNumberOfRows() 
 | 
					    virtual size_t GetNumberOfRows() 
 | 
				
			||||||
        { return 1000; }
 | 
					        { return 1000; }
 | 
				
			||||||
    virtual size_t GetNumberOfCols()
 | 
					    virtual size_t GetNumberOfCols()
 | 
				
			||||||
        { return 6; }
 | 
					        { return 7; }
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
    // as reported by wxVariant
 | 
					    // as reported by wxVariant
 | 
				
			||||||
    virtual wxString GetColType( size_t col )
 | 
					    virtual wxString GetColType( size_t col )
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
 | 
					            if (col == 6)
 | 
				
			||||||
 | 
					                return wxT("datetime");
 | 
				
			||||||
 | 
					                
 | 
				
			||||||
            if (col == 5)
 | 
					            if (col == 5)
 | 
				
			||||||
                return wxT("long");
 | 
					                return wxT("long");
 | 
				
			||||||
                
 | 
					                
 | 
				
			||||||
@@ -65,6 +77,10 @@ public:
 | 
				
			|||||||
        
 | 
					        
 | 
				
			||||||
    virtual wxVariant GetValue( size_t col, size_t row )
 | 
					    virtual wxVariant GetValue( size_t col, size_t row )
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
 | 
					            if (col == 6)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                return (wxDateTime) *m_dates[row];
 | 
				
			||||||
 | 
					            } else
 | 
				
			||||||
            if (col == 5)
 | 
					            if (col == 5)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                return (long) m_progress[row];
 | 
					                return (long) m_progress[row];
 | 
				
			||||||
@@ -90,6 +106,10 @@ public:
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    virtual bool SetValue( wxVariant &value, size_t col, size_t row )
 | 
					    virtual bool SetValue( wxVariant &value, size_t col, size_t row )
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
 | 
					            if (col == 6)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                *m_dates[row] = value.GetDateTime();
 | 
				
			||||||
 | 
					            } else
 | 
				
			||||||
            if (col == 3)
 | 
					            if (col == 3)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                m_bools[row] = (int) value.GetBool();
 | 
					                m_bools[row] = (int) value.GetBool();
 | 
				
			||||||
@@ -105,6 +125,7 @@ public:
 | 
				
			|||||||
    wxArrayInt    m_bools;
 | 
					    wxArrayInt    m_bools;
 | 
				
			||||||
    wxArrayString m_colours;
 | 
					    wxArrayString m_colours;
 | 
				
			||||||
    wxArrayInt    m_progress;
 | 
					    wxArrayInt    m_progress;
 | 
				
			||||||
 | 
					    wxArrayDate   m_dates;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// -------------------------------------
 | 
					// -------------------------------------
 | 
				
			||||||
@@ -140,9 +161,9 @@ public:
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        return wxSize(20,8);
 | 
					        return wxSize(20,8);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    bool Activate( wxRect rect )
 | 
					    bool Activate( wxRect rect,
 | 
				
			||||||
 | 
					                   wxDataViewListModel *model, size_t col, size_t row )
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        wxPrintf( wxT("activate\n") );
 | 
					 | 
				
			||||||
        return false;
 | 
					        return false;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -249,6 +270,8 @@ MyFrame::MyFrame(wxFrame *frame, wxChar *title, int x, int y, int w, int h):
 | 
				
			|||||||
    
 | 
					    
 | 
				
			||||||
    dataview_left->AppendProgressColumn( wxT("progress"), 5 );
 | 
					    dataview_left->AppendProgressColumn( wxT("progress"), 5 );
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
 | 
					    dataview_left->AppendDateColumn( wxT("date"), 6 );
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
    // Right wxDataViewCtrl using the same model
 | 
					    // Right wxDataViewCtrl using the same model
 | 
				
			||||||
    dataview_right = new wxDataViewCtrl( this, -1 );
 | 
					    dataview_right = new wxDataViewCtrl( this, -1 );
 | 
				
			||||||
    dataview_right->AssociateModel( model );
 | 
					    dataview_right->AssociateModel( model );
 | 
				
			||||||
@@ -263,9 +286,9 @@ MyFrame::MyFrame(wxFrame *frame, wxChar *title, int x, int y, int w, int h):
 | 
				
			|||||||
    dataview_right->AppendColumn( column );
 | 
					    dataview_right->AppendColumn( column );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    wxBoxSizer *sizer = new wxBoxSizer( wxHORIZONTAL );
 | 
					    wxBoxSizer *sizer = new wxBoxSizer( wxHORIZONTAL );
 | 
				
			||||||
    sizer->Add( dataview_left, 1, wxGROW );
 | 
					    sizer->Add( dataview_left, 3, wxGROW );
 | 
				
			||||||
    sizer->Add(10,10);
 | 
					    sizer->Add(10,10);
 | 
				
			||||||
    sizer->Add( dataview_right, 1, wxGROW );
 | 
					    sizer->Add( dataview_right, 2, wxGROW );
 | 
				
			||||||
    SetSizer( sizer );
 | 
					    SetSizer( sizer );
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -208,6 +208,11 @@ bool wxDataViewCtrlBase::AppendProgressColumn( const wxString &label, size_t mod
 | 
				
			|||||||
    return AppendColumn( new wxDataViewColumn( label, new wxDataViewProgressCell(), model_column ) );
 | 
					    return AppendColumn( new wxDataViewColumn( label, new wxDataViewProgressCell(), model_column ) );
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool wxDataViewCtrlBase::AppendDateColumn( const wxString &label, size_t model_column )
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    return AppendColumn( new wxDataViewColumn( label, new wxDataViewDateCell(), model_column ) );
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool wxDataViewCtrlBase::AppendColumn( wxDataViewColumn *col )
 | 
					bool wxDataViewCtrlBase::AppendColumn( wxDataViewColumn *col )
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    m_cols.Append( (wxObject*) col );
 | 
					    m_cols.Append( (wxObject*) col );
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -25,6 +25,8 @@
 | 
				
			|||||||
#include <gtk/gtktreemodel.h>
 | 
					#include <gtk/gtktreemodel.h>
 | 
				
			||||||
#include <gtk/gtktreednd.h>
 | 
					#include <gtk/gtktreednd.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <gdk/gdkkeysyms.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//-----------------------------------------------------------------------------
 | 
					//-----------------------------------------------------------------------------
 | 
				
			||||||
// classes
 | 
					// classes
 | 
				
			||||||
//-----------------------------------------------------------------------------
 | 
					//-----------------------------------------------------------------------------
 | 
				
			||||||
@@ -447,6 +449,7 @@ struct _GtkWxCellRenderer
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  /*< private >*/
 | 
					  /*< private >*/
 | 
				
			||||||
  wxDataViewCustomCell *cell;
 | 
					  wxDataViewCustomCell *cell;
 | 
				
			||||||
 | 
					  guint32 last_click;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct _GtkWxCellRendererClass
 | 
					struct _GtkWxCellRendererClass
 | 
				
			||||||
@@ -522,6 +525,7 @@ static void
 | 
				
			|||||||
gtk_wx_cell_renderer_init (GtkWxCellRenderer *cell)
 | 
					gtk_wx_cell_renderer_init (GtkWxCellRenderer *cell)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    cell->cell = NULL;
 | 
					    cell->cell = NULL;
 | 
				
			||||||
 | 
					    cell->last_click = 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
@@ -627,7 +631,11 @@ gtk_wx_cell_renderer_render (GtkCellRenderer      *renderer,
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        wxRect renderrect( rect.x, rect.y, rect.width, rect.height );
 | 
					        wxRect renderrect( rect.x, rect.y, rect.width, rect.height );
 | 
				
			||||||
        wxWindowDC* dc = (wxWindowDC*) cell->GetDC();
 | 
					        wxWindowDC* dc = (wxWindowDC*) cell->GetDC();
 | 
				
			||||||
        dc->m_window = window;
 | 
					        if (dc->m_window == NULL)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            dc->m_window = window;
 | 
				
			||||||
 | 
					            dc->SetUpDC();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        int state = 0;
 | 
					        int state = 0;
 | 
				
			||||||
        if (flags & GTK_CELL_RENDERER_SELECTED)
 | 
					        if (flags & GTK_CELL_RENDERER_SELECTED)
 | 
				
			||||||
@@ -671,7 +679,53 @@ gtk_wx_cell_renderer_activate(
 | 
				
			|||||||
    
 | 
					    
 | 
				
			||||||
    wxRect renderrect( rect.x, rect.y, rect.width, rect.height );
 | 
					    wxRect renderrect( rect.x, rect.y, rect.width, rect.height );
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    return cell->Activate( renderrect );
 | 
					    wxDataViewListModel *model = cell->GetOwner()->GetOwner()->GetModel();
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    GtkTreePath *treepath = gtk_tree_path_new_from_string( path );
 | 
				
			||||||
 | 
					    size_t model_row = (size_t)gtk_tree_path_get_indices (treepath)[0];
 | 
				
			||||||
 | 
					    gtk_tree_path_free( treepath );
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    size_t model_col = cell->GetOwner()->GetModelColumn();
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    if (event->type == GDK_BUTTON_PRESS)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        GdkEventButton *button_event = (GdkEventButton*) event;
 | 
				
			||||||
 | 
					        wxPoint pt( ((int) button_event->x) - renderrect.x, 
 | 
				
			||||||
 | 
					                    ((int) button_event->y) - renderrect.y );
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        bool ret = false;
 | 
				
			||||||
 | 
					        if (button_event->button == 1)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if (cell->LeftClick( pt, renderrect, model, model_col, model_row ))
 | 
				
			||||||
 | 
					                ret = true;
 | 
				
			||||||
 | 
					            if (button_event->time - wxrenderer->last_click < 400)
 | 
				
			||||||
 | 
					                if (cell->Activate( renderrect, model, model_col, model_row ))
 | 
				
			||||||
 | 
					                    ret = true;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        if (button_event->button == 3)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if (cell->RightClick( pt, renderrect, model, model_col, model_row ))
 | 
				
			||||||
 | 
					                ret = true;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        wxrenderer->last_click = button_event->time;
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        return ret;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    if (event->type == GDK_KEY_PRESS)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        wxPrintf( wxT("key\n") );
 | 
				
			||||||
 | 
					        GdkEventKey *key_event = (GdkEventKey*) event;
 | 
				
			||||||
 | 
					        if ((key_event->keyval == GDK_Return) ||
 | 
				
			||||||
 | 
					            (key_event->keyval == GDK_Linefeed) || 
 | 
				
			||||||
 | 
					            (key_event->keyval == GDK_Execute))
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return cell->Activate( renderrect, model, model_col, model_row );
 | 
				
			||||||
 | 
					        } 
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    return false;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// --------------------------------------------------------- 
 | 
					// --------------------------------------------------------- 
 | 
				
			||||||
@@ -970,9 +1024,9 @@ public:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        m_cmap = gtk_widget_get_colormap( widget ? widget : window->m_widget );
 | 
					        m_cmap = gtk_widget_get_colormap( widget ? widget : window->m_widget );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        SetUpDC();
 | 
					        // Set m_window later
 | 
				
			||||||
 | 
					        // SetUpDC();
 | 
				
			||||||
        m_owner = window;
 | 
					        // m_owner = window;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1022,7 +1076,13 @@ wxDataViewCustomCell::~wxDataViewCustomCell()
 | 
				
			|||||||
wxDC *wxDataViewCustomCell::GetDC()
 | 
					wxDC *wxDataViewCustomCell::GetDC()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    if (m_dc == NULL)
 | 
					    if (m_dc == NULL)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        if (GetOwner() == NULL)
 | 
				
			||||||
 | 
					            return NULL;
 | 
				
			||||||
 | 
					        if (GetOwner()->GetOwner() == NULL)
 | 
				
			||||||
 | 
					            return NULL;
 | 
				
			||||||
        m_dc = new wxDataViewCtrlDC( GetOwner()->GetOwner() );
 | 
					        m_dc = new wxDataViewCtrlDC( GetOwner()->GetOwner() );
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
    return m_dc;
 | 
					    return m_dc;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -1108,6 +1168,49 @@ wxSize wxDataViewProgressCell::GetSize()
 | 
				
			|||||||
    return wxSize(40,12);
 | 
					    return wxSize(40,12);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
 | 
					// --------------------------------------------------------- 
 | 
				
			||||||
 | 
					// wxDataViewDateCell
 | 
				
			||||||
 | 
					// --------------------------------------------------------- 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					IMPLEMENT_ABSTRACT_CLASS(wxDataViewDateCell, wxDataViewCustomCell)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					wxDataViewDateCell::wxDataViewDateCell( const wxString &varianttype,
 | 
				
			||||||
 | 
					                        wxDataViewCellMode mode ) :
 | 
				
			||||||
 | 
					    wxDataViewCustomCell( varianttype, mode )
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					bool wxDataViewDateCell::SetValue( const wxVariant &value )
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    m_date = value.GetDateTime();
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    return true;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool wxDataViewDateCell::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 wxDataViewDateCell::GetSize()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    wxDataViewCtrl* view = GetOwner()->GetOwner();
 | 
				
			||||||
 | 
					    wxString tmp = m_date.FormatDate();
 | 
				
			||||||
 | 
					    wxCoord x,y,d;
 | 
				
			||||||
 | 
					    view->GetTextExtent( tmp, &x, &y, &d );
 | 
				
			||||||
 | 
					    return wxSize(x,y+d);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool wxDataViewDateCell::Activate( wxRect cell, wxDataViewListModel *model, size_t col, size_t row )
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return true;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// --------------------------------------------------------- 
 | 
					// --------------------------------------------------------- 
 | 
				
			||||||
// wxDataViewColumn
 | 
					// wxDataViewColumn
 | 
				
			||||||
// --------------------------------------------------------- 
 | 
					// --------------------------------------------------------- 
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user