- const int height = m_txt->GetBestSize().y - 4; // FIXME: fudge
- wxBitmap bmp(height, height);
- {
- wxMemoryDC dc;
- dc.SelectObject(bmp);
- wxRendererNative::Get().DrawComboBoxDropButton
- (
- this,
- dc,
- wxRect(0, 0, height, height)
- );
- }
-
- 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(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"));
-
-
-#ifdef __WXMSW__
- #define CALBORDER 0
- #define RIGHTBUTTONBORDER 2
- #define TOPBUTTONBORDER 1
-#else
- #define CALBORDER 4
- #define RIGHTBUTTONBORDER 0
- #define TOPBUTTONBORDER 0
-#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)
- {
- 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);