From 95c336d620c49d16f2c6ceb52779bb657bb59494 Mon Sep 17 00:00:00 2001 From: =?utf8?q?W=C5=82odzimierz=20Skiba?= Date: Sun, 10 Dec 2006 10:49:18 +0000 Subject: [PATCH] Implemented Set button for date picker page. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43892 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- samples/widgets/datepick.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/samples/widgets/datepick.cpp b/samples/widgets/datepick.cpp index 04ebb2e20e..12ee2f8fcd 100644 --- a/samples/widgets/datepick.cpp +++ b/samples/widgets/datepick.cpp @@ -156,7 +156,7 @@ void DatePickerWidgetsPage::CreateContent() sizerLeft->Add( CreateSizerWithTextAndLabel( wxT("&Year:"), DatePickerPage_Year , &m_year ), 0, wxALL | wxALIGN_RIGHT , 5 ); - sizerLeft->Add( new wxButton( this, wxID_ANY, wxT("&Set date") ), + sizerLeft->Add( new wxButton( this, DatePickerPage_Set, wxT("&Set date") ), 0, wxALL , 5 ); // right pane @@ -223,6 +223,27 @@ void DatePickerWidgetsPage::OnButtonReset(wxCommandEvent& WXUNUSED(event)) void DatePickerWidgetsPage::OnButtonSet(wxCommandEvent& WXUNUSED(event)) { + long day = 0, month = 0, year = 0; + if ( m_day->GetValue().ToLong(&day) && + m_month->GetValue().ToLong(&month) && + m_year->GetValue().ToLong(&year) ) + { + const wxDateTime someDay(wxDateTime::wxDateTime_t(day), + wxDateTime::Month(month), + year); + if(someDay.IsValid()) + { + m_datePicker->SetValue(someDay); + } + else + { + wxLogError(_T("Date is invalid")); + } + } + else + { + wxLogError(_T("One of inputs is not number")); + } } #endif // wxUSE_DATEPICKCTRL -- 2.45.2