- wxBitmapButton *btn = new wxBitmapButton(this, CTRLID_BTN, bmp);
- btn->SetMargins(0, 0);
- m_btn = btn;
-
- 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)
- (wxEventFunction)
- (wxCalendarEventFunction)
- &wxDatePickerCtrlGeneric::OnSelChange,
- 0, this);
- m_cal->Connect(wxID_ANY, wxID_ANY, wxEVT_KEY_DOWN,
- (wxObjectEventFunction)
- (wxEventFunction)
- (wxCharEventFunction)
- &wxDatePickerCtrlGeneric::OnCalKey,
- 0, this);
- m_cal->Connect(CTRLID_CAL, CTRLID_CAL, wxEVT_CALENDAR_DOUBLECLICKED,
- (wxObjectEventFunction)
- (wxEventFunction)
- (wxCalendarEventFunction)
- &wxDatePickerCtrlGeneric::OnSelChange,
- 0, this);
- m_cal->Connect(CTRLID_CAL, CTRLID_CAL, wxEVT_CALENDAR_DAY_CHANGED,
- (wxObjectEventFunction)
- (wxEventFunction)
- (wxCalendarEventFunction)
- &wxDatePickerCtrlGeneric::OnSelChange,
- 0, this);
- m_cal->Connect(CTRLID_CAL, CTRLID_CAL, wxEVT_CALENDAR_MONTH_CHANGED,
- (wxObjectEventFunction)
- (wxEventFunction)
- (wxCalendarEventFunction)
- &wxDatePickerCtrlGeneric::OnSelChange,
- 0, this);
- m_cal->Connect(CTRLID_CAL, CTRLID_CAL, wxEVT_CALENDAR_YEAR_CHANGED,
- (wxObjectEventFunction)
- (wxEventFunction)
- (wxCalendarEventFunction)
- &wxDatePickerCtrlGeneric::OnSelChange,
- 0, this);
-
- wxWindow *yearControl = m_cal->GetYearControl();
-
- Connect(wxID_ANY, wxID_ANY, wxEVT_SET_FOCUS,
- (wxObjectEventFunction)
- (wxEventFunction)
- (wxFocusEventFunction)
- &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"));
-
- if (date.IsValid())
- m_txt->SetValue(date.Format(m_format));
-
-
-#ifdef __WXMSW__
-#define CALBORDER 0
-#else
-#define CALBORDER 4
-#endif