]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/calctrl.cpp
This should make the GTK statictext control wrap
[wxWidgets.git] / src / generic / calctrl.cpp
index 1f6cacf0d51a42bf2b6e5da1b09698c32e6ee3a9..f7ee6134f4490bd28721d3b7fbe780950b98df47 100644 (file)
@@ -33,6 +33,7 @@
     #include "wx/settings.h"
     #include "wx/brush.h"
     #include "wx/combobox.h"
+    #include "wx/listbox.h"
     #include "wx/stattext.h"
     #include "wx/textctrl.h"
 #endif //WX_PRECOMP
 
 #include "wx/spinctrl.h"
 
+// if wxDatePickerCtrl code doesn't define the date event, do it here as we
+// need it as well
+#if !wxUSE_DATEPICKCTRL
+    #define _WX_DEFINE_DATE_EVENTS_
+#endif
+
 #include "wx/calctrl.h"
 
 #define DEBUG_PAINT 0
@@ -161,7 +168,7 @@ wxCONSTRUCTOR_6( wxCalendarCtrl , wxWindow* , Parent , wxWindowID , Id , wxDateT
 #else
 IMPLEMENT_DYNAMIC_CLASS(wxCalendarCtrl, wxControl)
 #endif
-IMPLEMENT_DYNAMIC_CLASS(wxCalendarEvent, wxCommandEvent)
+IMPLEMENT_DYNAMIC_CLASS(wxCalendarEvent, wxDateEvent)
 
 // ----------------------------------------------------------------------------
 // events
@@ -199,10 +206,10 @@ wxMonthComboBox::wxMonthComboBox(wxCalendarCtrl *cal)
     }
 
     SetSelection(m_cal->GetDate().GetMonth());
-    SetSize(wxDefaultPosition.x,
-            wxDefaultPosition.y,
-            wxDefaultSize.x,
-            wxDefaultSize.y,
+    SetSize(wxDefaultCoord,
+            wxDefaultCoord,
+            wxDefaultCoord,
+            wxDefaultCoord,
             wxSIZE_AUTO_WIDTH|wxSIZE_AUTO_HEIGHT);
 }
 
@@ -306,28 +313,15 @@ bool wxCalendarCtrl::Create(wxWindow *parent,
 
     ShowCurrentControls();
 
-    wxSize sizeReal;
-    if ( size.x == wxDefaultSize.x || size.y == wxDefaultSize.y )
-    {
-        sizeReal = DoGetBestSize();
-        if ( size.x != wxDefaultSize.x )
-            sizeReal.x = size.x;
-        if ( size.y != wxDefaultSize.y )
-            sizeReal.y = size.y;
-    }
-    else
-    {
-        sizeReal = size;
-    }
-
     // we need to set the position as well because the main control position
     // is not the same as the one specified in pos if we have the controls
     // above it
-    SetSize(pos.x, pos.y, sizeReal.x, sizeReal.y);
+    SetBestSize(size);
+    SetPosition(pos);
 
-    SetForegroundColour(*wxBLACK);
-    SetBackgroundColour(*wxWHITE);
-    SetFont(*wxSWISS_FONT);
+    // Since we don't paint the whole background make sure that the platform
+    // will use the right one.
+    SetBackgroundColour(GetBackgroundColour());
 
     SetHolidayAttrs();
 
@@ -805,7 +799,9 @@ wxSize wxCalendarCtrl::DoGetBestSize() const
         width += 4;
     }
 
-    return wxSize(width, height);
+    wxSize best(width, height);
+    CacheBestSize(best);
+    return best;
 }
 
 void wxCalendarCtrl::DoSetSize(int x, int y,
@@ -904,12 +900,9 @@ void wxCalendarCtrl::DoGetSize(int *width, int *height) const
 
 void wxCalendarCtrl::RecalcGeometry()
 {
-    if ( m_widthCol != 0 )
-        return;
-
     wxClientDC dc(this);
 
-    dc.SetFont(m_font);
+    dc.SetFont(GetFont());
 
     // determine the column width (we assume that the weekday names are always
     // wider (in any language) than the numbers)
@@ -940,7 +933,7 @@ void wxCalendarCtrl::OnPaint(wxPaintEvent& WXUNUSED(event))
 {
     wxPaintDC dc(this);
 
-    dc.SetFont(m_font);
+    dc.SetFont(GetFont());
 
     RecalcGeometry();
 
@@ -982,7 +975,7 @@ void wxCalendarCtrl::OnPaint(wxPaintEvent& WXUNUSED(event))
         leftarrow[1] = wxPoint(arrowheight / 2, 0);
         leftarrow[2] = wxPoint(arrowheight / 2, arrowheight - 1);
 
-        rightarrow[0] = wxPoint(0, 0);
+        rightarrow[0] = wxPoint(0,0);
         rightarrow[1] = wxPoint(arrowheight / 2, arrowheight / 2);
         rightarrow[2] = wxPoint(0, arrowheight - 1);
 
@@ -991,8 +984,7 @@ void wxCalendarCtrl::OnPaint(wxPaintEvent& WXUNUSED(event))
         wxCoord arrowy = (m_heightRow - arrowheight) / 2;
         wxCoord larrowx = (m_widthCol - (arrowheight / 2)) / 2;
         wxCoord rarrowx = ((m_widthCol - (arrowheight / 2)) / 2) + m_widthCol*6;
-        m_leftArrowRect = wxRect(0, 0, 0, 0);
-        m_rightArrowRect = wxRect(0, 0, 0, 0);
+        m_leftArrowRect = m_rightArrowRect = wxRect(0,0,0,0);
 
         if ( AllowMonthChange() )
         {
@@ -1158,7 +1150,7 @@ void wxCalendarCtrl::OnPaint(wxPaintEvent& WXUNUSED(event))
                     }
                     else
                     {
-                        colBorder = m_foregroundColour;
+                        colBorder = GetForegroundColour();
                     }
 
                     wxPen pen(colBorder, 1, wxSOLID);
@@ -1184,13 +1176,13 @@ void wxCalendarCtrl::OnPaint(wxPaintEvent& WXUNUSED(event))
 
                 if ( changedColours )
                 {
-                    dc.SetTextForeground(m_foregroundColour);
-                    dc.SetTextBackground(m_backgroundColour);
+                    dc.SetTextForeground(GetForegroundColour());
+                    dc.SetTextBackground(GetBackgroundColour());
                 }
 
                 if ( changedFont )
                 {
-                    dc.SetFont(m_font);
+                    dc.SetFont(GetFont());
                 }
             }
             //else: just don't draw it
@@ -1824,20 +1816,13 @@ void wxCalendarCtrl::ResetHolidayAttrs()
     }
 }
 
-// ----------------------------------------------------------------------------
-// wxCalendarEvent
-// ----------------------------------------------------------------------------
-
-void wxCalendarEvent::Init()
-{
-    m_wday = wxDateTime::Inv_WeekDay;
-}
 
-wxCalendarEvent::wxCalendarEvent(wxCalendarCtrl *cal, wxEventType type)
-               : wxCommandEvent(type, cal->GetId())
+//static
+wxVisualAttributes
+wxCalendarCtrl::GetClassDefaultAttributes(wxWindowVariant variant)
 {
-    m_date = cal->GetDate();
-    SetEventObject(cal);
+    // Use the same color scheme as wxListBox
+    return wxListBox::GetClassDefaultAttributes(variant);
 }
 
 #endif // wxUSE_CALENDARCTRL