]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/src/calendar.i
wx.App
[wxWidgets.git] / wxPython / src / calendar.i
index aeaed635aeabf36d724f1c66b4f7082f07a5e8f8..d513513e44295aaf58748a8ff30d8917732b3c3c 100644 (file)
 
 
 %{
-#include "export.h"
+#include "wx/wxPython/wxPython.h"
+#include "wx/wxPython/pyclasses.h"
+
 #include <wx/calctrl.h>
 %}
 
 //----------------------------------------------------------------------
 
-%include typemaps.i
-%include my_typemaps.i
-
-// Import some definitions of other classes, etc.
-%import _defs.i
 %import misc.i
-%import windows.i
-%import controls.i
-%import events.i
-%import utils.i
+%pythoncode { wx = core }
 
-%pragma(python) code = "import wx"
+%include _calendar_rename.i
 
 //---------------------------------------------------------------------------
 
@@ -41,6 +35,8 @@ enum {
     wxCAL_SHOW_HOLIDAYS,
     wxCAL_NO_YEAR_CHANGE,
     wxCAL_NO_MONTH_CHANGE,
+    wxCAL_SEQUENTIAL_MONTH_SELECTION,
+    wxCAL_SHOW_SURROUNDING_WEEKS,
 };
 
 
@@ -48,7 +44,10 @@ enum wxCalendarHitTestResult
 {
     wxCAL_HITTEST_NOWHERE,      // outside of anything
     wxCAL_HITTEST_HEADER,       // on the header (weekdays)
-    wxCAL_HITTEST_DAY           // on a day in the calendar
+    wxCAL_HITTEST_DAY,          // on a day in the calendar
+    wxCAL_HITTEST_INCMONTH,
+    wxCAL_HITTEST_DECMONTH,
+    wxCAL_HITTEST_SURROUNDING_WEEK
 };
 
 // border types for a date
@@ -72,7 +71,7 @@ public:
                        const wxFont& font = wxNullFont,
                        wxCalendarDateBorder border = wxCAL_BORDER_NONE);
 
-    %name(wxCalendarDateAttrBorder)
+    %name(CalendarDateAttrBorder)
         wxCalendarDateAttr(wxCalendarDateBorder border,
                            const wxColour& colBorder = wxNullColour);
 
@@ -93,10 +92,10 @@ public:
 
     bool IsHoliday() const;
 
-    const wxColour& GetTextColour() const;
-    const wxColour& GetBackgroundColour() const;
-    const wxColour& GetBorderColour() const;
-    const wxFont& GetFont() const;
+    wxColour GetTextColour() const;
+    wxColour GetBackgroundColour() const;
+    wxColour GetBorderColour() const;
+    wxFont GetFont() const;
     wxCalendarDateBorder GetBorder() const;
 };
 
@@ -110,62 +109,60 @@ public:
     wxCalendarEvent(wxCalendarCtrl *cal, wxEventType type);
 
     const wxDateTime& GetDate() const;
+    void SetDate(const wxDateTime &date);
+    void SetWeekDay(const wxDateTime::WeekDay wd);
     wxDateTime::WeekDay GetWeekDay() const;
 
 };
 
-enum {
-    wxEVT_CALENDAR_DOUBLECLICKED,
-    wxEVT_CALENDAR_SEL_CHANGED,
-    wxEVT_CALENDAR_DAY_CHANGED,
-    wxEVT_CALENDAR_MONTH_CHANGED,
-    wxEVT_CALENDAR_YEAR_CHANGED,
-    wxEVT_CALENDAR_WEEKDAY_CLICKED,
-};
 
-%pragma(python) code = "
-def EVT_CALENDAR(win, id, fn):
-    win.Connect(id, -1, wxEVT_CALENDAR_DOUBLECLICKED, fn)
+%constant wxEventType wxEVT_CALENDAR_DOUBLECLICKED;
+%constant wxEventType wxEVT_CALENDAR_SEL_CHANGED;
+%constant wxEventType wxEVT_CALENDAR_DAY_CHANGED;
+%constant wxEventType wxEVT_CALENDAR_MONTH_CHANGED;
+%constant wxEventType wxEVT_CALENDAR_YEAR_CHANGED;
+%constant wxEventType wxEVT_CALENDAR_WEEKDAY_CLICKED;
 
-def EVT_CALENDAR_SEL_CHANGED(win, id, fn):
-    win.Connect(id, -1, wxEVT_CALENDAR_SEL_CHANGED, fn)
 
-def EVT_CALENDAR_DAY(win, id, fn):
-    win.Connect(id, -1, wxEVT_CALENDAR_DAY_CHANGED, fn)
+%pythoncode {
+EVT_CALENDAR =                 wx.PyEventBinder( wxEVT_CALENDAR_DOUBLECLICKED, 1)
+EVT_CALENDAR_SEL_CHANGED =     wx.PyEventBinder( wxEVT_CALENDAR_SEL_CHANGED, 1)
+EVT_CALENDAR_DAY =             wx.PyEventBinder( wxEVT_CALENDAR_DAY_CHANGED, 1)
+EVT_CALENDAR_MONTH =           wx.PyEventBinder( wxEVT_CALENDAR_MONTH_CHANGED, 1)
+EVT_CALENDAR_YEAR =            wx.PyEventBinder( wxEVT_CALENDAR_YEAR_CHANGED, 1)
+EVT_CALENDAR_WEEKDAY_CLICKED = wx.PyEventBinder( wxEVT_CALENDAR_WEEKDAY_CLICKED, 1)
+}
 
