- m_txt=new wxTextCtrl(this, CTRLID_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);
-
- m_btn = new wxBitmapButton(this, CTRLID_BTN, bmp);
-
- m_popup = new wxPopupWindow(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(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();
-
- SetFormat(wxT("%x"));
-
- if (date.IsValid())
- m_txt->SetValue(date.Format(m_format));
-
-
-#ifdef __WXMSW__
-#define CALBORDER 0
-#else
-#define CALBORDER 4
-#endif
-
- 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)