- m_txt = new wxTextCtrl(this, CTRLID_TXT, wxEmptyString, wxDefaultPosition, wxDefaultSize, TXTCTRL_FLAGS);
-
- 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 - BUTTONBORDER;
-
- 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"));
-
- width = yearPosition.x + yearSize.x+2+CALBORDER/2;
- if (width < calSize.x-4)
- width = calSize.x-4;
-
- int calPos = (width-calSize.x)/2;
- if (calPos == -1)
- {
- calPos = 0;
- width += 2;
- }
- m_cal->SetSize(calPos, 0, calSize.x, calSize.y);
- yearControl->SetSize(width-yearSize.x-CALBORDER/2, yearPosition.y,
- yearSize.x, yearSize.y);
- m_cal->GetMonthControl()->Move(0, 0);