-def EVT_CALENDAR_MONTH(win, id, fn):
-    win.Connect(id, -1, wxEVT_CALENDAR_MONTH_CHANGED, fn)
 
-def EVT_CALENDAR_YEAR(win, id, fn):
-    win.Connect(id, -1, wxEVT_CALENDAR_YEAR_CHANGED, fn)
+//---------------------------------------------------------------------------
 
-def EVT_CALENDAR_WEEKDAY_CLICKED(win, id, fn):
-    win.Connect(id, -1, wxEVT_CALENDAR_WEEKDAY_CLICKED, fn)
+MAKE_CONST_WXSTRING(CalendarNameStr);
 
-"
 
-//---------------------------------------------------------------------------
 
 class wxCalendarCtrl : public wxControl
 {
 public:
-    // construction
+    %addtofunc wxCalendarCtrl      "self._setOORInfo(self)"
+    %addtofunc wxCalendarCtrl()    ""
+
     wxCalendarCtrl(wxWindow *parent,
                    wxWindowID id,
                    const wxDateTime& date = wxDefaultDateTime,
                    const wxPoint& pos = wxDefaultPosition,
                    const wxSize& size = wxDefaultSize,
-                   long style = wxCAL_SHOW_HOLIDAYS,
-                   const char* name = "calendar");
-    %name(wxPreCalendarCtrl)wxCalendarCtrl();
+                   long style = wxCAL_SHOW_HOLIDAYS | wxWANTS_CHARS,
+                   const wxString& name = wxPyCalendarNameStr);
+    %name(PreCalendarCtrl)wxCalendarCtrl();
 
     bool Create(wxWindow *parent,
                 wxWindowID id,
                 const wxDateTime& date = wxDefaultDateTime,
                 const wxPoint& pos = wxDefaultPosition,
                 const wxSize& size = wxDefaultSize,
-                long style = wxCAL_SHOW_HOLIDAYS,
-                const char* name = "calendar");
+                long style = wxCAL_SHOW_HOLIDAYS | wxWANTS_CHARS,
+                const wxString& name = wxPyCalendarNameStr);
+
 
     // set/get the current date
     // ------------------------
@@ -173,6 +170,18 @@ public:
     void SetDate(const wxDateTime& date);
     const wxDateTime& GetDate() const;
 
+    // set/get the range in which selection can occur
+    // ---------------------------------------------
+
+    bool SetLowerDateLimit(const wxDateTime& date = wxDefaultDateTime);
+    const wxDateTime& GetLowerDateLimit() const;
+    bool SetUpperDateLimit(const wxDateTime& date = wxDefaultDateTime);
+    const wxDateTime& GetUpperDateLimit() const;
+
+    bool SetDateRange(const wxDateTime& lowerdate = wxDefaultDateTime,
+                      const wxDateTime& upperdate = wxDefaultDateTime);
+
+
     // calendar mode
     // -------------
 
@@ -181,31 +190,31 @@ public:
     // should be used instead for them
 
     // corresponds to wxCAL_NO_YEAR_CHANGE bit
-    void EnableYearChange(bool enable = TRUE);
+    void EnableYearChange(bool enable = True);
 
     // corresponds to wxCAL_NO_MONTH_CHANGE bit
-    void EnableMonthChange(bool enable = TRUE);
+    void EnableMonthChange(bool enable = True);
 
     // corresponds to wxCAL_SHOW_HOLIDAYS bit
-    void EnableHolidayDisplay(bool display = TRUE);
+    void EnableHolidayDisplay(bool display = True);
 
     // customization
     // -------------
 
     // header colours are used for painting the weekdays at the top
     void SetHeaderColours(const wxColour& colFg, const wxColour& colBg);
-    const wxColour& GetHeaderColourFg() const;
-    const wxColour& GetHeaderColourBg() const;
+    wxColour GetHeaderColourFg() const;
+    wxColour GetHeaderColourBg() const;
 
     // highlight colour is used for the currently selected date
     void SetHighlightColours(const wxColour& colFg, const wxColour& colBg);
-    const wxColour& GetHighlightColourFg() const;
-    const wxColour& GetHighlightColourBg() const;
+    wxColour GetHighlightColourFg() const;
+    wxColour GetHighlightColourBg() const;
 
     // holiday colour is used for the holidays (if style & wxCAL_SHOW_HOLIDAYS)
     void SetHolidayColours(const wxColour& colFg, const wxColour& colBg);
-    const wxColour& GetHolidayColourFg() const;
-    const wxColour& GetHolidayColourBg() const;
+    wxColour GetHolidayColourFg() const;
+    wxColour GetHolidayColourBg() const;
 
     // an item without custom attributes is drawn with the default colours and
     // font and without border, setting custom attributes allows to modify this
@@ -228,19 +237,20 @@ public:
                                     wxDateTime *date = NULL,
                                     wxDateTime::WeekDay *wd = NULL);
 
+
+    bool Enable(bool enable = True);
+    bool Show(bool show = True);
+
+    // get the currently shown control for month/year
+    wxControl *GetMonthControl() const;
+    wxControl *GetYearControl() const;
 };
 
 
 //---------------------------------------------------------------------------
 
 %init %{
-    wxClassInfo::CleanUpClasses();
-    wxClassInfo::InitializeClasses();
 %}
 
 //---------------------------------------------------------------------------
 
-%pragma(python) include="_calextras.py";
-
-//---------------------------------------------------------------------------
-