From 8957e55ed3292874c54db019be74ef152c962d96 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 29 Sep 2011 13:43:02 +0000 Subject: [PATCH 1/1] Refactor wxDatePickerCtrl to derive from wxDateTimePickerCtrl. No real changes, just refactor wxMSW wxDatePickerCtrl to allow sharing code with the upcoming wxTimePickerCtrl class. Even less changes for the other platforms where wxDateTimePickerCtrl is trivial. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@69222 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- Makefile.in | 34 ++++++++ build/bakefiles/files.bkl | 2 + build/msw/makefile.bcc | 16 ++++ build/msw/makefile.gcc | 16 ++++ build/msw/makefile.vc | 16 ++++ build/msw/makefile.wat | 16 ++++ build/msw/wx_adv.dsp | 39 +++++++++ build/msw/wx_core.dsp | 4 + build/msw/wx_vc7_adv.vcproj | 18 ++++ build/msw/wx_vc7_core.vcproj | 3 + build/msw/wx_vc8_adv.vcproj | 24 ++++++ build/msw/wx_vc8_core.vcproj | 4 + build/msw/wx_vc9_adv.vcproj | 24 ++++++ build/msw/wx_vc9_core.vcproj | 4 + include/wx/datectrl.h | 20 +++-- include/wx/datetimectrl.h | 48 +++++++++++ include/wx/msw/datectrl.h | 21 ++--- include/wx/msw/datetimectrl.h | 65 ++++++++++++++ src/msw/datectrl.cpp | 155 +++++----------------------------- src/msw/datetimectrl.cpp | 152 +++++++++++++++++++++++++++++++++ 20 files changed, 523 insertions(+), 158 deletions(-) create mode 100644 include/wx/datetimectrl.h create mode 100644 include/wx/msw/datetimectrl.h create mode 100644 src/msw/datetimectrl.cpp diff --git a/Makefile.in b/Makefile.in index 65c25a9077..1e58584aa2 100644 --- a/Makefile.in +++ b/Makefile.in @@ -3698,6 +3698,7 @@ COND_TOOLKIT_MSW_ADVANCED_PLATFORM_NATIVE_HDR = \ wx/msw/commandlinkbutton.h \ wx/msw/calctrl.h \ wx/msw/datectrl.h \ + wx/msw/datetimectrl.h \ wx/msw/hyperlink.h @COND_TOOLKIT_MSW@ADVANCED_PLATFORM_NATIVE_HDR = $(COND_TOOLKIT_MSW_ADVANCED_PLATFORM_NATIVE_HDR) COND_TOOLKIT_WINCE_ADVANCED_PLATFORM_NATIVE_HDR = \ @@ -3706,6 +3707,7 @@ COND_TOOLKIT_WINCE_ADVANCED_PLATFORM_NATIVE_HDR = \ wx/msw/commandlinkbutton.h \ wx/msw/calctrl.h \ wx/msw/datectrl.h \ + wx/msw/datetimectrl.h \ wx/msw/hyperlink.h @COND_TOOLKIT_WINCE@ADVANCED_PLATFORM_NATIVE_HDR = $(COND_TOOLKIT_WINCE_ADVANCED_PLATFORM_NATIVE_HDR) COND_WXUNIV_0_ADVANCED_HDR = \ @@ -6194,6 +6196,7 @@ COND_TOOLKIT_MSW___ADVANCED_PLATFORM_NATIVE_SRC_OBJECTS = \ monodll_commandlinkbutton.o \ monodll_datecontrols.o \ monodll_datectrl.o \ + monodll_datetimectrl.o \ monodll_msw_hyperlink.o @COND_TOOLKIT_MSW@__ADVANCED_PLATFORM_NATIVE_SRC_OBJECTS = $(COND_TOOLKIT_MSW___ADVANCED_PLATFORM_NATIVE_SRC_OBJECTS) COND_TOOLKIT_WINCE___ADVANCED_PLATFORM_NATIVE_SRC_OBJECTS = \ @@ -6203,6 +6206,7 @@ COND_TOOLKIT_WINCE___ADVANCED_PLATFORM_NATIVE_SRC_OBJECTS = \ monodll_commandlinkbutton.o \ monodll_datecontrols.o \ monodll_datectrl.o \ + monodll_datetimectrl.o \ monodll_msw_hyperlink.o @COND_TOOLKIT_WINCE@__ADVANCED_PLATFORM_NATIVE_SRC_OBJECTS = $(COND_TOOLKIT_WINCE___ADVANCED_PLATFORM_NATIVE_SRC_OBJECTS) @COND_TOOLKIT_COCOA@__MEDIA_PLATFORM_SRC_OBJECTS = \ @@ -8137,6 +8141,7 @@ COND_TOOLKIT_MSW___ADVANCED_PLATFORM_NATIVE_SRC_OBJECTS_1 = \ monolib_commandlinkbutton.o \ monolib_datecontrols.o \ monolib_datectrl.o \ + monolib_datetimectrl.o \ monolib_msw_hyperlink.o @COND_TOOLKIT_MSW@__ADVANCED_PLATFORM_NATIVE_SRC_OBJECTS_1 = $(COND_TOOLKIT_MSW___ADVANCED_PLATFORM_NATIVE_SRC_OBJECTS_1) COND_TOOLKIT_WINCE___ADVANCED_PLATFORM_NATIVE_SRC_OBJECTS_1 = \ @@ -8146,6 +8151,7 @@ COND_TOOLKIT_WINCE___ADVANCED_PLATFORM_NATIVE_SRC_OBJECTS_1 = \ monolib_commandlinkbutton.o \ monolib_datecontrols.o \ monolib_datectrl.o \ + monolib_datetimectrl.o \ monolib_msw_hyperlink.o @COND_TOOLKIT_WINCE@__ADVANCED_PLATFORM_NATIVE_SRC_OBJECTS_1 = $(COND_TOOLKIT_WINCE___ADVANCED_PLATFORM_NATIVE_SRC_OBJECTS_1) @COND_TOOLKIT_COCOA@__MEDIA_PLATFORM_SRC_OBJECTS_1 = \ @@ -11919,6 +11925,7 @@ COND_TOOLKIT_MSW___ADVANCED_PLATFORM_NATIVE_SRC_OBJECTS_2 = \ advdll_commandlinkbutton.o \ advdll_datecontrols.o \ advdll_datectrl.o \ + advdll_datetimectrl.o \ advdll_msw_hyperlink.o @COND_TOOLKIT_MSW@__ADVANCED_PLATFORM_NATIVE_SRC_OBJECTS_2 = $(COND_TOOLKIT_MSW___ADVANCED_PLATFORM_NATIVE_SRC_OBJECTS_2) COND_TOOLKIT_WINCE___ADVANCED_PLATFORM_NATIVE_SRC_OBJECTS_2 = \ @@ -11928,6 +11935,7 @@ COND_TOOLKIT_WINCE___ADVANCED_PLATFORM_NATIVE_SRC_OBJECTS_2 = \ advdll_commandlinkbutton.o \ advdll_datecontrols.o \ advdll_datectrl.o \ + advdll_datetimectrl.o \ advdll_msw_hyperlink.o @COND_TOOLKIT_WINCE@__ADVANCED_PLATFORM_NATIVE_SRC_OBJECTS_2 = $(COND_TOOLKIT_WINCE___ADVANCED_PLATFORM_NATIVE_SRC_OBJECTS_2) @COND_PLATFORM_UNIX_1_USE_PLUGINS_0@__PLUGIN_ADV_SRC_OBJECTS_2 \ @@ -12027,6 +12035,7 @@ COND_TOOLKIT_MSW___ADVANCED_PLATFORM_NATIVE_SRC_OBJECTS_3 = \ advlib_commandlinkbutton.o \ advlib_datecontrols.o \ advlib_datectrl.o \ + advlib_datetimectrl.o \ advlib_msw_hyperlink.o @COND_TOOLKIT_MSW@__ADVANCED_PLATFORM_NATIVE_SRC_OBJECTS_3 = $(COND_TOOLKIT_MSW___ADVANCED_PLATFORM_NATIVE_SRC_OBJECTS_3) COND_TOOLKIT_WINCE___ADVANCED_PLATFORM_NATIVE_SRC_OBJECTS_3 = \ @@ -12036,6 +12045,7 @@ COND_TOOLKIT_WINCE___ADVANCED_PLATFORM_NATIVE_SRC_OBJECTS_3 = \ advlib_commandlinkbutton.o \ advlib_datecontrols.o \ advlib_datectrl.o \ + advlib_datetimectrl.o \ advlib_msw_hyperlink.o @COND_TOOLKIT_WINCE@__ADVANCED_PLATFORM_NATIVE_SRC_OBJECTS_3 = $(COND_TOOLKIT_WINCE___ADVANCED_PLATFORM_NATIVE_SRC_OBJECTS_3) @COND_PLATFORM_UNIX_1_USE_PLUGINS_0@__PLUGIN_ADV_SRC_OBJECTS_3 \ @@ -20885,6 +20895,12 @@ monodll_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(MONODLL_ODEP) @COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@monodll_datectrl.o: $(srcdir)/src/msw/datectrl.cpp $(MONODLL_ODEP) @COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/msw/datectrl.cpp +@COND_TOOLKIT_MSW_USE_GUI_1_WXUNIV_0@monodll_datetimectrl.o: $(srcdir)/src/msw/datetimectrl.cpp $(MONODLL_ODEP) +@COND_TOOLKIT_MSW_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/msw/datetimectrl.cpp + +@COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@monodll_datetimectrl.o: $(srcdir)/src/msw/datetimectrl.cpp $(MONODLL_ODEP) +@COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/msw/datetimectrl.cpp + @COND_TOOLKIT_MSW_USE_GUI_1_WXUNIV_0@monodll_msw_hyperlink.o: $(srcdir)/src/msw/hyperlink.cpp $(MONODLL_ODEP) @COND_TOOLKIT_MSW_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/msw/hyperlink.cpp @@ -26234,6 +26250,12 @@ monolib_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(MONOLIB_ODEP) @COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@monolib_datectrl.o: $(srcdir)/src/msw/datectrl.cpp $(MONOLIB_ODEP) @COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/msw/datectrl.cpp +@COND_TOOLKIT_MSW_USE_GUI_1_WXUNIV_0@monolib_datetimectrl.o: $(srcdir)/src/msw/datetimectrl.cpp $(MONOLIB_ODEP) +@COND_TOOLKIT_MSW_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/msw/datetimectrl.cpp + +@COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@monolib_datetimectrl.o: $(srcdir)/src/msw/datetimectrl.cpp $(MONOLIB_ODEP) +@COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/msw/datetimectrl.cpp + @COND_TOOLKIT_MSW_USE_GUI_1_WXUNIV_0@monolib_msw_hyperlink.o: $(srcdir)/src/msw/hyperlink.cpp $(MONOLIB_ODEP) @COND_TOOLKIT_MSW_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/msw/hyperlink.cpp @@ -35777,6 +35799,12 @@ advdll_wizard.o: $(srcdir)/src/generic/wizard.cpp $(ADVDLL_ODEP) @COND_TOOLKIT_WINCE_WXUNIV_0@advdll_datectrl.o: $(srcdir)/src/msw/datectrl.cpp $(ADVDLL_ODEP) @COND_TOOLKIT_WINCE_WXUNIV_0@ $(CXXC) -c -o $@ $(ADVDLL_CXXFLAGS) $(srcdir)/src/msw/datectrl.cpp +@COND_TOOLKIT_MSW_WXUNIV_0@advdll_datetimectrl.o: $(srcdir)/src/msw/datetimectrl.cpp $(ADVDLL_ODEP) +@COND_TOOLKIT_MSW_WXUNIV_0@ $(CXXC) -c -o $@ $(ADVDLL_CXXFLAGS) $(srcdir)/src/msw/datetimectrl.cpp + +@COND_TOOLKIT_WINCE_WXUNIV_0@advdll_datetimectrl.o: $(srcdir)/src/msw/datetimectrl.cpp $(ADVDLL_ODEP) +@COND_TOOLKIT_WINCE_WXUNIV_0@ $(CXXC) -c -o $@ $(ADVDLL_CXXFLAGS) $(srcdir)/src/msw/datetimectrl.cpp + @COND_TOOLKIT_MSW_WXUNIV_0@advdll_msw_hyperlink.o: $(srcdir)/src/msw/hyperlink.cpp $(ADVDLL_ODEP) @COND_TOOLKIT_MSW_WXUNIV_0@ $(CXXC) -c -o $@ $(ADVDLL_CXXFLAGS) $(srcdir)/src/msw/hyperlink.cpp @@ -36137,6 +36165,12 @@ advlib_wizard.o: $(srcdir)/src/generic/wizard.cpp $(ADVLIB_ODEP) @COND_TOOLKIT_WINCE_WXUNIV_0@advlib_datectrl.o: $(srcdir)/src/msw/datectrl.cpp $(ADVLIB_ODEP) @COND_TOOLKIT_WINCE_WXUNIV_0@ $(CXXC) -c -o $@ $(ADVLIB_CXXFLAGS) $(srcdir)/src/msw/datectrl.cpp +@COND_TOOLKIT_MSW_WXUNIV_0@advlib_datetimectrl.o: $(srcdir)/src/msw/datetimectrl.cpp $(ADVLIB_ODEP) +@COND_TOOLKIT_MSW_WXUNIV_0@ $(CXXC) -c -o $@ $(ADVLIB_CXXFLAGS) $(srcdir)/src/msw/datetimectrl.cpp + +@COND_TOOLKIT_WINCE_WXUNIV_0@advlib_datetimectrl.o: $(srcdir)/src/msw/datetimectrl.cpp $(ADVLIB_ODEP) +@COND_TOOLKIT_WINCE_WXUNIV_0@ $(CXXC) -c -o $@ $(ADVLIB_CXXFLAGS) $(srcdir)/src/msw/datetimectrl.cpp + @COND_TOOLKIT_MSW_WXUNIV_0@advlib_msw_hyperlink.o: $(srcdir)/src/msw/hyperlink.cpp $(ADVLIB_ODEP) @COND_TOOLKIT_MSW_WXUNIV_0@ $(CXXC) -c -o $@ $(ADVLIB_CXXFLAGS) $(srcdir)/src/msw/hyperlink.cpp diff --git a/build/bakefiles/files.bkl b/build/bakefiles/files.bkl index 3a7fb6df0d..28e0f8d481 100644 --- a/build/bakefiles/files.bkl +++ b/build/bakefiles/files.bkl @@ -3048,6 +3048,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file! src/msw/commandlinkbutton.cpp src/msw/datecontrols.cpp src/msw/datectrl.cpp + src/msw/datetimectrl.cpp src/msw/hyperlink.cpp @@ -3056,6 +3057,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file! wx/msw/commandlinkbutton.h wx/msw/calctrl.h wx/msw/datectrl.h + wx/msw/datetimectrl.h wx/msw/hyperlink.h diff --git a/build/msw/makefile.bcc b/build/msw/makefile.bcc index 115f529e98..8936a1ce19 100644 --- a/build/msw/makefile.bcc +++ b/build/msw/makefile.bcc @@ -2295,6 +2295,7 @@ ____ADVANCED_SRC_FILENAMES_OBJECTS = \ $(OBJS)\monodll_commandlinkbutton.obj \ $(OBJS)\monodll_datecontrols.obj \ $(OBJS)\monodll_datectrl.obj \ + $(OBJS)\monodll_datetimectrl.obj \ $(OBJS)\monodll_hyperlink.obj !endif !if "$(WXUNIV)" == "1" @@ -3067,6 +3068,7 @@ ____ADVANCED_SRC_FILENAMES_1_OBJECTS = \ $(OBJS)\monolib_commandlinkbutton.obj \ $(OBJS)\monolib_datecontrols.obj \ $(OBJS)\monolib_datectrl.obj \ + $(OBJS)\monolib_datetimectrl.obj \ $(OBJS)\monolib_hyperlink.obj !endif !if "$(WXUNIV)" == "1" @@ -4275,6 +4277,7 @@ ____ADVANCED_SRC_FILENAMES_2_OBJECTS = \ $(OBJS)\advdll_commandlinkbutton.obj \ $(OBJS)\advdll_datecontrols.obj \ $(OBJS)\advdll_datectrl.obj \ + $(OBJS)\advdll_datetimectrl.obj \ $(OBJS)\advdll_hyperlink.obj !endif !if "$(WXUNIV)" == "1" @@ -4365,6 +4368,7 @@ ____ADVANCED_SRC_FILENAMES_3_OBJECTS = \ $(OBJS)\advlib_commandlinkbutton.obj \ $(OBJS)\advlib_datecontrols.obj \ $(OBJS)\advlib_datectrl.obj \ + $(OBJS)\advlib_datetimectrl.obj \ $(OBJS)\advlib_hyperlink.obj !endif !if "$(WXUNIV)" == "1" @@ -6694,6 +6698,9 @@ $(OBJS)\monodll_datecontrols.obj: ..\..\src\msw\datecontrols.cpp $(OBJS)\monodll_datectrl.obj: ..\..\src\msw\datectrl.cpp $(CXX) -q -c -P -o$@ $(MONODLL_CXXFLAGS) ..\..\src\msw\datectrl.cpp +$(OBJS)\monodll_datetimectrl.obj: ..\..\src\msw\datetimectrl.cpp + $(CXX) -q -c -P -o$@ $(MONODLL_CXXFLAGS) ..\..\src\msw\datetimectrl.cpp + $(OBJS)\monodll_hyperlink.obj: ..\..\src\msw\hyperlink.cpp $(CXX) -q -c -P -o$@ $(MONODLL_CXXFLAGS) ..\..\src\msw\hyperlink.cpp @@ -9067,6 +9074,9 @@ $(OBJS)\monolib_datecontrols.obj: ..\..\src\msw\datecontrols.cpp $(OBJS)\monolib_datectrl.obj: ..\..\src\msw\datectrl.cpp $(CXX) -q -c -P -o$@ $(MONOLIB_CXXFLAGS) ..\..\src\msw\datectrl.cpp +$(OBJS)\monolib_datetimectrl.obj: ..\..\src\msw\datetimectrl.cpp + $(CXX) -q -c -P -o$@ $(MONOLIB_CXXFLAGS) ..\..\src\msw\datetimectrl.cpp + $(OBJS)\monolib_hyperlink.obj: ..\..\src\msw\hyperlink.cpp $(CXX) -q -c -P -o$@ $(MONOLIB_CXXFLAGS) ..\..\src\msw\hyperlink.cpp @@ -14340,6 +14350,9 @@ $(OBJS)\advdll_datecontrols.obj: ..\..\src\msw\datecontrols.cpp $(OBJS)\advdll_datectrl.obj: ..\..\src\msw\datectrl.cpp $(CXX) -q -c -P -o$@ $(ADVDLL_CXXFLAGS) ..\..\src\msw\datectrl.cpp +$(OBJS)\advdll_datetimectrl.obj: ..\..\src\msw\datetimectrl.cpp + $(CXX) -q -c -P -o$@ $(ADVDLL_CXXFLAGS) ..\..\src\msw\datetimectrl.cpp + $(OBJS)\advdll_hyperlink.obj: ..\..\src\msw\hyperlink.cpp $(CXX) -q -c -P -o$@ $(ADVDLL_CXXFLAGS) ..\..\src\msw\hyperlink.cpp @@ -14472,6 +14485,9 @@ $(OBJS)\advlib_datecontrols.obj: ..\..\src\msw\datecontrols.cpp $(OBJS)\advlib_datectrl.obj: ..\..\src\msw\datectrl.cpp $(CXX) -q -c -P -o$@ $(ADVLIB_CXXFLAGS) ..\..\src\msw\datectrl.cpp +$(OBJS)\advlib_datetimectrl.obj: ..\..\src\msw\datetimectrl.cpp + $(CXX) -q -c -P -o$@ $(ADVLIB_CXXFLAGS) ..\..\src\msw\datetimectrl.cpp + $(OBJS)\advlib_hyperlink.obj: ..\..\src\msw\hyperlink.cpp $(CXX) -q -c -P -o$@ $(ADVLIB_CXXFLAGS) ..\..\src\msw\hyperlink.cpp diff --git a/build/msw/makefile.gcc b/build/msw/makefile.gcc index 20a8881774..bee702f499 100644 --- a/build/msw/makefile.gcc +++ b/build/msw/makefile.gcc @@ -2310,6 +2310,7 @@ ____ADVANCED_SRC_FILENAMES_OBJECTS = \ $(OBJS)\monodll_commandlinkbutton.o \ $(OBJS)\monodll_datecontrols.o \ $(OBJS)\monodll_datectrl.o \ + $(OBJS)\monodll_datetimectrl.o \ $(OBJS)\monodll_hyperlink.o endif ifeq ($(WXUNIV),1) @@ -3088,6 +3089,7 @@ ____ADVANCED_SRC_FILENAMES_1_OBJECTS = \ $(OBJS)\monolib_commandlinkbutton.o \ $(OBJS)\monolib_datecontrols.o \ $(OBJS)\monolib_datectrl.o \ + $(OBJS)\monolib_datetimectrl.o \ $(OBJS)\monolib_hyperlink.o endif ifeq ($(WXUNIV),1) @@ -4324,6 +4326,7 @@ ____ADVANCED_SRC_FILENAMES_2_OBJECTS = \ $(OBJS)\advdll_commandlinkbutton.o \ $(OBJS)\advdll_datecontrols.o \ $(OBJS)\advdll_datectrl.o \ + $(OBJS)\advdll_datetimectrl.o \ $(OBJS)\advdll_hyperlink.o endif ifeq ($(WXUNIV),1) @@ -4418,6 +4421,7 @@ ____ADVANCED_SRC_FILENAMES_3_OBJECTS = \ $(OBJS)\advlib_commandlinkbutton.o \ $(OBJS)\advlib_datecontrols.o \ $(OBJS)\advlib_datectrl.o \ + $(OBJS)\advlib_datetimectrl.o \ $(OBJS)\advlib_hyperlink.o endif ifeq ($(WXUNIV),1) @@ -6862,6 +6866,9 @@ $(OBJS)\monodll_datecontrols.o: ../../src/msw/datecontrols.cpp $(OBJS)\monodll_datectrl.o: ../../src/msw/datectrl.cpp $(CXX) -c -o $@ $(MONODLL_CXXFLAGS) $(CPPDEPS) $< +$(OBJS)\monodll_datetimectrl.o: ../../src/msw/datetimectrl.cpp + $(CXX) -c -o $@ $(MONODLL_CXXFLAGS) $(CPPDEPS) $< + $(OBJS)\monodll_hyperlink.o: ../../src/msw/hyperlink.cpp $(CXX) -c -o $@ $(MONODLL_CXXFLAGS) $(CPPDEPS) $< @@ -9235,6 +9242,9 @@ $(OBJS)\monolib_datecontrols.o: ../../src/msw/datecontrols.cpp $(OBJS)\monolib_datectrl.o: ../../src/msw/datectrl.cpp $(CXX) -c -o $@ $(MONOLIB_CXXFLAGS) $(CPPDEPS) $< +$(OBJS)\monolib_datetimectrl.o: ../../src/msw/datetimectrl.cpp + $(CXX) -c -o $@ $(MONOLIB_CXXFLAGS) $(CPPDEPS) $< + $(OBJS)\monolib_hyperlink.o: ../../src/msw/hyperlink.cpp $(CXX) -c -o $@ $(MONOLIB_CXXFLAGS) $(CPPDEPS) $< @@ -14508,6 +14518,9 @@ $(OBJS)\advdll_datecontrols.o: ../../src/msw/datecontrols.cpp $(OBJS)\advdll_datectrl.o: ../../src/msw/datectrl.cpp $(CXX) -c -o $@ $(ADVDLL_CXXFLAGS) $(CPPDEPS) $< +$(OBJS)\advdll_datetimectrl.o: ../../src/msw/datetimectrl.cpp + $(CXX) -c -o $@ $(ADVDLL_CXXFLAGS) $(CPPDEPS) $< + $(OBJS)\advdll_hyperlink.o: ../../src/msw/hyperlink.cpp $(CXX) -c -o $@ $(ADVDLL_CXXFLAGS) $(CPPDEPS) $< @@ -14640,6 +14653,9 @@ $(OBJS)\advlib_datecontrols.o: ../../src/msw/datecontrols.cpp $(OBJS)\advlib_datectrl.o: ../../src/msw/datectrl.cpp $(CXX) -c -o $@ $(ADVLIB_CXXFLAGS) $(CPPDEPS) $< +$(OBJS)\advlib_datetimectrl.o: ../../src/msw/datetimectrl.cpp + $(CXX) -c -o $@ $(ADVLIB_CXXFLAGS) $(CPPDEPS) $< + $(OBJS)\advlib_hyperlink.o: ../../src/msw/hyperlink.cpp $(CXX) -c -o $@ $(ADVLIB_CXXFLAGS) $(CPPDEPS) $< diff --git a/build/msw/makefile.vc b/build/msw/makefile.vc index cf1b6b7a30..b87655973a 100644 --- a/build/msw/makefile.vc +++ b/build/msw/makefile.vc @@ -2509,6 +2509,7 @@ ____ADVANCED_SRC_FILENAMES_OBJECTS = \ $(OBJS)\monodll_commandlinkbutton.obj \ $(OBJS)\monodll_datecontrols.obj \ $(OBJS)\monodll_datectrl.obj \ + $(OBJS)\monodll_datetimectrl.obj \ $(OBJS)\monodll_hyperlink.obj !endif !if "$(WXUNIV)" == "1" @@ -3287,6 +3288,7 @@ ____ADVANCED_SRC_FILENAMES_1_OBJECTS = \ $(OBJS)\monolib_commandlinkbutton.obj \ $(OBJS)\monolib_datecontrols.obj \ $(OBJS)\monolib_datectrl.obj \ + $(OBJS)\monolib_datetimectrl.obj \ $(OBJS)\monolib_hyperlink.obj !endif !if "$(WXUNIV)" == "1" @@ -4585,6 +4587,7 @@ ____ADVANCED_SRC_FILENAMES_2_OBJECTS = \ $(OBJS)\advdll_commandlinkbutton.obj \ $(OBJS)\advdll_datecontrols.obj \ $(OBJS)\advdll_datectrl.obj \ + $(OBJS)\advdll_datetimectrl.obj \ $(OBJS)\advdll_hyperlink.obj !endif !if "$(WXUNIV)" == "1" @@ -4681,6 +4684,7 @@ ____ADVANCED_SRC_FILENAMES_3_OBJECTS = \ $(OBJS)\advlib_commandlinkbutton.obj \ $(OBJS)\advlib_datecontrols.obj \ $(OBJS)\advlib_datectrl.obj \ + $(OBJS)\advlib_datetimectrl.obj \ $(OBJS)\advlib_hyperlink.obj !endif !if "$(WXUNIV)" == "1" @@ -7300,6 +7304,9 @@ $(OBJS)\monodll_datecontrols.obj: ..\..\src\msw\datecontrols.cpp $(OBJS)\monodll_datectrl.obj: ..\..\src\msw\datectrl.cpp $(CXX) /c /nologo /TP /Fo$@ $(MONODLL_CXXFLAGS) ..\..\src\msw\datectrl.cpp +$(OBJS)\monodll_datetimectrl.obj: ..\..\src\msw\datetimectrl.cpp + $(CXX) /c /nologo /TP /Fo$@ $(MONODLL_CXXFLAGS) ..\..\src\msw\datetimectrl.cpp + $(OBJS)\monodll_hyperlink.obj: ..\..\src\msw\hyperlink.cpp $(CXX) /c /nologo /TP /Fo$@ $(MONODLL_CXXFLAGS) ..\..\src\msw\hyperlink.cpp @@ -9673,6 +9680,9 @@ $(OBJS)\monolib_datecontrols.obj: ..\..\src\msw\datecontrols.cpp $(OBJS)\monolib_datectrl.obj: ..\..\src\msw\datectrl.cpp $(CXX) /c /nologo /TP /Fo$@ $(MONOLIB_CXXFLAGS) ..\..\src\msw\datectrl.cpp +$(OBJS)\monolib_datetimectrl.obj: ..\..\src\msw\datetimectrl.cpp + $(CXX) /c /nologo /TP /Fo$@ $(MONOLIB_CXXFLAGS) ..\..\src\msw\datetimectrl.cpp + $(OBJS)\monolib_hyperlink.obj: ..\..\src\msw\hyperlink.cpp $(CXX) /c /nologo /TP /Fo$@ $(MONOLIB_CXXFLAGS) ..\..\src\msw\hyperlink.cpp @@ -14946,6 +14956,9 @@ $(OBJS)\advdll_datecontrols.obj: ..\..\src\msw\datecontrols.cpp $(OBJS)\advdll_datectrl.obj: ..\..\src\msw\datectrl.cpp $(CXX) /c /nologo /TP /Fo$@ $(ADVDLL_CXXFLAGS) ..\..\src\msw\datectrl.cpp +$(OBJS)\advdll_datetimectrl.obj: ..\..\src\msw\datetimectrl.cpp + $(CXX) /c /nologo /TP /Fo$@ $(ADVDLL_CXXFLAGS) ..\..\src\msw\datetimectrl.cpp + $(OBJS)\advdll_hyperlink.obj: ..\..\src\msw\hyperlink.cpp $(CXX) /c /nologo /TP /Fo$@ $(ADVDLL_CXXFLAGS) ..\..\src\msw\hyperlink.cpp @@ -15078,6 +15091,9 @@ $(OBJS)\advlib_datecontrols.obj: ..\..\src\msw\datecontrols.cpp $(OBJS)\advlib_datectrl.obj: ..\..\src\msw\datectrl.cpp $(CXX) /c /nologo /TP /Fo$@ $(ADVLIB_CXXFLAGS) ..\..\src\msw\datectrl.cpp +$(OBJS)\advlib_datetimectrl.obj: ..\..\src\msw\datetimectrl.cpp + $(CXX) /c /nologo /TP /Fo$@ $(ADVLIB_CXXFLAGS) ..\..\src\msw\datetimectrl.cpp + $(OBJS)\advlib_hyperlink.obj: ..\..\src\msw\hyperlink.cpp $(CXX) /c /nologo /TP /Fo$@ $(ADVLIB_CXXFLAGS) ..\..\src\msw\hyperlink.cpp diff --git a/build/msw/makefile.wat b/build/msw/makefile.wat index 7df5936e28..75e6d3b581 100644 --- a/build/msw/makefile.wat +++ b/build/msw/makefile.wat @@ -830,6 +830,7 @@ ____ADVANCED_SRC_FILENAMES_OBJECTS = & $(OBJS)\monodll_commandlinkbutton.obj & $(OBJS)\monodll_datecontrols.obj & $(OBJS)\monodll_datectrl.obj & + $(OBJS)\monodll_datetimectrl.obj & $(OBJS)\monodll_hyperlink.obj !endif !ifeq WXUNIV 1 @@ -1613,6 +1614,7 @@ ____ADVANCED_SRC_FILENAMES_1_OBJECTS = & $(OBJS)\monolib_commandlinkbutton.obj & $(OBJS)\monolib_datecontrols.obj & $(OBJS)\monolib_datectrl.obj & + $(OBJS)\monolib_datetimectrl.obj & $(OBJS)\monolib_hyperlink.obj !endif !ifeq WXUNIV 1 @@ -2865,6 +2867,7 @@ ____ADVANCED_SRC_FILENAMES_2_OBJECTS = & $(OBJS)\advdll_commandlinkbutton.obj & $(OBJS)\advdll_datecontrols.obj & $(OBJS)\advdll_datectrl.obj & + $(OBJS)\advdll_datetimectrl.obj & $(OBJS)\advdll_hyperlink.obj !endif !ifeq WXUNIV 1 @@ -2961,6 +2964,7 @@ ____ADVANCED_SRC_FILENAMES_3_OBJECTS = & $(OBJS)\advlib_commandlinkbutton.obj & $(OBJS)\advlib_datecontrols.obj & $(OBJS)\advlib_datectrl.obj & + $(OBJS)\advlib_datetimectrl.obj & $(OBJS)\advlib_hyperlink.obj !endif !ifeq WXUNIV 1 @@ -7133,6 +7137,9 @@ $(OBJS)\monodll_datecontrols.obj : .AUTODEPEND ..\..\src\msw\datecontrols.cpp $(OBJS)\monodll_datectrl.obj : .AUTODEPEND ..\..\src\msw\datectrl.cpp $(CXX) -bt=nt -zq -fo=$^@ $(MONODLL_CXXFLAGS) $< +$(OBJS)\monodll_datetimectrl.obj : .AUTODEPEND ..\..\src\msw\datetimectrl.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(MONODLL_CXXFLAGS) $< + $(OBJS)\monodll_hyperlink.obj : .AUTODEPEND ..\..\src\msw\hyperlink.cpp $(CXX) -bt=nt -zq -fo=$^@ $(MONODLL_CXXFLAGS) $< @@ -9506,6 +9513,9 @@ $(OBJS)\monolib_datecontrols.obj : .AUTODEPEND ..\..\src\msw\datecontrols.cpp $(OBJS)\monolib_datectrl.obj : .AUTODEPEND ..\..\src\msw\datectrl.cpp $(CXX) -bt=nt -zq -fo=$^@ $(MONOLIB_CXXFLAGS) $< +$(OBJS)\monolib_datetimectrl.obj : .AUTODEPEND ..\..\src\msw\datetimectrl.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(MONOLIB_CXXFLAGS) $< + $(OBJS)\monolib_hyperlink.obj : .AUTODEPEND ..\..\src\msw\hyperlink.cpp $(CXX) -bt=nt -zq -fo=$^@ $(MONOLIB_CXXFLAGS) $< @@ -14779,6 +14789,9 @@ $(OBJS)\advdll_datecontrols.obj : .AUTODEPEND ..\..\src\msw\datecontrols.cpp $(OBJS)\advdll_datectrl.obj : .AUTODEPEND ..\..\src\msw\datectrl.cpp $(CXX) -bt=nt -zq -fo=$^@ $(ADVDLL_CXXFLAGS) $< +$(OBJS)\advdll_datetimectrl.obj : .AUTODEPEND ..\..\src\msw\datetimectrl.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(ADVDLL_CXXFLAGS) $< + $(OBJS)\advdll_hyperlink.obj : .AUTODEPEND ..\..\src\msw\hyperlink.cpp $(CXX) -bt=nt -zq -fo=$^@ $(ADVDLL_CXXFLAGS) $< @@ -14911,6 +14924,9 @@ $(OBJS)\advlib_datecontrols.obj : .AUTODEPEND ..\..\src\msw\datecontrols.cpp $(OBJS)\advlib_datectrl.obj : .AUTODEPEND ..\..\src\msw\datectrl.cpp $(CXX) -bt=nt -zq -fo=$^@ $(ADVLIB_CXXFLAGS) $< +$(OBJS)\advlib_datetimectrl.obj : .AUTODEPEND ..\..\src\msw\datetimectrl.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(ADVLIB_CXXFLAGS) $< + $(OBJS)\advlib_hyperlink.obj : .AUTODEPEND ..\..\src\msw\hyperlink.cpp $(CXX) -bt=nt -zq -fo=$^@ $(ADVLIB_CXXFLAGS) $< diff --git a/build/msw/wx_adv.dsp b/build/msw/wx_adv.dsp index 7b4632fa04..b19a99847d 100644 --- a/build/msw/wx_adv.dsp +++ b/build/msw/wx_adv.dsp @@ -465,6 +465,41 @@ SOURCE=..\..\src\msw\datectrl.cpp # End Source File # Begin Source File +SOURCE=..\..\src\msw\datetimectrl.cpp + +!IF "$(CFG)" == "adv - Win32 DLL Universal Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "adv - Win32 DLL Universal Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "adv - Win32 DLL Release" + + +!ELSEIF "$(CFG)" == "adv - Win32 DLL Debug" + + +!ELSEIF "$(CFG)" == "adv - Win32 Universal Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "adv - Win32 Universal Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "adv - Win32 Release" + + +!ELSEIF "$(CFG)" == "adv - Win32 Debug" + + +!ENDIF + +# End Source File +# Begin Source File + SOURCE=..\..\src\msw\hyperlink.cpp !IF "$(CFG)" == "adv - Win32 DLL Universal Release" @@ -817,6 +852,10 @@ SOURCE=..\..\include\wx\msw\datectrl.h # End Source File # Begin Source File +SOURCE=..\..\include\wx\msw\datetimectrl.h +# End Source File +# Begin Source File + SOURCE=..\..\include\wx\msw\genrcdefs.h !IF "$(CFG)" == "adv - Win32 DLL Universal Release" diff --git a/build/msw/wx_core.dsp b/build/msw/wx_core.dsp index 2d554d77b2..467e05c009 100644 --- a/build/msw/wx_core.dsp +++ b/build/msw/wx_core.dsp @@ -5025,6 +5025,10 @@ SOURCE=..\..\include\wx\msw\datectrl.h # End Source File # Begin Source File +SOURCE=..\..\include\wx\msw\datetimectrl.h +# End Source File +# Begin Source File + SOURCE=..\..\include\wx\msw\dc.h # End Source File # Begin Source File diff --git a/build/msw/wx_vc7_adv.vcproj b/build/msw/wx_vc7_adv.vcproj index efd6dce9da..a55f1b3700 100644 --- a/build/msw/wx_vc7_adv.vcproj +++ b/build/msw/wx_vc7_adv.vcproj @@ -686,6 +686,21 @@ ExcludedFromBuild="TRUE"/> + + + + + + + + diff --git a/build/msw/wx_vc7_core.vcproj b/build/msw/wx_vc7_core.vcproj index 2bf160f215..ee5dfe323e 100644 --- a/build/msw/wx_vc7_core.vcproj +++ b/build/msw/wx_vc7_core.vcproj @@ -4331,6 +4331,9 @@ RelativePath="..\..\include\wx\msw\datectrl.h"> + + + + + + + + + + + + diff --git a/build/msw/wx_vc9_adv.vcproj b/build/msw/wx_vc9_adv.vcproj index 91dd723c2a..598252c315 100644 --- a/build/msw/wx_vc9_adv.vcproj +++ b/build/msw/wx_vc9_adv.vcproj @@ -944,6 +944,26 @@ /> + + + + + + + + + + diff --git a/include/wx/datectrl.h b/include/wx/datectrl.h index 822902f062..d666a59a10 100644 --- a/include/wx/datectrl.h +++ b/include/wx/datectrl.h @@ -16,8 +16,7 @@ #if wxUSE_DATEPICKCTRL -#include "wx/control.h" // the base class -#include "wx/datetime.h" +#include "wx/datetimectrl.h" // the base class #define wxDatePickerCtrlNameStr wxT("datectrl") @@ -46,7 +45,7 @@ enum // wxDatePickerCtrl: allow the user to enter the date // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_ADV wxDatePickerCtrlBase : public wxControl +class WXDLLIMPEXP_ADV wxDatePickerCtrlBase : public wxDateTimePickerCtrl { public: /* @@ -63,13 +62,16 @@ public: const wxString& name = wxDatePickerCtrlNameStr); */ - // set/get the date - virtual void SetValue(const wxDateTime& dt) = 0; - virtual wxDateTime GetValue() const = 0; + /* + We inherit the methods to set/get the date from the base class. + + virtual void SetValue(const wxDateTime& dt) = 0; + virtual wxDateTime GetValue() const = 0; + */ - // set/get the allowed valid range for the dates, if either/both of them - // are invalid, there is no corresponding limit and if neither is set - // GetRange() returns false + // And add methods to set/get the allowed valid range for the dates. If + // either/both of them are invalid, there is no corresponding limit and if + // neither is set, GetRange() returns false. virtual void SetRange(const wxDateTime& dt1, const wxDateTime& dt2) = 0; virtual bool GetRange(wxDateTime *dt1, wxDateTime *dt2) const = 0; }; diff --git a/include/wx/datetimectrl.h b/include/wx/datetimectrl.h new file mode 100644 index 0000000000..90da113f99 --- /dev/null +++ b/include/wx/datetimectrl.h @@ -0,0 +1,48 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: wx/timectrl.h +// Purpose: Declaration of wxDateTimePickerCtrl class. +// Author: Vadim Zeitlin +// Created: 2011-09-22 +// RCS-ID: $Id: wxhead.h,v 1.12 2010-04-22 12:44:51 zeitlin Exp $ +// Copyright: (c) 2011 Vadim Zeitlin +// Licence: wxWindows licence +/////////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_DATETIME_CTRL_H_ +#define _WX_DATETIME_CTRL_H_ + +#include "wx/defs.h" + +#if wxUSE_DATEPICKCTRL + +#define wxNEEDS_DATETIMEPICKCTRL + +#include "wx/control.h" // the base class + +#include "wx/datetime.h" + +// ---------------------------------------------------------------------------- +// wxDateTimePickerCtrl: Private common base class of wx{Date,Time}PickerCtrl. +// ---------------------------------------------------------------------------- + +// This class is an implementation detail and should not be used directly, only +// use the documented API of wxDateTimePickerCtrl and wxTimePickerCtrl. +class WXDLLIMPEXP_ADV wxDateTimePickerCtrlBase : public wxControl +{ +public: + // Set/get the date or time (in the latter case, time part is ignored). + virtual void SetValue(const wxDateTime& dt) = 0; + virtual wxDateTime GetValue() const = 0; +}; + +// Only MSW currently has any code to share between wxDatePickerCtrl and +// wxTimePickerCtrl, under the other platforms this class is trivial. +#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) + #include "wx/msw/datetimectrl.h" +#else + typedef wxDateTimePickerCtrlBase wxDateTimePickerCtrl; +#endif + +#endif // wxUSE_DATEPICKCTRL + +#endif // _WX_DATETIME_CTRL_H_ diff --git a/include/wx/msw/datectrl.h b/include/wx/msw/datectrl.h index b92a88ea38..f4b5b3d242 100644 --- a/include/wx/msw/datectrl.h +++ b/include/wx/msw/datectrl.h @@ -43,30 +43,21 @@ public: const wxValidator& validator = wxDefaultValidator, const wxString& name = wxDatePickerCtrlNameStr); - // set/get the date + // Override this one to add date-specific (and time-ignoring) checks. virtual void SetValue(const wxDateTime& dt); virtual wxDateTime GetValue() const; - // set/get the allowed valid range for the dates, if either/both of them - // are invalid, there is no corresponding limit and if neither is set - // GetRange() returns false + // Implement the base class pure virtuals. virtual void SetRange(const wxDateTime& dt1, const wxDateTime& dt2); virtual bool GetRange(wxDateTime *dt1, wxDateTime *dt2) const; + // Override MSW-specific functions used during control creation. virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const; - virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result); - - // returns true if the platform should explicitly apply a theme border - virtual bool CanApplyThemeBorder() const { return false; } - protected: - virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; } - virtual wxSize DoGetBestSize() const; - - // the date currently shown by the control, may be invalid - wxDateTime m_date; - + virtual wxLocaleInfo MSWGetFormat() const; + virtual bool MSWAllowsNone() const { return HasFlag(wxDP_ALLOWNONE); } + virtual bool MSWOnDateTimeChange(const tagNMDATETIMECHANGE& dtch); DECLARE_DYNAMIC_CLASS_NO_COPY(wxDatePickerCtrl) }; diff --git a/include/wx/msw/datetimectrl.h b/include/wx/msw/datetimectrl.h new file mode 100644 index 0000000000..1efcaa242c --- /dev/null +++ b/include/wx/msw/datetimectrl.h @@ -0,0 +1,65 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: wx/msw/datetimectrl.h +// Purpose: wxDateTimePickerCtrl for Windows. +// Author: Vadim Zeitlin +// Created: 2011-09-22 (extracted from wx/msw/datectrl.h). +// RCS-ID: $Id$ +// Copyright: (c) 2005-2011 Vadim Zeitlin +// Licence: wxWindows licence +/////////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_MSW_DATETIMECTRL_H_ +#define _WX_MSW_DATETIMECTRL_H_ + +#include "wx/intl.h" + +// Forward declare a struct from Platform SDK. +struct tagNMDATETIMECHANGE; + +// ---------------------------------------------------------------------------- +// wxDateTimePickerCtrl +// ---------------------------------------------------------------------------- + +class WXDLLIMPEXP_ADV wxDateTimePickerCtrl : public wxDateTimePickerCtrlBase +{ +public: + // set/get the date + virtual void SetValue(const wxDateTime& dt); + virtual wxDateTime GetValue() const; + + // returns true if the platform should explicitly apply a theme border + virtual bool CanApplyThemeBorder() const { return false; } + + virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result); + +protected: + virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; } + virtual wxSize DoGetBestSize() const; + + // Helper for the derived classes Create(): creates a native control with + // the specified attributes. + bool MSWCreateDateTimePicker(wxWindow *parent, + wxWindowID id, + const wxDateTime& dt, + const wxPoint& pos, + const wxSize& size, + long style, + const wxValidator& validator, + const wxString& name); + + // Override to return the date/time format used by this control. + virtual wxLocaleInfo MSWGetFormat() const = 0; + + // Override to indicate whether we can have no date at all. + virtual bool MSWAllowsNone() const = 0; + + // Override to update m_date and send the event when the control contents + // changes, return true if the event was handled. + virtual bool MSWOnDateTimeChange(const tagNMDATETIMECHANGE& dtch) = 0; + + + // the date currently shown by the control, may be invalid + wxDateTime m_date; +}; + +#endif // _WX_MSW_DATETIMECTRL_H_ diff --git a/src/msw/datectrl.cpp b/src/msw/datectrl.cpp index c544e32251..02de59289b 100644 --- a/src/msw/datectrl.cpp +++ b/src/msw/datectrl.cpp @@ -36,20 +36,8 @@ #endif #include "wx/datectrl.h" - -#include "wx/msw/private/datecontrols.h" - #include "wx/dateevt.h" -// apparently some versions of mingw define these macros erroneously -#ifndef DateTime_GetSystemtime - #define DateTime_GetSystemtime DateTime_GetSystemTime -#endif - -#ifndef DateTime_SetSystemtime - #define DateTime_SetSystemtime DateTime_SetSystemTime -#endif - IMPLEMENT_DYNAMIC_CLASS(wxDatePickerCtrl, wxControl) // ============================================================================ @@ -70,27 +58,13 @@ wxDatePickerCtrl::Create(wxWindow *parent, const wxValidator& validator, const wxString& name) { - if ( !wxMSWDateControls::CheckInitialization() ) - return false; - // use wxDP_SPIN if wxDP_DEFAULT (0) was given as style if ( !(style & wxDP_DROPDOWN) ) style |= wxDP_SPIN; - // initialize the base class - if ( !CreateControl(parent, id, pos, size, style, validator, name) ) - return false; - - // create the native control - if ( !MSWCreateControl(DATETIMEPICK_CLASS, wxEmptyString, pos, size) ) - return false; - - if ( dt.IsValid() || (style & wxDP_ALLOWNONE) ) - SetValue(dt); - else - SetValue(wxDateTime::Today()); - - return true; + return MSWCreateDateTimePicker(parent, id, dt, + pos, size, style, + validator, name); } WXDWORD wxDatePickerCtrl::MSWGetStyle(long style, WXDWORD *exstyle) const @@ -118,63 +92,9 @@ WXDWORD wxDatePickerCtrl::MSWGetStyle(long style, WXDWORD *exstyle) const // TODO: handle WM_WININICHANGE -// ---------------------------------------------------------------------------- -// wxDatePickerCtrl geometry -// ---------------------------------------------------------------------------- - -wxSize wxDatePickerCtrl::DoGetBestSize() const +wxLocaleInfo wxDatePickerCtrl::MSWGetFormat() const { - wxClientDC dc(const_cast(this)); - - // we can't use FormatDate() here as the CRT doesn't always use the same - // format as the date picker control - wxString s; - for ( int len = 100; ; len *= 2 ) - { - if ( ::GetDateFormat - ( - LOCALE_USER_DEFAULT, // the control should use the same - DATE_SHORTDATE, // the format used by the control - NULL, // use current date (we don't care) - NULL, // no custom format - wxStringBuffer(s, len), // output buffer - len // and its length - ) ) - { - // success - break; - } - - const DWORD rc = ::GetLastError(); - if ( rc != ERROR_INSUFFICIENT_BUFFER ) - { - wxLogApiError(wxT("GetDateFormat"), rc); - - // fall back on wxDateTime, what else to do? - s = wxDateTime::Today().FormatDate(); - break; - } - } - - // the best size for the control is bigger than just the string - // representation of todays date because the control must accommodate any - // date and while the widths of all digits are usually about the same, the - // width of the month string varies a lot, so try to account for it - s += wxT("WW"); - - int x, y; - dc.GetTextExtent(s, &x, &y); - - // account for the drop-down arrow or spin arrows - x += wxSystemSettings::GetMetric(wxSYS_HSCROLL_ARROW_X); - - // and for the checkbox if we have it - if ( HasFlag(wxDP_ALLOWNONE) ) - x += 3*GetCharWidth(); - - wxSize best(x, EDIT_HEIGHT_FROM_CHAR_HEIGHT(y)); - CacheBestSize(best); - return best; + return wxLOCALE_SHORT_DATE_FMT; } // ---------------------------------------------------------------------------- @@ -183,10 +103,6 @@ wxSize wxDatePickerCtrl::DoGetBestSize() const void wxDatePickerCtrl::SetValue(const wxDateTime& dt) { - wxCHECK_RET( dt.IsValid() || HasFlag(wxDP_ALLOWNONE), - wxT("this control requires a valid date") ); - - SYSTEMTIME st; if ( dt.IsValid() ) { // Don't try setting the date if it's out of range: calendar control @@ -209,25 +125,12 @@ void wxDatePickerCtrl::SetValue(const wxDateTime& dt) // out of range value simply doing nothing -- so don't. return; } - - dt.GetAsMSWSysTime(&st); } - if ( !DateTime_SetSystemtime(GetHwnd(), - dt.IsValid() ? GDT_VALID : GDT_NONE, - &st) ) - { - // The only expected failure is when the date is out of range but we - // already checked for this above. - wxFAIL_MSG( wxT("Setting the calendar date unexpectedly failed.") ); - - // In any case, skip updating m_date below. - return; - } + wxDateTimePickerCtrl::SetValue(dt); // we need to keep only the date part, times don't make sense for this // control (in particular, comparisons with other dates would fail) - m_date = dt; if ( m_date.IsValid() ) m_date.ResetTime(); } @@ -244,10 +147,10 @@ wxDateTime wxDatePickerCtrl::GetValue() const wxASSERT_MSG( m_date.IsValid() == dt.IsValid() && (!dt.IsValid() || dt == m_date), - wxT("bug in wxDatePickerCtrl: m_date not in sync") ); + wxT("bug in wxDateTimePickerCtrl: m_date not in sync") ); #endif // wxDEBUG_LEVEL - return m_date; + return wxDateTimePickerCtrl::GetValue(); } void wxDatePickerCtrl::SetRange(const wxDateTime& dt1, const wxDateTime& dt2) @@ -301,37 +204,21 @@ bool wxDatePickerCtrl::GetRange(wxDateTime *dt1, wxDateTime *dt2) const // wxDatePickerCtrl events // ---------------------------------------------------------------------------- -bool -wxDatePickerCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) +bool wxDatePickerCtrl::MSWOnDateTimeChange(const NMDATETIMECHANGE& dtch) { - NMHDR* hdr = (NMHDR *)lParam; - switch ( hdr->code ) - { - case DTN_DATETIMECHANGE: - { - NMDATETIMECHANGE *dtch = (NMDATETIMECHANGE *)hdr; - wxDateTime dt; - if ( dtch->dwFlags == GDT_VALID ) - dt.SetFromMSWSysDate(dtch->st); - - // filter out duplicate DTN_DATETIMECHANGE events which the native - // control sends us when using wxDP_DROPDOWN style - if ( (m_date.IsValid() != dt.IsValid()) || - (m_date.IsValid() && dt != m_date) ) - { - m_date = dt; - wxDateEvent event(this, dt, wxEVT_DATE_CHANGED); - if ( HandleWindowEvent(event) ) - { - *result = 0; - return true; - } - } - //else: both the old and new values are invalid, nothing changed - } - } + wxDateTime dt; + if ( dtch.dwFlags == GDT_VALID ) + dt.SetFromMSWSysDate(dtch.st); - return wxDatePickerCtrlBase::MSWOnNotify(idCtrl, lParam, result); + // filter out duplicate DTN_DATETIMECHANGE events which the native + // control sends us when using wxDP_DROPDOWN style + if ( (m_date.IsValid() == dt.IsValid()) && + (!m_date.IsValid() || dt == m_date) ) + return false; + + m_date = dt; + wxDateEvent event(this, dt, wxEVT_DATE_CHANGED); + return HandleWindowEvent(event); } #endif // wxUSE_DATEPICKCTRL diff --git a/src/msw/datetimectrl.cpp b/src/msw/datetimectrl.cpp new file mode 100644 index 0000000000..a20149cb7a --- /dev/null +++ b/src/msw/datetimectrl.cpp @@ -0,0 +1,152 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: src/msw/datetimectrl.cpp +// Purpose: Implementation of wxDateTimePickerCtrl for MSW. +// Author: Vadim Zeitlin +// Created: 2011-09-22 (extracted from src/msw/datectrl.cpp) +// RCS-ID: $Id: wxhead.cpp,v 1.11 2010-04-22 12:44:51 zeitlin Exp $ +// Copyright: (c) 2005-2011 Vadim Zeitlin +// Licence: wxWindows licence +/////////////////////////////////////////////////////////////////////////////// + +// ============================================================================ +// declarations +// ============================================================================ + +// ---------------------------------------------------------------------------- +// headers +// ---------------------------------------------------------------------------- + +// for compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#include "wx/datetimectrl.h" + +#ifdef wxNEEDS_DATETIMEPICKCTRL + +#ifndef WX_PRECOMP +#endif // WX_PRECOMP + +#include "wx/msw/private/datecontrols.h" + +// apparently some versions of mingw define these macros erroneously +#ifndef DateTime_GetSystemtime + #define DateTime_GetSystemtime DateTime_GetSystemTime +#endif + +#ifndef DateTime_SetSystemtime + #define DateTime_SetSystemtime DateTime_SetSystemTime +#endif + +// ============================================================================ +// wxDateTimePickerCtrl implementation +// ============================================================================ + +bool +wxDateTimePickerCtrl::MSWCreateDateTimePicker(wxWindow *parent, + wxWindowID id, + const wxDateTime& dt, + const wxPoint& pos, + const wxSize& size, + long style, + const wxValidator& validator, + const wxString& name) +{ + if ( !wxMSWDateControls::CheckInitialization() ) + return false; + + // initialize the base class + if ( !CreateControl(parent, id, pos, size, style, validator, name) ) + return false; + + // create the native control + if ( !MSWCreateControl(DATETIMEPICK_CLASS, wxString(), pos, size) ) + return false; + + if ( dt.IsValid() || MSWAllowsNone() ) + SetValue(dt); + else + SetValue(wxDateTime::Now()); + + return true; +} + +void wxDateTimePickerCtrl::SetValue(const wxDateTime& dt) +{ + wxCHECK_RET( dt.IsValid() || MSWAllowsNone(), + wxT("this control requires a valid date") ); + + SYSTEMTIME st; + if ( dt.IsValid() ) + dt.GetAsMSWSysTime(&st); + + if ( !DateTime_SetSystemtime(GetHwnd(), + dt.IsValid() ? GDT_VALID : GDT_NONE, + &st) ) + { + // The only expected failure is when the date is out of range but we + // already checked for this above. + wxFAIL_MSG( wxT("Setting the calendar date unexpectedly failed.") ); + + // In any case, skip updating m_date below. + return; + } + + m_date = dt; +} + +wxDateTime wxDateTimePickerCtrl::GetValue() const +{ + return m_date; +} + +wxSize wxDateTimePickerCtrl::DoGetBestSize() const +{ + wxClientDC dc(const_cast(this)); + + // Use the same native format as this as the underlying native control. + wxString s = wxDateTime::Now().Format(wxLocale::GetInfo(MSWGetFormat())); + + // the best size for the control is bigger than just the string + // representation of the current value because the control must accommodate + // any date and while the widths of all digits are usually about the same, + // the width of the month string varies a lot, so try to account for it + s += wxT("WW"); + + int x, y; + dc.GetTextExtent(s, &x, &y); + + // account for the drop-down arrow or spin arrows + x += wxSystemSettings::GetMetric(wxSYS_HSCROLL_ARROW_X); + + // and for the checkbox if we have it + if ( MSWAllowsNone() ) + x += 3*GetCharWidth(); + + wxSize best(x, EDIT_HEIGHT_FROM_CHAR_HEIGHT(y)); + CacheBestSize(best); + return best; +} + +bool +wxDateTimePickerCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) +{ + NMHDR* hdr = (NMHDR *)lParam; + switch ( hdr->code ) + { + case DTN_DATETIMECHANGE: + if ( MSWOnDateTimeChange(*(NMDATETIMECHANGE*)(hdr)) ) + { + *result = 0; + return true; + } + break; + } + + return wxDateTimePickerCtrlBase::MSWOnNotify(idCtrl, lParam, result); +} + +#endif // wxNEEDS_DATETIMEPICKCTRL -- 2.45.2