+ m_marginX = 0;
+ m_marginY = 0;
+
+ m_useDropArrow = DROPBUT_USEDROPARROW(style & wxBU_COMBO);
+
+ wxBitmap chkBmp(15,15); // arbitrary
+ if ( !wxBitmapButton::Create(parent, id, chkBmp,
+ pos, wxDefaultSize,
+ style | (m_useDropArrow ? wxBU_AUTODRAW : wxNO_BORDER),
+ validator) )
+ return false;
+
+ const wxSize sz = GetSize();
+ int w = chkBmp.GetWidth(),
+ h = chkBmp.GetHeight();
+ m_borderX = sz.x - m_marginX - w;
+ m_borderY = sz.y - m_marginY - h;
+
+ DoMoveWindow(pos.x, pos.y, size.x, size.y);
+
+ return true;
+}
+
+
+void wxDropdownButton::RecreateBitmaps(int w, int h)
+{
+ wxMemoryDC dc;
+
+ int borderX = m_marginX + m_borderX;
+ int borderY = m_marginY + m_borderY;
+ int bw = w - borderX;
+ int bh = h - borderY;
+
+ wxBitmap bmp(bw, bh);
+ wxBitmap bmpSel(bw, bh);
+ wxRect r(0,0,w,h);
+
+ wxRendererNative& renderer = wxRendererNative::Get();
+
+ dc.SelectObject(bmp);
+
+ if ( m_useDropArrow )
+ {
+ // Use DrawDropArrow on transparent background.
+
+ wxColour magic(255,0,255);
+ wxBrush magicBrush(magic);
+ r.x = -(borderX/2);
+ r.y = -(borderY/2);
+
+ dc.SetBrush( magicBrush );
+ dc.SetPen( *wxTRANSPARENT_PEN );
+ dc.DrawRectangle(0,0,bw,bh);
+ renderer.DrawDropArrow(this, dc, r);
+ dc.SelectObject( wxNullBitmap );
+ wxMask *mask = new wxMask( bmp, magic );
+ bmp.SetMask( mask );
+
+ dc.SelectObject(bmpSel);
+
+ dc.SetBrush( magicBrush );
+ dc.SetPen( *wxTRANSPARENT_PEN );
+ dc.DrawRectangle(0,0,bw,bh);
+ renderer.DrawDropArrow(this, dc, r, wxCONTROL_PRESSED);
+ dc.SelectObject( wxNullBitmap );
+ mask = new wxMask( bmpSel, magic );
+ bmpSel.SetMask( mask );
+ }
+ else
+ {
+ // Use DrawComboBoxDropButton for the entire button
+ // (also render extra "hot" button state).
+
+ renderer.DrawComboBoxDropButton(this, dc, r);
+
+ dc.SelectObject(bmpSel);
+
+ renderer.DrawComboBoxDropButton(this, dc, r, wxCONTROL_PRESSED);
+
+ wxBitmap bmpHot(bw,bh);
+ dc.SelectObject(bmpHot);
+ renderer.DrawComboBoxDropButton(this, dc, r, wxCONTROL_CURRENT);
+
+ m_bmpNormal = bmp;
+ m_bmpHot = bmpHot;
+ }
+
+ SetBitmapLabel(bmp);
+ SetBitmapSelected(bmpSel);
+}
+
+
+void wxDropdownButton::DoMoveWindow(int x, int y, int w, int h)
+{
+ if (w < 0)
+ w = DROPBUT_DEFAULT_WIDTH;
+
+ wxBitmapButton::DoMoveWindow(x, y, w, h);
+}
+
+
+void wxDropdownButton::OnSize(wxSizeEvent& event)
+{
+ if ( m_borderX >= 0 && m_borderY >= 0 )
+ {
+ int w, h;
+ GetClientSize(&w,&h);
+
+ if ( w > 1 && h > 1 )
+ RecreateBitmaps(w,h);
+ }
+ event.Skip();
+}
+
+
+void wxDropdownButton::OnMouseEnter(wxMouseEvent& event)
+{
+ if ( !m_useDropArrow )
+ SetBitmapLabel(m_bmpHot);
+
+ event.Skip();
+}
+
+
+void wxDropdownButton::OnMouseLeave(wxMouseEvent& event)
+{
+ if ( !m_useDropArrow )
+ SetBitmapLabel(m_bmpNormal);
+
+ event.Skip();
+}
+
+
+#if wxUSE_POPUPWIN
+
+#include "wx/popupwin.h"
+
+class wxDatePopupInternal : public wxPopupTransientWindow
+{
+public:
+ wxDatePopupInternal(wxWindow *parent) : wxPopupTransientWindow(parent) { }
+
+ void ShowAt(int x, int y)
+ {
+ Position(wxPoint(x, y), wxSize(0, 0));
+ Popup();
+ }
+
+ void Hide()
+ {
+ Dismiss();
+ }
+};
+
+#else // !wxUSE_POPUPWIN
+
+class wxDatePopupInternal : public wxDialog
+{
+public:
+ wxDatePopupInternal(wxWindow *parent)
+ : wxDialog(parent,
+ wxID_ANY,
+ wxEmptyString,
+ wxDefaultPosition,
+ wxDefaultSize,
+ wxSIMPLE_BORDER)
+ {
+ }
+
+ void ShowAt(int x, int y)
+ {
+ Show();
+ Move(x, y);
+ }
+
+ void Hide()
+ {
+ wxDialog::Hide();
+ }
+};
+
+#endif // wxUSE_POPUPWIN/!wxUSE_POPUPWIN
+
+// ============================================================================
+// wxDatePickerCtrlGeneric implementation
+// ============================================================================
+
+BEGIN_EVENT_TABLE(wxDatePickerCtrlGeneric, wxDatePickerCtrlBase)
+ EVT_BUTTON(CTRLID_BTN, wxDatePickerCtrlGeneric::OnClick)
+ EVT_TEXT(CTRLID_TXT, wxDatePickerCtrlGeneric::OnText)
+ EVT_CHILD_FOCUS(wxDatePickerCtrlGeneric::OnChildSetFocus)
+ EVT_SIZE(wxDatePickerCtrlGeneric::OnSize)
+END_EVENT_TABLE()
+
+#ifndef wxHAS_NATIVE_DATEPICKCTRL
+ IMPLEMENT_DYNAMIC_CLASS(wxDatePickerCtrl, wxControl)
+#endif
+
+// ----------------------------------------------------------------------------
+// creation
+// ----------------------------------------------------------------------------
+
+bool wxDatePickerCtrlGeneric::Create(wxWindow *parent,
+ wxWindowID id,
+ const wxDateTime& date,
+ const wxPoint& pos,
+ const wxSize& size,
+ long style,
+ const wxValidator& validator,
+ const wxString& name)
+{
+ wxASSERT_MSG( !(style & wxDP_SPIN),
+ _T("wxDP_SPIN style not supported, use wxDP_DEFAULT") );