From: Vadim Zeitlin Date: Fri, 28 Mar 2008 02:47:12 +0000 (+0000) Subject: added native GTK implementation of wxCalendarCtrl (modified patch 1925439) X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/628e155d8c70da0f962289cf1e1dea3699255707 added native GTK implementation of wxCalendarCtrl (modified patch 1925439) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@52891 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/Makefile.in b/Makefile.in index b7ea69cdba..a22b10ad2f 100644 --- a/Makefile.in +++ b/Makefile.in @@ -3009,9 +3009,12 @@ COND_TOOLKIT_WINCE_ADVANCED_PLATFORM_HDR = \ @COND_TOOLKIT_WINCE@ADVANCED_PLATFORM_HDR = $(COND_TOOLKIT_WINCE_ADVANCED_PLATFORM_HDR) @COND_TOOLKIT_X11@ADVANCED_PLATFORM_HDR = \ @COND_TOOLKIT_X11@ wx/unix/joystick.h wx/unix/sound.h wx/unix/taskbarx11.h -@COND_TOOLKIT_GTK_TOOLKIT_VERSION_2@ADVANCED_PLATFORM_NATIVE_HDR \ -@COND_TOOLKIT_GTK_TOOLKIT_VERSION_2@ = wx/gtk/animate.h wx/gtk/dataview.h \ -@COND_TOOLKIT_GTK_TOOLKIT_VERSION_2@ wx/gtk/hyperlink.h +COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_ADVANCED_PLATFORM_NATIVE_HDR = \ + wx/gtk/animate.h \ + wx/gtk/calctrl.h \ + wx/gtk/dataview.h \ + wx/gtk/hyperlink.h +@COND_TOOLKIT_GTK_TOOLKIT_VERSION_2@ADVANCED_PLATFORM_NATIVE_HDR = $(COND_TOOLKIT_GTK_TOOLKIT_VERSION_2_ADVANCED_PLATFORM_NATIVE_HDR) @COND_TOOLKIT_MSW@ADVANCED_PLATFORM_NATIVE_HDR = wx/msw/datectrl.h @COND_TOOLKIT_WINCE@ADVANCED_PLATFORM_NATIVE_HDR = wx/msw/datectrl.h COND_WXUNIV_0_ADVANCED_HDR = \ @@ -3026,7 +3029,7 @@ COND_WXUNIV_0_ADVANCED_HDR = \ wx/editlbox.h \ wx/generic/aboutdlgg.h \ wx/generic/bmpcbox.h \ - wx/generic/calctrl.h \ + wx/generic/calctrlg.h \ wx/generic/datectrl.h \ wx/generic/dataview.h \ wx/generic/grid.h \ @@ -3068,7 +3071,7 @@ COND_WXUNIV_1_ADVANCED_HDR = \ wx/editlbox.h \ wx/generic/aboutdlgg.h \ wx/generic/bmpcbox.h \ - wx/generic/calctrl.h \ + wx/generic/calctrlg.h \ wx/generic/datectrl.h \ wx/generic/dataview.h \ wx/generic/grid.h \ @@ -5313,11 +5316,12 @@ COND_TOOLKIT_X11___LOWLEVEL_SRC_OBJECTS_1 = \ @COND_TOOLKIT_X11@__LOWLEVEL_SRC_OBJECTS_1 = $(COND_TOOLKIT_X11___LOWLEVEL_SRC_OBJECTS_1) COND_WXUNIV_0___ADVANCED_SRC_OBJECTS = \ monodll_animatecmn.o \ + monodll_calctrlcmn.o \ monodll_datavcmn.o \ monodll_hyperlnkcmn.o \ monodll_aboutdlgg.o \ monodll_bmpcboxg.o \ - monodll_calctrl.o \ + monodll_calctrlg.o \ monodll_datavgen.o \ monodll_datectlg.o \ monodll_editlbox.o \ @@ -5339,11 +5343,12 @@ COND_WXUNIV_0___ADVANCED_SRC_OBJECTS = \ @COND_WXUNIV_0@__ADVANCED_SRC_OBJECTS = $(COND_WXUNIV_0___ADVANCED_SRC_OBJECTS) COND_WXUNIV_1___ADVANCED_SRC_OBJECTS = \ monodll_animatecmn.o \ + monodll_calctrlcmn.o \ monodll_datavcmn.o \ monodll_hyperlnkcmn.o \ monodll_aboutdlgg.o \ monodll_bmpcboxg.o \ - monodll_calctrl.o \ + monodll_calctrlg.o \ monodll_datavgen.o \ monodll_datectlg.o \ monodll_editlbox.o \ @@ -5366,6 +5371,7 @@ COND_WXUNIV_1___ADVANCED_SRC_OBJECTS = \ COND_TOOLKIT_GTK_TOOLKIT_VERSION_2___ADVANCED_PLATFORM_NATIVE_SRC_OBJECTS = \ monodll_aboutdlg.o \ monodll_animate.o \ + monodll_calctrl.o \ monodll_dataview.o \ monodll_hyperlink.o @COND_TOOLKIT_GTK_TOOLKIT_VERSION_2@__ADVANCED_PLATFORM_NATIVE_SRC_OBJECTS = $(COND_TOOLKIT_GTK_TOOLKIT_VERSION_2___ADVANCED_PLATFORM_NATIVE_SRC_OBJECTS) @@ -7220,11 +7226,12 @@ COND_TOOLKIT_X11___LOWLEVEL_SRC_OBJECTS_3 = \ @COND_TOOLKIT_X11@__LOWLEVEL_SRC_OBJECTS_3 = $(COND_TOOLKIT_X11___LOWLEVEL_SRC_OBJECTS_3) COND_WXUNIV_0___ADVANCED_SRC_OBJECTS_1 = \ monolib_animatecmn.o \ + monolib_calctrlcmn.o \ monolib_datavcmn.o \ monolib_hyperlnkcmn.o \ monolib_aboutdlgg.o \ monolib_bmpcboxg.o \ - monolib_calctrl.o \ + monolib_calctrlg.o \ monolib_datavgen.o \ monolib_datectlg.o \ monolib_editlbox.o \ @@ -7246,11 +7253,12 @@ COND_WXUNIV_0___ADVANCED_SRC_OBJECTS_1 = \ @COND_WXUNIV_0@__ADVANCED_SRC_OBJECTS_1 = $(COND_WXUNIV_0___ADVANCED_SRC_OBJECTS_1) COND_WXUNIV_1___ADVANCED_SRC_OBJECTS_1 = \ monolib_animatecmn.o \ + monolib_calctrlcmn.o \ monolib_datavcmn.o \ monolib_hyperlnkcmn.o \ monolib_aboutdlgg.o \ monolib_bmpcboxg.o \ - monolib_calctrl.o \ + monolib_calctrlg.o \ monolib_datavgen.o \ monolib_datectlg.o \ monolib_editlbox.o \ @@ -7273,6 +7281,7 @@ COND_WXUNIV_1___ADVANCED_SRC_OBJECTS_1 = \ COND_TOOLKIT_GTK_TOOLKIT_VERSION_2___ADVANCED_PLATFORM_NATIVE_SRC_OBJECTS_1 = \ monolib_aboutdlg.o \ monolib_animate.o \ + monolib_calctrl.o \ monolib_dataview.o \ monolib_hyperlink.o @COND_TOOLKIT_GTK_TOOLKIT_VERSION_2@__ADVANCED_PLATFORM_NATIVE_SRC_OBJECTS_1 = $(COND_TOOLKIT_GTK_TOOLKIT_VERSION_2___ADVANCED_PLATFORM_NATIVE_SRC_OBJECTS_1) @@ -10961,11 +10970,12 @@ COND_USE_SOSYMLINKS_1___advdll___so_symlinks_uninst_cmd = rm -f \ @COND_PLATFORM_WIN32_1@__advdll___win32rc = advdll_version_rc.o COND_WXUNIV_0___ADVANCED_SRC_OBJECTS_2 = \ advdll_animatecmn.o \ + advdll_calctrlcmn.o \ advdll_datavcmn.o \ advdll_hyperlnkcmn.o \ advdll_aboutdlgg.o \ advdll_bmpcboxg.o \ - advdll_calctrl.o \ + advdll_calctrlg.o \ advdll_datavgen.o \ advdll_datectlg.o \ advdll_editlbox.o \ @@ -10987,11 +10997,12 @@ COND_WXUNIV_0___ADVANCED_SRC_OBJECTS_2 = \ @COND_WXUNIV_0@__ADVANCED_SRC_OBJECTS_2 = $(COND_WXUNIV_0___ADVANCED_SRC_OBJECTS_2) COND_WXUNIV_1___ADVANCED_SRC_OBJECTS_2 = \ advdll_animatecmn.o \ + advdll_calctrlcmn.o \ advdll_datavcmn.o \ advdll_hyperlnkcmn.o \ advdll_aboutdlgg.o \ advdll_bmpcboxg.o \ - advdll_calctrl.o \ + advdll_calctrlg.o \ advdll_datavgen.o \ advdll_datectlg.o \ advdll_editlbox.o \ @@ -11011,9 +11022,13 @@ COND_WXUNIV_1___ADVANCED_SRC_OBJECTS_2 = \ $(__ADVANCED_PLATFORM_SRC_OBJECTS_8) \ advdll_animateg.o @COND_WXUNIV_1@__ADVANCED_SRC_OBJECTS_2 = $(COND_WXUNIV_1___ADVANCED_SRC_OBJECTS_2) -@COND_TOOLKIT_GTK_TOOLKIT_VERSION_2@__ADVANCED_PLATFORM_NATIVE_SRC_OBJECTS_2 \ -@COND_TOOLKIT_GTK_TOOLKIT_VERSION_2@ = advdll_aboutdlg.o advdll_animate.o \ -@COND_TOOLKIT_GTK_TOOLKIT_VERSION_2@ advdll_dataview.o advdll_hyperlink.o +COND_TOOLKIT_GTK_TOOLKIT_VERSION_2___ADVANCED_PLATFORM_NATIVE_SRC_OBJECTS_2 = \ + advdll_aboutdlg.o \ + advdll_animate.o \ + advdll_calctrl.o \ + advdll_dataview.o \ + advdll_hyperlink.o +@COND_TOOLKIT_GTK_TOOLKIT_VERSION_2@__ADVANCED_PLATFORM_NATIVE_SRC_OBJECTS_2 = $(COND_TOOLKIT_GTK_TOOLKIT_VERSION_2___ADVANCED_PLATFORM_NATIVE_SRC_OBJECTS_2) @COND_TOOLKIT_MSW@__ADVANCED_PLATFORM_NATIVE_SRC_OBJECTS_2 \ @COND_TOOLKIT_MSW@ = advdll_datectrl.o @COND_TOOLKIT_WINCE@__ADVANCED_PLATFORM_NATIVE_SRC_OBJECTS_2 \ @@ -11034,11 +11049,12 @@ COND_MONOLITHIC_0_SHARED_0_USE_GUI_1___advlib___depname = \ @COND_USE_PCH_1@ = .pch/wxprec_advlib/wx/wxprec.h.gch COND_WXUNIV_0___ADVANCED_SRC_OBJECTS_3 = \ advlib_animatecmn.o \ + advlib_calctrlcmn.o \ advlib_datavcmn.o \ advlib_hyperlnkcmn.o \ advlib_aboutdlgg.o \ advlib_bmpcboxg.o \ - advlib_calctrl.o \ + advlib_calctrlg.o \ advlib_datavgen.o \ advlib_datectlg.o \ advlib_editlbox.o \ @@ -11060,11 +11076,12 @@ COND_WXUNIV_0___ADVANCED_SRC_OBJECTS_3 = \ @COND_WXUNIV_0@__ADVANCED_SRC_OBJECTS_3 = $(COND_WXUNIV_0___ADVANCED_SRC_OBJECTS_3) COND_WXUNIV_1___ADVANCED_SRC_OBJECTS_3 = \ advlib_animatecmn.o \ + advlib_calctrlcmn.o \ advlib_datavcmn.o \ advlib_hyperlnkcmn.o \ advlib_aboutdlgg.o \ advlib_bmpcboxg.o \ - advlib_calctrl.o \ + advlib_calctrlg.o \ advlib_datavgen.o \ advlib_datectlg.o \ advlib_editlbox.o \ @@ -11084,9 +11101,13 @@ COND_WXUNIV_1___ADVANCED_SRC_OBJECTS_3 = \ $(__ADVANCED_PLATFORM_SRC_OBJECTS_9) \ advlib_animateg.o @COND_WXUNIV_1@__ADVANCED_SRC_OBJECTS_3 = $(COND_WXUNIV_1___ADVANCED_SRC_OBJECTS_3) -@COND_TOOLKIT_GTK_TOOLKIT_VERSION_2@__ADVANCED_PLATFORM_NATIVE_SRC_OBJECTS_3 \ -@COND_TOOLKIT_GTK_TOOLKIT_VERSION_2@ = advlib_aboutdlg.o advlib_animate.o \ -@COND_TOOLKIT_GTK_TOOLKIT_VERSION_2@ advlib_dataview.o advlib_hyperlink.o +COND_TOOLKIT_GTK_TOOLKIT_VERSION_2___ADVANCED_PLATFORM_NATIVE_SRC_OBJECTS_3 = \ + advlib_aboutdlg.o \ + advlib_animate.o \ + advlib_calctrl.o \ + advlib_dataview.o \ + advlib_hyperlink.o +@COND_TOOLKIT_GTK_TOOLKIT_VERSION_2@__ADVANCED_PLATFORM_NATIVE_SRC_OBJECTS_3 = $(COND_TOOLKIT_GTK_TOOLKIT_VERSION_2___ADVANCED_PLATFORM_NATIVE_SRC_OBJECTS_3) @COND_TOOLKIT_MSW@__ADVANCED_PLATFORM_NATIVE_SRC_OBJECTS_3 \ @COND_TOOLKIT_MSW@ = advlib_datectrl.o @COND_TOOLKIT_WINCE@__ADVANCED_PLATFORM_NATIVE_SRC_OBJECTS_3 \ @@ -14131,6 +14152,9 @@ monodll_win32.o: $(srcdir)/src/univ/themes/win32.cpp $(MONODLL_ODEP) monodll_animate.o: $(srcdir)/src/gtk/animate.cpp $(MONODLL_ODEP) $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/gtk/animate.cpp +monodll_calctrl.o: $(srcdir)/src/gtk/calctrl.cpp $(MONODLL_ODEP) + $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/gtk/calctrl.cpp + monodll_hyperlink.o: $(srcdir)/src/gtk/hyperlink.cpp $(MONODLL_ODEP) $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/gtk/hyperlink.cpp @@ -17836,6 +17860,9 @@ monodll_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(MONODLL_ODEP) @COND_USE_GUI_1@monodll_animatecmn.o: $(srcdir)/src/common/animatecmn.cpp $(MONODLL_ODEP) @COND_USE_GUI_1@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/common/animatecmn.cpp +@COND_USE_GUI_1@monodll_calctrlcmn.o: $(srcdir)/src/common/calctrlcmn.cpp $(MONODLL_ODEP) +@COND_USE_GUI_1@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/common/calctrlcmn.cpp + @COND_USE_GUI_1@monodll_datavcmn.o: $(srcdir)/src/common/datavcmn.cpp $(MONODLL_ODEP) @COND_USE_GUI_1@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/common/datavcmn.cpp @@ -17848,8 +17875,8 @@ monodll_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(MONODLL_ODEP) @COND_USE_GUI_1@monodll_bmpcboxg.o: $(srcdir)/src/generic/bmpcboxg.cpp $(MONODLL_ODEP) @COND_USE_GUI_1@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/generic/bmpcboxg.cpp -@COND_USE_GUI_1@monodll_calctrl.o: $(srcdir)/src/generic/calctrl.cpp $(MONODLL_ODEP) -@COND_USE_GUI_1@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/generic/calctrl.cpp +@COND_USE_GUI_1@monodll_calctrlg.o: $(srcdir)/src/generic/calctrlg.cpp $(MONODLL_ODEP) +@COND_USE_GUI_1@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/generic/calctrlg.cpp @COND_USE_GUI_1@monodll_datavgen.o: $(srcdir)/src/generic/datavgen.cpp $(MONODLL_ODEP) @COND_USE_GUI_1@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/generic/datavgen.cpp @@ -18649,6 +18676,9 @@ monolib_win32.o: $(srcdir)/src/univ/themes/win32.cpp $(MONOLIB_ODEP) monolib_animate.o: $(srcdir)/src/gtk/animate.cpp $(MONOLIB_ODEP) $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/gtk/animate.cpp +monolib_calctrl.o: $(srcdir)/src/gtk/calctrl.cpp $(MONOLIB_ODEP) + $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/gtk/calctrl.cpp + monolib_hyperlink.o: $(srcdir)/src/gtk/hyperlink.cpp $(MONOLIB_ODEP) $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/gtk/hyperlink.cpp @@ -22354,6 +22384,9 @@ monolib_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(MONOLIB_ODEP) @COND_USE_GUI_1@monolib_animatecmn.o: $(srcdir)/src/common/animatecmn.cpp $(MONOLIB_ODEP) @COND_USE_GUI_1@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/common/animatecmn.cpp +@COND_USE_GUI_1@monolib_calctrlcmn.o: $(srcdir)/src/common/calctrlcmn.cpp $(MONOLIB_ODEP) +@COND_USE_GUI_1@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/common/calctrlcmn.cpp + @COND_USE_GUI_1@monolib_datavcmn.o: $(srcdir)/src/common/datavcmn.cpp $(MONOLIB_ODEP) @COND_USE_GUI_1@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/common/datavcmn.cpp @@ -22366,8 +22399,8 @@ monolib_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(MONOLIB_ODEP) @COND_USE_GUI_1@monolib_bmpcboxg.o: $(srcdir)/src/generic/bmpcboxg.cpp $(MONOLIB_ODEP) @COND_USE_GUI_1@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/generic/bmpcboxg.cpp -@COND_USE_GUI_1@monolib_calctrl.o: $(srcdir)/src/generic/calctrl.cpp $(MONOLIB_ODEP) -@COND_USE_GUI_1@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/generic/calctrl.cpp +@COND_USE_GUI_1@monolib_calctrlg.o: $(srcdir)/src/generic/calctrlg.cpp $(MONOLIB_ODEP) +@COND_USE_GUI_1@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/generic/calctrlg.cpp @COND_USE_GUI_1@monolib_datavgen.o: $(srcdir)/src/generic/datavgen.cpp $(MONOLIB_ODEP) @COND_USE_GUI_1@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/generic/datavgen.cpp @@ -30496,6 +30529,9 @@ advdll_version_rc.o: $(srcdir)/src/msw/version.rc $(ADVDLL_ODEP) advdll_animate.o: $(srcdir)/src/gtk/animate.cpp $(ADVDLL_ODEP) $(CXXC) -c -o $@ $(ADVDLL_CXXFLAGS) $(srcdir)/src/gtk/animate.cpp +advdll_calctrl.o: $(srcdir)/src/gtk/calctrl.cpp $(ADVDLL_ODEP) + $(CXXC) -c -o $@ $(ADVDLL_CXXFLAGS) $(srcdir)/src/gtk/calctrl.cpp + advdll_hyperlink.o: $(srcdir)/src/gtk/hyperlink.cpp $(ADVDLL_ODEP) $(CXXC) -c -o $@ $(ADVDLL_CXXFLAGS) $(srcdir)/src/gtk/hyperlink.cpp @@ -30505,6 +30541,9 @@ advdll_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(ADVDLL_ODEP) advdll_animatecmn.o: $(srcdir)/src/common/animatecmn.cpp $(ADVDLL_ODEP) $(CXXC) -c -o $@ $(ADVDLL_CXXFLAGS) $(srcdir)/src/common/animatecmn.cpp +advdll_calctrlcmn.o: $(srcdir)/src/common/calctrlcmn.cpp $(ADVDLL_ODEP) + $(CXXC) -c -o $@ $(ADVDLL_CXXFLAGS) $(srcdir)/src/common/calctrlcmn.cpp + advdll_datavcmn.o: $(srcdir)/src/common/datavcmn.cpp $(ADVDLL_ODEP) $(CXXC) -c -o $@ $(ADVDLL_CXXFLAGS) $(srcdir)/src/common/datavcmn.cpp @@ -30517,8 +30556,8 @@ advdll_aboutdlgg.o: $(srcdir)/src/generic/aboutdlgg.cpp $(ADVDLL_ODEP) advdll_bmpcboxg.o: $(srcdir)/src/generic/bmpcboxg.cpp $(ADVDLL_ODEP) $(CXXC) -c -o $@ $(ADVDLL_CXXFLAGS) $(srcdir)/src/generic/bmpcboxg.cpp -advdll_calctrl.o: $(srcdir)/src/generic/calctrl.cpp $(ADVDLL_ODEP) - $(CXXC) -c -o $@ $(ADVDLL_CXXFLAGS) $(srcdir)/src/generic/calctrl.cpp +advdll_calctrlg.o: $(srcdir)/src/generic/calctrlg.cpp $(ADVDLL_ODEP) + $(CXXC) -c -o $@ $(ADVDLL_CXXFLAGS) $(srcdir)/src/generic/calctrlg.cpp advdll_datavgen.o: $(srcdir)/src/generic/datavgen.cpp $(ADVDLL_ODEP) $(CXXC) -c -o $@ $(ADVDLL_CXXFLAGS) $(srcdir)/src/generic/datavgen.cpp @@ -30754,6 +30793,9 @@ advdll_wizard.o: $(srcdir)/src/generic/wizard.cpp $(ADVDLL_ODEP) advlib_animate.o: $(srcdir)/src/gtk/animate.cpp $(ADVLIB_ODEP) $(CXXC) -c -o $@ $(ADVLIB_CXXFLAGS) $(srcdir)/src/gtk/animate.cpp +advlib_calctrl.o: $(srcdir)/src/gtk/calctrl.cpp $(ADVLIB_ODEP) + $(CXXC) -c -o $@ $(ADVLIB_CXXFLAGS) $(srcdir)/src/gtk/calctrl.cpp + advlib_hyperlink.o: $(srcdir)/src/gtk/hyperlink.cpp $(ADVLIB_ODEP) $(CXXC) -c -o $@ $(ADVLIB_CXXFLAGS) $(srcdir)/src/gtk/hyperlink.cpp @@ -30763,6 +30805,9 @@ advlib_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(ADVLIB_ODEP) advlib_animatecmn.o: $(srcdir)/src/common/animatecmn.cpp $(ADVLIB_ODEP) $(CXXC) -c -o $@ $(ADVLIB_CXXFLAGS) $(srcdir)/src/common/animatecmn.cpp +advlib_calctrlcmn.o: $(srcdir)/src/common/calctrlcmn.cpp $(ADVLIB_ODEP) + $(CXXC) -c -o $@ $(ADVLIB_CXXFLAGS) $(srcdir)/src/common/calctrlcmn.cpp + advlib_datavcmn.o: $(srcdir)/src/common/datavcmn.cpp $(ADVLIB_ODEP) $(CXXC) -c -o $@ $(ADVLIB_CXXFLAGS) $(srcdir)/src/common/datavcmn.cpp @@ -30775,8 +30820,8 @@ advlib_aboutdlgg.o: $(srcdir)/src/generic/aboutdlgg.cpp $(ADVLIB_ODEP) advlib_bmpcboxg.o: $(srcdir)/src/generic/bmpcboxg.cpp $(ADVLIB_ODEP) $(CXXC) -c -o $@ $(ADVLIB_CXXFLAGS) $(srcdir)/src/generic/bmpcboxg.cpp -advlib_calctrl.o: $(srcdir)/src/generic/calctrl.cpp $(ADVLIB_ODEP) - $(CXXC) -c -o $@ $(ADVLIB_CXXFLAGS) $(srcdir)/src/generic/calctrl.cpp +advlib_calctrlg.o: $(srcdir)/src/generic/calctrlg.cpp $(ADVLIB_ODEP) + $(CXXC) -c -o $@ $(ADVLIB_CXXFLAGS) $(srcdir)/src/generic/calctrlg.cpp advlib_datavgen.o: $(srcdir)/src/generic/datavgen.cpp $(ADVLIB_ODEP) $(CXXC) -c -o $@ $(ADVLIB_CXXFLAGS) $(srcdir)/src/generic/datavgen.cpp diff --git a/build/bakefiles/files.bkl b/build/bakefiles/files.bkl index 7b0dba2005..0e99acb71b 100644 --- a/build/bakefiles/files.bkl +++ b/build/bakefiles/files.bkl @@ -2814,11 +2814,12 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file! src/common/animatecmn.cpp + src/common/calctrlcmn.cpp src/common/datavcmn.cpp src/common/hyperlnkcmn.cpp src/generic/aboutdlgg.cpp src/generic/bmpcboxg.cpp - src/generic/calctrl.cpp + src/generic/calctrlg.cpp src/generic/datavgen.cpp src/generic/datectlg.cpp src/generic/editlbox.cpp @@ -2849,7 +2850,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file! wx/editlbox.h wx/generic/aboutdlgg.h wx/generic/bmpcbox.h - wx/generic/calctrl.h + wx/generic/calctrlg.h wx/generic/datectrl.h wx/generic/dataview.h wx/generic/grid.h @@ -2988,11 +2989,13 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file! src/gtk/aboutdlg.cpp src/gtk/animate.cpp + src/gtk/calctrl.cpp src/gtk/dataview.cpp src/gtk/hyperlink.cpp wx/gtk/animate.h + wx/gtk/calctrl.h wx/gtk/dataview.h wx/gtk/hyperlink.h diff --git a/build/msw/makefile.bcc b/build/msw/makefile.bcc index e86526d16a..4afaf4e956 100644 --- a/build/msw/makefile.bcc +++ b/build/msw/makefile.bcc @@ -1936,11 +1936,12 @@ ____CORE_SRC_FILENAMES_OBJECTS = \ !if "$(WXUNIV)" == "0" ____ADVANCED_SRC_FILENAMES_OBJECTS = \ $(OBJS)\monodll_animatecmn.obj \ + $(OBJS)\monodll_calctrlcmn.obj \ $(OBJS)\monodll_datavcmn.obj \ $(OBJS)\monodll_hyperlnkcmn.obj \ $(OBJS)\monodll_aboutdlgg.obj \ $(OBJS)\monodll_bmpcboxg.obj \ - $(OBJS)\monodll_calctrl.obj \ + $(OBJS)\monodll_calctrlg.obj \ $(OBJS)\monodll_datavgen.obj \ $(OBJS)\monodll_datectlg.obj \ $(OBJS)\monodll_editlbox.obj \ @@ -1969,11 +1970,12 @@ ____ADVANCED_SRC_FILENAMES_OBJECTS = \ !if "$(WXUNIV)" == "1" ____ADVANCED_SRC_FILENAMES_OBJECTS = \ $(OBJS)\monodll_animatecmn.obj \ + $(OBJS)\monodll_calctrlcmn.obj \ $(OBJS)\monodll_datavcmn.obj \ $(OBJS)\monodll_hyperlnkcmn.obj \ $(OBJS)\monodll_aboutdlgg.obj \ $(OBJS)\monodll_bmpcboxg.obj \ - $(OBJS)\monodll_calctrl.obj \ + $(OBJS)\monodll_calctrlg.obj \ $(OBJS)\monodll_datavgen.obj \ $(OBJS)\monodll_datectlg.obj \ $(OBJS)\monodll_editlbox.obj \ @@ -2580,11 +2582,12 @@ ____CORE_SRC_FILENAMES_1_OBJECTS = \ !if "$(WXUNIV)" == "0" ____ADVANCED_SRC_FILENAMES_1_OBJECTS = \ $(OBJS)\monolib_animatecmn.obj \ + $(OBJS)\monolib_calctrlcmn.obj \ $(OBJS)\monolib_datavcmn.obj \ $(OBJS)\monolib_hyperlnkcmn.obj \ $(OBJS)\monolib_aboutdlgg.obj \ $(OBJS)\monolib_bmpcboxg.obj \ - $(OBJS)\monolib_calctrl.obj \ + $(OBJS)\monolib_calctrlg.obj \ $(OBJS)\monolib_datavgen.obj \ $(OBJS)\monolib_datectlg.obj \ $(OBJS)\monolib_editlbox.obj \ @@ -2613,11 +2616,12 @@ ____ADVANCED_SRC_FILENAMES_1_OBJECTS = \ !if "$(WXUNIV)" == "1" ____ADVANCED_SRC_FILENAMES_1_OBJECTS = \ $(OBJS)\monolib_animatecmn.obj \ + $(OBJS)\monolib_calctrlcmn.obj \ $(OBJS)\monolib_datavcmn.obj \ $(OBJS)\monolib_hyperlnkcmn.obj \ $(OBJS)\monolib_aboutdlgg.obj \ $(OBJS)\monolib_bmpcboxg.obj \ - $(OBJS)\monolib_calctrl.obj \ + $(OBJS)\monolib_calctrlg.obj \ $(OBJS)\monolib_datavgen.obj \ $(OBJS)\monolib_datectlg.obj \ $(OBJS)\monolib_editlbox.obj \ @@ -3614,11 +3618,12 @@ __advdll___depname = \ !if "$(WXUNIV)" == "0" ____ADVANCED_SRC_FILENAMES_2_OBJECTS = \ $(OBJS)\advdll_animatecmn.obj \ + $(OBJS)\advdll_calctrlcmn.obj \ $(OBJS)\advdll_datavcmn.obj \ $(OBJS)\advdll_hyperlnkcmn.obj \ $(OBJS)\advdll_aboutdlgg.obj \ $(OBJS)\advdll_bmpcboxg.obj \ - $(OBJS)\advdll_calctrl.obj \ + $(OBJS)\advdll_calctrlg.obj \ $(OBJS)\advdll_datavgen.obj \ $(OBJS)\advdll_datectlg.obj \ $(OBJS)\advdll_editlbox.obj \ @@ -3647,11 +3652,12 @@ ____ADVANCED_SRC_FILENAMES_2_OBJECTS = \ !if "$(WXUNIV)" == "1" ____ADVANCED_SRC_FILENAMES_2_OBJECTS = \ $(OBJS)\advdll_animatecmn.obj \ + $(OBJS)\advdll_calctrlcmn.obj \ $(OBJS)\advdll_datavcmn.obj \ $(OBJS)\advdll_hyperlnkcmn.obj \ $(OBJS)\advdll_aboutdlgg.obj \ $(OBJS)\advdll_bmpcboxg.obj \ - $(OBJS)\advdll_calctrl.obj \ + $(OBJS)\advdll_calctrlg.obj \ $(OBJS)\advdll_datavgen.obj \ $(OBJS)\advdll_datectlg.obj \ $(OBJS)\advdll_editlbox.obj \ @@ -3684,11 +3690,12 @@ __advlib___depname = \ !if "$(WXUNIV)" == "0" ____ADVANCED_SRC_FILENAMES_3_OBJECTS = \ $(OBJS)\advlib_animatecmn.obj \ + $(OBJS)\advlib_calctrlcmn.obj \ $(OBJS)\advlib_datavcmn.obj \ $(OBJS)\advlib_hyperlnkcmn.obj \ $(OBJS)\advlib_aboutdlgg.obj \ $(OBJS)\advlib_bmpcboxg.obj \ - $(OBJS)\advlib_calctrl.obj \ + $(OBJS)\advlib_calctrlg.obj \ $(OBJS)\advlib_datavgen.obj \ $(OBJS)\advlib_datectlg.obj \ $(OBJS)\advlib_editlbox.obj \ @@ -3717,11 +3724,12 @@ ____ADVANCED_SRC_FILENAMES_3_OBJECTS = \ !if "$(WXUNIV)" == "1" ____ADVANCED_SRC_FILENAMES_3_OBJECTS = \ $(OBJS)\advlib_animatecmn.obj \ + $(OBJS)\advlib_calctrlcmn.obj \ $(OBJS)\advlib_datavcmn.obj \ $(OBJS)\advlib_hyperlnkcmn.obj \ $(OBJS)\advlib_aboutdlgg.obj \ $(OBJS)\advlib_bmpcboxg.obj \ - $(OBJS)\advlib_calctrl.obj \ + $(OBJS)\advlib_calctrlg.obj \ $(OBJS)\advlib_datavgen.obj \ $(OBJS)\advlib_datectlg.obj \ $(OBJS)\advlib_editlbox.obj \ @@ -7152,6 +7160,11 @@ $(OBJS)\monodll_animatecmn.obj: ..\..\src\common\animatecmn.cpp $(CXX) -q -c -P -o$@ $(MONODLL_CXXFLAGS) ..\..\src\common\animatecmn.cpp !endif +!if "$(USE_GUI)" == "1" +$(OBJS)\monodll_calctrlcmn.obj: ..\..\src\common\calctrlcmn.cpp + $(CXX) -q -c -P -o$@ $(MONODLL_CXXFLAGS) ..\..\src\common\calctrlcmn.cpp +!endif + !if "$(USE_GUI)" == "1" $(OBJS)\monodll_datavcmn.obj: ..\..\src\common\datavcmn.cpp $(CXX) -q -c -P -o$@ $(MONODLL_CXXFLAGS) ..\..\src\common\datavcmn.cpp @@ -7173,8 +7186,8 @@ $(OBJS)\monodll_bmpcboxg.obj: ..\..\src\generic\bmpcboxg.cpp !endif !if "$(USE_GUI)" == "1" -$(OBJS)\monodll_calctrl.obj: ..\..\src\generic\calctrl.cpp - $(CXX) -q -c -P -o$@ $(MONODLL_CXXFLAGS) ..\..\src\generic\calctrl.cpp +$(OBJS)\monodll_calctrlg.obj: ..\..\src\generic\calctrlg.cpp + $(CXX) -q -c -P -o$@ $(MONODLL_CXXFLAGS) ..\..\src\generic\calctrlg.cpp !endif !if "$(USE_GUI)" == "1" @@ -9273,6 +9286,11 @@ $(OBJS)\monolib_animatecmn.obj: ..\..\src\common\animatecmn.cpp $(CXX) -q -c -P -o$@ $(MONOLIB_CXXFLAGS) ..\..\src\common\animatecmn.cpp !endif +!if "$(USE_GUI)" == "1" +$(OBJS)\monolib_calctrlcmn.obj: ..\..\src\common\calctrlcmn.cpp + $(CXX) -q -c -P -o$@ $(MONOLIB_CXXFLAGS) ..\..\src\common\calctrlcmn.cpp +!endif + !if "$(USE_GUI)" == "1" $(OBJS)\monolib_datavcmn.obj: ..\..\src\common\datavcmn.cpp $(CXX) -q -c -P -o$@ $(MONOLIB_CXXFLAGS) ..\..\src\common\datavcmn.cpp @@ -9294,8 +9312,8 @@ $(OBJS)\monolib_bmpcboxg.obj: ..\..\src\generic\bmpcboxg.cpp !endif !if "$(USE_GUI)" == "1" -$(OBJS)\monolib_calctrl.obj: ..\..\src\generic\calctrl.cpp - $(CXX) -q -c -P -o$@ $(MONOLIB_CXXFLAGS) ..\..\src\generic\calctrl.cpp +$(OBJS)\monolib_calctrlg.obj: ..\..\src\generic\calctrlg.cpp + $(CXX) -q -c -P -o$@ $(MONOLIB_CXXFLAGS) ..\..\src\generic\calctrlg.cpp !endif !if "$(USE_GUI)" == "1" @@ -12787,6 +12805,9 @@ $(OBJS)\advdll_datectrl.obj: ..\..\src\msw\datectrl.cpp $(OBJS)\advdll_animatecmn.obj: ..\..\src\common\animatecmn.cpp $(CXX) -q -c -P -o$@ $(ADVDLL_CXXFLAGS) ..\..\src\common\animatecmn.cpp +$(OBJS)\advdll_calctrlcmn.obj: ..\..\src\common\calctrlcmn.cpp + $(CXX) -q -c -P -o$@ $(ADVDLL_CXXFLAGS) ..\..\src\common\calctrlcmn.cpp + $(OBJS)\advdll_datavcmn.obj: ..\..\src\common\datavcmn.cpp $(CXX) -q -c -P -o$@ $(ADVDLL_CXXFLAGS) ..\..\src\common\datavcmn.cpp @@ -12799,8 +12820,8 @@ $(OBJS)\advdll_aboutdlgg.obj: ..\..\src\generic\aboutdlgg.cpp $(OBJS)\advdll_bmpcboxg.obj: ..\..\src\generic\bmpcboxg.cpp $(CXX) -q -c -P -o$@ $(ADVDLL_CXXFLAGS) ..\..\src\generic\bmpcboxg.cpp -$(OBJS)\advdll_calctrl.obj: ..\..\src\generic\calctrl.cpp - $(CXX) -q -c -P -o$@ $(ADVDLL_CXXFLAGS) ..\..\src\generic\calctrl.cpp +$(OBJS)\advdll_calctrlg.obj: ..\..\src\generic\calctrlg.cpp + $(CXX) -q -c -P -o$@ $(ADVDLL_CXXFLAGS) ..\..\src\generic\calctrlg.cpp $(OBJS)\advdll_datavgen.obj: ..\..\src\generic\datavgen.cpp $(CXX) -q -c -P -o$@ $(ADVDLL_CXXFLAGS) ..\..\src\generic\datavgen.cpp @@ -12885,6 +12906,9 @@ $(OBJS)\advlib_datectrl.obj: ..\..\src\msw\datectrl.cpp $(OBJS)\advlib_animatecmn.obj: ..\..\src\common\animatecmn.cpp $(CXX) -q -c -P -o$@ $(ADVLIB_CXXFLAGS) ..\..\src\common\animatecmn.cpp +$(OBJS)\advlib_calctrlcmn.obj: ..\..\src\common\calctrlcmn.cpp + $(CXX) -q -c -P -o$@ $(ADVLIB_CXXFLAGS) ..\..\src\common\calctrlcmn.cpp + $(OBJS)\advlib_datavcmn.obj: ..\..\src\common\datavcmn.cpp $(CXX) -q -c -P -o$@ $(ADVLIB_CXXFLAGS) ..\..\src\common\datavcmn.cpp @@ -12897,8 +12921,8 @@ $(OBJS)\advlib_aboutdlgg.obj: ..\..\src\generic\aboutdlgg.cpp $(OBJS)\advlib_bmpcboxg.obj: ..\..\src\generic\bmpcboxg.cpp $(CXX) -q -c -P -o$@ $(ADVLIB_CXXFLAGS) ..\..\src\generic\bmpcboxg.cpp -$(OBJS)\advlib_calctrl.obj: ..\..\src\generic\calctrl.cpp - $(CXX) -q -c -P -o$@ $(ADVLIB_CXXFLAGS) ..\..\src\generic\calctrl.cpp +$(OBJS)\advlib_calctrlg.obj: ..\..\src\generic\calctrlg.cpp + $(CXX) -q -c -P -o$@ $(ADVLIB_CXXFLAGS) ..\..\src\generic\calctrlg.cpp $(OBJS)\advlib_datavgen.obj: ..\..\src\generic\datavgen.cpp $(CXX) -q -c -P -o$@ $(ADVLIB_CXXFLAGS) ..\..\src\generic\datavgen.cpp diff --git a/build/msw/makefile.gcc b/build/msw/makefile.gcc index b810e60ff1..619ab08fbb 100644 --- a/build/msw/makefile.gcc +++ b/build/msw/makefile.gcc @@ -1956,11 +1956,12 @@ endif ifeq ($(WXUNIV),0) ____ADVANCED_SRC_FILENAMES_OBJECTS = \ $(OBJS)\monodll_animatecmn.o \ + $(OBJS)\monodll_calctrlcmn.o \ $(OBJS)\monodll_datavcmn.o \ $(OBJS)\monodll_hyperlnkcmn.o \ $(OBJS)\monodll_aboutdlgg.o \ $(OBJS)\monodll_bmpcboxg.o \ - $(OBJS)\monodll_calctrl.o \ + $(OBJS)\monodll_calctrlg.o \ $(OBJS)\monodll_datavgen.o \ $(OBJS)\monodll_datectlg.o \ $(OBJS)\monodll_editlbox.o \ @@ -1989,11 +1990,12 @@ endif ifeq ($(WXUNIV),1) ____ADVANCED_SRC_FILENAMES_OBJECTS = \ $(OBJS)\monodll_animatecmn.o \ + $(OBJS)\monodll_calctrlcmn.o \ $(OBJS)\monodll_datavcmn.o \ $(OBJS)\monodll_hyperlnkcmn.o \ $(OBJS)\monodll_aboutdlgg.o \ $(OBJS)\monodll_bmpcboxg.o \ - $(OBJS)\monodll_calctrl.o \ + $(OBJS)\monodll_calctrlg.o \ $(OBJS)\monodll_datavgen.o \ $(OBJS)\monodll_datectlg.o \ $(OBJS)\monodll_editlbox.o \ @@ -2606,11 +2608,12 @@ endif ifeq ($(WXUNIV),0) ____ADVANCED_SRC_FILENAMES_1_OBJECTS = \ $(OBJS)\monolib_animatecmn.o \ + $(OBJS)\monolib_calctrlcmn.o \ $(OBJS)\monolib_datavcmn.o \ $(OBJS)\monolib_hyperlnkcmn.o \ $(OBJS)\monolib_aboutdlgg.o \ $(OBJS)\monolib_bmpcboxg.o \ - $(OBJS)\monolib_calctrl.o \ + $(OBJS)\monolib_calctrlg.o \ $(OBJS)\monolib_datavgen.o \ $(OBJS)\monolib_datectlg.o \ $(OBJS)\monolib_editlbox.o \ @@ -2639,11 +2642,12 @@ endif ifeq ($(WXUNIV),1) ____ADVANCED_SRC_FILENAMES_1_OBJECTS = \ $(OBJS)\monolib_animatecmn.o \ + $(OBJS)\monolib_calctrlcmn.o \ $(OBJS)\monolib_datavcmn.o \ $(OBJS)\monolib_hyperlnkcmn.o \ $(OBJS)\monolib_aboutdlgg.o \ $(OBJS)\monolib_bmpcboxg.o \ - $(OBJS)\monolib_calctrl.o \ + $(OBJS)\monolib_calctrlg.o \ $(OBJS)\monolib_datavgen.o \ $(OBJS)\monolib_datectlg.o \ $(OBJS)\monolib_editlbox.o \ @@ -3668,11 +3672,12 @@ endif ifeq ($(WXUNIV),0) ____ADVANCED_SRC_FILENAMES_2_OBJECTS = \ $(OBJS)\advdll_animatecmn.o \ + $(OBJS)\advdll_calctrlcmn.o \ $(OBJS)\advdll_datavcmn.o \ $(OBJS)\advdll_hyperlnkcmn.o \ $(OBJS)\advdll_aboutdlgg.o \ $(OBJS)\advdll_bmpcboxg.o \ - $(OBJS)\advdll_calctrl.o \ + $(OBJS)\advdll_calctrlg.o \ $(OBJS)\advdll_datavgen.o \ $(OBJS)\advdll_datectlg.o \ $(OBJS)\advdll_editlbox.o \ @@ -3701,11 +3706,12 @@ endif ifeq ($(WXUNIV),1) ____ADVANCED_SRC_FILENAMES_2_OBJECTS = \ $(OBJS)\advdll_animatecmn.o \ + $(OBJS)\advdll_calctrlcmn.o \ $(OBJS)\advdll_datavcmn.o \ $(OBJS)\advdll_hyperlnkcmn.o \ $(OBJS)\advdll_aboutdlgg.o \ $(OBJS)\advdll_bmpcboxg.o \ - $(OBJS)\advdll_calctrl.o \ + $(OBJS)\advdll_calctrlg.o \ $(OBJS)\advdll_datavgen.o \ $(OBJS)\advdll_datectlg.o \ $(OBJS)\advdll_editlbox.o \ @@ -3742,11 +3748,12 @@ endif ifeq ($(WXUNIV),0) ____ADVANCED_SRC_FILENAMES_3_OBJECTS = \ $(OBJS)\advlib_animatecmn.o \ + $(OBJS)\advlib_calctrlcmn.o \ $(OBJS)\advlib_datavcmn.o \ $(OBJS)\advlib_hyperlnkcmn.o \ $(OBJS)\advlib_aboutdlgg.o \ $(OBJS)\advlib_bmpcboxg.o \ - $(OBJS)\advlib_calctrl.o \ + $(OBJS)\advlib_calctrlg.o \ $(OBJS)\advlib_datavgen.o \ $(OBJS)\advlib_datectlg.o \ $(OBJS)\advlib_editlbox.o \ @@ -3775,11 +3782,12 @@ endif ifeq ($(WXUNIV),1) ____ADVANCED_SRC_FILENAMES_3_OBJECTS = \ $(OBJS)\advlib_animatecmn.o \ + $(OBJS)\advlib_calctrlcmn.o \ $(OBJS)\advlib_datavcmn.o \ $(OBJS)\advlib_hyperlnkcmn.o \ $(OBJS)\advlib_aboutdlgg.o \ $(OBJS)\advlib_bmpcboxg.o \ - $(OBJS)\advlib_calctrl.o \ + $(OBJS)\advlib_calctrlg.o \ $(OBJS)\advlib_datavgen.o \ $(OBJS)\advlib_datectlg.o \ $(OBJS)\advlib_editlbox.o \ @@ -7406,6 +7414,11 @@ $(OBJS)\monodll_animatecmn.o: ../../src/common/animatecmn.cpp $(CXX) -c -o $@ $(MONODLL_CXXFLAGS) $(CPPDEPS) $< endif +ifeq ($(USE_GUI),1) +$(OBJS)\monodll_calctrlcmn.o: ../../src/common/calctrlcmn.cpp + $(CXX) -c -o $@ $(MONODLL_CXXFLAGS) $(CPPDEPS) $< +endif + ifeq ($(USE_GUI),1) $(OBJS)\monodll_datavcmn.o: ../../src/common/datavcmn.cpp $(CXX) -c -o $@ $(MONODLL_CXXFLAGS) $(CPPDEPS) $< @@ -7427,7 +7440,7 @@ $(OBJS)\monodll_bmpcboxg.o: ../../src/generic/bmpcboxg.cpp endif ifeq ($(USE_GUI),1) -$(OBJS)\monodll_calctrl.o: ../../src/generic/calctrl.cpp +$(OBJS)\monodll_calctrlg.o: ../../src/generic/calctrlg.cpp $(CXX) -c -o $@ $(MONODLL_CXXFLAGS) $(CPPDEPS) $< endif @@ -9641,6 +9654,11 @@ $(OBJS)\monolib_animatecmn.o: ../../src/common/animatecmn.cpp $(CXX) -c -o $@ $(MONOLIB_CXXFLAGS) $(CPPDEPS) $< endif +ifeq ($(USE_GUI),1) +$(OBJS)\monolib_calctrlcmn.o: ../../src/common/calctrlcmn.cpp + $(CXX) -c -o $@ $(MONOLIB_CXXFLAGS) $(CPPDEPS) $< +endif + ifeq ($(USE_GUI),1) $(OBJS)\monolib_datavcmn.o: ../../src/common/datavcmn.cpp $(CXX) -c -o $@ $(MONOLIB_CXXFLAGS) $(CPPDEPS) $< @@ -9662,7 +9680,7 @@ $(OBJS)\monolib_bmpcboxg.o: ../../src/generic/bmpcboxg.cpp endif ifeq ($(USE_GUI),1) -$(OBJS)\monolib_calctrl.o: ../../src/generic/calctrl.cpp +$(OBJS)\monolib_calctrlg.o: ../../src/generic/calctrlg.cpp $(CXX) -c -o $@ $(MONOLIB_CXXFLAGS) $(CPPDEPS) $< endif @@ -13381,6 +13399,9 @@ $(OBJS)\advdll_datectrl.o: ../../src/msw/datectrl.cpp $(OBJS)\advdll_animatecmn.o: ../../src/common/animatecmn.cpp $(CXX) -c -o $@ $(ADVDLL_CXXFLAGS) $(CPPDEPS) $< +$(OBJS)\advdll_calctrlcmn.o: ../../src/common/calctrlcmn.cpp + $(CXX) -c -o $@ $(ADVDLL_CXXFLAGS) $(CPPDEPS) $< + $(OBJS)\advdll_datavcmn.o: ../../src/common/datavcmn.cpp $(CXX) -c -o $@ $(ADVDLL_CXXFLAGS) $(CPPDEPS) $< @@ -13393,7 +13414,7 @@ $(OBJS)\advdll_aboutdlgg.o: ../../src/generic/aboutdlgg.cpp $(OBJS)\advdll_bmpcboxg.o: ../../src/generic/bmpcboxg.cpp $(CXX) -c -o $@ $(ADVDLL_CXXFLAGS) $(CPPDEPS) $< -$(OBJS)\advdll_calctrl.o: ../../src/generic/calctrl.cpp +$(OBJS)\advdll_calctrlg.o: ../../src/generic/calctrlg.cpp $(CXX) -c -o $@ $(ADVDLL_CXXFLAGS) $(CPPDEPS) $< $(OBJS)\advdll_datavgen.o: ../../src/generic/datavgen.cpp @@ -13479,6 +13500,9 @@ $(OBJS)\advlib_datectrl.o: ../../src/msw/datectrl.cpp $(OBJS)\advlib_animatecmn.o: ../../src/common/animatecmn.cpp $(CXX) -c -o $@ $(ADVLIB_CXXFLAGS) $(CPPDEPS) $< +$(OBJS)\advlib_calctrlcmn.o: ../../src/common/calctrlcmn.cpp + $(CXX) -c -o $@ $(ADVLIB_CXXFLAGS) $(CPPDEPS) $< + $(OBJS)\advlib_datavcmn.o: ../../src/common/datavcmn.cpp $(CXX) -c -o $@ $(ADVLIB_CXXFLAGS) $(CPPDEPS) $< @@ -13491,7 +13515,7 @@ $(OBJS)\advlib_aboutdlgg.o: ../../src/generic/aboutdlgg.cpp $(OBJS)\advlib_bmpcboxg.o: ../../src/generic/bmpcboxg.cpp $(CXX) -c -o $@ $(ADVLIB_CXXFLAGS) $(CPPDEPS) $< -$(OBJS)\advlib_calctrl.o: ../../src/generic/calctrl.cpp +$(OBJS)\advlib_calctrlg.o: ../../src/generic/calctrlg.cpp $(CXX) -c -o $@ $(ADVLIB_CXXFLAGS) $(CPPDEPS) $< $(OBJS)\advlib_datavgen.o: ../../src/generic/datavgen.cpp diff --git a/build/msw/makefile.vc b/build/msw/makefile.vc index a4a99aae7a..dd71c75ba3 100644 --- a/build/msw/makefile.vc +++ b/build/msw/makefile.vc @@ -2110,11 +2110,12 @@ ____CORE_SRC_FILENAMES_OBJECTS = \ !if "$(WXUNIV)" == "0" ____ADVANCED_SRC_FILENAMES_OBJECTS = \ $(OBJS)\monodll_animatecmn.obj \ + $(OBJS)\monodll_calctrlcmn.obj \ $(OBJS)\monodll_datavcmn.obj \ $(OBJS)\monodll_hyperlnkcmn.obj \ $(OBJS)\monodll_aboutdlgg.obj \ $(OBJS)\monodll_bmpcboxg.obj \ - $(OBJS)\monodll_calctrl.obj \ + $(OBJS)\monodll_calctrlg.obj \ $(OBJS)\monodll_datavgen.obj \ $(OBJS)\monodll_datectlg.obj \ $(OBJS)\monodll_editlbox.obj \ @@ -2143,11 +2144,12 @@ ____ADVANCED_SRC_FILENAMES_OBJECTS = \ !if "$(WXUNIV)" == "1" ____ADVANCED_SRC_FILENAMES_OBJECTS = \ $(OBJS)\monodll_animatecmn.obj \ + $(OBJS)\monodll_calctrlcmn.obj \ $(OBJS)\monodll_datavcmn.obj \ $(OBJS)\monodll_hyperlnkcmn.obj \ $(OBJS)\monodll_aboutdlgg.obj \ $(OBJS)\monodll_bmpcboxg.obj \ - $(OBJS)\monodll_calctrl.obj \ + $(OBJS)\monodll_calctrlg.obj \ $(OBJS)\monodll_datavgen.obj \ $(OBJS)\monodll_datectlg.obj \ $(OBJS)\monodll_editlbox.obj \ @@ -2760,11 +2762,12 @@ ____CORE_SRC_FILENAMES_1_OBJECTS = \ !if "$(WXUNIV)" == "0" ____ADVANCED_SRC_FILENAMES_1_OBJECTS = \ $(OBJS)\monolib_animatecmn.obj \ + $(OBJS)\monolib_calctrlcmn.obj \ $(OBJS)\monolib_datavcmn.obj \ $(OBJS)\monolib_hyperlnkcmn.obj \ $(OBJS)\monolib_aboutdlgg.obj \ $(OBJS)\monolib_bmpcboxg.obj \ - $(OBJS)\monolib_calctrl.obj \ + $(OBJS)\monolib_calctrlg.obj \ $(OBJS)\monolib_datavgen.obj \ $(OBJS)\monolib_datectlg.obj \ $(OBJS)\monolib_editlbox.obj \ @@ -2793,11 +2796,12 @@ ____ADVANCED_SRC_FILENAMES_1_OBJECTS = \ !if "$(WXUNIV)" == "1" ____ADVANCED_SRC_FILENAMES_1_OBJECTS = \ $(OBJS)\monolib_animatecmn.obj \ + $(OBJS)\monolib_calctrlcmn.obj \ $(OBJS)\monolib_datavcmn.obj \ $(OBJS)\monolib_hyperlnkcmn.obj \ $(OBJS)\monolib_aboutdlgg.obj \ $(OBJS)\monolib_bmpcboxg.obj \ - $(OBJS)\monolib_calctrl.obj \ + $(OBJS)\monolib_calctrlg.obj \ $(OBJS)\monolib_datavgen.obj \ $(OBJS)\monolib_datectlg.obj \ $(OBJS)\monolib_editlbox.obj \ @@ -3836,11 +3840,12 @@ __RUNTIME_LIBS_208 = $(__THREADSFLAG) !if "$(WXUNIV)" == "0" ____ADVANCED_SRC_FILENAMES_2_OBJECTS = \ $(OBJS)\advdll_animatecmn.obj \ + $(OBJS)\advdll_calctrlcmn.obj \ $(OBJS)\advdll_datavcmn.obj \ $(OBJS)\advdll_hyperlnkcmn.obj \ $(OBJS)\advdll_aboutdlgg.obj \ $(OBJS)\advdll_bmpcboxg.obj \ - $(OBJS)\advdll_calctrl.obj \ + $(OBJS)\advdll_calctrlg.obj \ $(OBJS)\advdll_datavgen.obj \ $(OBJS)\advdll_datectlg.obj \ $(OBJS)\advdll_editlbox.obj \ @@ -3869,11 +3874,12 @@ ____ADVANCED_SRC_FILENAMES_2_OBJECTS = \ !if "$(WXUNIV)" == "1" ____ADVANCED_SRC_FILENAMES_2_OBJECTS = \ $(OBJS)\advdll_animatecmn.obj \ + $(OBJS)\advdll_calctrlcmn.obj \ $(OBJS)\advdll_datavcmn.obj \ $(OBJS)\advdll_hyperlnkcmn.obj \ $(OBJS)\advdll_aboutdlgg.obj \ $(OBJS)\advdll_bmpcboxg.obj \ - $(OBJS)\advdll_calctrl.obj \ + $(OBJS)\advdll_calctrlg.obj \ $(OBJS)\advdll_datavgen.obj \ $(OBJS)\advdll_datectlg.obj \ $(OBJS)\advdll_editlbox.obj \ @@ -3912,11 +3918,12 @@ __RUNTIME_LIBS_221 = $(__THREADSFLAG) !if "$(WXUNIV)" == "0" ____ADVANCED_SRC_FILENAMES_3_OBJECTS = \ $(OBJS)\advlib_animatecmn.obj \ + $(OBJS)\advlib_calctrlcmn.obj \ $(OBJS)\advlib_datavcmn.obj \ $(OBJS)\advlib_hyperlnkcmn.obj \ $(OBJS)\advlib_aboutdlgg.obj \ $(OBJS)\advlib_bmpcboxg.obj \ - $(OBJS)\advlib_calctrl.obj \ + $(OBJS)\advlib_calctrlg.obj \ $(OBJS)\advlib_datavgen.obj \ $(OBJS)\advlib_datectlg.obj \ $(OBJS)\advlib_editlbox.obj \ @@ -3945,11 +3952,12 @@ ____ADVANCED_SRC_FILENAMES_3_OBJECTS = \ !if "$(WXUNIV)" == "1" ____ADVANCED_SRC_FILENAMES_3_OBJECTS = \ $(OBJS)\advlib_animatecmn.obj \ + $(OBJS)\advlib_calctrlcmn.obj \ $(OBJS)\advlib_datavcmn.obj \ $(OBJS)\advlib_hyperlnkcmn.obj \ $(OBJS)\advlib_aboutdlgg.obj \ $(OBJS)\advlib_bmpcboxg.obj \ - $(OBJS)\advlib_calctrl.obj \ + $(OBJS)\advlib_calctrlg.obj \ $(OBJS)\advlib_datavgen.obj \ $(OBJS)\advlib_datectlg.obj \ $(OBJS)\advlib_editlbox.obj \ @@ -7484,6 +7492,11 @@ $(OBJS)\monodll_animatecmn.obj: ..\..\src\common\animatecmn.cpp $(CXX) /c /nologo /TP /Fo$@ $(MONODLL_CXXFLAGS) ..\..\src\common\animatecmn.cpp !endif +!if "$(USE_GUI)" == "1" +$(OBJS)\monodll_calctrlcmn.obj: ..\..\src\common\calctrlcmn.cpp + $(CXX) /c /nologo /TP /Fo$@ $(MONODLL_CXXFLAGS) ..\..\src\common\calctrlcmn.cpp +!endif + !if "$(USE_GUI)" == "1" $(OBJS)\monodll_datavcmn.obj: ..\..\src\common\datavcmn.cpp $(CXX) /c /nologo /TP /Fo$@ $(MONODLL_CXXFLAGS) ..\..\src\common\datavcmn.cpp @@ -7505,8 +7518,8 @@ $(OBJS)\monodll_bmpcboxg.obj: ..\..\src\generic\bmpcboxg.cpp !endif !if "$(USE_GUI)" == "1" -$(OBJS)\monodll_calctrl.obj: ..\..\src\generic\calctrl.cpp - $(CXX) /c /nologo /TP /Fo$@ $(MONODLL_CXXFLAGS) ..\..\src\generic\calctrl.cpp +$(OBJS)\monodll_calctrlg.obj: ..\..\src\generic\calctrlg.cpp + $(CXX) /c /nologo /TP /Fo$@ $(MONODLL_CXXFLAGS) ..\..\src\generic\calctrlg.cpp !endif !if "$(USE_GUI)" == "1" @@ -9605,6 +9618,11 @@ $(OBJS)\monolib_animatecmn.obj: ..\..\src\common\animatecmn.cpp $(CXX) /c /nologo /TP /Fo$@ $(MONOLIB_CXXFLAGS) ..\..\src\common\animatecmn.cpp !endif +!if "$(USE_GUI)" == "1" +$(OBJS)\monolib_calctrlcmn.obj: ..\..\src\common\calctrlcmn.cpp + $(CXX) /c /nologo /TP /Fo$@ $(MONOLIB_CXXFLAGS) ..\..\src\common\calctrlcmn.cpp +!endif + !if "$(USE_GUI)" == "1" $(OBJS)\monolib_datavcmn.obj: ..\..\src\common\datavcmn.cpp $(CXX) /c /nologo /TP /Fo$@ $(MONOLIB_CXXFLAGS) ..\..\src\common\datavcmn.cpp @@ -9626,8 +9644,8 @@ $(OBJS)\monolib_bmpcboxg.obj: ..\..\src\generic\bmpcboxg.cpp !endif !if "$(USE_GUI)" == "1" -$(OBJS)\monolib_calctrl.obj: ..\..\src\generic\calctrl.cpp - $(CXX) /c /nologo /TP /Fo$@ $(MONOLIB_CXXFLAGS) ..\..\src\generic\calctrl.cpp +$(OBJS)\monolib_calctrlg.obj: ..\..\src\generic\calctrlg.cpp + $(CXX) /c /nologo /TP /Fo$@ $(MONOLIB_CXXFLAGS) ..\..\src\generic\calctrlg.cpp !endif !if "$(USE_GUI)" == "1" @@ -13119,6 +13137,9 @@ $(OBJS)\advdll_datectrl.obj: ..\..\src\msw\datectrl.cpp $(OBJS)\advdll_animatecmn.obj: ..\..\src\common\animatecmn.cpp $(CXX) /c /nologo /TP /Fo$@ $(ADVDLL_CXXFLAGS) ..\..\src\common\animatecmn.cpp +$(OBJS)\advdll_calctrlcmn.obj: ..\..\src\common\calctrlcmn.cpp + $(CXX) /c /nologo /TP /Fo$@ $(ADVDLL_CXXFLAGS) ..\..\src\common\calctrlcmn.cpp + $(OBJS)\advdll_datavcmn.obj: ..\..\src\common\datavcmn.cpp $(CXX) /c /nologo /TP /Fo$@ $(ADVDLL_CXXFLAGS) ..\..\src\common\datavcmn.cpp @@ -13131,8 +13152,8 @@ $(OBJS)\advdll_aboutdlgg.obj: ..\..\src\generic\aboutdlgg.cpp $(OBJS)\advdll_bmpcboxg.obj: ..\..\src\generic\bmpcboxg.cpp $(CXX) /c /nologo /TP /Fo$@ $(ADVDLL_CXXFLAGS) ..\..\src\generic\bmpcboxg.cpp -$(OBJS)\advdll_calctrl.obj: ..\..\src\generic\calctrl.cpp - $(CXX) /c /nologo /TP /Fo$@ $(ADVDLL_CXXFLAGS) ..\..\src\generic\calctrl.cpp +$(OBJS)\advdll_calctrlg.obj: ..\..\src\generic\calctrlg.cpp + $(CXX) /c /nologo /TP /Fo$@ $(ADVDLL_CXXFLAGS) ..\..\src\generic\calctrlg.cpp $(OBJS)\advdll_datavgen.obj: ..\..\src\generic\datavgen.cpp $(CXX) /c /nologo /TP /Fo$@ $(ADVDLL_CXXFLAGS) ..\..\src\generic\datavgen.cpp @@ -13217,6 +13238,9 @@ $(OBJS)\advlib_datectrl.obj: ..\..\src\msw\datectrl.cpp $(OBJS)\advlib_animatecmn.obj: ..\..\src\common\animatecmn.cpp $(CXX) /c /nologo /TP /Fo$@ $(ADVLIB_CXXFLAGS) ..\..\src\common\animatecmn.cpp +$(OBJS)\advlib_calctrlcmn.obj: ..\..\src\common\calctrlcmn.cpp + $(CXX) /c /nologo /TP /Fo$@ $(ADVLIB_CXXFLAGS) ..\..\src\common\calctrlcmn.cpp + $(OBJS)\advlib_datavcmn.obj: ..\..\src\common\datavcmn.cpp $(CXX) /c /nologo /TP /Fo$@ $(ADVLIB_CXXFLAGS) ..\..\src\common\datavcmn.cpp @@ -13229,8 +13253,8 @@ $(OBJS)\advlib_aboutdlgg.obj: ..\..\src\generic\aboutdlgg.cpp $(OBJS)\advlib_bmpcboxg.obj: ..\..\src\generic\bmpcboxg.cpp $(CXX) /c /nologo /TP /Fo$@ $(ADVLIB_CXXFLAGS) ..\..\src\generic\bmpcboxg.cpp -$(OBJS)\advlib_calctrl.obj: ..\..\src\generic\calctrl.cpp - $(CXX) /c /nologo /TP /Fo$@ $(ADVLIB_CXXFLAGS) ..\..\src\generic\calctrl.cpp +$(OBJS)\advlib_calctrlg.obj: ..\..\src\generic\calctrlg.cpp + $(CXX) /c /nologo /TP /Fo$@ $(ADVLIB_CXXFLAGS) ..\..\src\generic\calctrlg.cpp $(OBJS)\advlib_datavgen.obj: ..\..\src\generic\datavgen.cpp $(CXX) /c /nologo /TP /Fo$@ $(ADVLIB_CXXFLAGS) ..\..\src\generic\datavgen.cpp diff --git a/build/msw/makefile.wat b/build/msw/makefile.wat index e7c4ecd50d..a63e6b4762 100644 --- a/build/msw/makefile.wat +++ b/build/msw/makefile.wat @@ -676,11 +676,12 @@ ____ADVANCED_SRC_FILENAMES_OBJECTS = !ifeq WXUNIV 0 ____ADVANCED_SRC_FILENAMES_OBJECTS = & $(OBJS)\monodll_animatecmn.obj & + $(OBJS)\monodll_calctrlcmn.obj & $(OBJS)\monodll_datavcmn.obj & $(OBJS)\monodll_hyperlnkcmn.obj & $(OBJS)\monodll_aboutdlgg.obj & $(OBJS)\monodll_bmpcboxg.obj & - $(OBJS)\monodll_calctrl.obj & + $(OBJS)\monodll_calctrlg.obj & $(OBJS)\monodll_datavgen.obj & $(OBJS)\monodll_datectlg.obj & $(OBJS)\monodll_editlbox.obj & @@ -709,11 +710,12 @@ ____ADVANCED_SRC_FILENAMES_OBJECTS = & !ifeq WXUNIV 1 ____ADVANCED_SRC_FILENAMES_OBJECTS = & $(OBJS)\monodll_animatecmn.obj & + $(OBJS)\monodll_calctrlcmn.obj & $(OBJS)\monodll_datavcmn.obj & $(OBJS)\monodll_hyperlnkcmn.obj & $(OBJS)\monodll_aboutdlgg.obj & $(OBJS)\monodll_bmpcboxg.obj & - $(OBJS)\monodll_calctrl.obj & + $(OBJS)\monodll_calctrlg.obj & $(OBJS)\monodll_datavgen.obj & $(OBJS)\monodll_datectlg.obj & $(OBJS)\monodll_editlbox.obj & @@ -1331,11 +1333,12 @@ ____ADVANCED_SRC_FILENAMES_1_OBJECTS = !ifeq WXUNIV 0 ____ADVANCED_SRC_FILENAMES_1_OBJECTS = & $(OBJS)\monolib_animatecmn.obj & + $(OBJS)\monolib_calctrlcmn.obj & $(OBJS)\monolib_datavcmn.obj & $(OBJS)\monolib_hyperlnkcmn.obj & $(OBJS)\monolib_aboutdlgg.obj & $(OBJS)\monolib_bmpcboxg.obj & - $(OBJS)\monolib_calctrl.obj & + $(OBJS)\monolib_calctrlg.obj & $(OBJS)\monolib_datavgen.obj & $(OBJS)\monolib_datectlg.obj & $(OBJS)\monolib_editlbox.obj & @@ -1364,11 +1367,12 @@ ____ADVANCED_SRC_FILENAMES_1_OBJECTS = & !ifeq WXUNIV 1 ____ADVANCED_SRC_FILENAMES_1_OBJECTS = & $(OBJS)\monolib_animatecmn.obj & + $(OBJS)\monolib_calctrlcmn.obj & $(OBJS)\monolib_datavcmn.obj & $(OBJS)\monolib_hyperlnkcmn.obj & $(OBJS)\monolib_aboutdlgg.obj & $(OBJS)\monolib_bmpcboxg.obj & - $(OBJS)\monolib_calctrl.obj & + $(OBJS)\monolib_calctrlg.obj & $(OBJS)\monolib_datavgen.obj & $(OBJS)\monolib_datectlg.obj & $(OBJS)\monolib_editlbox.obj & @@ -2409,11 +2413,12 @@ ____ADVANCED_SRC_FILENAMES_2_OBJECTS = !ifeq WXUNIV 0 ____ADVANCED_SRC_FILENAMES_2_OBJECTS = & $(OBJS)\advdll_animatecmn.obj & + $(OBJS)\advdll_calctrlcmn.obj & $(OBJS)\advdll_datavcmn.obj & $(OBJS)\advdll_hyperlnkcmn.obj & $(OBJS)\advdll_aboutdlgg.obj & $(OBJS)\advdll_bmpcboxg.obj & - $(OBJS)\advdll_calctrl.obj & + $(OBJS)\advdll_calctrlg.obj & $(OBJS)\advdll_datavgen.obj & $(OBJS)\advdll_datectlg.obj & $(OBJS)\advdll_editlbox.obj & @@ -2442,11 +2447,12 @@ ____ADVANCED_SRC_FILENAMES_2_OBJECTS = & !ifeq WXUNIV 1 ____ADVANCED_SRC_FILENAMES_2_OBJECTS = & $(OBJS)\advdll_animatecmn.obj & + $(OBJS)\advdll_calctrlcmn.obj & $(OBJS)\advdll_datavcmn.obj & $(OBJS)\advdll_hyperlnkcmn.obj & $(OBJS)\advdll_aboutdlgg.obj & $(OBJS)\advdll_bmpcboxg.obj & - $(OBJS)\advdll_calctrl.obj & + $(OBJS)\advdll_calctrlg.obj & $(OBJS)\advdll_datavgen.obj & $(OBJS)\advdll_datectlg.obj & $(OBJS)\advdll_editlbox.obj & @@ -2485,11 +2491,12 @@ ____ADVANCED_SRC_FILENAMES_3_OBJECTS = !ifeq WXUNIV 0 ____ADVANCED_SRC_FILENAMES_3_OBJECTS = & $(OBJS)\advlib_animatecmn.obj & + $(OBJS)\advlib_calctrlcmn.obj & $(OBJS)\advlib_datavcmn.obj & $(OBJS)\advlib_hyperlnkcmn.obj & $(OBJS)\advlib_aboutdlgg.obj & $(OBJS)\advlib_bmpcboxg.obj & - $(OBJS)\advlib_calctrl.obj & + $(OBJS)\advlib_calctrlg.obj & $(OBJS)\advlib_datavgen.obj & $(OBJS)\advlib_datectlg.obj & $(OBJS)\advlib_editlbox.obj & @@ -2518,11 +2525,12 @@ ____ADVANCED_SRC_FILENAMES_3_OBJECTS = & !ifeq WXUNIV 1 ____ADVANCED_SRC_FILENAMES_3_OBJECTS = & $(OBJS)\advlib_animatecmn.obj & + $(OBJS)\advlib_calctrlcmn.obj & $(OBJS)\advlib_datavcmn.obj & $(OBJS)\advlib_hyperlnkcmn.obj & $(OBJS)\advlib_aboutdlgg.obj & $(OBJS)\advlib_bmpcboxg.obj & - $(OBJS)\advlib_calctrl.obj & + $(OBJS)\advlib_calctrlg.obj & $(OBJS)\advlib_datavgen.obj & $(OBJS)\advlib_datectlg.obj & $(OBJS)\advlib_editlbox.obj & @@ -7638,6 +7646,11 @@ $(OBJS)\monodll_animatecmn.obj : .AUTODEPEND ..\..\src\common\animatecmn.cpp $(CXX) -bt=nt -zq -fo=$^@ $(MONODLL_CXXFLAGS) $< !endif +!ifeq USE_GUI 1 +$(OBJS)\monodll_calctrlcmn.obj : .AUTODEPEND ..\..\src\common\calctrlcmn.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(MONODLL_CXXFLAGS) $< +!endif + !ifeq USE_GUI 1 $(OBJS)\monodll_datavcmn.obj : .AUTODEPEND ..\..\src\common\datavcmn.cpp $(CXX) -bt=nt -zq -fo=$^@ $(MONODLL_CXXFLAGS) $< @@ -7659,7 +7672,7 @@ $(OBJS)\monodll_bmpcboxg.obj : .AUTODEPEND ..\..\src\generic\bmpcboxg.cpp !endif !ifeq USE_GUI 1 -$(OBJS)\monodll_calctrl.obj : .AUTODEPEND ..\..\src\generic\calctrl.cpp +$(OBJS)\monodll_calctrlg.obj : .AUTODEPEND ..\..\src\generic\calctrlg.cpp $(CXX) -bt=nt -zq -fo=$^@ $(MONODLL_CXXFLAGS) $< !endif @@ -9873,6 +9886,11 @@ $(OBJS)\monolib_animatecmn.obj : .AUTODEPEND ..\..\src\common\animatecmn.cpp $(CXX) -bt=nt -zq -fo=$^@ $(MONOLIB_CXXFLAGS) $< !endif +!ifeq USE_GUI 1 +$(OBJS)\monolib_calctrlcmn.obj : .AUTODEPEND ..\..\src\common\calctrlcmn.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(MONOLIB_CXXFLAGS) $< +!endif + !ifeq USE_GUI 1 $(OBJS)\monolib_datavcmn.obj : .AUTODEPEND ..\..\src\common\datavcmn.cpp $(CXX) -bt=nt -zq -fo=$^@ $(MONOLIB_CXXFLAGS) $< @@ -9894,7 +9912,7 @@ $(OBJS)\monolib_bmpcboxg.obj : .AUTODEPEND ..\..\src\generic\bmpcboxg.cpp !endif !ifeq USE_GUI 1 -$(OBJS)\monolib_calctrl.obj : .AUTODEPEND ..\..\src\generic\calctrl.cpp +$(OBJS)\monolib_calctrlg.obj : .AUTODEPEND ..\..\src\generic\calctrlg.cpp $(CXX) -bt=nt -zq -fo=$^@ $(MONOLIB_CXXFLAGS) $< !endif @@ -13613,6 +13631,9 @@ $(OBJS)\advdll_datectrl.obj : .AUTODEPEND ..\..\src\msw\datectrl.cpp $(OBJS)\advdll_animatecmn.obj : .AUTODEPEND ..\..\src\common\animatecmn.cpp $(CXX) -bt=nt -zq -fo=$^@ $(ADVDLL_CXXFLAGS) $< +$(OBJS)\advdll_calctrlcmn.obj : .AUTODEPEND ..\..\src\common\calctrlcmn.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(ADVDLL_CXXFLAGS) $< + $(OBJS)\advdll_datavcmn.obj : .AUTODEPEND ..\..\src\common\datavcmn.cpp $(CXX) -bt=nt -zq -fo=$^@ $(ADVDLL_CXXFLAGS) $< @@ -13625,7 +13646,7 @@ $(OBJS)\advdll_aboutdlgg.obj : .AUTODEPEND ..\..\src\generic\aboutdlgg.cpp $(OBJS)\advdll_bmpcboxg.obj : .AUTODEPEND ..\..\src\generic\bmpcboxg.cpp $(CXX) -bt=nt -zq -fo=$^@ $(ADVDLL_CXXFLAGS) $< -$(OBJS)\advdll_calctrl.obj : .AUTODEPEND ..\..\src\generic\calctrl.cpp +$(OBJS)\advdll_calctrlg.obj : .AUTODEPEND ..\..\src\generic\calctrlg.cpp $(CXX) -bt=nt -zq -fo=$^@ $(ADVDLL_CXXFLAGS) $< $(OBJS)\advdll_datavgen.obj : .AUTODEPEND ..\..\src\generic\datavgen.cpp @@ -13711,6 +13732,9 @@ $(OBJS)\advlib_datectrl.obj : .AUTODEPEND ..\..\src\msw\datectrl.cpp $(OBJS)\advlib_animatecmn.obj : .AUTODEPEND ..\..\src\common\animatecmn.cpp $(CXX) -bt=nt -zq -fo=$^@ $(ADVLIB_CXXFLAGS) $< +$(OBJS)\advlib_calctrlcmn.obj : .AUTODEPEND ..\..\src\common\calctrlcmn.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(ADVLIB_CXXFLAGS) $< + $(OBJS)\advlib_datavcmn.obj : .AUTODEPEND ..\..\src\common\datavcmn.cpp $(CXX) -bt=nt -zq -fo=$^@ $(ADVLIB_CXXFLAGS) $< @@ -13723,7 +13747,7 @@ $(OBJS)\advlib_aboutdlgg.obj : .AUTODEPEND ..\..\src\generic\aboutdlgg.cpp $(OBJS)\advlib_bmpcboxg.obj : .AUTODEPEND ..\..\src\generic\bmpcboxg.cpp $(CXX) -bt=nt -zq -fo=$^@ $(ADVLIB_CXXFLAGS) $< -$(OBJS)\advlib_calctrl.obj : .AUTODEPEND ..\..\src\generic\calctrl.cpp +$(OBJS)\advlib_calctrlg.obj : .AUTODEPEND ..\..\src\generic\calctrlg.cpp $(CXX) -bt=nt -zq -fo=$^@ $(ADVLIB_CXXFLAGS) $< $(OBJS)\advlib_datavgen.obj : .AUTODEPEND ..\..\src\generic\datavgen.cpp diff --git a/build/msw/wx_adv.dsp b/build/msw/wx_adv.dsp index 1f28135bce..89105441bc 100644 --- a/build/msw/wx_adv.dsp +++ b/build/msw/wx_adv.dsp @@ -248,6 +248,10 @@ SOURCE=..\..\src\common\animatecmn.cpp # End Source File # Begin Source File +SOURCE=..\..\src\common\calctrlcmn.cpp +# End Source File +# Begin Source File + SOURCE=..\..\src\common\datavcmn.cpp # End Source File # Begin Source File @@ -403,7 +407,7 @@ SOURCE=..\..\src\generic\bmpcboxg.cpp # End Source File # Begin Source File -SOURCE=..\..\src\generic\calctrl.cpp +SOURCE=..\..\src\generic\calctrlg.cpp # End Source File # Begin Source File @@ -744,7 +748,7 @@ SOURCE=..\..\include\wx\generic\bmpcbox.h # End Source File # Begin Source File -SOURCE=..\..\include\wx\generic\calctrl.h +SOURCE=..\..\include\wx\generic\calctrlg.h # End Source File # Begin Source File diff --git a/build/msw/wx_core.dsp b/build/msw/wx_core.dsp index 7b12b93c4e..16161dc89f 100644 --- a/build/msw/wx_core.dsp +++ b/build/msw/wx_core.dsp @@ -5171,7 +5171,7 @@ SOURCE=..\..\include\wx\generic\buttonbar.h # End Source File # Begin Source File -SOURCE=..\..\include\wx\generic\calctrl.h +SOURCE=..\..\include\wx\generic\calctrlg.h # End Source File # Begin Source File diff --git a/build/msw/wx_vc7_adv.vcproj b/build/msw/wx_vc7_adv.vcproj index 3b27f64a5f..5b373d67db 100644 --- a/build/msw/wx_vc7_adv.vcproj +++ b/build/msw/wx_vc7_adv.vcproj @@ -586,6 +586,8 @@ UniqueIdentifier="{A6A5C30D-BDB6-5050-906D-10A96065136C}"> + + RelativePath="..\..\src\generic\calctrlg.cpp"/> + RelativePath="..\..\include\wx\generic\calctrlg.h"/> + RelativePath="..\..\include\wx\generic\calctrlg.h"/> + @@ -877,7 +880,7 @@ RelativePath="..\..\src\generic\bmpcboxg.cpp" /> GetDate(), type) -{ -} // ---------------------------------------------------------------------------- // calendar event types and macros for handling them // ---------------------------------------------------------------------------- extern WXDLLIMPEXP_ADV const wxEventType wxEVT_CALENDAR_SEL_CHANGED; +extern WXDLLIMPEXP_ADV const wxEventType wxEVT_CALENDAR_PAGE_CHANGED; +extern WXDLLIMPEXP_ADV const wxEventType wxEVT_CALENDAR_DOUBLECLICKED; +extern WXDLLIMPEXP_ADV const wxEventType wxEVT_CALENDAR_WEEKDAY_CLICKED; + +// deprecated events extern WXDLLIMPEXP_ADV const wxEventType wxEVT_CALENDAR_DAY_CHANGED; extern WXDLLIMPEXP_ADV const wxEventType wxEVT_CALENDAR_MONTH_CHANGED; extern WXDLLIMPEXP_ADV const wxEventType wxEVT_CALENDAR_YEAR_CHANGED; -extern WXDLLIMPEXP_ADV const wxEventType wxEVT_CALENDAR_DOUBLECLICKED; -extern WXDLLIMPEXP_ADV const wxEventType wxEVT_CALENDAR_WEEKDAY_CLICKED; typedef void (wxEvtHandler::*wxCalendarEventFunction)(wxCalendarEvent&); @@ -219,10 +278,13 @@ typedef void (wxEvtHandler::*wxCalendarEventFunction)(wxCalendarEvent&); #define EVT_CALENDAR(id, fn) wx__DECLARE_CALEVT(DOUBLECLICKED, id, fn) #define EVT_CALENDAR_SEL_CHANGED(id, fn) wx__DECLARE_CALEVT(SEL_CHANGED, id, fn) +#define EVT_CALENDAR_PAGE_CHANGED(id, fn) wx__DECLARE_CALEVT(PAGE_CHANGED, id, fn) +#define EVT_CALENDAR_WEEKDAY_CLICKED(id, fn) wx__DECLARE_CALEVT(WEEKDAY_CLICKED, id, fn) + +// deprecated events #define EVT_CALENDAR_DAY(id, fn) wx__DECLARE_CALEVT(DAY_CHANGED, id, fn) #define EVT_CALENDAR_MONTH(id, fn) wx__DECLARE_CALEVT(MONTH_CHANGED, id, fn) #define EVT_CALENDAR_YEAR(id, fn) wx__DECLARE_CALEVT(YEAR_CHANGED, id, fn) -#define EVT_CALENDAR_WEEKDAY_CLICKED(id, fn) wx__DECLARE_CALEVT(WEEKDAY_CLICKED, id, fn) #endif // wxUSE_CALENDARCTRL diff --git a/include/wx/dateevt.h b/include/wx/dateevt.h index 18db28eb60..2175fb2568 100644 --- a/include/wx/dateevt.h +++ b/include/wx/dateevt.h @@ -57,11 +57,5 @@ typedef void (wxEvtHandler::*wxDateEventFunction)(wxDateEvent&); #define EVT_DATE_CHANGED(id, fn) \ wx__DECLARE_EVT1(wxEVT_DATE_CHANGED, id, wxDateEventHandler(fn)) -#ifdef _WX_DEFINE_DATE_EVENTS_ - const wxEventType wxEVT_DATE_CHANGED = wxNewEventType(); - - IMPLEMENT_DYNAMIC_CLASS(wxDateEvent, wxCommandEvent) -#endif - #endif // _WX_DATEEVT_H_ diff --git a/include/wx/generic/calctrl.h b/include/wx/generic/calctrl.h deleted file mode 100644 index 08acaca363..0000000000 --- a/include/wx/generic/calctrl.h +++ /dev/null @@ -1,324 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: generic/calctrl.h -// Purpose: generic implementation of date-picker control -// Author: Vadim Zeitlin -// Modified by: -// Created: 29.12.99 -// RCS-ID: $Id$ -// Copyright: (c) 1999 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_GENERIC_CALCTRL_H -#define _WX_GENERIC_CALCTRL_H - -#include "wx/control.h" // the base class -#include "wx/dcclient.h" // for wxPaintDC - -class WXDLLIMPEXP_FWD_CORE wxComboBox; -class WXDLLIMPEXP_FWD_CORE wxStaticText; -class WXDLLIMPEXP_FWD_CORE wxSpinCtrl; - -#define wxCalendarNameStr _T("CalendarCtrl") - -// ---------------------------------------------------------------------------- -// wxCalendarCtrl: a control allowing the user to pick a date interactively -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_ADV wxCalendarCtrl : public wxControl -{ -public: - // construction - wxCalendarCtrl() { Init(); } - wxCalendarCtrl(wxWindow *parent, - wxWindowID id, - const wxDateTime& date = wxDefaultDateTime, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxCAL_SHOW_HOLIDAYS | wxWANTS_CHARS, - const wxString& name = wxCalendarNameStr); - - bool Create(wxWindow *parent, - wxWindowID id, - const wxDateTime& date = wxDefaultDateTime, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxCAL_SHOW_HOLIDAYS | wxWANTS_CHARS, - const wxString& name = wxCalendarNameStr); - - virtual ~wxCalendarCtrl(); - - virtual bool Destroy(); - - // set/get the current date - // ------------------------ - - bool SetDate(const wxDateTime& date); // we need to be able to control if the event should be sent in SetDateAndNotify(...) - const wxDateTime& GetDate() const { return m_date; } - - // set/get the range in which selection can occur - // --------------------------------------------- - - bool SetLowerDateLimit(const wxDateTime& date = wxDefaultDateTime); - const wxDateTime& GetLowerDateLimit() const { return m_lowdate; } - bool SetUpperDateLimit(const wxDateTime& date = wxDefaultDateTime); - const wxDateTime& GetUpperDateLimit() const { return m_highdate; } - - bool SetDateRange(const wxDateTime& lowerdate = wxDefaultDateTime, const wxDateTime& upperdate = wxDefaultDateTime); - - // calendar mode - // ------------- - - // some calendar styles can't be changed after the control creation by - // just using SetWindowStyle() and Refresh() and the functions below - // should be used instead for them - - // corresponds to wxCAL_NO_YEAR_CHANGE bit - void EnableYearChange(bool enable = true); - - // corresponds to wxCAL_NO_MONTH_CHANGE bit - void EnableMonthChange(bool enable = true); - - // corresponds to wxCAL_SHOW_HOLIDAYS bit - 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) - { - m_colHeaderFg = colFg; - m_colHeaderBg = colBg; - } - - const wxColour& GetHeaderColourFg() const { return m_colHeaderFg; } - const wxColour& GetHeaderColourBg() const { return m_colHeaderBg; } - - // highlight colour is used for the currently selected date - void SetHighlightColours(const wxColour& colFg, const wxColour& colBg) - { - m_colHighlightFg = colFg; - m_colHighlightBg = colBg; - } - - const wxColour& GetHighlightColourFg() const { return m_colHighlightFg; } - const wxColour& GetHighlightColourBg() const { return m_colHighlightBg; } - - // holiday colour is used for the holidays (if style & wxCAL_SHOW_HOLIDAYS) - void SetHolidayColours(const wxColour& colFg, const wxColour& colBg) - { - m_colHolidayFg = colFg; - m_colHolidayBg = colBg; - } - - const wxColour& GetHolidayColourFg() const { return m_colHolidayFg; } - const wxColour& GetHolidayColourBg() const { return m_colHolidayBg; } - - // an item without custom attributes is drawn with the default colours and - // font and without border, setting custom attributes allows to modify this - // - // the day parameter should be in 1..31 range, for days 29, 30, 31 the - // corresponding attribute is just unused if there is no such day in the - // current month - - wxCalendarDateAttr *GetAttr(size_t day) const - { - wxCHECK_MSG( day > 0 && day < 32, NULL, _T("invalid day") ); - - return m_attrs[day - 1]; - } - - void SetAttr(size_t day, wxCalendarDateAttr *attr) - { - wxCHECK_RET( day > 0 && day < 32, _T("invalid day") ); - - delete m_attrs[day - 1]; - m_attrs[day - 1] = attr; - } - - void SetHoliday(size_t day); - - void ResetAttr(size_t day) { SetAttr(day, (wxCalendarDateAttr *)NULL); } - - // returns one of wxCAL_HITTEST_XXX constants and fills either date or wd - // with the corresponding value (none for NOWHERE, the date for DAY and wd - // for HEADER) - wxCalendarHitTestResult HitTest(const wxPoint& pos, - wxDateTime *date = NULL, - wxDateTime::WeekDay *wd = NULL); - - // implementation only from now on - // ------------------------------- - - // forward these functions to all subcontrols - virtual bool Enable(bool enable = true); - virtual bool Show(bool show = true); - - virtual void SetWindowStyleFlag(long style); - - virtual wxVisualAttributes GetDefaultAttributes() const - { return GetClassDefaultAttributes(GetWindowVariant()); } - - static wxVisualAttributes - GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL); - - void OnSysColourChanged(wxSysColourChangedEvent& event); - -protected: - // override some base class virtuals - virtual wxSize DoGetBestSize() const; - virtual void DoGetPosition(int *x, int *y) const; - virtual void DoGetSize(int *width, int *height) const; - virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags); - virtual void DoMoveWindow(int x, int y, int width, int height); - -private: - // common part of all ctors - void Init(); - - // startup colours and reinitialization after colour changes in system - void InitColours(); - - // event handlers - void OnPaint(wxPaintEvent& event); - void OnClick(wxMouseEvent& event); - void OnDClick(wxMouseEvent& event); - void OnChar(wxKeyEvent& event); - void OnMonthChange(wxCommandEvent& event); - void OnYearChange(wxCommandEvent& event); - void OnYearTextChange(wxCommandEvent& event); - - // (re)calc m_widthCol and m_heightRow - void RecalcGeometry(); - - // set the date and send the notification - void SetDateAndNotify(const wxDateTime& date); - - // get the week (row, in range 1..6) for the given date - size_t GetWeek(const wxDateTime& date) const; - - // get the date from which we start drawing days - wxDateTime GetStartDate() const; - - // is this date shown? - bool IsDateShown(const wxDateTime& date) const; - - // is this date in the given range? - bool IsDateInRange(const wxDateTime& date) const; - - // range helpers - bool ChangeYear(wxDateTime* target) const; - bool ChangeMonth(wxDateTime* target) const; - - // redraw the given date - void RefreshDate(const wxDateTime& date); - - // change the date inside the same month/year - void ChangeDay(const wxDateTime& date); - - // set the attributes for the holidays if needed - void SetHolidayAttrs(); - - // reset all holidays - void ResetHolidayAttrs(); - - // generate the given calendar event(s) - void GenerateEvent(wxEventType type) - { - wxCalendarEvent event(this, type); - (void)GetEventHandler()->ProcessEvent(event); - } - - void GenerateEvents(wxEventType type1, wxEventType type2) - { - GenerateEvent(type1); - GenerateEvent(type2); - } - - // do we allow changing the month/year? - bool AllowMonthChange() const - { - return (GetWindowStyle() & wxCAL_NO_MONTH_CHANGE) - != wxCAL_NO_MONTH_CHANGE; - } - bool AllowYearChange() const - { - return !(GetWindowStyle() & wxCAL_NO_YEAR_CHANGE); - } - - // show the correct controls - void ShowCurrentControls(); - - // create the month combo and year spin controls - void CreateMonthComboBox(); - void CreateYearSpinCtrl(); - -public: - // get the currently shown control for month/year - wxControl *GetMonthControl() const; - wxControl *GetYearControl() const; - -private: - // OnPaint helper-methods - - // Highlight the [fromdate : todate] range using pen and brush - void HighlightRange(wxPaintDC* dc, const wxDateTime& fromdate, const wxDateTime& todate, const wxPen* pen, const wxBrush* brush); - - // Get the "coordinates" for the date relative to the month currently displayed. - // using (day, week): upper left coord is (1, 1), lower right coord is (7, 6) - // if the date isn't visible (-1, -1) is put in (day, week) and false is returned - bool GetDateCoord(const wxDateTime& date, int *day, int *week) const; - - // Set the flag for SetDate(): otherwise it would overwrite the year - // typed in by the user - void SetUserChangedYear() { m_userChangedYear = true; } - - // the subcontrols - wxStaticText *m_staticMonth; - wxComboBox *m_comboMonth; - - wxStaticText *m_staticYear; - wxSpinCtrl *m_spinYear; - - // the current selection - wxDateTime m_date; - - // the date-range - wxDateTime m_lowdate; - wxDateTime m_highdate; - - // default attributes - wxColour m_colHighlightFg, - m_colHighlightBg, - m_colHolidayFg, - m_colHolidayBg, - m_colHeaderFg, - m_colHeaderBg, - m_colBackground, - m_colSorrounding; - - // the attributes for each of the month days - wxCalendarDateAttr *m_attrs[31]; - - // the width and height of one column/row in the calendar - wxCoord m_widthCol, - m_heightRow, - m_rowOffset; - - wxRect m_leftArrowRect, - m_rightArrowRect; - - // the week day names - wxString m_weekdays[7]; - - // true if SetDate() is being called as the result of changing the year in - // the year control - bool m_userChangedYear; - - DECLARE_DYNAMIC_CLASS(wxCalendarCtrl) - DECLARE_EVENT_TABLE() - DECLARE_NO_COPY_CLASS(wxCalendarCtrl) -}; - -#endif // _WX_GENERIC_CALCTRL_H diff --git a/include/wx/generic/calctrlg.h b/include/wx/generic/calctrlg.h new file mode 100644 index 0000000000..682227cc37 --- /dev/null +++ b/include/wx/generic/calctrlg.h @@ -0,0 +1,303 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: generic/calctrlg.h +// Purpose: generic implementation of date-picker control +// Author: Vadim Zeitlin +// Modified by: +// Created: 29.12.99 +// RCS-ID: $Id$ +// Copyright: (c) 1999 Vadim Zeitlin +// Licence: wxWindows licence +/////////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_GENERIC_CALCTRLG_H +#define _WX_GENERIC_CALCTRLG_H + +#include "wx/control.h" // the base class +#include "wx/dcclient.h" // for wxPaintDC + +class WXDLLIMPEXP_FWD_CORE wxComboBox; +class WXDLLIMPEXP_FWD_CORE wxStaticText; +class WXDLLIMPEXP_FWD_CORE wxSpinCtrl; + +// ---------------------------------------------------------------------------- +// wxGenericCalendarCtrl +// ---------------------------------------------------------------------------- + +class WXDLLIMPEXP_ADV wxGenericCalendarCtrl : public wxCalendarCtrlBase +{ +public: + // construction + wxGenericCalendarCtrl() { Init(); } + wxGenericCalendarCtrl(wxWindow *parent, + wxWindowID id, + const wxDateTime& date = wxDefaultDateTime, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxCAL_SHOW_HOLIDAYS, + const wxString& name = wxCalendarNameStr); + + bool Create(wxWindow *parent, + wxWindowID id, + const wxDateTime& date = wxDefaultDateTime, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxCAL_SHOW_HOLIDAYS, + const wxString& name = wxCalendarNameStr); + + virtual ~wxGenericCalendarCtrl(); + + virtual bool Destroy(); + + // set/get the current date + // ------------------------ + + virtual bool SetDate(const wxDateTime& date); + virtual wxDateTime GetDate() const { return m_date; } + + + // set/get the range in which selection can occur + // --------------------------------------------- + + // all functions in this section are for generic version only + bool SetLowerDateLimit(const wxDateTime& date = wxDefaultDateTime); + const wxDateTime& GetLowerDateLimit() const { return m_lowdate; } + bool SetUpperDateLimit(const wxDateTime& date = wxDefaultDateTime); + const wxDateTime& GetUpperDateLimit() const { return m_highdate; } + + bool SetDateRange(const wxDateTime& lowerdate = wxDefaultDateTime, + const wxDateTime& upperdate = wxDefaultDateTime); + + + // calendar mode + // ------------- + + // some calendar styles can't be changed after the control creation by + // just using SetWindowStyle() and Refresh() and the functions below + // should be used instead for them + + // corresponds to wxCAL_NO_MONTH_CHANGE bit + virtual bool EnableMonthChange(bool enable = true); + + // corresponds to wxCAL_NO_YEAR_CHANGE bit, deprecated, generic only + void EnableYearChange(bool enable = true); + + // corresponds to wxCAL_SHOW_HOLIDAYS bit, generic only + void EnableHolidayDisplay(bool display = true); + + + // customization + // ------------- + + virtual void Mark(size_t day, bool mark); + + // all other functions in this section are for generic version only + + // header colours are used for painting the weekdays at the top + void SetHeaderColours(const wxColour& colFg, const wxColour& colBg) + { + m_colHeaderFg = colFg; + m_colHeaderBg = colBg; + } + + const wxColour& GetHeaderColourFg() const { return m_colHeaderFg; } + const wxColour& GetHeaderColourBg() const { return m_colHeaderBg; } + + // highlight colour is used for the currently selected date + void SetHighlightColours(const wxColour& colFg, const wxColour& colBg) + { + m_colHighlightFg = colFg; + m_colHighlightBg = colBg; + } + + const wxColour& GetHighlightColourFg() const { return m_colHighlightFg; } + const wxColour& GetHighlightColourBg() const { return m_colHighlightBg; } + + // holiday colour is used for the holidays (if style & wxCAL_SHOW_HOLIDAYS) + void SetHolidayColours(const wxColour& colFg, const wxColour& colBg) + { + m_colHolidayFg = colFg; + m_colHolidayBg = colBg; + } + + const wxColour& GetHolidayColourFg() const { return m_colHolidayFg; } + const wxColour& GetHolidayColourBg() const { return m_colHolidayBg; } + + virtual wxCalendarDateAttr *GetAttr(size_t day) const + { + wxCHECK_MSG( day > 0 && day < 32, NULL, _T("invalid day") ); + + return m_attrs[day - 1]; + } + + virtual void SetAttr(size_t day, wxCalendarDateAttr *attr) + { + wxCHECK_RET( day > 0 && day < 32, _T("invalid day") ); + + delete m_attrs[day - 1]; + m_attrs[day - 1] = attr; + } + + virtual void ResetAttr(size_t day) { SetAttr(day, NULL); } + + void SetHoliday(size_t day); + + virtual wxCalendarHitTestResult HitTest(const wxPoint& pos, + wxDateTime *date = NULL, + wxDateTime::WeekDay *wd = NULL); + + // implementation only from now on + // ------------------------------- + + // forward these functions to all subcontrols + virtual bool Enable(bool enable = true); + virtual bool Show(bool show = true); + + virtual void SetWindowStyleFlag(long style); + + virtual wxVisualAttributes GetDefaultAttributes() const + { return GetClassDefaultAttributes(GetWindowVariant()); } + + static wxVisualAttributes + GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL); + + void OnSysColourChanged(wxSysColourChangedEvent& event); + +protected: + // override some base class virtuals + virtual wxSize DoGetBestSize() const; + virtual void DoGetPosition(int *x, int *y) const; + virtual void DoGetSize(int *width, int *height) const; + virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags); + virtual void DoMoveWindow(int x, int y, int width, int height); + +private: + // common part of all ctors + void Init(); + + // startup colours and reinitialization after colour changes in system + void InitColours(); + + // event handlers + void OnPaint(wxPaintEvent& event); + void OnClick(wxMouseEvent& event); + void OnDClick(wxMouseEvent& event); + void OnChar(wxKeyEvent& event); + void OnMonthChange(wxCommandEvent& event); + void OnYearChange(wxCommandEvent& event); + void OnYearTextChange(wxCommandEvent& event); + + // (re)calc m_widthCol and m_heightRow + void RecalcGeometry(); + + // set the date and send the notification + void SetDateAndNotify(const wxDateTime& date); + + // get the week (row, in range 1..6) for the given date + size_t GetWeek(const wxDateTime& date) const; + + // get the date from which we start drawing days + wxDateTime GetStartDate() const; + + // is this date shown? + bool IsDateShown(const wxDateTime& date) const; + + // is this date in the given range? + bool IsDateInRange(const wxDateTime& date) const; + + // range helpers + bool ChangeYear(wxDateTime* target) const; + bool ChangeMonth(wxDateTime* target) const; + + // redraw the given date + void RefreshDate(const wxDateTime& date); + + // change the date inside the same month/year + void ChangeDay(const wxDateTime& date); + + // set the attributes for the holidays if needed + void SetHolidayAttrs(); + + // reset all holidays + void ResetHolidayAttrs(); + + // deprecated + bool AllowYearChange() const + { + return !(GetWindowStyle() & wxCAL_NO_YEAR_CHANGE); + } + + // show the correct controls + void ShowCurrentControls(); + + // create the month combo and year spin controls + void CreateMonthComboBox(); + void CreateYearSpinCtrl(); + +public: + // get the currently shown control for month/year + wxControl *GetMonthControl() const; + wxControl *GetYearControl() const; + +private: + // OnPaint helper-methods + + // Highlight the [fromdate : todate] range using pen and brush + void HighlightRange(wxPaintDC* dc, const wxDateTime& fromdate, const wxDateTime& todate, const wxPen* pen, const wxBrush* brush); + + // Get the "coordinates" for the date relative to the month currently displayed. + // using (day, week): upper left coord is (1, 1), lower right coord is (7, 6) + // if the date isn't visible (-1, -1) is put in (day, week) and false is returned + bool GetDateCoord(const wxDateTime& date, int *day, int *week) const; + + // Set the flag for SetDate(): otherwise it would overwrite the year + // typed in by the user + void SetUserChangedYear() { m_userChangedYear = true; } + + // the subcontrols + wxStaticText *m_staticMonth; + wxComboBox *m_comboMonth; + + wxStaticText *m_staticYear; + wxSpinCtrl *m_spinYear; + + // the current selection + wxDateTime m_date; + + // the date-range + wxDateTime m_lowdate; + wxDateTime m_highdate; + + // default attributes + wxColour m_colHighlightFg, + m_colHighlightBg, + m_colHolidayFg, + m_colHolidayBg, + m_colHeaderFg, + m_colHeaderBg, + m_colBackground, + m_colSorrounding; + + // the attributes for each of the month days + wxCalendarDateAttr *m_attrs[31]; + + // the width and height of one column/row in the calendar + wxCoord m_widthCol, + m_heightRow, + m_rowOffset; + + wxRect m_leftArrowRect, + m_rightArrowRect; + + // the week day names + wxString m_weekdays[7]; + + // true if SetDate() is being called as the result of changing the year in + // the year control + bool m_userChangedYear; + + DECLARE_DYNAMIC_CLASS(wxGenericCalendarCtrl) + DECLARE_EVENT_TABLE() + DECLARE_NO_COPY_CLASS(wxGenericCalendarCtrl) +}; + +#endif // _WX_GENERIC_CALCTRLG_H diff --git a/include/wx/generic/datectrl.h b/include/wx/generic/datectrl.h index da7bf72462..c84f551994 100644 --- a/include/wx/generic/datectrl.h +++ b/include/wx/generic/datectrl.h @@ -13,7 +13,7 @@ #define _WX_GENERIC_DATECTRL_H_ class WXDLLIMPEXP_FWD_ADV wxCalendarDateAttr; -class WXDLLIMPEXP_FWD_ADV wxCalendarCtrl; +class WXDLLIMPEXP_FWD_ADV wxGenericCalendarCtrl; class WXDLLIMPEXP_FWD_ADV wxCalendarEvent; class WXDLLIMPEXP_FWD_CORE wxComboCtrl; class WXDLLIMPEXP_FWD_ADV wxCalendarComboPopup; @@ -59,7 +59,7 @@ public: // extra methods available only in this (generic) implementation bool SetFormat(const wxString& fmt); - wxCalendarCtrl *GetCalendar() const; + wxGenericCalendarCtrl *GetCalendar() const; // implementation only from now on diff --git a/include/wx/gtk/calctrl.h b/include/wx/gtk/calctrl.h new file mode 100644 index 0000000000..73b3d916ae --- /dev/null +++ b/include/wx/gtk/calctrl.h @@ -0,0 +1,50 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: wx/gtk/calctrl.h +// Purpose: wxGtkCalendarCtrl control +// Author: Marcin Wojdyr +// RCS-ID: $Id$ +// Copyright: (C) 2008 Marcin Wojdyr +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef GTK_CALCTRL_H__ +#define GTK_CALCTRL_H__ + +class WXDLLIMPEXP_ADV wxGtkCalendarCtrl : public wxCalendarCtrlBase +{ +public: + wxGtkCalendarCtrl() {} + wxGtkCalendarCtrl(wxWindow *parent, + wxWindowID id, + const wxDateTime& date = wxDefaultDateTime, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxCAL_SHOW_HOLIDAYS, + const wxString& name = wxCalendarNameStr) + { + Create(parent, id, date, pos, size, style, name); + } + + bool Create(wxWindow *parent, + wxWindowID id, + const wxDateTime& date = wxDefaultDateTime, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxCAL_SHOW_HOLIDAYS, + const wxString& name = wxCalendarNameStr); + + virtual ~wxGtkCalendarCtrl() {} + + virtual bool SetDate(const wxDateTime& date); + virtual wxDateTime GetDate() const; + + virtual bool EnableMonthChange(bool enable = true); + + virtual void Mark(size_t day, bool mark); + +private: + DECLARE_DYNAMIC_CLASS(wxGtkCalendarCtrl) + DECLARE_NO_COPY_CLASS(wxGtkCalendarCtrl) +}; + +#endif // GTK_CALCTRL_H__ diff --git a/interface/calctrl.h b/interface/calctrl.h index 244d841c9b..d894e1f821 100644 --- a/interface/calctrl.h +++ b/interface/calctrl.h @@ -29,8 +29,8 @@ public: wxDateTime::WeekDay GetWeekDay() const; /** - Sets the week day carried by the event, normally only used by the library - internally. + Sets the week day carried by the event, + normally only used by the library internally. */ void SetWeekDay(wxDateTime::WeekDay day); }; @@ -152,6 +152,17 @@ public: Sets the text (foreground) colour to use. */ void SetTextColour(const wxColour& colText); + + /** + Used (internally) by generic wxCalendarCtrl::Mark() + */ + static const wxCalendarDateAttr& GetMark(); + + /** + Set the attribute that will be used to Mark() days + on generic wxCalendarCtrl + */ + static void SetMark(wxCalendarDateAttr const& m); }; @@ -160,56 +171,69 @@ public: @class wxCalendarCtrl @wxheader{calctrl.h} - The calendar control allows the user to pick a date. For this, - it displays a window containing several parts: a control at the top to pick the - month - and the year (either or both of them may be disabled), and a month - area below them which shows all the days in the month. The user can move the + The calendar control allows the user to pick a date. The user can move the current selection using the keyboard and select the date (generating @c EVT_CALENDAR event) by pressing @c Return or double clicking it. - It has advanced possibilities for the customization of its display. All global - settings (such as colours and fonts used) can, of course, be changed. But - also, the display style for each day in the month can be set independently - using wxCalendarDateAttr class. + Generic calendar has advanced possibilities for the customization of its + display, described below. If you want to use these possibilities on + every platform, use wxGenericCalendarCtrl instead of wxCalendarCtrl. + + All global settings (such as colours and fonts used) can, of course, + be changed. But also, the display style for each day in the month can + be set independently using wxCalendarDateAttr class. An item without custom attributes is drawn with the default colours and font and without border, but setting custom attributes with wxCalendarCtrl::SetAttr allows to modify its appearance. Just create a custom attribute object and set it for the day you want to be - displayed specially (note that the control will take ownership of the pointer, - i.e. it will delete it itself). A day may be marked as being a holiday, even - if it is not recognized as one by wxDateTime using - wxCalendarDateAttr::SetHoliday method. + displayed specially (note that the control will take ownership of + the pointer, i.e. it will delete it itself). + A day may be marked as being a holiday, even if it is not recognized as + one by wxDateTime using wxCalendarDateAttr::SetHoliday method. As the attributes are specified for each day, they may change when the month is changed, so you will often want to update them in - @c EVT_CALENDAR_MONTH event handler. + @c EVT_CALENDAR_PAGE_CHANGED event handler. @beginStyleTable @style{wxCAL_SUNDAY_FIRST}: - Show Sunday as the first day in the week + Show Sunday as the first day in the week (only generic) @style{wxCAL_MONDAY_FIRST}: - Show Monday as the first day in the week + Show Monday as the first day in the week (only generic) @style{wxCAL_SHOW_HOLIDAYS}: - Highlight holidays in the calendar + Highlight holidays in the calendar (only generic) @style{wxCAL_NO_YEAR_CHANGE}: - Disable the year changing + Disable the year changing (deprecated, only generic) @style{wxCAL_NO_MONTH_CHANGE}: Disable the month (and, implicitly, the year) changing @style{wxCAL_SHOW_SURROUNDING_WEEKS}: Show the neighbouring weeks in the previous and next months + (only generic) @style{wxCAL_SEQUENTIAL_MONTH_SELECTION}: Use alternative, more compact, style for the month and year - selection controls. + selection controls. (only generic) @endStyleTable + @beginEventTable + @event{EVT_CALENDAR(id, func)}: + A day was double clicked in the calendar. + @event{EVT_CALENDAR_SEL_CHANGED(id, func)}: + The selected date changed. + @event{EVT_CALENDAR_PAGE_CHANGED(id, func)}: + The selected month (and/or year) changed. + @event{EVT_CALENDAR_WEEKDAY_CLICKED(id, func)}: + User clicked on the week day header (only generic). + @endEventTable + @library{wxadv} @category{ctrl} @appearance{calendarctrl.png} + @nativeimpl{wxgtk} + @see @ref overview_samplecalendar "Calendar sample", wxCalendarDateAttr, - wxCalendarEvent + wxCalendarEvent, wxDatePickerCtrl */ class wxCalendarCtrl : public wxControl { @@ -253,21 +277,26 @@ public: /** This function should be used instead of changing @c wxCAL_NO_MONTH_CHANGE style bit. It allows or disallows the user to - change the month interactively. Note that if the month can not be changed, the - year can not be changed neither. + change the month interactively. Note that if the month can not + be changed, the year can not be changed neither. + + @return @true if the value of this option really changed or @false + if it was already set to the requested value. */ - void EnableMonthChange(bool enable = true); + bool EnableMonthChange(bool enable = true); /** + @deprecated + This function should be used instead of changing @c wxCAL_NO_YEAR_CHANGE style bit directly. It allows or disallows the user to change the year - interactively. + interactively. Only in generic wxCalendarCtrl. */ void EnableYearChange(bool enable = true); /** Returns the attribute for the given date (should be in the range 1...31). - The returned pointer may be @NULL. + The returned pointer may be @NULL. Only in generic wxCalendarCtrl. */ wxCalendarDateAttr* GetAttr(size_t day) const; @@ -285,20 +314,21 @@ public: /** Gets the foreground colour of the header part of the calendar window. + Only in generic wxCalendarCtrl. @see SetHeaderColours() */ const wxColour GetHeaderColourFg() const; /** - Gets the background highlight colour. + Gets the background highlight colour. Only in generic wxCalendarCtrl. @see SetHighlightColours() */ const wxColour GetHighlightColourBg() const; /** - Gets the foreground highlight colour. + Gets the foreground highlight colour. Only in generic wxCalendarCtrl. @see SetHighlightColours() */ @@ -306,6 +336,7 @@ public: /** Return the background colour currently used for holiday highlighting. + Only in generic wxCalendarCtrl. @see SetHolidayColours() */ @@ -313,6 +344,7 @@ public: /** Return the foreground colour currently used for holiday highlighting. + Only in generic wxCalendarCtrl. @see SetHolidayColours() */ @@ -320,8 +352,9 @@ public: /** Returns one of @c wxCAL_HITTEST_XXX - constants() and fills either @a date or - @a wd pointer with the corresponding value depending on the hit test code. + constants() and fills either @a date or @a wd pointer with + the corresponding value depending on the hit test code. + Only in generic wxCalendarCtrl. */ wxCalendarHitTestResult HitTest(const wxPoint& pos, wxDateTime* date = NULL, @@ -330,12 +363,14 @@ public: /** Clears any attributes associated with the given day (in the range 1...31). + Only in generic wxCalendarCtrl. */ void ResetAttr(size_t day); /** Associates the attribute with the specified date (in the range 1...31). If the pointer is @NULL, the items attribute is cleared. + Only in generic wxCalendarCtrl. */ void SetAttr(size_t day, wxCalendarDateAttr* attr); @@ -346,12 +381,14 @@ public: /** Set the colours used for painting the weekdays at the top of the control. + Only in generic wxCalendarCtrl. */ void SetHeaderColours(const wxColour& colFg, const wxColour& colBg); /** Set the colours to be used for highlighting the currently selected date. + Only in generic wxCalendarCtrl. */ void SetHighlightColours(const wxColour& colFg, const wxColour& colBg); @@ -364,8 +401,16 @@ public: /** Sets the colours to be used for the holidays highlighting (only used if the window style includes @c wxCAL_SHOW_HOLIDAYS flag). + Only in generic wxCalendarCtrl. */ void SetHolidayColours(const wxColour& colFg, const wxColour& colBg); + + /** + Mark or unmark the day. + This day of month will be marked in every month. + In generic wxCalendarCtrl, + */ + void Mark(size_t day, bool mark); }; diff --git a/samples/calendar/calendar.cpp b/samples/calendar/calendar.cpp index 4e003535e8..5241a440a6 100644 --- a/samples/calendar/calendar.cpp +++ b/samples/calendar/calendar.cpp @@ -42,6 +42,7 @@ #endif #include "wx/calctrl.h" +#include "wx/splitter.h" #if wxUSE_DATEPICKCTRL #include "wx/datectrl.h" @@ -52,6 +53,10 @@ #include "../sample.xpm" +#ifdef wxHAS_NATIVE_CALENDARCTRL + #include "wx/generic/calctrlg.h" +#endif + // ---------------------------------------------------------------------------- // private classes // ---------------------------------------------------------------------------- @@ -72,29 +77,40 @@ public: class MyPanel : public wxPanel { public: - MyPanel(wxFrame *frame); + MyPanel(wxWindow *parent); void OnCalendar(wxCalendarEvent& event); void OnCalendarWeekDayClick(wxCalendarEvent& event); void OnCalendarChange(wxCalendarEvent& event); void OnCalMonthChange(wxCalendarEvent& event); - void OnCalYearChange(wxCalendarEvent& event); - wxCalendarCtrl *GetCal() const { return m_calendar; } + wxCalendarCtrlBase *GetCal() const { return m_calendar; } // turn on/off the specified style bit on the calendar control void ToggleCalStyle(bool on, int style); + bool IsUsingGeneric() const { return m_usingGeneric; } + void ToggleUseGeneric() + { + m_usingGeneric = !m_usingGeneric; + RecreateCalendar(m_calendar->GetWindowStyle()); + } + void HighlightSpecial(bool on); wxDateTime GetDate() const { return m_calendar->GetDate(); } void SetDate(const wxDateTime& dt) { m_calendar->SetDate(dt); } private: - wxCalendarCtrl *m_calendar; + void RecreateCalendar(long style); + + wxCalendarCtrlBase *m_calendar; wxStaticText *m_date; wxSizer *m_sizer; + bool m_usingGeneric; + + DECLARE_EVENT_TABLE() }; @@ -106,8 +122,9 @@ public: MyFrame(const wxString& title, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize); // event handlers (these functions should _not_ be virtual) - void OnQuit(wxCommandEvent& event); void OnAbout(wxCommandEvent& event); + void OnClearLog(wxCommandEvent& event); + void OnQuit(wxCommandEvent& event); #if wxUSE_DATEPICKCTRL void OnAskDate(wxCommandEvent& event); @@ -115,12 +132,18 @@ public: void OnUpdateUIStartWithNone(wxUpdateUIEvent& event); #endif // wxUSE_DATEPICKCTRL +#ifdef wxHAS_NATIVE_CALENDARCTRL + void OnCalGeneric(wxCommandEvent& WXUNUSED(event)) + { + m_panel->ToggleUseGeneric(); + } +#endif // wxHAS_NATIVE_CALENDARCTRL + void OnCalMonday(wxCommandEvent& event); void OnCalHolidays(wxCommandEvent& event); void OnCalSpecial(wxCommandEvent& event); void OnCalAllowMonth(wxCommandEvent& event); - void OnCalAllowYear(wxCommandEvent& event); void OnCalSeqMonth(wxCommandEvent& event); void OnCalShowSurroundingWeeks(wxCommandEvent& event); @@ -131,10 +154,14 @@ public: void OnCalToggleResizable(wxCommandEvent& event); - void OnAllowYearUpdate(wxUpdateUIEvent& event); + void OnUpdateUIGenericOnly(wxUpdateUIEvent& event) + { + event.Enable(m_panel->IsUsingGeneric()); + } private: MyPanel *m_panel; + wxTextCtrl *m_logWindow; // any class wishing to process wxWidgets events must use this macro DECLARE_EVENT_TABLE() @@ -172,12 +199,13 @@ enum { // menu items Calendar_File_About = wxID_ABOUT, + Calendar_File_ClearLog = wxID_CLEAR, Calendar_File_Quit = wxID_EXIT, - Calendar_Cal_Monday = 200, + Calendar_Cal_Generic = 200, + Calendar_Cal_Monday, Calendar_Cal_Holidays, Calendar_Cal_Special, Calendar_Cal_Month, - Calendar_Cal_Year, Calendar_Cal_SeqMonth, Calendar_Cal_SurroundWeeks, Calendar_Cal_SetDate, @@ -205,8 +233,9 @@ enum // handlers) which process them. It can be also done at run-time, but for the // simple menu events like this the static method is much simpler. BEGIN_EVENT_TABLE(MyFrame, wxFrame) - EVT_MENU(Calendar_File_Quit, MyFrame::OnQuit) EVT_MENU(Calendar_File_About, MyFrame::OnAbout) + EVT_MENU(Calendar_File_ClearLog, MyFrame::OnClearLog) + EVT_MENU(Calendar_File_Quit, MyFrame::OnQuit) #if wxUSE_DATEPICKCTRL EVT_MENU(Calendar_DatePicker_AskDate, MyFrame::OnAskDate) @@ -215,12 +244,15 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame) MyFrame::OnUpdateUIStartWithNone) #endif // wxUSE_DATEPICKCTRL +#ifdef wxHAS_NATIVE_CALENDARCTRL + EVT_MENU(Calendar_Cal_Generic, MyFrame::OnCalGeneric) +#endif // wxHAS_NATIVE_CALENDARCTRL + EVT_MENU(Calendar_Cal_Monday, MyFrame::OnCalMonday) EVT_MENU(Calendar_Cal_Holidays, MyFrame::OnCalHolidays) EVT_MENU(Calendar_Cal_Special, MyFrame::OnCalSpecial) EVT_MENU(Calendar_Cal_Month, MyFrame::OnCalAllowMonth) - EVT_MENU(Calendar_Cal_Year, MyFrame::OnCalAllowYear) EVT_MENU(Calendar_Cal_SeqMonth, MyFrame::OnCalSeqMonth) EVT_MENU(Calendar_Cal_SurroundWeeks, MyFrame::OnCalShowSurroundingWeeks) @@ -232,14 +264,17 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame) EVT_MENU(Calendar_Cal_Resizable, MyFrame::OnCalToggleResizable) - EVT_UPDATE_UI(Calendar_Cal_Year, MyFrame::OnAllowYearUpdate) + EVT_UPDATE_UI(Calendar_Cal_SeqMonth, MyFrame::OnUpdateUIGenericOnly) + EVT_UPDATE_UI(Calendar_Cal_Monday, MyFrame::OnUpdateUIGenericOnly) + EVT_UPDATE_UI(Calendar_Cal_Holidays, MyFrame::OnUpdateUIGenericOnly) + EVT_UPDATE_UI(Calendar_Cal_Special, MyFrame::OnUpdateUIGenericOnly) + EVT_UPDATE_UI(Calendar_Cal_SurroundWeeks, MyFrame::OnUpdateUIGenericOnly) END_EVENT_TABLE() BEGIN_EVENT_TABLE(MyPanel, wxPanel) - EVT_CALENDAR (Calendar_CalCtrl, MyPanel::OnCalendar) - EVT_CALENDAR_MONTH (Calendar_CalCtrl, MyPanel::OnCalMonthChange) - EVT_CALENDAR_YEAR (Calendar_CalCtrl, MyPanel::OnCalYearChange) - EVT_CALENDAR_SEL_CHANGED(Calendar_CalCtrl, MyPanel::OnCalendarChange) + EVT_CALENDAR(Calendar_CalCtrl, MyPanel::OnCalendar) + EVT_CALENDAR_PAGE_CHANGED(Calendar_CalCtrl, MyPanel::OnCalMonthChange) + EVT_CALENDAR_SEL_CHANGED(Calendar_CalCtrl, MyPanel::OnCalendarChange) EVT_CALENDAR_WEEKDAY_CLICKED(Calendar_CalCtrl, MyPanel::OnCalendarWeekDayClick) END_EVENT_TABLE() @@ -302,9 +337,16 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size) wxMenu *menuFile = new wxMenu; menuFile->Append(Calendar_File_About, _T("&About...\tCtrl-A"), _T("Show about dialog")); menuFile->AppendSeparator(); + menuFile->Append(Calendar_File_ClearLog, _T("&Clear log\tCtrl-L")); + menuFile->AppendSeparator(); menuFile->Append(Calendar_File_Quit, _T("E&xit\tAlt-X"), _T("Quit this program")); wxMenu *menuCal = new wxMenu; +#ifdef wxHAS_NATIVE_CALENDARCTRL + menuCal->AppendCheckItem(Calendar_Cal_Generic, "Use &generic version\tCtrl-G", + "Toggle between native and generic control"); + menuCal->AppendSeparator(); +#endif // wxHAS_NATIVE_CALENDARCTRL menuCal->Append(Calendar_Cal_Monday, _T("Monday &first weekday\tCtrl-F"), _T("Toggle between Mon and Sun as the first week day"), @@ -321,15 +363,12 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size) true); menuCal->AppendSeparator(); menuCal->Append(Calendar_Cal_SeqMonth, - _T("To&ggle month selector style\tCtrl-G"), + _T("Toggle month selector st&yle\tCtrl-Y"), _T("Use another style for the calendar controls"), true); menuCal->Append(Calendar_Cal_Month, _T("&Month can be changed\tCtrl-M"), _T("Allow changing the month in the calendar"), true); - menuCal->Append(Calendar_Cal_Year, _T("&Year can be changed\tCtrl-Y"), - _T("Allow changing the year in the calendar"), - true); menuCal->AppendSeparator(); menuCal->Append(Calendar_Cal_SetDate, _T("Call &SetDate(2005-12-24)"), _T("Set date to 2005-12-24.")); menuCal->Append(Calendar_Cal_Today, _T("Call &Today()"), _T("Set to the current date.")); @@ -366,7 +405,6 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size) menuBar->Check(Calendar_Cal_Monday, true); menuBar->Check(Calendar_Cal_Holidays, true); menuBar->Check(Calendar_Cal_Month, true); - menuBar->Check(Calendar_Cal_Year, true); #if wxUSE_DATEPICKCTRL menuBar->Check(Calendar_DatePicker_ShowCentury, true); @@ -375,13 +413,16 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size) // ... and attach this menu bar to the frame SetMenuBar(menuBar); - m_panel = new MyPanel(this); - -#if wxUSE_STATUSBAR - // create a status bar just for fun (by default with 1 pane only) - CreateStatusBar(2); - SetStatusText(_T("Welcome to wxWidgets!")); -#endif // wxUSE_STATUSBAR + wxSplitterWindow *splitter = new wxSplitterWindow(this, wxID_ANY, + wxDefaultPosition, wxDefaultSize, + wxSP_NOBORDER); + m_panel = new MyPanel(splitter); + m_logWindow = new wxTextCtrl(splitter, wxID_ANY, wxEmptyString, + wxDefaultPosition, wxDefaultSize, + wxTE_READONLY | wxTE_MULTILINE); + splitter->SplitHorizontally(m_panel, m_logWindow); + splitter->SetMinimumPaneSize(20); + wxLog::SetActiveTarget(new wxLogTextCtrl(m_logWindow)); } void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) @@ -392,22 +433,29 @@ void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event)) { - wxMessageBox(_T("wxCalendarCtrl sample\n(c) 2000 Vadim Zeitlin"), + wxMessageBox(_T("wxCalendarCtrl sample\n(c) 2000--2008 Vadim Zeitlin"), _T("About Calendar"), wxOK | wxICON_INFORMATION, this); } -void MyFrame::OnCalMonday(wxCommandEvent& event) +void MyFrame::OnClearLog(wxCommandEvent& WXUNUSED(event)) { - bool enable = GetMenuBar()->IsChecked(event.GetId()); + m_logWindow->Clear(); +} - m_panel->ToggleCalStyle(enable, wxCAL_MONDAY_FIRST); +void MyFrame::OnCalMonday(wxCommandEvent& event) +{ + m_panel->ToggleCalStyle(event.IsChecked(), wxCAL_MONDAY_FIRST); } void MyFrame::OnCalHolidays(wxCommandEvent& event) { - bool enable = GetMenuBar()->IsChecked(event.GetId()); - - m_panel->GetCal()->EnableHolidayDisplay(enable); + wxCalendarCtrlBase * cal = m_panel->GetCal(); +#ifdef wxHAS_NATIVE_CALENDARCTRL + wxStaticCast(cal, wxGenericCalendarCtrl) +#else + cal +#endif + ->EnableHolidayDisplay(event.IsChecked()); } void MyFrame::OnCalSpecial(wxCommandEvent& event) @@ -417,40 +465,23 @@ void MyFrame::OnCalSpecial(wxCommandEvent& event) void MyFrame::OnCalAllowMonth(wxCommandEvent& event) { - bool allow = GetMenuBar()->IsChecked(event.GetId()); - - m_panel->GetCal()->EnableMonthChange(allow); -} - -void MyFrame::OnCalAllowYear(wxCommandEvent& event) -{ - bool allow = GetMenuBar()->IsChecked(event.GetId()); - - m_panel->GetCal()->EnableYearChange(allow); + m_panel->GetCal()->EnableMonthChange(event.IsChecked()); } void MyFrame::OnCalSeqMonth(wxCommandEvent& event) { - bool allow = GetMenuBar()->IsChecked(event.GetId()); - - m_panel->ToggleCalStyle(allow, wxCAL_SEQUENTIAL_MONTH_SELECTION); + m_panel->ToggleCalStyle(event.IsChecked(), + wxCAL_SEQUENTIAL_MONTH_SELECTION); } void MyFrame::OnCalShowSurroundingWeeks(wxCommandEvent& event) { - bool allow = GetMenuBar()->IsChecked(event.GetId()); - - m_panel->ToggleCalStyle(allow, wxCAL_SHOW_SURROUNDING_WEEKS); -} - -void MyFrame::OnAllowYearUpdate(wxUpdateUIEvent& event) -{ - event.Enable( GetMenuBar()->IsChecked(Calendar_Cal_Month)); + m_panel->ToggleCalStyle(event.IsChecked(), wxCAL_SHOW_SURROUNDING_WEEKS); } void MyFrame::OnSetDate(wxCommandEvent &WXUNUSED(event)) { - m_panel->SetDate(wxDateTime(5, wxDateTime::Apr, 2008, 22, 00, 00)); + m_panel->SetDate(wxDateTime(24, wxDateTime::Dec, 2005, 22, 00, 00)); } void MyFrame::OnToday(wxCommandEvent &WXUNUSED(event)) @@ -537,9 +568,15 @@ void MyFrame::OnAskDate(wxCommandEvent& WXUNUSED(event)) // MyPanel // ---------------------------------------------------------------------------- -MyPanel::MyPanel(wxFrame *frame) - : wxPanel(frame, wxID_ANY) +MyPanel::MyPanel(wxWindow *parent) + : wxPanel(parent, wxID_ANY) { +#ifdef wxHAS_NATIVE_CALENDARCTRL + m_usingGeneric = false; +#else + m_usingGeneric = true; +#endif + wxString date; date.Printf(wxT("Selected date: %s"), wxDateTime::Today().FormatISODate().c_str()); @@ -565,7 +602,8 @@ MyPanel::MyPanel(wxFrame *frame) void MyPanel::OnCalendar(wxCalendarEvent& event) { - wxLogMessage(wxT("Selected %s from calendar"), + m_calendar->Mark(event.GetDate().GetDay(), true); + wxLogMessage(wxT("Selected (and marked) %s from calendar."), event.GetDate().FormatISODate().c_str()); } @@ -575,16 +613,14 @@ void MyPanel::OnCalendarChange(wxCalendarEvent& event) s.Printf(wxT("Selected date: %s"), event.GetDate().FormatISODate().c_str()); m_date->SetLabel(s); + wxLogStatus(s); } -void MyPanel::OnCalMonthChange(wxCalendarEvent& WXUNUSED(event)) -{ - wxLogStatus(wxT("Calendar month changed")); -} - -void MyPanel::OnCalYearChange(wxCalendarEvent& WXUNUSED(event)) +void MyPanel::OnCalMonthChange(wxCalendarEvent& event) { - wxLogStatus(wxT("Calendar year changed")); + wxLogStatus(wxT("Calendar month changed to %s %d"), + wxDateTime::GetMonthName(event.GetDate().GetMonth()), + event.GetDate().GetYear()); } void MyPanel::OnCalendarWeekDayClick(wxCalendarEvent& event) @@ -593,6 +629,31 @@ void MyPanel::OnCalendarWeekDayClick(wxCalendarEvent& event) wxDateTime::GetWeekDayName(event.GetWeekDay()).c_str()); } +void MyPanel::RecreateCalendar(long style) +{ + wxCalendarCtrlBase *calendar; +#ifdef wxHAS_NATIVE_CALENDARCTRL + if ( m_usingGeneric ) + calendar = new wxGenericCalendarCtrl(this, Calendar_CalCtrl, + m_calendar->GetDate(), + wxDefaultPosition, + wxDefaultSize, + style); + else +#endif // wxHAS_NATIVE_CALENDARCTRL + calendar = new wxCalendarCtrl(this, Calendar_CalCtrl, + m_calendar->GetDate(), + wxDefaultPosition, + wxDefaultSize, + style); + + m_sizer->Replace(m_calendar, calendar); + delete m_calendar; + m_calendar = calendar; + + m_sizer->Layout(); +} + void MyPanel::ToggleCalStyle(bool on, int flag) { long style = m_calendar->GetWindowStyle(); @@ -604,16 +665,7 @@ void MyPanel::ToggleCalStyle(bool on, int flag) if ( flag == wxCAL_SEQUENTIAL_MONTH_SELECTION ) { // changing this style requires recreating the control - wxCalendarCtrl *calendar = new wxCalendarCtrl(this, Calendar_CalCtrl, - m_calendar->GetDate(), - wxDefaultPosition, - wxDefaultSize, - style); - m_sizer->Replace(m_calendar, calendar); - delete m_calendar; - m_calendar = calendar; - - m_sizer->Layout(); + RecreateCalendar(style); } else // just changing the style is enough { @@ -646,6 +698,7 @@ void MyPanel::HighlightSpecial(bool on) m_calendar->Refresh(); } + // ---------------------------------------------------------------------------- // MyDialog // ---------------------------------------------------------------------------- diff --git a/src/common/calctrlcmn.cpp b/src/common/calctrlcmn.cpp new file mode 100644 index 0000000000..481be6e619 --- /dev/null +++ b/src/common/calctrlcmn.cpp @@ -0,0 +1,64 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: common/calctrlcmn.cpp +// Author: Marcin Wojdyr +// Created: 2008-03-26 +// RCS-ID: $Id$ +// Copyright: (C) Marcin Wojdyr +// Licence: wxWindows licence +/////////////////////////////////////////////////////////////////////////////// + +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#endif //WX_PRECOMP + +#if wxUSE_CALENDARCTRL || wxUSE_DATEPICKCTRL + +#include "wx/dateevt.h" +IMPLEMENT_DYNAMIC_CLASS(wxDateEvent, wxCommandEvent) +DEFINE_EVENT_TYPE(wxEVT_DATE_CHANGED) + +#endif // wxUSE_CALENDARCTRL || wxUSE_DATEPICKCTRL + + +#if wxUSE_CALENDARCTRL + +#include "wx/calctrl.h" + +// ---------------------------------------------------------------------------- +// events +// ---------------------------------------------------------------------------- +IMPLEMENT_DYNAMIC_CLASS(wxCalendarEvent, wxDateEvent) + +DEFINE_EVENT_TYPE(wxEVT_CALENDAR_SEL_CHANGED) +DEFINE_EVENT_TYPE(wxEVT_CALENDAR_PAGE_CHANGED) +DEFINE_EVENT_TYPE(wxEVT_CALENDAR_DOUBLECLICKED) +DEFINE_EVENT_TYPE(wxEVT_CALENDAR_WEEKDAY_CLICKED) + +// deprecated events +DEFINE_EVENT_TYPE(wxEVT_CALENDAR_DAY_CHANGED) +DEFINE_EVENT_TYPE(wxEVT_CALENDAR_MONTH_CHANGED) +DEFINE_EVENT_TYPE(wxEVT_CALENDAR_YEAR_CHANGED) + + +wxCalendarDateAttr wxCalendarDateAttr::m_mark(wxCAL_BORDER_SQUARE); + +bool wxCalendarCtrlBase::EnableMonthChange(bool enable) +{ + const long styleOrig = GetWindowStyle(); + long style = enable ? styleOrig & ~wxCAL_NO_MONTH_CHANGE + : styleOrig | wxCAL_NO_MONTH_CHANGE; + if ( style == styleOrig ) + return false; + + SetWindowStyle(style); + + return true; +} + +#endif // wxUSE_CALENDARCTRL + diff --git a/src/generic/calctrl.cpp b/src/generic/calctrl.cpp deleted file mode 100644 index e9e06acc71..0000000000 --- a/src/generic/calctrl.cpp +++ /dev/null @@ -1,1834 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: src/generic/calctrl.cpp -// Purpose: implementation fo the generic wxCalendarCtrl -// Author: Vadim Zeitlin -// Modified by: -// Created: 29.12.99 -// RCS-ID: $Id$ -// Copyright: (c) 1999 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#ifndef WX_PRECOMP - #include "wx/dcclient.h" - #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 - -#if wxUSE_CALENDARCTRL - -#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 - -// ---------------------------------------------------------------------------- -// wxWin macros -// ---------------------------------------------------------------------------- - -BEGIN_EVENT_TABLE(wxCalendarCtrl, wxControl) - EVT_PAINT(wxCalendarCtrl::OnPaint) - - EVT_CHAR(wxCalendarCtrl::OnChar) - - EVT_LEFT_DOWN(wxCalendarCtrl::OnClick) - EVT_LEFT_DCLICK(wxCalendarCtrl::OnDClick) - - EVT_SYS_COLOUR_CHANGED(wxCalendarCtrl::OnSysColourChanged) -END_EVENT_TABLE() - -#if wxUSE_EXTENDED_RTTI -WX_DEFINE_FLAGS( wxCalendarCtrlStyle ) - -wxBEGIN_FLAGS( wxCalendarCtrlStyle ) - // new style border flags, we put them first to - // use them for streaming out - wxFLAGS_MEMBER(wxBORDER_SIMPLE) - wxFLAGS_MEMBER(wxBORDER_SUNKEN) - wxFLAGS_MEMBER(wxBORDER_DOUBLE) - wxFLAGS_MEMBER(wxBORDER_RAISED) - wxFLAGS_MEMBER(wxBORDER_STATIC) - wxFLAGS_MEMBER(wxBORDER_NONE) - - // old style border flags - wxFLAGS_MEMBER(wxSIMPLE_BORDER) - wxFLAGS_MEMBER(wxSUNKEN_BORDER) - wxFLAGS_MEMBER(wxDOUBLE_BORDER) - wxFLAGS_MEMBER(wxRAISED_BORDER) - wxFLAGS_MEMBER(wxSTATIC_BORDER) - wxFLAGS_MEMBER(wxBORDER) - - // standard window styles - wxFLAGS_MEMBER(wxTAB_TRAVERSAL) - wxFLAGS_MEMBER(wxCLIP_CHILDREN) - wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW) - wxFLAGS_MEMBER(wxWANTS_CHARS) - wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE) - wxFLAGS_MEMBER(wxALWAYS_SHOW_SB ) - wxFLAGS_MEMBER(wxVSCROLL) - wxFLAGS_MEMBER(wxHSCROLL) - - wxFLAGS_MEMBER(wxCAL_SUNDAY_FIRST) - wxFLAGS_MEMBER(wxCAL_MONDAY_FIRST) - wxFLAGS_MEMBER(wxCAL_SHOW_HOLIDAYS) - wxFLAGS_MEMBER(wxCAL_NO_YEAR_CHANGE) - wxFLAGS_MEMBER(wxCAL_NO_MONTH_CHANGE) - wxFLAGS_MEMBER(wxCAL_SEQUENTIAL_MONTH_SELECTION) - wxFLAGS_MEMBER(wxCAL_SHOW_SURROUNDING_WEEKS) - -wxEND_FLAGS( wxCalendarCtrlStyle ) - -IMPLEMENT_DYNAMIC_CLASS_XTI(wxCalendarCtrl, wxControl,"wx/calctrl.h") - -wxBEGIN_PROPERTIES_TABLE(wxCalendarCtrl) - wxEVENT_RANGE_PROPERTY( Updated , wxEVT_CALENDAR_SEL_CHANGED , wxEVT_CALENDAR_WEEKDAY_CLICKED , wxCalendarEvent ) - wxHIDE_PROPERTY( Children ) - wxPROPERTY( Date,wxDateTime, SetDate , GetDate, , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) - wxPROPERTY_FLAGS( WindowStyle , wxCalendarCtrlStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style -wxEND_PROPERTIES_TABLE() - -wxBEGIN_HANDLERS_TABLE(wxCalendarCtrl) -wxEND_HANDLERS_TABLE() - -wxCONSTRUCTOR_6( wxCalendarCtrl , wxWindow* , Parent , wxWindowID , Id , wxDateTime , Date , wxPoint , Position , wxSize , Size , long , WindowStyle ) -#else -IMPLEMENT_DYNAMIC_CLASS(wxCalendarCtrl, wxControl) -#endif -IMPLEMENT_DYNAMIC_CLASS(wxCalendarEvent, wxDateEvent) - -// ---------------------------------------------------------------------------- -// events -// ---------------------------------------------------------------------------- - -DEFINE_EVENT_TYPE(wxEVT_CALENDAR_SEL_CHANGED) -DEFINE_EVENT_TYPE(wxEVT_CALENDAR_DAY_CHANGED) -DEFINE_EVENT_TYPE(wxEVT_CALENDAR_MONTH_CHANGED) -DEFINE_EVENT_TYPE(wxEVT_CALENDAR_YEAR_CHANGED) -DEFINE_EVENT_TYPE(wxEVT_CALENDAR_DOUBLECLICKED) -DEFINE_EVENT_TYPE(wxEVT_CALENDAR_WEEKDAY_CLICKED) - -// ============================================================================ -// implementation -// ============================================================================ - -// ---------------------------------------------------------------------------- -// wxCalendarCtrl -// ---------------------------------------------------------------------------- - -wxCalendarCtrl::wxCalendarCtrl(wxWindow *parent, - wxWindowID id, - const wxDateTime& date, - const wxPoint& pos, - const wxSize& size, - long style, - const wxString& name) -{ - Init(); - - (void)Create(parent, id, date, pos, size, style, name); -} - -void wxCalendarCtrl::Init() -{ - m_comboMonth = NULL; - m_spinYear = NULL; - m_staticYear = NULL; - m_staticMonth = NULL; - - m_userChangedYear = false; - - m_widthCol = - m_heightRow = 0; - - wxDateTime::WeekDay wd; - for ( wd = wxDateTime::Sun; wd < wxDateTime::Inv_WeekDay; wxNextWDay(wd) ) - { - m_weekdays[wd] = wxDateTime::GetWeekDayName(wd, wxDateTime::Name_Abbr); - } - - for ( size_t n = 0; n < WXSIZEOF(m_attrs); n++ ) - { - m_attrs[n] = NULL; - } - - InitColours(); -} - -void wxCalendarCtrl::InitColours() -{ - m_colHighlightFg = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT); - m_colHighlightBg = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT); - m_colBackground = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW); - m_colSorrounding = wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT); - - m_colHolidayFg = *wxRED; - // don't set m_colHolidayBg - by default, same as our bg colour - - m_colHeaderFg = *wxBLUE; - m_colHeaderBg = *wxLIGHT_GREY; -} - -bool wxCalendarCtrl::Create(wxWindow *parent, - wxWindowID id, - const wxDateTime& date, - const wxPoint& pos, - const wxSize& size, - long style, - const wxString& name) -{ - if ( !wxControl::Create(parent, id, pos, size, - style | wxCLIP_CHILDREN | wxWANTS_CHARS | wxFULL_REPAINT_ON_RESIZE, - wxDefaultValidator, name) ) - { - return false; - } - - // needed to get the arrow keys normally used for the dialog navigation - SetWindowStyle(style | wxWANTS_CHARS); - - m_date = date.IsValid() ? date : wxDateTime::Today(); - - m_lowdate = wxDefaultDateTime; - m_highdate = wxDefaultDateTime; - - if ( !HasFlag(wxCAL_SEQUENTIAL_MONTH_SELECTION) ) - { - CreateYearSpinCtrl(); - m_staticYear = new wxStaticText(GetParent(), wxID_ANY, m_date.Format(_T("%Y")), - wxDefaultPosition, wxDefaultSize, - wxALIGN_CENTRE); - - CreateMonthComboBox(); - m_staticMonth = new wxStaticText(GetParent(), wxID_ANY, m_date.Format(_T("%B")), - wxDefaultPosition, wxDefaultSize, - wxALIGN_CENTRE); - } - - ShowCurrentControls(); - - // 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 - SetInitialSize(size); - SetPosition(pos); - - // Since we don't paint the whole background make sure that the platform - // will use the right one. - SetBackgroundColour(m_colBackground); - - SetHolidayAttrs(); - - return true; -} - -wxCalendarCtrl::~wxCalendarCtrl() -{ - for ( size_t n = 0; n < WXSIZEOF(m_attrs); n++ ) - { - delete m_attrs[n]; - } - - if ( !HasFlag(wxCAL_SEQUENTIAL_MONTH_SELECTION) ) - { - delete m_comboMonth; - delete m_staticMonth; - delete m_spinYear; - delete m_staticYear; - } -} - -void wxCalendarCtrl::SetWindowStyleFlag(long style) -{ - // changing this style doesn't work because the controls are not - // created/shown/hidden accordingly - wxASSERT_MSG( (style & wxCAL_SEQUENTIAL_MONTH_SELECTION) == - (m_windowStyle & wxCAL_SEQUENTIAL_MONTH_SELECTION), - _T("wxCAL_SEQUENTIAL_MONTH_SELECTION can't be changed after creation") ); - - wxControl::SetWindowStyleFlag(style); -} - -// ---------------------------------------------------------------------------- -// Create the wxComboBox and wxSpinCtrl -// ---------------------------------------------------------------------------- - -void wxCalendarCtrl::CreateMonthComboBox() -{ - m_comboMonth = new wxComboBox(GetParent(), wxID_ANY, - wxEmptyString, - wxDefaultPosition, - wxDefaultSize, - 0, NULL, - wxCB_READONLY | wxCLIP_SIBLINGS); - - wxDateTime::Month m; - for ( m = wxDateTime::Jan; m < wxDateTime::Inv_Month; wxNextMonth(m) ) - { - m_comboMonth->Append(wxDateTime::GetMonthName(m)); - } - - m_comboMonth->SetSelection(GetDate().GetMonth()); - m_comboMonth->SetSize(wxDefaultCoord, - wxDefaultCoord, - wxDefaultCoord, - wxDefaultCoord, - wxSIZE_AUTO_WIDTH|wxSIZE_AUTO_HEIGHT); - - m_comboMonth->Connect(m_comboMonth->GetId(), wxEVT_COMMAND_COMBOBOX_SELECTED, - wxCommandEventHandler(wxCalendarCtrl::OnMonthChange), - NULL, this); -} - -void wxCalendarCtrl::CreateYearSpinCtrl() -{ - m_spinYear = new wxSpinCtrl(GetParent(), wxID_ANY, - GetDate().Format(_T("%Y")), - wxDefaultPosition, - wxDefaultSize, - wxSP_ARROW_KEYS | wxCLIP_SIBLINGS, - -4300, 10000, GetDate().GetYear()); - - m_spinYear->Connect(m_spinYear->GetId(), wxEVT_COMMAND_TEXT_UPDATED, - wxCommandEventHandler(wxCalendarCtrl::OnYearTextChange), - NULL, this); - - m_spinYear->Connect(m_spinYear->GetId(), wxEVT_COMMAND_SPINCTRL_UPDATED, - wxCommandEventHandler(wxCalendarCtrl::OnYearChange), - NULL, this); -} - -// ---------------------------------------------------------------------------- -// forward wxWin functions to subcontrols -// ---------------------------------------------------------------------------- - -bool wxCalendarCtrl::Destroy() -{ - if ( m_staticYear ) - m_staticYear->Destroy(); - if ( m_spinYear ) - m_spinYear->Destroy(); - if ( m_comboMonth ) - m_comboMonth->Destroy(); - if ( m_staticMonth ) - m_staticMonth->Destroy(); - - m_staticYear = NULL; - m_spinYear = NULL; - m_comboMonth = NULL; - m_staticMonth = NULL; - - return wxControl::Destroy(); -} - -bool wxCalendarCtrl::Show(bool show) -{ - if ( !wxControl::Show(show) ) - { - return false; - } - - if ( !(GetWindowStyle() & wxCAL_SEQUENTIAL_MONTH_SELECTION) ) - { - if ( GetMonthControl() ) - { - GetMonthControl()->Show(show); - GetYearControl()->Show(show); - } - } - - return true; -} - -bool wxCalendarCtrl::Enable(bool enable) -{ - if ( !wxControl::Enable(enable) ) - { - return false; - } - - if ( !(GetWindowStyle() & wxCAL_SEQUENTIAL_MONTH_SELECTION) ) - { - GetMonthControl()->Enable(enable); - GetYearControl()->Enable(enable); - } - - return true; -} - -// ---------------------------------------------------------------------------- -// enable/disable month/year controls -// ---------------------------------------------------------------------------- - -void wxCalendarCtrl::ShowCurrentControls() -{ - if ( !HasFlag(wxCAL_SEQUENTIAL_MONTH_SELECTION) ) - { - if ( AllowMonthChange() ) - { - m_comboMonth->Show(); - m_staticMonth->Hide(); - - if ( AllowYearChange() ) - { - m_spinYear->Show(); - m_staticYear->Hide(); - - // skip the rest - return; - } - } - else - { - m_comboMonth->Hide(); - m_staticMonth->Show(); - } - - // year change not allowed here - m_spinYear->Hide(); - m_staticYear->Show(); - } - //else: these controls are not even created, don't show/hide them -} - -wxControl *wxCalendarCtrl::GetMonthControl() const -{ - return AllowMonthChange() ? (wxControl *)m_comboMonth : (wxControl *)m_staticMonth; -} - -wxControl *wxCalendarCtrl::GetYearControl() const -{ - return AllowYearChange() ? (wxControl *)m_spinYear : (wxControl *)m_staticYear; -} - -void wxCalendarCtrl::EnableYearChange(bool enable) -{ - if ( enable != AllowYearChange() ) - { - long style = GetWindowStyle(); - if ( enable ) - style &= ~wxCAL_NO_YEAR_CHANGE; - else - style |= wxCAL_NO_YEAR_CHANGE; - SetWindowStyle(style); - - ShowCurrentControls(); - if ( GetWindowStyle() & wxCAL_SEQUENTIAL_MONTH_SELECTION ) - { - Refresh(); - } - } -} - -void wxCalendarCtrl::EnableMonthChange(bool enable) -{ - if ( enable != AllowMonthChange() ) - { - long style = GetWindowStyle(); - if ( enable ) - style &= ~wxCAL_NO_MONTH_CHANGE; - else - style |= wxCAL_NO_MONTH_CHANGE; - SetWindowStyle(style); - - ShowCurrentControls(); - if ( GetWindowStyle() & wxCAL_SEQUENTIAL_MONTH_SELECTION ) - { - Refresh(); - } - } -} - -// ---------------------------------------------------------------------------- -// changing date -// ---------------------------------------------------------------------------- - -bool wxCalendarCtrl::SetDate(const wxDateTime& date) -{ - bool retval = true; - - bool sameMonth = m_date.GetMonth() == date.GetMonth(), - sameYear = m_date.GetYear() == date.GetYear(); - - if ( IsDateInRange(date) ) - { - if ( sameMonth && sameYear ) - { - // just change the day - ChangeDay(date); - } - else - { - if ( AllowMonthChange() && (AllowYearChange() || sameYear) ) - { - // change everything - m_date = date; - - if ( !(GetWindowStyle() & wxCAL_SEQUENTIAL_MONTH_SELECTION) ) - { - // update the controls - m_comboMonth->SetSelection(m_date.GetMonth()); - - if ( AllowYearChange() ) - { - if ( !m_userChangedYear ) - m_spinYear->SetValue(m_date.Format(_T("%Y"))); - } - } - - // as the month changed, holidays did too - SetHolidayAttrs(); - - // update the calendar - Refresh(); - } - else - { - // forbidden - retval = false; - } - } - } - - m_userChangedYear = false; - - return retval; -} - -void wxCalendarCtrl::ChangeDay(const wxDateTime& date) -{ - if ( m_date != date ) - { - // we need to refresh the row containing the old date and the one - // containing the new one - wxDateTime dateOld = m_date; - m_date = date; - - RefreshDate(dateOld); - - // if the date is in the same row, it was already drawn correctly - if ( GetWeek(m_date) != GetWeek(dateOld) ) - { - RefreshDate(m_date); - } - } -} - -void wxCalendarCtrl::SetDateAndNotify(const wxDateTime& date) -{ - wxDateTime::Tm tm1 = m_date.GetTm(), - tm2 = date.GetTm(); - - wxEventType type; - if ( tm1.year != tm2.year ) - type = wxEVT_CALENDAR_YEAR_CHANGED; - else if ( tm1.mon != tm2.mon ) - type = wxEVT_CALENDAR_MONTH_CHANGED; - else if ( tm1.mday != tm2.mday ) - type = wxEVT_CALENDAR_DAY_CHANGED; - else - return; - - if ( SetDate(date) ) - { - GenerateEvents(type, wxEVT_CALENDAR_SEL_CHANGED); - } -} - -// ---------------------------------------------------------------------------- -// date range -// ---------------------------------------------------------------------------- - -bool wxCalendarCtrl::SetLowerDateLimit(const wxDateTime& date /* = wxDefaultDateTime */) -{ - bool retval = true; - - if ( !(date.IsValid()) || ( ( m_highdate.IsValid() ) ? ( date <= m_highdate ) : true ) ) - { - m_lowdate = date; - } - else - { - retval = false; - } - - return retval; -} - -bool wxCalendarCtrl::SetUpperDateLimit(const wxDateTime& date /* = wxDefaultDateTime */) -{ - bool retval = true; - - if ( !(date.IsValid()) || ( ( m_lowdate.IsValid() ) ? ( date >= m_lowdate ) : true ) ) - { - m_highdate = date; - } - else - { - retval = false; - } - - return retval; -} - -bool wxCalendarCtrl::SetDateRange(const wxDateTime& lowerdate /* = wxDefaultDateTime */, const wxDateTime& upperdate /* = wxDefaultDateTime */) -{ - bool retval = true; - - if ( - ( !( lowerdate.IsValid() ) || ( ( upperdate.IsValid() ) ? ( lowerdate <= upperdate ) : true ) ) && - ( !( upperdate.IsValid() ) || ( ( lowerdate.IsValid() ) ? ( upperdate >= lowerdate ) : true ) ) ) - { - m_lowdate = lowerdate; - m_highdate = upperdate; - } - else - { - retval = false; - } - - return retval; -} - -// ---------------------------------------------------------------------------- -// date helpers -// ---------------------------------------------------------------------------- - -wxDateTime wxCalendarCtrl::GetStartDate() const -{ - wxDateTime::Tm tm = m_date.GetTm(); - - wxDateTime date = wxDateTime(1, tm.mon, tm.year); - - // rewind back - date.SetToPrevWeekDay(GetWindowStyle() & wxCAL_MONDAY_FIRST - ? wxDateTime::Mon : wxDateTime::Sun); - - if ( GetWindowStyle() & wxCAL_SHOW_SURROUNDING_WEEKS ) - { - // We want to offset the calendar if we start on the first.. - if ( date.GetDay() == 1 ) - { - date -= wxDateSpan::Week(); - } - } - - return date; -} - -bool wxCalendarCtrl::IsDateShown(const wxDateTime& date) const -{ - if ( !(GetWindowStyle() & wxCAL_SHOW_SURROUNDING_WEEKS) ) - { - return date.GetMonth() == m_date.GetMonth(); - } - else - { - return true; - } -} - -bool wxCalendarCtrl::IsDateInRange(const wxDateTime& date) const -{ - // Check if the given date is in the range specified - return ( ( ( m_lowdate.IsValid() ) ? ( date >= m_lowdate ) : true ) - && ( ( m_highdate.IsValid() ) ? ( date <= m_highdate ) : true ) ); -} - -bool wxCalendarCtrl::ChangeYear(wxDateTime* target) const -{ - bool retval = false; - - if ( !(IsDateInRange(*target)) ) - { - if ( target->GetYear() < m_date.GetYear() ) - { - if ( target->GetYear() >= GetLowerDateLimit().GetYear() ) - { - *target = GetLowerDateLimit(); - retval = true; - } - else - { - *target = m_date; - } - } - else - { - if ( target->GetYear() <= GetUpperDateLimit().GetYear() ) - { - *target = GetUpperDateLimit(); - retval = true; - } - else - { - *target = m_date; - } - } - } - else - { - retval = true; - } - - return retval; -} - -bool wxCalendarCtrl::ChangeMonth(wxDateTime* target) const -{ - bool retval = true; - - if ( !(IsDateInRange(*target)) ) - { - retval = false; - - if ( target->GetMonth() < m_date.GetMonth() ) - { - *target = GetLowerDateLimit(); - } - else - { - *target = GetUpperDateLimit(); - } - } - - return retval; -} - -size_t wxCalendarCtrl::GetWeek(const wxDateTime& date) const -{ - size_t retval = date.GetWeekOfMonth(GetWindowStyle() & wxCAL_MONDAY_FIRST - ? wxDateTime::Monday_First - : wxDateTime::Sunday_First); - - if ( (GetWindowStyle() & wxCAL_SHOW_SURROUNDING_WEEKS) ) - { - // we need to offset an extra week if we "start" on the 1st of the month - wxDateTime::Tm tm = date.GetTm(); - - wxDateTime datetest = wxDateTime(1, tm.mon, tm.year); - - // rewind back - datetest.SetToPrevWeekDay(GetWindowStyle() & wxCAL_MONDAY_FIRST - ? wxDateTime::Mon : wxDateTime::Sun); - - if ( datetest.GetDay() == 1 ) - { - retval += 1; - } - } - - return retval; -} - -// ---------------------------------------------------------------------------- -// size management -// ---------------------------------------------------------------------------- - -// this is a composite control and it must arrange its parts each time its -// size or position changes: the combobox and spinctrl are along the top of -// the available area and the calendar takes up therest of the space - -// the static controls are supposed to be always smaller than combo/spin so we -// always use the latter for size calculations and position the static to take -// the same space - -// the constants used for the layout -#define VERT_MARGIN 5 // distance between combo and calendar -#ifdef __WXMAC__ -#define HORZ_MARGIN 5 // spin -#else -#define HORZ_MARGIN 15 // spin -#endif -wxSize wxCalendarCtrl::DoGetBestSize() const -{ - // calc the size of the calendar - ((wxCalendarCtrl *)this)->RecalcGeometry(); // const_cast - - wxCoord width = 7*m_widthCol, - height = 7*m_heightRow + m_rowOffset + VERT_MARGIN; - - if ( !HasFlag(wxCAL_SEQUENTIAL_MONTH_SELECTION) ) - { - // the combobox doesn't report its height correctly (it returns the - // height including the drop down list) so don't use it - height += m_spinYear->GetBestSize().y; - - - wxCoord w2 = m_comboMonth->GetBestSize().x + HORZ_MARGIN + GetCharWidth()*6; - if (width < w2) - width = w2; - } - - if ( !HasFlag(wxBORDER_NONE) ) - { - // the border would clip the last line otherwise - height += 6; - width += 4; - } - - wxSize best(width, height); - CacheBestSize(best); - return best; -} - -void wxCalendarCtrl::DoSetSize(int x, int y, - int width, int height, - int sizeFlags) -{ - wxControl::DoSetSize(x, y, width, height, sizeFlags); -} - -void wxCalendarCtrl::DoMoveWindow(int x, int y, int width, int height) -{ - int yDiff; - - if ( !HasFlag(wxCAL_SEQUENTIAL_MONTH_SELECTION) && m_staticMonth ) - { - wxSize sizeCombo = m_comboMonth->GetEffectiveMinSize(); - wxSize sizeStatic = m_staticMonth->GetSize(); - wxSize sizeSpin = m_spinYear->GetSize(); - - // wxMSW sometimes reports the wrong combo height, - // so on this platform we'll use the spin control - // height instead. -#ifdef __WXMSW__ - int maxHeight = sizeSpin.y; - int requiredSpinHeight = -1; -#else - int maxHeight = sizeCombo.y; - int requiredSpinHeight = sizeCombo.y; -#endif - int dy = (maxHeight - sizeStatic.y) / 2; - m_comboMonth->Move(x, y); - m_staticMonth->SetSize(x, y + dy, sizeCombo.x, -1, sizeStatic.y); - - int xDiff = sizeCombo.x + HORZ_MARGIN; - - m_spinYear->SetSize(x + xDiff, y, width - xDiff, requiredSpinHeight); - m_staticYear->SetSize(x + xDiff, y + dy, width - xDiff, sizeStatic.y); - - yDiff = wxMax(sizeSpin.y, maxHeight) + VERT_MARGIN; - } - else // no controls on the top - { - yDiff = 0; - } - - wxControl::DoMoveWindow(x, y + yDiff, width, height - yDiff); -} - -void wxCalendarCtrl::DoGetPosition(int *x, int *y) const -{ - wxControl::DoGetPosition(x, y); -#ifndef __WXPM__ - if ( !HasFlag(wxCAL_SEQUENTIAL_MONTH_SELECTION) && GetMonthControl() ) - { - // our real top corner is not in this position - if ( y ) - { - *y -= GetMonthControl()->GetSize().y + VERT_MARGIN; - } - } -#endif -} - -void wxCalendarCtrl::DoGetSize(int *width, int *height) const -{ - wxControl::DoGetSize(width, height); -#ifndef __WXPM__ - if ( !HasFlag(wxCAL_SEQUENTIAL_MONTH_SELECTION) ) - { - // our real height is bigger - if ( height && GetMonthControl()) - { - *height += GetMonthControl()->GetSize().y + VERT_MARGIN; - } - } -#endif -} - -void wxCalendarCtrl::RecalcGeometry() -{ - wxClientDC dc(this); - - dc.SetFont(GetFont()); - - // determine the column width (weekday names are not necessarily wider - // than the numbers (in some languages), so let's not assume that they are) - m_widthCol = 0; - for ( int day = 10; day <= 31; day++) - { - wxCoord width; - dc.GetTextExtent(wxString::Format(wxT("%d"), day), &width, &m_heightRow); - if ( width > m_widthCol ) - { - // 1.5 times the width gives nice margins even if the weekday - // names are short - m_widthCol = width+width/2; - } - } - wxDateTime::WeekDay wd; - for ( wd = wxDateTime::Sun; wd < wxDateTime::Inv_WeekDay; wxNextWDay(wd) ) - { - wxCoord width; - dc.GetTextExtent(m_weekdays[wd], &width, &m_heightRow); - if ( width > m_widthCol ) - { - m_widthCol = width; - } - } - - // leave some margins - m_widthCol += 2; - m_heightRow += 2; - - m_rowOffset = HasFlag(wxCAL_SEQUENTIAL_MONTH_SELECTION) ? m_heightRow : 0; // conditional in relation to style -} - -// ---------------------------------------------------------------------------- -// drawing -// ---------------------------------------------------------------------------- - -void wxCalendarCtrl::OnPaint(wxPaintEvent& WXUNUSED(event)) -{ - wxPaintDC dc(this); - - dc.SetFont(GetFont()); - - RecalcGeometry(); - -#if DEBUG_PAINT - wxLogDebug("--- starting to paint, selection: %s, week %u\n", - m_date.Format("%a %d-%m-%Y %H:%M:%S").c_str(), - GetWeek(m_date)); -#endif - - wxCoord y = 0; - wxCoord x0 = wxMax( (GetSize().x - m_widthCol*7) /2 , 0 ); - - if ( HasFlag(wxCAL_SEQUENTIAL_MONTH_SELECTION) ) - { - // draw the sequential month-selector - - dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); - dc.SetTextForeground(*wxBLACK); - dc.SetBrush(wxBrush(m_colHeaderBg, wxBRUSHSTYLE_SOLID)); - dc.SetPen(wxPen(m_colHeaderBg, 1, wxPENSTYLE_SOLID)); - dc.DrawRectangle(0, y, GetClientSize().x, m_heightRow); - - // Get extent of month-name + year - wxCoord monthw, monthh; - wxString headertext = m_date.Format(wxT("%B %Y")); - dc.GetTextExtent(headertext, &monthw, &monthh); - - // draw month-name centered above weekdays - wxCoord monthx = ((m_widthCol * 7) - monthw) / 2 + x0; - wxCoord monthy = ((m_heightRow - monthh) / 2) + y; - dc.DrawText(headertext, monthx, monthy); - - // calculate the "month-arrows" - wxPoint leftarrow[3]; - wxPoint rightarrow[3]; - - int arrowheight = monthh / 2; - - leftarrow[0] = wxPoint(0, arrowheight / 2); - leftarrow[1] = wxPoint(arrowheight / 2, 0); - leftarrow[2] = wxPoint(arrowheight / 2, arrowheight - 1); - - rightarrow[0] = wxPoint(0,0); - rightarrow[1] = wxPoint(arrowheight / 2, arrowheight / 2); - rightarrow[2] = wxPoint(0, arrowheight - 1); - - // draw the "month-arrows" - - wxCoord arrowy = (m_heightRow - arrowheight) / 2; - wxCoord larrowx = (m_widthCol - (arrowheight / 2)) / 2 + x0; - wxCoord rarrowx = ((m_widthCol - (arrowheight / 2)) / 2) + m_widthCol*6 + x0; - m_leftArrowRect = m_rightArrowRect = wxRect(0,0,0,0); - - if ( AllowMonthChange() ) - { - wxDateTime ldpm = wxDateTime(1,m_date.GetMonth(), m_date.GetYear()) - wxDateSpan::Day(); // last day prev month - // Check if range permits change - if ( IsDateInRange(ldpm) && ( ( ldpm.GetYear() == m_date.GetYear() ) ? true : AllowYearChange() ) ) - { - m_leftArrowRect = wxRect(larrowx - 3, arrowy - 3, (arrowheight / 2) + 8, (arrowheight + 6)); - dc.SetBrush(*wxBLACK_BRUSH); - dc.SetPen(*wxBLACK_PEN); - dc.DrawPolygon(3, leftarrow, larrowx , arrowy, wxWINDING_RULE); - dc.SetBrush(*wxTRANSPARENT_BRUSH); - dc.DrawRectangle(m_leftArrowRect); - } - wxDateTime fdnm = wxDateTime(1,m_date.GetMonth(), m_date.GetYear()) + wxDateSpan::Month(); // first day next month - if ( IsDateInRange(fdnm) && ( ( fdnm.GetYear() == m_date.GetYear() ) ? true : AllowYearChange() ) ) - { - m_rightArrowRect = wxRect(rarrowx - 4, arrowy - 3, (arrowheight / 2) + 8, (arrowheight + 6)); - dc.SetBrush(*wxBLACK_BRUSH); - dc.SetPen(*wxBLACK_PEN); - dc.DrawPolygon(3, rightarrow, rarrowx , arrowy, wxWINDING_RULE); - dc.SetBrush(*wxTRANSPARENT_BRUSH); - dc.DrawRectangle(m_rightArrowRect); - } - } - - y += m_heightRow; - } - - // first draw the week days - if ( IsExposed(x0, y, x0 + 7*m_widthCol, m_heightRow) ) - { -#if DEBUG_PAINT - wxLogDebug("painting the header"); -#endif - - dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); - dc.SetTextForeground(m_colHeaderFg); - dc.SetBrush(wxBrush(m_colHeaderBg, wxBRUSHSTYLE_SOLID)); - dc.SetPen(wxPen(m_colHeaderBg, 1, wxPENSTYLE_SOLID)); - dc.DrawRectangle(0, y, GetClientSize().x, m_heightRow); - - bool startOnMonday = (GetWindowStyle() & wxCAL_MONDAY_FIRST) != 0; - for ( int wd = 0; wd < 7; wd++ ) - { - size_t n; - if ( startOnMonday ) - n = wd == 6 ? 0 : wd + 1; - else - n = wd; - wxCoord dayw, dayh; - dc.GetTextExtent(m_weekdays[n], &dayw, &dayh); - dc.DrawText(m_weekdays[n], x0 + (wd*m_widthCol) + ((m_widthCol- dayw) / 2), y); // center the day-name - } - } - - // then the calendar itself - dc.SetTextForeground(*wxBLACK); - //dc.SetFont(*wxNORMAL_FONT); - - y += m_heightRow; - wxDateTime date = GetStartDate(); - -#if DEBUG_PAINT - wxLogDebug("starting calendar from %s\n", - date.Format("%a %d-%m-%Y %H:%M:%S").c_str()); -#endif - - dc.SetBackgroundMode(wxBRUSHSTYLE_SOLID); - for ( size_t nWeek = 1; nWeek <= 6; nWeek++, y += m_heightRow ) - { - // if the update region doesn't intersect this row, don't paint it - if ( !IsExposed(x0, y, x0 + 7*m_widthCol, m_heightRow - 1) ) - { - date += wxDateSpan::Week(); - - continue; - } - -#if DEBUG_PAINT - wxLogDebug("painting week %d at y = %d\n", nWeek, y); -#endif - - for ( int wd = 0; wd < 7; wd++ ) - { - dc.SetTextBackground(m_colBackground); - if ( IsDateShown(date) ) - { - // don't use wxDate::Format() which prepends 0s - unsigned int day = date.GetDay(); - wxString dayStr = wxString::Format(_T("%u"), day); - wxCoord width; - dc.GetTextExtent(dayStr, &width, (wxCoord *)NULL); - - bool changedColours = false, - changedFont = false; - - bool isSel = false; - wxCalendarDateAttr *attr = NULL; - - if ( date.GetMonth() != m_date.GetMonth() || !IsDateInRange(date) ) - { - // surrounding week or out-of-range - // draw "disabled" - dc.SetTextForeground(m_colSorrounding); - changedColours = true; - } - else - { - isSel = date.IsSameDate(m_date); - attr = m_attrs[day - 1]; - - if ( isSel ) - { - dc.SetTextForeground(m_colHighlightFg); - dc.SetTextBackground(m_colHighlightBg); - - changedColours = true; - } - else if ( attr ) - { - wxColour colFg, colBg; - - if ( attr->IsHoliday() ) - { - colFg = m_colHolidayFg; - colBg = m_colHolidayBg; - } - else - { - colFg = attr->GetTextColour(); - colBg = attr->GetBackgroundColour(); - } - - if ( colFg.Ok() ) - { - dc.SetTextForeground(colFg); - changedColours = true; - } - - if ( colBg.Ok() ) - { - dc.SetTextBackground(colBg); - changedColours = true; - } - - if ( attr->HasFont() ) - { - dc.SetFont(attr->GetFont()); - changedFont = true; - } - } - } - - wxCoord x = wd*m_widthCol + (m_widthCol - width) / 2 + x0; - dc.DrawText(dayStr, x, y + 1); - - if ( !isSel && attr && attr->HasBorder() ) - { - wxColour colBorder; - if ( attr->HasBorderColour() ) - { - colBorder = attr->GetBorderColour(); - } - else - { - colBorder = GetForegroundColour(); - } - - wxPen pen(colBorder, 1, wxPENSTYLE_SOLID); - dc.SetPen(pen); - dc.SetBrush(*wxTRANSPARENT_BRUSH); - - switch ( attr->GetBorder() ) - { - case wxCAL_BORDER_SQUARE: - dc.DrawRectangle(x - 2, y, - width + 4, m_heightRow); - break; - - case wxCAL_BORDER_ROUND: - dc.DrawEllipse(x - 2, y, - width + 4, m_heightRow); - break; - - default: - wxFAIL_MSG(_T("unknown border type")); - } - } - - if ( changedColours ) - { - dc.SetTextForeground(GetForegroundColour()); - dc.SetTextBackground(GetBackgroundColour()); - } - - if ( changedFont ) - { - dc.SetFont(GetFont()); - } - } - //else: just don't draw it - - date += wxDateSpan::Day(); - } - } - - // Greying out out-of-range background - bool showSurrounding = (GetWindowStyle() & wxCAL_SHOW_SURROUNDING_WEEKS) != 0; - - date = ( showSurrounding ) ? GetStartDate() : wxDateTime(1, m_date.GetMonth(), m_date.GetYear()); - if ( !IsDateInRange(date) ) - { - wxDateTime firstOOR = GetLowerDateLimit() - wxDateSpan::Day(); // first out-of-range - - wxBrush oorbrush = *wxLIGHT_GREY_BRUSH; - oorbrush.SetStyle(wxBRUSHSTYLE_FDIAGONAL_HATCH); - - HighlightRange(&dc, date, firstOOR, wxTRANSPARENT_PEN, &oorbrush); - } - - date = ( showSurrounding ) ? GetStartDate() + wxDateSpan::Weeks(6) - wxDateSpan::Day() : wxDateTime().SetToLastMonthDay(m_date.GetMonth(), m_date.GetYear()); - if ( !IsDateInRange(date) ) - { - wxDateTime firstOOR = GetUpperDateLimit() + wxDateSpan::Day(); // first out-of-range - - wxBrush oorbrush = *wxLIGHT_GREY_BRUSH; - oorbrush.SetStyle(wxBRUSHSTYLE_FDIAGONAL_HATCH); - - HighlightRange(&dc, firstOOR, date, wxTRANSPARENT_PEN, &oorbrush); - } - -#if DEBUG_PAINT - wxLogDebug("+++ finished painting"); -#endif -} - -void wxCalendarCtrl::RefreshDate(const wxDateTime& date) -{ - RecalcGeometry(); - - wxRect rect; - - // always refresh the whole row at once because our OnPaint() will draw - // the whole row anyhow - and this allows the small optimisation in - // OnClick() below to work - rect.x = wxMax( (GetSize().x - m_widthCol*7) /2 , 0 ); - - rect.y = (m_heightRow * GetWeek(date)) + m_rowOffset; - - rect.width = 7*m_widthCol; - rect.height = m_heightRow; - -#ifdef __WXMSW__ - // VZ: for some reason, the selected date seems to occupy more space under - // MSW - this is probably some bug in the font size calculations, but I - // don't know where exactly. This fix is ugly and leads to more - // refreshes than really needed, but without it the selected days - // leaves even more ugly underscores on screen. - rect.Inflate(0, 1); -#endif // MSW - -#if DEBUG_PAINT - wxLogDebug("*** refreshing week %d at (%d, %d)-(%d, %d)\n", - GetWeek(date), - rect.x, rect.y, - rect.x + rect.width, rect.y + rect.height); -#endif - - Refresh(true, &rect); -} - -void wxCalendarCtrl::HighlightRange(wxPaintDC* pDC, const wxDateTime& fromdate, const wxDateTime& todate, const wxPen* pPen, const wxBrush* pBrush) -{ - // Highlights the given range using pen and brush - // Does nothing if todate < fromdate - - -#if DEBUG_PAINT - wxLogDebug("+++ HighlightRange: (%s) - (%s) +++", fromdate.Format("%d %m %Y"), todate.Format("%d %m %Y")); -#endif - - if ( todate >= fromdate ) - { - // do stuff - // date-coordinates - int fd, fw; - int td, tw; - - // implicit: both dates must be currently shown - checked by GetDateCoord - if ( GetDateCoord(fromdate, &fd, &fw) && GetDateCoord(todate, &td, &tw) ) - { -#if DEBUG_PAINT - wxLogDebug("Highlight range: (%i, %i) - (%i, %i)", fd, fw, td, tw); -#endif - if ( ( (tw - fw) == 1 ) && ( td < fd ) ) - { - // special case: interval 7 days or less not in same week - // split in two separate intervals - wxDateTime tfd = fromdate + wxDateSpan::Days(7-fd); - wxDateTime ftd = tfd + wxDateSpan::Day(); -#if DEBUG_PAINT - wxLogDebug("Highlight: Separate segments"); -#endif - // draw separately - HighlightRange(pDC, fromdate, tfd, pPen, pBrush); - HighlightRange(pDC, ftd, todate, pPen, pBrush); - } - else - { - int numpoints; - wxPoint corners[8]; // potentially 8 corners in polygon - wxCoord x0 = wxMax( (GetSize().x - m_widthCol*7) /2 , 0 ); - - if ( fw == tw ) - { - // simple case: same week - numpoints = 4; - corners[0] = wxPoint(x0 + (fd - 1) * m_widthCol, (fw * m_heightRow) + m_rowOffset); - corners[1] = wxPoint(x0 + (fd - 1) * m_widthCol, ((fw + 1 ) * m_heightRow) + m_rowOffset); - corners[2] = wxPoint(x0 + td * m_widthCol, ((tw + 1) * m_heightRow) + m_rowOffset); - corners[3] = wxPoint(x0 + td * m_widthCol, (tw * m_heightRow) + m_rowOffset); - } - else - { - int cidx = 0; - // "complex" polygon - corners[cidx] = wxPoint(x0 + (fd - 1) * m_widthCol, (fw * m_heightRow) + m_rowOffset); cidx++; - - if ( fd > 1 ) - { - corners[cidx] = wxPoint(x0 + (fd - 1) * m_widthCol, ((fw + 1) * m_heightRow) + m_rowOffset); cidx++; - corners[cidx] = wxPoint(x0, ((fw + 1) * m_heightRow) + m_rowOffset); cidx++; - } - - corners[cidx] = wxPoint(x0, ((tw + 1) * m_heightRow) + m_rowOffset); cidx++; - corners[cidx] = wxPoint(x0 + td * m_widthCol, ((tw + 1) * m_heightRow) + m_rowOffset); cidx++; - - if ( td < 7 ) - { - corners[cidx] = wxPoint(x0 + td * m_widthCol, (tw * m_heightRow) + m_rowOffset); cidx++; - corners[cidx] = wxPoint(x0 + 7 * m_widthCol, (tw * m_heightRow) + m_rowOffset); cidx++; - } - - corners[cidx] = wxPoint(x0 + 7 * m_widthCol, (fw * m_heightRow) + m_rowOffset); cidx++; - - numpoints = cidx; - } - - // draw the polygon - pDC->SetBrush(*pBrush); - pDC->SetPen(*pPen); - pDC->DrawPolygon(numpoints, corners); - } - } - } - // else do nothing -#if DEBUG_PAINT - wxLogDebug("--- HighlightRange ---"); -#endif -} - -bool wxCalendarCtrl::GetDateCoord(const wxDateTime& date, int *day, int *week) const -{ - bool retval = true; - -#if DEBUG_PAINT - wxLogDebug("+++ GetDateCoord: (%s) +++", date.Format("%d %m %Y")); -#endif - - if ( IsDateShown(date) ) - { - bool startOnMonday = ( GetWindowStyle() & wxCAL_MONDAY_FIRST ) != 0; - - // Find day - *day = date.GetWeekDay(); - - if ( *day == 0 ) // sunday - { - *day = ( startOnMonday ) ? 7 : 1; - } - else - { - *day += ( startOnMonday ) ? 0 : 1; - } - - int targetmonth = date.GetMonth() + (12 * date.GetYear()); - int thismonth = m_date.GetMonth() + (12 * m_date.GetYear()); - - // Find week - if ( targetmonth == thismonth ) - { - *week = GetWeek(date); - } - else - { - if ( targetmonth < thismonth ) - { - *week = 1; // trivial - } - else // targetmonth > thismonth - { - wxDateTime ldcm; - int lastweek; - int lastday; - - // get the datecoord of the last day in the month currently shown -#if DEBUG_PAINT - wxLogDebug(" +++ LDOM +++"); -#endif - GetDateCoord(ldcm.SetToLastMonthDay(m_date.GetMonth(), m_date.GetYear()), &lastday, &lastweek); -#if DEBUG_PAINT - wxLogDebug(" --- LDOM ---"); -#endif - - wxTimeSpan span = date - ldcm; - - int daysfromlast = span.GetDays(); -#if DEBUG_PAINT - wxLogDebug("daysfromlast: %i", daysfromlast); -#endif - if ( daysfromlast + lastday > 7 ) // past week boundary - { - int wholeweeks = (daysfromlast / 7); - *week = wholeweeks + lastweek; - if ( (daysfromlast - (7 * wholeweeks) + lastday) > 7 ) - { - *week += 1; - } - } - else - { - *week = lastweek; - } - } - } - } - else - { - *day = -1; - *week = -1; - retval = false; - } - -#if DEBUG_PAINT - wxLogDebug("--- GetDateCoord: (%s) = (%i, %i) ---", date.Format("%d %m %Y"), *day, *week); -#endif - - return retval; -} - -// ---------------------------------------------------------------------------- -// mouse handling -// ---------------------------------------------------------------------------- - -void wxCalendarCtrl::OnDClick(wxMouseEvent& event) -{ - if ( HitTest(event.GetPosition()) != wxCAL_HITTEST_DAY ) - { - event.Skip(); - } - else - { - GenerateEvent(wxEVT_CALENDAR_DOUBLECLICKED); - } -} - -void wxCalendarCtrl::OnClick(wxMouseEvent& event) -{ - wxDateTime date; - wxDateTime::WeekDay wday; - switch ( HitTest(event.GetPosition(), &date, &wday) ) - { - case wxCAL_HITTEST_DAY: - if ( IsDateInRange(date) ) - { - ChangeDay(date); - - GenerateEvents(wxEVT_CALENDAR_DAY_CHANGED, - wxEVT_CALENDAR_SEL_CHANGED); - } - break; - - case wxCAL_HITTEST_HEADER: - { - wxCalendarEvent eventWd(this, wxEVT_CALENDAR_WEEKDAY_CLICKED); - eventWd.m_wday = wday; - (void)GetEventHandler()->ProcessEvent(eventWd); - } - break; - - case wxCAL_HITTEST_DECMONTH: - case wxCAL_HITTEST_INCMONTH: - case wxCAL_HITTEST_SURROUNDING_WEEK: - SetDateAndNotify(date); // we probably only want to refresh the control. No notification.. (maybe as an option?) - break; - - default: - wxFAIL_MSG(_T("unknown hittest code")); - // fall through - - case wxCAL_HITTEST_NOWHERE: - event.Skip(); - break; - } -} - -wxCalendarHitTestResult wxCalendarCtrl::HitTest(const wxPoint& pos, - wxDateTime *date, - wxDateTime::WeekDay *wd) -{ - RecalcGeometry(); - - // the position where the calendar really begins - wxCoord x0 = wxMax((GetSize().x - m_widthCol*7)/2, 0); - - if ( HasFlag(wxCAL_SEQUENTIAL_MONTH_SELECTION) ) - { - // Header: month - - // we need to find out if the hit is on left arrow, on month or on right arrow - // left arrow? - if ( m_leftArrowRect.Contains(pos) ) - { - if ( date ) - { - if ( IsDateInRange(m_date - wxDateSpan::Month()) ) - { - *date = m_date - wxDateSpan::Month(); - } - else - { - *date = GetLowerDateLimit(); - } - } - - return wxCAL_HITTEST_DECMONTH; - } - - if ( m_rightArrowRect.Contains(pos) ) - { - if ( date ) - { - if ( IsDateInRange(m_date + wxDateSpan::Month()) ) - { - *date = m_date + wxDateSpan::Month(); - } - else - { - *date = GetUpperDateLimit(); - } - } - - return wxCAL_HITTEST_INCMONTH; - } - - } - - // header: week days - int wday = (pos.x - x0) / m_widthCol; - if ( pos.y < (m_heightRow + m_rowOffset) ) - { - if ( pos.y > m_rowOffset ) - { - if ( wd ) - { - if ( GetWindowStyle() & wxCAL_MONDAY_FIRST ) - { - wday = wday == 6 ? 0 : wday + 1; - } - - *wd = (wxDateTime::WeekDay)wday; - } - - return wxCAL_HITTEST_HEADER; - } - else - { - return wxCAL_HITTEST_NOWHERE; - } - } - - int week = (pos.y - (m_heightRow + m_rowOffset)) / m_heightRow; - if ( week >= 6 || wday >= 7 ) - { - return wxCAL_HITTEST_NOWHERE; - } - - wxDateTime dt = GetStartDate() + wxDateSpan::Days(7*week + wday); - - if ( IsDateShown(dt) ) - { - if ( date ) - *date = dt; - - if ( dt.GetMonth() == m_date.GetMonth() ) - { - - return wxCAL_HITTEST_DAY; - } - else - { - return wxCAL_HITTEST_SURROUNDING_WEEK; - } - } - else - { - return wxCAL_HITTEST_NOWHERE; - } -} - -// ---------------------------------------------------------------------------- -// subcontrols events handling -// ---------------------------------------------------------------------------- - -void wxCalendarCtrl::OnMonthChange(wxCommandEvent& event) -{ - wxDateTime::Tm tm = m_date.GetTm(); - - wxDateTime::Month mon = (wxDateTime::Month)event.GetInt(); - if ( tm.mday > wxDateTime::GetNumberOfDays(mon, tm.year) ) - { - tm.mday = wxDateTime::GetNumberOfDays(mon, tm.year); - } - - wxDateTime target = wxDateTime(tm.mday, mon, tm.year); - - ChangeMonth(&target); - SetDateAndNotify(target); -} - -void wxCalendarCtrl::OnYearChange(wxCommandEvent& event) -{ - int year = (int)event.GetInt(); - if ( year == INT_MIN ) - { - // invalid year in the spin control, ignore it - return; - } - - wxDateTime::Tm tm = m_date.GetTm(); - - if ( tm.mday > wxDateTime::GetNumberOfDays(tm.mon, year) ) - { - tm.mday = wxDateTime::GetNumberOfDays(tm.mon, year); - } - - wxDateTime target = wxDateTime(tm.mday, tm.mon, year); - - if ( ChangeYear(&target) ) - { - SetDateAndNotify(target); - } - else - { - // In this case we don't want to change the date. That would put us - // inside the same year but a strange number of months forward/back.. - m_spinYear->SetValue(target.GetYear()); - } -} - -void wxCalendarCtrl::OnYearTextChange(wxCommandEvent& event) -{ - SetUserChangedYear(); - OnYearChange(event); -} - -// Responds to colour changes, and passes event on to children. -void wxCalendarCtrl::OnSysColourChanged(wxSysColourChangedEvent& event) -{ - // reinit colours - InitColours(); - - // Propagate the event to the children - wxControl::OnSysColourChanged(event); - - // Redraw control area - SetBackgroundColour(m_colBackground); - Refresh(); -} - -// ---------------------------------------------------------------------------- -// keyboard interface -// ---------------------------------------------------------------------------- - -void wxCalendarCtrl::OnChar(wxKeyEvent& event) -{ - wxDateTime target; - switch ( event.GetKeyCode() ) - { - case _T('+'): - case WXK_ADD: - target = m_date + wxDateSpan::Year(); - if ( ChangeYear(&target) ) - { - SetDateAndNotify(target); - } - break; - - case _T('-'): - case WXK_SUBTRACT: - target = m_date - wxDateSpan::Year(); - if ( ChangeYear(&target) ) - { - SetDateAndNotify(target); - } - break; - - case WXK_PAGEUP: - target = m_date - wxDateSpan::Month(); - ChangeMonth(&target); - SetDateAndNotify(target); // always - break; - - case WXK_PAGEDOWN: - target = m_date + wxDateSpan::Month(); - ChangeMonth(&target); - SetDateAndNotify(target); // always - break; - - case WXK_RIGHT: - if ( event.ControlDown() ) - { - target = wxDateTime(m_date).SetToNextWeekDay( - GetWindowStyle() & wxCAL_MONDAY_FIRST - ? wxDateTime::Sun : wxDateTime::Sat); - if ( !IsDateInRange(target) ) - { - target = GetUpperDateLimit(); - } - SetDateAndNotify(target); - } - else - SetDateAndNotify(m_date + wxDateSpan::Day()); - break; - - case WXK_LEFT: - if ( event.ControlDown() ) - { - target = wxDateTime(m_date).SetToPrevWeekDay( - GetWindowStyle() & wxCAL_MONDAY_FIRST - ? wxDateTime::Mon : wxDateTime::Sun); - if ( !IsDateInRange(target) ) - { - target = GetLowerDateLimit(); - } - SetDateAndNotify(target); - } - else - SetDateAndNotify(m_date - wxDateSpan::Day()); - break; - - case WXK_UP: - SetDateAndNotify(m_date - wxDateSpan::Week()); - break; - - case WXK_DOWN: - SetDateAndNotify(m_date + wxDateSpan::Week()); - break; - - case WXK_HOME: - if ( event.ControlDown() ) - SetDateAndNotify(wxDateTime::Today()); - else - SetDateAndNotify(wxDateTime(1, m_date.GetMonth(), m_date.GetYear())); - break; - - case WXK_END: - SetDateAndNotify(wxDateTime(m_date).SetToLastMonthDay()); - break; - - case WXK_RETURN: - GenerateEvent(wxEVT_CALENDAR_DOUBLECLICKED); - break; - - default: - event.Skip(); - } -} - -// ---------------------------------------------------------------------------- -// holidays handling -// ---------------------------------------------------------------------------- - -void wxCalendarCtrl::EnableHolidayDisplay(bool display) -{ - long style = GetWindowStyle(); - if ( display ) - style |= wxCAL_SHOW_HOLIDAYS; - else - style &= ~wxCAL_SHOW_HOLIDAYS; - - SetWindowStyle(style); - - if ( display ) - SetHolidayAttrs(); - else - ResetHolidayAttrs(); - - Refresh(); -} - -void wxCalendarCtrl::SetHolidayAttrs() -{ - if ( GetWindowStyle() & wxCAL_SHOW_HOLIDAYS ) - { - ResetHolidayAttrs(); - - wxDateTime::Tm tm = m_date.GetTm(); - wxDateTime dtStart(1, tm.mon, tm.year), - dtEnd = dtStart.GetLastMonthDay(); - - wxDateTimeArray hol; - wxDateTimeHolidayAuthority::GetHolidaysInRange(dtStart, dtEnd, hol); - - size_t count = hol.GetCount(); - for ( size_t n = 0; n < count; n++ ) - { - SetHoliday(hol[n].GetDay()); - } - } -} - -void wxCalendarCtrl::SetHoliday(size_t day) -{ - wxCHECK_RET( day > 0 && day < 32, _T("invalid day in SetHoliday") ); - - wxCalendarDateAttr *attr = GetAttr(day); - if ( !attr ) - { - attr = new wxCalendarDateAttr; - } - - attr->SetHoliday(true); - - // can't use SetAttr() because it would delete this pointer - m_attrs[day - 1] = attr; -} - -void wxCalendarCtrl::ResetHolidayAttrs() -{ - for ( size_t day = 0; day < 31; day++ ) - { - if ( m_attrs[day] ) - { - m_attrs[day]->SetHoliday(false); - } - } -} - - -//static -wxVisualAttributes -wxCalendarCtrl::GetClassDefaultAttributes(wxWindowVariant variant) -{ - // Use the same color scheme as wxListBox - return wxListBox::GetClassDefaultAttributes(variant); -} - -#endif // wxUSE_CALENDARCTRL diff --git a/src/generic/calctrlg.cpp b/src/generic/calctrlg.cpp new file mode 100644 index 0000000000..9ac23cf05a --- /dev/null +++ b/src/generic/calctrlg.cpp @@ -0,0 +1,1875 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: src/generic/calctrlg.cpp +// Purpose: implementation of the wxGenericCalendarCtrl +// Author: Vadim Zeitlin +// Modified by: +// Created: 29.12.99 +// RCS-ID: $Id$ +// Copyright: (c) 1999 Vadim Zeitlin +// Licence: wxWindows licence +/////////////////////////////////////////////////////////////////////////////// + +// ============================================================================ +// declarations +// ============================================================================ + +// ---------------------------------------------------------------------------- +// headers +// ---------------------------------------------------------------------------- + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#ifndef WX_PRECOMP + #include "wx/dcclient.h" + #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 + + +#if wxUSE_CALENDARCTRL + +#include "wx/spinctrl.h" +#include "wx/calctrl.h" +#include "wx/generic/calctrlg.h" + +#define DEBUG_PAINT 0 + +// ---------------------------------------------------------------------------- +// wxWin macros +// ---------------------------------------------------------------------------- + +BEGIN_EVENT_TABLE(wxGenericCalendarCtrl, wxControl) + EVT_PAINT(wxGenericCalendarCtrl::OnPaint) + + EVT_CHAR(wxGenericCalendarCtrl::OnChar) + + EVT_LEFT_DOWN(wxGenericCalendarCtrl::OnClick) + EVT_LEFT_DCLICK(wxGenericCalendarCtrl::OnDClick) + + EVT_SYS_COLOUR_CHANGED(wxGenericCalendarCtrl::OnSysColourChanged) +END_EVENT_TABLE() + +#if wxUSE_EXTENDED_RTTI +WX_DEFINE_FLAGS( wxCalendarCtrlStyle ) + +wxBEGIN_FLAGS( wxCalendarCtrlStyle ) + // new style border flags, we put them first to + // use them for streaming out + wxFLAGS_MEMBER(wxBORDER_SIMPLE) + wxFLAGS_MEMBER(wxBORDER_SUNKEN) + wxFLAGS_MEMBER(wxBORDER_DOUBLE) + wxFLAGS_MEMBER(wxBORDER_RAISED) + wxFLAGS_MEMBER(wxBORDER_STATIC) + wxFLAGS_MEMBER(wxBORDER_NONE) + + // old style border flags + wxFLAGS_MEMBER(wxSIMPLE_BORDER) + wxFLAGS_MEMBER(wxSUNKEN_BORDER) + wxFLAGS_MEMBER(wxDOUBLE_BORDER) + wxFLAGS_MEMBER(wxRAISED_BORDER) + wxFLAGS_MEMBER(wxSTATIC_BORDER) + wxFLAGS_MEMBER(wxBORDER) + + // standard window styles + wxFLAGS_MEMBER(wxTAB_TRAVERSAL) + wxFLAGS_MEMBER(wxCLIP_CHILDREN) + wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW) + wxFLAGS_MEMBER(wxWANTS_CHARS) + wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE) + wxFLAGS_MEMBER(wxALWAYS_SHOW_SB ) + wxFLAGS_MEMBER(wxVSCROLL) + wxFLAGS_MEMBER(wxHSCROLL) + + wxFLAGS_MEMBER(wxCAL_SUNDAY_FIRST) + wxFLAGS_MEMBER(wxCAL_MONDAY_FIRST) + wxFLAGS_MEMBER(wxCAL_SHOW_HOLIDAYS) + wxFLAGS_MEMBER(wxCAL_NO_YEAR_CHANGE) + wxFLAGS_MEMBER(wxCAL_NO_MONTH_CHANGE) + wxFLAGS_MEMBER(wxCAL_SEQUENTIAL_MONTH_SELECTION) + wxFLAGS_MEMBER(wxCAL_SHOW_SURROUNDING_WEEKS) + +wxEND_FLAGS( wxCalendarCtrlStyle ) + +IMPLEMENT_DYNAMIC_CLASS_XTI(wxGenericCalendarCtrl, wxControl,"wx/calctrl.h") + +wxBEGIN_PROPERTIES_TABLE(wxGenericCalendarCtrl) + wxEVENT_RANGE_PROPERTY( Updated , wxEVT_CALENDAR_SEL_CHANGED , wxEVT_CALENDAR_WEEKDAY_CLICKED , wxCalendarEvent ) + wxHIDE_PROPERTY( Children ) + wxPROPERTY( Date,wxDateTime, SetDate , GetDate, , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) + wxPROPERTY_FLAGS( WindowStyle , wxCalendarCtrlStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style +wxEND_PROPERTIES_TABLE() + +wxBEGIN_HANDLERS_TABLE(wxGenericCalendarCtrl) +wxEND_HANDLERS_TABLE() + +wxCONSTRUCTOR_6( wxGenericCalendarCtrl , wxWindow* , Parent , wxWindowID , Id , wxDateTime , Date , wxPoint , Position , wxSize , Size , long , WindowStyle ) +#else +IMPLEMENT_DYNAMIC_CLASS(wxGenericCalendarCtrl, wxControl) +#endif + +// ============================================================================ +// implementation +// ============================================================================ + +// ---------------------------------------------------------------------------- +// helper functions +// ---------------------------------------------------------------------------- + +namespace +{ + +// add attributes that are set in attr +void AddAttr(wxCalendarDateAttr *self, const wxCalendarDateAttr& attr) +{ + if (attr.HasTextColour()) + self->SetTextColour(attr.GetTextColour()); + if (attr.HasBackgroundColour()) + self->SetBackgroundColour(attr.GetBackgroundColour()); + if (attr.HasBorderColour()) + self->SetBorderColour(attr.GetBorderColour()); + if (attr.HasFont()) + self->SetFont(attr.GetFont()); + if (attr.HasBorder()) + self->SetBorder(attr.GetBorder()); + if (attr.IsHoliday()) + self->SetHoliday(true); +} + +// remove attributes that are set in attr +void DelAttr(wxCalendarDateAttr *self, const wxCalendarDateAttr &attr) +{ + if (attr.HasTextColour()) + self->SetTextColour(wxNullColour); + if (attr.HasBackgroundColour()) + self->SetBackgroundColour(wxNullColour); + if (attr.HasBorderColour()) + self->SetBorderColour(wxNullColour); + if (attr.HasFont()) + self->SetFont(wxNullFont); + if (attr.HasBorder()) + self->SetBorder(wxCAL_BORDER_NONE); + if (attr.IsHoliday()) + self->SetHoliday(false); +} + +} // anonymous namespace + +// ---------------------------------------------------------------------------- +// wxGenericCalendarCtrl +// ---------------------------------------------------------------------------- + +wxGenericCalendarCtrl::wxGenericCalendarCtrl(wxWindow *parent, + wxWindowID id, + const wxDateTime& date, + const wxPoint& pos, + const wxSize& size, + long style, + const wxString& name) +{ + Init(); + + (void)Create(parent, id, date, pos, size, style, name); +} + +void wxGenericCalendarCtrl::Init() +{ + m_comboMonth = NULL; + m_spinYear = NULL; + m_staticYear = NULL; + m_staticMonth = NULL; + + m_userChangedYear = false; + + m_widthCol = + m_heightRow = 0; + + wxDateTime::WeekDay wd; + for ( wd = wxDateTime::Sun; wd < wxDateTime::Inv_WeekDay; wxNextWDay(wd) ) + { + m_weekdays[wd] = wxDateTime::GetWeekDayName(wd, wxDateTime::Name_Abbr); + } + + for ( size_t n = 0; n < WXSIZEOF(m_attrs); n++ ) + { + m_attrs[n] = NULL; + } + + InitColours(); +} + +void wxGenericCalendarCtrl::InitColours() +{ + m_colHighlightFg = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT); + m_colHighlightBg = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT); + m_colBackground = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW); + m_colSorrounding = wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT); + + m_colHolidayFg = *wxRED; + // don't set m_colHolidayBg - by default, same as our bg colour + + m_colHeaderFg = *wxBLUE; + m_colHeaderBg = *wxLIGHT_GREY; +} + +bool wxGenericCalendarCtrl::Create(wxWindow *parent, + wxWindowID id, + const wxDateTime& date, + const wxPoint& pos, + const wxSize& size, + long style, + const wxString& name) +{ + if ( !wxControl::Create(parent, id, pos, size, + style | wxCLIP_CHILDREN | wxWANTS_CHARS | wxFULL_REPAINT_ON_RESIZE, + wxDefaultValidator, name) ) + { + return false; + } + + // needed to get the arrow keys normally used for the dialog navigation + SetWindowStyle(style | wxWANTS_CHARS); + + m_date = date.IsValid() ? date : wxDateTime::Today(); + + m_lowdate = wxDefaultDateTime; + m_highdate = wxDefaultDateTime; + + if ( !HasFlag(wxCAL_SEQUENTIAL_MONTH_SELECTION) ) + { + CreateYearSpinCtrl(); + m_staticYear = new wxStaticText(GetParent(), wxID_ANY, m_date.Format(_T("%Y")), + wxDefaultPosition, wxDefaultSize, + wxALIGN_CENTRE); + + CreateMonthComboBox(); + m_staticMonth = new wxStaticText(GetParent(), wxID_ANY, m_date.Format(_T("%B")), + wxDefaultPosition, wxDefaultSize, + wxALIGN_CENTRE); + } + + ShowCurrentControls(); + + // 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 + SetInitialSize(size); + SetPosition(pos); + + // Since we don't paint the whole background make sure that the platform + // will use the right one. + SetBackgroundColour(m_colBackground); + + SetHolidayAttrs(); + + return true; +} + +wxGenericCalendarCtrl::~wxGenericCalendarCtrl() +{ + for ( size_t n = 0; n < WXSIZEOF(m_attrs); n++ ) + { + delete m_attrs[n]; + } + + if ( !HasFlag(wxCAL_SEQUENTIAL_MONTH_SELECTION) ) + { + delete m_comboMonth; + delete m_staticMonth; + delete m_spinYear; + delete m_staticYear; + } +} + +void wxGenericCalendarCtrl::SetWindowStyleFlag(long style) +{ + // changing this style doesn't work because the controls are not + // created/shown/hidden accordingly + wxASSERT_MSG( (style & wxCAL_SEQUENTIAL_MONTH_SELECTION) == + (m_windowStyle & wxCAL_SEQUENTIAL_MONTH_SELECTION), + _T("wxCAL_SEQUENTIAL_MONTH_SELECTION can't be changed after creation") ); + + wxControl::SetWindowStyleFlag(style); +} + +// ---------------------------------------------------------------------------- +// Create the wxComboBox and wxSpinCtrl +// ---------------------------------------------------------------------------- + +void wxGenericCalendarCtrl::CreateMonthComboBox() +{ + m_comboMonth = new wxComboBox(GetParent(), wxID_ANY, + wxEmptyString, + wxDefaultPosition, + wxDefaultSize, + 0, NULL, + wxCB_READONLY | wxCLIP_SIBLINGS); + + wxDateTime::Month m; + for ( m = wxDateTime::Jan; m < wxDateTime::Inv_Month; wxNextMonth(m) ) + { + m_comboMonth->Append(wxDateTime::GetMonthName(m)); + } + + m_comboMonth->SetSelection(GetDate().GetMonth()); + m_comboMonth->SetSize(wxDefaultCoord, + wxDefaultCoord, + wxDefaultCoord, + wxDefaultCoord, + wxSIZE_AUTO_WIDTH|wxSIZE_AUTO_HEIGHT); + + m_comboMonth->Connect(m_comboMonth->GetId(), wxEVT_COMMAND_COMBOBOX_SELECTED, + wxCommandEventHandler(wxGenericCalendarCtrl::OnMonthChange), + NULL, this); +} + +void wxGenericCalendarCtrl::CreateYearSpinCtrl() +{ + m_spinYear = new wxSpinCtrl(GetParent(), wxID_ANY, + GetDate().Format(_T("%Y")), + wxDefaultPosition, + wxDefaultSize, + wxSP_ARROW_KEYS | wxCLIP_SIBLINGS, + -4300, 10000, GetDate().GetYear()); + + m_spinYear->Connect(m_spinYear->GetId(), wxEVT_COMMAND_TEXT_UPDATED, + wxCommandEventHandler(wxGenericCalendarCtrl::OnYearTextChange), + NULL, this); + + m_spinYear->Connect(m_spinYear->GetId(), wxEVT_COMMAND_SPINCTRL_UPDATED, + wxCommandEventHandler(wxGenericCalendarCtrl::OnYearChange), + NULL, this); +} + +// ---------------------------------------------------------------------------- +// forward wxWin functions to subcontrols +// ---------------------------------------------------------------------------- + +bool wxGenericCalendarCtrl::Destroy() +{ + if ( m_staticYear ) + m_staticYear->Destroy(); + if ( m_spinYear ) + m_spinYear->Destroy(); + if ( m_comboMonth ) + m_comboMonth->Destroy(); + if ( m_staticMonth ) + m_staticMonth->Destroy(); + + m_staticYear = NULL; + m_spinYear = NULL; + m_comboMonth = NULL; + m_staticMonth = NULL; + + return wxControl::Destroy(); +} + +bool wxGenericCalendarCtrl::Show(bool show) +{ + if ( !wxControl::Show(show) ) + { + return false; + } + + if ( !(GetWindowStyle() & wxCAL_SEQUENTIAL_MONTH_SELECTION) ) + { + if ( GetMonthControl() ) + { + GetMonthControl()->Show(show); + GetYearControl()->Show(show); + } + } + + return true; +} + +bool wxGenericCalendarCtrl::Enable(bool enable) +{ + if ( !wxControl::Enable(enable) ) + { + return false; + } + + if ( !(GetWindowStyle() & wxCAL_SEQUENTIAL_MONTH_SELECTION) ) + { + GetMonthControl()->Enable(enable); + GetYearControl()->Enable(enable); + } + + return true; +} + +// ---------------------------------------------------------------------------- +// enable/disable month/year controls +// ---------------------------------------------------------------------------- + +void wxGenericCalendarCtrl::ShowCurrentControls() +{ + if ( !HasFlag(wxCAL_SEQUENTIAL_MONTH_SELECTION) ) + { + if ( AllowMonthChange() ) + { + m_comboMonth->Show(); + m_staticMonth->Hide(); + + if ( AllowYearChange() ) + { + m_spinYear->Show(); + m_staticYear->Hide(); + + // skip the rest + return; + } + } + else + { + m_comboMonth->Hide(); + m_staticMonth->Show(); + } + + // year change not allowed here + m_spinYear->Hide(); + m_staticYear->Show(); + } + //else: these controls are not even created, don't show/hide them +} + +wxControl *wxGenericCalendarCtrl::GetMonthControl() const +{ + return AllowMonthChange() ? (wxControl *)m_comboMonth : (wxControl *)m_staticMonth; +} + +wxControl *wxGenericCalendarCtrl::GetYearControl() const +{ + return AllowYearChange() ? (wxControl *)m_spinYear : (wxControl *)m_staticYear; +} + +void wxGenericCalendarCtrl::EnableYearChange(bool enable) +{ + if ( enable != AllowYearChange() ) + { + long style = GetWindowStyle(); + if ( enable ) + style &= ~wxCAL_NO_YEAR_CHANGE; + else + style |= wxCAL_NO_YEAR_CHANGE; + SetWindowStyle(style); + + ShowCurrentControls(); + if ( GetWindowStyle() & wxCAL_SEQUENTIAL_MONTH_SELECTION ) + { + Refresh(); + } + } +} + +bool wxGenericCalendarCtrl::EnableMonthChange(bool enable) +{ + if ( !wxCalendarCtrlBase::EnableMonthChange(enable) ) + return false; + + ShowCurrentControls(); + if ( GetWindowStyle() & wxCAL_SEQUENTIAL_MONTH_SELECTION ) + Refresh(); + + return true; +} + +// ---------------------------------------------------------------------------- +// changing date +// ---------------------------------------------------------------------------- + +bool wxGenericCalendarCtrl::SetDate(const wxDateTime& date) +{ + bool retval = true; + + bool sameMonth = m_date.GetMonth() == date.GetMonth(), + sameYear = m_date.GetYear() == date.GetYear(); + + if ( IsDateInRange(date) ) + { + if ( sameMonth && sameYear ) + { + // just change the day + ChangeDay(date); + } + else + { + if ( AllowMonthChange() && (AllowYearChange() || sameYear) ) + { + // change everything + m_date = date; + + if ( !(GetWindowStyle() & wxCAL_SEQUENTIAL_MONTH_SELECTION) ) + { + // update the controls + m_comboMonth->SetSelection(m_date.GetMonth()); + + if ( AllowYearChange() ) + { + if ( !m_userChangedYear ) + m_spinYear->SetValue(m_date.Format(_T("%Y"))); + } + } + + // as the month changed, holidays did too + SetHolidayAttrs(); + + // update the calendar + Refresh(); + } + else + { + // forbidden + retval = false; + } + } + } + + m_userChangedYear = false; + + return retval; +} + +void wxGenericCalendarCtrl::ChangeDay(const wxDateTime& date) +{ + if ( m_date != date ) + { + // we need to refresh the row containing the old date and the one + // containing the new one + wxDateTime dateOld = m_date; + m_date = date; + + RefreshDate(dateOld); + + // if the date is in the same row, it was already drawn correctly + if ( GetWeek(m_date) != GetWeek(dateOld) ) + { + RefreshDate(m_date); + } + } +} + +void wxGenericCalendarCtrl::SetDateAndNotify(const wxDateTime& date) +{ + wxDateTime::Tm tm1 = m_date.GetTm(), + tm2 = date.GetTm(); + + const bool pageChanged = tm1.year != tm2.year || tm1.mon != tm2.mon; + + if ( !pageChanged && tm1.mday == tm2.mday ) + return; + + if ( SetDate(date) ) + { + GenerateEvent(wxEVT_CALENDAR_SEL_CHANGED); + if ( !pageChanged ) + GenerateEvent(wxEVT_CALENDAR_PAGE_CHANGED); + + // send also one of the deprecated events + if ( tm1.year != tm2.year ) + GenerateEvent(wxEVT_CALENDAR_YEAR_CHANGED); + else if ( tm1.mon != tm2.mon ) + GenerateEvent(wxEVT_CALENDAR_MONTH_CHANGED); + else + GenerateEvent(wxEVT_CALENDAR_DAY_CHANGED); + } +} + +// ---------------------------------------------------------------------------- +// date range +// ---------------------------------------------------------------------------- + +bool wxGenericCalendarCtrl::SetLowerDateLimit(const wxDateTime& date /* = wxDefaultDateTime */) +{ + bool retval = true; + + if ( !(date.IsValid()) || ( ( m_highdate.IsValid() ) ? ( date <= m_highdate ) : true ) ) + { + m_lowdate = date; + } + else + { + retval = false; + } + + return retval; +} + +bool wxGenericCalendarCtrl::SetUpperDateLimit(const wxDateTime& date /* = wxDefaultDateTime */) +{ + bool retval = true; + + if ( !(date.IsValid()) || ( ( m_lowdate.IsValid() ) ? ( date >= m_lowdate ) : true ) ) + { + m_highdate = date; + } + else + { + retval = false; + } + + return retval; +} + +bool wxGenericCalendarCtrl::SetDateRange(const wxDateTime& lowerdate /* = wxDefaultDateTime */, const wxDateTime& upperdate /* = wxDefaultDateTime */) +{ + bool retval = true; + + if ( + ( !( lowerdate.IsValid() ) || ( ( upperdate.IsValid() ) ? ( lowerdate <= upperdate ) : true ) ) && + ( !( upperdate.IsValid() ) || ( ( lowerdate.IsValid() ) ? ( upperdate >= lowerdate ) : true ) ) ) + { + m_lowdate = lowerdate; + m_highdate = upperdate; + } + else + { + retval = false; + } + + return retval; +} + +// ---------------------------------------------------------------------------- +// date helpers +// ---------------------------------------------------------------------------- + +wxDateTime wxGenericCalendarCtrl::GetStartDate() const +{ + wxDateTime::Tm tm = m_date.GetTm(); + + wxDateTime date = wxDateTime(1, tm.mon, tm.year); + + // rewind back + date.SetToPrevWeekDay(GetWindowStyle() & wxCAL_MONDAY_FIRST + ? wxDateTime::Mon : wxDateTime::Sun); + + if ( GetWindowStyle() & wxCAL_SHOW_SURROUNDING_WEEKS ) + { + // We want to offset the calendar if we start on the first.. + if ( date.GetDay() == 1 ) + { + date -= wxDateSpan::Week(); + } + } + + return date; +} + +bool wxGenericCalendarCtrl::IsDateShown(const wxDateTime& date) const +{ + if ( !(GetWindowStyle() & wxCAL_SHOW_SURROUNDING_WEEKS) ) + { + return date.GetMonth() == m_date.GetMonth(); + } + else + { + return true; + } +} + +bool wxGenericCalendarCtrl::IsDateInRange(const wxDateTime& date) const +{ + // Check if the given date is in the range specified + return ( ( ( m_lowdate.IsValid() ) ? ( date >= m_lowdate ) : true ) + && ( ( m_highdate.IsValid() ) ? ( date <= m_highdate ) : true ) ); +} + +bool wxGenericCalendarCtrl::ChangeYear(wxDateTime* target) const +{ + bool retval = false; + + if ( !(IsDateInRange(*target)) ) + { + if ( target->GetYear() < m_date.GetYear() ) + { + if ( target->GetYear() >= GetLowerDateLimit().GetYear() ) + { + *target = GetLowerDateLimit(); + retval = true; + } + else + { + *target = m_date; + } + } + else + { + if ( target->GetYear() <= GetUpperDateLimit().GetYear() ) + { + *target = GetUpperDateLimit(); + retval = true; + } + else + { + *target = m_date; + } + } + } + else + { + retval = true; + } + + return retval; +} + +bool wxGenericCalendarCtrl::ChangeMonth(wxDateTime* target) const +{ + bool retval = true; + + if ( !(IsDateInRange(*target)) ) + { + retval = false; + + if ( target->GetMonth() < m_date.GetMonth() ) + { + *target = GetLowerDateLimit(); + } + else + { + *target = GetUpperDateLimit(); + } + } + + return retval; +} + +size_t wxGenericCalendarCtrl::GetWeek(const wxDateTime& date) const +{ + size_t retval = date.GetWeekOfMonth(GetWindowStyle() & wxCAL_MONDAY_FIRST + ? wxDateTime::Monday_First + : wxDateTime::Sunday_First); + + if ( (GetWindowStyle() & wxCAL_SHOW_SURROUNDING_WEEKS) ) + { + // we need to offset an extra week if we "start" on the 1st of the month + wxDateTime::Tm tm = date.GetTm(); + + wxDateTime datetest = wxDateTime(1, tm.mon, tm.year); + + // rewind back + datetest.SetToPrevWeekDay(GetWindowStyle() & wxCAL_MONDAY_FIRST + ? wxDateTime::Mon : wxDateTime::Sun); + + if ( datetest.GetDay() == 1 ) + { + retval += 1; + } + } + + return retval; +} + +// ---------------------------------------------------------------------------- +// size management +// ---------------------------------------------------------------------------- + +// this is a composite control and it must arrange its parts each time its +// size or position changes: the combobox and spinctrl are along the top of +// the available area and the calendar takes up therest of the space + +// the static controls are supposed to be always smaller than combo/spin so we +// always use the latter for size calculations and position the static to take +// the same space + +// the constants used for the layout +#define VERT_MARGIN 5 // distance between combo and calendar +#ifdef __WXMAC__ +#define HORZ_MARGIN 5 // spin +#else +#define HORZ_MARGIN 15 // spin +#endif +wxSize wxGenericCalendarCtrl::DoGetBestSize() const +{ + // calc the size of the calendar + wx_const_cast(wxGenericCalendarCtrl *, this)->RecalcGeometry(); + + wxCoord width = 7*m_widthCol, + height = 7*m_heightRow + m_rowOffset + VERT_MARGIN; + + if ( !HasFlag(wxCAL_SEQUENTIAL_MONTH_SELECTION) ) + { + // the combobox doesn't report its height correctly (it returns the + // height including the drop down list) so don't use it + height += m_spinYear->GetBestSize().y; + + + wxCoord w2 = m_comboMonth->GetBestSize().x + HORZ_MARGIN + GetCharWidth()*6; + if (width < w2) + width = w2; + } + + if ( !HasFlag(wxBORDER_NONE) ) + { + // the border would clip the last line otherwise + height += 6; + width += 4; + } + + wxSize best(width, height); + CacheBestSize(best); + return best; +} + +void wxGenericCalendarCtrl::DoSetSize(int x, int y, + int width, int height, + int sizeFlags) +{ + wxControl::DoSetSize(x, y, width, height, sizeFlags); +} + +void wxGenericCalendarCtrl::DoMoveWindow(int x, int y, int width, int height) +{ + int yDiff; + + if ( !HasFlag(wxCAL_SEQUENTIAL_MONTH_SELECTION) && m_staticMonth ) + { + wxSize sizeCombo = m_comboMonth->GetEffectiveMinSize(); + wxSize sizeStatic = m_staticMonth->GetSize(); + wxSize sizeSpin = m_spinYear->GetSize(); + + // wxMSW sometimes reports the wrong combo height, + // so on this platform we'll use the spin control + // height instead. +#ifdef __WXMSW__ + int maxHeight = sizeSpin.y; + int requiredSpinHeight = -1; +#else + int maxHeight = sizeCombo.y; + int requiredSpinHeight = sizeCombo.y; +#endif + int dy = (maxHeight - sizeStatic.y) / 2; + m_comboMonth->Move(x, y); + m_staticMonth->SetSize(x, y + dy, sizeCombo.x, -1, sizeStatic.y); + + int xDiff = sizeCombo.x + HORZ_MARGIN; + + m_spinYear->SetSize(x + xDiff, y, width - xDiff, requiredSpinHeight); + m_staticYear->SetSize(x + xDiff, y + dy, width - xDiff, sizeStatic.y); + + yDiff = wxMax(sizeSpin.y, maxHeight) + VERT_MARGIN; + } + else // no controls on the top + { + yDiff = 0; + } + + wxControl::DoMoveWindow(x, y + yDiff, width, height - yDiff); +} + +void wxGenericCalendarCtrl::DoGetPosition(int *x, int *y) const +{ + wxControl::DoGetPosition(x, y); +#ifndef __WXPM__ + if ( !HasFlag(wxCAL_SEQUENTIAL_MONTH_SELECTION) && GetMonthControl() ) + { + // our real top corner is not in this position + if ( y ) + { + *y -= GetMonthControl()->GetSize().y + VERT_MARGIN; + } + } +#endif +} + +void wxGenericCalendarCtrl::DoGetSize(int *width, int *height) const +{ + wxControl::DoGetSize(width, height); +#ifndef __WXPM__ + if ( !HasFlag(wxCAL_SEQUENTIAL_MONTH_SELECTION) ) + { + // our real height is bigger + if ( height && GetMonthControl()) + { + *height += GetMonthControl()->GetSize().y + VERT_MARGIN; + } + } +#endif +} + +void wxGenericCalendarCtrl::RecalcGeometry() +{ + wxClientDC dc(this); + + dc.SetFont(GetFont()); + + // determine the column width (weekday names are not necessarily wider + // than the numbers (in some languages), so let's not assume that they are) + m_widthCol = 0; + for ( int day = 10; day <= 31; day++) + { + wxCoord width; + dc.GetTextExtent(wxString::Format(wxT("%d"), day), &width, &m_heightRow); + if ( width > m_widthCol ) + { + // 1.5 times the width gives nice margins even if the weekday + // names are short + m_widthCol = width+width/2; + } + } + wxDateTime::WeekDay wd; + for ( wd = wxDateTime::Sun; wd < wxDateTime::Inv_WeekDay; wxNextWDay(wd) ) + { + wxCoord width; + dc.GetTextExtent(m_weekdays[wd], &width, &m_heightRow); + if ( width > m_widthCol ) + { + m_widthCol = width; + } + } + + // leave some margins + m_widthCol += 2; + m_heightRow += 2; + + m_rowOffset = HasFlag(wxCAL_SEQUENTIAL_MONTH_SELECTION) ? m_heightRow : 0; // conditional in relation to style +} + +// ---------------------------------------------------------------------------- +// drawing +// ---------------------------------------------------------------------------- + +void wxGenericCalendarCtrl::OnPaint(wxPaintEvent& WXUNUSED(event)) +{ + wxPaintDC dc(this); + + dc.SetFont(GetFont()); + + RecalcGeometry(); + +#if DEBUG_PAINT + wxLogDebug("--- starting to paint, selection: %s, week %u\n", + m_date.Format("%a %d-%m-%Y %H:%M:%S").c_str(), + GetWeek(m_date)); +#endif + + wxCoord y = 0; + wxCoord x0 = wxMax( (GetSize().x - m_widthCol*7) /2 , 0 ); + + if ( HasFlag(wxCAL_SEQUENTIAL_MONTH_SELECTION) ) + { + // draw the sequential month-selector + + dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); + dc.SetTextForeground(*wxBLACK); + dc.SetBrush(wxBrush(m_colHeaderBg, wxBRUSHSTYLE_SOLID)); + dc.SetPen(wxPen(m_colHeaderBg, 1, wxPENSTYLE_SOLID)); + dc.DrawRectangle(0, y, GetClientSize().x, m_heightRow); + + // Get extent of month-name + year + wxCoord monthw, monthh; + wxString headertext = m_date.Format(wxT("%B %Y")); + dc.GetTextExtent(headertext, &monthw, &monthh); + + // draw month-name centered above weekdays + wxCoord monthx = ((m_widthCol * 7) - monthw) / 2 + x0; + wxCoord monthy = ((m_heightRow - monthh) / 2) + y; + dc.DrawText(headertext, monthx, monthy); + + // calculate the "month-arrows" + wxPoint leftarrow[3]; + wxPoint rightarrow[3]; + + int arrowheight = monthh / 2; + + leftarrow[0] = wxPoint(0, arrowheight / 2); + leftarrow[1] = wxPoint(arrowheight / 2, 0); + leftarrow[2] = wxPoint(arrowheight / 2, arrowheight - 1); + + rightarrow[0] = wxPoint(0,0); + rightarrow[1] = wxPoint(arrowheight / 2, arrowheight / 2); + rightarrow[2] = wxPoint(0, arrowheight - 1); + + // draw the "month-arrows" + + wxCoord arrowy = (m_heightRow - arrowheight) / 2; + wxCoord larrowx = (m_widthCol - (arrowheight / 2)) / 2 + x0; + wxCoord rarrowx = ((m_widthCol - (arrowheight / 2)) / 2) + m_widthCol*6 + x0; + m_leftArrowRect = m_rightArrowRect = wxRect(0,0,0,0); + + if ( AllowMonthChange() ) + { + wxDateTime ldpm = wxDateTime(1,m_date.GetMonth(), m_date.GetYear()) - wxDateSpan::Day(); // last day prev month + // Check if range permits change + if ( IsDateInRange(ldpm) && ( ( ldpm.GetYear() == m_date.GetYear() ) ? true : AllowYearChange() ) ) + { + m_leftArrowRect = wxRect(larrowx - 3, arrowy - 3, (arrowheight / 2) + 8, (arrowheight + 6)); + dc.SetBrush(*wxBLACK_BRUSH); + dc.SetPen(*wxBLACK_PEN); + dc.DrawPolygon(3, leftarrow, larrowx , arrowy, wxWINDING_RULE); + dc.SetBrush(*wxTRANSPARENT_BRUSH); + dc.DrawRectangle(m_leftArrowRect); + } + wxDateTime fdnm = wxDateTime(1,m_date.GetMonth(), m_date.GetYear()) + wxDateSpan::Month(); // first day next month + if ( IsDateInRange(fdnm) && ( ( fdnm.GetYear() == m_date.GetYear() ) ? true : AllowYearChange() ) ) + { + m_rightArrowRect = wxRect(rarrowx - 4, arrowy - 3, (arrowheight / 2) + 8, (arrowheight + 6)); + dc.SetBrush(*wxBLACK_BRUSH); + dc.SetPen(*wxBLACK_PEN); + dc.DrawPolygon(3, rightarrow, rarrowx , arrowy, wxWINDING_RULE); + dc.SetBrush(*wxTRANSPARENT_BRUSH); + dc.DrawRectangle(m_rightArrowRect); + } + } + + y += m_heightRow; + } + + // first draw the week days + if ( IsExposed(x0, y, x0 + 7*m_widthCol, m_heightRow) ) + { +#if DEBUG_PAINT + wxLogDebug("painting the header"); +#endif + + dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); + dc.SetTextForeground(m_colHeaderFg); + dc.SetBrush(wxBrush(m_colHeaderBg, wxBRUSHSTYLE_SOLID)); + dc.SetPen(wxPen(m_colHeaderBg, 1, wxPENSTYLE_SOLID)); + dc.DrawRectangle(0, y, GetClientSize().x, m_heightRow); + + bool startOnMonday = (GetWindowStyle() & wxCAL_MONDAY_FIRST) != 0; + for ( int wd = 0; wd < 7; wd++ ) + { + size_t n; + if ( startOnMonday ) + n = wd == 6 ? 0 : wd + 1; + else + n = wd; + wxCoord dayw, dayh; + dc.GetTextExtent(m_weekdays[n], &dayw, &dayh); + dc.DrawText(m_weekdays[n], x0 + (wd*m_widthCol) + ((m_widthCol- dayw) / 2), y); // center the day-name + } + } + + // then the calendar itself + dc.SetTextForeground(*wxBLACK); + //dc.SetFont(*wxNORMAL_FONT); + + y += m_heightRow; + wxDateTime date = GetStartDate(); + +#if DEBUG_PAINT + wxLogDebug("starting calendar from %s\n", + date.Format("%a %d-%m-%Y %H:%M:%S").c_str()); +#endif + + dc.SetBackgroundMode(wxBRUSHSTYLE_SOLID); + for ( size_t nWeek = 1; nWeek <= 6; nWeek++, y += m_heightRow ) + { + // if the update region doesn't intersect this row, don't paint it + if ( !IsExposed(x0, y, x0 + 7*m_widthCol, m_heightRow - 1) ) + { + date += wxDateSpan::Week(); + + continue; + } + +#if DEBUG_PAINT + wxLogDebug("painting week %d at y = %d\n", nWeek, y); +#endif + + for ( int wd = 0; wd < 7; wd++ ) + { + dc.SetTextBackground(m_colBackground); + if ( IsDateShown(date) ) + { + // don't use wxDate::Format() which prepends 0s + unsigned int day = date.GetDay(); + wxString dayStr = wxString::Format(_T("%u"), day); + wxCoord width; + dc.GetTextExtent(dayStr, &width, (wxCoord *)NULL); + + bool changedColours = false, + changedFont = false; + + bool isSel = false; + wxCalendarDateAttr *attr = NULL; + + if ( date.GetMonth() != m_date.GetMonth() || !IsDateInRange(date) ) + { + // surrounding week or out-of-range + // draw "disabled" + dc.SetTextForeground(m_colSorrounding); + changedColours = true; + } + else + { + isSel = date.IsSameDate(m_date); + attr = m_attrs[day - 1]; + + if ( isSel ) + { + dc.SetTextForeground(m_colHighlightFg); + dc.SetTextBackground(m_colHighlightBg); + + changedColours = true; + } + else if ( attr ) + { + wxColour colFg, colBg; + + if ( attr->IsHoliday() ) + { + colFg = m_colHolidayFg; + colBg = m_colHolidayBg; + } + else + { + colFg = attr->GetTextColour(); + colBg = attr->GetBackgroundColour(); + } + + if ( colFg.Ok() ) + { + dc.SetTextForeground(colFg); + changedColours = true; + } + + if ( colBg.Ok() ) + { + dc.SetTextBackground(colBg); + changedColours = true; + } + + if ( attr->HasFont() ) + { + dc.SetFont(attr->GetFont()); + changedFont = true; + } + } + } + + wxCoord x = wd*m_widthCol + (m_widthCol - width) / 2 + x0; + dc.DrawText(dayStr, x, y + 1); + + if ( !isSel && attr && attr->HasBorder() ) + { + wxColour colBorder; + if ( attr->HasBorderColour() ) + { + colBorder = attr->GetBorderColour(); + } + else + { + colBorder = GetForegroundColour(); + } + + wxPen pen(colBorder, 1, wxPENSTYLE_SOLID); + dc.SetPen(pen); + dc.SetBrush(*wxTRANSPARENT_BRUSH); + + switch ( attr->GetBorder() ) + { + case wxCAL_BORDER_SQUARE: + dc.DrawRectangle(x - 2, y, + width + 4, m_heightRow); + break; + + case wxCAL_BORDER_ROUND: + dc.DrawEllipse(x - 2, y, + width + 4, m_heightRow); + break; + + default: + wxFAIL_MSG(_T("unknown border type")); + } + } + + if ( changedColours ) + { + dc.SetTextForeground(GetForegroundColour()); + dc.SetTextBackground(GetBackgroundColour()); + } + + if ( changedFont ) + { + dc.SetFont(GetFont()); + } + } + //else: just don't draw it + + date += wxDateSpan::Day(); + } + } + + // Greying out out-of-range background + bool showSurrounding = (GetWindowStyle() & wxCAL_SHOW_SURROUNDING_WEEKS) != 0; + + date = ( showSurrounding ) ? GetStartDate() : wxDateTime(1, m_date.GetMonth(), m_date.GetYear()); + if ( !IsDateInRange(date) ) + { + wxDateTime firstOOR = GetLowerDateLimit() - wxDateSpan::Day(); // first out-of-range + + wxBrush oorbrush = *wxLIGHT_GREY_BRUSH; + oorbrush.SetStyle(wxBRUSHSTYLE_FDIAGONAL_HATCH); + + HighlightRange(&dc, date, firstOOR, wxTRANSPARENT_PEN, &oorbrush); + } + + date = ( showSurrounding ) ? GetStartDate() + wxDateSpan::Weeks(6) - wxDateSpan::Day() : wxDateTime().SetToLastMonthDay(m_date.GetMonth(), m_date.GetYear()); + if ( !IsDateInRange(date) ) + { + wxDateTime firstOOR = GetUpperDateLimit() + wxDateSpan::Day(); // first out-of-range + + wxBrush oorbrush = *wxLIGHT_GREY_BRUSH; + oorbrush.SetStyle(wxBRUSHSTYLE_FDIAGONAL_HATCH); + + HighlightRange(&dc, firstOOR, date, wxTRANSPARENT_PEN, &oorbrush); + } + +#if DEBUG_PAINT + wxLogDebug("+++ finished painting"); +#endif +} + +void wxGenericCalendarCtrl::RefreshDate(const wxDateTime& date) +{ + RecalcGeometry(); + + wxRect rect; + + // always refresh the whole row at once because our OnPaint() will draw + // the whole row anyhow - and this allows the small optimisation in + // OnClick() below to work + rect.x = wxMax( (GetSize().x - m_widthCol*7) /2 , 0 ); + + rect.y = (m_heightRow * GetWeek(date)) + m_rowOffset; + + rect.width = 7*m_widthCol; + rect.height = m_heightRow; + +#ifdef __WXMSW__ + // VZ: for some reason, the selected date seems to occupy more space under + // MSW - this is probably some bug in the font size calculations, but I + // don't know where exactly. This fix is ugly and leads to more + // refreshes than really needed, but without it the selected days + // leaves even more ugly underscores on screen. + rect.Inflate(0, 1); +#endif // MSW + +#if DEBUG_PAINT + wxLogDebug("*** refreshing week %d at (%d, %d)-(%d, %d)\n", + GetWeek(date), + rect.x, rect.y, + rect.x + rect.width, rect.y + rect.height); +#endif + + Refresh(true, &rect); +} + +void wxGenericCalendarCtrl::HighlightRange(wxPaintDC* pDC, const wxDateTime& fromdate, const wxDateTime& todate, const wxPen* pPen, const wxBrush* pBrush) +{ + // Highlights the given range using pen and brush + // Does nothing if todate < fromdate + + +#if DEBUG_PAINT + wxLogDebug("+++ HighlightRange: (%s) - (%s) +++", fromdate.Format("%d %m %Y"), todate.Format("%d %m %Y")); +#endif + + if ( todate >= fromdate ) + { + // do stuff + // date-coordinates + int fd, fw; + int td, tw; + + // implicit: both dates must be currently shown - checked by GetDateCoord + if ( GetDateCoord(fromdate, &fd, &fw) && GetDateCoord(todate, &td, &tw) ) + { +#if DEBUG_PAINT + wxLogDebug("Highlight range: (%i, %i) - (%i, %i)", fd, fw, td, tw); +#endif + if ( ( (tw - fw) == 1 ) && ( td < fd ) ) + { + // special case: interval 7 days or less not in same week + // split in two separate intervals + wxDateTime tfd = fromdate + wxDateSpan::Days(7-fd); + wxDateTime ftd = tfd + wxDateSpan::Day(); +#if DEBUG_PAINT + wxLogDebug("Highlight: Separate segments"); +#endif + // draw separately + HighlightRange(pDC, fromdate, tfd, pPen, pBrush); + HighlightRange(pDC, ftd, todate, pPen, pBrush); + } + else + { + int numpoints; + wxPoint corners[8]; // potentially 8 corners in polygon + wxCoord x0 = wxMax( (GetSize().x - m_widthCol*7) /2 , 0 ); + + if ( fw == tw ) + { + // simple case: same week + numpoints = 4; + corners[0] = wxPoint(x0 + (fd - 1) * m_widthCol, (fw * m_heightRow) + m_rowOffset); + corners[1] = wxPoint(x0 + (fd - 1) * m_widthCol, ((fw + 1 ) * m_heightRow) + m_rowOffset); + corners[2] = wxPoint(x0 + td * m_widthCol, ((tw + 1) * m_heightRow) + m_rowOffset); + corners[3] = wxPoint(x0 + td * m_widthCol, (tw * m_heightRow) + m_rowOffset); + } + else + { + int cidx = 0; + // "complex" polygon + corners[cidx] = wxPoint(x0 + (fd - 1) * m_widthCol, (fw * m_heightRow) + m_rowOffset); cidx++; + + if ( fd > 1 ) + { + corners[cidx] = wxPoint(x0 + (fd - 1) * m_widthCol, ((fw + 1) * m_heightRow) + m_rowOffset); cidx++; + corners[cidx] = wxPoint(x0, ((fw + 1) * m_heightRow) + m_rowOffset); cidx++; + } + + corners[cidx] = wxPoint(x0, ((tw + 1) * m_heightRow) + m_rowOffset); cidx++; + corners[cidx] = wxPoint(x0 + td * m_widthCol, ((tw + 1) * m_heightRow) + m_rowOffset); cidx++; + + if ( td < 7 ) + { + corners[cidx] = wxPoint(x0 + td * m_widthCol, (tw * m_heightRow) + m_rowOffset); cidx++; + corners[cidx] = wxPoint(x0 + 7 * m_widthCol, (tw * m_heightRow) + m_rowOffset); cidx++; + } + + corners[cidx] = wxPoint(x0 + 7 * m_widthCol, (fw * m_heightRow) + m_rowOffset); cidx++; + + numpoints = cidx; + } + + // draw the polygon + pDC->SetBrush(*pBrush); + pDC->SetPen(*pPen); + pDC->DrawPolygon(numpoints, corners); + } + } + } + // else do nothing +#if DEBUG_PAINT + wxLogDebug("--- HighlightRange ---"); +#endif +} + +bool wxGenericCalendarCtrl::GetDateCoord(const wxDateTime& date, int *day, int *week) const +{ + bool retval = true; + +#if DEBUG_PAINT + wxLogDebug("+++ GetDateCoord: (%s) +++", date.Format("%d %m %Y")); +#endif + + if ( IsDateShown(date) ) + { + bool startOnMonday = ( GetWindowStyle() & wxCAL_MONDAY_FIRST ) != 0; + + // Find day + *day = date.GetWeekDay(); + + if ( *day == 0 ) // sunday + { + *day = ( startOnMonday ) ? 7 : 1; + } + else + { + *day += ( startOnMonday ) ? 0 : 1; + } + + int targetmonth = date.GetMonth() + (12 * date.GetYear()); + int thismonth = m_date.GetMonth() + (12 * m_date.GetYear()); + + // Find week + if ( targetmonth == thismonth ) + { + *week = GetWeek(date); + } + else + { + if ( targetmonth < thismonth ) + { + *week = 1; // trivial + } + else // targetmonth > thismonth + { + wxDateTime ldcm; + int lastweek; + int lastday; + + // get the datecoord of the last day in the month currently shown +#if DEBUG_PAINT + wxLogDebug(" +++ LDOM +++"); +#endif + GetDateCoord(ldcm.SetToLastMonthDay(m_date.GetMonth(), m_date.GetYear()), &lastday, &lastweek); +#if DEBUG_PAINT + wxLogDebug(" --- LDOM ---"); +#endif + + wxTimeSpan span = date - ldcm; + + int daysfromlast = span.GetDays(); +#if DEBUG_PAINT + wxLogDebug("daysfromlast: %i", daysfromlast); +#endif + if ( daysfromlast + lastday > 7 ) // past week boundary + { + int wholeweeks = (daysfromlast / 7); + *week = wholeweeks + lastweek; + if ( (daysfromlast - (7 * wholeweeks) + lastday) > 7 ) + { + *week += 1; + } + } + else + { + *week = lastweek; + } + } + } + } + else + { + *day = -1; + *week = -1; + retval = false; + } + +#if DEBUG_PAINT + wxLogDebug("--- GetDateCoord: (%s) = (%i, %i) ---", date.Format("%d %m %Y"), *day, *week); +#endif + + return retval; +} + +// ---------------------------------------------------------------------------- +// mouse handling +// ---------------------------------------------------------------------------- + +void wxGenericCalendarCtrl::OnDClick(wxMouseEvent& event) +{ + if ( HitTest(event.GetPosition()) != wxCAL_HITTEST_DAY ) + { + event.Skip(); + } + else + { + GenerateEvent(wxEVT_CALENDAR_DOUBLECLICKED); + } +} + +void wxGenericCalendarCtrl::OnClick(wxMouseEvent& event) +{ + wxDateTime date; + wxDateTime::WeekDay wday; + switch ( HitTest(event.GetPosition(), &date, &wday) ) + { + case wxCAL_HITTEST_DAY: + if ( IsDateInRange(date) ) + { + ChangeDay(date); + + GenerateEvent(wxEVT_CALENDAR_SEL_CHANGED); + GenerateEvent(wxEVT_CALENDAR_DAY_CHANGED); + } + break; + + case wxCAL_HITTEST_HEADER: + { + wxCalendarEvent eventWd(this, GetDate(), + wxEVT_CALENDAR_WEEKDAY_CLICKED); + eventWd.SetWeekDay(wday); + (void)GetEventHandler()->ProcessEvent(eventWd); + } + break; + + case wxCAL_HITTEST_DECMONTH: + case wxCAL_HITTEST_INCMONTH: + case wxCAL_HITTEST_SURROUNDING_WEEK: + SetDateAndNotify(date); // we probably only want to refresh the control. No notification.. (maybe as an option?) + break; + + default: + wxFAIL_MSG(_T("unknown hittest code")); + // fall through + + case wxCAL_HITTEST_NOWHERE: + event.Skip(); + break; + } +} + +wxCalendarHitTestResult wxGenericCalendarCtrl::HitTest(const wxPoint& pos, + wxDateTime *date, + wxDateTime::WeekDay *wd) +{ + RecalcGeometry(); + + // the position where the calendar really begins + wxCoord x0 = wxMax((GetSize().x - m_widthCol*7)/2, 0); + + if ( HasFlag(wxCAL_SEQUENTIAL_MONTH_SELECTION) ) + { + // Header: month + + // we need to find out if the hit is on left arrow, on month or on right arrow + // left arrow? + if ( m_leftArrowRect.Contains(pos) ) + { + if ( date ) + { + if ( IsDateInRange(m_date - wxDateSpan::Month()) ) + { + *date = m_date - wxDateSpan::Month(); + } + else + { + *date = GetLowerDateLimit(); + } + } + + return wxCAL_HITTEST_DECMONTH; + } + + if ( m_rightArrowRect.Contains(pos) ) + { + if ( date ) + { + if ( IsDateInRange(m_date + wxDateSpan::Month()) ) + { + *date = m_date + wxDateSpan::Month(); + } + else + { + *date = GetUpperDateLimit(); + } + } + + return wxCAL_HITTEST_INCMONTH; + } + + } + + // header: week days + int wday = (pos.x - x0) / m_widthCol; + if ( pos.y < (m_heightRow + m_rowOffset) ) + { + if ( pos.y > m_rowOffset ) + { + if ( wd ) + { + if ( GetWindowStyle() & wxCAL_MONDAY_FIRST ) + { + wday = wday == 6 ? 0 : wday + 1; + } + + *wd = (wxDateTime::WeekDay)wday; + } + + return wxCAL_HITTEST_HEADER; + } + else + { + return wxCAL_HITTEST_NOWHERE; + } + } + + int week = (pos.y - (m_heightRow + m_rowOffset)) / m_heightRow; + if ( week >= 6 || wday >= 7 ) + { + return wxCAL_HITTEST_NOWHERE; + } + + wxDateTime dt = GetStartDate() + wxDateSpan::Days(7*week + wday); + + if ( IsDateShown(dt) ) + { + if ( date ) + *date = dt; + + if ( dt.GetMonth() == m_date.GetMonth() ) + { + + return wxCAL_HITTEST_DAY; + } + else + { + return wxCAL_HITTEST_SURROUNDING_WEEK; + } + } + else + { + return wxCAL_HITTEST_NOWHERE; + } +} + +// ---------------------------------------------------------------------------- +// subcontrols events handling +// ---------------------------------------------------------------------------- + +void wxGenericCalendarCtrl::OnMonthChange(wxCommandEvent& event) +{ + wxDateTime::Tm tm = m_date.GetTm(); + + wxDateTime::Month mon = (wxDateTime::Month)event.GetInt(); + if ( tm.mday > wxDateTime::GetNumberOfDays(mon, tm.year) ) + { + tm.mday = wxDateTime::GetNumberOfDays(mon, tm.year); + } + + wxDateTime target = wxDateTime(tm.mday, mon, tm.year); + + ChangeMonth(&target); + SetDateAndNotify(target); +} + +void wxGenericCalendarCtrl::OnYearChange(wxCommandEvent& event) +{ + int year = (int)event.GetInt(); + if ( year == INT_MIN ) + { + // invalid year in the spin control, ignore it + return; + } + + wxDateTime::Tm tm = m_date.GetTm(); + + if ( tm.mday > wxDateTime::GetNumberOfDays(tm.mon, year) ) + { + tm.mday = wxDateTime::GetNumberOfDays(tm.mon, year); + } + + wxDateTime target = wxDateTime(tm.mday, tm.mon, year); + + if ( ChangeYear(&target) ) + { + SetDateAndNotify(target); + } + else + { + // In this case we don't want to change the date. That would put us + // inside the same year but a strange number of months forward/back.. + m_spinYear->SetValue(target.GetYear()); + } +} + +void wxGenericCalendarCtrl::OnYearTextChange(wxCommandEvent& event) +{ + SetUserChangedYear(); + OnYearChange(event); +} + +// Responds to colour changes, and passes event on to children. +void wxGenericCalendarCtrl::OnSysColourChanged(wxSysColourChangedEvent& event) +{ + // reinit colours + InitColours(); + + // Propagate the event to the children + wxControl::OnSysColourChanged(event); + + // Redraw control area + SetBackgroundColour(m_colBackground); + Refresh(); +} + +// ---------------------------------------------------------------------------- +// keyboard interface +// ---------------------------------------------------------------------------- + +void wxGenericCalendarCtrl::OnChar(wxKeyEvent& event) +{ + wxDateTime target; + switch ( event.GetKeyCode() ) + { + case _T('+'): + case WXK_ADD: + target = m_date + wxDateSpan::Year(); + if ( ChangeYear(&target) ) + { + SetDateAndNotify(target); + } + break; + + case _T('-'): + case WXK_SUBTRACT: + target = m_date - wxDateSpan::Year(); + if ( ChangeYear(&target) ) + { + SetDateAndNotify(target); + } + break; + + case WXK_PAGEUP: + target = m_date - wxDateSpan::Month(); + ChangeMonth(&target); + SetDateAndNotify(target); // always + break; + + case WXK_PAGEDOWN: + target = m_date + wxDateSpan::Month(); + ChangeMonth(&target); + SetDateAndNotify(target); // always + break; + + case WXK_RIGHT: + if ( event.ControlDown() ) + { + target = wxDateTime(m_date).SetToNextWeekDay( + GetWindowStyle() & wxCAL_MONDAY_FIRST + ? wxDateTime::Sun : wxDateTime::Sat); + if ( !IsDateInRange(target) ) + { + target = GetUpperDateLimit(); + } + SetDateAndNotify(target); + } + else + SetDateAndNotify(m_date + wxDateSpan::Day()); + break; + + case WXK_LEFT: + if ( event.ControlDown() ) + { + target = wxDateTime(m_date).SetToPrevWeekDay( + GetWindowStyle() & wxCAL_MONDAY_FIRST + ? wxDateTime::Mon : wxDateTime::Sun); + if ( !IsDateInRange(target) ) + { + target = GetLowerDateLimit(); + } + SetDateAndNotify(target); + } + else + SetDateAndNotify(m_date - wxDateSpan::Day()); + break; + + case WXK_UP: + SetDateAndNotify(m_date - wxDateSpan::Week()); + break; + + case WXK_DOWN: + SetDateAndNotify(m_date + wxDateSpan::Week()); + break; + + case WXK_HOME: + if ( event.ControlDown() ) + SetDateAndNotify(wxDateTime::Today()); + else + SetDateAndNotify(wxDateTime(1, m_date.GetMonth(), m_date.GetYear())); + break; + + case WXK_END: + SetDateAndNotify(wxDateTime(m_date).SetToLastMonthDay()); + break; + + case WXK_RETURN: + GenerateEvent(wxEVT_CALENDAR_DOUBLECLICKED); + break; + + default: + event.Skip(); + } +} + +// ---------------------------------------------------------------------------- +// holidays handling +// ---------------------------------------------------------------------------- + +void wxGenericCalendarCtrl::EnableHolidayDisplay(bool display) +{ + long style = GetWindowStyle(); + if ( display ) + style |= wxCAL_SHOW_HOLIDAYS; + else + style &= ~wxCAL_SHOW_HOLIDAYS; + + SetWindowStyle(style); + + if ( display ) + SetHolidayAttrs(); + else + ResetHolidayAttrs(); + + Refresh(); +} + +void wxGenericCalendarCtrl::SetHolidayAttrs() +{ + if ( GetWindowStyle() & wxCAL_SHOW_HOLIDAYS ) + { + ResetHolidayAttrs(); + + wxDateTime::Tm tm = m_date.GetTm(); + wxDateTime dtStart(1, tm.mon, tm.year), + dtEnd = dtStart.GetLastMonthDay(); + + wxDateTimeArray hol; + wxDateTimeHolidayAuthority::GetHolidaysInRange(dtStart, dtEnd, hol); + + size_t count = hol.GetCount(); + for ( size_t n = 0; n < count; n++ ) + { + SetHoliday(hol[n].GetDay()); + } + } +} + +void wxGenericCalendarCtrl::SetHoliday(size_t day) +{ + wxCHECK_RET( day > 0 && day < 32, _T("invalid day in SetHoliday") ); + + wxCalendarDateAttr *attr = GetAttr(day); + if ( !attr ) + { + attr = new wxCalendarDateAttr; + } + + attr->SetHoliday(true); + + // can't use SetAttr() because it would delete this pointer + m_attrs[day - 1] = attr; +} + +void wxGenericCalendarCtrl::ResetHolidayAttrs() +{ + for ( size_t day = 0; day < 31; day++ ) + { + if ( m_attrs[day] ) + { + m_attrs[day]->SetHoliday(false); + } + } +} + +void wxGenericCalendarCtrl::Mark(size_t day, bool mark) +{ + wxCHECK_RET( day > 0 && day < 32, _T("invalid day in Mark") ); + + const wxCalendarDateAttr& m = wxCalendarDateAttr::GetMark(); + if (mark) { + if ( m_attrs[day - 1] ) + AddAttr(m_attrs[day - 1], m); + else + SetAttr(day, new wxCalendarDateAttr(m)); + } + else { + if ( m_attrs[day - 1] ) + DelAttr(m_attrs[day - 1], m); + } +} + +//static +wxVisualAttributes +wxGenericCalendarCtrl::GetClassDefaultAttributes(wxWindowVariant variant) +{ + // Use the same color scheme as wxListBox + return wxListBox::GetClassDefaultAttributes(variant); +} + +#endif // wxUSE_CALENDARCTRL diff --git a/src/generic/datectlg.cpp b/src/generic/datectlg.cpp index 5028bb79b0..c451b17347 100644 --- a/src/generic/datectlg.cpp +++ b/src/generic/datectlg.cpp @@ -44,16 +44,12 @@ // this header is not included from wx/datectrl.h if we have a native // version, but we do need it here #include "wx/generic/datectrl.h" -#else - // we need to define _WX_DEFINE_DATE_EVENTS_ before including wx/dateevt.h to - // define the event types we use if we're the only date picker control version - // being compiled -- otherwise it's defined in the native version implementation - #define _WX_DEFINE_DATE_EVENTS_ #endif #include "wx/dateevt.h" #include "wx/calctrl.h" +#include "wx/generic/calctrlg.h" #include "wx/combo.h" // ---------------------------------------------------------------------------- @@ -75,12 +71,12 @@ // local classes // ---------------------------------------------------------------------------- -class wxCalendarComboPopup : public wxCalendarCtrl, +class wxCalendarComboPopup : public wxGenericCalendarCtrl, public wxComboPopup { public: - wxCalendarComboPopup() : wxCalendarCtrl(), + wxCalendarComboPopup() : wxGenericCalendarCtrl(), wxComboPopup() { } @@ -94,12 +90,12 @@ public: // certainly introduce new bugs. virtual bool Create(wxWindow* parent) { - if ( !wxCalendarCtrl::Create(parent, wxID_ANY, wxDefaultDateTime, + if ( !wxGenericCalendarCtrl::Create(parent, wxID_ANY, wxDefaultDateTime, wxPoint(0, 0), wxDefaultSize, wxCAL_SHOW_HOLIDAYS | wxBORDER_SUNKEN) ) return false; - wxWindow *yearControl = wxCalendarCtrl::GetYearControl(); + wxWindow *yearControl = wxGenericCalendarCtrl::GetYearControl(); wxClientDC dc(yearControl); dc.SetFont(yearControl->GetFont()); @@ -107,7 +103,7 @@ public: dc.GetTextExtent(wxT("2000"), &width, &dummy); width += ConvertDialogToPixels(wxSize(20, 0)).x; - wxSize calSize = wxCalendarCtrl::GetBestSize(); + wxSize calSize = wxGenericCalendarCtrl::GetBestSize(); wxSize yearSize = yearControl->GetSize(); yearSize.x = width; @@ -125,10 +121,10 @@ public: calPos = 0; width += 2; } - wxCalendarCtrl::SetSize(calPos, 0, calSize.x, calSize.y); + wxGenericCalendarCtrl::SetSize(calPos, 0, calSize.x, calSize.y); yearControl->SetSize(width-yearSize.x-CALBORDER/2, yearPosition.y, yearSize.x, yearSize.y); - wxCalendarCtrl::GetMonthControl()->Move(0, 0); + wxGenericCalendarCtrl::GetMonthControl()->Move(0, 0); m_useSize.x = width+CALBORDER/2; m_useSize.y = calSize.y-2+CALBORDER; @@ -186,14 +182,10 @@ public: void SendDateEvent(const wxDateTime& dt) { - // // Sends both wxCalendarEvent and wxDateEvent wxWindow* datePicker = m_combo->GetParent(); - wxCalendarEvent cev((wxCalendarCtrl*) this, wxEVT_CALENDAR_SEL_CHANGED); - cev.SetEventObject(datePicker); - cev.SetId(datePicker->GetId()); - cev.SetDate(dt); + wxCalendarEvent cev(datePicker, dt, wxEVT_CALENDAR_SEL_CHANGED); datePicker->GetEventHandler()->ProcessEvent(cev); wxDateEvent event(datePicker, dt, wxEVT_DATE_CHANGED); @@ -353,12 +345,10 @@ private: }; -BEGIN_EVENT_TABLE(wxCalendarComboPopup, wxCalendarCtrl) +BEGIN_EVENT_TABLE(wxCalendarComboPopup, wxGenericCalendarCtrl) EVT_KEY_DOWN(wxCalendarComboPopup::OnCalKey) EVT_CALENDAR_SEL_CHANGED(wxID_ANY, wxCalendarComboPopup::OnSelChange) - EVT_CALENDAR_DAY(wxID_ANY, wxCalendarComboPopup::OnSelChange) - EVT_CALENDAR_MONTH(wxID_ANY, wxCalendarComboPopup::OnSelChange) - EVT_CALENDAR_YEAR(wxID_ANY, wxCalendarComboPopup::OnSelChange) + EVT_CALENDAR_PAGE_CHANGED(wxID_ANY, wxCalendarComboPopup::OnSelChange) EVT_CALENDAR(wxID_ANY, wxCalendarComboPopup::OnSelChange) END_EVENT_TABLE() @@ -493,7 +483,7 @@ wxDatePickerCtrlGeneric::SetRange(const wxDateTime &dt1, const wxDateTime &dt2) m_popup->SetDateRange(dt1, dt2); } -wxCalendarCtrl *wxDatePickerCtrlGeneric::GetCalendar() const +wxGenericCalendarCtrl *wxDatePickerCtrlGeneric::GetCalendar() const { return m_popup; } diff --git a/src/gtk/calctrl.cpp b/src/gtk/calctrl.cpp new file mode 100644 index 0000000000..9c5b2a1717 --- /dev/null +++ b/src/gtk/calctrl.cpp @@ -0,0 +1,158 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: src/gtk/calctrl.cpp +// Purpose: implementation of the wxGtkCalendarCtrl +// Author: Marcin Wojdyr +// RCS-ID: $Id$ +// Copyright: (c) 2008 Marcin Wojdyr +// Licence: wxWindows licence +/////////////////////////////////////////////////////////////////////////////// + +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#endif //WX_PRECOMP + +#if wxUSE_CALENDARCTRL + +#include "wx/gtk/private.h" +#include "wx/calctrl.h" +#include "wx/gtk/calctrl.h" + + +extern "C" { + +static void gtk_day_selected_callback(GtkWidget *WXUNUSED(widget), + wxGtkCalendarCtrl *cal) +{ + cal->GenerateEvent(wxEVT_CALENDAR_SEL_CHANGED); + cal->GenerateEvent(wxEVT_CALENDAR_DAY_CHANGED); +} + +static void gtk_day_selected_double_click_callback(GtkWidget *WXUNUSED(widget), + wxGtkCalendarCtrl *cal) +{ + cal->GenerateEvent(wxEVT_CALENDAR_DOUBLECLICKED); +} + +static void gtk_month_changed_callback(GtkWidget *WXUNUSED(widget), + wxGtkCalendarCtrl *cal) +{ + cal->GenerateEvent(wxEVT_CALENDAR_PAGE_CHANGED); +} + +// callbacks that send deprecated events + +static void gtk_prev_month_callback(GtkWidget *WXUNUSED(widget), + wxGtkCalendarCtrl *cal) +{ + cal->GenerateEvent(wxEVT_CALENDAR_MONTH_CHANGED); +} + +static void gtk_prev_year_callback(GtkWidget *WXUNUSED(widget), + wxGtkCalendarCtrl *cal) +{ + cal->GenerateEvent(wxEVT_CALENDAR_YEAR_CHANGED); +} + +} + +// ---------------------------------------------------------------------------- +// wxGtkCalendarCtrl +// ---------------------------------------------------------------------------- + + +bool wxGtkCalendarCtrl::Create(wxWindow *parent, + wxWindowID id, + const wxDateTime& date, + const wxPoint& pos, + const wxSize& size, + long style, + const wxString& name) +{ + if (!PreCreation(parent, pos, size) || + !CreateBase(parent, id, pos, size, style, wxDefaultValidator, name)) + { + wxFAIL_MSG(wxT("wxGtkCalendarCtrl creation failed")); + return false; + } + + m_widget = gtk_calendar_new(); + SetDate(date.IsValid() ? date : wxDateTime::Today()); + + if (style & wxCAL_NO_MONTH_CHANGE) + g_object_set (G_OBJECT (m_widget), "no-month-change", true, NULL); + + g_signal_connect_after(m_widget, "day-selected", + G_CALLBACK (gtk_day_selected_callback), + this); + g_signal_connect_after(m_widget, "day-selected-double-click", + G_CALLBACK (gtk_day_selected_double_click_callback), + this); + g_signal_connect_after(m_widget, "month-changed", + G_CALLBACK (gtk_month_changed_callback), + this); + + // connect callbacks that send deprecated events + g_signal_connect_after(m_widget, "prev-month", + G_CALLBACK (gtk_prev_month_callback), + this); + g_signal_connect_after(m_widget, "next-month", + G_CALLBACK (gtk_prev_month_callback), + this); + g_signal_connect_after(m_widget, "prev-year", + G_CALLBACK (gtk_prev_year_callback), + this); + g_signal_connect_after(m_widget, "next-year", + G_CALLBACK (gtk_prev_year_callback), + this); + + m_parent->DoAddChild(this); + + PostCreation(size); + + return true; +} + +bool wxGtkCalendarCtrl::EnableMonthChange(bool enable) +{ + if ( !wxCalendarCtrlBase::EnableMonthChange(enable) ) + return false; + + g_object_set (G_OBJECT (m_widget), "no-month-change", !enable, NULL); + + return true; +} + +bool wxGtkCalendarCtrl::SetDate(const wxDateTime& date) +{ + int year = date.GetYear(); + int month = date.GetMonth(); + int day = date.GetDay(); + gtk_calendar_select_month(GTK_CALENDAR(m_widget), month, year); + gtk_calendar_select_day(GTK_CALENDAR(m_widget), day); + return true; +} + +wxDateTime wxGtkCalendarCtrl::GetDate() const +{ + guint year, month, day; + gtk_calendar_get_date(GTK_CALENDAR(m_widget), &year, &month, &day); + return wxDateTime(day, (wxDateTime::Month) month, year); +} + +void wxGtkCalendarCtrl::Mark(size_t day, bool mark) +{ + if (mark) + gtk_calendar_mark_day(GTK_CALENDAR(m_widget), day); + else + gtk_calendar_unmark_day(GTK_CALENDAR(m_widget), day); +} + +IMPLEMENT_DYNAMIC_CLASS(wxGtkCalendarCtrl, wxControl) + + +#endif // wxUSE_CALENDARCTRL