From 64d3ed176d5b88473b69c7ab63075d50608d2f66 Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Fri, 14 Apr 2006 09:15:10 +0000 Subject: [PATCH] Steps towards implementing native-style, non-top-level toolbars on Mac by implementing a toolbar class that uses native buttons. Ultimately this should allow wxToolbook and wxPropertySheetDialog classes to look native, when we complete the button API improvements to combine text, bitmaps and toggling. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@38703 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- Makefile.in | 22 ++ build/bakefiles/files.bkl | 2 + build/msw/makefile.bcc | 24 ++ build/msw/makefile.gcc | 24 ++ build/msw/makefile.vc | 24 ++ build/msw/makefile.wat | 24 ++ build/msw/wx_adv.dsp | 8 + build/msw/wx_core.dsp | 4 + include/wx/generic/buttonbar.h | 110 +++++++++ include/wx/generic/propdlg.h | 3 + include/wx/toolbook.h | 3 + samples/dialogs/dialogs.cpp | 27 ++- samples/dialogs/dialogs.h | 6 +- src/generic/buttonbar.cpp | 428 +++++++++++++++++++++++++++++++++ src/generic/propdlg.cpp | 7 +- src/generic/toolbkg.cpp | 18 +- 16 files changed, 718 insertions(+), 16 deletions(-) create mode 100644 include/wx/generic/buttonbar.h create mode 100644 src/generic/buttonbar.cpp diff --git a/Makefile.in b/Makefile.in index f5000687a7..8cf84a95d4 100644 --- a/Makefile.in +++ b/Makefile.in @@ -2483,6 +2483,7 @@ COND_WXUNIV_0_ADVANCED_HDR = \ wx/dataview.h \ wx/dateevt.h \ wx/dcbuffer.h \ + wx/generic/buttonbar.h \ wx/generic/calctrl.h \ wx/generic/datectrl.h \ wx/generic/dataview.h \ @@ -2520,6 +2521,7 @@ COND_WXUNIV_1_ADVANCED_HDR = \ wx/dataview.h \ wx/dateevt.h \ wx/dcbuffer.h \ + wx/generic/buttonbar.h \ wx/generic/calctrl.h \ wx/generic/datectrl.h \ wx/generic/dataview.h \ @@ -4444,6 +4446,7 @@ 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_datavcmn.o \ + monodll_buttonbar.o \ monodll_calctrl.o \ monodll_datavgen.o \ monodll_datectlg.o \ @@ -4467,6 +4470,7 @@ 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_datavcmn.o \ + monodll_buttonbar.o \ monodll_calctrl.o \ monodll_datavgen.o \ monodll_datectlg.o \ @@ -6068,6 +6072,7 @@ 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_datavcmn.o \ + monolib_buttonbar.o \ monolib_calctrl.o \ monolib_datavgen.o \ monolib_datectlg.o \ @@ -6091,6 +6096,7 @@ 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_datavcmn.o \ + monolib_buttonbar.o \ monolib_calctrl.o \ monolib_datavgen.o \ monolib_datectlg.o \ @@ -9300,6 +9306,7 @@ COND_USE_SOSYMLINKS_1___advdll___so_symlinks_inst_cmd = rm -f \ @COND_PLATFORM_WIN32_1@__advdll___win32rc = advdll_version_rc.o COND_WXUNIV_0___ADVANCED_SRC_OBJECTS_2 = \ advdll_datavcmn.o \ + advdll_buttonbar.o \ advdll_calctrl.o \ advdll_datavgen.o \ advdll_datectlg.o \ @@ -9323,6 +9330,7 @@ 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_datavcmn.o \ + advdll_buttonbar.o \ advdll_calctrl.o \ advdll_datavgen.o \ advdll_datectlg.o \ @@ -9361,6 +9369,7 @@ 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_datavcmn.o \ + advlib_buttonbar.o \ advlib_calctrl.o \ advlib_datavgen.o \ advlib_datectlg.o \ @@ -9384,6 +9393,7 @@ 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_datavcmn.o \ + advlib_buttonbar.o \ advlib_calctrl.o \ advlib_datavgen.o \ advlib_datectlg.o \ @@ -14743,6 +14753,9 @@ monodll_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(MONODLL_ODEP) @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 +@COND_USE_GUI_1@monodll_buttonbar.o: $(srcdir)/src/generic/buttonbar.cpp $(MONODLL_ODEP) +@COND_USE_GUI_1@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/generic/buttonbar.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 @@ -18529,6 +18542,9 @@ monolib_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(MONOLIB_ODEP) @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 +@COND_USE_GUI_1@monolib_buttonbar.o: $(srcdir)/src/generic/buttonbar.cpp $(MONOLIB_ODEP) +@COND_USE_GUI_1@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/generic/buttonbar.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 @@ -25477,6 +25493,9 @@ advdll_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(ADVDLL_ODEP) advdll_datavcmn.o: $(srcdir)/src/common/datavcmn.cpp $(ADVDLL_ODEP) $(CXXC) -c -o $@ $(ADVDLL_CXXFLAGS) $(srcdir)/src/common/datavcmn.cpp +advdll_buttonbar.o: $(srcdir)/src/generic/buttonbar.cpp $(ADVDLL_ODEP) + $(CXXC) -c -o $@ $(ADVDLL_CXXFLAGS) $(srcdir)/src/generic/buttonbar.cpp + advdll_calctrl.o: $(srcdir)/src/generic/calctrl.cpp $(ADVDLL_ODEP) $(CXXC) -c -o $@ $(ADVDLL_CXXFLAGS) $(srcdir)/src/generic/calctrl.cpp @@ -25651,6 +25670,9 @@ advlib_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(ADVLIB_ODEP) advlib_datavcmn.o: $(srcdir)/src/common/datavcmn.cpp $(ADVLIB_ODEP) $(CXXC) -c -o $@ $(ADVLIB_CXXFLAGS) $(srcdir)/src/common/datavcmn.cpp +advlib_buttonbar.o: $(srcdir)/src/generic/buttonbar.cpp $(ADVLIB_ODEP) + $(CXXC) -c -o $@ $(ADVLIB_CXXFLAGS) $(srcdir)/src/generic/buttonbar.cpp + advlib_calctrl.o: $(srcdir)/src/generic/calctrl.cpp $(ADVLIB_ODEP) $(CXXC) -c -o $@ $(ADVLIB_CXXFLAGS) $(srcdir)/src/generic/calctrl.cpp diff --git a/build/bakefiles/files.bkl b/build/bakefiles/files.bkl index b58dc6fa6d..6c543f2642 100644 --- a/build/bakefiles/files.bkl +++ b/build/bakefiles/files.bkl @@ -2516,6 +2516,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file! src/common/datavcmn.cpp + src/generic/buttonbar.cpp src/generic/calctrl.cpp src/generic/datavgen.cpp src/generic/datectlg.cpp @@ -2541,6 +2542,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file! wx/dataview.h wx/dateevt.h wx/dcbuffer.h + wx/generic/buttonbar.h wx/generic/calctrl.h wx/generic/datectrl.h wx/generic/dataview.h diff --git a/build/msw/makefile.bcc b/build/msw/makefile.bcc index 8c1863f658..d334482da3 100644 --- a/build/msw/makefile.bcc +++ b/build/msw/makefile.bcc @@ -1545,6 +1545,7 @@ ____CORE_SRC_FILENAMES_OBJECTS = \ !if "$(WXUNIV)" == "0" ____ADVANCED_SRC_FILENAMES_OBJECTS = \ $(OBJS)\monodll_datavcmn.obj \ + $(OBJS)\monodll_buttonbar.obj \ $(OBJS)\monodll_calctrl.obj \ $(OBJS)\monodll_datavgen.obj \ $(OBJS)\monodll_datectlg.obj \ @@ -1572,6 +1573,7 @@ ____ADVANCED_SRC_FILENAMES_OBJECTS = \ !if "$(WXUNIV)" == "1" ____ADVANCED_SRC_FILENAMES_OBJECTS = \ $(OBJS)\monodll_datavcmn.obj \ + $(OBJS)\monodll_buttonbar.obj \ $(OBJS)\monodll_calctrl.obj \ $(OBJS)\monodll_datavgen.obj \ $(OBJS)\monodll_datectlg.obj \ @@ -2082,6 +2084,7 @@ ____CORE_SRC_FILENAMES_1_OBJECTS = \ !if "$(WXUNIV)" == "0" ____ADVANCED_SRC_FILENAMES_1_OBJECTS = \ $(OBJS)\monolib_datavcmn.obj \ + $(OBJS)\monolib_buttonbar.obj \ $(OBJS)\monolib_calctrl.obj \ $(OBJS)\monolib_datavgen.obj \ $(OBJS)\monolib_datectlg.obj \ @@ -2109,6 +2112,7 @@ ____ADVANCED_SRC_FILENAMES_1_OBJECTS = \ !if "$(WXUNIV)" == "1" ____ADVANCED_SRC_FILENAMES_1_OBJECTS = \ $(OBJS)\monolib_datavcmn.obj \ + $(OBJS)\monolib_buttonbar.obj \ $(OBJS)\monolib_calctrl.obj \ $(OBJS)\monolib_datavgen.obj \ $(OBJS)\monolib_datectlg.obj \ @@ -2957,6 +2961,7 @@ __advdll___depname = \ !if "$(WXUNIV)" == "0" ____ADVANCED_SRC_FILENAMES_2_OBJECTS = \ $(OBJS)\advdll_datavcmn.obj \ + $(OBJS)\advdll_buttonbar.obj \ $(OBJS)\advdll_calctrl.obj \ $(OBJS)\advdll_datavgen.obj \ $(OBJS)\advdll_datectlg.obj \ @@ -2984,6 +2989,7 @@ ____ADVANCED_SRC_FILENAMES_2_OBJECTS = \ !if "$(WXUNIV)" == "1" ____ADVANCED_SRC_FILENAMES_2_OBJECTS = \ $(OBJS)\advdll_datavcmn.obj \ + $(OBJS)\advdll_buttonbar.obj \ $(OBJS)\advdll_calctrl.obj \ $(OBJS)\advdll_datavgen.obj \ $(OBJS)\advdll_datectlg.obj \ @@ -3014,6 +3020,7 @@ __advlib___depname = \ !if "$(WXUNIV)" == "0" ____ADVANCED_SRC_FILENAMES_3_OBJECTS = \ $(OBJS)\advlib_datavcmn.obj \ + $(OBJS)\advlib_buttonbar.obj \ $(OBJS)\advlib_calctrl.obj \ $(OBJS)\advlib_datavgen.obj \ $(OBJS)\advlib_datectlg.obj \ @@ -3041,6 +3048,7 @@ ____ADVANCED_SRC_FILENAMES_3_OBJECTS = \ !if "$(WXUNIV)" == "1" ____ADVANCED_SRC_FILENAMES_3_OBJECTS = \ $(OBJS)\advlib_datavcmn.obj \ + $(OBJS)\advlib_buttonbar.obj \ $(OBJS)\advlib_calctrl.obj \ $(OBJS)\advlib_datavgen.obj \ $(OBJS)\advlib_datectlg.obj \ @@ -5688,6 +5696,11 @@ $(OBJS)\monodll_datavcmn.obj: ..\..\src\common\datavcmn.cpp $(CXX) -q -c -P -o$@ $(MONODLL_CXXFLAGS) $** !endif +!if "$(USE_GUI)" == "1" +$(OBJS)\monodll_buttonbar.obj: ..\..\src\generic\buttonbar.cpp + $(CXX) -q -c -P -o$@ $(MONODLL_CXXFLAGS) $** +!endif + !if "$(USE_GUI)" == "1" $(OBJS)\monodll_calctrl.obj: ..\..\src\generic\calctrl.cpp $(CXX) -q -c -P -o$@ $(MONODLL_CXXFLAGS) $** @@ -7444,6 +7457,11 @@ $(OBJS)\monolib_datavcmn.obj: ..\..\src\common\datavcmn.cpp $(CXX) -q -c -P -o$@ $(MONOLIB_CXXFLAGS) $** !endif +!if "$(USE_GUI)" == "1" +$(OBJS)\monolib_buttonbar.obj: ..\..\src\generic\buttonbar.cpp + $(CXX) -q -c -P -o$@ $(MONOLIB_CXXFLAGS) $** +!endif + !if "$(USE_GUI)" == "1" $(OBJS)\monolib_calctrl.obj: ..\..\src\generic\calctrl.cpp $(CXX) -q -c -P -o$@ $(MONOLIB_CXXFLAGS) $** @@ -10425,6 +10443,9 @@ $(OBJS)\advdll_datectrl.obj: ..\..\src\msw\datectrl.cpp $(OBJS)\advdll_datavcmn.obj: ..\..\src\common\datavcmn.cpp $(CXX) -q -c -P -o$@ $(ADVDLL_CXXFLAGS) $** +$(OBJS)\advdll_buttonbar.obj: ..\..\src\generic\buttonbar.cpp + $(CXX) -q -c -P -o$@ $(ADVDLL_CXXFLAGS) $** + $(OBJS)\advdll_calctrl.obj: ..\..\src\generic\calctrl.cpp $(CXX) -q -c -P -o$@ $(ADVDLL_CXXFLAGS) $** @@ -10500,6 +10521,9 @@ $(OBJS)\advlib_datectrl.obj: ..\..\src\msw\datectrl.cpp $(OBJS)\advlib_datavcmn.obj: ..\..\src\common\datavcmn.cpp $(CXX) -q -c -P -o$@ $(ADVLIB_CXXFLAGS) $** +$(OBJS)\advlib_buttonbar.obj: ..\..\src\generic\buttonbar.cpp + $(CXX) -q -c -P -o$@ $(ADVLIB_CXXFLAGS) $** + $(OBJS)\advlib_calctrl.obj: ..\..\src\generic\calctrl.cpp $(CXX) -q -c -P -o$@ $(ADVLIB_CXXFLAGS) $** diff --git a/build/msw/makefile.gcc b/build/msw/makefile.gcc index 2dccbab4aa..6fc34bbef6 100644 --- a/build/msw/makefile.gcc +++ b/build/msw/makefile.gcc @@ -1559,6 +1559,7 @@ endif ifeq ($(WXUNIV),0) ____ADVANCED_SRC_FILENAMES_OBJECTS = \ $(OBJS)\monodll_datavcmn.o \ + $(OBJS)\monodll_buttonbar.o \ $(OBJS)\monodll_calctrl.o \ $(OBJS)\monodll_datavgen.o \ $(OBJS)\monodll_datectlg.o \ @@ -1586,6 +1587,7 @@ endif ifeq ($(WXUNIV),1) ____ADVANCED_SRC_FILENAMES_OBJECTS = \ $(OBJS)\monodll_datavcmn.o \ + $(OBJS)\monodll_buttonbar.o \ $(OBJS)\monodll_calctrl.o \ $(OBJS)\monodll_datavgen.o \ $(OBJS)\monodll_datectlg.o \ @@ -2102,6 +2104,7 @@ endif ifeq ($(WXUNIV),0) ____ADVANCED_SRC_FILENAMES_1_OBJECTS = \ $(OBJS)\monolib_datavcmn.o \ + $(OBJS)\monolib_buttonbar.o \ $(OBJS)\monolib_calctrl.o \ $(OBJS)\monolib_datavgen.o \ $(OBJS)\monolib_datectlg.o \ @@ -2129,6 +2132,7 @@ endif ifeq ($(WXUNIV),1) ____ADVANCED_SRC_FILENAMES_1_OBJECTS = \ $(OBJS)\monolib_datavcmn.o \ + $(OBJS)\monolib_buttonbar.o \ $(OBJS)\monolib_calctrl.o \ $(OBJS)\monolib_datavgen.o \ $(OBJS)\monolib_datectlg.o \ @@ -3005,6 +3009,7 @@ endif ifeq ($(WXUNIV),0) ____ADVANCED_SRC_FILENAMES_2_OBJECTS = \ $(OBJS)\advdll_datavcmn.o \ + $(OBJS)\advdll_buttonbar.o \ $(OBJS)\advdll_calctrl.o \ $(OBJS)\advdll_datavgen.o \ $(OBJS)\advdll_datectlg.o \ @@ -3032,6 +3037,7 @@ endif ifeq ($(WXUNIV),1) ____ADVANCED_SRC_FILENAMES_2_OBJECTS = \ $(OBJS)\advdll_datavcmn.o \ + $(OBJS)\advdll_buttonbar.o \ $(OBJS)\advdll_calctrl.o \ $(OBJS)\advdll_datavgen.o \ $(OBJS)\advdll_datectlg.o \ @@ -3066,6 +3072,7 @@ endif ifeq ($(WXUNIV),0) ____ADVANCED_SRC_FILENAMES_3_OBJECTS = \ $(OBJS)\advlib_datavcmn.o \ + $(OBJS)\advlib_buttonbar.o \ $(OBJS)\advlib_calctrl.o \ $(OBJS)\advlib_datavgen.o \ $(OBJS)\advlib_datectlg.o \ @@ -3093,6 +3100,7 @@ endif ifeq ($(WXUNIV),1) ____ADVANCED_SRC_FILENAMES_3_OBJECTS = \ $(OBJS)\advlib_datavcmn.o \ + $(OBJS)\advlib_buttonbar.o \ $(OBJS)\advlib_calctrl.o \ $(OBJS)\advlib_datavgen.o \ $(OBJS)\advlib_datectlg.o \ @@ -5892,6 +5900,11 @@ $(OBJS)\monodll_datavcmn.o: ../../src/common/datavcmn.cpp $(CXX) -c -o $@ $(MONODLL_CXXFLAGS) $(CPPDEPS) $< endif +ifeq ($(USE_GUI),1) +$(OBJS)\monodll_buttonbar.o: ../../src/generic/buttonbar.cpp + $(CXX) -c -o $@ $(MONODLL_CXXFLAGS) $(CPPDEPS) $< +endif + ifeq ($(USE_GUI),1) $(OBJS)\monodll_calctrl.o: ../../src/generic/calctrl.cpp $(CXX) -c -o $@ $(MONODLL_CXXFLAGS) $(CPPDEPS) $< @@ -7748,6 +7761,11 @@ $(OBJS)\monolib_datavcmn.o: ../../src/common/datavcmn.cpp $(CXX) -c -o $@ $(MONOLIB_CXXFLAGS) $(CPPDEPS) $< endif +ifeq ($(USE_GUI),1) +$(OBJS)\monolib_buttonbar.o: ../../src/generic/buttonbar.cpp + $(CXX) -c -o $@ $(MONOLIB_CXXFLAGS) $(CPPDEPS) $< +endif + ifeq ($(USE_GUI),1) $(OBJS)\monolib_calctrl.o: ../../src/generic/calctrl.cpp $(CXX) -c -o $@ $(MONOLIB_CXXFLAGS) $(CPPDEPS) $< @@ -10929,6 +10947,9 @@ $(OBJS)\advdll_datectrl.o: ../../src/msw/datectrl.cpp $(OBJS)\advdll_datavcmn.o: ../../src/common/datavcmn.cpp $(CXX) -c -o $@ $(ADVDLL_CXXFLAGS) $(CPPDEPS) $< +$(OBJS)\advdll_buttonbar.o: ../../src/generic/buttonbar.cpp + $(CXX) -c -o $@ $(ADVDLL_CXXFLAGS) $(CPPDEPS) $< + $(OBJS)\advdll_calctrl.o: ../../src/generic/calctrl.cpp $(CXX) -c -o $@ $(ADVDLL_CXXFLAGS) $(CPPDEPS) $< @@ -11004,6 +11025,9 @@ $(OBJS)\advlib_datectrl.o: ../../src/msw/datectrl.cpp $(OBJS)\advlib_datavcmn.o: ../../src/common/datavcmn.cpp $(CXX) -c -o $@ $(ADVLIB_CXXFLAGS) $(CPPDEPS) $< +$(OBJS)\advlib_buttonbar.o: ../../src/generic/buttonbar.cpp + $(CXX) -c -o $@ $(ADVLIB_CXXFLAGS) $(CPPDEPS) $< + $(OBJS)\advlib_calctrl.o: ../../src/generic/calctrl.cpp $(CXX) -c -o $@ $(ADVLIB_CXXFLAGS) $(CPPDEPS) $< diff --git a/build/msw/makefile.vc b/build/msw/makefile.vc index b4f1fad142..101afa073d 100644 --- a/build/msw/makefile.vc +++ b/build/msw/makefile.vc @@ -1704,6 +1704,7 @@ ____CORE_SRC_FILENAMES_OBJECTS = \ !if "$(WXUNIV)" == "0" ____ADVANCED_SRC_FILENAMES_OBJECTS = \ $(OBJS)\monodll_datavcmn.obj \ + $(OBJS)\monodll_buttonbar.obj \ $(OBJS)\monodll_calctrl.obj \ $(OBJS)\monodll_datavgen.obj \ $(OBJS)\monodll_datectlg.obj \ @@ -1731,6 +1732,7 @@ ____ADVANCED_SRC_FILENAMES_OBJECTS = \ !if "$(WXUNIV)" == "1" ____ADVANCED_SRC_FILENAMES_OBJECTS = \ $(OBJS)\monodll_datavcmn.obj \ + $(OBJS)\monodll_buttonbar.obj \ $(OBJS)\monodll_calctrl.obj \ $(OBJS)\monodll_datavgen.obj \ $(OBJS)\monodll_datectlg.obj \ @@ -2247,6 +2249,7 @@ ____CORE_SRC_FILENAMES_1_OBJECTS = \ !if "$(WXUNIV)" == "0" ____ADVANCED_SRC_FILENAMES_1_OBJECTS = \ $(OBJS)\monolib_datavcmn.obj \ + $(OBJS)\monolib_buttonbar.obj \ $(OBJS)\monolib_calctrl.obj \ $(OBJS)\monolib_datavgen.obj \ $(OBJS)\monolib_datectlg.obj \ @@ -2274,6 +2277,7 @@ ____ADVANCED_SRC_FILENAMES_1_OBJECTS = \ !if "$(WXUNIV)" == "1" ____ADVANCED_SRC_FILENAMES_1_OBJECTS = \ $(OBJS)\monolib_datavcmn.obj \ + $(OBJS)\monolib_buttonbar.obj \ $(OBJS)\monolib_calctrl.obj \ $(OBJS)\monolib_datavgen.obj \ $(OBJS)\monolib_datectlg.obj \ @@ -3164,6 +3168,7 @@ __RUNTIME_LIBS_195 = $(__THREADSFLAG) !if "$(WXUNIV)" == "0" ____ADVANCED_SRC_FILENAMES_2_OBJECTS = \ $(OBJS)\advdll_datavcmn.obj \ + $(OBJS)\advdll_buttonbar.obj \ $(OBJS)\advdll_calctrl.obj \ $(OBJS)\advdll_datavgen.obj \ $(OBJS)\advdll_datectlg.obj \ @@ -3191,6 +3196,7 @@ ____ADVANCED_SRC_FILENAMES_2_OBJECTS = \ !if "$(WXUNIV)" == "1" ____ADVANCED_SRC_FILENAMES_2_OBJECTS = \ $(OBJS)\advdll_datavcmn.obj \ + $(OBJS)\advdll_buttonbar.obj \ $(OBJS)\advdll_calctrl.obj \ $(OBJS)\advdll_datavgen.obj \ $(OBJS)\advdll_datectlg.obj \ @@ -3227,6 +3233,7 @@ __RUNTIME_LIBS_208 = $(__THREADSFLAG) !if "$(WXUNIV)" == "0" ____ADVANCED_SRC_FILENAMES_3_OBJECTS = \ $(OBJS)\advlib_datavcmn.obj \ + $(OBJS)\advlib_buttonbar.obj \ $(OBJS)\advlib_calctrl.obj \ $(OBJS)\advlib_datavgen.obj \ $(OBJS)\advlib_datectlg.obj \ @@ -3254,6 +3261,7 @@ ____ADVANCED_SRC_FILENAMES_3_OBJECTS = \ !if "$(WXUNIV)" == "1" ____ADVANCED_SRC_FILENAMES_3_OBJECTS = \ $(OBJS)\advlib_datavcmn.obj \ + $(OBJS)\advlib_buttonbar.obj \ $(OBJS)\advlib_calctrl.obj \ $(OBJS)\advlib_datavgen.obj \ $(OBJS)\advlib_datectlg.obj \ @@ -5997,6 +6005,11 @@ $(OBJS)\monodll_datavcmn.obj: ..\..\src\common\datavcmn.cpp $(CXX) /c /nologo /TP /Fo$@ $(MONODLL_CXXFLAGS) $** !endif +!if "$(USE_GUI)" == "1" +$(OBJS)\monodll_buttonbar.obj: ..\..\src\generic\buttonbar.cpp + $(CXX) /c /nologo /TP /Fo$@ $(MONODLL_CXXFLAGS) $** +!endif + !if "$(USE_GUI)" == "1" $(OBJS)\monodll_calctrl.obj: ..\..\src\generic\calctrl.cpp $(CXX) /c /nologo /TP /Fo$@ $(MONODLL_CXXFLAGS) $** @@ -7753,6 +7766,11 @@ $(OBJS)\monolib_datavcmn.obj: ..\..\src\common\datavcmn.cpp $(CXX) /c /nologo /TP /Fo$@ $(MONOLIB_CXXFLAGS) $** !endif +!if "$(USE_GUI)" == "1" +$(OBJS)\monolib_buttonbar.obj: ..\..\src\generic\buttonbar.cpp + $(CXX) /c /nologo /TP /Fo$@ $(MONOLIB_CXXFLAGS) $** +!endif + !if "$(USE_GUI)" == "1" $(OBJS)\monolib_calctrl.obj: ..\..\src\generic\calctrl.cpp $(CXX) /c /nologo /TP /Fo$@ $(MONOLIB_CXXFLAGS) $** @@ -10734,6 +10752,9 @@ $(OBJS)\advdll_datectrl.obj: ..\..\src\msw\datectrl.cpp $(OBJS)\advdll_datavcmn.obj: ..\..\src\common\datavcmn.cpp $(CXX) /c /nologo /TP /Fo$@ $(ADVDLL_CXXFLAGS) $** +$(OBJS)\advdll_buttonbar.obj: ..\..\src\generic\buttonbar.cpp + $(CXX) /c /nologo /TP /Fo$@ $(ADVDLL_CXXFLAGS) $** + $(OBJS)\advdll_calctrl.obj: ..\..\src\generic\calctrl.cpp $(CXX) /c /nologo /TP /Fo$@ $(ADVDLL_CXXFLAGS) $** @@ -10809,6 +10830,9 @@ $(OBJS)\advlib_datectrl.obj: ..\..\src\msw\datectrl.cpp $(OBJS)\advlib_datavcmn.obj: ..\..\src\common\datavcmn.cpp $(CXX) /c /nologo /TP /Fo$@ $(ADVLIB_CXXFLAGS) $** +$(OBJS)\advlib_buttonbar.obj: ..\..\src\generic\buttonbar.cpp + $(CXX) /c /nologo /TP /Fo$@ $(ADVLIB_CXXFLAGS) $** + $(OBJS)\advlib_calctrl.obj: ..\..\src\generic\calctrl.cpp $(CXX) /c /nologo /TP /Fo$@ $(ADVLIB_CXXFLAGS) $** diff --git a/build/msw/makefile.wat b/build/msw/makefile.wat index e630e6ab1e..3da1e13caf 100644 --- a/build/msw/makefile.wat +++ b/build/msw/makefile.wat @@ -585,6 +585,7 @@ ____ADVANCED_SRC_FILENAMES_OBJECTS = !ifeq WXUNIV 0 ____ADVANCED_SRC_FILENAMES_OBJECTS = & $(OBJS)\monodll_datavcmn.obj & + $(OBJS)\monodll_buttonbar.obj & $(OBJS)\monodll_calctrl.obj & $(OBJS)\monodll_datavgen.obj & $(OBJS)\monodll_datectlg.obj & @@ -612,6 +613,7 @@ ____ADVANCED_SRC_FILENAMES_OBJECTS = & !ifeq WXUNIV 1 ____ADVANCED_SRC_FILENAMES_OBJECTS = & $(OBJS)\monodll_datavcmn.obj & + $(OBJS)\monodll_buttonbar.obj & $(OBJS)\monodll_calctrl.obj & $(OBJS)\monodll_datavgen.obj & $(OBJS)\monodll_datectlg.obj & @@ -1132,6 +1134,7 @@ ____ADVANCED_SRC_FILENAMES_1_OBJECTS = !ifeq WXUNIV 0 ____ADVANCED_SRC_FILENAMES_1_OBJECTS = & $(OBJS)\monolib_datavcmn.obj & + $(OBJS)\monolib_buttonbar.obj & $(OBJS)\monolib_calctrl.obj & $(OBJS)\monolib_datavgen.obj & $(OBJS)\monolib_datectlg.obj & @@ -1159,6 +1162,7 @@ ____ADVANCED_SRC_FILENAMES_1_OBJECTS = & !ifeq WXUNIV 1 ____ADVANCED_SRC_FILENAMES_1_OBJECTS = & $(OBJS)\monolib_datavcmn.obj & + $(OBJS)\monolib_buttonbar.obj & $(OBJS)\monolib_calctrl.obj & $(OBJS)\monolib_datavgen.obj & $(OBJS)\monolib_datectlg.obj & @@ -2045,6 +2049,7 @@ ____ADVANCED_SRC_FILENAMES_2_OBJECTS = !ifeq WXUNIV 0 ____ADVANCED_SRC_FILENAMES_2_OBJECTS = & $(OBJS)\advdll_datavcmn.obj & + $(OBJS)\advdll_buttonbar.obj & $(OBJS)\advdll_calctrl.obj & $(OBJS)\advdll_datavgen.obj & $(OBJS)\advdll_datectlg.obj & @@ -2072,6 +2077,7 @@ ____ADVANCED_SRC_FILENAMES_2_OBJECTS = & !ifeq WXUNIV 1 ____ADVANCED_SRC_FILENAMES_2_OBJECTS = & $(OBJS)\advdll_datavcmn.obj & + $(OBJS)\advdll_buttonbar.obj & $(OBJS)\advdll_calctrl.obj & $(OBJS)\advdll_datavgen.obj & $(OBJS)\advdll_datectlg.obj & @@ -2108,6 +2114,7 @@ ____ADVANCED_SRC_FILENAMES_3_OBJECTS = !ifeq WXUNIV 0 ____ADVANCED_SRC_FILENAMES_3_OBJECTS = & $(OBJS)\advlib_datavcmn.obj & + $(OBJS)\advlib_buttonbar.obj & $(OBJS)\advlib_calctrl.obj & $(OBJS)\advlib_datavgen.obj & $(OBJS)\advlib_datectlg.obj & @@ -2135,6 +2142,7 @@ ____ADVANCED_SRC_FILENAMES_3_OBJECTS = & !ifeq WXUNIV 1 ____ADVANCED_SRC_FILENAMES_3_OBJECTS = & $(OBJS)\advlib_datavcmn.obj & + $(OBJS)\advlib_buttonbar.obj & $(OBJS)\advlib_calctrl.obj & $(OBJS)\advlib_datavgen.obj & $(OBJS)\advlib_datectlg.obj & @@ -6092,6 +6100,11 @@ $(OBJS)\monodll_datavcmn.obj : .AUTODEPEND ..\..\src\common\datavcmn.cpp $(CXX) -bt=nt -zq -fo=$^@ $(MONODLL_CXXFLAGS) $< !endif +!ifeq USE_GUI 1 +$(OBJS)\monodll_buttonbar.obj : .AUTODEPEND ..\..\src\generic\buttonbar.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(MONODLL_CXXFLAGS) $< +!endif + !ifeq USE_GUI 1 $(OBJS)\monodll_calctrl.obj : .AUTODEPEND ..\..\src\generic\calctrl.cpp $(CXX) -bt=nt -zq -fo=$^@ $(MONODLL_CXXFLAGS) $< @@ -7948,6 +7961,11 @@ $(OBJS)\monolib_datavcmn.obj : .AUTODEPEND ..\..\src\common\datavcmn.cpp $(CXX) -bt=nt -zq -fo=$^@ $(MONOLIB_CXXFLAGS) $< !endif +!ifeq USE_GUI 1 +$(OBJS)\monolib_buttonbar.obj : .AUTODEPEND ..\..\src\generic\buttonbar.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(MONOLIB_CXXFLAGS) $< +!endif + !ifeq USE_GUI 1 $(OBJS)\monolib_calctrl.obj : .AUTODEPEND ..\..\src\generic\calctrl.cpp $(CXX) -bt=nt -zq -fo=$^@ $(MONOLIB_CXXFLAGS) $< @@ -11129,6 +11147,9 @@ $(OBJS)\advdll_datectrl.obj : .AUTODEPEND ..\..\src\msw\datectrl.cpp $(OBJS)\advdll_datavcmn.obj : .AUTODEPEND ..\..\src\common\datavcmn.cpp $(CXX) -bt=nt -zq -fo=$^@ $(ADVDLL_CXXFLAGS) $< +$(OBJS)\advdll_buttonbar.obj : .AUTODEPEND ..\..\src\generic\buttonbar.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(ADVDLL_CXXFLAGS) $< + $(OBJS)\advdll_calctrl.obj : .AUTODEPEND ..\..\src\generic\calctrl.cpp $(CXX) -bt=nt -zq -fo=$^@ $(ADVDLL_CXXFLAGS) $< @@ -11204,6 +11225,9 @@ $(OBJS)\advlib_datectrl.obj : .AUTODEPEND ..\..\src\msw\datectrl.cpp $(OBJS)\advlib_datavcmn.obj : .AUTODEPEND ..\..\src\common\datavcmn.cpp $(CXX) -bt=nt -zq -fo=$^@ $(ADVLIB_CXXFLAGS) $< +$(OBJS)\advlib_buttonbar.obj : .AUTODEPEND ..\..\src\generic\buttonbar.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(ADVLIB_CXXFLAGS) $< + $(OBJS)\advlib_calctrl.obj : .AUTODEPEND ..\..\src\generic\calctrl.cpp $(CXX) -bt=nt -zq -fo=$^@ $(ADVLIB_CXXFLAGS) $< diff --git a/build/msw/wx_adv.dsp b/build/msw/wx_adv.dsp index 0fdfa476c5..8d8abb1c3b 100644 --- a/build/msw/wx_adv.dsp +++ b/build/msw/wx_adv.dsp @@ -612,6 +612,10 @@ SOURCE=..\..\src\msw\version.rc # PROP Default_Filter "" # Begin Source File +SOURCE=..\..\src\generic\buttonbar.cpp +# End Source File +# Begin Source File + SOURCE=..\..\src\generic\calctrl.cpp # End Source File # Begin Source File @@ -1113,6 +1117,10 @@ SOURCE=..\..\include\wx\msw\taskbar.h # PROP Default_Filter "" # Begin Source File +SOURCE=..\..\include\wx\generic\buttonbar.h +# End Source File +# Begin Source File + SOURCE=..\..\include\wx\generic\calctrl.h # End Source File # Begin Source File diff --git a/build/msw/wx_core.dsp b/build/msw/wx_core.dsp index b63fa483a8..18a40537a2 100644 --- a/build/msw/wx_core.dsp +++ b/build/msw/wx_core.dsp @@ -7971,6 +7971,10 @@ SOURCE=..\..\include\wx\generic\busyinfo.h # End Source File # Begin Source File +SOURCE=..\..\include\wx\generic\buttonbar.h +# End Source File +# Begin Source File + SOURCE=..\..\include\wx\generic\calctrl.h # End Source File # Begin Source File diff --git a/include/wx/generic/buttonbar.h b/include/wx/generic/buttonbar.h new file mode 100644 index 0000000000..1cb9d63a7f --- /dev/null +++ b/include/wx/generic/buttonbar.h @@ -0,0 +1,110 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: wx/generic/buttonbar.h +// Purpose: wxButtonToolBar declaration +// Author: Julian Smart, after Robert Roebling, Vadim Zeitlin, SciTech +// Modified by: +// Created: 2006-04-13 +// Id: $Id$ +// Copyright: (c) Julian Smart, Robert Roebling, Vadim Zeitlin, +// SciTech Software, Inc. +// Licence: wxWindows licence +/////////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_BUTTONBAR_H_ +#define _WX_BUTTONBAR_H_ + +#include "wx/bmpbuttn.h" + +class WXDLLEXPORT wxButtonToolBarTool; + +// ---------------------------------------------------------------------------- +// wxButtonToolBar +// ---------------------------------------------------------------------------- + +class WXDLLEXPORT wxButtonToolBar : public wxToolBarBase +{ +public: + // construction/destruction + wxButtonToolBar() { Init(); } + wxButtonToolBar(wxWindow *parent, + wxWindowID id, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = 0, + const wxString& name = wxToolBarNameStr) + { + Init(); + + Create(parent, id, pos, size, style, name); + } + + bool Create( wxWindow *parent, + wxWindowID id, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = 0, + const wxString& name = wxToolBarNameStr ); + + virtual ~wxButtonToolBar(); + + virtual bool Realize(); + + virtual void SetToolShortHelp(int id, const wxString& helpString); + virtual wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y) const; + +protected: + // common part of all ctors + void Init(); + + // implement base class pure virtuals + virtual bool DoInsertTool(size_t pos, wxToolBarToolBase *tool); + virtual bool DoDeleteTool(size_t pos, wxToolBarToolBase *tool); + + virtual void DoEnableTool(wxToolBarToolBase *tool, bool enable); + virtual void DoToggleTool(wxToolBarToolBase *tool, bool toggle); + virtual void DoSetToggle(wxToolBarToolBase *tool, bool toggle); + + virtual wxToolBarToolBase *CreateTool(int id, + const wxString& label, + const wxBitmap& bmpNormal, + const wxBitmap& bmpDisabled, + wxItemKind kind, + wxObject *clientData, + const wxString& shortHelp, + const wxString& longHelp); + virtual wxToolBarToolBase *CreateTool(wxControl *control); + + virtual wxSize DoGetBestClientSize() const; + + // calculate layout + void DoLayout(); + + // get the bounding rect for the given tool + wxRect GetToolRect(wxToolBarToolBase *tool) const; + + // get the rect limits depending on the orientation: top/bottom for a + // vertical toolbar, left/right for a horizontal one + void GetRectLimits(const wxRect& rect, wxCoord *start, wxCoord *end) const; + + // receives button commands + void OnCommand(wxCommandEvent& event); + +private: + // have we calculated the positions of our tools? + bool m_needsLayout; + + // the width of a separator + wxCoord m_widthSeparator; + + // the total size of all toolbar elements + wxCoord m_maxWidth, + m_maxHeight; + +private: + DECLARE_DYNAMIC_CLASS(wxButtonToolBar) + DECLARE_EVENT_TABLE() +}; + +#endif + // _WX_BUTTONBAR_H_ + diff --git a/include/wx/generic/propdlg.h b/include/wx/generic/propdlg.h index 6ecb9ec47c..5be620faca 100644 --- a/include/wx/generic/propdlg.h +++ b/include/wx/generic/propdlg.h @@ -66,6 +66,9 @@ class WXDLLEXPORT wxBookCtrlBase; // Shrink dialog to fit current page #define wxPROPSHEET_SHRINKTOFIT 0x0100 +// Use a wxButtonToolBar toolbook +#define wxPROPSHEET_BUTTONTOOLBOOK 0x0200 + class WXDLLIMPEXP_ADV wxPropertySheetDialog : public wxDialog { public: diff --git a/include/wx/toolbook.h b/include/wx/toolbook.h index f5b6fc8f1e..472054e467 100644 --- a/include/wx/toolbook.h +++ b/include/wx/toolbook.h @@ -21,6 +21,9 @@ class WXDLLEXPORT wxToolBarBase; class WXDLLEXPORT wxCommandEvent; +// Use wxButtonToolBar +#define wxBK_BUTTONBAR 0x0100 + // ---------------------------------------------------------------------------- // wxToolbook // ---------------------------------------------------------------------------- diff --git a/samples/dialogs/dialogs.cpp b/samples/dialogs/dialogs.cpp index 035c2e1557..b29c7530f7 100644 --- a/samples/dialogs/dialogs.cpp +++ b/samples/dialogs/dialogs.cpp @@ -196,7 +196,8 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame) #if USE_SETTINGS_DIALOG EVT_MENU(DIALOGS_PROPERTY_SHEET, MyFrame::OnPropertySheet) - EVT_MENU(DIALOGS_PROPERTY_SHEET_TOOLBOOK, MyFrame::OnPropertySheetToolBook) + EVT_MENU(DIALOGS_PROPERTY_SHEET_TOOLBOOK, MyFrame::OnPropertySheet) + EVT_MENU(DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK, MyFrame::OnPropertySheet) #endif EVT_MENU(DIALOGS_REQUEST, MyFrame::OnRequestUserAttention) @@ -368,6 +369,7 @@ bool MyApp::OnInit() wxMenu *sheet_menu = new wxMenu; sheet_menu->Append(DIALOGS_PROPERTY_SHEET, _T("&Standard property sheet\tShift-Ctrl-P")); sheet_menu->Append(DIALOGS_PROPERTY_SHEET_TOOLBOOK, _T("&Toolbook sheet\tShift-Ctrl-T")); + sheet_menu->Append(DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK, _T("Button &Toolbook sheet\tShift-Ctrl-U")); file_menu->Append(wxID_ANY, _T("&Property sheets"), sheet_menu); #endif // USE_SETTINGS_DIALOG @@ -1005,15 +1007,9 @@ void MyFrame::ShowTip(wxCommandEvent& WXUNUSED(event)) #endif // wxUSE_STARTUP_TIPS #if USE_SETTINGS_DIALOG -void MyFrame::OnPropertySheet(wxCommandEvent& WXUNUSED(event)) +void MyFrame::OnPropertySheet(wxCommandEvent& event) { - SettingsDialog dialog(this); - dialog.ShowModal(); -} - -void MyFrame::OnPropertySheetToolBook(wxCommandEvent& WXUNUSED(event)) -{ - SettingsDialog dialog(this, true); + SettingsDialog dialog(this, event.GetId()); dialog.ShowModal(); } #endif // USE_SETTINGS_DIALOG @@ -1414,18 +1410,27 @@ IMPLEMENT_CLASS(SettingsDialog, wxPropertySheetDialog) BEGIN_EVENT_TABLE(SettingsDialog, wxPropertySheetDialog) END_EVENT_TABLE() -SettingsDialog::SettingsDialog(wxWindow* win, bool useToolBook) +SettingsDialog::SettingsDialog(wxWindow* win, int dialogType) { SetExtraStyle(wxDIALOG_EX_CONTEXTHELP|wxWS_EX_VALIDATE_RECURSIVELY); int tabImage1 = -1; int tabImage2 = -1; + + bool useToolBook = (dialogType == DIALOGS_PROPERTY_SHEET_TOOLBOOK || dialogType == DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK); if (useToolBook) { tabImage1 = 0; tabImage2 = 1; - SetSheetStyle(wxPROPSHEET_TOOLBOOK|wxPROPSHEET_SHRINKTOFIT); + + int sheetStyle = wxPROPSHEET_SHRINKTOFIT; + if (dialogType == DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK) + sheetStyle |= wxPROPSHEET_BUTTONTOOLBOOK; + else + sheetStyle |= wxPROPSHEET_TOOLBOOK; + + SetSheetStyle(sheetStyle); // create a dummy image list with a few icons const wxSize imageSize(32, 32); diff --git a/samples/dialogs/dialogs.h b/samples/dialogs/dialogs.h index 6b9b05064e..45e8d92843 100644 --- a/samples/dialogs/dialogs.h +++ b/samples/dialogs/dialogs.h @@ -147,7 +147,7 @@ class SettingsDialog: public wxPropertySheetDialog { DECLARE_CLASS(SettingsDialog) public: - SettingsDialog(wxWindow* parent, bool useToolBook = false); + SettingsDialog(wxWindow* parent, int dialogType); ~SettingsDialog(); wxPanel* CreateGeneralSettingsPage(wxWindow* parent); @@ -263,7 +263,6 @@ public: #endif // USE_FONTDLG_GENERIC void OnPropertySheet(wxCommandEvent& event); - void OnPropertySheetToolBook(wxCommandEvent& event); void OnRequestUserAttention(wxCommandEvent& event); void OnExit(wxCommandEvent& event); @@ -336,7 +335,8 @@ enum DIALOGS_REPLACE, DIALOGS_REQUEST, DIALOGS_PROPERTY_SHEET, - DIALOGS_PROPERTY_SHEET_TOOLBOOK + DIALOGS_PROPERTY_SHEET_TOOLBOOK, + DIALOGS_PROPERTY_SHEET_BUTTONTOOLBOOK }; #endif diff --git a/src/generic/buttonbar.cpp b/src/generic/buttonbar.cpp new file mode 100644 index 0000000000..f6a261c092 --- /dev/null +++ b/src/generic/buttonbar.cpp @@ -0,0 +1,428 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: src/generic/buttonbar.cpp +// Purpose: wxButtonToolBar implementation +// Author: Julian Smart, after Robert Roebling, Vadim Zeitlin, SciTech +// Modified by: +// Created: 2006-04-13 +// Id: $Id$ +// Copyright: (c) Julian Smart, Robert Roebling, Vadim Zeitlin, +// SciTech Software, Inc. +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +// ============================================================================ +// declarations +// ============================================================================ + +// ---------------------------------------------------------------------------- +// headers +// ---------------------------------------------------------------------------- + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#if wxUSE_TOOLBAR && wxUSE_BMPBUTTON + +#ifndef WX_PRECOMP + #include "wx/utils.h" + #include "wx/app.h" +#endif + +#include "wx/generic/buttonbar.h" +#include "wx/frame.h" +#include "wx/image.h" +#include "wx/log.h" + +// ---------------------------------------------------------------------------- +// wxButtonToolBarTool: our implementation of wxToolBarToolBase +// ---------------------------------------------------------------------------- + +class WXDLLEXPORT wxButtonToolBarTool : public wxToolBarToolBase +{ +public: + wxButtonToolBarTool(wxButtonToolBar *tbar, + int id, + const wxString& label, + const wxBitmap& bmpNormal, + const wxBitmap& bmpDisabled, + wxItemKind kind, + wxObject *clientData, + const wxString& shortHelp, + const wxString& longHelp) + : wxToolBarToolBase(tbar, id, label, bmpNormal, bmpDisabled, kind, + clientData, shortHelp, longHelp) + { + m_x = m_y = wxDefaultCoord; + m_width = + m_height = 0; + + m_button = NULL; + } + + wxButtonToolBarTool(wxButtonToolBar *tbar, wxControl *control) + : wxToolBarToolBase(tbar, control) + { + m_x = m_y = wxDefaultCoord; + m_width = + m_height = 0; + m_button = NULL; + } + + wxBitmapButton* GetButton() const { return m_button; } + void SetButton(wxBitmapButton* button) { m_button = button; } + +public: + // the tool position (for controls) + wxCoord m_x; + wxCoord m_y; + wxCoord m_width; + wxCoord m_height; + +private: + // the control representing the button + wxBitmapButton* m_button; +}; + +// ============================================================================ +// wxButtonToolBar implementation +// ============================================================================ + +IMPLEMENT_DYNAMIC_CLASS(wxButtonToolBar, wxControl) + +BEGIN_EVENT_TABLE(wxButtonToolBar, wxControl) + EVT_BUTTON(wxID_ANY, wxButtonToolBar::OnCommand) +END_EVENT_TABLE() + +// ---------------------------------------------------------------------------- +// wxButtonToolBar creation +// ---------------------------------------------------------------------------- + +void wxButtonToolBar::Init() +{ + // no tools yet + m_needsLayout = false; + + // unknown widths for the tools and separators + m_widthSeparator = wxDefaultCoord; + + m_maxWidth = + m_maxHeight = 0; +} + +bool wxButtonToolBar::Create(wxWindow *parent, + wxWindowID id, + const wxPoint& pos, + const wxSize& size, + long style, + const wxString& name) +{ + if ( !wxToolBarBase::Create(parent, id, pos, size, style, + wxDefaultValidator, name) ) + { + return false; + } + + return true; +} + +wxButtonToolBar::~wxButtonToolBar() +{ +} + +// ---------------------------------------------------------------------------- +// wxButtonToolBar tool-related methods +// ---------------------------------------------------------------------------- + +wxToolBarToolBase *wxButtonToolBar::FindToolForPosition(wxCoord x, wxCoord y) const +{ + // check the "other" direction first: it must be inside the toolbar or we + // don't risk finding anything + if ( IsVertical() ) + { + if ( x < 0 || x > m_maxWidth ) + return NULL; + + // we always use x, even for a vertical toolbar, this makes the code + // below simpler + x = y; + } + else // horizontal + { + if ( y < 0 || y > m_maxHeight ) + return NULL; + } + + for ( wxToolBarToolsList::compatibility_iterator node = m_tools.GetFirst(); + node; + node = node->GetNext() ) + { + wxButtonToolBarTool *tool = (wxButtonToolBarTool*) node->GetData(); + wxRect rectTool = GetToolRect(tool); + + wxCoord startTool, endTool; + GetRectLimits(rectTool, &startTool, &endTool); + + if ( x >= startTool && x <= endTool ) + { + // don't return the separators from here, they don't accept any + // input anyhow + return tool->IsSeparator() ? NULL : tool; + } + } + + return NULL; +} + +void wxButtonToolBar::GetRectLimits(const wxRect& rect, + wxCoord *start, + wxCoord *end) const +{ + wxCHECK_RET( start && end, _T("NULL pointer in GetRectLimits") ); + + if ( IsVertical() ) + { + *start = rect.GetTop(); + *end = rect.GetBottom(); + } + else // horizontal + { + *start = rect.GetLeft(); + *end = rect.GetRight(); + } +} + + +void wxButtonToolBar::SetToolShortHelp(int id, const wxString& help) +{ + wxToolBarToolBase *tool = FindById(id); + + wxCHECK_RET( tool, _T("SetToolShortHelp: no such tool") ); + + // TODO: set tooltip/short help + tool->SetShortHelp(help); +} + +bool wxButtonToolBar::DoInsertTool(size_t WXUNUSED(pos), + wxToolBarToolBase * WXUNUSED(tool)) +{ + return true; +} + +bool wxButtonToolBar::DoDeleteTool(size_t WXUNUSED(pos), + wxToolBarToolBase * WXUNUSED(tool)) +{ + // TODO + return true; +} + +void wxButtonToolBar::DoEnableTool(wxToolBarToolBase *WXUNUSED(tool), bool WXUNUSED(enable)) +{ + // TODO +} + +void wxButtonToolBar::DoToggleTool(wxToolBarToolBase *WXUNUSED(tool), bool WXUNUSED(toggle)) +{ + // TODO +} + +void wxButtonToolBar::DoSetToggle(wxToolBarToolBase *WXUNUSED(tool), bool WXUNUSED(toggle)) +{ + // TODO +} + +wxToolBarToolBase *wxButtonToolBar::CreateTool(int id, + const wxString& label, + const wxBitmap& bmpNormal, + const wxBitmap& bmpDisabled, + wxItemKind kind, + wxObject *clientData, + const wxString& shortHelp, + const wxString& longHelp) +{ + return new wxButtonToolBarTool(this, id, label, bmpNormal, bmpDisabled, kind, + clientData, shortHelp, longHelp); +} + +wxToolBarToolBase *wxButtonToolBar::CreateTool(wxControl *control) +{ + return new wxButtonToolBarTool(this, control); +} + +// ---------------------------------------------------------------------------- +// wxButtonToolBar geometry +// ---------------------------------------------------------------------------- + +wxRect wxButtonToolBar::GetToolRect(wxToolBarToolBase *toolBase) const +{ + const wxButtonToolBarTool *tool = (wxButtonToolBarTool *)toolBase; + + wxRect rect; + + wxCHECK_MSG( tool, rect, _T("GetToolRect: NULL tool") ); + + // ensure that we always have the valid tool position + if ( m_needsLayout ) + { + wxConstCast(this, wxButtonToolBar)->DoLayout(); + } + + rect.x = tool->m_x - m_xMargin; + rect.y = tool->m_y - m_yMargin; + + if ( IsVertical() ) + { + if (tool->IsButton()) + { + rect.width = m_defaultWidth; + rect.height = m_defaultHeight; + if (tool->GetButton()) + rect.SetSize(tool->GetButton()->GetSize()); + } + else if (tool->IsSeparator()) + { + rect.width = m_defaultWidth; + rect.height = m_widthSeparator; + } + else // control + { + rect.width = tool->m_width; + rect.height = tool->m_height; + } + } + else // horizontal + { + if (tool->IsButton()) + { + rect.width = m_defaultWidth; + rect.height = m_defaultHeight; + if (tool->GetButton()) + rect.SetSize(tool->GetButton()->GetSize()); + } + else if (tool->IsSeparator()) + { + rect.width = m_widthSeparator; + rect.height = m_defaultHeight; + } + else // control + { + rect.width = tool->m_width; + rect.height = tool->m_height; + } + } + + rect.width += 2*m_xMargin; + rect.height += 2*m_yMargin; + + return rect; +} + +bool wxButtonToolBar::Realize() +{ + if ( !wxToolBarBase::Realize() ) + return false; + + m_needsLayout = true; + DoLayout(); + + SetBestSize(wxSize(m_maxWidth, m_maxHeight)); + + return true; +} + +void wxButtonToolBar::DoLayout() +{ + m_needsLayout = false; + + wxCoord x = m_xMargin, + y = m_yMargin; + + int maxHeight = 0; + + const wxCoord widthTool = IsVertical() ? m_defaultHeight : m_defaultWidth; + wxCoord margin = IsVertical() ? m_xMargin : m_yMargin; + wxCoord *pCur = IsVertical() ? &y : &x; + + // calculate the positions of all elements + for ( wxToolBarToolsList::compatibility_iterator node = m_tools.GetFirst(); + node; + node = node->GetNext() ) + { + wxButtonToolBarTool *tool = (wxButtonToolBarTool *) node->GetData(); + + tool->m_x = x; + tool->m_y = y; + + if (tool->IsButton()) + { + if (!tool->GetButton()) + { + wxBitmapButton* bmpButton = new wxBitmapButton(this, tool->GetId(), tool->GetNormalBitmap(), wxPoint(tool->m_x, tool->m_y), wxDefaultSize, + wxBU_AUTODRAW); + + tool->SetButton(bmpButton); + } + else + { + tool->GetButton()->Move(wxPoint(tool->m_x, tool->m_y)); + } + + int w = widthTool; + if (tool->GetButton()) + { + wxSize sz = tool->GetButton()->GetSize(); + w = sz.x; + + maxHeight = wxMax(maxHeight, sz.y); + } + + *pCur += (w + GetToolPacking()); + } + else if (tool->IsSeparator()) + { + *pCur += m_widthSeparator; + } + else if (!IsVertical()) // horizontal control + { + wxControl *control = tool->GetControl(); + wxSize size = control->GetSize(); + tool->m_y += (m_defaultHeight - size.y)/2; + tool->m_width = size.x; + tool->m_height = size.y; + + *pCur += tool->m_width; + + maxHeight = wxMax(maxHeight, size.y); + } + *pCur += margin; + } + + // calculate the total toolbar size + m_maxWidth = x + 2*m_xMargin; + m_maxHeight = maxHeight + 2*m_yMargin; +} + +wxSize wxButtonToolBar::DoGetBestClientSize() const +{ + return wxSize(m_maxWidth, m_maxHeight); +} + +// receives button commands +void wxButtonToolBar::OnCommand(wxCommandEvent& event) +{ + wxButtonToolBarTool* tool = (wxButtonToolBarTool*) FindById(event.GetId()); + if (!tool) + { + event.Skip(); + return; + } + + // TODO: handle toggle items + OnLeftClick(event.GetId(), false); +} + +#endif // wxUSE_TOOLBAR && wxUSE_BMPBUTTON + diff --git a/src/generic/propdlg.cpp b/src/generic/propdlg.cpp index aa4589b2b9..096758dcc4 100644 --- a/src/generic/propdlg.cpp +++ b/src/generic/propdlg.cpp @@ -154,7 +154,12 @@ wxBookCtrlBase* wxPropertySheetDialog::CreateBookCtrl() bookCtrl = new wxChoicebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, style ); #endif #if wxUSE_TOOLBOOK - if (GetSheetStyle() & wxPROPSHEET_TOOLBOOK) +#if wxUSE_TOOLBAR && wxUSE_BMPBUTTON + if (GetSheetStyle() & wxPROPSHEET_BUTTONTOOLBOOK) + bookCtrl = new wxToolbook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, style|wxBK_BUTTONBAR ); + else +#endif + if ((GetSheetStyle() & wxPROPSHEET_TOOLBOOK) || (GetSheetStyle() & wxPROPSHEET_BUTTONTOOLBOOK)) bookCtrl = new wxToolbook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, style ); #endif #if wxUSE_LISTBOOK diff --git a/src/generic/toolbkg.cpp b/src/generic/toolbkg.cpp index f5720f5ab8..b2536e57ae 100644 --- a/src/generic/toolbkg.cpp +++ b/src/generic/toolbkg.cpp @@ -27,6 +27,7 @@ #include "wx/imaglist.h" #include "wx/sysopt.h" #include "wx/toolbook.h" +#include "wx/generic/buttonbar.h" // ---------------------------------------------------------------------------- // various wxWidgets macros @@ -89,7 +90,21 @@ bool wxToolbook::Create(wxWindow *parent, orient = wxTB_VERTICAL; // TODO: make more configurable - m_bookctrl = new wxToolBar + + if (style & wxBK_BUTTONBAR) + { + m_bookctrl = new wxButtonToolBar + ( + this, + wxID_TOOLBOOKTOOLBAR, + wxDefaultPosition, + wxDefaultSize, + orient|wxTB_TEXT|wxTB_FLAT|wxTB_NODIVIDER|wxNO_BORDER + ); + } + else + { + m_bookctrl = new wxToolBar ( this, wxID_TOOLBOOKTOOLBAR, @@ -97,6 +112,7 @@ bool wxToolbook::Create(wxWindow *parent, wxDefaultSize, orient | wxTB_TEXT|wxTB_FLAT|wxTB_NODIVIDER ); + } return true; } -- 2.45.2