- wxBitmapButton *btn = new wxBitmapButton(this, CTRLID_BTN, bmp);
- btn->SetMargins(0, 0);
- m_btn = btn;
-
- 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(CTRLID_CAL, CTRLID_CAL, wxEVT_CALENDAR_SEL_CHANGED,
- (wxObjectEventFunction)&wxDatePickerCtrlGeneric::OnSelChange,
- 0, this);
- m_cal->Connect(wxID_ANY, wxID_ANY, wxEVT_KEY_DOWN,
- (wxObjectEventFunction)&wxDatePickerCtrlGeneric::OnCalKey,
- 0, this);
- m_cal->Connect(CTRLID_CAL, CTRLID_CAL, wxEVT_CALENDAR_DOUBLECLICKED,
- (wxObjectEventFunction)&wxDatePickerCtrlGeneric::OnSelChange,
- 0, this);
- m_cal->Connect(CTRLID_CAL, CTRLID_CAL, wxEVT_CALENDAR_DAY_CHANGED,
- (wxObjectEventFunction)&wxDatePickerCtrlGeneric::OnSelChange,
- 0, this);
- m_cal->Connect(CTRLID_CAL, CTRLID_CAL, wxEVT_CALENDAR_MONTH_CHANGED,
- (wxObjectEventFunction)&wxDatePickerCtrlGeneric::OnSelChange,
- 0, this);
- m_cal->Connect(CTRLID_CAL, CTRLID_CAL, wxEVT_CALENDAR_YEAR_CHANGED,
- (wxObjectEventFunction)&wxDatePickerCtrlGeneric::OnSelChange,
- 0, this);
-
- wxWindow *yearControl = m_cal->GetYearControl();
-
- Connect(wxID_ANY, wxID_ANY, wxEVT_SET_FOCUS,
- (wxObjectEventFunction)&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