- m_txt=new wxTextCtrl(this, CTRLID_TXT, txt);
- m_txt->Connect(wxID_ANY, wxID_ANY, wxEVT_KEY_DOWN,
- (wxObjectEventFunction)&wxDatePickerCtrl::OnEditKey,
- 0, this);
- m_txt->Connect(wxID_ANY, wxID_ANY, wxEVT_KILL_FOCUS,
- (wxObjectEventFunction)&wxDatePickerCtrl::OnKillFocus,
- 0, this);
- SetFormat(wxT("%x"));
-
- m_btn = new wxBitmapButton(this, CTRLID_BTN, bmp);
-
- m_dlg = new wxDialog(this, CTRLID_CAL, wxEmptyString,
- wxDefaultPosition, wxDefaultSize,
- wxSIMPLE_BORDER);
- m_dlg->SetFont(GetFont());
-
- wxPanel *panel=new wxPanel(m_dlg, 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(CTRLID_CAL, CTRLID_CAL, wxEVT_CALENDAR_SEL_CHANGED,
- (wxObjectEventFunction)&wxDatePickerCtrl::OnSelChange,
- 0, this);
- m_cal->Connect(wxID_ANY, wxID_ANY, wxEVT_KEY_DOWN,
- (wxObjectEventFunction)&wxDatePickerCtrl::OnCalKey,
- 0, this);
- m_cal->Connect(CTRLID_CAL, CTRLID_CAL, wxEVT_CALENDAR_DOUBLECLICKED,
- (wxObjectEventFunction)&wxDatePickerCtrl::OnSelChange,
- 0, this);
- m_cal->Connect(CTRLID_CAL, CTRLID_CAL, wxEVT_CALENDAR_DAY_CHANGED,
- (wxObjectEventFunction)&wxDatePickerCtrl::OnSelChange,
- 0, this);
- m_cal->Connect(CTRLID_CAL, CTRLID_CAL, wxEVT_CALENDAR_MONTH_CHANGED,
- (wxObjectEventFunction)&wxDatePickerCtrl::OnSelChange,
- 0, this);
- m_cal->Connect(CTRLID_CAL, CTRLID_CAL, wxEVT_CALENDAR_YEAR_CHANGED,
- (wxObjectEventFunction)&wxDatePickerCtrl::OnSelChange,
- 0, this);
-
- wxWindow *yearControl = m_cal->GetYearControl();
-
- Connect(wxID_ANY, wxID_ANY, wxEVT_SET_FOCUS,
- (wxObjectEventFunction)&wxDatePickerCtrl::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();
-
-#ifdef __WXMSW__
-#define CALBORDER 0
-#else
-#define CALBORDER 4
-#endif