From 2fff3cd29fe353c196dbc523f4ce319e4dc71599 Mon Sep 17 00:00:00 2001 From: Tobias Taschner Date: Thu, 17 Sep 2015 14:46:27 +0200 Subject: [PATCH] Add wxSystemThemedControl and use it in wxMSW wxSystemThemedControl allows to use the "system theme" (i.e. the theme used by the system applications such as file manager and which can, surprisingly, be different from the default one). Currently it is only implemented for wxMSW and does nothing under the other platforms. Use wxSystemThemedControl for wxDataViewCtrl, wxListCtrl and, optionally, if wxTR_TWIST_BUTTONS style is specified, wxTreeCtrl to give them more native appearance under MSW. Closes #16414. --- Makefile.in | 33 +++++++++++++++ build/bakefiles/files.bkl | 2 + build/files | 2 + build/msw/makefile.bcc | 16 +++++++ build/msw/makefile.gcc | 16 +++++++ build/msw/makefile.vc | 16 +++++++ build/msw/wx_core.vcxproj | 3 ++ build/msw/wx_core.vcxproj.filters | 6 +++ build/msw/wx_vc7_core.vcproj | 6 +++ build/msw/wx_vc8_core.vcproj | 8 ++++ build/msw/wx_vc9_core.vcproj | 8 ++++ docs/changes.txt | 1 + include/wx/dataview.h | 3 +- include/wx/generic/dataview.h | 2 + include/wx/listbase.h | 3 +- include/wx/systhemectrl.h | 66 +++++++++++++++++++++++++++++ include/wx/treectrl.h | 3 +- interface/wx/dataview.h | 5 +++ interface/wx/listctrl.h | 4 ++ interface/wx/systhemectrl.h | 70 +++++++++++++++++++++++++++++++ interface/wx/treectrl.h | 6 +-- src/common/datavcmn.cpp | 18 ++++++-- src/generic/datavgen.cpp | 10 +++++ src/msw/listctrl.cpp | 2 + src/msw/systhemectrl.cpp | 35 ++++++++++++++++ src/msw/treectrl.cpp | 13 ++---- 26 files changed, 337 insertions(+), 20 deletions(-) create mode 100644 include/wx/systhemectrl.h create mode 100644 interface/wx/systhemectrl.h create mode 100644 src/msw/systhemectrl.cpp diff --git a/Makefile.in b/Makefile.in index 2901e1a93d..2cb5017f60 100644 --- a/Makefile.in +++ b/Makefile.in @@ -4278,6 +4278,7 @@ COND_USE_GUI_1_ALL_GUI_HEADERS = \ wx/xpmdecod.h \ wx/xpmhand.h \ wx/xrc/xmlreshandler.h \ + wx/systhemectrl.h \ $(LOWLEVEL_HDR) \ $(GUI_CORE_HEADERS) \ $(ADVANCED_HDR) \ @@ -5905,6 +5906,7 @@ COND_TOOLKIT_MSW___GUI_SRC_OBJECTS = \ monodll_msw_textentry.o \ monodll_msw_tglbtn.o \ monodll_treectrl.o \ + monodll_systhemectrl.o \ monodll_msw_checklst.o \ monodll_msw_fdrepdlg.o \ monodll_msw_fontdlg.o @@ -6065,6 +6067,7 @@ COND_TOOLKIT_WINCE___GUI_SRC_OBJECTS = \ monodll_msw_textentry.o \ monodll_msw_tglbtn.o \ monodll_treectrl.o \ + monodll_systhemectrl.o \ monodll_dirdlgg.o \ monodll_generic_fdrepdlg.o \ monodll_filedlgg.o \ @@ -8277,6 +8280,7 @@ COND_TOOLKIT_MSW___GUI_SRC_OBJECTS_1 = \ monolib_msw_textentry.o \ monolib_msw_tglbtn.o \ monolib_treectrl.o \ + monolib_systhemectrl.o \ monolib_msw_checklst.o \ monolib_msw_fdrepdlg.o \ monolib_msw_fontdlg.o @@ -8437,6 +8441,7 @@ COND_TOOLKIT_WINCE___GUI_SRC_OBJECTS_1 = \ monolib_msw_textentry.o \ monolib_msw_tglbtn.o \ monolib_treectrl.o \ + monolib_systhemectrl.o \ monolib_dirdlgg.o \ monolib_generic_fdrepdlg.o \ monolib_filedlgg.o \ @@ -10801,6 +10806,7 @@ COND_TOOLKIT_MSW___GUI_SRC_OBJECTS_2 = \ coredll_msw_textentry.o \ coredll_msw_tglbtn.o \ coredll_treectrl.o \ + coredll_systhemectrl.o \ coredll_msw_checklst.o \ coredll_msw_fdrepdlg.o \ coredll_msw_fontdlg.o @@ -10961,6 +10967,7 @@ COND_TOOLKIT_WINCE___GUI_SRC_OBJECTS_2 = \ coredll_msw_textentry.o \ coredll_msw_tglbtn.o \ coredll_treectrl.o \ + coredll_systhemectrl.o \ coredll_dirdlgg.o \ coredll_generic_fdrepdlg.o \ coredll_filedlgg.o \ @@ -12580,6 +12587,7 @@ COND_TOOLKIT_MSW___GUI_SRC_OBJECTS_3 = \ corelib_msw_textentry.o \ corelib_msw_tglbtn.o \ corelib_treectrl.o \ + corelib_systhemectrl.o \ corelib_msw_checklst.o \ corelib_msw_fdrepdlg.o \ corelib_msw_fontdlg.o @@ -12740,6 +12748,7 @@ COND_TOOLKIT_WINCE___GUI_SRC_OBJECTS_3 = \ corelib_msw_textentry.o \ corelib_msw_tglbtn.o \ corelib_treectrl.o \ + corelib_systhemectrl.o \ corelib_dirdlgg.o \ corelib_generic_fdrepdlg.o \ corelib_filedlgg.o \ @@ -21776,6 +21785,12 @@ monodll_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(MONODLL_ODEP) @COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@monodll_treectrl.o: $(srcdir)/src/msw/treectrl.cpp $(MONODLL_ODEP) @COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/msw/treectrl.cpp +@COND_TOOLKIT_MSW_USE_GUI_1_WXUNIV_0@monodll_systhemectrl.o: $(srcdir)/src/msw/systhemectrl.cpp $(MONODLL_ODEP) +@COND_TOOLKIT_MSW_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/msw/systhemectrl.cpp + +@COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@monodll_systhemectrl.o: $(srcdir)/src/msw/systhemectrl.cpp $(MONODLL_ODEP) +@COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/msw/systhemectrl.cpp + @COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_CARBON_USE_GUI_1_WXUNIV_0@monodll_anybutton_osx.o: $(srcdir)/src/osx/anybutton_osx.cpp $(MONODLL_ODEP) @COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_CARBON_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/osx/anybutton_osx.cpp @@ -27695,6 +27710,12 @@ monolib_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(MONOLIB_ODEP) @COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@monolib_treectrl.o: $(srcdir)/src/msw/treectrl.cpp $(MONOLIB_ODEP) @COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/msw/treectrl.cpp +@COND_TOOLKIT_MSW_USE_GUI_1_WXUNIV_0@monolib_systhemectrl.o: $(srcdir)/src/msw/systhemectrl.cpp $(MONOLIB_ODEP) +@COND_TOOLKIT_MSW_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/msw/systhemectrl.cpp + +@COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@monolib_systhemectrl.o: $(srcdir)/src/msw/systhemectrl.cpp $(MONOLIB_ODEP) +@COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/msw/systhemectrl.cpp + @COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_CARBON_USE_GUI_1_WXUNIV_0@monolib_anybutton_osx.o: $(srcdir)/src/osx/anybutton_osx.cpp $(MONOLIB_ODEP) @COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_CARBON_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/osx/anybutton_osx.cpp @@ -33719,6 +33740,12 @@ coredll_win32.o: $(srcdir)/src/univ/themes/win32.cpp $(COREDLL_ODEP) @COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@coredll_treectrl.o: $(srcdir)/src/msw/treectrl.cpp $(COREDLL_ODEP) @COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/msw/treectrl.cpp +@COND_TOOLKIT_MSW_USE_GUI_1_WXUNIV_0@coredll_systhemectrl.o: $(srcdir)/src/msw/systhemectrl.cpp $(COREDLL_ODEP) +@COND_TOOLKIT_MSW_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/msw/systhemectrl.cpp + +@COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@coredll_systhemectrl.o: $(srcdir)/src/msw/systhemectrl.cpp $(COREDLL_ODEP) +@COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/msw/systhemectrl.cpp + @COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_CARBON_USE_GUI_1_WXUNIV_0@coredll_anybutton_osx.o: $(srcdir)/src/osx/anybutton_osx.cpp $(COREDLL_ODEP) @COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_CARBON_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/osx/anybutton_osx.cpp @@ -38123,6 +38150,12 @@ corelib_win32.o: $(srcdir)/src/univ/themes/win32.cpp $(CORELIB_ODEP) @COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@corelib_treectrl.o: $(srcdir)/src/msw/treectrl.cpp $(CORELIB_ODEP) @COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/msw/treectrl.cpp +@COND_TOOLKIT_MSW_USE_GUI_1_WXUNIV_0@corelib_systhemectrl.o: $(srcdir)/src/msw/systhemectrl.cpp $(CORELIB_ODEP) +@COND_TOOLKIT_MSW_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/msw/systhemectrl.cpp + +@COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@corelib_systhemectrl.o: $(srcdir)/src/msw/systhemectrl.cpp $(CORELIB_ODEP) +@COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/msw/systhemectrl.cpp + @COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_CARBON_USE_GUI_1_WXUNIV_0@corelib_anybutton_osx.o: $(srcdir)/src/osx/anybutton_osx.cpp $(CORELIB_ODEP) @COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_CARBON_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/osx/anybutton_osx.cpp diff --git a/build/bakefiles/files.bkl b/build/bakefiles/files.bkl index 89e579c58a..840133ddb2 100644 --- a/build/bakefiles/files.bkl +++ b/build/bakefiles/files.bkl @@ -1193,6 +1193,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file! wx/xpmdecod.h wx/xpmhand.h wx/xrc/xmlreshandler.h + wx/systhemectrl.h @@ -1992,6 +1993,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file! src/msw/textentry.cpp src/msw/tglbtn.cpp src/msw/treectrl.cpp + src/msw/systhemectrl.cpp wx/generic/clrpickerg.h diff --git a/build/files b/build/files index fe6889aa60..ff9515b6ce 100644 --- a/build/files +++ b/build/files @@ -759,6 +759,7 @@ GUI_CMN_HDR = wx/statbox.h wx/stattext.h wx/statusbr.h + wx/systhemectrl.h wx/taskbarbutton.h wx/testing.h wx/textcompleter.h @@ -1630,6 +1631,7 @@ MSW_SRC = src/msw/statusbar.cpp src/msw/statline.cpp src/msw/stattext.cpp + src/msw/systhemectrl.cpp src/msw/taskbarbutton.cpp src/msw/toolbar.cpp src/msw/textctrl.cpp diff --git a/build/msw/makefile.bcc b/build/msw/makefile.bcc index bdf04b22ea..510f0e3490 100644 --- a/build/msw/makefile.bcc +++ b/build/msw/makefile.bcc @@ -1884,6 +1884,7 @@ ____CORE_SRC_FILENAMES_OBJECTS = \ $(OBJS)\monodll_textentry.obj \ $(OBJS)\monodll_msw_tglbtn.obj \ $(OBJS)\monodll_treectrl.obj \ + $(OBJS)\monodll_systhemectrl.obj \ $(OBJS)\monodll_msw_checklst.obj \ $(OBJS)\monodll_msw_fdrepdlg.obj \ $(OBJS)\monodll_fontdlg.obj \ @@ -2702,6 +2703,7 @@ ____CORE_SRC_FILENAMES_1_OBJECTS = \ $(OBJS)\monolib_textentry.obj \ $(OBJS)\monolib_msw_tglbtn.obj \ $(OBJS)\monolib_treectrl.obj \ + $(OBJS)\monolib_systhemectrl.obj \ $(OBJS)\monolib_msw_checklst.obj \ $(OBJS)\monolib_msw_fdrepdlg.obj \ $(OBJS)\monolib_fontdlg.obj \ @@ -3394,6 +3396,7 @@ ____CORE_SRC_FILENAMES_2_OBJECTS = \ $(OBJS)\coredll_textentry.obj \ $(OBJS)\coredll_msw_tglbtn.obj \ $(OBJS)\coredll_treectrl.obj \ + $(OBJS)\coredll_systhemectrl.obj \ $(OBJS)\coredll_msw_checklst.obj \ $(OBJS)\coredll_msw_fdrepdlg.obj \ $(OBJS)\coredll_fontdlg.obj \ @@ -3959,6 +3962,7 @@ ____CORE_SRC_FILENAMES_3_OBJECTS = \ $(OBJS)\corelib_textentry.obj \ $(OBJS)\corelib_msw_tglbtn.obj \ $(OBJS)\corelib_treectrl.obj \ + $(OBJS)\corelib_systhemectrl.obj \ $(OBJS)\corelib_msw_checklst.obj \ $(OBJS)\corelib_msw_fdrepdlg.obj \ $(OBJS)\corelib_fontdlg.obj \ @@ -6852,6 +6856,9 @@ $(OBJS)\monodll_msw_tglbtn.obj: ..\..\src\msw\tglbtn.cpp $(OBJS)\monodll_treectrl.obj: ..\..\src\msw\treectrl.cpp $(CXX) -q -c -P -o$@ $(MONODLL_CXXFLAGS) ..\..\src\msw\treectrl.cpp +$(OBJS)\monodll_systhemectrl.obj: ..\..\src\msw\systhemectrl.cpp + $(CXX) -q -c -P -o$@ $(MONODLL_CXXFLAGS) ..\..\src\msw\systhemectrl.cpp + $(OBJS)\monodll_msw_checklst.obj: ..\..\src\msw\checklst.cpp $(CXX) -q -c -P -o$@ $(MONODLL_CXXFLAGS) ..\..\src\msw\checklst.cpp @@ -9351,6 +9358,9 @@ $(OBJS)\monolib_msw_tglbtn.obj: ..\..\src\msw\tglbtn.cpp $(OBJS)\monolib_treectrl.obj: ..\..\src\msw\treectrl.cpp $(CXX) -q -c -P -o$@ $(MONOLIB_CXXFLAGS) ..\..\src\msw\treectrl.cpp +$(OBJS)\monolib_systhemectrl.obj: ..\..\src\msw\systhemectrl.cpp + $(CXX) -q -c -P -o$@ $(MONOLIB_CXXFLAGS) ..\..\src\msw\systhemectrl.cpp + $(OBJS)\monolib_msw_checklst.obj: ..\..\src\msw\checklst.cpp $(CXX) -q -c -P -o$@ $(MONOLIB_CXXFLAGS) ..\..\src\msw\checklst.cpp @@ -12258,6 +12268,9 @@ $(OBJS)\coredll_msw_tglbtn.obj: ..\..\src\msw\tglbtn.cpp $(OBJS)\coredll_treectrl.obj: ..\..\src\msw\treectrl.cpp $(CXX) -q -c -P -o$@ $(COREDLL_CXXFLAGS) ..\..\src\msw\treectrl.cpp +$(OBJS)\coredll_systhemectrl.obj: ..\..\src\msw\systhemectrl.cpp + $(CXX) -q -c -P -o$@ $(COREDLL_CXXFLAGS) ..\..\src\msw\systhemectrl.cpp + $(OBJS)\coredll_msw_checklst.obj: ..\..\src\msw\checklst.cpp $(CXX) -q -c -P -o$@ $(COREDLL_CXXFLAGS) ..\..\src\msw\checklst.cpp @@ -13719,6 +13732,9 @@ $(OBJS)\corelib_msw_tglbtn.obj: ..\..\src\msw\tglbtn.cpp $(OBJS)\corelib_treectrl.obj: ..\..\src\msw\treectrl.cpp $(CXX) -q -c -P -o$@ $(CORELIB_CXXFLAGS) ..\..\src\msw\treectrl.cpp +$(OBJS)\corelib_systhemectrl.obj: ..\..\src\msw\systhemectrl.cpp + $(CXX) -q -c -P -o$@ $(CORELIB_CXXFLAGS) ..\..\src\msw\systhemectrl.cpp + $(OBJS)\corelib_msw_checklst.obj: ..\..\src\msw\checklst.cpp $(CXX) -q -c -P -o$@ $(CORELIB_CXXFLAGS) ..\..\src\msw\checklst.cpp diff --git a/build/msw/makefile.gcc b/build/msw/makefile.gcc index 72a3c195d6..b3e780ac95 100644 --- a/build/msw/makefile.gcc +++ b/build/msw/makefile.gcc @@ -1903,6 +1903,7 @@ ____CORE_SRC_FILENAMES_OBJECTS = \ $(OBJS)\monodll_textentry.o \ $(OBJS)\monodll_msw_tglbtn.o \ $(OBJS)\monodll_treectrl.o \ + $(OBJS)\monodll_systhemectrl.o \ $(OBJS)\monodll_msw_checklst.o \ $(OBJS)\monodll_msw_fdrepdlg.o \ $(OBJS)\monodll_fontdlg.o \ @@ -2727,6 +2728,7 @@ ____CORE_SRC_FILENAMES_1_OBJECTS = \ $(OBJS)\monolib_textentry.o \ $(OBJS)\monolib_msw_tglbtn.o \ $(OBJS)\monolib_treectrl.o \ + $(OBJS)\monolib_systhemectrl.o \ $(OBJS)\monolib_msw_checklst.o \ $(OBJS)\monolib_msw_fdrepdlg.o \ $(OBJS)\monolib_fontdlg.o \ @@ -3435,6 +3437,7 @@ ____CORE_SRC_FILENAMES_2_OBJECTS = \ $(OBJS)\coredll_textentry.o \ $(OBJS)\coredll_msw_tglbtn.o \ $(OBJS)\coredll_treectrl.o \ + $(OBJS)\coredll_systhemectrl.o \ $(OBJS)\coredll_msw_checklst.o \ $(OBJS)\coredll_msw_fdrepdlg.o \ $(OBJS)\coredll_fontdlg.o \ @@ -4008,6 +4011,7 @@ ____CORE_SRC_FILENAMES_3_OBJECTS = \ $(OBJS)\corelib_textentry.o \ $(OBJS)\corelib_msw_tglbtn.o \ $(OBJS)\corelib_treectrl.o \ + $(OBJS)\corelib_systhemectrl.o \ $(OBJS)\corelib_msw_checklst.o \ $(OBJS)\corelib_msw_fdrepdlg.o \ $(OBJS)\corelib_fontdlg.o \ @@ -7027,6 +7031,9 @@ $(OBJS)\monodll_msw_tglbtn.o: ../../src/msw/tglbtn.cpp $(OBJS)\monodll_treectrl.o: ../../src/msw/treectrl.cpp $(CXX) -c -o $@ $(MONODLL_CXXFLAGS) $(CPPDEPS) $< +$(OBJS)\monodll_systhemectrl.o: ../../src/msw/systhemectrl.cpp + $(CXX) -c -o $@ $(MONODLL_CXXFLAGS) $(CPPDEPS) $< + $(OBJS)\monodll_msw_checklst.o: ../../src/msw/checklst.cpp $(CXX) -c -o $@ $(MONODLL_CXXFLAGS) $(CPPDEPS) $< @@ -9526,6 +9533,9 @@ $(OBJS)\monolib_msw_tglbtn.o: ../../src/msw/tglbtn.cpp $(OBJS)\monolib_treectrl.o: ../../src/msw/treectrl.cpp $(CXX) -c -o $@ $(MONOLIB_CXXFLAGS) $(CPPDEPS) $< +$(OBJS)\monolib_systhemectrl.o: ../../src/msw/systhemectrl.cpp + $(CXX) -c -o $@ $(MONOLIB_CXXFLAGS) $(CPPDEPS) $< + $(OBJS)\monolib_msw_checklst.o: ../../src/msw/checklst.cpp $(CXX) -c -o $@ $(MONOLIB_CXXFLAGS) $(CPPDEPS) $< @@ -12433,6 +12443,9 @@ $(OBJS)\coredll_msw_tglbtn.o: ../../src/msw/tglbtn.cpp $(OBJS)\coredll_treectrl.o: ../../src/msw/treectrl.cpp $(CXX) -c -o $@ $(COREDLL_CXXFLAGS) $(CPPDEPS) $< +$(OBJS)\coredll_systhemectrl.o: ../../src/msw/systhemectrl.cpp + $(CXX) -c -o $@ $(COREDLL_CXXFLAGS) $(CPPDEPS) $< + $(OBJS)\coredll_msw_checklst.o: ../../src/msw/checklst.cpp $(CXX) -c -o $@ $(COREDLL_CXXFLAGS) $(CPPDEPS) $< @@ -13894,6 +13907,9 @@ $(OBJS)\corelib_msw_tglbtn.o: ../../src/msw/tglbtn.cpp $(OBJS)\corelib_treectrl.o: ../../src/msw/treectrl.cpp $(CXX) -c -o $@ $(CORELIB_CXXFLAGS) $(CPPDEPS) $< +$(OBJS)\corelib_systhemectrl.o: ../../src/msw/systhemectrl.cpp + $(CXX) -c -o $@ $(CORELIB_CXXFLAGS) $(CPPDEPS) $< + $(OBJS)\corelib_msw_checklst.o: ../../src/msw/checklst.cpp $(CXX) -c -o $@ $(CORELIB_CXXFLAGS) $(CPPDEPS) $< diff --git a/build/msw/makefile.vc b/build/msw/makefile.vc index dd52e808a8..3c0e7a5c64 100644 --- a/build/msw/makefile.vc +++ b/build/msw/makefile.vc @@ -2184,6 +2184,7 @@ ____CORE_SRC_FILENAMES_OBJECTS = \ $(OBJS)\monodll_textentry.obj \ $(OBJS)\monodll_msw_tglbtn.obj \ $(OBJS)\monodll_treectrl.obj \ + $(OBJS)\monodll_systhemectrl.obj \ $(OBJS)\monodll_msw_checklst.obj \ $(OBJS)\monodll_msw_fdrepdlg.obj \ $(OBJS)\monodll_fontdlg.obj \ @@ -3008,6 +3009,7 @@ ____CORE_SRC_FILENAMES_1_OBJECTS = \ $(OBJS)\monolib_textentry.obj \ $(OBJS)\monolib_msw_tglbtn.obj \ $(OBJS)\monolib_treectrl.obj \ + $(OBJS)\monolib_systhemectrl.obj \ $(OBJS)\monolib_msw_checklst.obj \ $(OBJS)\monolib_msw_fdrepdlg.obj \ $(OBJS)\monolib_fontdlg.obj \ @@ -3766,6 +3768,7 @@ ____CORE_SRC_FILENAMES_2_OBJECTS = \ $(OBJS)\coredll_textentry.obj \ $(OBJS)\coredll_msw_tglbtn.obj \ $(OBJS)\coredll_treectrl.obj \ + $(OBJS)\coredll_systhemectrl.obj \ $(OBJS)\coredll_msw_checklst.obj \ $(OBJS)\coredll_msw_fdrepdlg.obj \ $(OBJS)\coredll_fontdlg.obj \ @@ -4337,6 +4340,7 @@ ____CORE_SRC_FILENAMES_3_OBJECTS = \ $(OBJS)\corelib_textentry.obj \ $(OBJS)\corelib_msw_tglbtn.obj \ $(OBJS)\corelib_treectrl.obj \ + $(OBJS)\corelib_systhemectrl.obj \ $(OBJS)\corelib_msw_checklst.obj \ $(OBJS)\corelib_msw_fdrepdlg.obj \ $(OBJS)\corelib_fontdlg.obj \ @@ -7544,6 +7548,9 @@ $(OBJS)\monodll_msw_tglbtn.obj: ..\..\src\msw\tglbtn.cpp $(OBJS)\monodll_treectrl.obj: ..\..\src\msw\treectrl.cpp $(CXX) /c /nologo /TP /Fo$@ $(MONODLL_CXXFLAGS) ..\..\src\msw\treectrl.cpp +$(OBJS)\monodll_systhemectrl.obj: ..\..\src\msw\systhemectrl.cpp + $(CXX) /c /nologo /TP /Fo$@ $(MONODLL_CXXFLAGS) ..\..\src\msw\systhemectrl.cpp + $(OBJS)\monodll_msw_checklst.obj: ..\..\src\msw\checklst.cpp $(CXX) /c /nologo /TP /Fo$@ $(MONODLL_CXXFLAGS) ..\..\src\msw\checklst.cpp @@ -10043,6 +10050,9 @@ $(OBJS)\monolib_msw_tglbtn.obj: ..\..\src\msw\tglbtn.cpp $(OBJS)\monolib_treectrl.obj: ..\..\src\msw\treectrl.cpp $(CXX) /c /nologo /TP /Fo$@ $(MONOLIB_CXXFLAGS) ..\..\src\msw\treectrl.cpp +$(OBJS)\monolib_systhemectrl.obj: ..\..\src\msw\systhemectrl.cpp + $(CXX) /c /nologo /TP /Fo$@ $(MONOLIB_CXXFLAGS) ..\..\src\msw\systhemectrl.cpp + $(OBJS)\monolib_msw_checklst.obj: ..\..\src\msw\checklst.cpp $(CXX) /c /nologo /TP /Fo$@ $(MONOLIB_CXXFLAGS) ..\..\src\msw\checklst.cpp @@ -12950,6 +12960,9 @@ $(OBJS)\coredll_msw_tglbtn.obj: ..\..\src\msw\tglbtn.cpp $(OBJS)\coredll_treectrl.obj: ..\..\src\msw\treectrl.cpp $(CXX) /c /nologo /TP /Fo$@ $(COREDLL_CXXFLAGS) ..\..\src\msw\treectrl.cpp +$(OBJS)\coredll_systhemectrl.obj: ..\..\src\msw\systhemectrl.cpp + $(CXX) /c /nologo /TP /Fo$@ $(COREDLL_CXXFLAGS) ..\..\src\msw\systhemectrl.cpp + $(OBJS)\coredll_msw_checklst.obj: ..\..\src\msw\checklst.cpp $(CXX) /c /nologo /TP /Fo$@ $(COREDLL_CXXFLAGS) ..\..\src\msw\checklst.cpp @@ -14411,6 +14424,9 @@ $(OBJS)\corelib_msw_tglbtn.obj: ..\..\src\msw\tglbtn.cpp $(OBJS)\corelib_treectrl.obj: ..\..\src\msw\treectrl.cpp $(CXX) /c /nologo /TP /Fo$@ $(CORELIB_CXXFLAGS) ..\..\src\msw\treectrl.cpp +$(OBJS)\corelib_systhemectrl.obj: ..\..\src\msw\systhemectrl.cpp + $(CXX) /c /nologo /TP /Fo$@ $(CORELIB_CXXFLAGS) ..\..\src\msw\systhemectrl.cpp + $(OBJS)\corelib_msw_checklst.obj: ..\..\src\msw\checklst.cpp $(CXX) /c /nologo /TP /Fo$@ $(CORELIB_CXXFLAGS) ..\..\src\msw\checklst.cpp diff --git a/build/msw/wx_core.vcxproj b/build/msw/wx_core.vcxproj index 4758299466..3f76dde06c 100644 --- a/build/msw/wx_core.vcxproj +++ b/build/msw/wx_core.vcxproj @@ -1004,6 +1004,7 @@ + @@ -1012,6 +1013,7 @@ true true + @@ -1372,6 +1374,7 @@ + diff --git a/build/msw/wx_core.vcxproj.filters b/build/msw/wx_core.vcxproj.filters index 454a1293ea..d4aefef7b0 100644 --- a/build/msw/wx_core.vcxproj.filters +++ b/build/msw/wx_core.vcxproj.filters @@ -840,6 +840,9 @@ MSW Sources + + MSW Sources + MSW Sources @@ -1807,6 +1810,9 @@ Common Headers + + Common Headers + Common Headers diff --git a/build/msw/wx_vc7_core.vcproj b/build/msw/wx_vc7_core.vcproj index c51b675233..c2536df2b1 100644 --- a/build/msw/wx_vc7_core.vcproj +++ b/build/msw/wx_vc7_core.vcproj @@ -991,6 +991,9 @@ + + @@ -2576,6 +2579,9 @@ + + diff --git a/build/msw/wx_vc8_core.vcproj b/build/msw/wx_vc8_core.vcproj index b94b2016b0..ea1cf3cf49 100644 --- a/build/msw/wx_vc8_core.vcproj +++ b/build/msw/wx_vc8_core.vcproj @@ -1726,6 +1726,10 @@ RelativePath="..\..\src\msw\statusbar.cpp" > + + @@ -3936,6 +3940,10 @@ RelativePath="..\..\include\wx\stc\stc.h" > + + diff --git a/build/msw/wx_vc9_core.vcproj b/build/msw/wx_vc9_core.vcproj index 5d2bdfc321..ed41ad6fd7 100644 --- a/build/msw/wx_vc9_core.vcproj +++ b/build/msw/wx_vc9_core.vcproj @@ -1722,6 +1722,10 @@ RelativePath="..\..\src\msw\statusbar.cpp" > + + @@ -3932,6 +3936,10 @@ RelativePath="..\..\include\wx\stc\stc.h" > + + diff --git a/docs/changes.txt b/docs/changes.txt index 60173464f4..ec3c6aa02d 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -171,6 +171,7 @@ wxMSW: - Avoid bogus assert after calling wxDatePickerCtrl::SetRange(). - Add solution file for building with MSVS 2014 (Peter Tissen). - Correct wxGetOsDescription() for Windows 10 (Tobias Taschner). +- Make wxListCtrl &c appearance more native on modern systems (Tobias Taschner). - Don't send wxActivateEvent for minimized windows (bzcdr). wxOSX/Cocoa: diff --git a/include/wx/dataview.h b/include/wx/dataview.h index bf5554f951..8364cdbd78 100644 --- a/include/wx/dataview.h +++ b/include/wx/dataview.h @@ -26,6 +26,7 @@ #include "wx/vector.h" #include "wx/dataobj.h" #include "wx/withimages.h" +#include "wx/systhemectrl.h" class WXDLLIMPEXP_FWD_CORE wxImageList; @@ -513,7 +514,7 @@ private: #define wxDV_ROW_LINES 0x0010 // alternating colour in rows #define wxDV_VARIABLE_LINE_HEIGHT 0x0020 // variable line height -class WXDLLIMPEXP_ADV wxDataViewCtrlBase: public wxControl +class WXDLLIMPEXP_ADV wxDataViewCtrlBase: public wxSystemThemedControl { public: wxDataViewCtrlBase(); diff --git a/include/wx/generic/dataview.h b/include/wx/generic/dataview.h index a0f5edc425..c4ec501229 100644 --- a/include/wx/generic/dataview.h +++ b/include/wx/generic/dataview.h @@ -220,6 +220,8 @@ protected: // Reset all columns currently used for sorting. void ResetAllSortColumns(); + virtual void DoEnableSystemTheme(bool enable, wxWindow* window) wxOVERRIDE; + public: // utility functions not part of the API // returns the "best" width for the idx-th column diff --git a/include/wx/listbase.h b/include/wx/listbase.h index dba43ffa44..13f4bb8ec6 100644 --- a/include/wx/listbase.h +++ b/include/wx/listbase.h @@ -16,6 +16,7 @@ #include "wx/gdicmn.h" #include "wx/event.h" #include "wx/control.h" +#include "wx/systhemectrl.h" class WXDLLIMPEXP_FWD_CORE wxImageList; @@ -377,7 +378,7 @@ private: // the real control class but is just used for implementation convenience. We // should define the public class functions as pure virtual here in the future // however. -class WXDLLIMPEXP_CORE wxListCtrlBase : public wxControl +class WXDLLIMPEXP_CORE wxListCtrlBase : public wxSystemThemedControl { public: wxListCtrlBase() { } diff --git a/include/wx/systhemectrl.h b/include/wx/systhemectrl.h new file mode 100644 index 0000000000..597288e166 --- /dev/null +++ b/include/wx/systhemectrl.h @@ -0,0 +1,66 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: wx/systhemectrl.h +// Purpose: Class to make controls appear in the systems theme +// Author: Tobias Taschner +// Created: 2014-08-14 +// Copyright: (c) 2014 wxWidgets development team +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_SYSTHEMECTRL_H +#define _WX_SYSTHEMECTRL_H + +#include "wx/defs.h" + +class WXDLLIMPEXP_FWD_CORE wxWindow; + +class WXDLLIMPEXP_CORE wxSystemThemedControlBase +{ +public: + wxSystemThemedControlBase() { } + + virtual ~wxSystemThemedControlBase() { } + +protected: + // This method is virtual and can be overridden, e.g. composite controls do + // it to enable the system theme for all of their parts. + virtual void DoEnableSystemTheme(bool enable, wxWindow* window); + + wxDECLARE_NO_COPY_CLASS(wxSystemThemedControlBase); +}; + +// This class used CRTP, i.e. it should be instantiated for the real base class +// and inherited from. +template +class wxSystemThemedControl : public C, + public wxSystemThemedControlBase +{ +public: + wxSystemThemedControl() { } + + void EnableSystemTheme(bool enable = true) + { + DoEnableSystemTheme(enable, this); + } + +protected: + wxDECLARE_NO_COPY_TEMPLATE_CLASS(wxSystemThemedControl, C); +}; + +// Only __WXMSW__ has a non-trivial implementation currently. +#ifdef __WXMSW__ + #define wxHAS_SYSTEM_THEMED_CONTROL +#endif + +#ifndef wxHAS_SYSTEM_THEMED_CONTROL + +inline void +wxSystemThemedControlBase::DoEnableSystemTheme(bool WXUNUSED(enable), + wxWindow* WXUNUSED(window)) +{ + // Nothing to do. +} + +#endif // !wxHAS_SYSTEM_THEMED_CONTROL + +#endif // _WX_SYSTHEMECTRL_H diff --git a/include/wx/treectrl.h b/include/wx/treectrl.h index 2a958abac3..5e7dfa9731 100644 --- a/include/wx/treectrl.h +++ b/include/wx/treectrl.h @@ -22,6 +22,7 @@ #include "wx/control.h" #include "wx/treebase.h" #include "wx/textctrl.h" // wxTextCtrl::ms_classinfo used through wxCLASSINFO macro +#include "wx/systhemectrl.h" class WXDLLIMPEXP_FWD_CORE wxImageList; @@ -33,7 +34,7 @@ class WXDLLIMPEXP_FWD_CORE wxImageList; // wxTreeCtrlBase // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxTreeCtrlBase : public wxControl +class WXDLLIMPEXP_CORE wxTreeCtrlBase : public wxSystemThemedControl { public: wxTreeCtrlBase(); diff --git a/interface/wx/dataview.h b/interface/wx/dataview.h index 1892e60740..957c1de05e 100644 --- a/interface/wx/dataview.h +++ b/interface/wx/dataview.h @@ -907,6 +907,11 @@ wxEventType wxEVT_DATAVIEW_ITEM_DROP; you need to handle any mouse events not covered by the ones above, consider using a custom renderer for the cells that must handle them. + @note Under wxMSW this control uses wxSystemThemedControl for an explorer + style appearance by default since wxWidgets 3.1.0. If this is not desired, + you can call wxSystemThemedControl::EnableSystemTheme with @c false + argument to disable this. + @library{wxadv} @category{ctrl,dvc} @appearance{dataviewctrl} diff --git a/interface/wx/listctrl.h b/interface/wx/listctrl.h index 5b825d8021..34d4a17449 100644 --- a/interface/wx/listctrl.h +++ b/interface/wx/listctrl.h @@ -258,6 +258,10 @@ enum Processes a @c wxEVT_LIST_CACHE_HINT event type. @endEventTable + @note Under wxMSW this control uses wxSystemThemedControl for an explorer + style appearance by default since wxWidgets 3.1.0. If this is not desired, + you can call wxSystemThemedControl::EnableSystemTheme with @c false + argument to disable this. @library{wxcore} @category{ctrl} diff --git a/interface/wx/systhemectrl.h b/interface/wx/systhemectrl.h new file mode 100644 index 0000000000..c8fc4d8f88 --- /dev/null +++ b/interface/wx/systhemectrl.h @@ -0,0 +1,70 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: wx/systhemectrl.h +// Purpose: Documentation for wxSystemThemedControl +// Author: Tobias Taschner +// Created: 2014-08-15 +// Copyright: (c) 2014 wxWidgets development team +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +/** + A helper class making it possible to use system theme for any control. + + Under MSW, there an alternative theme available for the list and list-like + controls since Windows Vista. This theme us used by Windows Explorer list + and tree view and so is arguably more familiar to the users than the standard + appearance of these controls. + + This class is used in wxWidgets to enable this system theme in wxTreeCtrl, + wxListCtrl and wxDataViewCtrl and thus give them the same, familiar look. + It can also be used as a helper for implementing custom controls with the same + appearance. Notice that when using this class it is especially important + to use wxRendererNative::DrawItemSelectionRect() and + wxRendererNative::DrawItemText() to draw the control items to ensure that + they appear correctly under all platforms and Windows versions. + + The following example shows implementation of a system theme enabled wxVListBox: + @code + #include + + class MyListCtrl : public wxSystemThemedControl + { + public: + MyListCtrl(wxWindow* parent) + { + + ... + + EnableSystemTheme(); + } + + void OnDrawItem(wxDC& dc, const wxRect& rect, size_t n) const wxOVERRIDE + { + wxRendererNative::GetDefault().DrawItemText(this, dc, "Item #x", rect); + } + }; + @endcode + + On non-MSW platforms this class currently does nothing but is still + available, so that it can be used in portable code without any conditional + compilation directives. + + @category{miscwnd} + + @see wxTreeCtrl, wxListCtrl, wxDataViewCtrl, wxRendererNative + + @since 3.1.0 +*/ +template +class wxSystemThemedControl : public C +{ +public: + /// Trival default constructor. + wxSystemThemedControl(); + + /** + This method may be called to disable the system theme of controls + using it by default. + */ + void EnableSystemTheme(bool enable = true); +}; diff --git a/interface/wx/treectrl.h b/interface/wx/treectrl.h index d1b8f9eaaa..c119aca425 100644 --- a/interface/wx/treectrl.h +++ b/interface/wx/treectrl.h @@ -32,10 +32,8 @@ Selects alternative style of @c +/@c - buttons and shows rotating ("twisting") arrows instead. Currently this style is only implemented under Microsoft Windows Vista and later Windows versions and is ignored - under the other platforms. Notice that under Vista this style results - in the same appearance as used by the tree control in Explorer and - other built-in programs and so using it may be preferable to the - default style. + under the other platforms as enabling it is equivalent to using + wxSystemThemedControl::EnableSystemTheme(). @style{wxTR_NO_LINES} Use this style to hide vertical level connectors. @style{wxTR_FULL_ROW_HIGHLIGHT} diff --git a/src/common/datavcmn.cpp b/src/common/datavcmn.cpp index ec94efc43d..536e7ae2ea 100644 --- a/src/common/datavcmn.cpp +++ b/src/common/datavcmn.cpp @@ -29,6 +29,7 @@ #include "wx/spinctrl.h" #include "wx/choice.h" #include "wx/imaglist.h" +#include "wx/renderer.h" const char wxDataViewCtrlNameStr[] = "dataviewCtrl"; @@ -974,7 +975,7 @@ wxDataViewCustomRendererBase::RenderText(const wxString& text, int xoffset, wxRect rect, wxDC *dc, - int WXUNUSED(state)) + int state) { wxRect rectText = rect; rectText.x += xoffset; @@ -994,9 +995,20 @@ wxDataViewCustomRendererBase::RenderText(const wxString& text, ); } + int flags = 0; + if ( state & wxDATAVIEW_CELL_SELECTED ) + flags |= wxCONTROL_SELECTED | wxCONTROL_FOCUSED; + if ( !GetOwner()->GetOwner()->IsEnabled() ) + flags |= wxCONTROL_DISABLED; + // get the alignment to use - dc->DrawLabel(ellipsizedText.empty() ? text : ellipsizedText, - rectText, GetEffectiveAlignment()); + wxRendererNative::Get().DrawItemText( + GetOwner()->GetOwner(), + *dc, + ellipsizedText.empty() ? text : ellipsizedText, + rectText, + GetEffectiveAlignment(), + flags); } void wxDataViewCustomRendererBase::SetEnabled(bool enabled) diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index c5bb710690..1fcad8eb24 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -4659,6 +4659,8 @@ bool wxDataViewCtrl::Create(wxWindow *parent, sizer->Add( m_clientArea, 1, wxGROW ); SetSizer( sizer ); + EnableSystemTheme(); + return true; } @@ -5419,6 +5421,14 @@ void wxDataViewCtrl::ToggleSortByColumn(int column) m_headerArea->ToggleSortByColumn(column); } +void wxDataViewCtrl::DoEnableSystemTheme(bool enable, wxWindow* window) +{ + wxSystemThemedControl::DoEnableSystemTheme(enable, window); + wxSystemThemedControl::DoEnableSystemTheme(enable, m_clientArea); + if ( m_headerArea ) + wxSystemThemedControl::DoEnableSystemTheme(enable, m_headerArea); +} + #endif // !wxUSE_GENERICDATAVIEWCTRL #endif // wxUSE_DATAVIEWCTRL diff --git a/src/msw/listctrl.cpp b/src/msw/listctrl.cpp index 29f9986bf0..5e27d051cb 100644 --- a/src/msw/listctrl.cpp +++ b/src/msw/listctrl.cpp @@ -267,6 +267,8 @@ bool wxListCtrl::Create(wxWindow *parent, if ( !MSWCreateControl(WC_LISTVIEW, wxEmptyString, pos, size) ) return false; + EnableSystemTheme(); + // explicitly say that we want to use Unicode because otherwise we get ANSI // versions of _some_ messages (notably LVN_GETDISPINFOA) wxSetCCUnicodeFormat(GetHwnd()); diff --git a/src/msw/systhemectrl.cpp b/src/msw/systhemectrl.cpp new file mode 100644 index 0000000000..c705b05e00 --- /dev/null +++ b/src/msw/systhemectrl.cpp @@ -0,0 +1,35 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: src/msw/systhemectrl.cpp +// Purpose: wxMSW implementation of wxSystemThemedControl +// Author: Tobias Taschner +// Created: 2015-09-15 +// Copyright: (c) 2015 wxWidgets development team +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#include "wx/systhemectrl.h" + +#include "wx/msw/private.h" +#include "wx/msw/uxtheme.h" + +#ifdef wxHAS_SYSTEM_THEMED_CONTROL + +void wxSystemThemedControlBase::DoEnableSystemTheme(bool enable, wxWindow* window) +{ + if ( wxGetWinVersion() >= wxWinVersion_Vista ) + { + if ( wxUxThemeEngine *te = wxUxThemeEngine::GetIfActive() ) + { + const wchar_t* const sysThemeId = enable ? L"EXPLORER" : NULL; + te->SetWindowTheme(GetHwndOf(window), sysThemeId, NULL); + } + } +} + +#endif // wxHAS_SYSTEM_THEMED_CONTROL diff --git a/src/msw/treectrl.cpp b/src/msw/treectrl.cpp index 3112e1eb93..49591b2d65 100644 --- a/src/msw/treectrl.cpp +++ b/src/msw/treectrl.cpp @@ -783,16 +783,9 @@ bool wxTreeCtrl::Create(wxWindow *parent, if ( m_windowStyle & wxTR_TWIST_BUTTONS ) { - // Under Vista and later Explorer uses rotating ("twist") buttons - // instead of the default "+/-" ones so apply its theme to the tree - // control to implement this style. - if ( wxGetWinVersion() >= wxWinVersion_Vista ) - { - if ( wxUxThemeEngine *theme = wxUxThemeEngine::GetIfActive() ) - { - theme->SetWindowTheme(GetHwnd(), L"EXPLORER", NULL); - } - } + // The Vista+ system theme uses rotating ("twist") buttons, so we map + // this style to it. + EnableSystemTheme(); } return true;