// global variables
// ----------------------------------------------------------------------------
-// this should have been a flag in wxDatePickerCtrlGeneric itself but adding it
-// there now would break backwards compatibility, so put it here as a global:
-// this shouldn't be a big problem as only one (GUI) thread normally can call
-// wxDatePickerCtrlGeneric::SetValue() and so it can be only ever used for one
-// control at a time
-//
-// if the value is not NULL, it points to the control which is inside SetValue()
-static wxDatePickerCtrlGeneric *gs_inSetValue = NULL;
// ----------------------------------------------------------------------------
// local classes
wxPoint yearPosition = yearControl->GetPosition();
- SetFormat(wxT("%x"));
+ SetFormat("%x");
width = yearPosition.x + yearSize.x+2+CALBORDER/2;
if (width < calSize.x-4)
if ( !s.empty() )
{
- pDt->ParseFormat(s, m_format);
+ pDt->ParseFormat(s.c_str(), m_format);
if ( !pDt->IsValid() )
return false;
}
cev.SetEventObject(datePicker);
cev.SetId(datePicker->GetId());
cev.SetDate(dt);
- GetParent()->ProcessEvent(cev);
+ datePicker->GetEventHandler()->ProcessEvent(cev);
wxDateEvent event(datePicker, dt, wxEVT_DATE_CHANGED);
- datePicker->GetParent()->ProcessEvent(event);
+ datePicker->GetEventHandler()->ProcessEvent(event);
}
private:
return m_combo->GetParent()->HasFlag(flag);
}
- bool SetFormat(const wxChar *fmt)
+ bool SetFormat(const wxString& fmt)
{
m_format.clear();
BEGIN_EVENT_TABLE(wxDatePickerCtrlGeneric, wxDatePickerCtrlBase)
EVT_TEXT(wxID_ANY, wxDatePickerCtrlGeneric::OnText)
EVT_SIZE(wxDatePickerCtrlGeneric::OnSize)
+ EVT_SET_FOCUS(wxDatePickerCtrlGeneric::OnFocus)
END_EVENT_TABLE()
#ifndef wxHAS_NATIVE_DATEPICKCTRL
m_combo = new wxComboCtrl(this, -1, wxEmptyString,
wxDefaultPosition, wxDefaultSize);
+ m_combo->SetCtrlMainWnd(this);
+
m_popup = new wxCalendarComboPopup();
+#if defined(__WXMSW__)
+ // without this keyboard navigation in month control doesn't work
+ m_combo->UseAltPopupWindow();
+#endif
m_combo->SetPopupControl(m_popup);
m_cal = m_popup;
m_popup->SetDateValue(date.IsValid() ? date : wxDateTime::Today());
- SetBestFittingSize(size);
+ SetInitialSize(size);
return true;
}
{
ev.SetEventObject(this);
ev.SetId(GetId());
- GetParent()->ProcessEvent(ev);
+ GetParent()->GetEventHandler()->ProcessEvent(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
}
+void wxDatePickerCtrlGeneric::OnFocus(wxFocusEvent& WXUNUSED(event))
+{
+ m_combo->SetFocus();
+}
+
+
#endif // wxUSE_DATEPICKCTRL_GENERIC
#endif // wxUSE_DATEPICKCTRL