Minor editing.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@32042 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -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
|
||||
|
@@ -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())
|
||||
|
Reference in New Issue
Block a user