Most things about wxDataViewDateCell work.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@37748 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
2006-02-27 09:34:50 +00:00
parent 33c0d0ed75
commit 7ea3a0de1e
2 changed files with 62 additions and 12 deletions

View File

@@ -285,6 +285,10 @@ MyFrame::MyFrame(wxFrame *frame, wxChar *title, int x, int y, int w, int h):
column = new wxDataViewColumn( wxT("bool"), toggle_cell, 3 );
dataview_right->AppendColumn( column );
dataview_right->AppendDateColumn( wxT("date"), 6 );
// layout dataview controls.
wxBoxSizer *sizer = new wxBoxSizer( wxHORIZONTAL );
sizer->Add( dataview_left, 3, wxGROW );
sizer->Add(10,10);

View File

@@ -17,6 +17,9 @@
#include "wx/dataview.h"
#include "wx/stockitem.h"
#include "wx/dcclient.h"
#include "wx/calctrl.h"
#include "wx/popupwin.h"
#include "wx/sizer.h"
#include "wx/gtk/private.h"
#include "wx/gtk/win_gtk.h"
@@ -698,6 +701,7 @@ gtk_wx_cell_renderer_activate(
{
if (cell->LeftClick( pt, renderrect, model, model_col, model_row ))
ret = true;
// TODO: query system double-click time
if (button_event->time - wxrenderer->last_click < 400)
if (cell->Activate( renderrect, model, model_col, model_row ))
ret = true;
@@ -713,18 +717,6 @@ gtk_wx_cell_renderer_activate(
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;
}
@@ -1172,6 +1164,51 @@ wxSize wxDataViewProgressCell::GetSize()
// wxDataViewDateCell
// ---------------------------------------------------------
class wxDataViewDateCellPopupTransient: public wxPopupTransientWindow
{
public:
wxDataViewDateCellPopupTransient( wxWindow* parent, wxDateTime *value,
wxDataViewListModel *model, size_t col, size_t 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;
size_t m_col;
size_t m_row;
private:
DECLARE_EVENT_TABLE()
};
BEGIN_EVENT_TABLE(wxDataViewDateCellPopupTransient,wxPopupTransientWindow)
EVT_CALENDAR( -1, wxDataViewDateCellPopupTransient::OnCalendar )
END_EVENT_TABLE()
void wxDataViewDateCellPopupTransient::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_ABSTRACT_CLASS(wxDataViewDateCell, wxDataViewCustomCell)
wxDataViewDateCell::wxDataViewDateCell( const wxString &varianttype,
@@ -1207,6 +1244,15 @@ wxSize wxDataViewDateCell::GetSize()
bool wxDataViewDateCell::Activate( wxRect cell, wxDataViewListModel *model, size_t col, size_t row )
{
wxVariant variant = model->GetValue( col, row );
wxDateTime value = variant.GetDateTime();
wxDataViewDateCellPopupTransient *popup = new wxDataViewDateCellPopupTransient(
GetOwner()->GetOwner()->GetParent(), &value, model, col, row );
wxPoint pos = wxGetMousePosition();
popup->Move( pos );
popup->Layout();
popup->Popup( popup->m_cal );
return true;
}