Refactor: create src/univ/anybutton.cpp.

Extract and pull the common functions from wxButton and wxToggleButton to
wxAnyButton in wxUniv too.

Also make wxToggleButton inherit from wxToggleButtonBase correctly

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@77759 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2014-09-23 17:38:47 +00:00
parent 16601713a4
commit 43c99ef613
12 changed files with 497 additions and 386 deletions

View File

@ -4887,6 +4887,7 @@ COND_USE_GUI_1_WXUNIV_1___CORE_SRC_OBJECTS = \
monodll_generic_listctrl.o \
monodll_mdig.o \
monodll_prntdlgg.o \
monodll_univ_anybutton.o \
monodll_univ_bmpbuttn.o \
monodll_univ_button.o \
monodll_univ_checkbox.o \
@ -7243,6 +7244,7 @@ COND_USE_GUI_1_WXUNIV_1___CORE_SRC_OBJECTS_1 = \
monolib_generic_listctrl.o \
monolib_mdig.o \
monolib_prntdlgg.o \
monolib_univ_anybutton.o \
monolib_univ_bmpbuttn.o \
monolib_univ_button.o \
monolib_univ_checkbox.o \
@ -9756,6 +9758,7 @@ COND_USE_GUI_1_WXUNIV_1___CORE_SRC_OBJECTS_2 = \
coredll_generic_listctrl.o \
coredll_mdig.o \
coredll_prntdlgg.o \
coredll_univ_anybutton.o \
coredll_univ_bmpbuttn.o \
coredll_univ_button.o \
coredll_univ_checkbox.o \
@ -11533,6 +11536,7 @@ COND_USE_GUI_1_WXUNIV_1___CORE_SRC_OBJECTS_3 = \
corelib_generic_listctrl.o \
corelib_mdig.o \
corelib_prntdlgg.o \
corelib_univ_anybutton.o \
corelib_univ_bmpbuttn.o \
corelib_univ_button.o \
corelib_univ_checkbox.o \
@ -18489,6 +18493,9 @@ monodll_cocoa_utilsexc.o: $(srcdir)/src/cocoa/utilsexc.mm $(MONODLL_ODEP)
monodll_src_cocoa_window.o: $(srcdir)/src/cocoa/window.mm $(MONODLL_ODEP)
$(CXXC) -c -o $@ $(MONODLL_OBJCXXFLAGS) $(srcdir)/src/cocoa/window.mm
monodll_univ_anybutton.o: $(srcdir)/src/univ/anybutton.cpp $(MONODLL_ODEP)
$(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/univ/anybutton.cpp
monodll_univ_bmpbuttn.o: $(srcdir)/src/univ/bmpbuttn.cpp $(MONODLL_ODEP)
$(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/univ/bmpbuttn.cpp
@ -24372,6 +24379,9 @@ monolib_cocoa_utilsexc.o: $(srcdir)/src/cocoa/utilsexc.mm $(MONOLIB_ODEP)
monolib_src_cocoa_window.o: $(srcdir)/src/cocoa/window.mm $(MONOLIB_ODEP)
$(CXXC) -c -o $@ $(MONOLIB_OBJCXXFLAGS) $(srcdir)/src/cocoa/window.mm
monolib_univ_anybutton.o: $(srcdir)/src/univ/anybutton.cpp $(MONOLIB_ODEP)
$(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/univ/anybutton.cpp
monolib_univ_bmpbuttn.o: $(srcdir)/src/univ/bmpbuttn.cpp $(MONOLIB_ODEP)
$(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/univ/bmpbuttn.cpp
@ -30933,6 +30943,9 @@ coredll_utilsexc.o: $(srcdir)/src/cocoa/utilsexc.mm $(COREDLL_ODEP)
coredll_src_cocoa_window.o: $(srcdir)/src/cocoa/window.mm $(COREDLL_ODEP)
$(CXXC) -c -o $@ $(COREDLL_OBJCXXFLAGS) $(srcdir)/src/cocoa/window.mm
coredll_univ_anybutton.o: $(srcdir)/src/univ/anybutton.cpp $(COREDLL_ODEP)
$(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/univ/anybutton.cpp
coredll_univ_bmpbuttn.o: $(srcdir)/src/univ/bmpbuttn.cpp $(COREDLL_ODEP)
$(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/univ/bmpbuttn.cpp
@ -35328,6 +35341,9 @@ corelib_utilsexc.o: $(srcdir)/src/cocoa/utilsexc.mm $(CORELIB_ODEP)
corelib_src_cocoa_window.o: $(srcdir)/src/cocoa/window.mm $(CORELIB_ODEP)
$(CXXC) -c -o $@ $(CORELIB_OBJCXXFLAGS) $(srcdir)/src/cocoa/window.mm
corelib_univ_anybutton.o: $(srcdir)/src/univ/anybutton.cpp $(CORELIB_ODEP)
$(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/univ/anybutton.cpp
corelib_univ_bmpbuttn.o: $(srcdir)/src/univ/bmpbuttn.cpp $(CORELIB_ODEP)
$(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/univ/bmpbuttn.cpp

View File

@ -2833,6 +2833,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
src/generic/listctrl.cpp
src/generic/mdig.cpp
src/generic/prntdlgg.cpp
src/univ/anybutton.cpp
src/univ/bmpbuttn.cpp
src/univ/button.cpp
src/univ/checkbox.cpp

View File

@ -2409,6 +2409,7 @@ UNIV_SRC =
src/generic/listctrl.cpp
src/generic/mdig.cpp
src/generic/prntdlgg.cpp
src/univ/anybutton.cpp
src/univ/bmpbuttn.cpp
src/univ/button.cpp
src/univ/checkbox.cpp

View File

@ -1819,7 +1819,7 @@ ____CORE_SRC_FILENAMES_OBJECTS = \
$(OBJS)\monodll_generic_statusbr.obj \
$(OBJS)\monodll_prntdlgg.obj \
$(OBJS)\monodll_msw_accel.obj \
$(OBJS)\monodll_anybutton.obj \
$(OBJS)\monodll_msw_anybutton.obj \
$(OBJS)\monodll_artmsw.obj \
$(OBJS)\monodll_appprogress.obj \
$(OBJS)\monodll_msw_bmpbuttn.obj \
@ -2110,6 +2110,7 @@ ____CORE_SRC_FILENAMES_OBJECTS = \
$(OBJS)\monodll_generic_listctrl.obj \
$(OBJS)\monodll_mdig.obj \
$(OBJS)\monodll_prntdlgg.obj \
$(OBJS)\monodll_univ_anybutton.obj \
$(OBJS)\monodll_univ_bmpbuttn.obj \
$(OBJS)\monodll_univ_button.obj \
$(OBJS)\monodll_univ_checkbox.obj \
@ -2631,7 +2632,7 @@ ____CORE_SRC_FILENAMES_1_OBJECTS = \
$(OBJS)\monolib_generic_statusbr.obj \
$(OBJS)\monolib_prntdlgg.obj \
$(OBJS)\monolib_msw_accel.obj \
$(OBJS)\monolib_anybutton.obj \
$(OBJS)\monolib_msw_anybutton.obj \
$(OBJS)\monolib_artmsw.obj \
$(OBJS)\monolib_appprogress.obj \
$(OBJS)\monolib_msw_bmpbuttn.obj \
@ -2922,6 +2923,7 @@ ____CORE_SRC_FILENAMES_1_OBJECTS = \
$(OBJS)\monolib_generic_listctrl.obj \
$(OBJS)\monolib_mdig.obj \
$(OBJS)\monolib_prntdlgg.obj \
$(OBJS)\monolib_univ_anybutton.obj \
$(OBJS)\monolib_univ_bmpbuttn.obj \
$(OBJS)\monolib_univ_button.obj \
$(OBJS)\monolib_univ_checkbox.obj \
@ -3319,7 +3321,7 @@ ____CORE_SRC_FILENAMES_2_OBJECTS = \
$(OBJS)\coredll_generic_statusbr.obj \
$(OBJS)\coredll_prntdlgg.obj \
$(OBJS)\coredll_msw_accel.obj \
$(OBJS)\coredll_anybutton.obj \
$(OBJS)\coredll_msw_anybutton.obj \
$(OBJS)\coredll_artmsw.obj \
$(OBJS)\coredll_appprogress.obj \
$(OBJS)\coredll_msw_bmpbuttn.obj \
@ -3610,6 +3612,7 @@ ____CORE_SRC_FILENAMES_2_OBJECTS = \
$(OBJS)\coredll_generic_listctrl.obj \
$(OBJS)\coredll_mdig.obj \
$(OBJS)\coredll_prntdlgg.obj \
$(OBJS)\coredll_univ_anybutton.obj \
$(OBJS)\coredll_univ_bmpbuttn.obj \
$(OBJS)\coredll_univ_button.obj \
$(OBJS)\coredll_univ_checkbox.obj \
@ -3883,7 +3886,7 @@ ____CORE_SRC_FILENAMES_3_OBJECTS = \
$(OBJS)\corelib_generic_statusbr.obj \
$(OBJS)\corelib_prntdlgg.obj \
$(OBJS)\corelib_msw_accel.obj \
$(OBJS)\corelib_anybutton.obj \
$(OBJS)\corelib_msw_anybutton.obj \
$(OBJS)\corelib_artmsw.obj \
$(OBJS)\corelib_appprogress.obj \
$(OBJS)\corelib_msw_bmpbuttn.obj \
@ -4174,6 +4177,7 @@ ____CORE_SRC_FILENAMES_3_OBJECTS = \
$(OBJS)\corelib_generic_listctrl.obj \
$(OBJS)\corelib_mdig.obj \
$(OBJS)\corelib_prntdlgg.obj \
$(OBJS)\corelib_univ_anybutton.obj \
$(OBJS)\corelib_univ_bmpbuttn.obj \
$(OBJS)\corelib_univ_button.obj \
$(OBJS)\corelib_univ_checkbox.obj \
@ -6647,7 +6651,7 @@ $(OBJS)\monodll_generic_statusbr.obj: ..\..\src\generic\statusbr.cpp
$(OBJS)\monodll_msw_accel.obj: ..\..\src\msw\accel.cpp
$(CXX) -q -c -P -o$@ $(MONODLL_CXXFLAGS) ..\..\src\msw\accel.cpp
$(OBJS)\monodll_anybutton.obj: ..\..\src\msw\anybutton.cpp
$(OBJS)\monodll_msw_anybutton.obj: ..\..\src\msw\anybutton.cpp
$(CXX) -q -c -P -o$@ $(MONODLL_CXXFLAGS) ..\..\src\msw\anybutton.cpp
$(OBJS)\monodll_artmsw.obj: ..\..\src\msw\artmsw.cpp
@ -6833,6 +6837,9 @@ $(OBJS)\monodll_generic_listctrl.obj: ..\..\src\generic\listctrl.cpp
$(OBJS)\monodll_mdig.obj: ..\..\src\generic\mdig.cpp
$(CXX) -q -c -P -o$@ $(MONODLL_CXXFLAGS) ..\..\src\generic\mdig.cpp
$(OBJS)\monodll_univ_anybutton.obj: ..\..\src\univ\anybutton.cpp
$(CXX) -q -c -P -o$@ $(MONODLL_CXXFLAGS) ..\..\src\univ\anybutton.cpp
$(OBJS)\monodll_univ_bmpbuttn.obj: ..\..\src\univ\bmpbuttn.cpp
$(CXX) -q -c -P -o$@ $(MONODLL_CXXFLAGS) ..\..\src\univ\bmpbuttn.cpp
@ -9129,7 +9136,7 @@ $(OBJS)\monolib_generic_statusbr.obj: ..\..\src\generic\statusbr.cpp
$(OBJS)\monolib_msw_accel.obj: ..\..\src\msw\accel.cpp
$(CXX) -q -c -P -o$@ $(MONOLIB_CXXFLAGS) ..\..\src\msw\accel.cpp
$(OBJS)\monolib_anybutton.obj: ..\..\src\msw\anybutton.cpp
$(OBJS)\monolib_msw_anybutton.obj: ..\..\src\msw\anybutton.cpp
$(CXX) -q -c -P -o$@ $(MONOLIB_CXXFLAGS) ..\..\src\msw\anybutton.cpp
$(OBJS)\monolib_artmsw.obj: ..\..\src\msw\artmsw.cpp
@ -9315,6 +9322,9 @@ $(OBJS)\monolib_generic_listctrl.obj: ..\..\src\generic\listctrl.cpp
$(OBJS)\monolib_mdig.obj: ..\..\src\generic\mdig.cpp
$(CXX) -q -c -P -o$@ $(MONOLIB_CXXFLAGS) ..\..\src\generic\mdig.cpp
$(OBJS)\monolib_univ_anybutton.obj: ..\..\src\univ\anybutton.cpp
$(CXX) -q -c -P -o$@ $(MONOLIB_CXXFLAGS) ..\..\src\univ\anybutton.cpp
$(OBJS)\monolib_univ_bmpbuttn.obj: ..\..\src\univ\bmpbuttn.cpp
$(CXX) -q -c -P -o$@ $(MONOLIB_CXXFLAGS) ..\..\src\univ\bmpbuttn.cpp
@ -12019,7 +12029,7 @@ $(OBJS)\coredll_generic_statusbr.obj: ..\..\src\generic\statusbr.cpp
$(OBJS)\coredll_msw_accel.obj: ..\..\src\msw\accel.cpp
$(CXX) -q -c -P -o$@ $(COREDLL_CXXFLAGS) ..\..\src\msw\accel.cpp
$(OBJS)\coredll_anybutton.obj: ..\..\src\msw\anybutton.cpp
$(OBJS)\coredll_msw_anybutton.obj: ..\..\src\msw\anybutton.cpp
$(CXX) -q -c -P -o$@ $(COREDLL_CXXFLAGS) ..\..\src\msw\anybutton.cpp
$(OBJS)\coredll_artmsw.obj: ..\..\src\msw\artmsw.cpp
@ -12205,6 +12215,9 @@ $(OBJS)\coredll_generic_listctrl.obj: ..\..\src\generic\listctrl.cpp
$(OBJS)\coredll_mdig.obj: ..\..\src\generic\mdig.cpp
$(CXX) -q -c -P -o$@ $(COREDLL_CXXFLAGS) ..\..\src\generic\mdig.cpp
$(OBJS)\coredll_univ_anybutton.obj: ..\..\src\univ\anybutton.cpp
$(CXX) -q -c -P -o$@ $(COREDLL_CXXFLAGS) ..\..\src\univ\anybutton.cpp
$(OBJS)\coredll_univ_bmpbuttn.obj: ..\..\src\univ\bmpbuttn.cpp
$(CXX) -q -c -P -o$@ $(COREDLL_CXXFLAGS) ..\..\src\univ\bmpbuttn.cpp
@ -13477,7 +13490,7 @@ $(OBJS)\corelib_generic_statusbr.obj: ..\..\src\generic\statusbr.cpp
$(OBJS)\corelib_msw_accel.obj: ..\..\src\msw\accel.cpp
$(CXX) -q -c -P -o$@ $(CORELIB_CXXFLAGS) ..\..\src\msw\accel.cpp
$(OBJS)\corelib_anybutton.obj: ..\..\src\msw\anybutton.cpp
$(OBJS)\corelib_msw_anybutton.obj: ..\..\src\msw\anybutton.cpp
$(CXX) -q -c -P -o$@ $(CORELIB_CXXFLAGS) ..\..\src\msw\anybutton.cpp
$(OBJS)\corelib_artmsw.obj: ..\..\src\msw\artmsw.cpp
@ -13663,6 +13676,9 @@ $(OBJS)\corelib_generic_listctrl.obj: ..\..\src\generic\listctrl.cpp
$(OBJS)\corelib_mdig.obj: ..\..\src\generic\mdig.cpp
$(CXX) -q -c -P -o$@ $(CORELIB_CXXFLAGS) ..\..\src\generic\mdig.cpp
$(OBJS)\corelib_univ_anybutton.obj: ..\..\src\univ\anybutton.cpp
$(CXX) -q -c -P -o$@ $(CORELIB_CXXFLAGS) ..\..\src\univ\anybutton.cpp
$(OBJS)\corelib_univ_bmpbuttn.obj: ..\..\src\univ\bmpbuttn.cpp
$(CXX) -q -c -P -o$@ $(CORELIB_CXXFLAGS) ..\..\src\univ\bmpbuttn.cpp

View File

@ -1838,7 +1838,7 @@ ____CORE_SRC_FILENAMES_OBJECTS = \
$(OBJS)\monodll_generic_statusbr.o \
$(OBJS)\monodll_prntdlgg.o \
$(OBJS)\monodll_msw_accel.o \
$(OBJS)\monodll_anybutton.o \
$(OBJS)\monodll_msw_anybutton.o \
$(OBJS)\monodll_artmsw.o \
$(OBJS)\monodll_appprogress.o \
$(OBJS)\monodll_msw_bmpbuttn.o \
@ -2131,6 +2131,7 @@ ____CORE_SRC_FILENAMES_OBJECTS = \
$(OBJS)\monodll_generic_listctrl.o \
$(OBJS)\monodll_mdig.o \
$(OBJS)\monodll_prntdlgg.o \
$(OBJS)\monodll_univ_anybutton.o \
$(OBJS)\monodll_univ_bmpbuttn.o \
$(OBJS)\monodll_univ_button.o \
$(OBJS)\monodll_univ_checkbox.o \
@ -2656,7 +2657,7 @@ ____CORE_SRC_FILENAMES_1_OBJECTS = \
$(OBJS)\monolib_generic_statusbr.o \
$(OBJS)\monolib_prntdlgg.o \
$(OBJS)\monolib_msw_accel.o \
$(OBJS)\monolib_anybutton.o \
$(OBJS)\monolib_msw_anybutton.o \
$(OBJS)\monolib_artmsw.o \
$(OBJS)\monolib_appprogress.o \
$(OBJS)\monolib_msw_bmpbuttn.o \
@ -2949,6 +2950,7 @@ ____CORE_SRC_FILENAMES_1_OBJECTS = \
$(OBJS)\monolib_generic_listctrl.o \
$(OBJS)\monolib_mdig.o \
$(OBJS)\monolib_prntdlgg.o \
$(OBJS)\monolib_univ_anybutton.o \
$(OBJS)\monolib_univ_bmpbuttn.o \
$(OBJS)\monolib_univ_button.o \
$(OBJS)\monolib_univ_checkbox.o \
@ -3360,7 +3362,7 @@ ____CORE_SRC_FILENAMES_2_OBJECTS = \
$(OBJS)\coredll_generic_statusbr.o \
$(OBJS)\coredll_prntdlgg.o \
$(OBJS)\coredll_msw_accel.o \
$(OBJS)\coredll_anybutton.o \
$(OBJS)\coredll_msw_anybutton.o \
$(OBJS)\coredll_artmsw.o \
$(OBJS)\coredll_appprogress.o \
$(OBJS)\coredll_msw_bmpbuttn.o \
@ -3653,6 +3655,7 @@ ____CORE_SRC_FILENAMES_2_OBJECTS = \
$(OBJS)\coredll_generic_listctrl.o \
$(OBJS)\coredll_mdig.o \
$(OBJS)\coredll_prntdlgg.o \
$(OBJS)\coredll_univ_anybutton.o \
$(OBJS)\coredll_univ_bmpbuttn.o \
$(OBJS)\coredll_univ_button.o \
$(OBJS)\coredll_univ_checkbox.o \
@ -3932,7 +3935,7 @@ ____CORE_SRC_FILENAMES_3_OBJECTS = \
$(OBJS)\corelib_generic_statusbr.o \
$(OBJS)\corelib_prntdlgg.o \
$(OBJS)\corelib_msw_accel.o \
$(OBJS)\corelib_anybutton.o \
$(OBJS)\corelib_msw_anybutton.o \
$(OBJS)\corelib_artmsw.o \
$(OBJS)\corelib_appprogress.o \
$(OBJS)\corelib_msw_bmpbuttn.o \
@ -4225,6 +4228,7 @@ ____CORE_SRC_FILENAMES_3_OBJECTS = \
$(OBJS)\corelib_generic_listctrl.o \
$(OBJS)\corelib_mdig.o \
$(OBJS)\corelib_prntdlgg.o \
$(OBJS)\corelib_univ_anybutton.o \
$(OBJS)\corelib_univ_bmpbuttn.o \
$(OBJS)\corelib_univ_button.o \
$(OBJS)\corelib_univ_checkbox.o \
@ -6822,7 +6826,7 @@ $(OBJS)\monodll_generic_statusbr.o: ../../src/generic/statusbr.cpp
$(OBJS)\monodll_msw_accel.o: ../../src/msw/accel.cpp
$(CXX) -c -o $@ $(MONODLL_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\monodll_anybutton.o: ../../src/msw/anybutton.cpp
$(OBJS)\monodll_msw_anybutton.o: ../../src/msw/anybutton.cpp
$(CXX) -c -o $@ $(MONODLL_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\monodll_artmsw.o: ../../src/msw/artmsw.cpp
@ -7008,6 +7012,9 @@ $(OBJS)\monodll_generic_listctrl.o: ../../src/generic/listctrl.cpp
$(OBJS)\monodll_mdig.o: ../../src/generic/mdig.cpp
$(CXX) -c -o $@ $(MONODLL_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\monodll_univ_anybutton.o: ../../src/univ/anybutton.cpp
$(CXX) -c -o $@ $(MONODLL_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\monodll_univ_bmpbuttn.o: ../../src/univ/bmpbuttn.cpp
$(CXX) -c -o $@ $(MONODLL_CXXFLAGS) $(CPPDEPS) $<
@ -9304,7 +9311,7 @@ $(OBJS)\monolib_generic_statusbr.o: ../../src/generic/statusbr.cpp
$(OBJS)\monolib_msw_accel.o: ../../src/msw/accel.cpp
$(CXX) -c -o $@ $(MONOLIB_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\monolib_anybutton.o: ../../src/msw/anybutton.cpp
$(OBJS)\monolib_msw_anybutton.o: ../../src/msw/anybutton.cpp
$(CXX) -c -o $@ $(MONOLIB_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\monolib_artmsw.o: ../../src/msw/artmsw.cpp
@ -9490,6 +9497,9 @@ $(OBJS)\monolib_generic_listctrl.o: ../../src/generic/listctrl.cpp
$(OBJS)\monolib_mdig.o: ../../src/generic/mdig.cpp
$(CXX) -c -o $@ $(MONOLIB_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\monolib_univ_anybutton.o: ../../src/univ/anybutton.cpp
$(CXX) -c -o $@ $(MONOLIB_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\monolib_univ_bmpbuttn.o: ../../src/univ/bmpbuttn.cpp
$(CXX) -c -o $@ $(MONOLIB_CXXFLAGS) $(CPPDEPS) $<
@ -12194,7 +12204,7 @@ $(OBJS)\coredll_generic_statusbr.o: ../../src/generic/statusbr.cpp
$(OBJS)\coredll_msw_accel.o: ../../src/msw/accel.cpp
$(CXX) -c -o $@ $(COREDLL_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\coredll_anybutton.o: ../../src/msw/anybutton.cpp
$(OBJS)\coredll_msw_anybutton.o: ../../src/msw/anybutton.cpp
$(CXX) -c -o $@ $(COREDLL_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\coredll_artmsw.o: ../../src/msw/artmsw.cpp
@ -12380,6 +12390,9 @@ $(OBJS)\coredll_generic_listctrl.o: ../../src/generic/listctrl.cpp
$(OBJS)\coredll_mdig.o: ../../src/generic/mdig.cpp
$(CXX) -c -o $@ $(COREDLL_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\coredll_univ_anybutton.o: ../../src/univ/anybutton.cpp
$(CXX) -c -o $@ $(COREDLL_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\coredll_univ_bmpbuttn.o: ../../src/univ/bmpbuttn.cpp
$(CXX) -c -o $@ $(COREDLL_CXXFLAGS) $(CPPDEPS) $<
@ -13652,7 +13665,7 @@ $(OBJS)\corelib_generic_statusbr.o: ../../src/generic/statusbr.cpp
$(OBJS)\corelib_msw_accel.o: ../../src/msw/accel.cpp
$(CXX) -c -o $@ $(CORELIB_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\corelib_anybutton.o: ../../src/msw/anybutton.cpp
$(OBJS)\corelib_msw_anybutton.o: ../../src/msw/anybutton.cpp
$(CXX) -c -o $@ $(CORELIB_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\corelib_artmsw.o: ../../src/msw/artmsw.cpp
@ -13838,6 +13851,9 @@ $(OBJS)\corelib_generic_listctrl.o: ../../src/generic/listctrl.cpp
$(OBJS)\corelib_mdig.o: ../../src/generic/mdig.cpp
$(CXX) -c -o $@ $(CORELIB_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\corelib_univ_anybutton.o: ../../src/univ/anybutton.cpp
$(CXX) -c -o $@ $(CORELIB_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\corelib_univ_bmpbuttn.o: ../../src/univ/bmpbuttn.cpp
$(CXX) -c -o $@ $(CORELIB_CXXFLAGS) $(CPPDEPS) $<

View File

@ -2119,7 +2119,7 @@ ____CORE_SRC_FILENAMES_OBJECTS = \
$(OBJS)\monodll_generic_statusbr.obj \
$(OBJS)\monodll_prntdlgg.obj \
$(OBJS)\monodll_msw_accel.obj \
$(OBJS)\monodll_anybutton.obj \
$(OBJS)\monodll_msw_anybutton.obj \
$(OBJS)\monodll_artmsw.obj \
$(OBJS)\monodll_appprogress.obj \
$(OBJS)\monodll_msw_bmpbuttn.obj \
@ -2410,6 +2410,7 @@ ____CORE_SRC_FILENAMES_OBJECTS = \
$(OBJS)\monodll_generic_listctrl.obj \
$(OBJS)\monodll_mdig.obj \
$(OBJS)\monodll_prntdlgg.obj \
$(OBJS)\monodll_univ_anybutton.obj \
$(OBJS)\monodll_univ_bmpbuttn.obj \
$(OBJS)\monodll_univ_button.obj \
$(OBJS)\monodll_univ_checkbox.obj \
@ -2937,7 +2938,7 @@ ____CORE_SRC_FILENAMES_1_OBJECTS = \
$(OBJS)\monolib_generic_statusbr.obj \
$(OBJS)\monolib_prntdlgg.obj \
$(OBJS)\monolib_msw_accel.obj \
$(OBJS)\monolib_anybutton.obj \
$(OBJS)\monolib_msw_anybutton.obj \
$(OBJS)\monolib_artmsw.obj \
$(OBJS)\monolib_appprogress.obj \
$(OBJS)\monolib_msw_bmpbuttn.obj \
@ -3228,6 +3229,7 @@ ____CORE_SRC_FILENAMES_1_OBJECTS = \
$(OBJS)\monolib_generic_listctrl.obj \
$(OBJS)\monolib_mdig.obj \
$(OBJS)\monolib_prntdlgg.obj \
$(OBJS)\monolib_univ_anybutton.obj \
$(OBJS)\monolib_univ_bmpbuttn.obj \
$(OBJS)\monolib_univ_button.obj \
$(OBJS)\monolib_univ_checkbox.obj \
@ -3691,7 +3693,7 @@ ____CORE_SRC_FILENAMES_2_OBJECTS = \
$(OBJS)\coredll_generic_statusbr.obj \
$(OBJS)\coredll_prntdlgg.obj \
$(OBJS)\coredll_msw_accel.obj \
$(OBJS)\coredll_anybutton.obj \
$(OBJS)\coredll_msw_anybutton.obj \
$(OBJS)\coredll_artmsw.obj \
$(OBJS)\coredll_appprogress.obj \
$(OBJS)\coredll_msw_bmpbuttn.obj \
@ -3982,6 +3984,7 @@ ____CORE_SRC_FILENAMES_2_OBJECTS = \
$(OBJS)\coredll_generic_listctrl.obj \
$(OBJS)\coredll_mdig.obj \
$(OBJS)\coredll_prntdlgg.obj \
$(OBJS)\coredll_univ_anybutton.obj \
$(OBJS)\coredll_univ_bmpbuttn.obj \
$(OBJS)\coredll_univ_button.obj \
$(OBJS)\coredll_univ_checkbox.obj \
@ -4261,7 +4264,7 @@ ____CORE_SRC_FILENAMES_3_OBJECTS = \
$(OBJS)\corelib_generic_statusbr.obj \
$(OBJS)\corelib_prntdlgg.obj \
$(OBJS)\corelib_msw_accel.obj \
$(OBJS)\corelib_anybutton.obj \
$(OBJS)\corelib_msw_anybutton.obj \
$(OBJS)\corelib_artmsw.obj \
$(OBJS)\corelib_appprogress.obj \
$(OBJS)\corelib_msw_bmpbuttn.obj \
@ -4552,6 +4555,7 @@ ____CORE_SRC_FILENAMES_3_OBJECTS = \
$(OBJS)\corelib_generic_listctrl.obj \
$(OBJS)\corelib_mdig.obj \
$(OBJS)\corelib_prntdlgg.obj \
$(OBJS)\corelib_univ_anybutton.obj \
$(OBJS)\corelib_univ_bmpbuttn.obj \
$(OBJS)\corelib_univ_button.obj \
$(OBJS)\corelib_univ_checkbox.obj \
@ -7339,7 +7343,7 @@ $(OBJS)\monodll_generic_statusbr.obj: ..\..\src\generic\statusbr.cpp
$(OBJS)\monodll_msw_accel.obj: ..\..\src\msw\accel.cpp
$(CXX) /c /nologo /TP /Fo$@ $(MONODLL_CXXFLAGS) ..\..\src\msw\accel.cpp
$(OBJS)\monodll_anybutton.obj: ..\..\src\msw\anybutton.cpp
$(OBJS)\monodll_msw_anybutton.obj: ..\..\src\msw\anybutton.cpp
$(CXX) /c /nologo /TP /Fo$@ $(MONODLL_CXXFLAGS) ..\..\src\msw\anybutton.cpp
$(OBJS)\monodll_artmsw.obj: ..\..\src\msw\artmsw.cpp
@ -7525,6 +7529,9 @@ $(OBJS)\monodll_generic_listctrl.obj: ..\..\src\generic\listctrl.cpp
$(OBJS)\monodll_mdig.obj: ..\..\src\generic\mdig.cpp
$(CXX) /c /nologo /TP /Fo$@ $(MONODLL_CXXFLAGS) ..\..\src\generic\mdig.cpp
$(OBJS)\monodll_univ_anybutton.obj: ..\..\src\univ\anybutton.cpp
$(CXX) /c /nologo /TP /Fo$@ $(MONODLL_CXXFLAGS) ..\..\src\univ\anybutton.cpp
$(OBJS)\monodll_univ_bmpbuttn.obj: ..\..\src\univ\bmpbuttn.cpp
$(CXX) /c /nologo /TP /Fo$@ $(MONODLL_CXXFLAGS) ..\..\src\univ\bmpbuttn.cpp
@ -9821,7 +9828,7 @@ $(OBJS)\monolib_generic_statusbr.obj: ..\..\src\generic\statusbr.cpp
$(OBJS)\monolib_msw_accel.obj: ..\..\src\msw\accel.cpp
$(CXX) /c /nologo /TP /Fo$@ $(MONOLIB_CXXFLAGS) ..\..\src\msw\accel.cpp
$(OBJS)\monolib_anybutton.obj: ..\..\src\msw\anybutton.cpp
$(OBJS)\monolib_msw_anybutton.obj: ..\..\src\msw\anybutton.cpp
$(CXX) /c /nologo /TP /Fo$@ $(MONOLIB_CXXFLAGS) ..\..\src\msw\anybutton.cpp
$(OBJS)\monolib_artmsw.obj: ..\..\src\msw\artmsw.cpp
@ -10007,6 +10014,9 @@ $(OBJS)\monolib_generic_listctrl.obj: ..\..\src\generic\listctrl.cpp
$(OBJS)\monolib_mdig.obj: ..\..\src\generic\mdig.cpp
$(CXX) /c /nologo /TP /Fo$@ $(MONOLIB_CXXFLAGS) ..\..\src\generic\mdig.cpp
$(OBJS)\monolib_univ_anybutton.obj: ..\..\src\univ\anybutton.cpp
$(CXX) /c /nologo /TP /Fo$@ $(MONOLIB_CXXFLAGS) ..\..\src\univ\anybutton.cpp
$(OBJS)\monolib_univ_bmpbuttn.obj: ..\..\src\univ\bmpbuttn.cpp
$(CXX) /c /nologo /TP /Fo$@ $(MONOLIB_CXXFLAGS) ..\..\src\univ\bmpbuttn.cpp
@ -12711,7 +12721,7 @@ $(OBJS)\coredll_generic_statusbr.obj: ..\..\src\generic\statusbr.cpp
$(OBJS)\coredll_msw_accel.obj: ..\..\src\msw\accel.cpp
$(CXX) /c /nologo /TP /Fo$@ $(COREDLL_CXXFLAGS) ..\..\src\msw\accel.cpp
$(OBJS)\coredll_anybutton.obj: ..\..\src\msw\anybutton.cpp
$(OBJS)\coredll_msw_anybutton.obj: ..\..\src\msw\anybutton.cpp
$(CXX) /c /nologo /TP /Fo$@ $(COREDLL_CXXFLAGS) ..\..\src\msw\anybutton.cpp
$(OBJS)\coredll_artmsw.obj: ..\..\src\msw\artmsw.cpp
@ -12897,6 +12907,9 @@ $(OBJS)\coredll_generic_listctrl.obj: ..\..\src\generic\listctrl.cpp
$(OBJS)\coredll_mdig.obj: ..\..\src\generic\mdig.cpp
$(CXX) /c /nologo /TP /Fo$@ $(COREDLL_CXXFLAGS) ..\..\src\generic\mdig.cpp
$(OBJS)\coredll_univ_anybutton.obj: ..\..\src\univ\anybutton.cpp
$(CXX) /c /nologo /TP /Fo$@ $(COREDLL_CXXFLAGS) ..\..\src\univ\anybutton.cpp
$(OBJS)\coredll_univ_bmpbuttn.obj: ..\..\src\univ\bmpbuttn.cpp
$(CXX) /c /nologo /TP /Fo$@ $(COREDLL_CXXFLAGS) ..\..\src\univ\bmpbuttn.cpp
@ -14169,7 +14182,7 @@ $(OBJS)\corelib_generic_statusbr.obj: ..\..\src\generic\statusbr.cpp
$(OBJS)\corelib_msw_accel.obj: ..\..\src\msw\accel.cpp
$(CXX) /c /nologo /TP /Fo$@ $(CORELIB_CXXFLAGS) ..\..\src\msw\accel.cpp
$(OBJS)\corelib_anybutton.obj: ..\..\src\msw\anybutton.cpp
$(OBJS)\corelib_msw_anybutton.obj: ..\..\src\msw\anybutton.cpp
$(CXX) /c /nologo /TP /Fo$@ $(CORELIB_CXXFLAGS) ..\..\src\msw\anybutton.cpp
$(OBJS)\corelib_artmsw.obj: ..\..\src\msw\artmsw.cpp
@ -14355,6 +14368,9 @@ $(OBJS)\corelib_generic_listctrl.obj: ..\..\src\generic\listctrl.cpp
$(OBJS)\corelib_mdig.obj: ..\..\src\generic\mdig.cpp
$(CXX) /c /nologo /TP /Fo$@ $(CORELIB_CXXFLAGS) ..\..\src\generic\mdig.cpp
$(OBJS)\corelib_univ_anybutton.obj: ..\..\src\univ\anybutton.cpp
$(CXX) /c /nologo /TP /Fo$@ $(CORELIB_CXXFLAGS) ..\..\src\univ\anybutton.cpp
$(OBJS)\corelib_univ_bmpbuttn.obj: ..\..\src\univ\bmpbuttn.cpp
$(CXX) /c /nologo /TP /Fo$@ $(CORELIB_CXXFLAGS) ..\..\src\univ\bmpbuttn.cpp

View File

@ -9,7 +9,7 @@
#ifndef _WX_UNIV_ANYBUTTON_H_
#define _WX_UNIV_ANYBUTTON_H_
#include "wx/univ/inphand.h"
// ----------------------------------------------------------------------------
// Common button functionality
// ----------------------------------------------------------------------------
@ -21,12 +21,69 @@ public:
virtual ~wxAnyButton() {}
// wxAnyButton actions
virtual void Toggle();
virtual void Press();
virtual void Release();
virtual void Click(){}
virtual bool PerformAction(const wxControlAction& action,
long numArg = -1,
const wxString& strArg = wxEmptyString) wxOVERRIDE;
static wxInputHandler *GetStdInputHandler(wxInputHandler *handlerDef);
virtual wxInputHandler *DoGetStdInputHandler(wxInputHandler *handlerDef) wxOVERRIDE
{
return GetStdInputHandler(handlerDef);
}
protected:
// choose the default border for this window
virtual wxBorder GetDefaultBorder() const wxOVERRIDE { return wxBORDER_STATIC; }
virtual wxSize DoGetBestClientSize() const wxOVERRIDE;
virtual bool DoDrawBackground(wxDC& dc) wxOVERRIDE;
virtual void DoDraw(wxControlRenderer *renderer) wxOVERRIDE;
// current state
bool m_isPressed,
m_isDefault;
// the (optional) image to show and the margins around it
wxBitmap m_bitmap;
wxCoord m_marginBmpX,
m_marginBmpY;
private:
wxDECLARE_NO_COPY_CLASS(wxAnyButton);
};
// ----------------------------------------------------------------------------
// wxStdAnyButtonInputHandler: translates SPACE and ENTER keys and the left mouse
// click into button press/release actions
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxStdAnyButtonInputHandler : public wxStdInputHandler
{
public:
wxStdAnyButtonInputHandler(wxInputHandler *inphand);
virtual bool HandleKey(wxInputConsumer *consumer,
const wxKeyEvent& event,
bool pressed) wxOVERRIDE;
virtual bool HandleMouse(wxInputConsumer *consumer,
const wxMouseEvent& event) wxOVERRIDE;
virtual bool HandleMouseMove(wxInputConsumer *consumer,
const wxMouseEvent& event) wxOVERRIDE;
virtual bool HandleFocus(wxInputConsumer *consumer,
const wxFocusEvent& event) wxOVERRIDE;
virtual bool HandleActivation(wxInputConsumer *consumer, bool activated) wxOVERRIDE;
private:
// the window (button) which has capture or NULL and the flag telling if
// the mouse is inside the button which captured it or not
wxWindow *m_winCapture;
bool m_winHasMouse;
};
#endif // _WX_UNIV_ANYBUTTON_H_

View File

@ -11,14 +11,12 @@
#ifndef _WX_UNIV_BUTTON_H_
#define _WX_UNIV_BUTTON_H_
class WXDLLIMPEXP_FWD_CORE wxInputHandler;
#include "wx/bitmap.h"
// ----------------------------------------------------------------------------
// the actions supported by this control
// ----------------------------------------------------------------------------
//checkbox.cpp needed it, so not move it to anybutton.h
#define wxACTION_BUTTON_TOGGLE wxT("toggle") // press/release the button
#define wxACTION_BUTTON_PRESS wxT("press") // press the button
#define wxACTION_BUTTON_RELEASE wxT("release") // release the button
@ -92,45 +90,19 @@ public:
virtual bool IsDefault() const wxOVERRIDE { return m_isDefault; }
// wxButton actions
virtual void Toggle();
virtual void Press();
virtual void Release();
virtual void Click();
virtual bool PerformAction(const wxControlAction& action,
long numArg = -1,
const wxString& strArg = wxEmptyString) wxOVERRIDE;
virtual void Click() wxOVERRIDE;
virtual bool CanBeHighlighted() const wxOVERRIDE { return true; }
static wxInputHandler *GetStdInputHandler(wxInputHandler *handlerDef);
virtual wxInputHandler *DoGetStdInputHandler(wxInputHandler *handlerDef) wxOVERRIDE
{
return GetStdInputHandler(handlerDef);
}
protected:
virtual wxSize DoGetBestClientSize() const wxOVERRIDE;
virtual bool DoDrawBackground(wxDC& dc) wxOVERRIDE;
virtual void DoDraw(wxControlRenderer *renderer) wxOVERRIDE;
virtual void DoSetBitmap(const wxBitmap& bitmap, State which) wxOVERRIDE;
virtual void DoSetBitmapMargins(wxCoord x, wxCoord y) wxOVERRIDE;
// common part of all ctors
void Init();
// current state
bool m_isPressed,
m_isDefault;
// the (optional) image to show and the margins around it
wxBitmap m_bitmap;
wxCoord m_marginBmpX,
m_marginBmpY;
private:
DECLARE_DYNAMIC_CLASS(wxButton)
};

View File

@ -11,20 +11,17 @@
#ifndef _WX_UNIV_TGLBTN_H_
#define _WX_UNIV_TGLBTN_H_
#include "wx/button.h"
// ----------------------------------------------------------------------------
// wxToggleButton: a push button
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxToggleButton: public wxButton
class WXDLLIMPEXP_CORE wxToggleButton: public wxToggleButtonBase
{
public:
wxToggleButton();
wxToggleButton(wxWindow *parent,
wxWindowID id,
const wxBitmap& bitmap,
const wxString& label = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
@ -32,16 +29,15 @@ public:
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxCheckBoxNameStr);
wxToggleButton(wxWindow *parent,
wxWindowID id,
const wxString& label = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxCheckBoxNameStr);
virtual ~wxToggleButton();
// Create the control
bool Create(wxWindow *parent,
wxWindowID id,
const wxString& lbl = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxCheckBoxNameStr);
virtual bool IsPressed() const wxOVERRIDE { return m_isPressed || m_value; }

290
src/univ/anybutton.cpp Normal file
View File

@ -0,0 +1,290 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/univ/anybutton.cpp
// Purpose: wxAnyButton
// Author: Vadim Zeitlin
// Created: 2014-03-26 (extracted from button.cpp and tglbtn.cpp)
// Copyright: (c) 2014
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#include "wx/univ/renderer.h"
#include "wx/univ/theme.h"
#include "wx/univ/colschem.h"
// ============================================================================
// implementation
// ============================================================================
void wxAnyButton::Press()
{
if ( !m_isPressed )
{
m_isPressed = true;
Refresh();
}
}
void wxAnyButton::Release()
{
if ( m_isPressed )
{
m_isPressed = false;
Refresh();
}
}
void wxAnyButton::Toggle()
{
if ( m_isPressed )
Release();
else
Press();
if ( !m_isPressed )
{
// releasing button after it had been pressed generates a click event
Click();
}
Refresh();
}
bool wxAnyButton::PerformAction(const wxControlAction& action,
long numArg,
const wxString& strArg)
{
if ( action == wxACTION_BUTTON_TOGGLE )
Toggle();
else if ( action == wxACTION_BUTTON_CLICK )
Click();
else if ( action == wxACTION_BUTTON_PRESS )
Press();
else if ( action == wxACTION_BUTTON_RELEASE )
Release();
else
return wxControl::PerformAction(action, numArg, strArg);
return true;
}
/* static */
wxInputHandler *wxAnyButton::GetStdInputHandler(wxInputHandler *handlerDef)
{
static wxStdAnyButtonInputHandler s_handlerBtn(handlerDef);
return &s_handlerBtn;
}
// ----------------------------------------------------------------------------
// size management
// ----------------------------------------------------------------------------
wxSize wxAnyButton::DoGetBestClientSize() const
{
wxClientDC dc(wxConstCast(this, wxAnyButton));
wxCoord width, height;
dc.GetMultiLineTextExtent(GetLabel(), &width, &height);
if ( m_bitmap.IsOk() )
{
// allocate extra space for the bitmap
wxCoord heightBmp = m_bitmap.GetHeight() + 2*m_marginBmpY;
if ( height < heightBmp )
height = heightBmp;
width += m_bitmap.GetWidth() + 2*m_marginBmpX;
}
// The default size should not be adjusted, so the code is moved into the
// renderer. This is conceptual wrong but currently the only solution.
// (Otto Wyss, Patch 664399)
/*
// for compatibility with other ports, the buttons default size is never
// less than the standard one, but not when display not PDAs.
if (wxSystemSettings::GetScreenType() > wxSYS_SCREEN_PDA)
{
if ( !(GetWindowStyle() & wxBU_EXACTFIT) )
{
wxSize szDef = GetDefaultSize();
if ( width < szDef.x )
width = szDef.x;
}
}
*/
return wxSize(width, height);
}
// ----------------------------------------------------------------------------
// drawing
// ----------------------------------------------------------------------------
void wxAnyButton::DoDraw(wxControlRenderer *renderer)
{
if ( !(GetWindowStyle() & wxBORDER_NONE) )
{
renderer->DrawButtonBorder();
}
renderer->DrawButtonLabel(m_bitmap, m_marginBmpX, m_marginBmpY);
}
bool wxAnyButton::DoDrawBackground(wxDC& dc)
{
wxRect rect;
wxSize size = GetSize();
rect.width = size.x;
rect.height = size.y;
if ( GetBackgroundBitmap().IsOk() )
{
// get the bitmap and the flags
int alignment;
wxStretch stretch;
wxBitmap bmp = GetBackgroundBitmap(&alignment, &stretch);
wxControlRenderer::DrawBitmap(dc, bmp, rect, alignment, stretch);
}
else
{
m_renderer->DrawButtonSurface(dc, wxTHEME_BG_COLOUR(this),
rect, GetStateFlags());
}
return true;
}
// ============================================================================
// wxStdAnyButtonInputHandler
// ============================================================================
wxStdAnyButtonInputHandler::wxStdAnyButtonInputHandler(wxInputHandler *handler)
: wxStdInputHandler(handler)
{
m_winCapture = NULL;
m_winHasMouse = false;
}
bool wxStdAnyButtonInputHandler::HandleKey(wxInputConsumer *consumer,
const wxKeyEvent& event,
bool pressed)
{
int keycode = event.GetKeyCode();
if ( keycode == WXK_SPACE || keycode == WXK_RETURN )
{
consumer->PerformAction(wxACTION_BUTTON_TOGGLE);
return true;
}
return wxStdInputHandler::HandleKey(consumer, event, pressed);
}
bool wxStdAnyButtonInputHandler::HandleMouse(wxInputConsumer *consumer,
const wxMouseEvent& event)
{
// the button has 2 states: pressed and normal with the following
// transitions between them:
//
// normal -> left down -> capture mouse and go to pressed state
// pressed -> left up inside -> generate click -> go to normal
// outside ------------------>
//
// the other mouse buttons are ignored
if ( event.Button(1) )
{
if ( event.LeftDown() || event.LeftDClick() )
{
m_winCapture = consumer->GetInputWindow();
m_winCapture->CaptureMouse();
m_winHasMouse = true;
consumer->PerformAction(wxACTION_BUTTON_PRESS);
return true;
}
else if ( event.LeftUp() )
{
if ( m_winCapture )
{
m_winCapture->ReleaseMouse();
m_winCapture = NULL;
}
if ( m_winHasMouse )
{
// this will generate a click event
consumer->PerformAction(wxACTION_BUTTON_TOGGLE);
return true;
}
//else: the mouse was released outside the window, this doesn't
// count as a click
}
//else: don't do anything special about the double click
}
return wxStdInputHandler::HandleMouse(consumer, event);
}
bool wxStdAnyButtonInputHandler::HandleMouseMove(wxInputConsumer *consumer,
const wxMouseEvent& event)
{
// we only have to do something when the mouse leaves/enters the pressed
// button and don't care about the other ones
if ( event.GetEventObject() == m_winCapture )
{
// leaving the button should remove its pressed state
if ( event.Leaving() )
{
// remember that the mouse is now outside
m_winHasMouse = false;
// we do have a pressed button, so release it
consumer->GetInputWindow()->SetCurrent(false);
consumer->PerformAction(wxACTION_BUTTON_RELEASE);
return true;
}
// and entering it back should make it pressed again if it had been
// pressed
else if ( event.Entering() )
{
// the mouse is (back) inside the button
m_winHasMouse = true;
// we did have a pressed button which we released when leaving the
// window, press it again
consumer->GetInputWindow()->SetCurrent(true);
consumer->PerformAction(wxACTION_BUTTON_PRESS);
return true;
}
}
return wxStdInputHandler::HandleMouseMove(consumer, event);
}
bool wxStdAnyButtonInputHandler::HandleFocus(wxInputConsumer * WXUNUSED(consumer),
const wxFocusEvent& WXUNUSED(event))
{
// buttons change appearance when they get/lose focus, so return true to
// refresh
return true;
}
bool wxStdAnyButtonInputHandler::HandleActivation(wxInputConsumer *consumer,
bool WXUNUSED(activated))
{
// the default button changes appearance when the app is [de]activated, so
// return true to refresh
return wxStaticCast(consumer->GetInputWindow(), wxAnyButton)->IsDefault();
}

View File

@ -32,40 +32,6 @@
#include "wx/settings.h"
#endif
#include "wx/univ/renderer.h"
#include "wx/univ/inphand.h"
#include "wx/univ/theme.h"
#include "wx/univ/colschem.h"
#include "wx/stockitem.h"
// ----------------------------------------------------------------------------
// wxStdButtonInputHandler: translates SPACE and ENTER keys and the left mouse
// click into button press/release actions
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxStdButtonInputHandler : public wxStdInputHandler
{
public:
wxStdButtonInputHandler(wxInputHandler *inphand);
virtual bool HandleKey(wxInputConsumer *consumer,
const wxKeyEvent& event,
bool pressed);
virtual bool HandleMouse(wxInputConsumer *consumer,
const wxMouseEvent& event);
virtual bool HandleMouseMove(wxInputConsumer *consumer,
const wxMouseEvent& event);
virtual bool HandleFocus(wxInputConsumer *consumer,
const wxFocusEvent& event);
virtual bool HandleActivation(wxInputConsumer *consumer, bool activated);
private:
// the window (button) which has capture or NULL and the flag telling if
// the mouse is inside the button which captured it or not
wxWindow *m_winCapture;
bool m_winHasMouse;
};
// ----------------------------------------------------------------------------
// constants
// ----------------------------------------------------------------------------
@ -163,118 +129,11 @@ wxSize wxButtonBase::GetDefaultSize()
return s_sizeBtn;
}
wxSize wxButton::DoGetBestClientSize() const
{
wxClientDC dc(wxConstCast(this, wxButton));
wxCoord width, height;
dc.GetMultiLineTextExtent(GetLabel(), &width, &height);
if ( m_bitmap.IsOk() )
{
// allocate extra space for the bitmap
wxCoord heightBmp = m_bitmap.GetHeight() + 2*m_marginBmpY;
if ( height < heightBmp )
height = heightBmp;
width += m_bitmap.GetWidth() + 2*m_marginBmpX;
}
// The default size should not be adjusted, so the code is moved into the
// renderer. This is conceptual wrong but currently the only solution.
// (Otto Wyss, Patch 664399)
/*
// for compatibility with other ports, the buttons default size is never
// less than the standard one, but not when display not PDAs.
if (wxSystemSettings::GetScreenType() > wxSYS_SCREEN_PDA)
{
if ( !(GetWindowStyle() & wxBU_EXACTFIT) )
{
wxSize szDef = GetDefaultSize();
if ( width < szDef.x )
width = szDef.x;
}
}
*/
return wxSize(width, height);
}
// ----------------------------------------------------------------------------
// drawing
// ----------------------------------------------------------------------------
void wxButton::DoDraw(wxControlRenderer *renderer)
{
if ( !(GetWindowStyle() & wxBORDER_NONE) )
{
renderer->DrawButtonBorder();
}
renderer->DrawButtonLabel(m_bitmap, m_marginBmpX, m_marginBmpY);
}
bool wxButton::DoDrawBackground(wxDC& dc)
{
wxRect rect;
wxSize size = GetSize();
rect.width = size.x;
rect.height = size.y;
if ( GetBackgroundBitmap().IsOk() )
{
// get the bitmap and the flags
int alignment;
wxStretch stretch;
wxBitmap bmp = GetBackgroundBitmap(&alignment, &stretch);
wxControlRenderer::DrawBitmap(dc, bmp, rect, alignment, stretch);
}
else
{
m_renderer->DrawButtonSurface(dc, wxTHEME_BG_COLOUR(this),
rect, GetStateFlags());
}
return true;
}
// ----------------------------------------------------------------------------
// input processing
// ----------------------------------------------------------------------------
void wxButton::Press()
{
if ( !m_isPressed )
{
m_isPressed = true;
Refresh();
}
}
void wxButton::Release()
{
if ( m_isPressed )
{
m_isPressed = false;
Refresh();
}
}
void wxButton::Toggle()
{
if ( m_isPressed )
Release();
else
Press();
if ( !m_isPressed )
{
// releasing button after it had been pressed generates a click event
Click();
}
}
void wxButton::Click()
{
wxCommandEvent event(wxEVT_BUTTON, GetId());
@ -282,32 +141,6 @@ void wxButton::Click()
Command(event);
}
bool wxButton::PerformAction(const wxControlAction& action,
long numArg,
const wxString& strArg)
{
if ( action == wxACTION_BUTTON_TOGGLE )
Toggle();
else if ( action == wxACTION_BUTTON_CLICK )
Click();
else if ( action == wxACTION_BUTTON_PRESS )
Press();
else if ( action == wxACTION_BUTTON_RELEASE )
Release();
else
return wxControl::PerformAction(action, numArg, strArg);
return true;
}
/* static */
wxInputHandler *wxButton::GetStdInputHandler(wxInputHandler *handlerDef)
{
static wxStdButtonInputHandler s_handlerBtn(handlerDef);
return &s_handlerBtn;
}
// ----------------------------------------------------------------------------
// misc
// ----------------------------------------------------------------------------
@ -337,132 +170,5 @@ wxWindow *wxButton::SetDefault()
return wxButtonBase::SetDefault();
}
// ============================================================================
// wxStdButtonInputHandler
// ============================================================================
wxStdButtonInputHandler::wxStdButtonInputHandler(wxInputHandler *handler)
: wxStdInputHandler(handler)
{
m_winCapture = NULL;
m_winHasMouse = false;
}
bool wxStdButtonInputHandler::HandleKey(wxInputConsumer *consumer,
const wxKeyEvent& event,
bool pressed)
{
int keycode = event.GetKeyCode();
if ( keycode == WXK_SPACE || keycode == WXK_RETURN )
{
consumer->PerformAction(wxACTION_BUTTON_TOGGLE);
return true;
}
return wxStdInputHandler::HandleKey(consumer, event, pressed);
}
bool wxStdButtonInputHandler::HandleMouse(wxInputConsumer *consumer,
const wxMouseEvent& event)
{
// the button has 2 states: pressed and normal with the following
// transitions between them:
//
// normal -> left down -> capture mouse and go to pressed state
// pressed -> left up inside -> generate click -> go to normal
// outside ------------------>
//
// the other mouse buttons are ignored
if ( event.Button(1) )
{
if ( event.LeftDown() || event.LeftDClick() )
{
m_winCapture = consumer->GetInputWindow();
m_winCapture->CaptureMouse();
m_winHasMouse = true;
consumer->PerformAction(wxACTION_BUTTON_PRESS);
return true;
}
else if ( event.LeftUp() )
{
if ( m_winCapture )
{
m_winCapture->ReleaseMouse();
m_winCapture = NULL;
}
if ( m_winHasMouse )
{
// this will generate a click event
consumer->PerformAction(wxACTION_BUTTON_TOGGLE);
return true;
}
//else: the mouse was released outside the window, this doesn't
// count as a click
}
//else: don't do anything special about the double click
}
return wxStdInputHandler::HandleMouse(consumer, event);
}
bool wxStdButtonInputHandler::HandleMouseMove(wxInputConsumer *consumer,
const wxMouseEvent& event)
{
// we only have to do something when the mouse leaves/enters the pressed
// button and don't care about the other ones
if ( event.GetEventObject() == m_winCapture )
{
// leaving the button should remove its pressed state
if ( event.Leaving() )
{
// remember that the mouse is now outside
m_winHasMouse = false;
// we do have a pressed button, so release it
consumer->GetInputWindow()->SetCurrent(false);
consumer->PerformAction(wxACTION_BUTTON_RELEASE);
return true;
}
// and entering it back should make it pressed again if it had been
// pressed
else if ( event.Entering() )
{
// the mouse is (back) inside the button
m_winHasMouse = true;
// we did have a pressed button which we released when leaving the
// window, press it again
consumer->GetInputWindow()->SetCurrent(true);
consumer->PerformAction(wxACTION_BUTTON_PRESS);
return true;
}
}
return wxStdInputHandler::HandleMouseMove(consumer, event);
}
bool wxStdButtonInputHandler::HandleFocus(wxInputConsumer * WXUNUSED(consumer),
const wxFocusEvent& WXUNUSED(event))
{
// buttons change appearance when they get/lose focus, so return true to
// refresh
return true;
}
bool wxStdButtonInputHandler::HandleActivation(wxInputConsumer *consumer,
bool WXUNUSED(activated))
{
// the default button changes appearance when the app is [de]activated, so
// return true to refresh
return wxStaticCast(consumer->GetInputWindow(), wxButton)->IsDefault();
}
#endif // wxUSE_BUTTON

View File

@ -17,10 +17,13 @@
#if wxUSE_TOGGLEBTN
#include "wx/tglbtn.h"
#include "wx/univ/renderer.h"
#include "wx/univ/colschem.h"
#include "wx/univ/theme.h"
wxDEFINE_EVENT( wxEVT_TOGGLEBUTTON, wxCommandEvent );
IMPLEMENT_DYNAMIC_CLASS(wxToggleButton, wxButton)
IMPLEMENT_DYNAMIC_CLASS(wxToggleButton, wxToggleButtonBase)
wxToggleButton::wxToggleButton()
{
@ -28,34 +31,55 @@ wxToggleButton::wxToggleButton()
}
wxToggleButton::wxToggleButton(wxWindow *parent,
wxWindowID id,
const wxBitmap& bitmap,
const wxString& label,
const wxPoint& pos,
const wxSize& size,
long style,
const wxValidator& validator,
const wxString& name)
{
Init();
Create(parent, id, bitmap, label, pos, size, style, validator, name);
}
wxToggleButton::wxToggleButton(wxWindow *parent,
wxWindowID id,
const wxString& label,
const wxPoint& pos,
const wxSize& size,
long style,
const wxValidator& validator,
const wxString& name)
wxWindowID id,
const wxString& label,
const wxPoint& pos,
const wxSize& size,
long style,
const wxValidator& validator,
const wxString& name)
{
Init();
Create(parent, id, label, pos, size, style, validator, name);
}
wxToggleButton::~wxToggleButton()
bool wxToggleButton::Create(wxWindow *parent,
wxWindowID id,
const wxString& lbl,
const wxPoint& pos,
const wxSize& size, long style,
const wxValidator& validator,
const wxString& name)
{
wxString label(lbl);
if (label.empty() && wxIsStockID(id))
label = wxGetStockLabel(id);
long ctrl_style = style & ~wxBU_ALIGN_MASK;
ctrl_style = ctrl_style & ~wxALIGN_MASK;
if((style & wxBU_RIGHT) == wxBU_RIGHT)
ctrl_style |= wxALIGN_RIGHT;
else if((style & wxBU_LEFT) == wxBU_LEFT)
ctrl_style |= wxALIGN_LEFT;
else
ctrl_style |= wxALIGN_CENTRE_HORIZONTAL;
if((style & wxBU_TOP) == wxBU_TOP)
ctrl_style |= wxALIGN_TOP;
else if((style & wxBU_BOTTOM) == wxBU_BOTTOM)
ctrl_style |= wxALIGN_BOTTOM;
else
ctrl_style |= wxALIGN_CENTRE_VERTICAL;
if ( !wxToggleButtonBase::Create(parent, id, pos, size, ctrl_style, validator, name) )
{
wxFAIL_MSG(wxT("wxToggleButton creation failed"));
return false;
}
SetLabel(label);
CreateInputHandler(wxINP_HANDLER_BUTTON);
return true;
}
void wxToggleButton::Init()