]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/widgets/datepick.cpp
Make height of red square depend on value in the model
[wxWidgets.git] / samples / widgets / datepick.cpp
index 04ebb2e20ee41ea93b96882280c05d8fa138bedd..e553c3581f967fae39b313d79516e1eb2403dc5c 100644 (file)
@@ -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(day, wxDateTime::Month(month - 1), 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