From a7c58211dbcef64535223ca550cc8ad34f890cf8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?W=C5=82odzimierz=20Skiba?= Date: Mon, 14 Feb 2005 18:28:56 +0000 Subject: [PATCH] Minor editing. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@32042 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- samples/calendar/calendar.cpp | 19 +++++++++++-------- src/generic/datectlg.cpp | 11 +++++++---- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/samples/calendar/calendar.cpp b/samples/calendar/calendar.cpp index fb34cfe280..9cc91601f7 100644 --- a/samples/calendar/calendar.cpp +++ b/samples/calendar/calendar.cpp @@ -96,7 +96,7 @@ public: void SetDate(); void Today(); - + private: wxCalendarCtrl *m_calendar; wxStaticText *m_date; @@ -590,7 +590,7 @@ void MyPanel::Today() #if wxUSE_DATEPICKCTRL MyDialog::MyDialog(wxWindow *parent, const wxDateTime& dt, int dtpStyle) - : wxDialog(parent, -1, wxString(_T("Calendar: Choose a date"))) + : wxDialog(parent, wxID_ANY, wxString(_T("Calendar: Choose a date"))) { wxStdDialogButtonSizer *sizerBtns = new wxStdDialogButtonSizer; sizerBtns->AddButton(new wxButton(this, wxID_OK)); @@ -598,16 +598,16 @@ MyDialog::MyDialog(wxWindow *parent, const wxDateTime& dt, int dtpStyle) sizerBtns->Finalise(); wxSizer *sizerText = new wxBoxSizer(wxHORIZONTAL); - sizerText->Add(new wxStaticText(this, -1, _T("Date in ISO format: ")), + sizerText->Add(new wxStaticText(this, wxID_ANY, _T("Date in ISO format: ")), wxSizerFlags().Border().Align(wxALIGN_CENTRE_VERTICAL)); - m_text = new wxTextCtrl(this, -1); + m_text = new wxTextCtrl(this, wxID_ANY); sizerText->Add(m_text, wxSizerFlags(). Expand().Border().Align(wxALIGN_CENTRE_VERTICAL)); wxSizer *sizerTop = new wxBoxSizer(wxVERTICAL); sizerTop->Add(new wxStaticText ( - this, -1, + this, wxID_ANY, _T("Enter your birthday date (not before 20th century):") ), wxSizerFlags().Border()); @@ -615,13 +615,13 @@ MyDialog::MyDialog(wxWindow *parent, const wxDateTime& dt, int dtpStyle) #if wxUSE_DATEPICKCTRL_GENERIC wxFrame *frame = (wxFrame *)wxGetTopLevelParent(parent); if ( frame && frame->GetMenuBar()->IsChecked(Calendar_DatePicker_Generic) ) - m_datePicker = new wxDatePickerCtrlGeneric(this, -1, dt, + m_datePicker = new wxDatePickerCtrlGeneric(this, wxID_ANY, dt, wxDefaultPosition, wxDefaultSize, dtpStyle); else #endif // wxUSE_DATEPICKCTRL_GENERIC - m_datePicker = new wxDatePickerCtrl(this, -1, dt, + m_datePicker = new wxDatePickerCtrl(this, wxID_ANY, dt, wxDefaultPosition, wxDefaultSize, dtpStyle); m_datePicker->SetRange(wxDateTime(1, wxDateTime::Jan, 1900), @@ -640,7 +640,10 @@ MyDialog::MyDialog(wxWindow *parent, const wxDateTime& dt, int dtpStyle) void MyDialog::OnDateChange(wxDateEvent& event) { const wxDateTime dt = event.GetDate(); - m_text->SetValue(dt.IsValid()? dt.FormatISODate() : wxString()); + if(dt.IsValid()) + m_text->SetValue(dt.FormatISODate()); + else + m_text->SetValue(wxEmptyString); } #endif // wxUSE_DATEPICKCTRL diff --git a/src/generic/datectlg.cpp b/src/generic/datectlg.cpp index 3ccd9d0553..4602a9c107 100644 --- a/src/generic/datectlg.cpp +++ b/src/generic/datectlg.cpp @@ -506,7 +506,7 @@ void wxDatePickerCtrlGeneric::DropDown(bool down) if (down) { wxDateTime dt; - if (!m_txt->GetValue().IsEmpty()) + if (!m_txt->GetValue().empty()) dt.ParseFormat(m_txt->GetValue(), m_format); if (dt.IsValid()) @@ -588,7 +588,10 @@ void wxDatePickerCtrlGeneric::OnKillFocus(wxFocusEvent &ev) dt = m_currentDate; } - m_txt->SetValue(dt.IsValid()? dt.Format(m_format) : wxString()); + if(dt.IsValid()) + m_txt->SetValue(dt.Format(m_format)); + else + m_txt->SetValue(wxEmptyString); // notify that we had to change the date after validation if ( (dt.IsValid() && m_currentDate != dt) || @@ -630,9 +633,9 @@ void wxDatePickerCtrlGeneric::OnText(wxCommandEvent &ev) // We'll create an additional event if the date is valid. // If the date isn't valid, the user's probably in the middle of typing - wxString txt=m_txt->GetValue(); + wxString txt = m_txt->GetValue(); wxDateTime dt; - if (!txt.IsEmpty()) + if (!txt.empty()) { dt.ParseFormat(txt, m_format); if (!dt.IsValid()) -- 2.45.2