- m_txt = new wxTextCtrl(this, CTRLID_TXT);
-
- m_txt->Connect(wxEVT_KEY_DOWN,
- wxKeyEventHandler(wxDatePickerCtrlGeneric::OnEditKey),
- NULL, this);
- m_txt->Connect(wxEVT_KILL_FOCUS,
- wxFocusEventHandler(wxDatePickerCtrlGeneric::OnKillFocus),
- NULL, this);
-
- const int height = m_txt->GetBestSize().y;
-
- m_btn = new wxDropdownButton(this, CTRLID_BTN, wxDefaultPosition, wxSize(height, height));
-
- m_popup = new wxDatePopupInternal(this);
- m_popup->SetFont(GetFont());
-
- wxPanel *panel=new wxPanel(m_popup, CTRLID_PAN,
- wxPoint(0, 0), wxDefaultSize,
- wxSUNKEN_BORDER);
- m_cal = new wxCalendarCtrl(panel, CTRLID_CAL, wxDefaultDateTime,
- wxPoint(0, 0), wxDefaultSize,
- wxCAL_SHOW_HOLIDAYS | wxSUNKEN_BORDER);
- m_cal->Connect(wxEVT_CALENDAR_SEL_CHANGED,
- wxCalendarEventHandler(wxDatePickerCtrlGeneric::OnSelChange),
- NULL, this);
- m_cal->Connect(wxEVT_KEY_DOWN,
- wxKeyEventHandler(wxDatePickerCtrlGeneric::OnCalKey),
- NULL, this);
- m_cal->Connect(wxEVT_CALENDAR_DOUBLECLICKED,
- wxCalendarEventHandler(wxDatePickerCtrlGeneric::OnSelChange),
- NULL, this);
- m_cal->Connect(wxEVT_CALENDAR_DAY_CHANGED,
- wxCalendarEventHandler(wxDatePickerCtrlGeneric::OnSelChange),
- NULL, this);
- m_cal->Connect(wxEVT_CALENDAR_MONTH_CHANGED,
- wxCalendarEventHandler(wxDatePickerCtrlGeneric::OnSelChange),
- NULL, this);
- m_cal->Connect(wxEVT_CALENDAR_YEAR_CHANGED,
- wxCalendarEventHandler(wxDatePickerCtrlGeneric::OnSelChange),
- NULL, this);
-
- wxWindow *yearControl = m_cal->GetYearControl();
-
- Connect(wxEVT_SET_FOCUS,
- wxFocusEventHandler(wxDatePickerCtrlGeneric::OnSetFocus));
-
- wxClientDC dc(yearControl);
- dc.SetFont(m_font);
- wxCoord width, dummy;
- dc.GetTextExtent(wxT("2000"), &width, &dummy);
- width += ConvertDialogToPixels(wxSize(20, 0)).x;
-
- wxSize calSize = m_cal->GetBestSize();
- wxSize yearSize = yearControl->GetSize();
- yearSize.x = width;
-
- wxPoint yearPosition = yearControl->GetPosition();
-
- SetFormat(wxT("%x"));
-
-
-#ifdef __WXMSW__
- #define CALBORDER 0
- #define RIGHTBUTTONBORDER 2
- #define TOPBUTTONBORDER 1
-#else
- #define CALBORDER 4
- #define RIGHTBUTTONBORDER 0
- #define TOPBUTTONBORDER 0
-#endif
-
- width = yearPosition.x + yearSize.x+2+CALBORDER/2;
- if (width < calSize.x-4)
- width = calSize.x-4;