wx/generic/listctrl.h \
wx/generic/statusbr.h \
wx/gtk/accel.h \
+ wx/gtk/anybutton.h \
wx/gtk/bmpbuttn.h \
wx/gtk/button.h \
wx/gtk/checkbox.h \
wx/generic/filepickerg.h \
wx/generic/fontpickerg.h \
wx/msw/accel.h \
+ wx/msw/anybutton.h \
wx/msw/app.h \
wx/msw/bitmap.h \
wx/msw/bmpbuttn.h \
COND_TOOLKIT_OSX_CARBON_GUI_HDR = \
wx/html/webkit.h \
wx/osx/accel.h \
+ wx/osx/anybutton.h \
wx/osx/app.h \
wx/osx/bitmap.h \
wx/osx/bmpbuttn.h \
COND_TOOLKIT_OSX_COCOA_GUI_HDR = \
wx/html/webkit.h \
wx/osx/accel.h \
+ wx/osx/anybutton.h \
wx/osx/app.h \
wx/osx/bitmap.h \
wx/osx/bmpbuttn.h \
COND_TOOLKIT_OSX_IPHONE_GUI_HDR = \
wx/html/webkit.h \
wx/osx/accel.h \
+ wx/osx/anybutton.h \
wx/osx/app.h \
wx/osx/bitmap.h \
wx/osx/bmpbuttn.h \
wx/generic/filepickerg.h \
wx/generic/fontpickerg.h \
wx/msw/accel.h \
+ wx/msw/anybutton.h \
wx/msw/app.h \
wx/msw/bitmap.h \
wx/msw/bmpbuttn.h \
COND_USE_GUI_1_ALL_GUI_HEADERS = \
wx/affinematrix2dbase.h \
wx/affinematrix2d.h \
+ wx/anybutton.h \
wx/bmpbuttn.h \
wx/brush.h \
wx/button.h \
monodll_prntdlgg.o \
monodll_generic_statusbr.o \
monodll_fontdlgg.o \
+ monodll_gtk_anybutton.o \
monodll_artgtk.o \
monodll_gtk_bmpbuttn.o \
monodll_gtk_button.o \
monodll_generic_statusbr.o \
monodll_prntdlgg.o \
monodll_msw_accel.o \
+ monodll_msw_anybutton.o \
monodll_artmsw.o \
monodll_msw_bmpbuttn.o \
monodll_msw_button.o \
@COND_TOOLKIT_MSW@__GUI_SRC_OBJECTS = $(COND_TOOLKIT_MSW___GUI_SRC_OBJECTS)
COND_TOOLKIT_OSX_CARBON___GUI_SRC_OBJECTS = \
$(__OSX_CARBON_COCOA_SRC_OBJECTS) \
+ monodll_carbon_anybutton.o \
monodll_carbon_bmpbuttn.o \
monodll_carbon_button.o \
monodll_carbon_checkbox.o \
@COND_TOOLKIT_OSX_CARBON@__GUI_SRC_OBJECTS = $(COND_TOOLKIT_OSX_CARBON___GUI_SRC_OBJECTS)
COND_TOOLKIT_OSX_COCOA___GUI_SRC_OBJECTS = \
$(__OSX_CARBON_COCOA_SRC_OBJECTS) \
+ monodll_cocoa_anybutton.o \
monodll_osx_cocoa_button.o \
monodll_osx_cocoa_checkbox.o \
monodll_osx_cocoa_choice.o \
$(__OSX_CARBON_COCOA_SRC_OBJECTS) \
monodll_regiong.o \
monodll_generic_icon.o \
+ monodll_iphone_anybutton.o \
monodll_iphone_button.o \
monodll_iphone_checkbox.o \
monodll_iphone_dialog.o \
monodll_generic_statusbr.o \
monodll_prntdlgg.o \
monodll_msw_accel.o \
+ monodll_msw_anybutton.o \
monodll_artmsw.o \
monodll_msw_bmpbuttn.o \
monodll_msw_button.o \
monolib_prntdlgg.o \
monolib_generic_statusbr.o \
monolib_fontdlgg.o \
+ monolib_gtk_anybutton.o \
monolib_artgtk.o \
monolib_gtk_bmpbuttn.o \
monolib_gtk_button.o \
monolib_generic_statusbr.o \
monolib_prntdlgg.o \
monolib_msw_accel.o \
+ monolib_msw_anybutton.o \
monolib_artmsw.o \
monolib_msw_bmpbuttn.o \
monolib_msw_button.o \
@COND_TOOLKIT_MSW@__GUI_SRC_OBJECTS_1 = $(COND_TOOLKIT_MSW___GUI_SRC_OBJECTS_1)
COND_TOOLKIT_OSX_CARBON___GUI_SRC_OBJECTS_1 = \
$(__OSX_CARBON_COCOA_SRC_OBJECTS_12) \
+ monolib_carbon_anybutton.o \
monolib_carbon_bmpbuttn.o \
monolib_carbon_button.o \
monolib_carbon_checkbox.o \
@COND_TOOLKIT_OSX_CARBON@__GUI_SRC_OBJECTS_1 = $(COND_TOOLKIT_OSX_CARBON___GUI_SRC_OBJECTS_1)
COND_TOOLKIT_OSX_COCOA___GUI_SRC_OBJECTS_1 = \
$(__OSX_CARBON_COCOA_SRC_OBJECTS_12) \
+ monolib_cocoa_anybutton.o \
monolib_osx_cocoa_button.o \
monolib_osx_cocoa_checkbox.o \
monolib_osx_cocoa_choice.o \
$(__OSX_CARBON_COCOA_SRC_OBJECTS_12) \
monolib_regiong.o \
monolib_generic_icon.o \
+ monolib_iphone_anybutton.o \
monolib_iphone_button.o \
monolib_iphone_checkbox.o \
monolib_iphone_dialog.o \
monolib_generic_statusbr.o \
monolib_prntdlgg.o \
monolib_msw_accel.o \
+ monolib_msw_anybutton.o \
monolib_artmsw.o \
monolib_msw_bmpbuttn.o \
monolib_msw_button.o \
coredll_prntdlgg.o \
coredll_generic_statusbr.o \
coredll_fontdlgg.o \
+ coredll_gtk_anybutton.o \
coredll_artgtk.o \
coredll_gtk_bmpbuttn.o \
coredll_gtk_button.o \
coredll_generic_statusbr.o \
coredll_prntdlgg.o \
coredll_msw_accel.o \
+ coredll_msw_anybutton.o \
coredll_artmsw.o \
coredll_msw_bmpbuttn.o \
coredll_msw_button.o \
@COND_TOOLKIT_MSW@__GUI_SRC_OBJECTS_2 = $(COND_TOOLKIT_MSW___GUI_SRC_OBJECTS_2)
COND_TOOLKIT_OSX_CARBON___GUI_SRC_OBJECTS_2 = \
$(__OSX_CARBON_COCOA_SRC_OBJECTS_14) \
+ coredll_carbon_anybutton.o \
coredll_carbon_bmpbuttn.o \
coredll_carbon_button.o \
coredll_carbon_checkbox.o \
@COND_TOOLKIT_OSX_CARBON@__GUI_SRC_OBJECTS_2 = $(COND_TOOLKIT_OSX_CARBON___GUI_SRC_OBJECTS_2)
COND_TOOLKIT_OSX_COCOA___GUI_SRC_OBJECTS_2 = \
$(__OSX_CARBON_COCOA_SRC_OBJECTS_14) \
+ coredll_cocoa_anybutton.o \
coredll_osx_cocoa_button.o \
coredll_osx_cocoa_checkbox.o \
coredll_osx_cocoa_choice.o \
$(__OSX_CARBON_COCOA_SRC_OBJECTS_14) \
coredll_regiong.o \
coredll_generic_icon.o \
+ coredll_iphone_anybutton.o \
coredll_iphone_button.o \
coredll_iphone_checkbox.o \
coredll_iphone_dialog.o \
coredll_generic_statusbr.o \
coredll_prntdlgg.o \
coredll_msw_accel.o \
+ coredll_msw_anybutton.o \
coredll_artmsw.o \
coredll_msw_bmpbuttn.o \
coredll_msw_button.o \
corelib_prntdlgg.o \
corelib_generic_statusbr.o \
corelib_fontdlgg.o \
+ corelib_gtk_anybutton.o \
corelib_artgtk.o \
corelib_gtk_bmpbuttn.o \
corelib_gtk_button.o \
corelib_generic_statusbr.o \
corelib_prntdlgg.o \
corelib_msw_accel.o \
+ corelib_msw_anybutton.o \
corelib_artmsw.o \
corelib_msw_bmpbuttn.o \
corelib_msw_button.o \
@COND_TOOLKIT_MSW@__GUI_SRC_OBJECTS_3 = $(COND_TOOLKIT_MSW___GUI_SRC_OBJECTS_3)
COND_TOOLKIT_OSX_CARBON___GUI_SRC_OBJECTS_3 = \
$(__OSX_CARBON_COCOA_SRC_OBJECTS_1_0) \
+ corelib_carbon_anybutton.o \
corelib_carbon_bmpbuttn.o \
corelib_carbon_button.o \
corelib_carbon_checkbox.o \
@COND_TOOLKIT_OSX_CARBON@__GUI_SRC_OBJECTS_3 = $(COND_TOOLKIT_OSX_CARBON___GUI_SRC_OBJECTS_3)
COND_TOOLKIT_OSX_COCOA___GUI_SRC_OBJECTS_3 = \
$(__OSX_CARBON_COCOA_SRC_OBJECTS_1_0) \
+ corelib_cocoa_anybutton.o \
corelib_osx_cocoa_button.o \
corelib_osx_cocoa_checkbox.o \
corelib_osx_cocoa_choice.o \
$(__OSX_CARBON_COCOA_SRC_OBJECTS_1_0) \
corelib_regiong.o \
corelib_generic_icon.o \
+ corelib_iphone_anybutton.o \
corelib_iphone_button.o \
corelib_iphone_checkbox.o \
corelib_iphone_dialog.o \
corelib_generic_statusbr.o \
corelib_prntdlgg.o \
corelib_msw_accel.o \
+ corelib_msw_anybutton.o \
corelib_artmsw.o \
corelib_msw_bmpbuttn.o \
corelib_msw_button.o \
@COND_PLATFORM_MACOSX_1@__PLATFORM_SRC_OBJECTS = monodll_apptraits.o
@COND_PLATFORM_UNIX_1@__PLATFORM_SRC_OBJECTS = monodll_apptraits.o
COND_PLATFORM_MACOSX_1___OSX_CARBON_COCOA_SRC_OBJECTS = \
+ monodll_anybutton_osx.o \
monodll_bmpbuttn_osx.o \
monodll_button_osx.o \
monodll_checkbox_osx.o \
@COND_PLATFORM_MACOSX_1@__PLATFORM_SRC_OBJECTS_0 = monolib_apptraits.o
@COND_PLATFORM_UNIX_1@__PLATFORM_SRC_OBJECTS_0 = monolib_apptraits.o
COND_PLATFORM_MACOSX_1___OSX_CARBON_COCOA_SRC_OBJECTS_12 = \
+ monolib_anybutton_osx.o \
monolib_bmpbuttn_osx.o \
monolib_button_osx.o \
monolib_checkbox_osx.o \
@COND_PLATFORM_MACOSX_1@__PLATFORM_SRC_OBJECTS_8 = coredll_apptraits.o
@COND_PLATFORM_UNIX_1@__PLATFORM_SRC_OBJECTS_8 = coredll_apptraits.o
COND_PLATFORM_MACOSX_1___OSX_CARBON_COCOA_SRC_OBJECTS_14 = \
+ coredll_anybutton_osx.o \
coredll_bmpbuttn_osx.o \
coredll_button_osx.o \
coredll_checkbox_osx.o \
@COND_PLATFORM_MACOSX_1@__PLATFORM_SRC_OBJECTS_9 = corelib_apptraits.o
@COND_PLATFORM_UNIX_1@__PLATFORM_SRC_OBJECTS_9 = corelib_apptraits.o
COND_PLATFORM_MACOSX_1___OSX_CARBON_COCOA_SRC_OBJECTS_1_0 = \
+ corelib_anybutton_osx.o \
corelib_bmpbuttn_osx.o \
corelib_button_osx.o \
corelib_checkbox_osx.o \
monodll_sockosx.o: $(srcdir)/src/osx/core/sockosx.cpp $(MONODLL_ODEP)
$(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/osx/core/sockosx.cpp
+monodll_gtk_anybutton.o: $(srcdir)/src/gtk/anybutton.cpp $(MONODLL_ODEP)
+ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/gtk/anybutton.cpp
+
monodll_artgtk.o: $(srcdir)/src/gtk/artgtk.cpp $(MONODLL_ODEP)
$(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/gtk/artgtk.cpp
monodll_textctrlce.o: $(srcdir)/src/msw/wince/textctrlce.cpp $(MONODLL_ODEP)
$(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/msw/wince/textctrlce.cpp
+monodll_carbon_anybutton.o: $(srcdir)/src/osx/carbon/anybutton.cpp $(MONODLL_ODEP)
+ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/osx/carbon/anybutton.cpp
+
monodll_carbon_bmpbuttn.o: $(srcdir)/src/osx/carbon/bmpbuttn.cpp $(MONODLL_ODEP)
$(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/osx/carbon/bmpbuttn.cpp
monodll_carbon_window.o: $(srcdir)/src/osx/carbon/window.cpp $(MONODLL_ODEP)
$(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/osx/carbon/window.cpp
+monodll_cocoa_anybutton.o: $(srcdir)/src/osx/cocoa/anybutton.mm $(MONODLL_ODEP)
+ $(CXXC) -c -o $@ $(MONODLL_OBJCXXFLAGS) $(srcdir)/src/osx/cocoa/anybutton.mm
+
monodll_osx_cocoa_button.o: $(srcdir)/src/osx/cocoa/button.mm $(MONODLL_ODEP)
$(CXXC) -c -o $@ $(MONODLL_OBJCXXFLAGS) $(srcdir)/src/osx/cocoa/button.mm
monodll_osx_cocoa_window.o: $(srcdir)/src/osx/cocoa/window.mm $(MONODLL_ODEP)
$(CXXC) -c -o $@ $(MONODLL_OBJCXXFLAGS) $(srcdir)/src/osx/cocoa/window.mm
+monodll_iphone_anybutton.o: $(srcdir)/src/osx/iphone/anybutton.mm $(MONODLL_ODEP)
+ $(CXXC) -c -o $@ $(MONODLL_OBJCXXFLAGS) $(srcdir)/src/osx/iphone/anybutton.mm
+
monodll_iphone_button.o: $(srcdir)/src/osx/iphone/button.mm $(MONODLL_ODEP)
$(CXXC) -c -o $@ $(MONODLL_OBJCXXFLAGS) $(srcdir)/src/osx/iphone/button.mm
@COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@monodll_msw_accel.o: $(srcdir)/src/msw/accel.cpp $(MONODLL_ODEP)
@COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/msw/accel.cpp
+@COND_TOOLKIT_MSW_USE_GUI_1_WXUNIV_0@monodll_msw_anybutton.o: $(srcdir)/src/msw/anybutton.cpp $(MONODLL_ODEP)
+@COND_TOOLKIT_MSW_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/msw/anybutton.cpp
+
+@COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@monodll_msw_anybutton.o: $(srcdir)/src/msw/anybutton.cpp $(MONODLL_ODEP)
+@COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/msw/anybutton.cpp
+
@COND_TOOLKIT_MSW_USE_GUI_1_WXUNIV_0@monodll_artmsw.o: $(srcdir)/src/msw/artmsw.cpp $(MONODLL_ODEP)
@COND_TOOLKIT_MSW_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/msw/artmsw.cpp
@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_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
+
+@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_COCOA_USE_GUI_1_WXUNIV_0@monodll_anybutton_osx.o: $(srcdir)/src/osx/anybutton_osx.cpp $(MONODLL_ODEP)
+@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_COCOA_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/osx/anybutton_osx.cpp
+
+@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_IPHONE_USE_GUI_1_WXUNIV_0@monodll_anybutton_osx.o: $(srcdir)/src/osx/anybutton_osx.cpp $(MONODLL_ODEP)
+@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_IPHONE_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/osx/anybutton_osx.cpp
+
@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_CARBON_USE_GUI_1_WXUNIV_0@monodll_bmpbuttn_osx.o: $(srcdir)/src/osx/bmpbuttn_osx.cpp $(MONODLL_ODEP)
@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_CARBON_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/osx/bmpbuttn_osx.cpp
monolib_sockosx.o: $(srcdir)/src/osx/core/sockosx.cpp $(MONOLIB_ODEP)
$(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/osx/core/sockosx.cpp
+monolib_gtk_anybutton.o: $(srcdir)/src/gtk/anybutton.cpp $(MONOLIB_ODEP)
+ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/gtk/anybutton.cpp
+
monolib_artgtk.o: $(srcdir)/src/gtk/artgtk.cpp $(MONOLIB_ODEP)
$(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/gtk/artgtk.cpp
monolib_textctrlce.o: $(srcdir)/src/msw/wince/textctrlce.cpp $(MONOLIB_ODEP)
$(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/msw/wince/textctrlce.cpp
+monolib_carbon_anybutton.o: $(srcdir)/src/osx/carbon/anybutton.cpp $(MONOLIB_ODEP)
+ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/osx/carbon/anybutton.cpp
+
monolib_carbon_bmpbuttn.o: $(srcdir)/src/osx/carbon/bmpbuttn.cpp $(MONOLIB_ODEP)
$(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/osx/carbon/bmpbuttn.cpp
monolib_carbon_window.o: $(srcdir)/src/osx/carbon/window.cpp $(MONOLIB_ODEP)
$(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/osx/carbon/window.cpp
+monolib_cocoa_anybutton.o: $(srcdir)/src/osx/cocoa/anybutton.mm $(MONOLIB_ODEP)
+ $(CXXC) -c -o $@ $(MONOLIB_OBJCXXFLAGS) $(srcdir)/src/osx/cocoa/anybutton.mm
+
monolib_osx_cocoa_button.o: $(srcdir)/src/osx/cocoa/button.mm $(MONOLIB_ODEP)
$(CXXC) -c -o $@ $(MONOLIB_OBJCXXFLAGS) $(srcdir)/src/osx/cocoa/button.mm
monolib_osx_cocoa_window.o: $(srcdir)/src/osx/cocoa/window.mm $(MONOLIB_ODEP)
$(CXXC) -c -o $@ $(MONOLIB_OBJCXXFLAGS) $(srcdir)/src/osx/cocoa/window.mm
+monolib_iphone_anybutton.o: $(srcdir)/src/osx/iphone/anybutton.mm $(MONOLIB_ODEP)
+ $(CXXC) -c -o $@ $(MONOLIB_OBJCXXFLAGS) $(srcdir)/src/osx/iphone/anybutton.mm
+
monolib_iphone_button.o: $(srcdir)/src/osx/iphone/button.mm $(MONOLIB_ODEP)
$(CXXC) -c -o $@ $(MONOLIB_OBJCXXFLAGS) $(srcdir)/src/osx/iphone/button.mm
@COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@monolib_msw_accel.o: $(srcdir)/src/msw/accel.cpp $(MONOLIB_ODEP)
@COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/msw/accel.cpp
+@COND_TOOLKIT_MSW_USE_GUI_1_WXUNIV_0@monolib_msw_anybutton.o: $(srcdir)/src/msw/anybutton.cpp $(MONOLIB_ODEP)
+@COND_TOOLKIT_MSW_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/msw/anybutton.cpp
+
+@COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@monolib_msw_anybutton.o: $(srcdir)/src/msw/anybutton.cpp $(MONOLIB_ODEP)
+@COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/msw/anybutton.cpp
+
@COND_TOOLKIT_MSW_USE_GUI_1_WXUNIV_0@monolib_artmsw.o: $(srcdir)/src/msw/artmsw.cpp $(MONOLIB_ODEP)
@COND_TOOLKIT_MSW_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/msw/artmsw.cpp
@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_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
+
+@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_COCOA_USE_GUI_1_WXUNIV_0@monolib_anybutton_osx.o: $(srcdir)/src/osx/anybutton_osx.cpp $(MONOLIB_ODEP)
+@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_COCOA_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/osx/anybutton_osx.cpp
+
+@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_IPHONE_USE_GUI_1_WXUNIV_0@monolib_anybutton_osx.o: $(srcdir)/src/osx/anybutton_osx.cpp $(MONOLIB_ODEP)
+@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_IPHONE_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/osx/anybutton_osx.cpp
+
@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_CARBON_USE_GUI_1_WXUNIV_0@monolib_bmpbuttn_osx.o: $(srcdir)/src/osx/bmpbuttn_osx.cpp $(MONOLIB_ODEP)
@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_CARBON_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/osx/bmpbuttn_osx.cpp
coredll_osx_cocoa_utils.o: $(srcdir)/src/osx/cocoa/utils.mm $(COREDLL_ODEP)
$(CXXC) -c -o $@ $(COREDLL_OBJCXXFLAGS) $(srcdir)/src/osx/cocoa/utils.mm
+coredll_gtk_anybutton.o: $(srcdir)/src/gtk/anybutton.cpp $(COREDLL_ODEP)
+ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/gtk/anybutton.cpp
+
coredll_artgtk.o: $(srcdir)/src/gtk/artgtk.cpp $(COREDLL_ODEP)
$(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/gtk/artgtk.cpp
coredll_textctrlce.o: $(srcdir)/src/msw/wince/textctrlce.cpp $(COREDLL_ODEP)
$(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/msw/wince/textctrlce.cpp
+coredll_carbon_anybutton.o: $(srcdir)/src/osx/carbon/anybutton.cpp $(COREDLL_ODEP)
+ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/osx/carbon/anybutton.cpp
+
coredll_carbon_bmpbuttn.o: $(srcdir)/src/osx/carbon/bmpbuttn.cpp $(COREDLL_ODEP)
$(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/osx/carbon/bmpbuttn.cpp
coredll_carbon_window.o: $(srcdir)/src/osx/carbon/window.cpp $(COREDLL_ODEP)
$(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/osx/carbon/window.cpp
+coredll_cocoa_anybutton.o: $(srcdir)/src/osx/cocoa/anybutton.mm $(COREDLL_ODEP)
+ $(CXXC) -c -o $@ $(COREDLL_OBJCXXFLAGS) $(srcdir)/src/osx/cocoa/anybutton.mm
+
coredll_osx_cocoa_button.o: $(srcdir)/src/osx/cocoa/button.mm $(COREDLL_ODEP)
$(CXXC) -c -o $@ $(COREDLL_OBJCXXFLAGS) $(srcdir)/src/osx/cocoa/button.mm
coredll_osx_cocoa_window.o: $(srcdir)/src/osx/cocoa/window.mm $(COREDLL_ODEP)
$(CXXC) -c -o $@ $(COREDLL_OBJCXXFLAGS) $(srcdir)/src/osx/cocoa/window.mm
+coredll_iphone_anybutton.o: $(srcdir)/src/osx/iphone/anybutton.mm $(COREDLL_ODEP)
+ $(CXXC) -c -o $@ $(COREDLL_OBJCXXFLAGS) $(srcdir)/src/osx/iphone/anybutton.mm
+
coredll_iphone_button.o: $(srcdir)/src/osx/iphone/button.mm $(COREDLL_ODEP)
$(CXXC) -c -o $@ $(COREDLL_OBJCXXFLAGS) $(srcdir)/src/osx/iphone/button.mm
@COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@coredll_msw_accel.o: $(srcdir)/src/msw/accel.cpp $(COREDLL_ODEP)
@COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/msw/accel.cpp
+@COND_TOOLKIT_MSW_USE_GUI_1_WXUNIV_0@coredll_msw_anybutton.o: $(srcdir)/src/msw/anybutton.cpp $(COREDLL_ODEP)
+@COND_TOOLKIT_MSW_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/msw/anybutton.cpp
+
+@COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@coredll_msw_anybutton.o: $(srcdir)/src/msw/anybutton.cpp $(COREDLL_ODEP)
+@COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/msw/anybutton.cpp
+
@COND_TOOLKIT_MSW_USE_GUI_1_WXUNIV_0@coredll_artmsw.o: $(srcdir)/src/msw/artmsw.cpp $(COREDLL_ODEP)
@COND_TOOLKIT_MSW_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/msw/artmsw.cpp
@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_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
+
+@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_COCOA_USE_GUI_1_WXUNIV_0@coredll_anybutton_osx.o: $(srcdir)/src/osx/anybutton_osx.cpp $(COREDLL_ODEP)
+@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_COCOA_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/osx/anybutton_osx.cpp
+
+@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_IPHONE_USE_GUI_1_WXUNIV_0@coredll_anybutton_osx.o: $(srcdir)/src/osx/anybutton_osx.cpp $(COREDLL_ODEP)
+@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_IPHONE_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/osx/anybutton_osx.cpp
+
@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_CARBON_USE_GUI_1_WXUNIV_0@coredll_bmpbuttn_osx.o: $(srcdir)/src/osx/bmpbuttn_osx.cpp $(COREDLL_ODEP)
@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_CARBON_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/osx/bmpbuttn_osx.cpp
corelib_osx_cocoa_utils.o: $(srcdir)/src/osx/cocoa/utils.mm $(CORELIB_ODEP)
$(CXXC) -c -o $@ $(CORELIB_OBJCXXFLAGS) $(srcdir)/src/osx/cocoa/utils.mm
+corelib_gtk_anybutton.o: $(srcdir)/src/gtk/anybutton.cpp $(CORELIB_ODEP)
+ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/gtk/anybutton.cpp
+
corelib_artgtk.o: $(srcdir)/src/gtk/artgtk.cpp $(CORELIB_ODEP)
$(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/gtk/artgtk.cpp
corelib_textctrlce.o: $(srcdir)/src/msw/wince/textctrlce.cpp $(CORELIB_ODEP)
$(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/msw/wince/textctrlce.cpp
+corelib_carbon_anybutton.o: $(srcdir)/src/osx/carbon/anybutton.cpp $(CORELIB_ODEP)
+ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/osx/carbon/anybutton.cpp
+
corelib_carbon_bmpbuttn.o: $(srcdir)/src/osx/carbon/bmpbuttn.cpp $(CORELIB_ODEP)
$(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/osx/carbon/bmpbuttn.cpp
corelib_carbon_window.o: $(srcdir)/src/osx/carbon/window.cpp $(CORELIB_ODEP)
$(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/osx/carbon/window.cpp
+corelib_cocoa_anybutton.o: $(srcdir)/src/osx/cocoa/anybutton.mm $(CORELIB_ODEP)
+ $(CXXC) -c -o $@ $(CORELIB_OBJCXXFLAGS) $(srcdir)/src/osx/cocoa/anybutton.mm
+
corelib_osx_cocoa_button.o: $(srcdir)/src/osx/cocoa/button.mm $(CORELIB_ODEP)
$(CXXC) -c -o $@ $(CORELIB_OBJCXXFLAGS) $(srcdir)/src/osx/cocoa/button.mm
corelib_osx_cocoa_window.o: $(srcdir)/src/osx/cocoa/window.mm $(CORELIB_ODEP)
$(CXXC) -c -o $@ $(CORELIB_OBJCXXFLAGS) $(srcdir)/src/osx/cocoa/window.mm
+corelib_iphone_anybutton.o: $(srcdir)/src/osx/iphone/anybutton.mm $(CORELIB_ODEP)
+ $(CXXC) -c -o $@ $(CORELIB_OBJCXXFLAGS) $(srcdir)/src/osx/iphone/anybutton.mm
+
corelib_iphone_button.o: $(srcdir)/src/osx/iphone/button.mm $(CORELIB_ODEP)
$(CXXC) -c -o $@ $(CORELIB_OBJCXXFLAGS) $(srcdir)/src/osx/iphone/button.mm
@COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@corelib_msw_accel.o: $(srcdir)/src/msw/accel.cpp $(CORELIB_ODEP)
@COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/msw/accel.cpp
+@COND_TOOLKIT_MSW_USE_GUI_1_WXUNIV_0@corelib_msw_anybutton.o: $(srcdir)/src/msw/anybutton.cpp $(CORELIB_ODEP)
+@COND_TOOLKIT_MSW_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/msw/anybutton.cpp
+
+@COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@corelib_msw_anybutton.o: $(srcdir)/src/msw/anybutton.cpp $(CORELIB_ODEP)
+@COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/msw/anybutton.cpp
+
@COND_TOOLKIT_MSW_USE_GUI_1_WXUNIV_0@corelib_artmsw.o: $(srcdir)/src/msw/artmsw.cpp $(CORELIB_ODEP)
@COND_TOOLKIT_MSW_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/msw/artmsw.cpp
@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_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
+
+@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_COCOA_USE_GUI_1_WXUNIV_0@corelib_anybutton_osx.o: $(srcdir)/src/osx/anybutton_osx.cpp $(CORELIB_ODEP)
+@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_COCOA_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/osx/anybutton_osx.cpp
+
+@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_IPHONE_USE_GUI_1_WXUNIV_0@corelib_anybutton_osx.o: $(srcdir)/src/osx/anybutton_osx.cpp $(CORELIB_ODEP)
+@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_IPHONE_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/osx/anybutton_osx.cpp
+
@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_CARBON_USE_GUI_1_WXUNIV_0@corelib_bmpbuttn_osx.o: $(srcdir)/src/osx/bmpbuttn_osx.cpp $(CORELIB_ODEP)
@COND_PLATFORM_MACOSX_1_TOOLKIT_OSX_CARBON_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/osx/bmpbuttn_osx.cpp
<set var="GUI_CMN_HDR" hints="files">
wx/affinematrix2dbase.h
wx/affinematrix2d.h
+ wx/anybutton.h
wx/bmpbuttn.h
wx/brush.h
wx/button.h
<!-- Generic implementations used by wxGPE: -->
src/generic/fontdlgg.cpp
<!-- GTK+ specific files: -->
+ src/gtk/anybutton.cpp
src/gtk/artgtk.cpp
src/gtk/bmpbuttn.cpp
src/gtk/button.cpp
wx/generic/listctrl.h
wx/generic/statusbr.h
wx/gtk/accel.h
+ wx/gtk/anybutton.h
wx/gtk/bmpbuttn.h
wx/gtk/button.h
wx/gtk/checkbox.h
src/generic/statusbr.cpp
src/generic/prntdlgg.cpp
src/msw/accel.cpp
+ src/msw/anybutton.cpp
src/msw/artmsw.cpp
src/msw/bmpbuttn.cpp
src/msw/button.cpp
wx/generic/filepickerg.h
wx/generic/fontpickerg.h
wx/msw/accel.h
+ wx/msw/anybutton.h
wx/msw/app.h
wx/msw/bitmap.h
wx/msw/bmpbuttn.h
<set var="OSX_CARBON_COCOA_SRC" hints="files">
<if cond="PLATFORM_MACOSX=='1'">
<!-- Common controls implementation -->
+ src/osx/anybutton_osx.cpp
src/osx/bmpbuttn_osx.cpp
src/osx/button_osx.cpp
src/osx/checkbox_osx.cpp
wx/html/webkit.h
<!-- other shared headers -->
wx/osx/accel.h
+ wx/osx/anybutton.h
wx/osx/app.h
wx/osx/bitmap.h
wx/osx/bmpbuttn.h
<set var="OSX_CARBON_SRC" hints="files">
<!-- carbon files -->
$(OSX_CARBON_COCOA_SRC)
+ src/osx/carbon/anybutton.cpp
src/osx/carbon/bmpbuttn.cpp
src/osx/carbon/button.cpp
src/osx/carbon/checkbox.cpp
<set var="OSX_COCOA_SRC" hints="files">
$(OSX_CARBON_COCOA_SRC)
+ src/osx/cocoa/anybutton.mm
src/osx/cocoa/button.mm
src/osx/cocoa/checkbox.mm
src/osx/cocoa/choice.mm
src/generic/regiong.cpp
src/generic/icon.cpp
<!-- iphone files -->
+ src/osx/iphone/anybutton.mm
src/osx/iphone/button.mm
src/osx/iphone/checkbox.mm
src/osx/iphone/dialog.mm
$(OBJS)\monodll_generic_statusbr.obj \\r
$(OBJS)\monodll_prntdlgg.obj \\r
$(OBJS)\monodll_msw_accel.obj \\r
+ $(OBJS)\monodll_anybutton.obj \\r
$(OBJS)\monodll_artmsw.obj \\r
$(OBJS)\monodll_msw_bmpbuttn.obj \\r
$(OBJS)\monodll_msw_button.obj \\r
$(OBJS)\monolib_generic_statusbr.obj \\r
$(OBJS)\monolib_prntdlgg.obj \\r
$(OBJS)\monolib_msw_accel.obj \\r
+ $(OBJS)\monolib_anybutton.obj \\r
$(OBJS)\monolib_artmsw.obj \\r
$(OBJS)\monolib_msw_bmpbuttn.obj \\r
$(OBJS)\monolib_msw_button.obj \\r
$(OBJS)\coredll_generic_statusbr.obj \\r
$(OBJS)\coredll_prntdlgg.obj \\r
$(OBJS)\coredll_msw_accel.obj \\r
+ $(OBJS)\coredll_anybutton.obj \\r
$(OBJS)\coredll_artmsw.obj \\r
$(OBJS)\coredll_msw_bmpbuttn.obj \\r
$(OBJS)\coredll_msw_button.obj \\r
$(OBJS)\corelib_generic_statusbr.obj \\r
$(OBJS)\corelib_prntdlgg.obj \\r
$(OBJS)\corelib_msw_accel.obj \\r
+ $(OBJS)\corelib_anybutton.obj \\r
$(OBJS)\corelib_artmsw.obj \\r
$(OBJS)\corelib_msw_bmpbuttn.obj \\r
$(OBJS)\corelib_msw_button.obj \\r
$(OBJS)\monodll_msw_accel.obj: ..\..\src\msw\accel.cpp\r
$(CXX) -q -c -P -o$@ $(MONODLL_CXXFLAGS) ..\..\src\msw\accel.cpp\r
\r
+$(OBJS)\monodll_anybutton.obj: ..\..\src\msw\anybutton.cpp\r
+ $(CXX) -q -c -P -o$@ $(MONODLL_CXXFLAGS) ..\..\src\msw\anybutton.cpp\r
+\r
$(OBJS)\monodll_artmsw.obj: ..\..\src\msw\artmsw.cpp\r
$(CXX) -q -c -P -o$@ $(MONODLL_CXXFLAGS) ..\..\src\msw\artmsw.cpp\r
\r
$(OBJS)\monolib_msw_accel.obj: ..\..\src\msw\accel.cpp\r
$(CXX) -q -c -P -o$@ $(MONOLIB_CXXFLAGS) ..\..\src\msw\accel.cpp\r
\r
+$(OBJS)\monolib_anybutton.obj: ..\..\src\msw\anybutton.cpp\r
+ $(CXX) -q -c -P -o$@ $(MONOLIB_CXXFLAGS) ..\..\src\msw\anybutton.cpp\r
+\r
$(OBJS)\monolib_artmsw.obj: ..\..\src\msw\artmsw.cpp\r
$(CXX) -q -c -P -o$@ $(MONOLIB_CXXFLAGS) ..\..\src\msw\artmsw.cpp\r
\r
$(OBJS)\coredll_msw_accel.obj: ..\..\src\msw\accel.cpp\r
$(CXX) -q -c -P -o$@ $(COREDLL_CXXFLAGS) ..\..\src\msw\accel.cpp\r
\r
+$(OBJS)\coredll_anybutton.obj: ..\..\src\msw\anybutton.cpp\r
+ $(CXX) -q -c -P -o$@ $(COREDLL_CXXFLAGS) ..\..\src\msw\anybutton.cpp\r
+\r
$(OBJS)\coredll_artmsw.obj: ..\..\src\msw\artmsw.cpp\r
$(CXX) -q -c -P -o$@ $(COREDLL_CXXFLAGS) ..\..\src\msw\artmsw.cpp\r
\r
$(OBJS)\corelib_msw_accel.obj: ..\..\src\msw\accel.cpp\r
$(CXX) -q -c -P -o$@ $(CORELIB_CXXFLAGS) ..\..\src\msw\accel.cpp\r
\r
+$(OBJS)\corelib_anybutton.obj: ..\..\src\msw\anybutton.cpp\r
+ $(CXX) -q -c -P -o$@ $(CORELIB_CXXFLAGS) ..\..\src\msw\anybutton.cpp\r
+\r
$(OBJS)\corelib_artmsw.obj: ..\..\src\msw\artmsw.cpp\r
$(CXX) -q -c -P -o$@ $(CORELIB_CXXFLAGS) ..\..\src\msw\artmsw.cpp\r
\r
$(OBJS)\monodll_generic_statusbr.o \\r
$(OBJS)\monodll_prntdlgg.o \\r
$(OBJS)\monodll_msw_accel.o \\r
+ $(OBJS)\monodll_anybutton.o \\r
$(OBJS)\monodll_artmsw.o \\r
$(OBJS)\monodll_msw_bmpbuttn.o \\r
$(OBJS)\monodll_msw_button.o \\r
$(OBJS)\monolib_generic_statusbr.o \\r
$(OBJS)\monolib_prntdlgg.o \\r
$(OBJS)\monolib_msw_accel.o \\r
+ $(OBJS)\monolib_anybutton.o \\r
$(OBJS)\monolib_artmsw.o \\r
$(OBJS)\monolib_msw_bmpbuttn.o \\r
$(OBJS)\monolib_msw_button.o \\r
$(OBJS)\coredll_generic_statusbr.o \\r
$(OBJS)\coredll_prntdlgg.o \\r
$(OBJS)\coredll_msw_accel.o \\r
+ $(OBJS)\coredll_anybutton.o \\r
$(OBJS)\coredll_artmsw.o \\r
$(OBJS)\coredll_msw_bmpbuttn.o \\r
$(OBJS)\coredll_msw_button.o \\r
$(OBJS)\corelib_generic_statusbr.o \\r
$(OBJS)\corelib_prntdlgg.o \\r
$(OBJS)\corelib_msw_accel.o \\r
+ $(OBJS)\corelib_anybutton.o \\r
$(OBJS)\corelib_artmsw.o \\r
$(OBJS)\corelib_msw_bmpbuttn.o \\r
$(OBJS)\corelib_msw_button.o \\r
$(OBJS)\monodll_msw_accel.o: ../../src/msw/accel.cpp\r
$(CXX) -c -o $@ $(MONODLL_CXXFLAGS) $(CPPDEPS) $<\r
\r
+$(OBJS)\monodll_anybutton.o: ../../src/msw/anybutton.cpp\r
+ $(CXX) -c -o $@ $(MONODLL_CXXFLAGS) $(CPPDEPS) $<\r
+\r
$(OBJS)\monodll_artmsw.o: ../../src/msw/artmsw.cpp\r
$(CXX) -c -o $@ $(MONODLL_CXXFLAGS) $(CPPDEPS) $<\r
\r
$(OBJS)\monolib_msw_accel.o: ../../src/msw/accel.cpp\r
$(CXX) -c -o $@ $(MONOLIB_CXXFLAGS) $(CPPDEPS) $<\r
\r
+$(OBJS)\monolib_anybutton.o: ../../src/msw/anybutton.cpp\r
+ $(CXX) -c -o $@ $(MONOLIB_CXXFLAGS) $(CPPDEPS) $<\r
+\r
$(OBJS)\monolib_artmsw.o: ../../src/msw/artmsw.cpp\r
$(CXX) -c -o $@ $(MONOLIB_CXXFLAGS) $(CPPDEPS) $<\r
\r
$(OBJS)\coredll_msw_accel.o: ../../src/msw/accel.cpp\r
$(CXX) -c -o $@ $(COREDLL_CXXFLAGS) $(CPPDEPS) $<\r
\r
+$(OBJS)\coredll_anybutton.o: ../../src/msw/anybutton.cpp\r
+ $(CXX) -c -o $@ $(COREDLL_CXXFLAGS) $(CPPDEPS) $<\r
+\r
$(OBJS)\coredll_artmsw.o: ../../src/msw/artmsw.cpp\r
$(CXX) -c -o $@ $(COREDLL_CXXFLAGS) $(CPPDEPS) $<\r
\r
$(OBJS)\corelib_msw_accel.o: ../../src/msw/accel.cpp\r
$(CXX) -c -o $@ $(CORELIB_CXXFLAGS) $(CPPDEPS) $<\r
\r
+$(OBJS)\corelib_anybutton.o: ../../src/msw/anybutton.cpp\r
+ $(CXX) -c -o $@ $(CORELIB_CXXFLAGS) $(CPPDEPS) $<\r
+\r
$(OBJS)\corelib_artmsw.o: ../../src/msw/artmsw.cpp\r
$(CXX) -c -o $@ $(CORELIB_CXXFLAGS) $(CPPDEPS) $<\r
\r
$(OBJS)\monodll_generic_statusbr.obj \\r
$(OBJS)\monodll_prntdlgg.obj \\r
$(OBJS)\monodll_msw_accel.obj \\r
+ $(OBJS)\monodll_anybutton.obj \\r
$(OBJS)\monodll_artmsw.obj \\r
$(OBJS)\monodll_msw_bmpbuttn.obj \\r
$(OBJS)\monodll_msw_button.obj \\r
$(OBJS)\monolib_generic_statusbr.obj \\r
$(OBJS)\monolib_prntdlgg.obj \\r
$(OBJS)\monolib_msw_accel.obj \\r
+ $(OBJS)\monolib_anybutton.obj \\r
$(OBJS)\monolib_artmsw.obj \\r
$(OBJS)\monolib_msw_bmpbuttn.obj \\r
$(OBJS)\monolib_msw_button.obj \\r
$(OBJS)\coredll_generic_statusbr.obj \\r
$(OBJS)\coredll_prntdlgg.obj \\r
$(OBJS)\coredll_msw_accel.obj \\r
+ $(OBJS)\coredll_anybutton.obj \\r
$(OBJS)\coredll_artmsw.obj \\r
$(OBJS)\coredll_msw_bmpbuttn.obj \\r
$(OBJS)\coredll_msw_button.obj \\r
$(OBJS)\corelib_generic_statusbr.obj \\r
$(OBJS)\corelib_prntdlgg.obj \\r
$(OBJS)\corelib_msw_accel.obj \\r
+ $(OBJS)\corelib_anybutton.obj \\r
$(OBJS)\corelib_artmsw.obj \\r
$(OBJS)\corelib_msw_bmpbuttn.obj \\r
$(OBJS)\corelib_msw_button.obj \\r
$(OBJS)\monodll_msw_accel.obj: ..\..\src\msw\accel.cpp\r
$(CXX) /c /nologo /TP /Fo$@ $(MONODLL_CXXFLAGS) ..\..\src\msw\accel.cpp\r
\r
+$(OBJS)\monodll_anybutton.obj: ..\..\src\msw\anybutton.cpp\r
+ $(CXX) /c /nologo /TP /Fo$@ $(MONODLL_CXXFLAGS) ..\..\src\msw\anybutton.cpp\r
+\r
$(OBJS)\monodll_artmsw.obj: ..\..\src\msw\artmsw.cpp\r
$(CXX) /c /nologo /TP /Fo$@ $(MONODLL_CXXFLAGS) ..\..\src\msw\artmsw.cpp\r
\r
$(OBJS)\monolib_msw_accel.obj: ..\..\src\msw\accel.cpp\r
$(CXX) /c /nologo /TP /Fo$@ $(MONOLIB_CXXFLAGS) ..\..\src\msw\accel.cpp\r
\r
+$(OBJS)\monolib_anybutton.obj: ..\..\src\msw\anybutton.cpp\r
+ $(CXX) /c /nologo /TP /Fo$@ $(MONOLIB_CXXFLAGS) ..\..\src\msw\anybutton.cpp\r
+\r
$(OBJS)\monolib_artmsw.obj: ..\..\src\msw\artmsw.cpp\r
$(CXX) /c /nologo /TP /Fo$@ $(MONOLIB_CXXFLAGS) ..\..\src\msw\artmsw.cpp\r
\r
$(OBJS)\coredll_msw_accel.obj: ..\..\src\msw\accel.cpp\r
$(CXX) /c /nologo /TP /Fo$@ $(COREDLL_CXXFLAGS) ..\..\src\msw\accel.cpp\r
\r
+$(OBJS)\coredll_anybutton.obj: ..\..\src\msw\anybutton.cpp\r
+ $(CXX) /c /nologo /TP /Fo$@ $(COREDLL_CXXFLAGS) ..\..\src\msw\anybutton.cpp\r
+\r
$(OBJS)\coredll_artmsw.obj: ..\..\src\msw\artmsw.cpp\r
$(CXX) /c /nologo /TP /Fo$@ $(COREDLL_CXXFLAGS) ..\..\src\msw\artmsw.cpp\r
\r
$(OBJS)\corelib_msw_accel.obj: ..\..\src\msw\accel.cpp\r
$(CXX) /c /nologo /TP /Fo$@ $(CORELIB_CXXFLAGS) ..\..\src\msw\accel.cpp\r
\r
+$(OBJS)\corelib_anybutton.obj: ..\..\src\msw\anybutton.cpp\r
+ $(CXX) /c /nologo /TP /Fo$@ $(CORELIB_CXXFLAGS) ..\..\src\msw\anybutton.cpp\r
+\r
$(OBJS)\corelib_artmsw.obj: ..\..\src\msw\artmsw.cpp\r
$(CXX) /c /nologo /TP /Fo$@ $(CORELIB_CXXFLAGS) ..\..\src\msw\artmsw.cpp\r
\r
$(OBJS)\monodll_generic_statusbr.obj &\r
$(OBJS)\monodll_prntdlgg.obj &\r
$(OBJS)\monodll_msw_accel.obj &\r
+ $(OBJS)\monodll_anybutton.obj &\r
$(OBJS)\monodll_artmsw.obj &\r
$(OBJS)\monodll_msw_bmpbuttn.obj &\r
$(OBJS)\monodll_msw_button.obj &\r
$(OBJS)\monolib_generic_statusbr.obj &\r
$(OBJS)\monolib_prntdlgg.obj &\r
$(OBJS)\monolib_msw_accel.obj &\r
+ $(OBJS)\monolib_anybutton.obj &\r
$(OBJS)\monolib_artmsw.obj &\r
$(OBJS)\monolib_msw_bmpbuttn.obj &\r
$(OBJS)\monolib_msw_button.obj &\r
$(OBJS)\coredll_generic_statusbr.obj &\r
$(OBJS)\coredll_prntdlgg.obj &\r
$(OBJS)\coredll_msw_accel.obj &\r
+ $(OBJS)\coredll_anybutton.obj &\r
$(OBJS)\coredll_artmsw.obj &\r
$(OBJS)\coredll_msw_bmpbuttn.obj &\r
$(OBJS)\coredll_msw_button.obj &\r
$(OBJS)\corelib_generic_statusbr.obj &\r
$(OBJS)\corelib_prntdlgg.obj &\r
$(OBJS)\corelib_msw_accel.obj &\r
+ $(OBJS)\corelib_anybutton.obj &\r
$(OBJS)\corelib_artmsw.obj &\r
$(OBJS)\corelib_msw_bmpbuttn.obj &\r
$(OBJS)\corelib_msw_button.obj &\r
$(OBJS)\monodll_msw_accel.obj : .AUTODEPEND ..\..\src\msw\accel.cpp\r
$(CXX) -bt=nt -zq -fo=$^@ $(MONODLL_CXXFLAGS) $<\r
\r
+$(OBJS)\monodll_anybutton.obj : .AUTODEPEND ..\..\src\msw\anybutton.cpp\r
+ $(CXX) -bt=nt -zq -fo=$^@ $(MONODLL_CXXFLAGS) $<\r
+\r
$(OBJS)\monodll_artmsw.obj : .AUTODEPEND ..\..\src\msw\artmsw.cpp\r
$(CXX) -bt=nt -zq -fo=$^@ $(MONODLL_CXXFLAGS) $<\r
\r
$(OBJS)\monolib_msw_accel.obj : .AUTODEPEND ..\..\src\msw\accel.cpp\r
$(CXX) -bt=nt -zq -fo=$^@ $(MONOLIB_CXXFLAGS) $<\r
\r
+$(OBJS)\monolib_anybutton.obj : .AUTODEPEND ..\..\src\msw\anybutton.cpp\r
+ $(CXX) -bt=nt -zq -fo=$^@ $(MONOLIB_CXXFLAGS) $<\r
+\r
$(OBJS)\monolib_artmsw.obj : .AUTODEPEND ..\..\src\msw\artmsw.cpp\r
$(CXX) -bt=nt -zq -fo=$^@ $(MONOLIB_CXXFLAGS) $<\r
\r
$(OBJS)\coredll_msw_accel.obj : .AUTODEPEND ..\..\src\msw\accel.cpp\r
$(CXX) -bt=nt -zq -fo=$^@ $(COREDLL_CXXFLAGS) $<\r
\r
+$(OBJS)\coredll_anybutton.obj : .AUTODEPEND ..\..\src\msw\anybutton.cpp\r
+ $(CXX) -bt=nt -zq -fo=$^@ $(COREDLL_CXXFLAGS) $<\r
+\r
$(OBJS)\coredll_artmsw.obj : .AUTODEPEND ..\..\src\msw\artmsw.cpp\r
$(CXX) -bt=nt -zq -fo=$^@ $(COREDLL_CXXFLAGS) $<\r
\r
$(OBJS)\corelib_msw_accel.obj : .AUTODEPEND ..\..\src\msw\accel.cpp\r
$(CXX) -bt=nt -zq -fo=$^@ $(CORELIB_CXXFLAGS) $<\r
\r
+$(OBJS)\corelib_anybutton.obj : .AUTODEPEND ..\..\src\msw\anybutton.cpp\r
+ $(CXX) -bt=nt -zq -fo=$^@ $(CORELIB_CXXFLAGS) $<\r
+\r
$(OBJS)\corelib_artmsw.obj : .AUTODEPEND ..\..\src\msw\artmsw.cpp\r
$(CXX) -bt=nt -zq -fo=$^@ $(CORELIB_CXXFLAGS) $<\r
\r
# End Source File\r
# Begin Source File\r
\r
+SOURCE=..\..\src\msw\anybutton.cpp\r
+\r
+!IF "$(CFG)" == "core - Win32 DLL Universal Release"\r
+\r
+# PROP Exclude_From_Build 1\r
+\r
+!ELSEIF "$(CFG)" == "core - Win32 DLL Universal Debug"\r
+\r
+# PROP Exclude_From_Build 1\r
+\r
+!ELSEIF "$(CFG)" == "core - Win32 DLL Release"\r
+\r
+\r
+!ELSEIF "$(CFG)" == "core - Win32 DLL Debug"\r
+\r
+\r
+!ELSEIF "$(CFG)" == "core - Win32 Universal Release"\r
+\r
+# PROP Exclude_From_Build 1\r
+\r
+!ELSEIF "$(CFG)" == "core - Win32 Universal Debug"\r
+\r
+# PROP Exclude_From_Build 1\r
+\r
+!ELSEIF "$(CFG)" == "core - Win32 Release"\r
+\r
+\r
+!ELSEIF "$(CFG)" == "core - Win32 Debug"\r
+\r
+\r
+!ENDIF\r
+\r
+# End Source File\r
+# Begin Source File\r
+\r
SOURCE=..\..\src\msw\app.cpp\r
# End Source File\r
# Begin Source File\r
# End Source File\r
# Begin Source File\r
\r
+SOURCE=..\..\include\wx\msw\anybutton.h\r
+# End Source File\r
+# Begin Source File\r
+\r
SOURCE=..\..\include\wx\msw\app.h\r
# End Source File\r
# Begin Source File\r
# End Source File\r
# Begin Source File\r
\r
+SOURCE=..\..\include\wx\anybutton.h\r
+# End Source File\r
+# Begin Source File\r
+\r
SOURCE=..\..\include\wx\ribbon\art.h\r
# End Source File\r
# Begin Source File\r
<File\r
RelativePath="..\..\src\msw\ole\activex.cpp">\r
</File>\r
+ <File\r
+ RelativePath="..\..\src\msw\anybutton.cpp">\r
+ <FileConfiguration\r
+ Name="Universal Debug|Win32"\r
+ ExcludedFromBuild="TRUE"/>\r
+ <FileConfiguration\r
+ Name="Universal Release|Win32"\r
+ ExcludedFromBuild="TRUE"/>\r
+ <FileConfiguration\r
+ Name="DLL Universal Debug|Win32"\r
+ ExcludedFromBuild="TRUE"/>\r
+ <FileConfiguration\r
+ Name="DLL Universal Release|Win32"\r
+ ExcludedFromBuild="TRUE"/>\r
+ </File>\r
<File\r
RelativePath="..\..\src\msw\app.cpp">\r
</File>\r
<File\r
RelativePath="..\..\include\wx\msw\ole\activex.h">\r
</File>\r
+ <File\r
+ RelativePath="..\..\include\wx\msw\anybutton.h">\r
+ </File>\r
<File\r
RelativePath="..\..\include\wx\msw\app.h">\r
</File>\r
<File\r
RelativePath="..\..\include\wx\animdecod.h">\r
</File>\r
+ <File\r
+ RelativePath="..\..\include\wx\anybutton.h">\r
+ </File>\r
<File\r
RelativePath="..\..\include\wx\ribbon\art.h">\r
</File>\r
RelativePath="..\..\src\msw\ole\activex.cpp"\r
>\r
</File>\r
+ <File\r
+ RelativePath="..\..\src\msw\anybutton.cpp"\r
+ >\r
+ <FileConfiguration\r
+ Name="Universal Debug|Win32"\r
+ ExcludedFromBuild="true"\r
+ />\r
+ <FileConfiguration\r
+ Name="Universal Release|Win32"\r
+ ExcludedFromBuild="true"\r
+ />\r
+ <FileConfiguration\r
+ Name="DLL Universal Debug|Win32"\r
+ ExcludedFromBuild="true"\r
+ />\r
+ <FileConfiguration\r
+ Name="DLL Universal Release|Win32"\r
+ ExcludedFromBuild="true"\r
+ />\r
+ </File>\r
<File\r
RelativePath="..\..\src\msw\app.cpp"\r
>\r
RelativePath="..\..\include\wx\msw\ole\activex.h"\r
>\r
</File>\r
+ <File\r
+ RelativePath="..\..\include\wx\msw\anybutton.h"\r
+ >\r
+ </File>\r
<File\r
RelativePath="..\..\include\wx\msw\app.h"\r
>\r
RelativePath="..\..\include\wx\animdecod.h"\r
>\r
</File>\r
+ <File\r
+ RelativePath="..\..\include\wx\anybutton.h"\r
+ >\r
+ </File>\r
<File\r
RelativePath="..\..\include\wx\ribbon\art.h"\r
>\r
RelativePath="..\..\src\msw\ole\activex.cpp"\r
>\r
</File>\r
+ <File\r
+ RelativePath="..\..\src\msw\anybutton.cpp"\r
+ >\r
+ <FileConfiguration\r
+ Name="Universal Debug|Win32"\r
+ ExcludedFromBuild="true"\r
+ />\r
+ <FileConfiguration\r
+ Name="Universal Release|Win32"\r
+ ExcludedFromBuild="true"\r
+ />\r
+ <FileConfiguration\r
+ Name="DLL Universal Debug|Win32"\r
+ ExcludedFromBuild="true"\r
+ />\r
+ <FileConfiguration\r
+ Name="DLL Universal Release|Win32"\r
+ ExcludedFromBuild="true"\r
+ />\r
+ </File>\r
<File\r
RelativePath="..\..\src\msw\app.cpp"\r
>\r
RelativePath="..\..\include\wx\msw\ole\activex.h"\r
>\r
</File>\r
+ <File\r
+ RelativePath="..\..\include\wx\msw\anybutton.h"\r
+ >\r
+ </File>\r
<File\r
RelativePath="..\..\include\wx\msw\app.h"\r
>\r
RelativePath="..\..\include\wx\animdecod.h"\r
>\r
</File>\r
+ <File\r
+ RelativePath="..\..\include\wx\anybutton.h"\r
+ >\r
+ </File>\r
<File\r
RelativePath="..\..\include\wx\ribbon\art.h"\r
>\r
- Added wxCommandLinkButton (Rickard Westerlund, GSoC 2010 project).
- Added wxUIActionSimulator (Steven Lamerton, GSoC 2010 project).
- Added support for dynamic auto-completion in wxTextEntry.
+- Added images support to wxToggleButton (Garrick Meeker).
- wxAUI: support auto-orientable toolbars (wsu).
- wxAUI: add support for icons in pane title bars (triton).
- Added wxPanel::SetBackgroundBitmap().
--- /dev/null
+/////////////////////////////////////////////////////////////////////////////
+// Name: wx/anybutton.h
+// Purpose: wxAnyButtonBase class
+// Author: Vadim Zetlin
+// Created: 2000-08-15 (extracted from button.h)
+// RCS-ID: $Id: anybutton.h 65680 2010-09-30 11:44:45Z VZ $
+// Copyright: (c) Vadim Zetlin
+// Licence: wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef _WX_ANYBUTTON_H_BASE_
+#define _WX_ANYBUTTON_H_BASE_
+
+#include "wx/defs.h"
+
+#ifdef wxHAS_ANY_BUTTON
+
+// ----------------------------------------------------------------------------
+// wxAnyButton specific flags
+// ----------------------------------------------------------------------------
+
+// These flags affect label alignment
+#define wxBU_LEFT 0x0040
+#define wxBU_TOP 0x0080
+#define wxBU_RIGHT 0x0100
+#define wxBU_BOTTOM 0x0200
+#define wxBU_ALIGN_MASK ( wxBU_LEFT | wxBU_TOP | wxBU_RIGHT | wxBU_BOTTOM )
+
+// These two flags are obsolete
+#define wxBU_NOAUTODRAW 0x0000
+#define wxBU_AUTODRAW 0x0004
+
+// by default, the buttons will be created with some (system dependent)
+// minimal size to make them look nicer, giving this style will make them as
+// small as possible
+#define wxBU_EXACTFIT 0x0001
+
+// this flag can be used to disable using the text label in the button: it is
+// mostly useful when creating buttons showing bitmap and having stock id as
+// without it both the standard label corresponding to the stock id and the
+// bitmap would be shown
+#define wxBU_NOTEXT 0x0002
+
+
+#include "wx/bitmap.h"
+#include "wx/control.h"
+
+// ----------------------------------------------------------------------------
+// wxAnyButton: common button functionality
+// ----------------------------------------------------------------------------
+
+class WXDLLIMPEXP_CORE wxAnyButtonBase : public wxControl
+{
+public:
+ wxAnyButtonBase() { }
+
+ // show the image in the button in addition to the label: this method is
+ // supported on all (major) platforms
+ void SetBitmap(const wxBitmap& bitmap, wxDirection dir = wxLEFT)
+ {
+ SetBitmapLabel(bitmap);
+ SetBitmapPosition(dir);
+ }
+
+ wxBitmap GetBitmap() const { return DoGetBitmap(State_Normal); }
+
+ // Methods for setting individual images for different states: normal,
+ // selected (meaning pushed or pressed), focused (meaning normal state for
+ // a focused button), disabled or hover (a.k.a. hot or current).
+ //
+ // Remember that SetBitmap() itself must be called before any other
+ // SetBitmapXXX() methods (except for SetBitmapLabel() which is a synonym
+ // for it anyhow) and that all bitmaps passed to these functions should be
+ // of the same size.
+ void SetBitmapLabel(const wxBitmap& bitmap)
+ { DoSetBitmap(bitmap, State_Normal); }
+ void SetBitmapPressed(const wxBitmap& bitmap)
+ { DoSetBitmap(bitmap, State_Pressed); }
+ void SetBitmapDisabled(const wxBitmap& bitmap)
+ { DoSetBitmap(bitmap, State_Disabled); }
+ void SetBitmapCurrent(const wxBitmap& bitmap)
+ { DoSetBitmap(bitmap, State_Current); }
+ void SetBitmapFocus(const wxBitmap& bitmap)
+ { DoSetBitmap(bitmap, State_Focused); }
+
+ wxBitmap GetBitmapLabel() const { return DoGetBitmap(State_Normal); }
+ wxBitmap GetBitmapPressed() const { return DoGetBitmap(State_Pressed); }
+ wxBitmap GetBitmapDisabled() const { return DoGetBitmap(State_Disabled); }
+ wxBitmap GetBitmapCurrent() const { return DoGetBitmap(State_Current); }
+ wxBitmap GetBitmapFocus() const { return DoGetBitmap(State_Focused); }
+
+
+ // set the margins around the image
+ void SetBitmapMargins(wxCoord x, wxCoord y) { DoSetBitmapMargins(x, y); }
+ void SetBitmapMargins(const wxSize& sz) { DoSetBitmapMargins(sz.x, sz.y); }
+ wxSize GetBitmapMargins() { return DoGetBitmapMargins(); }
+
+ // set the image position relative to the text, i.e. wxLEFT means that the
+ // image is to the left of the text (this is the default)
+ void SetBitmapPosition(wxDirection dir);
+
+
+ // Buttons on MSW can look bad if they are not native colours, because
+ // then they become owner-drawn and not theme-drawn. Disable it here
+ // in wxAnyButtonBase to make it consistent.
+ virtual bool ShouldInheritColours() const { return false; }
+
+ // wxUniv-compatible and deprecated equivalents to SetBitmapXXX()
+#if WXWIN_COMPATIBILITY_2_8
+ void SetImageLabel(const wxBitmap& bitmap) { SetBitmap(bitmap); }
+ void SetImageMargins(wxCoord x, wxCoord y) { SetBitmapMargins(x, y); }
+#endif // WXWIN_COMPATIBILITY_2_8
+
+ // backwards compatible names for pressed/current bitmaps: they're not
+ // deprecated as there is nothing really wrong with using them and no real
+ // advantage to using the new names but the new names are still preferred
+ wxBitmap GetBitmapSelected() const { return GetBitmapPressed(); }
+ wxBitmap GetBitmapHover() const { return GetBitmapCurrent(); }
+
+ void SetBitmapSelected(const wxBitmap& bitmap) { SetBitmapPressed(bitmap); }
+ void SetBitmapHover(const wxBitmap& bitmap) { SetBitmapCurrent(bitmap); }
+
+
+ // this enum is not part of wx public API, it is public because it is used
+ // in non wxAnyButton-derived classes internally
+ //
+ // also notice that MSW code relies on the values of the enum elements, do
+ // not change them without revising src/msw/button.cpp
+ enum State
+ {
+ State_Normal,
+ State_Current, // a.k.a. hot or "hovering"
+ State_Pressed, // a.k.a. "selected" in public API for some reason
+ State_Disabled,
+ State_Focused,
+ State_Max
+ };
+
+ // return true if this button shouldn't show the text label, either because
+ // it doesn't have it or because it was explicitly disabled with wxBU_NOTEXT
+ bool DontShowLabel() const
+ {
+ return HasFlag(wxBU_NOTEXT) || GetLabel().empty();
+ }
+
+ // return true if we do show the label
+ bool ShowsLabel() const
+ {
+ return !DontShowLabel();
+ }
+
+protected:
+ // choose the default border for this window
+ virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
+
+ virtual wxBitmap DoGetBitmap(State WXUNUSED(which)) const
+ { return wxBitmap(); }
+ virtual void DoSetBitmap(const wxBitmap& WXUNUSED(bitmap),
+ State WXUNUSED(which))
+ { }
+
+ virtual wxSize DoGetBitmapMargins() const
+ { return wxSize(0, 0); }
+
+ virtual void DoSetBitmapMargins(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y))
+ { }
+
+ virtual void DoSetBitmapPosition(wxDirection WXUNUSED(dir))
+ { }
+
+ virtual bool DoGetAuthNeeded() const { return false; }
+ virtual void DoSetAuthNeeded(bool WXUNUSED(show)) { }
+
+
+ wxDECLARE_NO_COPY_CLASS(wxAnyButtonBase);
+};
+
+//#if defined(__WXUNIVERSAL__)
+// #include "wx/univ/anybutton.h"
+#if defined(__WXMSW__)
+ #include "wx/msw/anybutton.h"
+//#elif defined(__WXMOTIF__)
+// #include "wx/motif/anybutton.h"
+#elif defined(__WXGTK20__)
+ #include "wx/gtk/anybutton.h"
+//#elif defined(__WXGTK__)
+// #include "wx/gtk1/anybutton.h"
+#elif defined(__WXMAC__)
+ #include "wx/osx/anybutton.h"
+//#elif defined(__WXCOCOA__)
+// #include "wx/cocoa/anybutton.h"
+//#elif defined(__WXPM__)
+// #include "wx/os2/anybutton.h"
+//#elif defined(__WXPALMOS__)
+// #include "wx/palmos/anybutton.h"
+#else
+ typedef wxAnyButtonBase wxAnyButton;
+#endif
+
+#endif // wxHAS_ANY_BUTTON
+
+#endif // _WX_ANYBUTTON_H_BASE_
#include "wx/defs.h"
-// ----------------------------------------------------------------------------
-// wxButton flags shared with other classes
-// ----------------------------------------------------------------------------
-
-#if wxUSE_TOGGLEBTN || wxUSE_BUTTON
-
-// These flags affect label alignment
-#define wxBU_LEFT 0x0040
-#define wxBU_TOP 0x0080
-#define wxBU_RIGHT 0x0100
-#define wxBU_BOTTOM 0x0200
-#define wxBU_ALIGN_MASK ( wxBU_LEFT | wxBU_TOP | wxBU_RIGHT | wxBU_BOTTOM )
-#endif
-
#if wxUSE_BUTTON
-// ----------------------------------------------------------------------------
-// wxButton specific flags
-// ----------------------------------------------------------------------------
-
-// These two flags are obsolete
-#define wxBU_NOAUTODRAW 0x0000
-#define wxBU_AUTODRAW 0x0004
-
-// by default, the buttons will be created with some (system dependent)
-// minimal size to make them look nicer, giving this style will make them as
-// small as possible
-#define wxBU_EXACTFIT 0x0001
-
-// this flag can be used to disable using the text label in the button: it is
-// mostly useful when creating buttons showing bitmap and having stock id as
-// without it both the standard label corresponding to the stock id and the
-// bitmap would be shown
-#define wxBU_NOTEXT 0x0002
-
-
-#include "wx/bitmap.h"
-#include "wx/control.h"
+#include "wx/anybutton.h"
extern WXDLLIMPEXP_DATA_CORE(const char) wxButtonNameStr[];
// wxButton: a push button
// ----------------------------------------------------------------------------
-class WXDLLIMPEXP_CORE wxButtonBase : public wxControl
+class WXDLLIMPEXP_CORE wxButtonBase : public wxAnyButton
{
public:
wxButtonBase() { }
void SetAuthNeeded(bool show = true) { DoSetAuthNeeded(show); }
bool GetAuthNeeded() const { return DoGetAuthNeeded(); }
- // show the image in the button in addition to the label: this method is
- // supported on all (major) platforms
- void SetBitmap(const wxBitmap& bitmap, wxDirection dir = wxLEFT)
- {
- SetBitmapLabel(bitmap);
- SetBitmapPosition(dir);
- }
-
- wxBitmap GetBitmap() const { return DoGetBitmap(State_Normal); }
-
- // Methods for setting individual images for different states: normal,
- // selected (meaning pushed or pressed), focused (meaning normal state for
- // a focused button), disabled or hover (a.k.a. hot or current).
- //
- // Remember that SetBitmap() itself must be called before any other
- // SetBitmapXXX() methods (except for SetBitmapLabel() which is a synonym
- // for it anyhow) and that all bitmaps passed to these functions should be
- // of the same size.
- void SetBitmapLabel(const wxBitmap& bitmap)
- { DoSetBitmap(bitmap, State_Normal); }
- void SetBitmapPressed(const wxBitmap& bitmap)
- { DoSetBitmap(bitmap, State_Pressed); }
- void SetBitmapDisabled(const wxBitmap& bitmap)
- { DoSetBitmap(bitmap, State_Disabled); }
- void SetBitmapCurrent(const wxBitmap& bitmap)
- { DoSetBitmap(bitmap, State_Current); }
- void SetBitmapFocus(const wxBitmap& bitmap)
- { DoSetBitmap(bitmap, State_Focused); }
-
- wxBitmap GetBitmapLabel() const { return DoGetBitmap(State_Normal); }
- wxBitmap GetBitmapPressed() const { return DoGetBitmap(State_Pressed); }
- wxBitmap GetBitmapDisabled() const { return DoGetBitmap(State_Disabled); }
- wxBitmap GetBitmapCurrent() const { return DoGetBitmap(State_Current); }
- wxBitmap GetBitmapFocus() const { return DoGetBitmap(State_Focused); }
-
-
- // set the margins around the image
- void SetBitmapMargins(wxCoord x, wxCoord y) { DoSetBitmapMargins(x, y); }
- void SetBitmapMargins(const wxSize& sz) { DoSetBitmapMargins(sz.x, sz.y); }
- wxSize GetBitmapMargins() { return DoGetBitmapMargins(); }
-
- // set the image position relative to the text, i.e. wxLEFT means that the
- // image is to the left of the text (this is the default)
- void SetBitmapPosition(wxDirection dir);
-
-
// make this button the default button in its top level window
//
// returns the old default item (possibly NULL)
virtual wxWindow *SetDefault();
- // Buttons on MSW can look bad if they are not native colours, because
- // then they become owner-drawn and not theme-drawn. Disable it here
- // in wxButtonBase to make it consistent.
- virtual bool ShouldInheritColours() const { return false; }
-
// returns the default button size for this platform
static wxSize GetDefaultSize();
- // wxUniv-compatible and deprecated equivalents to SetBitmapXXX()
-#if WXWIN_COMPATIBILITY_2_8
- void SetImageLabel(const wxBitmap& bitmap) { SetBitmap(bitmap); }
- void SetImageMargins(wxCoord x, wxCoord y) { SetBitmapMargins(x, y); }
-#endif // WXWIN_COMPATIBILITY_2_8
-
- // backwards compatible names for pressed/current bitmaps: they're not
- // deprecated as there is nothing really wrong with using them and no real
- // advantage to using the new names but the new names are still preferred
- wxBitmap GetBitmapSelected() const { return GetBitmapPressed(); }
- wxBitmap GetBitmapHover() const { return GetBitmapCurrent(); }
-
- void SetBitmapSelected(const wxBitmap& bitmap) { SetBitmapPressed(bitmap); }
- void SetBitmapHover(const wxBitmap& bitmap) { SetBitmapCurrent(bitmap); }
-
-
- // this enum is not part of wx public API, it is public because it is used
- // in non wxButton-derived classes internally
- //
- // also notice that MSW code relies on the values of the enum elements, do
- // not change them without revising src/msw/button.cpp
- enum State
- {
- State_Normal,
- State_Current, // a.k.a. hot or "hovering"
- State_Pressed, // a.k.a. "selected" in public API for some reason
- State_Disabled,
- State_Focused,
- State_Max
- };
-
- // return true if this button shouldn't show the text label, either because
- // it doesn't have it or because it was explicitly disabled with wxBU_NOTEXT
- bool DontShowLabel() const
- {
- return HasFlag(wxBU_NOTEXT) || GetLabel().empty();
- }
-
- // return true if we do show the label
- bool ShowsLabel() const
- {
- return !DontShowLabel();
- }
-
protected:
- // choose the default border for this window
- virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
-
- virtual bool DoGetAuthNeeded() const { return false; }
- virtual void DoSetAuthNeeded(bool WXUNUSED(show)) { }
-
- virtual wxBitmap DoGetBitmap(State WXUNUSED(which)) const
- { return wxBitmap(); }
- virtual void DoSetBitmap(const wxBitmap& WXUNUSED(bitmap),
- State WXUNUSED(which))
- { }
-
- virtual wxSize DoGetBitmapMargins() const
- { return wxSize(0, 0); }
-
- virtual void DoSetBitmapMargins(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y))
- { }
-
- virtual void DoSetBitmapPosition(wxDirection WXUNUSED(dir))
- { }
-
-
wxDECLARE_NO_COPY_CLASS(wxButtonBase);
};
#endif // wxUSE_BUTTON
-#endif
- // _WX_BUTTON_H_BASE_
+#endif // _WX_BUTTON_H_BASE_
--- /dev/null
+/////////////////////////////////////////////////////////////////////////////
+// Name: wx/gtk/anybutton.h
+// Purpose: wxGTK wxAnyButton class declaration
+// Author: Robert Roebling
+// Created: 1998-05-20 (extracted from button.h)
+// Id: $Id: anybutton.h 67066 2011-02-27 12:48:30Z VZ $
+// Copyright: (c) 1998 Robert Roebling
+// Licence: wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef _WX_GTK_ANYBUTTON_H_
+#define _WX_GTK_ANYBUTTON_H_
+
+//-----------------------------------------------------------------------------
+// wxAnyButton
+//-----------------------------------------------------------------------------
+
+class WXDLLIMPEXP_CORE wxAnyButton : public wxAnyButtonBase
+{
+public:
+ wxAnyButton()
+ {
+ m_isCurrent =
+ m_isPressed = false;
+ }
+
+ virtual bool Enable( bool enable = true );
+
+ // implementation
+ // --------------
+
+ static wxVisualAttributes
+ GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
+
+ // called from GTK callbacks: they update the button state and call
+ // GTKUpdateBitmap()
+ void GTKMouseEnters();
+ void GTKMouseLeaves();
+ void GTKPressed();
+ void GTKReleased();
+
+protected:
+ virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const;
+
+ virtual wxBitmap DoGetBitmap(State which) const;
+ virtual void DoSetBitmap(const wxBitmap& bitmap, State which);
+ virtual void DoSetBitmapPosition(wxDirection dir);
+
+private:
+ typedef wxAnyButtonBase base_type;
+
+ // focus event handler: calls GTKUpdateBitmap()
+ void GTKOnFocus(wxFocusEvent& event);
+
+ // update the bitmap to correspond to the current button state
+ void GTKUpdateBitmap();
+
+ // return the current button state from m_isXXX flags (which means that it
+ // might not correspond to the real current state as e.g. m_isCurrent will
+ // never be true if we don't have a valid current bitmap)
+ State GTKGetCurrentState() const;
+
+ // show the given bitmap (must be valid)
+ void GTKDoShowBitmap(const wxBitmap& bitmap);
+
+
+ // the bitmaps for the different state of the buttons, all of them may be
+ // invalid and the button only shows a bitmap at all if State_Normal bitmap
+ // is valid
+ wxBitmap m_bitmaps[State_Max];
+
+ // true iff mouse is currently over the button
+ bool m_isCurrent;
+
+ // true iff the button is in pressed state
+ bool m_isPressed;
+
+ wxDECLARE_NO_COPY_CLASS(wxAnyButton);
+};
+
+#endif // _WX_GTK_ANYBUTTON_H_
class WXDLLIMPEXP_CORE wxButton : public wxButtonBase
{
public:
- wxButton() { Init(); }
+ wxButton() {}
wxButton(wxWindow *parent, wxWindowID id,
const wxString& label = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxButtonNameStr)
{
- Init();
-
Create(parent, id, label, pos, size, style, validator, name);
}
virtual wxWindow *SetDefault();
virtual void SetLabel( const wxString &label );
- virtual bool Enable( bool enable = true );
// implementation
// --------------
virtual wxSize DoGetBestSize() const;
virtual void DoApplyWidgetStyle(GtkRcStyle *style);
- virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const;
-
- virtual wxBitmap DoGetBitmap(State which) const;
- virtual void DoSetBitmap(const wxBitmap& bitmap, State which);
- virtual void DoSetBitmapPosition(wxDirection dir);
-
#if wxUSE_MARKUP
virtual bool DoSetLabelMarkup(const wxString& markup);
#endif // wxUSE_MARKUP
private:
typedef wxButtonBase base_type;
- // common part of all ctors
- void Init()
- {
- m_isCurrent =
- m_isPressed = false;
- }
-
- // focus event handler: calls GTKUpdateBitmap()
- void GTKOnFocus(wxFocusEvent& event);
-
- // update the bitmap to correspond to the current button state
- void GTKUpdateBitmap();
-
- // return the current button state from m_isXXX flags (which means that it
- // might not correspond to the real current state as e.g. m_isCurrent will
- // never be true if we don't have a valid current bitmap)
- State GTKGetCurrentState() const;
-
- // show the given bitmap (must be valid)
- void GTKDoShowBitmap(const wxBitmap& bitmap);
-
// Return the GtkLabel used by this button.
GtkLabel *GTKGetLabel() const;
-
- // the bitmaps for the different state of the buttons, all of them may be
- // invalid and the button only shows a bitmap at all if State_Normal bitmap
- // is valid
- wxBitmap m_bitmaps[State_Max];
-
- // true iff mouse is currently over the button
- bool m_isCurrent;
-
- // true iff the button is in pressed state
- bool m_isPressed;
-
DECLARE_DYNAMIC_CLASS(wxButton)
};
class WXDLLIMPEXP_FWD_CORE wxToggleBitmapButton;
//-----------------------------------------------------------------------------
-// wxBitmapToggleButton
+// wxToggleButton
//-----------------------------------------------------------------------------
-class WXDLLIMPEXP_CORE wxBitmapToggleButton: public wxToggleButtonBase
+class WXDLLIMPEXP_CORE wxToggleButton: public wxToggleButtonBase
{
public:
// construction/destruction
- wxBitmapToggleButton() {}
- wxBitmapToggleButton(wxWindow *parent,
+ wxToggleButton() {}
+ wxToggleButton(wxWindow *parent,
wxWindowID id,
- const wxBitmap& label,
+ const wxString& label,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
// Create the control
bool Create(wxWindow *parent,
wxWindowID id,
- const wxBitmap& label,
+ const wxString& label,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0,
const wxValidator& validator = wxDefaultValidator,
bool GetValue() const;
// Set the label
- virtual void SetLabel(const wxString& label) { wxControl::SetLabel(label); }
- virtual void SetLabel(const wxBitmap& label);
- bool Enable(bool enable = true);
+ void SetLabel(const wxString& label);
static wxVisualAttributes
GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
- // implementation
- wxBitmap m_bitmap;
-
- void OnSetBitmap();
-
protected:
void GTKDisableEvents();
void GTKEnableEvents();
virtual wxSize DoGetBestSize() const;
virtual void DoApplyWidgetStyle(GtkRcStyle *style);
- virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const;
+
+#if wxUSE_MARKUP
+ virtual bool DoSetLabelMarkup(const wxString& markup);
+#endif // wxUSE_MARKUP
private:
typedef wxToggleButtonBase base_type;
- DECLARE_DYNAMIC_CLASS(wxBitmapToggleButton)
+ // Return the GtkLabel used by this toggle button.
+ GtkLabel *GTKGetLabel() const;
+
+ DECLARE_DYNAMIC_CLASS(wxToggleButton)
};
//-----------------------------------------------------------------------------
-// wxToggleButton
+// wxBitmapToggleButton
//-----------------------------------------------------------------------------
-class WXDLLIMPEXP_CORE wxToggleButton: public wxToggleButtonBase
+class WXDLLIMPEXP_CORE wxBitmapToggleButton: public wxToggleButton
{
public:
// construction/destruction
- wxToggleButton() {}
- wxToggleButton(wxWindow *parent,
+ wxBitmapToggleButton() {}
+ wxBitmapToggleButton(wxWindow *parent,
wxWindowID id,
- const wxString& label,
+ const wxBitmap& label,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
// Create the control
bool Create(wxWindow *parent,
wxWindowID id,
- const wxString& label,
+ const wxBitmap& label,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxCheckBoxNameStr);
- // Get/set the value
- void SetValue(bool state);
- bool GetValue() const;
-
- // Set the label
- void SetLabel(const wxString& label);
- bool Enable(bool enable = true);
-
- static wxVisualAttributes
- GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
-
-protected:
- void GTKDisableEvents();
- void GTKEnableEvents();
-
- virtual wxSize DoGetBestSize() const;
- virtual void DoApplyWidgetStyle(GtkRcStyle *style);
- virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const;
+ // deprecated synonym for SetBitmapLabel()
+ wxDEPRECATED_INLINE( void SetLabel(const wxBitmap& bitmap),
+ SetBitmapLabel(bitmap); )
+ // prevent virtual function hiding
+ virtual void SetLabel(const wxString& label) { wxToggleButton::SetLabel(label); }
private:
typedef wxToggleButtonBase base_type;
- DECLARE_DYNAMIC_CLASS(wxToggleButton)
+ DECLARE_DYNAMIC_CLASS(wxBitmapToggleButton)
};
#endif // _WX_GTK_TOGGLEBUTTON_H_
--- /dev/null
+/////////////////////////////////////////////////////////////////////////////
+// Name: wx/msw/anybutton.h
+// Purpose: wxAnyButton class
+// Author: Julian Smart
+// Created: 1997-02-01 (extracted from button.h)
+// RCS-ID: $Id: anybutton.h 67065 2011-02-27 12:48:26Z VZ $
+// Copyright: (c) Julian Smart
+// Licence: wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef _WX_MSW_ANYBUTTON_H_
+#define _WX_MSW_ANYBUTTON_H_
+
+// ----------------------------------------------------------------------------
+// Common button functionality
+// ----------------------------------------------------------------------------
+
+class WXDLLIMPEXP_CORE wxAnyButton : public wxAnyButtonBase
+{
+public:
+ wxAnyButton()
+ {
+ m_imageData = NULL;
+#if wxUSE_MARKUP
+ m_markupText = NULL;
+#endif // wxUSE_MARKUP
+ }
+
+ virtual ~wxAnyButton();
+
+ // overridden base class methods
+ virtual void SetLabel(const wxString& label);
+ virtual bool SetBackgroundColour(const wxColour &colour);
+ virtual bool SetForegroundColour(const wxColour &colour);
+
+ // implementation from now on
+ virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
+
+ virtual bool MSWOnDraw(WXDRAWITEMSTRUCT *item);
+ virtual State GetNormalState() const { return State_Normal; }
+
+ // returns true if the platform should explicitly apply a theme border
+ virtual bool CanApplyThemeBorder() const { return false; }
+
+protected:
+ // usually overridden base class virtuals
+ virtual wxSize DoGetBestSize() const;
+
+ virtual wxBitmap DoGetBitmap(State which) const;
+ virtual void DoSetBitmap(const wxBitmap& bitmap, State which);
+ virtual wxSize DoGetBitmapMargins() const;
+ virtual void DoSetBitmapMargins(wxCoord x, wxCoord y);
+ virtual void DoSetBitmapPosition(wxDirection dir);
+
+#if wxUSE_MARKUP
+ virtual bool DoSetLabelMarkup(const wxString& markup);
+#endif // wxUSE_MARKUP
+
+ // Increases the passed in size to account for the button image.
+ //
+ // Should only be called if we do have a button, i.e. if m_imageData is
+ // non-NULL.
+ void AdjustForBitmapSize(wxSize& size) const;
+
+ class wxButtonImageData *m_imageData;
+
+#if wxUSE_MARKUP
+ class wxMarkupText *m_markupText;
+#endif // wxUSE_MARKUP
+
+ // Switches button into owner-drawn mode: this is used if we need to draw
+ // something not supported by the native control, such as using non default
+ // colours or a bitmap on pre-XP systems.
+ void MakeOwnerDrawn();
+ bool IsOwnerDrawn() const;
+
+private:
+ wxDECLARE_NO_COPY_CLASS(wxAnyButton);
+};
+
+#endif // _WX_MSW_ANYBUTTON_H_
class WXDLLIMPEXP_CORE wxBitmapButton : public wxBitmapButtonBase
{
public:
- wxBitmapButton() { Init(); }
+ wxBitmapButton() {}
wxBitmapButton(wxWindow *parent,
wxWindowID id,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxButtonNameStr)
{
- Init();
-
Create(parent, id, bitmap, pos, size, style, validator, name);
}
const wxString& name = wxButtonNameStr);
protected:
- // common part of all ctors
- void Init()
- {
- m_disabledSetByUser =
- m_hoverSetByUser = false;
- }
-
- // reimplement some base class virtuals
- virtual void DoSetBitmap(const wxBitmap& bitmap, State which);
-
- // true if disabled bitmap was set by user, false if we created it
- // ourselves from the normal one
- bool m_disabledSetByUser;
-
- // true if hover bitmap was set by user, false if it was set from focused
- // one
- bool m_hoverSetByUser;
-
-
DECLARE_EVENT_TABLE()
DECLARE_DYNAMIC_CLASS_NO_COPY(wxBitmapButton)
};
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-#ifndef _WX_BUTTON_H_
-#define _WX_BUTTON_H_
+#ifndef _WX_MSW_BUTTON_H_
+#define _WX_MSW_BUTTON_H_
// ----------------------------------------------------------------------------
// Pushbutton
virtual wxWindow *SetDefault();
- // overridden base class methods
- virtual void SetLabel(const wxString& label);
- virtual bool SetBackgroundColour(const wxColour &colour);
- virtual bool SetForegroundColour(const wxColour &colour);
-
// implementation from now on
virtual void Command(wxCommandEvent& event);
virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
virtual bool MSWCommand(WXUINT param, WXWORD id);
- virtual bool MSWOnDraw(WXDRAWITEMSTRUCT *item);
virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const;
- // returns true if the platform should explicitly apply a theme border
- virtual bool CanApplyThemeBorder() const { return false; }
-
protected:
// send a notification event, return true if processed
bool SendClickEvent();
// set or unset BS_DEFPUSHBUTTON style
static void SetDefaultStyle(wxButton *btn, bool on);
- // usually overridden base class virtuals
- virtual wxSize DoGetBestSize() const;
-
virtual bool DoGetAuthNeeded() const;
virtual void DoSetAuthNeeded(bool show);
- virtual wxBitmap DoGetBitmap(State which) const;
- virtual void DoSetBitmap(const wxBitmap& bitmap, State which);
- virtual wxSize DoGetBitmapMargins() const;
- virtual void DoSetBitmapMargins(wxCoord x, wxCoord y);
- virtual void DoSetBitmapPosition(wxDirection dir);
-
-#if wxUSE_MARKUP
- virtual bool DoSetLabelMarkup(const wxString& markup);
-#endif // wxUSE_MARKUP
-
- // Increases the passed in size to account for the button image.
- //
- // Should only be called if we do have a button, i.e. if m_imageData is
- // non-NULL.
- void AdjustForBitmapSize(wxSize& size) const;
-
- class wxButtonImageData *m_imageData;
-
-#if wxUSE_MARKUP
- class wxMarkupText *m_markupText;
-#endif // wxUSE_MARKUP
// true if the UAC symbol is shown
bool m_authNeeded;
private:
void Init()
{
- m_imageData = NULL;
-#if wxUSE_MARKUP
- m_markupText = NULL;
-#endif // wxUSE_MARKUP
m_authNeeded = false;
}
- // Switches button into owner-drawn mode: this is used if we need to draw
- // something not supported by the native control, such as using non default
- // colours or a bitmap on pre-XP systems.
- void MakeOwnerDrawn();
-
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxButton);
};
-#endif // _WX_BUTTON_H_
+#endif // _WX_MSW_BUTTON_H_
#include "wx/bitmap.h"
-//-----------------------------------------------------------------------------
-// wxBitmapToggleButton
-//-----------------------------------------------------------------------------
-
-
-class WXDLLIMPEXP_CORE wxBitmapToggleButton: public wxToggleButtonBase
+// Checkbox item (single checkbox)
+class WXDLLIMPEXP_CORE wxToggleButton : public wxToggleButtonBase
{
public:
- // construction/destruction
- wxBitmapToggleButton() { Init(); }
- wxBitmapToggleButton(wxWindow *parent,
+ wxToggleButton() { Init(); }
+ wxToggleButton(wxWindow *parent,
wxWindowID id,
- const wxBitmap& label,
+ const wxString& label,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
Create(parent, id, label, pos, size, style, validator, name);
}
- // Create the control
bool Create(wxWindow *parent,
wxWindowID id,
- const wxBitmap& label,
+ const wxString& label,
const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize, long style = 0,
+ const wxSize& size = wxDefaultSize,
+ long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxCheckBoxNameStr);
- // Get/set the value
- void SetValue(bool state);
- bool GetValue() const;
+ virtual void SetValue(bool value);
+ virtual bool GetValue() const ;
+
+ virtual bool MSWCommand(WXUINT param, WXWORD id);
+ virtual void Command(wxCommandEvent& event);
- // Set the label
- virtual void SetLabel(const wxString& label) { wxControl::SetLabel(label); }
- virtual void SetLabel(const wxBitmap& label);
- bool Enable(bool enable = true);
+ virtual State GetNormalState() const;
+
+ // returns true if the platform should explicitly apply a theme border
+ virtual bool CanApplyThemeBorder() const { return false; }
protected:
- void Init();
+ virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
- wxBitmap m_bitmap;
- wxBitmap m_disabledBitmap;
- bool m_capturing;
- bool m_depressed,m_oldValue;
+ virtual WXDWORD MSWGetStyle(long flags, WXDWORD *exstyle = NULL) const;
- void OnPaint(wxPaintEvent &event);
- void OnMouse(wxMouseEvent &event);
- void OnChar(wxKeyEvent &event);
- void OnSize(wxSizeEvent &event);
+ void Init();
- virtual wxSize DoGetBestSize() const;
+ // current state of the button (when owner-drawn)
+ bool m_state;
private:
- DECLARE_EVENT_TABLE()
- DECLARE_DYNAMIC_CLASS(wxBitmapToggleButton)
+ DECLARE_DYNAMIC_CLASS_NO_COPY(wxToggleButton)
};
-// Checkbox item (single checkbox)
-class WXDLLIMPEXP_CORE wxToggleButton : public wxToggleButtonBase
+//-----------------------------------------------------------------------------
+// wxBitmapToggleButton
+//-----------------------------------------------------------------------------
+
+
+class WXDLLIMPEXP_CORE wxBitmapToggleButton: public wxToggleButton
{
public:
- wxToggleButton() {}
- wxToggleButton(wxWindow *parent,
+ // construction/destruction
+ wxBitmapToggleButton() {}
+ wxBitmapToggleButton(wxWindow *parent,
wxWindowID id,
- const wxString& label,
+ const wxBitmap& label,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
Create(parent, id, label, pos, size, style, validator, name);
}
+ // Create the control
bool Create(wxWindow *parent,
wxWindowID id,
- const wxString& label,
+ const wxBitmap& label,
const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- long style = 0,
+ const wxSize& size = wxDefaultSize, long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxCheckBoxNameStr);
- virtual void SetValue(bool value);
- virtual bool GetValue() const ;
-
- virtual void SetLabel(const wxString& label);
-
- virtual bool MSWCommand(WXUINT param, WXWORD id);
- virtual void Command(wxCommandEvent& event);
-
- // returns true if the platform should explicitly apply a theme border
- virtual bool CanApplyThemeBorder() const { return false; }
-
-protected:
- virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
- virtual wxSize DoGetBestSize() const;
-
- virtual WXDWORD MSWGetStyle(long flags, WXDWORD *exstyle = NULL) const;
+ // deprecated synonym for SetBitmapLabel()
+ wxDEPRECATED_INLINE( void SetLabel(const wxBitmap& bitmap),
+ SetBitmapLabel(bitmap); )
+ // prevent virtual function hiding
+ virtual void SetLabel(const wxString& label) { wxToggleButton::SetLabel(label); }
private:
- DECLARE_DYNAMIC_CLASS_NO_COPY(wxToggleButton)
+ DECLARE_DYNAMIC_CLASS(wxBitmapToggleButton)
};
#endif // _WX_TOGGLEBUTTON_H_
--- /dev/null
+/////////////////////////////////////////////////////////////////////////////
+// Name: anybutton.h
+// Purpose: wxAnyButton class
+// Author: Stefan Csomor
+// Created: 1998-01-01 (extracted from button.h)
+// RCS-ID: $Id: anybutton.h 67069 2011-02-27 12:48:46Z VZ $
+// Copyright: (c) Stefan Csomor
+// Licence: wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef _WX_OSX_ANYBUTTON_H_
+#define _WX_OSX_ANYBUTTON_H_
+
+// Any button
+class WXDLLIMPEXP_CORE wxAnyButton : public wxAnyButtonBase
+{
+public:
+ wxAnyButton() {}
+
+ static wxSize GetDefaultSize();
+
+ virtual void SetLabel(const wxString& label);
+
+protected:
+ virtual wxSize DoGetBestSize() const ;
+
+ void OnEnterWindow( wxMouseEvent& event);
+ void OnLeaveWindow( wxMouseEvent& event);
+
+ virtual wxBitmap DoGetBitmap(State which) const;
+ virtual void DoSetBitmap(const wxBitmap& bitmap, State which);
+ virtual void DoSetBitmapPosition(wxDirection dir);
+
+ virtual void DoSetBitmapMargins(int x, int y)
+ {
+ m_marginX = x;
+ m_marginY = y;
+ InvalidateBestSize();
+ }
+
+#if wxUSE_MARKUP && wxOSX_USE_COCOA
+ virtual bool DoSetLabelMarkup(const wxString& markup);
+#endif // wxUSE_MARKUP && wxOSX_USE_COCOA
+
+
+ // the margins around the bitmap
+ int m_marginX;
+ int m_marginY;
+
+ // the bitmaps for the different state of the buttons, all of them may be
+ // invalid and the button only shows a bitmap at all if State_Normal bitmap
+ // is valid
+ wxBitmap m_bitmaps[State_Max];
+
+ wxDECLARE_NO_COPY_CLASS(wxAnyButton);
+ DECLARE_EVENT_TABLE()
+};
+
+#endif // _WX_OSX_ANYBUTTON_H_
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxButtonNameStr);
- static wxSize GetDefaultSize();
-
virtual void SetLabel(const wxString& label);
virtual wxWindow *SetDefault();
virtual void Command(wxCommandEvent& event);
virtual bool OSXHandleClicked( double timestampsec );
protected:
- virtual wxSize DoGetBestSize() const ;
-
- void OnEnterWindow( wxMouseEvent& event);
- void OnLeaveWindow( wxMouseEvent& event);
-
- virtual wxBitmap DoGetBitmap(State which) const;
- virtual void DoSetBitmap(const wxBitmap& bitmap, State which);
- virtual void DoSetBitmapPosition(wxDirection dir);
-
- virtual void DoSetBitmapMargins(int x, int y)
- {
- m_marginX = x;
- m_marginY = y;
- InvalidateBestSize();
- }
-
-#if wxUSE_MARKUP && wxOSX_USE_COCOA
- virtual bool DoSetLabelMarkup(const wxString& markup);
-#endif // wxUSE_MARKUP && wxOSX_USE_COCOA
-
-
- // the margins around the bitmap
- int m_marginX;
- int m_marginY;
-
- // the bitmaps for the different state of the buttons, all of them may be
- // invalid and the button only shows a bitmap at all if State_Normal bitmap
- // is valid
- wxBitmap m_bitmaps[State_Max];
-
DECLARE_DYNAMIC_CLASS(wxButton)
- DECLARE_EVENT_TABLE()
};
// OS X specific class, not part of public wx API
#ifndef _WX_TOGGLEBUTTON_H_
#define _WX_TOGGLEBUTTON_H_
-class WXDLLIMPEXP_CORE wxBitmapToggleButton : public wxToggleButtonBase
+class WXDLLIMPEXP_CORE wxToggleButton : public wxToggleButtonBase
{
public:
- wxBitmapToggleButton() {}
- wxBitmapToggleButton(wxWindow *parent,
+ wxToggleButton() {}
+ wxToggleButton(wxWindow *parent,
wxWindowID id,
- const wxBitmap& label,
+ const wxString& label,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
bool Create(wxWindow *parent,
wxWindowID id,
- const wxBitmap& label,
+ const wxString& label,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
virtual void Command(wxCommandEvent& event);
-private:
- wxBitmap m_bitmap;
-
- int m_marginX,
- m_marginY;
-
protected:
virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
virtual wxSize DoGetBestSize() const;
private:
- DECLARE_DYNAMIC_CLASS_NO_COPY(wxBitmapToggleButton)
+ DECLARE_DYNAMIC_CLASS_NO_COPY(wxToggleButton)
};
-class WXDLLIMPEXP_CORE wxToggleButton : public wxToggleButtonBase
+class WXDLLIMPEXP_CORE wxBitmapToggleButton : public wxToggleButton
{
public:
- wxToggleButton() {}
- wxToggleButton(wxWindow *parent,
+ wxBitmapToggleButton() {}
+ wxBitmapToggleButton(wxWindow *parent,
wxWindowID id,
- const wxString& label,
+ const wxBitmap& label,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
bool Create(wxWindow *parent,
wxWindowID id,
- const wxString& label,
+ const wxBitmap& label,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxCheckBoxNameStr);
- virtual void SetValue(bool value);
- virtual bool GetValue() const ;
-
- virtual bool OSXHandleClicked( double timestampsec );
-
- virtual void Command(wxCommandEvent& event);
-
protected:
- virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
virtual wxSize DoGetBestSize() const;
private:
- DECLARE_DYNAMIC_CLASS_NO_COPY(wxToggleButton)
+ DECLARE_DYNAMIC_CLASS_NO_COPY(wxBitmapToggleButton)
};
#endif // _WX_TOGGLEBUTTON_H_
#include "wx/setup_gccxml.h"
#endif
+/*
+ Convenience for any optional classes that use the wxAnyButton base class.
+ */
+#if wxUSE_TOGGLEBTN || wxUSE_BUTTON
+ #define wxHAS_ANY_BUTTON
+#endif
+
/*
Hardware platform detection.
#if wxUSE_TOGGLEBTN
#include "wx/event.h"
-#include "wx/control.h" // base class
+#include "wx/anybutton.h" // base class
extern WXDLLIMPEXP_DATA_CORE(const char) wxCheckBoxNameStr[];
// wxToggleButtonBase
// ----------------------------------------------------------------------------
-class WXDLLIMPEXP_CORE wxToggleButtonBase : public wxControl
+class WXDLLIMPEXP_CORE wxToggleButtonBase : public wxAnyButton
{
public:
wxToggleButtonBase() { }
#if wxUSE_MARKUP
*m_chkUseMarkup,
#endif // wxUSE_MARKUP
- *m_chkDefault;
+ *m_chkDefault,
+ *m_chkUseBitmapClass;
// more checkboxes for wxBitmapButton only
wxCheckBox *m_chkUsePressed,
m_chkUseMarkup =
#endif // wxUSE_MARKUP
m_chkDefault =
+ m_chkUseBitmapClass =
m_chkUsePressed =
m_chkUseFocused =
m_chkUseCurrent =
#endif // wxUSE_MARKUP
m_chkDefault = CreateCheckBoxAndAddToSizer(sizerLeft, wxT("&Default"));
+ m_chkUseBitmapClass = CreateCheckBoxAndAddToSizer(sizerLeft,
+ "Use wxBitmapButton");
+ m_chkUseBitmapClass->SetValue(true);
+
sizerLeft->AddSpacer(5);
wxSizer *sizerUseLabels =
#if wxUSE_MARKUP
m_chkUseMarkup->SetValue(false);
#endif // wxUSE_MARKUP
+ m_chkUseBitmapClass->SetValue(true);
m_chkUsePressed->SetValue(true);
m_chkUseFocused->SetValue(true);
{
showsBitmap = true;
- wxBitmapButton *bbtn = new wxBitmapButton(this, ButtonPage_Button,
- CreateBitmap(wxT("normal")));
+ wxButton *bbtn;
+ if ( m_chkUseBitmapClass->GetValue() )
+ {
+ bbtn = new wxBitmapButton(this, ButtonPage_Button,
+ CreateBitmap(wxT("normal")));
+ }
+ else
+ {
+ bbtn = new wxButton(this, ButtonPage_Button);
+ bbtn->SetBitmapLabel(CreateBitmap(wxT("normal")));
+ }
if ( m_chkUsePressed->GetValue() )
bbtn->SetBitmapPressed(CreateBitmap(wxT("pushed")));
if ( m_chkUseFocused->GetValue() )
m_button->SetBitmapDisabled(wxArtProvider::GetIcon(wxART_MISSING_IMAGE, wxART_BUTTON));
}
+ m_chkUseBitmapClass->Enable(showsBitmap);
+
m_chkUsePressed->Enable(showsBitmap);
m_chkUseFocused->Enable(showsBitmap);
m_chkUseCurrent->Enable(showsBitmap);
// for all others, include the necessary headers
#ifndef WX_PRECOMP
- #include "wx/sizer.h"
+ #include "wx/button.h"
+ #include "wx/checkbox.h"
+ #include "wx/radiobox.h"
#include "wx/statbox.h"
#include "wx/textctrl.h"
#endif
+#include "wx/artprov.h"
+#include "wx/sizer.h"
+#include "wx/dcmemory.h"
+
#include "icons/toggle.xpm"
// ----------------------------------------------------------------------------
TogglePage_Picker
};
+// radio boxes
+enum
+{
+ ToggleImagePos_Left,
+ ToggleImagePos_Right,
+ ToggleImagePos_Top,
+ ToggleImagePos_Bottom
+};
+
+enum
+{
+ ToggleHAlign_Left,
+ ToggleHAlign_Centre,
+ ToggleHAlign_Right
+};
+
+enum
+{
+ ToggleVAlign_Top,
+ ToggleVAlign_Centre,
+ ToggleVAlign_Bottom
+};
+
// ----------------------------------------------------------------------------
// CheckBoxWidgetsPage
// ----------------------------------------------------------------------------
virtual void CreateContent();
protected:
+ // event handlers
+ void OnCheckOrRadioBox(wxCommandEvent& event);
+
// event handlers
void OnButtonReset(wxCommandEvent& event);
void OnButtonChangeLabel(wxCommandEvent& event);
// (re)create the toggle
void CreateToggle();
+ // helper function: create a bitmap for wxBitmapToggleButton
+ wxBitmap CreateBitmap(const wxString& label);
+
// the controls
// ------------
+#if wxUSE_MARKUP
+ wxCheckBox *m_chkUseMarkup;
+#endif // wxUSE_MARKUP
+#ifdef wxHAS_BITMAPTOGGLEBUTTON
+ // the check/radio boxes for styles
+ wxCheckBox *m_chkBitmapOnly,
+ *m_chkTextAndBitmap,
+ *m_chkFit,
+ *m_chkUseBitmapClass;
+
+ // more checkboxes for wxBitmapToggleButton only
+ wxCheckBox *m_chkUsePressed,
+ *m_chkUseFocused,
+ *m_chkUseCurrent,
+ *m_chkUseDisabled;
+
+ // and an image position choice used if m_chkTextAndBitmap is on
+ wxRadioBox *m_radioImagePos;
+
+ wxRadioBox *m_radioHAlign,
+ *m_radioVAlign;
+#endif // wxHAS_BITMAPTOGGLEBUTTON
+
// the checkbox itself and the sizer it is in
+#ifdef wxHAS_ANY_BUTTON
wxToggleButton *m_toggle;
+#else
+ wxToggleButtonBase *m_toggle;
+#endif // wxHAS_ANY_BUTTON
wxSizer *m_sizerToggle;
// the text entries for command parameters
BEGIN_EVENT_TABLE(ToggleWidgetsPage, WidgetsPage)
EVT_BUTTON(TogglePage_Reset, ToggleWidgetsPage::OnButtonReset)
EVT_BUTTON(TogglePage_ChangeLabel, ToggleWidgetsPage::OnButtonChangeLabel)
+
+ EVT_CHECKBOX(wxID_ANY, ToggleWidgetsPage::OnCheckOrRadioBox)
+ EVT_RADIOBOX(wxID_ANY, ToggleWidgetsPage::OnCheckOrRadioBox)
END_EVENT_TABLE()
// ============================================================================
wxImageList *imaglist)
:WidgetsPage(book, imaglist, toggle_xpm)
{
+#if wxUSE_MARKUP
+ m_chkUseMarkup = (wxCheckBox *)NULL;
+#endif // wxUSE_MARKUP
+#ifdef wxHAS_BITMAPTOGGLEBUTTON
+ // init everything
+ m_chkBitmapOnly =
+ m_chkTextAndBitmap =
+ m_chkFit =
+ m_chkUseBitmapClass =
+ m_chkUsePressed =
+ m_chkUseFocused =
+ m_chkUseCurrent =
+ m_chkUseDisabled = (wxCheckBox *)NULL;
+
+ m_radioImagePos =
+ m_radioHAlign =
+ m_radioVAlign = (wxRadioBox *)NULL;
+#endif // wxHAS_BITMAPTOGGLEBUTTON
+
+ m_textLabel = (wxTextCtrl *)NULL;
+
+ m_toggle = (wxToggleButton *)NULL;
+ m_sizerToggle = (wxSizer *)NULL;
}
void ToggleWidgetsPage::CreateContent()
wxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL);
// left pane
-// wxStaticBox *box = new wxStaticBox(this, wxID_ANY, wxT("Styles"));
+ wxStaticBox *box = new wxStaticBox(this, wxID_ANY, wxT("Styles"));
+
+ wxSizer *sizerLeft = new wxStaticBoxSizer(box, wxVERTICAL);
+
+#ifdef wxHAS_BITMAPTOGGLEBUTTON
+ m_chkBitmapOnly = CreateCheckBoxAndAddToSizer(sizerLeft, "&Bitmap only");
+ m_chkTextAndBitmap = CreateCheckBoxAndAddToSizer(sizerLeft, "Text &and bitmap");
+ m_chkFit = CreateCheckBoxAndAddToSizer(sizerLeft, wxT("&Fit exactly"));
+#endif // wxHAS_BITMAPTOGGLEBUTTON
+#if wxUSE_MARKUP
+ m_chkUseMarkup = CreateCheckBoxAndAddToSizer(sizerLeft, "Interpret &markup");
+#endif // wxUSE_MARKUP
+
+#ifdef wxHAS_BITMAPTOGGLEBUTTON
+ m_chkUseBitmapClass = CreateCheckBoxAndAddToSizer(sizerLeft,
+ "Use wxBitmapToggleButton");
+ m_chkUseBitmapClass->SetValue(true);
+
+ sizerLeft->AddSpacer(5);
+
+ wxSizer *sizerUseLabels =
+ new wxStaticBoxSizer(wxVERTICAL, this,
+ "&Use the following bitmaps in addition to the normal one?");
+ m_chkUsePressed = CreateCheckBoxAndAddToSizer(sizerUseLabels,
+ "&Pressed (small help icon)");
+ m_chkUseFocused = CreateCheckBoxAndAddToSizer(sizerUseLabels,
+ "&Focused (small error icon)");
+ m_chkUseCurrent = CreateCheckBoxAndAddToSizer(sizerUseLabels,
+ "&Current (small warning icon)");
+ m_chkUseDisabled = CreateCheckBoxAndAddToSizer(sizerUseLabels,
+ "&Disabled (broken image icon)");
+ sizerLeft->Add(sizerUseLabels, wxSizerFlags().Expand().Border());
+
+ sizerLeft->AddSpacer(10);
+
+ static const wxString dirs[] =
+ {
+ "left", "right", "top", "bottom",
+ };
+ m_radioImagePos = new wxRadioBox(this, wxID_ANY, "Image &position",
+ wxDefaultPosition, wxDefaultSize,
+ WXSIZEOF(dirs), dirs);
+ sizerLeft->Add(m_radioImagePos, 0, wxGROW | wxALL, 5);
+ sizerLeft->AddSpacer(15);
+
+ // should be in sync with enums Toggle[HV]Align!
+ static const wxString halign[] =
+ {
+ wxT("left"),
+ wxT("centre"),
+ wxT("right"),
+ };
+
+ static const wxString valign[] =
+ {
+ wxT("top"),
+ wxT("centre"),
+ wxT("bottom"),
+ };
+
+ m_radioHAlign = new wxRadioBox(this, wxID_ANY, wxT("&Horz alignment"),
+ wxDefaultPosition, wxDefaultSize,
+ WXSIZEOF(halign), halign);
+ m_radioVAlign = new wxRadioBox(this, wxID_ANY, wxT("&Vert alignment"),
+ wxDefaultPosition, wxDefaultSize,
+ WXSIZEOF(valign), valign);
-// wxSizer *sizerLeft = new wxStaticBoxSizer(box, wxVERTICAL);
+ sizerLeft->Add(m_radioHAlign, 0, wxGROW | wxALL, 5);
+ sizerLeft->Add(m_radioVAlign, 0, wxGROW | wxALL, 5);
+#endif // wxHAS_BITMAPTOGGLEBUTTON
+
+ sizerLeft->Add(5, 5, 0, wxGROW | wxALL, 5); // spacer
+
+ wxButton *btn = new wxButton(this, TogglePage_Reset, wxT("&Reset"));
+ sizerLeft->Add(btn, 0, wxALIGN_CENTRE_HORIZONTAL | wxALL, 15);
// middle pane
wxStaticBox *box2 = new wxStaticBox(this, wxID_ANY, wxT("&Operations"));
sizerMiddle->Add(sizerRow, 0, wxALL | wxGROW, 5);
// right pane
- wxSizer *sizerRight = new wxBoxSizer(wxHORIZONTAL);
-
- m_toggle = new wxToggleButton(this, TogglePage_Picker, wxT("Toggle Button"));
-
- sizerRight->Add(0, 0, 1, wxCENTRE);
- sizerRight->Add(m_toggle, 1, wxCENTRE);
- sizerRight->Add(0, 0, 1, wxCENTRE);
- sizerRight->SetMinSize(150, 0);
- m_sizerToggle = sizerRight; // save it to modify it later
+ m_sizerToggle = new wxBoxSizer(wxHORIZONTAL);
+ m_sizerToggle->SetMinSize(150, 0);
// the 3 panes panes compose the window
-// sizerTop->Add(sizerLeft, 0, (wxALL & ~wxLEFT), 10);
+ sizerTop->Add(sizerLeft, 0, (wxALL & ~wxLEFT), 10);
sizerTop->Add(sizerMiddle, 1, wxGROW | wxALL, 10);
- sizerTop->Add(sizerRight, 1, wxGROW | (wxALL & ~wxRIGHT), 10);
+ sizerTop->Add(m_sizerToggle, 1, wxGROW | (wxALL & ~wxRIGHT), 10);
- // final initializations
+ // do create the main control
Reset();
+ CreateToggle();
SetSizer(sizerTop);
}
void ToggleWidgetsPage::Reset()
{
- m_toggle->SetValue(false);
+#ifdef wxHAS_BITMAPTOGGLEBUTTON
+ m_chkBitmapOnly->SetValue(false);
+ m_chkFit->SetValue(true);
+ m_chkTextAndBitmap->SetValue(false);
+#if wxUSE_MARKUP
+ m_chkUseMarkup->SetValue(false);
+#endif // wxUSE_MARKUP
+ m_chkUseBitmapClass->SetValue(true);
+
+ m_chkUsePressed->SetValue(true);
+ m_chkUseFocused->SetValue(true);
+ m_chkUseCurrent->SetValue(true);
+ m_chkUseDisabled->SetValue(true);
+
+ m_radioImagePos->SetSelection(ToggleImagePos_Left);
+ m_radioHAlign->SetSelection(ToggleHAlign_Centre);
+ m_radioVAlign->SetSelection(ToggleVAlign_Centre);
+#endif // wxHAS_BITMAPTOGGLEBUTTON
+
+ if ( m_toggle )
+ {
+ m_toggle->SetValue(false);
+ }
}
void ToggleWidgetsPage::CreateToggle()
{
- const bool value = m_toggle->GetValue();
+ wxString label;
+ bool value = false;
- size_t count = m_sizerToggle->GetChildren().GetCount();
- for ( size_t n = 0; n < count; n++ )
+ if ( m_toggle )
{
- m_sizerToggle->Remove(0);
+ label = m_toggle->GetLabel();
+ value = m_toggle->GetValue();
+ size_t count = m_sizerToggle->GetChildren().GetCount();
+ for ( size_t n = 0; n < count; n++ )
+ {
+ m_sizerToggle->Remove(0);
+ }
+
+ delete m_toggle;
}
- delete m_toggle;
+ if ( label.empty() )
+ {
+ // creating for the first time or recreating a toggle button after bitmap
+ // button
+ label = m_textLabel->GetValue();
+ }
+
+ int flags = ms_defaultFlags;
+#ifdef wxHAS_BITMAPTOGGLEBUTTON
+ switch ( m_radioHAlign->GetSelection() )
+ {
+ case ToggleHAlign_Left:
+ flags |= wxBU_LEFT;
+ break;
+
+ default:
+ wxFAIL_MSG(wxT("unexpected radiobox selection"));
+ // fall through
+
+ case ToggleHAlign_Centre:
+ break;
+
+ case ToggleHAlign_Right:
+ flags |= wxBU_RIGHT;
+ break;
+ }
+
+ switch ( m_radioVAlign->GetSelection() )
+ {
+ case ToggleVAlign_Top:
+ flags |= wxBU_TOP;
+ break;
+
+ default:
+ wxFAIL_MSG(wxT("unexpected radiobox selection"));
+ // fall through
- m_toggle = new wxToggleButton(this, TogglePage_Picker, wxT("Toggle Button"));
+ case ToggleVAlign_Centre:
+ // centre vertical alignment is the default (no style)
+ break;
+
+ case ToggleVAlign_Bottom:
+ flags |= wxBU_BOTTOM;
+ break;
+ }
+#endif // wxHAS_BITMAPTOGGLEBUTTON
+#ifdef wxHAS_BITMAPTOGGLEBUTTON
+ bool showsBitmap = false;
+ if ( m_chkBitmapOnly->GetValue() )
+ {
+ showsBitmap = true;
+
+ wxToggleButton *btgl;
+ if ( m_chkUseBitmapClass->GetValue() )
+ {
+ btgl = new wxBitmapToggleButton(this, TogglePage_Picker,
+ CreateBitmap(wxT("normal")));
+ }
+ else
+ {
+ btgl = new wxToggleButton(this, TogglePage_Picker, wxT(""));
+ btgl->SetBitmapLabel(CreateBitmap(wxT("normal")));
+ }
+#ifdef wxHAS_ANY_BUTTON
+ if ( m_chkUsePressed->GetValue() )
+ btgl->SetBitmapPressed(CreateBitmap(wxT("pushed")));
+ if ( m_chkUseFocused->GetValue() )
+ btgl->SetBitmapFocus(CreateBitmap(wxT("focused")));
+ if ( m_chkUseCurrent->GetValue() )
+ btgl->SetBitmapCurrent(CreateBitmap(wxT("hover")));
+ if ( m_chkUseDisabled->GetValue() )
+ btgl->SetBitmapDisabled(CreateBitmap(wxT("disabled")));
+#endif // wxHAS_ANY_BUTTON
+ m_toggle = btgl;
+ }
+ else // normal button
+#endif // wxHAS_BITMAPTOGGLEBUTTON
+ {
+ m_toggle = new wxToggleButton(this, TogglePage_Picker, label,
+ wxDefaultPosition, wxDefaultSize,
+ flags);
+ }
m_toggle->SetValue(value);
+#ifdef wxHAS_BITMAPTOGGLEBUTTON
+#ifdef wxHAS_ANY_BUTTON
+ if ( !showsBitmap && m_chkTextAndBitmap->GetValue() )
+ {
+ showsBitmap = true;
+
+ static const wxDirection positions[] =
+ {
+ wxLEFT, wxRIGHT, wxTOP, wxBOTTOM
+ };
+
+ m_toggle->SetBitmap(wxArtProvider::GetIcon(wxART_INFORMATION, wxART_BUTTON),
+ positions[m_radioImagePos->GetSelection()]);
+
+ if ( m_chkUsePressed->GetValue() )
+ m_toggle->SetBitmapPressed(wxArtProvider::GetIcon(wxART_HELP, wxART_BUTTON));
+ if ( m_chkUseFocused->GetValue() )
+ m_toggle->SetBitmapFocus(wxArtProvider::GetIcon(wxART_ERROR, wxART_BUTTON));
+ if ( m_chkUseCurrent->GetValue() )
+ m_toggle->SetBitmapCurrent(wxArtProvider::GetIcon(wxART_WARNING, wxART_BUTTON));
+ if ( m_chkUseDisabled->GetValue() )
+ m_toggle->SetBitmapDisabled(wxArtProvider::GetIcon(wxART_MISSING_IMAGE, wxART_BUTTON));
+ }
+#endif // wxHAS_ANY_BUTTON
+
+ m_chkUseBitmapClass->Enable(showsBitmap);
+
+ m_chkUsePressed->Enable(showsBitmap);
+ m_chkUseFocused->Enable(showsBitmap);
+ m_chkUseCurrent->Enable(showsBitmap);
+ m_chkUseDisabled->Enable(showsBitmap);
+#endif // wxHAS_BITMAPTOGGLEBUTTON
+
m_sizerToggle->Add(0, 0, 1, wxCENTRE);
m_sizerToggle->Add(m_toggle, 1, wxCENTRE);
m_sizerToggle->Add(0, 0, 1, wxCENTRE);
CreateToggle();
}
+void ToggleWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& WXUNUSED(event))
+{
+ CreateToggle();
+}
+
void ToggleWidgetsPage::OnButtonChangeLabel(wxCommandEvent& WXUNUSED(event))
{
- m_toggle->SetLabel(m_textLabel->GetValue());
+ const wxString labelText = m_textLabel->GetValue();
+
+#if wxUSE_MARKUP
+ if ( m_chkUseMarkup->GetValue() )
+ m_toggle->SetLabelMarkup(labelText);
+ else
+#endif // wxUSE_MARKUP
+ m_toggle->SetLabel(labelText);
+}
+
+#ifdef wxHAS_BITMAPTOGGLEBUTTON
+// ----------------------------------------------------------------------------
+// bitmap toggle button stuff
+// ----------------------------------------------------------------------------
+
+wxBitmap ToggleWidgetsPage::CreateBitmap(const wxString& label)
+{
+ wxBitmap bmp(180, 70); // shouldn't hardcode but it's simpler like this
+ wxMemoryDC dc;
+ dc.SelectObject(bmp);
+ dc.SetBackground(wxBrush(*wxCYAN));
+ dc.Clear();
+ dc.SetTextForeground(*wxBLACK);
+ dc.DrawLabel(wxStripMenuCodes(m_textLabel->GetValue()) + wxT("\n")
+ wxT("(") + label + wxT(" state)"),
+ wxArtProvider::GetBitmap(wxART_INFORMATION),
+ wxRect(10, 10, bmp.GetWidth() - 20, bmp.GetHeight() - 20),
+ wxALIGN_CENTRE);
+
+ return bmp;
}
+#endif // wxHAS_BITMAPTOGGLEBUTTON
#endif // wxUSE_TOGGLEBTN
return tlw->SetDefaultItem(this);
}
-void wxButtonBase::SetBitmapPosition(wxDirection dir)
+void wxAnyButtonBase::SetBitmapPosition(wxDirection dir)
{
wxASSERT_MSG( !(dir & ~wxDIRECTION_MASK), "non-direction flag used" );
wxASSERT_MSG( !!(dir & wxLEFT) +
--- /dev/null
+/////////////////////////////////////////////////////////////////////////////
+// Name: src/gtk/anybutton.cpp
+// Purpose:
+// Author: Robert Roebling
+// Created: 1998-05-20 (extracted from button.cpp)
+// Id: $Id: anybutton.cpp 67326 2011-03-28 06:27:49Z PC $
+// Copyright: (c) 1998 Robert Roebling
+// Licence: wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef wxHAS_ANY_BUTTON
+
+#ifndef WX_PRECOMP
+ #include "wx/anybutton.h"
+#endif
+
+#include "wx/stockitem.h"
+
+#include "wx/gtk/private.h"
+
+// ----------------------------------------------------------------------------
+// GTK callbacks
+// ----------------------------------------------------------------------------
+
+extern "C"
+{
+
+static void
+wxgtk_button_enter_callback(GtkWidget *WXUNUSED(widget), wxAnyButton *button)
+{
+ if ( button->GTKShouldIgnoreEvent() )
+ return;
+
+ button->GTKMouseEnters();
+}
+
+static void
+wxgtk_button_leave_callback(GtkWidget *WXUNUSED(widget), wxAnyButton *button)
+{
+ if ( button->GTKShouldIgnoreEvent() )
+ return;
+
+ button->GTKMouseLeaves();
+}
+
+static void
+wxgtk_button_press_callback(GtkWidget *WXUNUSED(widget), wxAnyButton *button)
+{
+ if ( button->GTKShouldIgnoreEvent() )
+ return;
+
+ button->GTKPressed();
+}
+
+static void
+wxgtk_button_released_callback(GtkWidget *WXUNUSED(widget), wxAnyButton *button)
+{
+ if ( button->GTKShouldIgnoreEvent() )
+ return;
+
+ button->GTKReleased();
+}
+
+} // extern "C"
+
+//-----------------------------------------------------------------------------
+// wxAnyButton
+//-----------------------------------------------------------------------------
+
+bool wxAnyButton::Enable( bool enable )
+{
+ if (!base_type::Enable(enable))
+ return false;
+
+ gtk_widget_set_sensitive(gtk_bin_get_child(GTK_BIN(m_widget)), enable);
+
+ if (enable)
+ GTKFixSensitivity();
+
+ GTKUpdateBitmap();
+
+ return true;
+}
+
+GdkWindow *wxAnyButton::GTKGetWindow(wxArrayGdkWindows& WXUNUSED(windows)) const
+{
+ return GTK_BUTTON(m_widget)->event_window;
+}
+
+// static
+wxVisualAttributes
+wxAnyButton::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
+{
+ return GetDefaultAttributesFromGTKWidget(gtk_button_new);
+}
+
+// ----------------------------------------------------------------------------
+// bitmaps support
+// ----------------------------------------------------------------------------
+
+void wxAnyButton::GTKMouseEnters()
+{
+ m_isCurrent = true;
+
+ GTKUpdateBitmap();
+}
+
+void wxAnyButton::GTKMouseLeaves()
+{
+ m_isCurrent = false;
+
+ GTKUpdateBitmap();
+}
+
+void wxAnyButton::GTKPressed()
+{
+ m_isPressed = true;
+
+ GTKUpdateBitmap();
+}
+
+void wxAnyButton::GTKReleased()
+{
+ m_isPressed = false;
+
+ GTKUpdateBitmap();
+}
+
+void wxAnyButton::GTKOnFocus(wxFocusEvent& event)
+{
+ event.Skip();
+
+ GTKUpdateBitmap();
+}
+
+wxAnyButton::State wxAnyButton::GTKGetCurrentState() const
+{
+ if ( !IsThisEnabled() )
+ return m_bitmaps[State_Disabled].IsOk() ? State_Disabled : State_Normal;
+
+ if ( m_isPressed && m_bitmaps[State_Pressed].IsOk() )
+ return State_Pressed;
+
+ if ( m_isCurrent && m_bitmaps[State_Current].IsOk() )
+ return State_Current;
+
+ if ( HasFocus() && m_bitmaps[State_Focused].IsOk() )
+ return State_Focused;
+
+ return State_Normal;
+}
+
+void wxAnyButton::GTKUpdateBitmap()
+{
+ // if we don't show bitmaps at all, there is nothing to update
+ if ( m_bitmaps[State_Normal].IsOk() )
+ {
+ // if we do show them, this will return a state for which we do have a
+ // valid bitmap
+ State state = GTKGetCurrentState();
+
+ GTKDoShowBitmap(m_bitmaps[state]);
+ }
+}
+
+void wxAnyButton::GTKDoShowBitmap(const wxBitmap& bitmap)
+{
+ wxASSERT_MSG( bitmap.IsOk(), "invalid bitmap" );
+
+ GtkWidget *image;
+ if ( DontShowLabel() )
+ {
+ image = gtk_bin_get_child(GTK_BIN(m_widget));
+ }
+ else // have both label and bitmap
+ {
+#ifdef __WXGTK26__
+ if ( !gtk_check_version(2,6,0) )
+ {
+ image = gtk_button_get_image(GTK_BUTTON(m_widget));
+ }
+ else
+#endif // __WXGTK26__
+ {
+ // buttons with both label and bitmap are only supported with GTK+
+ // 2.6 so far
+ //
+ // it shouldn't be difficult to implement them ourselves for the
+ // previous GTK+ versions by stuffing a container with a label and
+ // an image inside GtkButton but there doesn't seem to be much
+ // point in doing this for ancient GTK+ versions
+ return;
+ }
+ }
+
+ wxCHECK_RET( image && GTK_IS_IMAGE(image), "must have image widget" );
+
+ gtk_image_set_from_pixbuf(GTK_IMAGE(image), bitmap.GetPixbuf());
+}
+
+wxBitmap wxAnyButton::DoGetBitmap(State which) const
+{
+ return m_bitmaps[which];
+}
+
+void wxAnyButton::DoSetBitmap(const wxBitmap& bitmap, State which)
+{
+ switch ( which )
+ {
+ case State_Normal:
+ if ( DontShowLabel() )
+ {
+ // we only have the bitmap in this button, never remove it but
+ // do invalidate the best size when the bitmap (and presumably
+ // its size) changes
+ InvalidateBestSize();
+ }
+#ifdef __WXGTK26__
+ // normal image is special: setting it enables images for the button and
+ // resetting it to nothing disables all of them
+ else if ( !gtk_check_version(2,6,0) )
+ {
+ GtkWidget *image = gtk_button_get_image(GTK_BUTTON(m_widget));
+ if ( image && !bitmap.IsOk() )
+ {
+ gtk_container_remove(GTK_CONTAINER(m_widget), image);
+ }
+ else if ( !image && bitmap.IsOk() )
+ {
+ image = gtk_image_new();
+ gtk_button_set_image(GTK_BUTTON(m_widget), image);
+ }
+ else // image presence or absence didn't change
+ {
+ // don't invalidate best size below
+ break;
+ }
+
+ InvalidateBestSize();
+ }
+#endif // GTK+ 2.6+
+ break;
+
+ case State_Pressed:
+ if ( bitmap.IsOk() )
+ {
+ if ( !m_bitmaps[which].IsOk() )
+ {
+ // we need to install the callbacks to be notified about
+ // the button pressed state change
+ g_signal_connect
+ (
+ m_widget,
+ "pressed",
+ G_CALLBACK(wxgtk_button_press_callback),
+ this
+ );
+
+ g_signal_connect
+ (
+ m_widget,
+ "released",
+ G_CALLBACK(wxgtk_button_released_callback),
+ this
+ );
+ }
+ }
+ else // no valid bitmap
+ {
+ if ( m_bitmaps[which].IsOk() )
+ {
+ // we don't need to be notified about the button pressed
+ // state changes any more
+ g_signal_handlers_disconnect_by_func
+ (
+ m_widget,
+ (gpointer)wxgtk_button_press_callback,
+ this
+ );
+
+ g_signal_handlers_disconnect_by_func
+ (
+ m_widget,
+ (gpointer)wxgtk_button_released_callback,
+ this
+ );
+
+ // also make sure we don't remain stuck in pressed state
+ if ( m_isPressed )
+ {
+ m_isPressed = false;
+ GTKUpdateBitmap();
+ }
+ }
+ }
+ break;
+
+ case State_Current:
+ // the logic here is the same as above for State_Pressed: we need
+ // to connect the handlers if we must be notified about the changes
+ // in the button current state and we disconnect them when/if we
+ // don't need them any more
+ if ( bitmap.IsOk() )
+ {
+ if ( !m_bitmaps[which].IsOk() )
+ {
+ g_signal_connect
+ (
+ m_widget,
+ "enter",
+ G_CALLBACK(wxgtk_button_enter_callback),
+ this
+ );
+
+ g_signal_connect
+ (
+ m_widget,
+ "leave",
+ G_CALLBACK(wxgtk_button_leave_callback),
+ this
+ );
+ }
+ }
+ else // no valid bitmap
+ {
+ if ( m_bitmaps[which].IsOk() )
+ {
+ g_signal_handlers_disconnect_by_func
+ (
+ m_widget,
+ (gpointer)wxgtk_button_enter_callback,
+ this
+ );
+
+ g_signal_handlers_disconnect_by_func
+ (
+ m_widget,
+ (gpointer)wxgtk_button_leave_callback,
+ this
+ );
+
+ if ( m_isCurrent )
+ {
+ m_isCurrent = false;
+ GTKUpdateBitmap();
+ }
+ }
+ }
+ break;
+
+ case State_Focused:
+ if ( bitmap.IsOk() )
+ {
+ Connect(wxEVT_SET_FOCUS,
+ wxFocusEventHandler(wxAnyButton::GTKOnFocus));
+ Connect(wxEVT_KILL_FOCUS,
+ wxFocusEventHandler(wxAnyButton::GTKOnFocus));
+ }
+ else // no valid focused bitmap
+ {
+ Disconnect(wxEVT_SET_FOCUS,
+ wxFocusEventHandler(wxAnyButton::GTKOnFocus));
+ Disconnect(wxEVT_KILL_FOCUS,
+ wxFocusEventHandler(wxAnyButton::GTKOnFocus));
+ }
+ break;
+
+ default:
+ // no callbacks to connect/disconnect
+ ;
+ }
+
+ m_bitmaps[which] = bitmap;
+
+ // update the bitmap immediately if necessary, otherwise it will be done
+ // when the bitmap for the corresponding state is needed the next time by
+ // GTKUpdateBitmap()
+ if ( bitmap.IsOk() && which == GTKGetCurrentState() )
+ {
+ GTKDoShowBitmap(bitmap);
+ }
+}
+
+void wxAnyButton::DoSetBitmapPosition(wxDirection dir)
+{
+#ifdef __WXGTK210__
+ if ( !gtk_check_version(2,10,0) )
+ {
+ GtkPositionType gtkpos;
+ switch ( dir )
+ {
+ default:
+ wxFAIL_MSG( "invalid position" );
+ // fall through
+
+ case wxLEFT:
+ gtkpos = GTK_POS_LEFT;
+ break;
+
+ case wxRIGHT:
+ gtkpos = GTK_POS_RIGHT;
+ break;
+
+ case wxTOP:
+ gtkpos = GTK_POS_TOP;
+ break;
+
+ case wxBOTTOM:
+ gtkpos = GTK_POS_BOTTOM;
+ break;
+ }
+
+ gtk_button_set_image_position(GTK_BUTTON(m_widget), gtkpos);
+ InvalidateBestSize();
+ }
+#endif // GTK+ 2.10+
+}
+
+#endif // wxHAS_ANY_BUTTON
button->HandleWindowEvent(event);
}
-static void
-wxgtk_button_enter_callback(GtkWidget *WXUNUSED(widget), wxButton *button)
-{
- if ( button->GTKShouldIgnoreEvent() )
- return;
-
- button->GTKMouseEnters();
-}
-
-static void
-wxgtk_button_leave_callback(GtkWidget *WXUNUSED(widget), wxButton *button)
-{
- if ( button->GTKShouldIgnoreEvent() )
- return;
-
- button->GTKMouseLeaves();
-}
-
-static void
-wxgtk_button_press_callback(GtkWidget *WXUNUSED(widget), wxButton *button)
-{
- if ( button->GTKShouldIgnoreEvent() )
- return;
-
- button->GTKPressed();
-}
-
-static void
-wxgtk_button_released_callback(GtkWidget *WXUNUSED(widget), wxButton *button)
-{
- if ( button->GTKShouldIgnoreEvent() )
- return;
-
- button->GTKReleased();
-}
-
//-----------------------------------------------------------------------------
// "style_set" from m_widget
//-----------------------------------------------------------------------------
if (label.empty() && wxIsStockID(m_windowId))
label = wxGetStockLabel(m_windowId);
- wxControl::SetLabel(label);
+ wxAnyButton::SetLabel(label);
// don't use label if it was explicitly disabled
if ( HasFlag(wxBU_NOTEXT) )
}
#endif // wxUSE_MARKUP
-bool wxButton::Enable( bool enable )
-{
- if (!base_type::Enable(enable))
- return false;
-
- gtk_widget_set_sensitive(gtk_bin_get_child(GTK_BIN(m_widget)), enable);
-
- if (enable)
- GTKFixSensitivity();
-
- GTKUpdateBitmap();
-
- return true;
-}
-
-GdkWindow *wxButton::GTKGetWindow(wxArrayGdkWindows& WXUNUSED(windows)) const
-{
- return GTK_BUTTON(m_widget)->event_window;
-}
-
GtkLabel *wxButton::GTKGetLabel() const
{
GtkWidget* child = gtk_bin_get_child(GTK_BIN(m_widget));
gtk_widget_set_can_default(m_widget, FALSE);
}
- wxSize ret( wxControl::DoGetBestSize() );
+ wxSize ret( wxAnyButton::DoGetBestSize() );
if ( isDefault )
{
return GetDefaultAttributesFromGTKWidget(gtk_button_new);
}
-// ----------------------------------------------------------------------------
-// bitmaps support
-// ----------------------------------------------------------------------------
-
-void wxButton::GTKMouseEnters()
-{
- m_isCurrent = true;
-
- GTKUpdateBitmap();
-}
-
-void wxButton::GTKMouseLeaves()
-{
- m_isCurrent = false;
-
- GTKUpdateBitmap();
-}
-
-void wxButton::GTKPressed()
-{
- m_isPressed = true;
-
- GTKUpdateBitmap();
-}
-
-void wxButton::GTKReleased()
-{
- m_isPressed = false;
-
- GTKUpdateBitmap();
-}
-
-void wxButton::GTKOnFocus(wxFocusEvent& event)
-{
- event.Skip();
-
- GTKUpdateBitmap();
-}
-
-wxButton::State wxButton::GTKGetCurrentState() const
-{
- if ( !IsThisEnabled() )
- return m_bitmaps[State_Disabled].IsOk() ? State_Disabled : State_Normal;
-
- if ( m_isPressed && m_bitmaps[State_Pressed].IsOk() )
- return State_Pressed;
-
- if ( m_isCurrent && m_bitmaps[State_Current].IsOk() )
- return State_Current;
-
- if ( HasFocus() && m_bitmaps[State_Focused].IsOk() )
- return State_Focused;
-
- return State_Normal;
-}
-
-void wxButton::GTKUpdateBitmap()
-{
- // if we don't show bitmaps at all, there is nothing to update
- if ( m_bitmaps[State_Normal].IsOk() )
- {
- // if we do show them, this will return a state for which we do have a
- // valid bitmap
- State state = GTKGetCurrentState();
-
- GTKDoShowBitmap(m_bitmaps[state]);
- }
-}
-
-void wxButton::GTKDoShowBitmap(const wxBitmap& bitmap)
-{
- wxASSERT_MSG( bitmap.IsOk(), "invalid bitmap" );
-
- GtkWidget *image;
- if ( DontShowLabel() )
- {
- image = gtk_bin_get_child(GTK_BIN(m_widget));
- }
- else // have both label and bitmap
- {
-#ifdef __WXGTK26__
- if ( !gtk_check_version(2,6,0) )
- {
- image = gtk_button_get_image(GTK_BUTTON(m_widget));
- }
- else
-#endif // __WXGTK26__
- {
- // buttons with both label and bitmap are only supported with GTK+
- // 2.6 so far
- //
- // it shouldn't be difficult to implement them ourselves for the
- // previous GTK+ versions by stuffing a container with a label and
- // an image inside GtkButton but there doesn't seem to be much
- // point in doing this for ancient GTK+ versions
- return;
- }
- }
-
- wxCHECK_RET( image && GTK_IS_IMAGE(image), "must have image widget" );
-
- gtk_image_set_from_pixbuf(GTK_IMAGE(image), bitmap.GetPixbuf());
-}
-
-wxBitmap wxButton::DoGetBitmap(State which) const
-{
- return m_bitmaps[which];
-}
-
-void wxButton::DoSetBitmap(const wxBitmap& bitmap, State which)
-{
- switch ( which )
- {
- case State_Normal:
- if ( DontShowLabel() )
- {
- // we only have the bitmap in this button, never remove it but
- // do invalidate the best size when the bitmap (and presumably
- // its size) changes
- InvalidateBestSize();
- }
-#ifdef __WXGTK26__
- // normal image is special: setting it enables images for the button and
- // resetting it to nothing disables all of them
- else if ( !gtk_check_version(2,6,0) )
- {
- GtkWidget *image = gtk_button_get_image(GTK_BUTTON(m_widget));
- if ( image && !bitmap.IsOk() )
- {
- gtk_container_remove(GTK_CONTAINER(m_widget), image);
- }
- else if ( !image && bitmap.IsOk() )
- {
- image = gtk_image_new();
- gtk_button_set_image(GTK_BUTTON(m_widget), image);
- }
- else // image presence or absence didn't change
- {
- // don't invalidate best size below
- break;
- }
-
- InvalidateBestSize();
- }
-#endif // GTK+ 2.6+
- break;
-
- case State_Pressed:
- if ( bitmap.IsOk() )
- {
- if ( !m_bitmaps[which].IsOk() )
- {
- // we need to install the callbacks to be notified about
- // the button pressed state change
- g_signal_connect
- (
- m_widget,
- "pressed",
- G_CALLBACK(wxgtk_button_press_callback),
- this
- );
-
- g_signal_connect
- (
- m_widget,
- "released",
- G_CALLBACK(wxgtk_button_released_callback),
- this
- );
- }
- }
- else // no valid bitmap
- {
- if ( m_bitmaps[which].IsOk() )
- {
- // we don't need to be notified about the button pressed
- // state changes any more
- g_signal_handlers_disconnect_by_func
- (
- m_widget,
- (gpointer)wxgtk_button_press_callback,
- this
- );
-
- g_signal_handlers_disconnect_by_func
- (
- m_widget,
- (gpointer)wxgtk_button_released_callback,
- this
- );
-
- // also make sure we don't remain stuck in pressed state
- if ( m_isPressed )
- {
- m_isPressed = false;
- GTKUpdateBitmap();
- }
- }
- }
- break;
-
- case State_Current:
- // the logic here is the same as above for State_Pressed: we need
- // to connect the handlers if we must be notified about the changes
- // in the button current state and we disconnect them when/if we
- // don't need them any more
- if ( bitmap.IsOk() )
- {
- if ( !m_bitmaps[which].IsOk() )
- {
- g_signal_connect
- (
- m_widget,
- "enter",
- G_CALLBACK(wxgtk_button_enter_callback),
- this
- );
-
- g_signal_connect
- (
- m_widget,
- "leave",
- G_CALLBACK(wxgtk_button_leave_callback),
- this
- );
- }
- }
- else // no valid bitmap
- {
- if ( m_bitmaps[which].IsOk() )
- {
- g_signal_handlers_disconnect_by_func
- (
- m_widget,
- (gpointer)wxgtk_button_enter_callback,
- this
- );
-
- g_signal_handlers_disconnect_by_func
- (
- m_widget,
- (gpointer)wxgtk_button_leave_callback,
- this
- );
-
- if ( m_isCurrent )
- {
- m_isCurrent = false;
- GTKUpdateBitmap();
- }
- }
- }
- break;
-
- case State_Focused:
- if ( bitmap.IsOk() )
- {
- Connect(wxEVT_SET_FOCUS,
- wxFocusEventHandler(wxButton::GTKOnFocus));
- Connect(wxEVT_KILL_FOCUS,
- wxFocusEventHandler(wxButton::GTKOnFocus));
- }
- else // no valid focused bitmap
- {
- Disconnect(wxEVT_SET_FOCUS,
- wxFocusEventHandler(wxButton::GTKOnFocus));
- Disconnect(wxEVT_KILL_FOCUS,
- wxFocusEventHandler(wxButton::GTKOnFocus));
- }
- break;
-
- default:
- // no callbacks to connect/disconnect
- ;
- }
-
- m_bitmaps[which] = bitmap;
-
- // update the bitmap immediately if necessary, otherwise it will be done
- // when the bitmap for the corresponding state is needed the next time by
- // GTKUpdateBitmap()
- if ( bitmap.IsOk() && which == GTKGetCurrentState() )
- {
- GTKDoShowBitmap(bitmap);
- }
-}
-
-void wxButton::DoSetBitmapPosition(wxDirection dir)
-{
-#ifdef __WXGTK210__
- if ( !gtk_check_version(2,10,0) )
- {
- GtkPositionType gtkpos;
- switch ( dir )
- {
- default:
- wxFAIL_MSG( "invalid position" );
- // fall through
-
- case wxLEFT:
- gtkpos = GTK_POS_LEFT;
- break;
-
- case wxRIGHT:
- gtkpos = GTK_POS_RIGHT;
- break;
-
- case wxTOP:
- gtkpos = GTK_POS_TOP;
- break;
-
- case wxBOTTOM:
- gtkpos = GTK_POS_BOTTOM;
- break;
- }
-
- gtk_button_set_image_position(GTK_BUTTON(m_widget), gtkpos);
- InvalidateBestSize();
- }
-#endif // GTK+ 2.10+
-}
-
#endif // wxUSE_BUTTON
// wxBitmapToggleButton
// ------------------------------------------------------------------------
-IMPLEMENT_DYNAMIC_CLASS(wxBitmapToggleButton, wxControl)
+IMPLEMENT_DYNAMIC_CLASS(wxBitmapToggleButton, wxToggleButton)
bool wxBitmapToggleButton::Create(wxWindow *parent, wxWindowID id,
- const wxBitmap &label, const wxPoint &pos,
+ const wxBitmap &bitmap, const wxPoint &pos,
const wxSize &size, long style,
const wxValidator& validator,
const wxString &name)
{
- if (!PreCreation(parent, pos, size) ||
- !CreateBase(parent, id, pos, size, style, validator, name ))
- {
- wxFAIL_MSG(wxT("wxBitmapToggleButton creation failed"));
+ if ( !wxToggleButton::Create(parent, id, wxEmptyString, pos, size, style | wxBU_NOTEXT | wxBU_EXACTFIT,
+ validator, name) )
return false;
- }
-
- // Create the gtk widget.
- m_widget = gtk_toggle_button_new();
- g_object_ref(m_widget);
-
- if (style & wxNO_BORDER)
- gtk_button_set_relief( GTK_BUTTON(m_widget), GTK_RELIEF_NONE );
-
- m_bitmap = label;
- OnSetBitmap();
-
- g_signal_connect (m_widget, "clicked",
- G_CALLBACK (gtk_togglebutton_clicked_callback),
- this);
-
- m_parent->DoAddChild(this);
-
- PostCreation(size);
-
- return true;
-}
-
-void wxBitmapToggleButton::GTKDisableEvents()
-{
- g_signal_handlers_block_by_func(m_widget,
- (gpointer) gtk_togglebutton_clicked_callback, this);
-}
-
-void wxBitmapToggleButton::GTKEnableEvents()
-{
- g_signal_handlers_unblock_by_func(m_widget,
- (gpointer) gtk_togglebutton_clicked_callback, this);
-}
-
-// void SetValue(bool state)
-// Set the value of the toggle button.
-void wxBitmapToggleButton::SetValue(bool state)
-{
- wxCHECK_RET(m_widget != NULL, wxT("invalid toggle button"));
-
- if (state == GetValue())
- return;
-
- GTKDisableEvents();
-
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_widget), state);
-
- GTKEnableEvents();
-}
-
-// bool GetValue() const
-// Get the value of the toggle button.
-bool wxBitmapToggleButton::GetValue() const
-{
- wxCHECK_MSG(m_widget != NULL, false, wxT("invalid toggle button"));
-
- return gtk_toggle_button_get_active((GtkToggleButton*)m_widget);
-}
-
-void wxBitmapToggleButton::SetLabel(const wxBitmap& label)
-{
- wxCHECK_RET(m_widget != NULL, wxT("invalid toggle button"));
-
- m_bitmap = label;
- InvalidateBestSize();
-
- OnSetBitmap();
-}
-void wxBitmapToggleButton::OnSetBitmap()
-{
- if (!m_bitmap.IsOk()) return;
-
- GtkWidget* image = gtk_bin_get_child(GTK_BIN(m_widget));
- if (image == NULL)
+ if ( bitmap.IsOk() )
{
- image = gtk_image_new();
- gtk_widget_show(image);
- gtk_container_add((GtkContainer*)m_widget, image);
- }
- // always use pixbuf, because pixmap mask does not
- // work with disabled images in some themes
- gtk_image_set_from_pixbuf((GtkImage*)image, m_bitmap.GetPixbuf());
-}
-
-bool wxBitmapToggleButton::Enable(bool enable /*=true*/)
-{
- bool isEnabled = IsEnabled();
-
- if (!wxControl::Enable(enable))
- return false;
+ SetBitmapLabel(bitmap);
- gtk_widget_set_sensitive(gtk_bin_get_child(GTK_BIN(m_widget)), enable);
-
- if (!isEnabled && enable)
- {
- GTKFixSensitivity();
+ // we need to adjust the size after setting the bitmap as it may be too
+ // big for the default button size
+ SetInitialSize(size);
}
return true;
}
-void wxBitmapToggleButton::DoApplyWidgetStyle(GtkRcStyle *style)
-{
- gtk_widget_modify_style(m_widget, style);
- gtk_widget_modify_style(gtk_bin_get_child(GTK_BIN(m_widget)), style);
-}
-
-GdkWindow *
-wxBitmapToggleButton::GTKGetWindow(wxArrayGdkWindows& WXUNUSED(windows)) const
-{
- return GTK_BUTTON(m_widget)->event_window;
-}
-
-// Get the "best" size for this control.
-wxSize wxBitmapToggleButton::DoGetBestSize() const
-{
- wxSize best;
-
- if (m_bitmap.IsOk())
- {
- int border = HasFlag(wxNO_BORDER) ? 4 : 10;
- best.x = m_bitmap.GetWidth()+border;
- best.y = m_bitmap.GetHeight()+border;
- }
- CacheBestSize(best);
- return best;
-}
-
-
-// static
-wxVisualAttributes
-wxBitmapToggleButton::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
-{
- return GetDefaultAttributesFromGTKWidget(gtk_toggle_button_new);
-}
-
// ------------------------------------------------------------------------
// wxToggleButton
return false;
}
- // Create the gtk widget.
- m_widget = gtk_toggle_button_new_with_mnemonic("");
+ // create either a standard toggle button with text label (which may still contain
+ // an image under GTK+ 2.6+) or a bitmap-only toggle button if we don't have any
+ // label
+ const bool
+ useLabel = !(style & wxBU_NOTEXT) && !label.empty();
+ if ( useLabel )
+ {
+ m_widget = gtk_toggle_button_new_with_mnemonic("");
+ }
+ else // no label, suppose we will have a bitmap
+ {
+ m_widget = gtk_toggle_button_new();
+
+ GtkWidget *image = gtk_image_new();
+ gtk_widget_show(image);
+ gtk_container_add(GTK_CONTAINER(m_widget), image);
+ }
+
g_object_ref(m_widget);
- SetLabel(label);
+ if ( useLabel )
+ SetLabel(label);
g_signal_connect (m_widget, "clicked",
G_CALLBACK (gtk_togglebutton_clicked_callback),
{
wxCHECK_RET(m_widget != NULL, wxT("invalid toggle button"));
- wxControl::SetLabel(label);
+ wxAnyButton::SetLabel(label);
const wxString labelGTK = GTKConvertMnemonics(label);
GTKApplyWidgetStyle( false );
}
-bool wxToggleButton::Enable(bool enable /*=true*/)
+#if wxUSE_MARKUP
+bool wxToggleButton::DoSetLabelMarkup(const wxString& markup)
{
- if (!base_type::Enable(enable))
+ wxCHECK_MSG( m_widget != NULL, false, "invalid toggle button" );
+
+ const wxString stripped = RemoveMarkup(markup);
+ if ( stripped.empty() && !markup.empty() )
return false;
- gtk_widget_set_sensitive(gtk_bin_get_child(GTK_BIN(m_widget)), enable);
+ wxControl::SetLabel(stripped);
+
+ GtkLabel * const label = GTKGetLabel();
+ wxCHECK_MSG( label, false, "no label in this toggle button?" );
- if (enable)
- GTKFixSensitivity();
+ GTKSetLabelWithMarkupForLabel(label, markup);
return true;
}
+#endif // wxUSE_MARKUP
-void wxToggleButton::DoApplyWidgetStyle(GtkRcStyle *style)
+GtkLabel *wxToggleButton::GTKGetLabel() const
{
- gtk_widget_modify_style(m_widget, style);
- gtk_widget_modify_style(gtk_bin_get_child(GTK_BIN(m_widget)), style);
+ GtkWidget* child = gtk_bin_get_child(GTK_BIN(m_widget));
+ return GTK_LABEL(child);
}
-GdkWindow *
-wxToggleButton::GTKGetWindow(wxArrayGdkWindows& WXUNUSED(windows)) const
+void wxToggleButton::DoApplyWidgetStyle(GtkRcStyle *style)
{
- return GTK_BUTTON(m_widget)->event_window;
+ gtk_widget_modify_style(m_widget, style);
+ gtk_widget_modify_style(gtk_bin_get_child(GTK_BIN(m_widget)), style);
}
// Get the "best" size for this control.
wxSize wxToggleButton::DoGetBestSize() const
{
- wxSize ret(wxControl::DoGetBestSize());
+ wxSize ret(wxAnyButton::DoGetBestSize());
if (!HasFlag(wxBU_EXACTFIT))
{
--- /dev/null
+/////////////////////////////////////////////////////////////////////////////
+// Name: src/msw/anybutton.cpp
+// Purpose: wxAnyButton
+// Author: Julian Smart
+// Created: 1998-01-04 (extracted from button.cpp)
+// RCS-ID: $Id: anybutton.cpp 67384 2011-04-03 20:31:32Z DS $
+// Copyright: (c) Julian Smart
+// Licence: wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+// ============================================================================
+// declarations
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// headers
+// ----------------------------------------------------------------------------
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+
+#ifdef wxHAS_ANY_BUTTON
+
+#include "wx/anybutton.h"
+
+#ifndef WX_PRECOMP
+ #include "wx/app.h"
+ #include "wx/brush.h"
+ #include "wx/panel.h"
+ #include "wx/bmpbuttn.h"
+ #include "wx/settings.h"
+ #include "wx/dcscreen.h"
+ #include "wx/dcclient.h"
+ #include "wx/toplevel.h"
+ #include "wx/msw/wrapcctl.h"
+ #include "wx/msw/private.h"
+ #include "wx/msw/missing.h"
+#endif
+
+#include "wx/imaglist.h"
+#include "wx/stockitem.h"
+#include "wx/msw/private/button.h"
+#include "wx/msw/private/dc.h"
+#include "wx/private/window.h"
+
+#if wxUSE_MARKUP
+ #include "wx/generic/private/markuptext.h"
+#endif // wxUSE_MARKUP
+
+using namespace wxMSWImpl;
+
+#if wxUSE_UXTHEME
+ #include "wx/msw/uxtheme.h"
+
+ // no need to include tmschema.h
+ #ifndef BP_PUSHBUTTON
+ #define BP_PUSHBUTTON 1
+
+ #define PBS_NORMAL 1
+ #define PBS_HOT 2
+ #define PBS_PRESSED 3
+ #define PBS_DISABLED 4
+ #define PBS_DEFAULTED 5
+
+ #define TMT_CONTENTMARGINS 3602
+ #endif
+
+ // provide the necessary declarations ourselves if they're missing from
+ // headers
+ #ifndef BCM_SETIMAGELIST
+ #define BCM_SETIMAGELIST 0x1602
+ #define BCM_SETTEXTMARGIN 0x1604
+
+ enum
+ {
+ BUTTON_IMAGELIST_ALIGN_LEFT,
+ BUTTON_IMAGELIST_ALIGN_RIGHT,
+ BUTTON_IMAGELIST_ALIGN_TOP,
+ BUTTON_IMAGELIST_ALIGN_BOTTOM
+ };
+
+ struct BUTTON_IMAGELIST
+ {
+ HIMAGELIST himl;
+ RECT margin;
+ UINT uAlign;
+ };
+ #endif
+#endif // wxUSE_UXTHEME
+
+#ifndef WM_THEMECHANGED
+ #define WM_THEMECHANGED 0x031A
+#endif
+
+#ifndef ODS_NOACCEL
+ #define ODS_NOACCEL 0x0100
+#endif
+
+#ifndef ODS_NOFOCUSRECT
+ #define ODS_NOFOCUSRECT 0x0200
+#endif
+
+#ifndef DT_HIDEPREFIX
+ #define DT_HIDEPREFIX 0x00100000
+#endif
+
+#if wxUSE_UXTHEME
+extern wxWindowMSW *wxWindowBeingErased; // From src/msw/window.cpp
+#endif // wxUSE_UXTHEME
+
+// ----------------------------------------------------------------------------
+// button image data
+// ----------------------------------------------------------------------------
+
+// we use different data classes for owner drawn buttons and for themed XP ones
+
+class wxButtonImageData
+{
+public:
+ wxButtonImageData() { }
+ virtual ~wxButtonImageData() { }
+
+ virtual wxBitmap GetBitmap(wxAnyButton::State which) const = 0;
+ virtual void SetBitmap(const wxBitmap& bitmap, wxAnyButton::State which) = 0;
+
+ virtual wxSize GetBitmapMargins() const = 0;
+ virtual void SetBitmapMargins(wxCoord x, wxCoord y) = 0;
+
+ virtual wxDirection GetBitmapPosition() const = 0;
+ virtual void SetBitmapPosition(wxDirection dir) = 0;
+
+private:
+ wxDECLARE_NO_COPY_CLASS(wxButtonImageData);
+};
+
+namespace
+{
+
+// the gap between button edge and the interior area used by Windows for the
+// standard buttons
+const int OD_BUTTON_MARGIN = 4;
+
+class wxODButtonImageData : public wxButtonImageData
+{
+public:
+ wxODButtonImageData(wxAnyButton *btn, const wxBitmap& bitmap)
+ {
+ SetBitmap(bitmap, wxAnyButton::State_Normal);
+ SetBitmap(bitmap.ConvertToDisabled(), wxAnyButton::State_Disabled);
+
+ m_dir = wxLEFT;
+
+ // we use margins when we have both bitmap and text, but when we have
+ // only the bitmap it should take up the entire button area
+ if ( btn->ShowsLabel() )
+ {
+ m_margin.x = btn->GetCharWidth();
+ m_margin.y = btn->GetCharHeight() / 2;
+ }
+ }
+
+ virtual wxBitmap GetBitmap(wxAnyButton::State which) const
+ {
+ return m_bitmaps[which];
+ }
+
+ virtual void SetBitmap(const wxBitmap& bitmap, wxAnyButton::State which)
+ {
+ m_bitmaps[which] = bitmap;
+ }
+
+ virtual wxSize GetBitmapMargins() const
+ {
+ return m_margin;
+ }
+
+ virtual void SetBitmapMargins(wxCoord x, wxCoord y)
+ {
+ m_margin = wxSize(x, y);
+ }
+
+ virtual wxDirection GetBitmapPosition() const
+ {
+ return m_dir;
+ }
+
+ virtual void SetBitmapPosition(wxDirection dir)
+ {
+ m_dir = dir;
+ }
+
+private:
+ // just store the values passed to us to be able to retrieve them later
+ // from the drawing code
+ wxBitmap m_bitmaps[wxAnyButton::State_Max];
+ wxSize m_margin;
+ wxDirection m_dir;
+
+ wxDECLARE_NO_COPY_CLASS(wxODButtonImageData);
+};
+
+#if wxUSE_UXTHEME
+
+// somehow the margin is one pixel greater than the value returned by
+// GetThemeMargins() call
+const int XP_BUTTON_EXTRA_MARGIN = 1;
+
+class wxXPButtonImageData : public wxButtonImageData
+{
+public:
+ // we must be constructed with the size of our images as we need to create
+ // the image list
+ wxXPButtonImageData(wxAnyButton *btn, const wxBitmap& bitmap)
+ : m_iml(bitmap.GetWidth(), bitmap.GetHeight(), true /* use mask */,
+ wxAnyButton::State_Max),
+ m_hwndBtn(GetHwndOf(btn))
+ {
+ // initialize all bitmaps except for the disabled one to normal state
+ for ( int n = 0; n < wxAnyButton::State_Max; n++ )
+ {
+ m_iml.Add(n == wxAnyButton::State_Disabled ? bitmap.ConvertToDisabled()
+ : bitmap);
+ }
+
+ m_data.himl = GetHimagelistOf(&m_iml);
+
+ // no margins by default
+ m_data.margin.left =
+ m_data.margin.right =
+ m_data.margin.top =
+ m_data.margin.bottom = 0;
+
+ // use default alignment
+ m_data.uAlign = BUTTON_IMAGELIST_ALIGN_LEFT;
+
+ UpdateImageInfo();
+ }
+
+ virtual wxBitmap GetBitmap(wxAnyButton::State which) const
+ {
+ return m_iml.GetBitmap(which);
+ }
+
+ virtual void SetBitmap(const wxBitmap& bitmap, wxAnyButton::State which)
+ {
+ m_iml.Replace(which, bitmap);
+
+ UpdateImageInfo();
+ }
+
+ virtual wxSize GetBitmapMargins() const
+ {
+ return wxSize(m_data.margin.left, m_data.margin.top);
+ }
+
+ virtual void SetBitmapMargins(wxCoord x, wxCoord y)
+ {
+ RECT& margin = m_data.margin;
+ margin.left =
+ margin.right = x;
+ margin.top =
+ margin.bottom = y;
+
+ if ( !::SendMessage(m_hwndBtn, BCM_SETTEXTMARGIN, 0, (LPARAM)&margin) )
+ {
+ wxLogDebug("SendMessage(BCM_SETTEXTMARGIN) failed");
+ }
+ }
+
+ virtual wxDirection GetBitmapPosition() const
+ {
+ switch ( m_data.uAlign )
+ {
+ default:
+ wxFAIL_MSG( "invalid image alignment" );
+ // fall through
+
+ case BUTTON_IMAGELIST_ALIGN_LEFT:
+ return wxLEFT;
+
+ case BUTTON_IMAGELIST_ALIGN_RIGHT:
+ return wxRIGHT;
+
+ case BUTTON_IMAGELIST_ALIGN_TOP:
+ return wxTOP;
+
+ case BUTTON_IMAGELIST_ALIGN_BOTTOM:
+ return wxBOTTOM;
+ }
+ }
+
+ virtual void SetBitmapPosition(wxDirection dir)
+ {
+ UINT alignNew;
+ switch ( dir )
+ {
+ default:
+ wxFAIL_MSG( "invalid direction" );
+ // fall through
+
+ case wxLEFT:
+ alignNew = BUTTON_IMAGELIST_ALIGN_LEFT;
+ break;
+
+ case wxRIGHT:
+ alignNew = BUTTON_IMAGELIST_ALIGN_RIGHT;
+ break;
+
+ case wxTOP:
+ alignNew = BUTTON_IMAGELIST_ALIGN_TOP;
+ break;
+
+ case wxBOTTOM:
+ alignNew = BUTTON_IMAGELIST_ALIGN_BOTTOM;
+ break;
+ }
+
+ if ( alignNew != m_data.uAlign )
+ {
+ m_data.uAlign = alignNew;
+ UpdateImageInfo();
+ }
+ }
+
+private:
+ void UpdateImageInfo()
+ {
+ if ( !::SendMessage(m_hwndBtn, BCM_SETIMAGELIST, 0, (LPARAM)&m_data) )
+ {
+ wxLogDebug("SendMessage(BCM_SETIMAGELIST) failed");
+ }
+ }
+
+ // we store image list separately to be able to use convenient wxImageList
+ // methods instead of working with raw HIMAGELIST
+ wxImageList m_iml;
+
+ // store the rest of the data in BCM_SETIMAGELIST-friendly form
+ BUTTON_IMAGELIST m_data;
+
+ // the button we're associated with
+ const HWND m_hwndBtn;
+
+
+ wxDECLARE_NO_COPY_CLASS(wxXPButtonImageData);
+};
+
+#endif // wxUSE_UXTHEME
+
+} // anonymous namespace
+
+// ----------------------------------------------------------------------------
+// macros
+// ----------------------------------------------------------------------------
+
+// ============================================================================
+// implementation
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// helper functions from wx/msw/private/button.h
+// ----------------------------------------------------------------------------
+
+void wxMSWButton::UpdateMultilineStyle(HWND hwnd, const wxString& label)
+{
+ // update BS_MULTILINE style depending on the new label (resetting it
+ // doesn't seem to do anything very useful but it shouldn't hurt and we do
+ // have to set it whenever the label becomes multi line as otherwise it
+ // wouldn't be shown correctly as we don't use BS_MULTILINE when creating
+ // the control unless it already has new lines in its label)
+ long styleOld = ::GetWindowLong(hwnd, GWL_STYLE),
+ styleNew;
+ if ( label.find(wxT('\n')) != wxString::npos )
+ styleNew = styleOld | BS_MULTILINE;
+ else
+ styleNew = styleOld & ~BS_MULTILINE;
+
+ if ( styleNew != styleOld )
+ ::SetWindowLong(hwnd, GWL_STYLE, styleNew);
+}
+
+wxSize wxMSWButton::GetFittingSize(wxWindow *win,
+ const wxSize& sizeLabel,
+ int flags)
+{
+ // FIXME: this is pure guesswork, need to retrieve the real button margins
+ wxSize sizeBtn = sizeLabel;
+
+ sizeBtn.x += 3*win->GetCharWidth();
+ sizeBtn.y += win->GetCharHeight()/2;
+
+ // account for the shield UAC icon if we have it
+ if ( flags & Size_AuthNeeded )
+ sizeBtn.x += wxSystemSettings::GetMetric(wxSYS_SMALLICON_X);
+
+ return sizeBtn;
+}
+
+wxSize wxMSWButton::ComputeBestFittingSize(wxControl *btn, int flags)
+{
+ wxClientDC dc(btn);
+
+ wxSize sizeBtn;
+ dc.GetMultiLineTextExtent(btn->GetLabelText(), &sizeBtn.x, &sizeBtn.y);
+
+ return GetFittingSize(btn, sizeBtn, flags);
+}
+
+wxSize wxMSWButton::IncreaseToStdSizeAndCache(wxControl *btn, const wxSize& size)
+{
+ wxSize sizeBtn(size);
+
+ // All buttons have at least the standard height and, unless the user
+ // explicitly wants them to be as small as possible and used wxBU_EXACTFIT
+ // style to indicate this, of at least the standard width too.
+ //
+ // Notice that we really want to make all buttons equally high, otherwise
+ // they look ugly and the existing code using wxBU_EXACTFIT only uses it to
+ // control width and not height.
+
+ // The 50x14 button size is documented in the "Recommended sizing and
+ // spacing" section of MSDN layout article.
+ //
+ // Note that we intentionally don't use GetDefaultSize() here, because
+ // it's inexact -- dialog units depend on this dialog's font.
+ const wxSize sizeDef = btn->ConvertDialogToPixels(wxSize(50, 14));
+ if ( !btn->HasFlag(wxBU_EXACTFIT) )
+ {
+ if ( sizeBtn.x < sizeDef.x )
+ sizeBtn.x = sizeDef.x;
+ }
+ if ( sizeBtn.y < sizeDef.y )
+ sizeBtn.y = sizeDef.y;
+
+ btn->CacheBestSize(sizeBtn);
+
+ return sizeBtn;
+}
+
+// ----------------------------------------------------------------------------
+// creation/destruction
+// ----------------------------------------------------------------------------
+
+wxAnyButton::~wxAnyButton()
+{
+ delete m_imageData;
+#if wxUSE_MARKUP
+ delete m_markupText;
+#endif // wxUSE_MARKUP
+}
+
+void wxAnyButton::SetLabel(const wxString& label)
+{
+ wxMSWButton::UpdateMultilineStyle(GetHwnd(), label);
+
+ wxAnyButtonBase::SetLabel(label);
+
+#if wxUSE_MARKUP
+ // If we have a plain text label, we shouldn't be using markup any longer.
+ if ( m_markupText )
+ {
+ delete m_markupText;
+ m_markupText = NULL;
+
+ // Unfortunately we don't really know whether we can reset the button
+ // to be non-owner-drawn or not: if we had made it owner-drawn just
+ // because of a call to SetLabelMarkup(), we could, but not if there
+ // were [also] calls to Set{Fore,Back}groundColour(). If it's really a
+ // problem to have button remain owner-drawn forever just because it
+ // had markup label once, we should record the reason for our current
+ // owner-drawnness and check it here.
+ }
+#endif // wxUSE_MARKUP
+}
+
+// ----------------------------------------------------------------------------
+// size management including autosizing
+// ----------------------------------------------------------------------------
+
+void wxAnyButton::AdjustForBitmapSize(wxSize &size) const
+{
+ wxCHECK_RET( m_imageData, wxT("shouldn't be called if no image") );
+
+ // account for the bitmap size
+ const wxSize sizeBmp = m_imageData->GetBitmap(State_Normal).GetSize();
+ const wxDirection dirBmp = m_imageData->GetBitmapPosition();
+ if ( dirBmp == wxLEFT || dirBmp == wxRIGHT )
+ {
+ size.x += sizeBmp.x;
+ if ( sizeBmp.y > size.y )
+ size.y = sizeBmp.y;
+ }
+ else // bitmap on top/below the text
+ {
+ size.y += sizeBmp.y;
+ if ( sizeBmp.x > size.x )
+ size.x = sizeBmp.x;
+ }
+
+ // account for the user-specified margins
+ size += 2*m_imageData->GetBitmapMargins();
+
+ // and also for the margins we always add internally (unless we have no
+ // border at all in which case the button has exactly the same size as
+ // bitmap and so no margins should be used)
+ if ( !HasFlag(wxBORDER_NONE) )
+ {
+ int marginH = 0,
+ marginV = 0;
+#if wxUSE_UXTHEME
+ if ( wxUxThemeEngine::GetIfActive() )
+ {
+ wxUxThemeHandle theme(const_cast<wxAnyButton *>(this), L"BUTTON");
+
+ MARGINS margins;
+ wxUxThemeEngine::Get()->GetThemeMargins(theme, NULL,
+ BP_PUSHBUTTON,
+ PBS_NORMAL,
+ TMT_CONTENTMARGINS,
+ NULL,
+ &margins);
+
+ // XP doesn't draw themed buttons correctly when the client
+ // area is smaller than 8x8 - enforce this minimum size for
+ // small bitmaps
+ size.IncTo(wxSize(8, 8));
+
+ marginH = margins.cxLeftWidth + margins.cxRightWidth
+ + 2*XP_BUTTON_EXTRA_MARGIN;
+ marginV = margins.cyTopHeight + margins.cyBottomHeight
+ + 2*XP_BUTTON_EXTRA_MARGIN;
+ }
+ else
+#endif // wxUSE_UXTHEME
+ {
+ marginH =
+ marginV = OD_BUTTON_MARGIN;
+ }
+
+ size.IncBy(marginH, marginV);
+ }
+}
+
+wxSize wxAnyButton::DoGetBestSize() const
+{
+ wxAnyButton * const self = const_cast<wxAnyButton *>(this);
+
+ wxSize size;
+
+ // Account for the text part if we have it.
+ if ( ShowsLabel() )
+ {
+ int flags = 0;
+ if ( DoGetAuthNeeded() )
+ flags |= wxMSWButton::Size_AuthNeeded;
+
+#if wxUSE_MARKUP
+ if ( m_markupText )
+ {
+ wxClientDC dc(self);
+ size = wxMSWButton::GetFittingSize(self,
+ m_markupText->Measure(dc),
+ flags);
+ }
+ else // Normal plain text (but possibly multiline) label.
+#endif // wxUSE_MARKUP
+ {
+ size = wxMSWButton::ComputeBestFittingSize(self, flags);
+ }
+ }
+
+ if ( m_imageData )
+ AdjustForBitmapSize(size);
+
+ return wxMSWButton::IncreaseToStdSizeAndCache(self, size);
+}
+
+// ----------------------------------------------------------------------------
+// event/message handlers
+// ----------------------------------------------------------------------------
+
+WXLRESULT wxAnyButton::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
+{
+ if ( nMsg == WM_LBUTTONDBLCLK )
+ {
+ // emulate a click event to force an owner-drawn button to change its
+ // appearance - without this, it won't do it
+ (void)wxControl::MSWWindowProc(WM_LBUTTONDOWN, wParam, lParam);
+
+ // and continue with processing the message normally as well
+ }
+#if wxUSE_UXTHEME
+ else if ( nMsg == WM_THEMECHANGED )
+ {
+ // need to recalculate the best size here
+ // as the theme size might have changed
+ InvalidateBestSize();
+ }
+#endif // wxUSE_UXTHEME
+ // must use m_mouseInWindow here instead of IsMouseInWindow()
+ // since we need to know the first time the mouse enters the window
+ // and IsMouseInWindow() would return true in this case
+ else if ( (nMsg == WM_MOUSEMOVE && !m_mouseInWindow) ||
+ nMsg == WM_MOUSELEAVE )
+ {
+ if (
+ IsEnabled() &&
+ (
+#if wxUSE_UXTHEME
+ wxUxThemeEngine::GetIfActive() ||
+#endif // wxUSE_UXTHEME
+ (m_imageData && m_imageData->GetBitmap(State_Current).IsOk())
+ )
+ )
+ {
+ Refresh();
+ }
+ }
+
+ // let the base class do all real processing
+ return wxControl::MSWWindowProc(nMsg, wParam, lParam);
+}
+
+// ----------------------------------------------------------------------------
+// button images
+// ----------------------------------------------------------------------------
+
+wxBitmap wxAnyButton::DoGetBitmap(State which) const
+{
+ return m_imageData ? m_imageData->GetBitmap(which) : wxBitmap();
+}
+
+void wxAnyButton::DoSetBitmap(const wxBitmap& bitmap, State which)
+{
+#if wxUSE_UXTHEME
+ wxXPButtonImageData *oldData = NULL;
+#endif // wxUSE_UXTHEME
+
+ // Check if we already had bitmaps of different size.
+ if ( m_imageData &&
+ bitmap.GetSize() != m_imageData->GetBitmap(State_Normal).GetSize() )
+ {
+ wxASSERT_MSG( which == State_Normal,
+ "Must set normal bitmap with the new size first" );
+
+#if wxUSE_UXTHEME
+ if ( ShowsLabel() && wxUxThemeEngine::GetIfActive() )
+ {
+ // We can't change the size of the images stored in wxImageList
+ // in wxXPButtonImageData::m_iml so force recreating it below but
+ // keep the current data to copy its values into the new one.
+ oldData = static_cast<wxXPButtonImageData *>(m_imageData);
+ m_imageData = NULL;
+ }
+#endif // wxUSE_UXTHEME
+ //else: wxODButtonImageData doesn't require anything special
+ }
+
+ // allocate the image data when the first bitmap is set
+ if ( !m_imageData )
+ {
+#if wxUSE_UXTHEME
+ // using image list doesn't work correctly if we don't have any label
+ // (even if we use BUTTON_IMAGELIST_ALIGN_CENTER alignment and
+ // BS_BITMAP style), at least under Windows 2003 so use owner drawn
+ // strategy for bitmap-only buttons
+ if ( ShowsLabel() && wxUxThemeEngine::GetIfActive() )
+ {
+ m_imageData = new wxXPButtonImageData(this, bitmap);
+
+ if ( oldData )
+ {
+ // Preserve the old values in case the user changed them.
+ m_imageData->SetBitmapPosition(oldData->GetBitmapPosition());
+
+ const wxSize oldMargins = oldData->GetBitmapMargins();
+ m_imageData->SetBitmapMargins(oldMargins.x, oldMargins.y);
+
+ // No need to preserve the bitmaps though as they were of wrong
+ // size anyhow.
+
+ delete oldData;
+ }
+ }
+ else
+#endif // wxUSE_UXTHEME
+ {
+ m_imageData = new wxODButtonImageData(this, bitmap);
+ MakeOwnerDrawn();
+ }
+ }
+ else
+ {
+ m_imageData->SetBitmap(bitmap, which);
+ }
+
+ // it should be enough to only invalidate the best size when the normal
+ // bitmap changes as all bitmaps assigned to the button should be of the
+ // same size anyhow
+ if ( which == State_Normal )
+ InvalidateBestSize();
+
+ Refresh();
+}
+
+wxSize wxAnyButton::DoGetBitmapMargins() const
+{
+ return m_imageData ? m_imageData->GetBitmapMargins() : wxSize(0, 0);
+}
+
+void wxAnyButton::DoSetBitmapMargins(wxCoord x, wxCoord y)
+{
+ wxCHECK_RET( m_imageData, "SetBitmap() must be called first" );
+
+ m_imageData->SetBitmapMargins(x, y);
+ InvalidateBestSize();
+}
+
+void wxAnyButton::DoSetBitmapPosition(wxDirection dir)
+{
+ wxCHECK_RET( m_imageData, "SetBitmap() must be called first" );
+
+ m_imageData->SetBitmapPosition(dir);
+ InvalidateBestSize();
+}
+
+// ----------------------------------------------------------------------------
+// markup support
+// ----------------------------------------------------------------------------
+
+#if wxUSE_MARKUP
+
+bool wxAnyButton::DoSetLabelMarkup(const wxString& markup)
+{
+ if ( !wxAnyButtonBase::DoSetLabelMarkup(markup) )
+ return false;
+
+ if ( !m_markupText )
+ {
+ m_markupText = new wxMarkupText(markup);
+ MakeOwnerDrawn();
+ }
+ else
+ {
+ // We are already owner-drawn so just update the text.
+ m_markupText->SetMarkup(markup);
+ }
+
+ Refresh();
+
+ return true;
+}
+
+#endif // wxUSE_MARKUP
+
+// ----------------------------------------------------------------------------
+// owner-drawn buttons support
+// ----------------------------------------------------------------------------
+
+// drawing helpers
+namespace
+{
+
+// return the button state using both the ODS_XXX flags specified in state
+// parameter and the current button state
+wxAnyButton::State GetButtonState(wxAnyButton *btn, UINT state)
+{
+ if ( state & ODS_DISABLED )
+ return wxAnyButton::State_Disabled;
+
+ if ( state & ODS_SELECTED )
+ return wxAnyButton::State_Pressed;
+
+ if ( btn->HasCapture() || btn->IsMouseInWindow() )
+ return wxAnyButton::State_Current;
+
+ if ( state & ODS_FOCUS )
+ return wxAnyButton::State_Focused;
+
+ return btn->GetNormalState();
+}
+
+void DrawButtonText(HDC hdc,
+ RECT *pRect,
+ wxAnyButton *btn,
+ int flags)
+{
+ const wxString text = btn->GetLabel();
+
+ if ( text.find(wxT('\n')) != wxString::npos )
+ {
+ // draw multiline label
+
+ // center text horizontally in any case
+ flags |= DT_CENTER;
+
+ // first we need to compute its bounding rect
+ RECT rc;
+ ::CopyRect(&rc, pRect);
+ ::DrawText(hdc, text.wx_str(), text.length(), &rc,
+ DT_CENTER | DT_CALCRECT);
+
+ // now center this rect inside the entire button area
+ const LONG w = rc.right - rc.left;
+ const LONG h = rc.bottom - rc.top;
+ rc.left = (pRect->right - pRect->left)/2 - w/2;
+ rc.right = rc.left+w;
+ rc.top = (pRect->bottom - pRect->top)/2 - h/2;
+ rc.bottom = rc.top+h;
+
+ ::DrawText(hdc, text.wx_str(), text.length(), &rc, flags);
+ }
+ else // single line label
+ {
+ // translate wx button flags to alignment flags for DrawText()
+ if ( btn->HasFlag(wxBU_RIGHT) )
+ {
+ flags |= DT_RIGHT;
+ }
+ else if ( !btn->HasFlag(wxBU_LEFT) )
+ {
+ flags |= DT_CENTER;
+ }
+ //else: DT_LEFT is the default anyhow (and its value is 0 too)
+
+ if ( btn->HasFlag(wxBU_BOTTOM) )
+ {
+ flags |= DT_BOTTOM;
+ }
+ else if ( !btn->HasFlag(wxBU_TOP) )
+ {
+ flags |= DT_VCENTER;
+ }
+ //else: as above, DT_TOP is the default
+
+ // notice that we must have DT_SINGLELINE for vertical alignment flags
+ // to work
+ ::DrawText(hdc, text.wx_str(), text.length(), pRect,
+ flags | DT_SINGLELINE );
+ }
+}
+
+void DrawRect(HDC hdc, const RECT& r)
+{
+ wxDrawLine(hdc, r.left, r.top, r.right, r.top);
+ wxDrawLine(hdc, r.right, r.top, r.right, r.bottom);
+ wxDrawLine(hdc, r.right, r.bottom, r.left, r.bottom);
+ wxDrawLine(hdc, r.left, r.bottom, r.left, r.top);
+}
+
+/*
+ The button frame looks like this normally:
+
+ WWWWWWWWWWWWWWWWWWB
+ WHHHHHHHHHHHHHHHHGB W = white (HILIGHT)
+ WH GB H = light grey (LIGHT)
+ WH GB G = dark grey (SHADOW)
+ WH GB B = black (DKSHADOW)
+ WH GB
+ WGGGGGGGGGGGGGGGGGB
+ BBBBBBBBBBBBBBBBBBB
+
+ When the button is selected, the button becomes like this (the total button
+ size doesn't change):
+
+ BBBBBBBBBBBBBBBBBBB
+ BWWWWWWWWWWWWWWWWBB
+ BWHHHHHHHHHHHHHHGBB
+ BWH GBB
+ BWH GBB
+ BWGGGGGGGGGGGGGGGBB
+ BBBBBBBBBBBBBBBBBBB
+ BBBBBBBBBBBBBBBBBBB
+
+ When the button is pushed (while selected) it is like:
+
+ BBBBBBBBBBBBBBBBBBB
+ BGGGGGGGGGGGGGGGGGB
+ BG GB
+ BG GB
+ BG GB
+ BG GB
+ BGGGGGGGGGGGGGGGGGB
+ BBBBBBBBBBBBBBBBBBB
+*/
+void DrawButtonFrame(HDC hdc, RECT& rectBtn,
+ bool selected, bool pushed)
+{
+ RECT r;
+ CopyRect(&r, &rectBtn);
+
+ AutoHPEN hpenBlack(GetSysColor(COLOR_3DDKSHADOW)),
+ hpenGrey(GetSysColor(COLOR_3DSHADOW)),
+ hpenLightGr(GetSysColor(COLOR_3DLIGHT)),
+ hpenWhite(GetSysColor(COLOR_3DHILIGHT));
+
+ SelectInHDC selectPen(hdc, hpenBlack);
+
+ r.right--;
+ r.bottom--;
+
+ if ( pushed )
+ {
+ DrawRect(hdc, r);
+
+ (void)SelectObject(hdc, hpenGrey);
+ ::InflateRect(&r, -1, -1);
+
+ DrawRect(hdc, r);
+ }
+ else // !pushed
+ {
+ if ( selected )
+ {
+ DrawRect(hdc, r);
+
+ ::InflateRect(&r, -1, -1);
+ }
+
+ wxDrawLine(hdc, r.left, r.bottom, r.right, r.bottom);
+ wxDrawLine(hdc, r.right, r.bottom, r.right, r.top - 1);
+
+ (void)SelectObject(hdc, hpenWhite);
+ wxDrawLine(hdc, r.left, r.bottom - 1, r.left, r.top);
+ wxDrawLine(hdc, r.left, r.top, r.right, r.top);
+
+ (void)SelectObject(hdc, hpenLightGr);
+ wxDrawLine(hdc, r.left + 1, r.bottom - 2, r.left + 1, r.top + 1);
+ wxDrawLine(hdc, r.left + 1, r.top + 1, r.right - 1, r.top + 1);
+
+ (void)SelectObject(hdc, hpenGrey);
+ wxDrawLine(hdc, r.left + 1, r.bottom - 1, r.right - 1, r.bottom - 1);
+ wxDrawLine(hdc, r.right - 1, r.bottom - 1, r.right - 1, r.top);
+ }
+
+ InflateRect(&rectBtn, -OD_BUTTON_MARGIN, -OD_BUTTON_MARGIN);
+}
+
+#if wxUSE_UXTHEME
+void DrawXPBackground(wxAnyButton *button, HDC hdc, RECT& rectBtn, UINT state)
+{
+ wxUxThemeHandle theme(button, L"BUTTON");
+
+ // this array is indexed by wxAnyButton::State values and so must be kept in
+ // sync with it
+ static const int uxStates[] =
+ {
+ PBS_NORMAL, PBS_HOT, PBS_PRESSED, PBS_DISABLED, PBS_DEFAULTED
+ };
+
+ int iState = uxStates[GetButtonState(button, state)];
+
+ wxUxThemeEngine * const engine = wxUxThemeEngine::Get();
+
+ // draw parent background if needed
+ if ( engine->IsThemeBackgroundPartiallyTransparent
+ (
+ theme,
+ BP_PUSHBUTTON,
+ iState
+ ) )
+ {
+ // Set this button as the one whose background is being erased: this
+ // allows our WM_ERASEBKGND handler used by DrawThemeParentBackground()
+ // to correctly align the background brush with this window instead of
+ // the parent window to which WM_ERASEBKGND is sent. Notice that this
+ // doesn't work with custom user-defined EVT_ERASE_BACKGROUND handlers
+ // as they won't be aligned but unfortunately all the attempts to fix
+ // it by shifting DC origin before calling DrawThemeParentBackground()
+ // failed to work so we at least do this, even though this is far from
+ // being the perfect solution.
+ wxWindowBeingErased = button;
+
+ engine->DrawThemeParentBackground(GetHwndOf(button), hdc, &rectBtn);
+
+ wxWindowBeingErased = NULL;
+ }
+
+ // draw background
+ engine->DrawThemeBackground(theme, hdc, BP_PUSHBUTTON, iState,
+ &rectBtn, NULL);
+
+ // calculate content area margins
+ MARGINS margins;
+ engine->GetThemeMargins(theme, hdc, BP_PUSHBUTTON, iState,
+ TMT_CONTENTMARGINS, &rectBtn, &margins);
+ ::InflateRect(&rectBtn, -margins.cxLeftWidth, -margins.cyTopHeight);
+ ::InflateRect(&rectBtn, -XP_BUTTON_EXTRA_MARGIN, -XP_BUTTON_EXTRA_MARGIN);
+
+ if ( button->UseBgCol() )
+ {
+ COLORREF colBg = wxColourToRGB(button->GetBackgroundColour());
+ AutoHBRUSH hbrushBackground(colBg);
+
+ // don't overwrite the focus rect
+ RECT rectClient;
+ ::CopyRect(&rectClient, &rectBtn);
+ ::InflateRect(&rectClient, -1, -1);
+ FillRect(hdc, &rectClient, hbrushBackground);
+ }
+}
+#endif // wxUSE_UXTHEME
+
+} // anonymous namespace
+
+// ----------------------------------------------------------------------------
+// owner drawn buttons support
+// ----------------------------------------------------------------------------
+
+void wxAnyButton::MakeOwnerDrawn()
+{
+ if ( !IsOwnerDrawn() )
+ {
+ // make it so
+ // note that BS_OWNERDRAW is not independent from other style bits
+ long style = GetWindowLong(GetHwnd(), GWL_STYLE);
+ style &= ~(BS_3STATE | BS_AUTO3STATE | BS_AUTOCHECKBOX | BS_AUTORADIOBUTTON | BS_CHECKBOX | BS_DEFPUSHBUTTON | BS_GROUPBOX | BS_PUSHBUTTON | BS_RADIOBUTTON | BS_PUSHLIKE);
+ style |= BS_OWNERDRAW;
+ SetWindowLong(GetHwnd(), GWL_STYLE, style);
+ }
+}
+
+bool wxAnyButton::IsOwnerDrawn() const
+{
+ long style = GetWindowLong(GetHwnd(), GWL_STYLE);
+ return ( (style & BS_OWNERDRAW) == BS_OWNERDRAW );
+}
+
+bool wxAnyButton::SetBackgroundColour(const wxColour &colour)
+{
+ if ( !wxControl::SetBackgroundColour(colour) )
+ {
+ // nothing to do
+ return false;
+ }
+
+ MakeOwnerDrawn();
+
+ Refresh();
+
+ return true;
+}
+
+bool wxAnyButton::SetForegroundColour(const wxColour &colour)
+{
+ if ( !wxControl::SetForegroundColour(colour) )
+ {
+ // nothing to do
+ return false;
+ }
+
+ MakeOwnerDrawn();
+
+ Refresh();
+
+ return true;
+}
+
+bool wxAnyButton::MSWOnDraw(WXDRAWITEMSTRUCT *wxdis)
+{
+ LPDRAWITEMSTRUCT lpDIS = (LPDRAWITEMSTRUCT)wxdis;
+ HDC hdc = lpDIS->hDC;
+
+ UINT state = lpDIS->itemState;
+ switch ( GetButtonState(this, state) )
+ {
+ case State_Disabled:
+ state |= ODS_DISABLED;
+ break;
+ case State_Pressed:
+ state |= ODS_SELECTED;
+ break;
+ case State_Focused:
+ state |= ODS_FOCUS;
+ break;
+ default:
+ break;
+ }
+
+ bool pushed = (SendMessage(GetHwnd(), BM_GETSTATE, 0, 0) & BST_PUSHED) != 0;
+
+ RECT rectBtn;
+ CopyRect(&rectBtn, &lpDIS->rcItem);
+
+ // draw the button background
+ if ( !HasFlag(wxBORDER_NONE) )
+ {
+#if wxUSE_UXTHEME
+ if ( wxUxThemeEngine::GetIfActive() )
+ {
+ DrawXPBackground(this, hdc, rectBtn, state);
+ }
+ else
+#endif // wxUSE_UXTHEME
+ {
+ COLORREF colBg = wxColourToRGB(GetBackgroundColour());
+
+ // first, draw the background
+ AutoHBRUSH hbrushBackground(colBg);
+ FillRect(hdc, &rectBtn, hbrushBackground);
+
+ // draw the border for the current state
+ bool selected = (state & ODS_SELECTED) != 0;
+ if ( !selected )
+ {
+ wxTopLevelWindow *
+ tlw = wxDynamicCast(wxGetTopLevelParent(this), wxTopLevelWindow);
+ if ( tlw )
+ {
+ selected = tlw->GetDefaultItem() == this;
+ }
+ }
+
+ DrawButtonFrame(hdc, rectBtn, selected, pushed);
+ }
+
+ // draw the focus rectangle if we need it
+ if ( (state & ODS_FOCUS) && !(state & ODS_NOFOCUSRECT) )
+ {
+ DrawFocusRect(hdc, &rectBtn);
+
+#if wxUSE_UXTHEME
+ if ( !wxUxThemeEngine::GetIfActive() )
+#endif // wxUSE_UXTHEME
+ {
+ if ( pushed )
+ {
+ // the label is shifted by 1 pixel to create "pushed" effect
+ OffsetRect(&rectBtn, 1, 1);
+ }
+ }
+ }
+ }
+
+
+ // draw the image, if any
+ if ( m_imageData )
+ {
+ wxBitmap bmp = m_imageData->GetBitmap(GetButtonState(this, state));
+ if ( !bmp.IsOk() )
+ bmp = m_imageData->GetBitmap(GetNormalState());
+
+ const wxSize sizeBmp = bmp.GetSize();
+ const wxSize margin = m_imageData->GetBitmapMargins();
+ const wxSize sizeBmpWithMargins(sizeBmp + 2*margin);
+ wxRect rectButton(wxRectFromRECT(rectBtn));
+
+ // for simplicity, we start with centred rectangle and then move it to
+ // the appropriate edge
+ wxRect rectBitmap = wxRect(sizeBmp).CentreIn(rectButton);
+
+ // move bitmap only if we have a label, otherwise keep it centered
+ if ( ShowsLabel() )
+ {
+ switch ( m_imageData->GetBitmapPosition() )
+ {
+ default:
+ wxFAIL_MSG( "invalid direction" );
+ // fall through
+
+ case wxLEFT:
+ rectBitmap.x = rectButton.x + margin.x;
+ rectButton.x += sizeBmpWithMargins.x;
+ rectButton.width -= sizeBmpWithMargins.x;
+ break;
+
+ case wxRIGHT:
+ rectBitmap.x = rectButton.GetRight() - sizeBmp.x - margin.x;
+ rectButton.width -= sizeBmpWithMargins.x;
+ break;
+
+ case wxTOP:
+ rectBitmap.y = rectButton.y + margin.y;
+ rectButton.y += sizeBmpWithMargins.y;
+ rectButton.height -= sizeBmpWithMargins.y;
+ break;
+
+ case wxBOTTOM:
+ rectBitmap.y = rectButton.GetBottom() - sizeBmp.y - margin.y;
+ rectButton.height -= sizeBmpWithMargins.y;
+ break;
+ }
+ }
+
+ wxDCTemp dst((WXHDC)hdc);
+ dst.DrawBitmap(bmp, rectBitmap.GetPosition(), true);
+
+ wxCopyRectToRECT(rectButton, rectBtn);
+ }
+
+
+ // finally draw the label
+ if ( ShowsLabel() )
+ {
+ COLORREF colFg = state & ODS_DISABLED
+ ? ::GetSysColor(COLOR_GRAYTEXT)
+ : wxColourToRGB(GetForegroundColour());
+
+ wxTextColoursChanger changeFg(hdc, colFg, CLR_INVALID);
+ wxBkModeChanger changeBkMode(hdc, wxBRUSHSTYLE_TRANSPARENT);
+
+#if wxUSE_MARKUP
+ if ( m_markupText )
+ {
+ wxDCTemp dc((WXHDC)hdc);
+ dc.SetTextForeground(wxColour(colFg));
+ dc.SetFont(GetFont());
+
+ m_markupText->Render(dc, wxRectFromRECT(rectBtn),
+ state & ODS_NOACCEL
+ ? wxMarkupText::Render_Default
+ : wxMarkupText::Render_ShowAccels);
+ }
+ else // Plain text label
+#endif // wxUSE_MARKUP
+ {
+ // notice that DT_HIDEPREFIX doesn't work on old (pre-Windows 2000)
+ // systems but by happy coincidence ODS_NOACCEL is not used under
+ // them neither so DT_HIDEPREFIX should never be used there
+ DrawButtonText(hdc, &rectBtn, this,
+ state & ODS_NOACCEL ? DT_HIDEPREFIX : 0);
+ }
+ }
+
+ return true;
+}
+
+#endif // wxHAS_ANY_BUTTON
return true;
}
-void wxBitmapButton::DoSetBitmap(const wxBitmap& bitmap, State which)
-{
- if ( bitmap.IsOk() )
- {
- switch ( which )
- {
-#if wxUSE_IMAGE
- case State_Normal:
- if ( !HasFlag(wxBU_AUTODRAW) && !m_disabledSetByUser )
- {
- wxImage img(bitmap.ConvertToImage().ConvertToGreyscale());
- wxBitmapButtonBase::DoSetBitmap(img, State_Disabled);
- }
- break;
-#endif // wxUSE_IMAGE
-
- case State_Focused:
- // if the focus bitmap is specified but current one isn't, use
- // the focus bitmap for hovering as well if this is consistent
- // with the current Windows version look and feel
- //
- // rationale: this is compatible with the old wxGTK behaviour
- // and also makes it much easier to do "the right thing" for
- // all platforms (some of them, such as Windows XP, have "hot"
- // buttons while others don't)
- if ( !m_hoverSetByUser )
- wxBitmapButtonBase::DoSetBitmap(bitmap, State_Current);
- break;
-
- case State_Current:
- // don't overwrite it with the focused bitmap
- m_hoverSetByUser = true;
- break;
-
- case State_Disabled:
- // don't overwrite it with the version automatically created
- // from the normal one
- m_disabledSetByUser = true;
- break;
-
- default:
- // nothing special to do but include the default clause to
- // suppress gcc warnings
- ;
- }
- }
-
- wxBitmapButtonBase::DoSetBitmap(bitmap, which);
-}
-
#endif // wxUSE_BMPBUTTON
#include "wx/generic/private/markuptext.h"
#endif // wxUSE_MARKUP
-using namespace wxMSWImpl;
-
-#if wxUSE_UXTHEME
- #include "wx/msw/uxtheme.h"
-
- // no need to include tmschema.h
- #ifndef BP_PUSHBUTTON
- #define BP_PUSHBUTTON 1
-
- #define PBS_NORMAL 1
- #define PBS_HOT 2
- #define PBS_PRESSED 3
- #define PBS_DISABLED 4
- #define PBS_DEFAULTED 5
-
- #define TMT_CONTENTMARGINS 3602
- #endif
-
- // provide the necessary declarations ourselves if they're missing from
- // headers
- #ifndef BCM_SETIMAGELIST
- #define BCM_SETIMAGELIST 0x1602
- #define BCM_SETTEXTMARGIN 0x1604
-
- enum
- {
- BUTTON_IMAGELIST_ALIGN_LEFT,
- BUTTON_IMAGELIST_ALIGN_RIGHT,
- BUTTON_IMAGELIST_ALIGN_TOP,
- BUTTON_IMAGELIST_ALIGN_BOTTOM
- };
-
- struct BUTTON_IMAGELIST
- {
- HIMAGELIST himl;
- RECT margin;
- UINT uAlign;
- };
- #endif
-#endif // wxUSE_UXTHEME
-
-#ifndef WM_THEMECHANGED
- #define WM_THEMECHANGED 0x031A
-#endif
-
-#ifndef ODS_NOACCEL
- #define ODS_NOACCEL 0x0100
-#endif
-
-#ifndef ODS_NOFOCUSRECT
- #define ODS_NOFOCUSRECT 0x0200
-#endif
-
-#ifndef DT_HIDEPREFIX
- #define DT_HIDEPREFIX 0x00100000
-#endif
-
// set the value for BCM_SETSHIELD (for the UAC shield) if it's not defined in
// the header
#ifndef BCM_SETSHIELD
#define BCM_SETSHIELD 0x160c
#endif
-#if wxUSE_UXTHEME
-extern wxWindowMSW *wxWindowBeingErased; // From src/msw/window.cpp
-#endif // wxUSE_UXTHEME
-
-// ----------------------------------------------------------------------------
-// button image data
-// ----------------------------------------------------------------------------
-
-// we use different data classes for owner drawn buttons and for themed XP ones
-
-class wxButtonImageData
-{
-public:
- wxButtonImageData() { }
- virtual ~wxButtonImageData() { }
-
- virtual wxBitmap GetBitmap(wxButton::State which) const = 0;
- virtual void SetBitmap(const wxBitmap& bitmap, wxButton::State which) = 0;
-
- virtual wxSize GetBitmapMargins() const = 0;
- virtual void SetBitmapMargins(wxCoord x, wxCoord y) = 0;
-
- virtual wxDirection GetBitmapPosition() const = 0;
- virtual void SetBitmapPosition(wxDirection dir) = 0;
-
-private:
- wxDECLARE_NO_COPY_CLASS(wxButtonImageData);
-};
-
-namespace
-{
-
-// the gap between button edge and the interior area used by Windows for the
-// standard buttons
-const int OD_BUTTON_MARGIN = 4;
-
-class wxODButtonImageData : public wxButtonImageData
-{
-public:
- wxODButtonImageData(wxButton *btn, const wxBitmap& bitmap)
- {
- SetBitmap(bitmap, wxButton::State_Normal);
- SetBitmap(bitmap.ConvertToDisabled(), wxButton::State_Disabled);
-
- m_dir = wxLEFT;
-
- // we use margins when we have both bitmap and text, but when we have
- // only the bitmap it should take up the entire button area
- if ( btn->ShowsLabel() )
- {
- m_margin.x = btn->GetCharWidth();
- m_margin.y = btn->GetCharHeight() / 2;
- }
- }
-
- virtual wxBitmap GetBitmap(wxButton::State which) const
- {
- return m_bitmaps[which];
- }
-
- virtual void SetBitmap(const wxBitmap& bitmap, wxButton::State which)
- {
- m_bitmaps[which] = bitmap;
- }
-
- virtual wxSize GetBitmapMargins() const
- {
- return m_margin;
- }
-
- virtual void SetBitmapMargins(wxCoord x, wxCoord y)
- {
- m_margin = wxSize(x, y);
- }
-
- virtual wxDirection GetBitmapPosition() const
- {
- return m_dir;
- }
-
- virtual void SetBitmapPosition(wxDirection dir)
- {
- m_dir = dir;
- }
-
-private:
- // just store the values passed to us to be able to retrieve them later
- // from the drawing code
- wxBitmap m_bitmaps[wxButton::State_Max];
- wxSize m_margin;
- wxDirection m_dir;
-
- wxDECLARE_NO_COPY_CLASS(wxODButtonImageData);
-};
-
-#if wxUSE_UXTHEME
-
-// somehow the margin is one pixel greater than the value returned by
-// GetThemeMargins() call
-const int XP_BUTTON_EXTRA_MARGIN = 1;
-
-class wxXPButtonImageData : public wxButtonImageData
-{
-public:
- // we must be constructed with the size of our images as we need to create
- // the image list
- wxXPButtonImageData(wxButton *btn, const wxBitmap& bitmap)
- : m_iml(bitmap.GetWidth(), bitmap.GetHeight(), true /* use mask */,
- wxButton::State_Max),
- m_hwndBtn(GetHwndOf(btn))
- {
- // initialize all bitmaps except for the disabled one to normal state
- for ( int n = 0; n < wxButton::State_Max; n++ )
- {
- m_iml.Add(n == wxButton::State_Disabled ? bitmap.ConvertToDisabled()
- : bitmap);
- }
-
- m_data.himl = GetHimagelistOf(&m_iml);
-
- // no margins by default
- m_data.margin.left =
- m_data.margin.right =
- m_data.margin.top =
- m_data.margin.bottom = 0;
-
- // use default alignment
- m_data.uAlign = BUTTON_IMAGELIST_ALIGN_LEFT;
-
- UpdateImageInfo();
- }
-
- virtual wxBitmap GetBitmap(wxButton::State which) const
- {
- return m_iml.GetBitmap(which);
- }
-
- virtual void SetBitmap(const wxBitmap& bitmap, wxButton::State which)
- {
- m_iml.Replace(which, bitmap);
-
- UpdateImageInfo();
- }
-
- virtual wxSize GetBitmapMargins() const
- {
- return wxSize(m_data.margin.left, m_data.margin.top);
- }
-
- virtual void SetBitmapMargins(wxCoord x, wxCoord y)
- {
- RECT& margin = m_data.margin;
- margin.left =
- margin.right = x;
- margin.top =
- margin.bottom = y;
-
- if ( !::SendMessage(m_hwndBtn, BCM_SETTEXTMARGIN, 0, (LPARAM)&margin) )
- {
- wxLogDebug("SendMessage(BCM_SETTEXTMARGIN) failed");
- }
- }
-
- virtual wxDirection GetBitmapPosition() const
- {
- switch ( m_data.uAlign )
- {
- default:
- wxFAIL_MSG( "invalid image alignment" );
- // fall through
-
- case BUTTON_IMAGELIST_ALIGN_LEFT:
- return wxLEFT;
-
- case BUTTON_IMAGELIST_ALIGN_RIGHT:
- return wxRIGHT;
-
- case BUTTON_IMAGELIST_ALIGN_TOP:
- return wxTOP;
-
- case BUTTON_IMAGELIST_ALIGN_BOTTOM:
- return wxBOTTOM;
- }
- }
-
- virtual void SetBitmapPosition(wxDirection dir)
- {
- UINT alignNew;
- switch ( dir )
- {
- default:
- wxFAIL_MSG( "invalid direction" );
- // fall through
-
- case wxLEFT:
- alignNew = BUTTON_IMAGELIST_ALIGN_LEFT;
- break;
-
- case wxRIGHT:
- alignNew = BUTTON_IMAGELIST_ALIGN_RIGHT;
- break;
-
- case wxTOP:
- alignNew = BUTTON_IMAGELIST_ALIGN_TOP;
- break;
-
- case wxBOTTOM:
- alignNew = BUTTON_IMAGELIST_ALIGN_BOTTOM;
- break;
- }
-
- if ( alignNew != m_data.uAlign )
- {
- m_data.uAlign = alignNew;
- UpdateImageInfo();
- }
- }
-
-private:
- void UpdateImageInfo()
- {
- if ( !::SendMessage(m_hwndBtn, BCM_SETIMAGELIST, 0, (LPARAM)&m_data) )
- {
- wxLogDebug("SendMessage(BCM_SETIMAGELIST) failed");
- }
- }
-
- // we store image list separately to be able to use convenient wxImageList
- // methods instead of working with raw HIMAGELIST
- wxImageList m_iml;
-
- // store the rest of the data in BCM_SETIMAGELIST-friendly form
- BUTTON_IMAGELIST m_data;
-
- // the button we're associated with
- const HWND m_hwndBtn;
-
-
- wxDECLARE_NO_COPY_CLASS(wxXPButtonImageData);
-};
-
-#endif // wxUSE_UXTHEME
-
-} // anonymous namespace
-
// ----------------------------------------------------------------------------
// macros
// ----------------------------------------------------------------------------
// implementation
// ============================================================================
-// ----------------------------------------------------------------------------
-// helper functions from wx/msw/private/button.h
-// ----------------------------------------------------------------------------
-
-void wxMSWButton::UpdateMultilineStyle(HWND hwnd, const wxString& label)
-{
- // update BS_MULTILINE style depending on the new label (resetting it
- // doesn't seem to do anything very useful but it shouldn't hurt and we do
- // have to set it whenever the label becomes multi line as otherwise it
- // wouldn't be shown correctly as we don't use BS_MULTILINE when creating
- // the control unless it already has new lines in its label)
- long styleOld = ::GetWindowLong(hwnd, GWL_STYLE),
- styleNew;
- if ( label.find(wxT('\n')) != wxString::npos )
- styleNew = styleOld | BS_MULTILINE;
- else
- styleNew = styleOld & ~BS_MULTILINE;
-
- if ( styleNew != styleOld )
- ::SetWindowLong(hwnd, GWL_STYLE, styleNew);
-}
-
-wxSize wxMSWButton::GetFittingSize(wxWindow *win,
- const wxSize& sizeLabel,
- int flags)
-{
- // FIXME: this is pure guesswork, need to retrieve the real button margins
- wxSize sizeBtn = sizeLabel;
-
- sizeBtn.x += 3*win->GetCharWidth();
- sizeBtn.y += win->GetCharHeight()/2;
-
- // account for the shield UAC icon if we have it
- if ( flags & Size_AuthNeeded )
- sizeBtn.x += wxSystemSettings::GetMetric(wxSYS_SMALLICON_X);
-
- return sizeBtn;
-}
-
-wxSize wxMSWButton::ComputeBestFittingSize(wxControl *btn, int flags)
-{
- wxClientDC dc(btn);
-
- wxSize sizeBtn;
- dc.GetMultiLineTextExtent(btn->GetLabelText(), &sizeBtn.x, &sizeBtn.y);
-
- return GetFittingSize(btn, sizeBtn, flags);
-}
-
-wxSize wxMSWButton::IncreaseToStdSizeAndCache(wxControl *btn, const wxSize& size)
-{
- wxSize sizeBtn(size);
-
- // All buttons have at least the standard height and, unless the user
- // explicitly wants them to be as small as possible and used wxBU_EXACTFIT
- // style to indicate this, of at least the standard width too.
- //
- // Notice that we really want to make all buttons equally high, otherwise
- // they look ugly and the existing code using wxBU_EXACTFIT only uses it to
- // control width and not height.
-
- // The 50x14 button size is documented in the "Recommended sizing and
- // spacing" section of MSDN layout article.
- //
- // Note that we intentionally don't use GetDefaultSize() here, because
- // it's inexact -- dialog units depend on this dialog's font.
- const wxSize sizeDef = btn->ConvertDialogToPixels(wxSize(50, 14));
- if ( !btn->HasFlag(wxBU_EXACTFIT) )
- {
- if ( sizeBtn.x < sizeDef.x )
- sizeBtn.x = sizeDef.x;
- }
- if ( sizeBtn.y < sizeDef.y )
- sizeBtn.y = sizeDef.y;
-
- btn->CacheBestSize(sizeBtn);
-
- return sizeBtn;
-}
-
// ----------------------------------------------------------------------------
// creation/destruction
// ----------------------------------------------------------------------------
{
UnsetTmpDefault();
}
-
- delete m_imageData;
-#if wxUSE_MARKUP
- delete m_markupText;
-#endif // wxUSE_MARKUP
}
// ----------------------------------------------------------------------------
return msStyle;
}
-void wxButton::SetLabel(const wxString& label)
-{
- wxMSWButton::UpdateMultilineStyle(GetHwnd(), label);
-
- wxButtonBase::SetLabel(label);
-
-#if wxUSE_MARKUP
- // If we have a plain text label, we shouldn't be using markup any longer.
- if ( m_markupText )
- {
- delete m_markupText;
- m_markupText = NULL;
-
- // Unfortunately we don't really know whether we can reset the button
- // to be non-owner-drawn or not: if we had made it owner-drawn just
- // because of a call to SetLabelMarkup(), we could, but not if there
- // were [also] calls to Set{Fore,Back}groundColour(). If it's really a
- // problem to have button remain owner-drawn forever just because it
- // had markup label once, we should record the reason for our current
- // owner-drawnness and check it here.
- }
-#endif // wxUSE_MARKUP
-}
-
-// ----------------------------------------------------------------------------
-// size management including autosizing
-// ----------------------------------------------------------------------------
-
-void wxButton::AdjustForBitmapSize(wxSize &size) const
-{
- wxCHECK_RET( m_imageData, wxT("shouldn't be called if no image") );
-
- // account for the bitmap size
- const wxSize sizeBmp = m_imageData->GetBitmap(State_Normal).GetSize();
- const wxDirection dirBmp = m_imageData->GetBitmapPosition();
- if ( dirBmp == wxLEFT || dirBmp == wxRIGHT )
- {
- size.x += sizeBmp.x;
- if ( sizeBmp.y > size.y )
- size.y = sizeBmp.y;
- }
- else // bitmap on top/below the text
- {
- size.y += sizeBmp.y;
- if ( sizeBmp.x > size.x )
- size.x = sizeBmp.x;
- }
-
- // account for the user-specified margins
- size += 2*m_imageData->GetBitmapMargins();
-
- // and also for the margins we always add internally (unless we have no
- // border at all in which case the button has exactly the same size as
- // bitmap and so no margins should be used)
- if ( !HasFlag(wxBORDER_NONE) )
- {
- int marginH = 0,
- marginV = 0;
-#if wxUSE_UXTHEME
- if ( wxUxThemeEngine::GetIfActive() )
- {
- wxUxThemeHandle theme(const_cast<wxButton *>(this), L"BUTTON");
-
- MARGINS margins;
- wxUxThemeEngine::Get()->GetThemeMargins(theme, NULL,
- BP_PUSHBUTTON,
- PBS_NORMAL,
- TMT_CONTENTMARGINS,
- NULL,
- &margins);
-
- // XP doesn't draw themed buttons correctly when the client
- // area is smaller than 8x8 - enforce this minimum size for
- // small bitmaps
- size.IncTo(wxSize(8, 8));
-
- marginH = margins.cxLeftWidth + margins.cxRightWidth
- + 2*XP_BUTTON_EXTRA_MARGIN;
- marginV = margins.cyTopHeight + margins.cyBottomHeight
- + 2*XP_BUTTON_EXTRA_MARGIN;
- }
- else
-#endif // wxUSE_UXTHEME
- {
- marginH =
- marginV = OD_BUTTON_MARGIN;
- }
-
- size.IncBy(marginH, marginV);
- }
-}
-
-wxSize wxButton::DoGetBestSize() const
-{
- wxButton * const self = const_cast<wxButton *>(this);
-
- wxSize size;
-
- // Account for the text part if we have it.
- if ( ShowsLabel() )
- {
- int flags = 0;
- if ( GetAuthNeeded() )
- flags |= wxMSWButton::Size_AuthNeeded;
-
-#if wxUSE_MARKUP
- if ( m_markupText )
- {
- wxClientDC dc(self);
- size = wxMSWButton::GetFittingSize(self,
- m_markupText->Measure(dc),
- flags);
- }
- else // Normal plain text (but possibly multiline) label.
-#endif // wxUSE_MARKUP
- {
- size = wxMSWButton::ComputeBestFittingSize(self, flags);
- }
- }
-
- if ( m_imageData )
- AdjustForBitmapSize(size);
-
- return wxMSWButton::IncreaseToStdSizeAndCache(self, size);
-}
-
/* static */
wxSize wxButtonBase::GetDefaultSize()
{
{
UnsetTmpDefault();
}
- else if ( nMsg == WM_LBUTTONDBLCLK )
- {
- // emulate a click event to force an owner-drawn button to change its
- // appearance - without this, it won't do it
- (void)wxControl::MSWWindowProc(WM_LBUTTONDOWN, wParam, lParam);
-
- // and continue with processing the message normally as well
- }
-#if wxUSE_UXTHEME
- else if ( nMsg == WM_THEMECHANGED )
- {
- // need to recalculate the best size here
- // as the theme size might have changed
- InvalidateBestSize();
- }
-#endif // wxUSE_UXTHEME
- // must use m_mouseInWindow here instead of IsMouseInWindow()
- // since we need to know the first time the mouse enters the window
- // and IsMouseInWindow() would return true in this case
- else if ( (nMsg == WM_MOUSEMOVE && !m_mouseInWindow) ||
- nMsg == WM_MOUSELEAVE )
- {
- if (
- IsEnabled() &&
- (
-#if wxUSE_UXTHEME
- wxUxThemeEngine::GetIfActive() ||
-#endif // wxUSE_UXTHEME
- (m_imageData && m_imageData->GetBitmap(State_Current).IsOk())
- )
- )
- {
- Refresh();
- }
- }
// let the base class do all real processing
- return wxControl::MSWWindowProc(nMsg, wParam, lParam);
+ return wxAnyButton::MSWWindowProc(nMsg, wParam, lParam);
}
// ----------------------------------------------------------------------------
}
}
-// ----------------------------------------------------------------------------
-// button images
-// ----------------------------------------------------------------------------
-
-wxBitmap wxButton::DoGetBitmap(State which) const
-{
- return m_imageData ? m_imageData->GetBitmap(which) : wxBitmap();
-}
-
-void wxButton::DoSetBitmap(const wxBitmap& bitmap, State which)
-{
-#if wxUSE_UXTHEME
- wxXPButtonImageData *oldData = NULL;
-#endif // wxUSE_UXTHEME
-
- // Check if we already had bitmaps of different size.
- if ( m_imageData &&
- bitmap.GetSize() != m_imageData->GetBitmap(State_Normal).GetSize() )
- {
- wxASSERT_MSG( which == State_Normal,
- "Must set normal bitmap with the new size first" );
-
-#if wxUSE_UXTHEME
- if ( ShowsLabel() && wxUxThemeEngine::GetIfActive() )
- {
- // We can't change the size of the images stored in wxImageList
- // in wxXPButtonImageData::m_iml so force recreating it below but
- // keep the current data to copy its values into the new one.
- oldData = static_cast<wxXPButtonImageData *>(m_imageData);
- m_imageData = NULL;
- }
-#endif // wxUSE_UXTHEME
- //else: wxODButtonImageData doesn't require anything special
- }
-
- // allocate the image data when the first bitmap is set
- if ( !m_imageData )
- {
-#if wxUSE_UXTHEME
- // using image list doesn't work correctly if we don't have any label
- // (even if we use BUTTON_IMAGELIST_ALIGN_CENTER alignment and
- // BS_BITMAP style), at least under Windows 2003 so use owner drawn
- // strategy for bitmap-only buttons
- if ( ShowsLabel() && wxUxThemeEngine::GetIfActive() )
- {
- m_imageData = new wxXPButtonImageData(this, bitmap);
-
- if ( oldData )
- {
- // Preserve the old values in case the user changed them.
- m_imageData->SetBitmapPosition(oldData->GetBitmapPosition());
-
- const wxSize oldMargins = oldData->GetBitmapMargins();
- m_imageData->SetBitmapMargins(oldMargins.x, oldMargins.y);
-
- // No need to preserve the bitmaps though as they were of wrong
- // size anyhow.
-
- delete oldData;
- }
- }
- else
-#endif // wxUSE_UXTHEME
- {
- m_imageData = new wxODButtonImageData(this, bitmap);
- MakeOwnerDrawn();
- }
- }
- else
- {
- m_imageData->SetBitmap(bitmap, which);
- }
-
- // it should be enough to only invalidate the best size when the normal
- // bitmap changes as all bitmaps assigned to the button should be of the
- // same size anyhow
- if ( which == State_Normal )
- InvalidateBestSize();
-
- Refresh();
-}
-
-wxSize wxButton::DoGetBitmapMargins() const
-{
- return m_imageData ? m_imageData->GetBitmapMargins() : wxSize(0, 0);
-}
-
-void wxButton::DoSetBitmapMargins(wxCoord x, wxCoord y)
-{
- wxCHECK_RET( m_imageData, "SetBitmap() must be called first" );
-
- m_imageData->SetBitmapMargins(x, y);
- InvalidateBestSize();
-}
-
-void wxButton::DoSetBitmapPosition(wxDirection dir)
-{
- wxCHECK_RET( m_imageData, "SetBitmap() must be called first" );
-
- m_imageData->SetBitmapPosition(dir);
- InvalidateBestSize();
-}
-
-// ----------------------------------------------------------------------------
-// markup support
-// ----------------------------------------------------------------------------
-
-#if wxUSE_MARKUP
-
-bool wxButton::DoSetLabelMarkup(const wxString& markup)
-{
- if ( !wxButtonBase::DoSetLabelMarkup(markup) )
- return false;
-
- if ( !m_markupText )
- {
- m_markupText = new wxMarkupText(markup);
- MakeOwnerDrawn();
- }
- else
- {
- // We are already owner-drawn so just update the text.
- m_markupText->SetMarkup(markup);
- }
-
- Refresh();
-
- return true;
-}
-
-#endif // wxUSE_MARKUP
-
-// ----------------------------------------------------------------------------
-// owner-drawn buttons support
-// ----------------------------------------------------------------------------
-
-// drawing helpers
-namespace
-{
-
-// return the button state using both the ODS_XXX flags specified in state
-// parameter and the current button state
-wxButton::State GetButtonState(wxButton *btn, UINT state)
-{
- if ( state & ODS_DISABLED )
- return wxButton::State_Disabled;
-
- if ( state & ODS_SELECTED )
- return wxButton::State_Pressed;
-
- if ( btn->HasCapture() || btn->IsMouseInWindow() )
- return wxButton::State_Current;
-
- if ( state & ODS_FOCUS )
- return wxButton::State_Focused;
-
- return wxButton::State_Normal;
-}
-
-void DrawButtonText(HDC hdc,
- RECT *pRect,
- wxButton *btn,
- int flags)
-{
- const wxString text = btn->GetLabel();
-
- if ( text.find(wxT('\n')) != wxString::npos )
- {
- // draw multiline label
-
- // center text horizontally in any case
- flags |= DT_CENTER;
-
- // first we need to compute its bounding rect
- RECT rc;
- ::CopyRect(&rc, pRect);
- ::DrawText(hdc, text.wx_str(), text.length(), &rc,
- DT_CENTER | DT_CALCRECT);
-
- // now center this rect inside the entire button area
- const LONG w = rc.right - rc.left;
- const LONG h = rc.bottom - rc.top;
- rc.left = (pRect->right - pRect->left)/2 - w/2;
- rc.right = rc.left+w;
- rc.top = (pRect->bottom - pRect->top)/2 - h/2;
- rc.bottom = rc.top+h;
-
- ::DrawText(hdc, text.wx_str(), text.length(), &rc, flags);
- }
- else // single line label
- {
- // translate wx button flags to alignment flags for DrawText()
- if ( btn->HasFlag(wxBU_RIGHT) )
- {
- flags |= DT_RIGHT;
- }
- else if ( !btn->HasFlag(wxBU_LEFT) )
- {
- flags |= DT_CENTER;
- }
- //else: DT_LEFT is the default anyhow (and its value is 0 too)
-
- if ( btn->HasFlag(wxBU_BOTTOM) )
- {
- flags |= DT_BOTTOM;
- }
- else if ( !btn->HasFlag(wxBU_TOP) )
- {
- flags |= DT_VCENTER;
- }
- //else: as above, DT_TOP is the default
-
- // notice that we must have DT_SINGLELINE for vertical alignment flags
- // to work
- ::DrawText(hdc, text.wx_str(), text.length(), pRect,
- flags | DT_SINGLELINE );
- }
-}
-
-void DrawRect(HDC hdc, const RECT& r)
-{
- wxDrawLine(hdc, r.left, r.top, r.right, r.top);
- wxDrawLine(hdc, r.right, r.top, r.right, r.bottom);
- wxDrawLine(hdc, r.right, r.bottom, r.left, r.bottom);
- wxDrawLine(hdc, r.left, r.bottom, r.left, r.top);
-}
-
-/*
- The button frame looks like this normally:
-
- WWWWWWWWWWWWWWWWWWB
- WHHHHHHHHHHHHHHHHGB W = white (HILIGHT)
- WH GB H = light grey (LIGHT)
- WH GB G = dark grey (SHADOW)
- WH GB B = black (DKSHADOW)
- WH GB
- WGGGGGGGGGGGGGGGGGB
- BBBBBBBBBBBBBBBBBBB
-
- When the button is selected, the button becomes like this (the total button
- size doesn't change):
-
- BBBBBBBBBBBBBBBBBBB
- BWWWWWWWWWWWWWWWWBB
- BWHHHHHHHHHHHHHHGBB
- BWH GBB
- BWH GBB
- BWGGGGGGGGGGGGGGGBB
- BBBBBBBBBBBBBBBBBBB
- BBBBBBBBBBBBBBBBBBB
-
- When the button is pushed (while selected) it is like:
-
- BBBBBBBBBBBBBBBBBBB
- BGGGGGGGGGGGGGGGGGB
- BG GB
- BG GB
- BG GB
- BG GB
- BGGGGGGGGGGGGGGGGGB
- BBBBBBBBBBBBBBBBBBB
-*/
-void DrawButtonFrame(HDC hdc, RECT& rectBtn,
- bool selected, bool pushed)
-{
- RECT r;
- CopyRect(&r, &rectBtn);
-
- AutoHPEN hpenBlack(GetSysColor(COLOR_3DDKSHADOW)),
- hpenGrey(GetSysColor(COLOR_3DSHADOW)),
- hpenLightGr(GetSysColor(COLOR_3DLIGHT)),
- hpenWhite(GetSysColor(COLOR_3DHILIGHT));
-
- SelectInHDC selectPen(hdc, hpenBlack);
-
- r.right--;
- r.bottom--;
-
- if ( pushed )
- {
- DrawRect(hdc, r);
-
- (void)SelectObject(hdc, hpenGrey);
- ::InflateRect(&r, -1, -1);
-
- DrawRect(hdc, r);
- }
- else // !pushed
- {
- if ( selected )
- {
- DrawRect(hdc, r);
-
- ::InflateRect(&r, -1, -1);
- }
-
- wxDrawLine(hdc, r.left, r.bottom, r.right, r.bottom);
- wxDrawLine(hdc, r.right, r.bottom, r.right, r.top - 1);
-
- (void)SelectObject(hdc, hpenWhite);
- wxDrawLine(hdc, r.left, r.bottom - 1, r.left, r.top);
- wxDrawLine(hdc, r.left, r.top, r.right, r.top);
-
- (void)SelectObject(hdc, hpenLightGr);
- wxDrawLine(hdc, r.left + 1, r.bottom - 2, r.left + 1, r.top + 1);
- wxDrawLine(hdc, r.left + 1, r.top + 1, r.right - 1, r.top + 1);
-
- (void)SelectObject(hdc, hpenGrey);
- wxDrawLine(hdc, r.left + 1, r.bottom - 1, r.right - 1, r.bottom - 1);
- wxDrawLine(hdc, r.right - 1, r.bottom - 1, r.right - 1, r.top);
- }
-
- InflateRect(&rectBtn, -OD_BUTTON_MARGIN, -OD_BUTTON_MARGIN);
-}
-
-#if wxUSE_UXTHEME
-void DrawXPBackground(wxButton *button, HDC hdc, RECT& rectBtn, UINT state)
-{
- wxUxThemeHandle theme(button, L"BUTTON");
-
- // this array is indexed by wxButton::State values and so must be kept in
- // sync with it
- static const int uxStates[] =
- {
- PBS_NORMAL, PBS_HOT, PBS_PRESSED, PBS_DISABLED, PBS_DEFAULTED
- };
-
- int iState = uxStates[GetButtonState(button, state)];
-
- wxUxThemeEngine * const engine = wxUxThemeEngine::Get();
-
- // draw parent background if needed
- if ( engine->IsThemeBackgroundPartiallyTransparent
- (
- theme,
- BP_PUSHBUTTON,
- iState
- ) )
- {
- // Set this button as the one whose background is being erased: this
- // allows our WM_ERASEBKGND handler used by DrawThemeParentBackground()
- // to correctly align the background brush with this window instead of
- // the parent window to which WM_ERASEBKGND is sent. Notice that this
- // doesn't work with custom user-defined EVT_ERASE_BACKGROUND handlers
- // as they won't be aligned but unfortunately all the attempts to fix
- // it by shifting DC origin before calling DrawThemeParentBackground()
- // failed to work so we at least do this, even though this is far from
- // being the perfect solution.
- wxWindowBeingErased = button;
-
- engine->DrawThemeParentBackground(GetHwndOf(button), hdc, &rectBtn);
-
- wxWindowBeingErased = NULL;
- }
-
- // draw background
- engine->DrawThemeBackground(theme, hdc, BP_PUSHBUTTON, iState,
- &rectBtn, NULL);
-
- // calculate content area margins
- MARGINS margins;
- engine->GetThemeMargins(theme, hdc, BP_PUSHBUTTON, iState,
- TMT_CONTENTMARGINS, &rectBtn, &margins);
- ::InflateRect(&rectBtn, -margins.cxLeftWidth, -margins.cyTopHeight);
- ::InflateRect(&rectBtn, -XP_BUTTON_EXTRA_MARGIN, -XP_BUTTON_EXTRA_MARGIN);
-
- if ( button->UseBgCol() )
- {
- COLORREF colBg = wxColourToRGB(button->GetBackgroundColour());
- AutoHBRUSH hbrushBackground(colBg);
-
- // don't overwrite the focus rect
- RECT rectClient;
- ::CopyRect(&rectClient, &rectBtn);
- ::InflateRect(&rectClient, -1, -1);
- FillRect(hdc, &rectClient, hbrushBackground);
- }
-}
-#endif // wxUSE_UXTHEME
-
-} // anonymous namespace
-
-// ----------------------------------------------------------------------------
-// owner drawn buttons support
-// ----------------------------------------------------------------------------
-
-void wxButton::MakeOwnerDrawn()
-{
- long style = GetWindowLong(GetHwnd(), GWL_STYLE);
- if ( (style & BS_OWNERDRAW) != BS_OWNERDRAW )
- {
- // make it so
- style |= BS_OWNERDRAW;
- SetWindowLong(GetHwnd(), GWL_STYLE, style);
- }
-}
-
-bool wxButton::SetBackgroundColour(const wxColour &colour)
-{
- if ( !wxControl::SetBackgroundColour(colour) )
- {
- // nothing to do
- return false;
- }
-
- MakeOwnerDrawn();
-
- Refresh();
-
- return true;
-}
-
-bool wxButton::SetForegroundColour(const wxColour &colour)
-{
- if ( !wxControl::SetForegroundColour(colour) )
- {
- // nothing to do
- return false;
- }
-
- MakeOwnerDrawn();
-
- Refresh();
-
- return true;
-}
-
-bool wxButton::MSWOnDraw(WXDRAWITEMSTRUCT *wxdis)
-{
- LPDRAWITEMSTRUCT lpDIS = (LPDRAWITEMSTRUCT)wxdis;
- HDC hdc = lpDIS->hDC;
-
- UINT state = lpDIS->itemState;
- bool pushed = (SendMessage(GetHwnd(), BM_GETSTATE, 0, 0) & BST_PUSHED) != 0;
-
- RECT rectBtn;
- CopyRect(&rectBtn, &lpDIS->rcItem);
-
- // draw the button background
- if ( !HasFlag(wxBORDER_NONE) )
- {
-#if wxUSE_UXTHEME
- if ( wxUxThemeEngine::GetIfActive() )
- {
- DrawXPBackground(this, hdc, rectBtn, state);
- }
- else
-#endif // wxUSE_UXTHEME
- {
- COLORREF colBg = wxColourToRGB(GetBackgroundColour());
-
- // first, draw the background
- AutoHBRUSH hbrushBackground(colBg);
- FillRect(hdc, &rectBtn, hbrushBackground);
-
- // draw the border for the current state
- bool selected = (state & ODS_SELECTED) != 0;
- if ( !selected )
- {
- wxTopLevelWindow *
- tlw = wxDynamicCast(wxGetTopLevelParent(this), wxTopLevelWindow);
- if ( tlw )
- {
- selected = tlw->GetDefaultItem() == this;
- }
- }
-
- DrawButtonFrame(hdc, rectBtn, selected, pushed);
- }
-
- // draw the focus rectangle if we need it
- if ( (state & ODS_FOCUS) && !(state & ODS_NOFOCUSRECT) )
- {
- DrawFocusRect(hdc, &rectBtn);
-
-#if wxUSE_UXTHEME
- if ( !wxUxThemeEngine::GetIfActive() )
-#endif // wxUSE_UXTHEME
- {
- if ( pushed )
- {
- // the label is shifted by 1 pixel to create "pushed" effect
- OffsetRect(&rectBtn, 1, 1);
- }
- }
- }
- }
-
-
- // draw the image, if any
- if ( m_imageData )
- {
- wxBitmap bmp = m_imageData->GetBitmap(GetButtonState(this, state));
- if ( !bmp.IsOk() )
- bmp = m_imageData->GetBitmap(State_Normal);
-
- const wxSize sizeBmp = bmp.GetSize();
- const wxSize margin = m_imageData->GetBitmapMargins();
- const wxSize sizeBmpWithMargins(sizeBmp + 2*margin);
- wxRect rectButton(wxRectFromRECT(rectBtn));
-
- // for simplicity, we start with centred rectangle and then move it to
- // the appropriate edge
- wxRect rectBitmap = wxRect(sizeBmp).CentreIn(rectButton);
-
- // move bitmap only if we have a label, otherwise keep it centered
- if ( ShowsLabel() )
- {
- switch ( m_imageData->GetBitmapPosition() )
- {
- default:
- wxFAIL_MSG( "invalid direction" );
- // fall through
-
- case wxLEFT:
- rectBitmap.x = rectButton.x + margin.x;
- rectButton.x += sizeBmpWithMargins.x;
- rectButton.width -= sizeBmpWithMargins.x;
- break;
-
- case wxRIGHT:
- rectBitmap.x = rectButton.GetRight() - sizeBmp.x - margin.x;
- rectButton.width -= sizeBmpWithMargins.x;
- break;
-
- case wxTOP:
- rectBitmap.y = rectButton.y + margin.y;
- rectButton.y += sizeBmpWithMargins.y;
- rectButton.height -= sizeBmpWithMargins.y;
- break;
-
- case wxBOTTOM:
- rectBitmap.y = rectButton.GetBottom() - sizeBmp.y - margin.y;
- rectButton.height -= sizeBmpWithMargins.y;
- break;
- }
- }
-
- wxDCTemp dst((WXHDC)hdc);
- dst.DrawBitmap(bmp, rectBitmap.GetPosition(), true);
-
- wxCopyRectToRECT(rectButton, rectBtn);
- }
-
-
- // finally draw the label
- if ( ShowsLabel() )
- {
- COLORREF colFg = state & ODS_DISABLED
- ? ::GetSysColor(COLOR_GRAYTEXT)
- : wxColourToRGB(GetForegroundColour());
-
- wxTextColoursChanger changeFg(hdc, colFg, CLR_INVALID);
- wxBkModeChanger changeBkMode(hdc, wxBRUSHSTYLE_TRANSPARENT);
-
-#if wxUSE_MARKUP
- if ( m_markupText )
- {
- wxDCTemp dc((WXHDC)hdc);
- dc.SetTextForeground(wxColour(colFg));
- dc.SetFont(GetFont());
-
- m_markupText->Render(dc, wxRectFromRECT(rectBtn),
- state & ODS_NOACCEL
- ? wxMarkupText::Render_Default
- : wxMarkupText::Render_ShowAccels);
- }
- else // Plain text label
-#endif // wxUSE_MARKUP
- {
- // notice that DT_HIDEPREFIX doesn't work on old (pre-Windows 2000)
- // systems but by happy coincidence ODS_NOACCEL is not used under
- // them neither so DT_HIDEPREFIX should never be used there
- DrawButtonText(hdc, &rectBtn, this,
- state & ODS_NOACCEL ? DT_HIDEPREFIX : 0);
- }
- }
-
- return true;
-}
-
#endif // wxUSE_BUTTON
#include "wx/log.h"
#endif // WX_PRECOMP
-#include "wx/renderer.h"
-#include "wx/dcclient.h"
-
#include "wx/msw/private.h"
#include "wx/msw/private/button.h"
// wxBitmapToggleButton
//-----------------------------------------------------------------------------
-IMPLEMENT_DYNAMIC_CLASS(wxBitmapToggleButton, wxControl)
-
-BEGIN_EVENT_TABLE(wxBitmapToggleButton,wxToggleButtonBase)
- EVT_PAINT(wxBitmapToggleButton::OnPaint)
- EVT_MOUSE_EVENTS(wxBitmapToggleButton::OnMouse)
- EVT_CHAR(wxBitmapToggleButton::OnChar)
- EVT_SIZE(wxBitmapToggleButton::OnSize)
-END_EVENT_TABLE()
-
-void wxBitmapToggleButton::Init()
-{
- m_depressed = false;
- m_oldValue = false;
- m_capturing = false;
-}
+IMPLEMENT_DYNAMIC_CLASS(wxBitmapToggleButton, wxToggleButton)
bool wxBitmapToggleButton::Create( wxWindow *parent, wxWindowID id,
const wxBitmap& label,const wxPoint& pos, const wxSize& size, long style,
const wxValidator& validator, const wxString& name )
{
- Init();
-
- if (!wxToggleButtonBase::Create( parent, id, pos, size, style, validator, name ))
+ if (!wxToggleButton::Create( parent, id, wxEmptyString, pos, size, style, validator, name ))
return false;
- m_bitmap = label;
+ SetBitmap(label);
if (size.x == -1 || size.y == -1)
{
return true;
}
-void wxBitmapToggleButton::SetValue(bool state)
-{
- if (m_capturing) return;
-
- if (state == m_depressed) return;
-
- m_depressed = state;
- Refresh();
-}
-
-bool wxBitmapToggleButton::GetValue() const
-{
- return m_depressed;
-}
-
-void wxBitmapToggleButton::SetLabel(const wxBitmap& label)
-{
- m_bitmap = label;
- m_disabledBitmap = wxBitmap();
-
- Refresh();
-}
-
-bool wxBitmapToggleButton::Enable(bool enable)
-{
- if (m_capturing) return false;
-
- if (!wxToggleButtonBase::Enable( enable ))
- return false;
-
- Refresh();
-
- return true;
-}
-
-void wxBitmapToggleButton::OnPaint(wxPaintEvent &WXUNUSED(event))
-{
- wxSize size = GetSize();
-
- wxBitmap bitmap = m_bitmap;
-
- wxPaintDC dc(this);
- wxRendererNative &renderer = wxRendererNative::Get();
- int flags = 0;
- if (m_depressed)
- flags |= wxCONTROL_PRESSED;
- wxRect rect(0,0,size.x,size.y);
- renderer.DrawPushButton( this, dc, rect, flags );
-
- if (bitmap.IsOk())
- {
- if (!IsEnabled())
- {
- if (!m_disabledBitmap.IsOk())
- {
- wxImage image = m_bitmap.ConvertToImage();
- m_disabledBitmap = wxBitmap( image.ConvertToGreyscale() );
- }
-
- bitmap = m_disabledBitmap;
- }
-
- wxSize bsize = bitmap.GetSize();
- int offset = 0;
- if (m_depressed) offset = 1;
- dc.DrawBitmap( bitmap, (size.x-bsize.x) / 2 + offset, (size.y-bsize.y) / 2 + offset, true );
- }
-
-}
-
-void wxBitmapToggleButton::OnMouse(wxMouseEvent &event)
-{
- if (!IsEnabled())
- return;
-
- wxSize size = GetSize();
- bool mouse_in = ((event.GetX() > 0) && (event.GetX() < size.x) &&
- (event.GetY() > 0) && (event.GetY() < size.y));
-
- if (m_capturing)
- {
- bool old_depressed = m_depressed;
- if (mouse_in)
- m_depressed = !m_oldValue;
- else
- m_depressed = m_oldValue;
-
- if (event.LeftUp())
- {
- ReleaseMouse();
- m_capturing = false;
- if (mouse_in)
- {
- wxCommandEvent event(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, m_windowId);
- event.SetInt(GetValue());
- event.SetEventObject(this);
- ProcessCommand(event);
- }
- }
-
- if (old_depressed != m_depressed)
- Refresh();
- }
- else
- {
- if (event.LeftDown())
- {
- m_capturing = true;
- m_oldValue = m_depressed;
- m_depressed = !m_oldValue;
- CaptureMouse();
- Refresh();
- }
- }
-}
-
-void wxBitmapToggleButton::OnChar(wxKeyEvent &event)
-{
- if (event.GetKeyCode() == WXK_SPACE)
- {
- m_depressed = !m_depressed;
- Refresh();
-
- wxCommandEvent event(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, m_windowId);
- event.SetInt(GetValue());
- event.SetEventObject(this);
- ProcessCommand(event);
- }
-}
-
-void wxBitmapToggleButton::OnSize(wxSizeEvent &WXUNUSED(event))
-{
- Refresh();
-}
-
-wxSize wxBitmapToggleButton::DoGetBestSize() const
-{
- if (!m_bitmap.IsOk())
- return wxSize(16,16);
-
- wxSize ret = m_bitmap.GetSize();
- ret.x += 8;
- ret.y += 8;
- return ret;
-}
-
// ----------------------------------------------------------------------------
// wxToggleButton
IMPLEMENT_DYNAMIC_CLASS(wxToggleButton, wxControl)
+void wxToggleButton::Init()
+{
+ m_state = false;
+}
+
// Single check box item
bool wxToggleButton::Create(wxWindow *parent,
wxWindowID id,
const wxValidator& validator,
const wxString& name)
{
+ Init();
+
if ( !CreateControl(parent, id, pos, size, style, validator, name) )
return false;
return msStyle;
}
-wxSize wxToggleButton::DoGetBestSize() const
-{
- return wxMSWButton::ComputeBestSize(const_cast<wxToggleButton *>(this));
-}
-
-void wxToggleButton::SetLabel(const wxString& label)
-{
- wxMSWButton::UpdateMultilineStyle(GetHwnd(), label);
-
- wxToggleButtonBase::SetLabel(label);
-}
-
void wxToggleButton::SetValue(bool val)
{
- ::SendMessage(GetHwnd(), BM_SETCHECK, val, 0);
+ m_state = val;
+ if ( IsOwnerDrawn() )
+ {
+ Refresh();
+ }
+ else
+ {
+ ::SendMessage(GetHwnd(), BM_SETCHECK, val, 0);
+ }
}
bool wxToggleButton::GetValue() const
{
- return ::SendMessage(GetHwnd(), BM_GETCHECK, 0, 0) == BST_CHECKED;
+ if ( IsOwnerDrawn() )
+ {
+ return m_state;
+ }
+ else
+ {
+ return ::SendMessage(GetHwnd(), BM_GETCHECK, 0, 0) == BST_CHECKED;
+ }
}
void wxToggleButton::Command(wxCommandEvent& event)
ProcessCommand(event);
}
-bool wxToggleButton::MSWCommand(WXUINT WXUNUSED(param), WXWORD WXUNUSED(id))
+bool wxToggleButton::MSWCommand(WXUINT param, WXWORD WXUNUSED(id))
{
+ if ( param != BN_CLICKED && param != BN_DBLCLK )
+ return false;
+
+ // first update the value so that user event handler gets the new
+ // toggle button value
+
+ // ownerdrawn buttons don't manage their state themselves unlike usual
+ // auto checkboxes so do it ourselves in any case
+ m_state = !m_state;
+
wxCommandEvent event(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, m_windowId);
event.SetInt(GetValue());
event.SetEventObject(this);
return true;
}
+wxAnyButton::State wxToggleButton::GetNormalState() const
+{
+ if ( GetValue() )
+ return State_Pressed;
+ else
+ return State_Normal;
+}
+
#endif // wxUSE_TOGGLEBTN
--- /dev/null
+/////////////////////////////////////////////////////////////////////////////
+// Name: src/osx/anybutton_osx.cpp
+// Purpose: wxAnyButton
+// Author: Stefan Csomor
+// Created: 1998-01-01 (extracted from button_osx.cpp)
+// RCS-ID: $Id: anybutton_osx.cpp 67280 2011-03-22 14:17:38Z DS $
+// Copyright: (c) Stefan Csomor
+// Licence: wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#include "wx/wxprec.h"
+
+#include "wx/anybutton.h"
+
+#ifndef WX_PRECOMP
+ #include "wx/panel.h"
+ #include "wx/toplevel.h"
+ #include "wx/dcclient.h"
+ #include "wx/stattext.h"
+#endif
+
+#include "wx/stockitem.h"
+
+#include "wx/osx/private.h"
+
+BEGIN_EVENT_TABLE(wxAnyButton, wxControl)
+ EVT_ENTER_WINDOW(wxAnyButton::OnEnterWindow)
+ EVT_LEAVE_WINDOW(wxAnyButton::OnLeaveWindow)
+END_EVENT_TABLE()
+
+void wxAnyButton::SetLabel(const wxString& label)
+{
+ if ( HasFlag(wxBU_NOTEXT) )
+ {
+ // just store the label internally but don't really use it for the
+ // button
+ m_labelOrig =
+ m_label = label;
+ return;
+ }
+
+ wxAnyButtonBase::SetLabel(label);
+}
+
+wxBitmap wxAnyButton::DoGetBitmap(State which) const
+{
+ return m_bitmaps[which];
+}
+
+void wxAnyButton::DoSetBitmap(const wxBitmap& bitmap, State which)
+{
+ m_bitmaps[which] = bitmap;
+
+ if ( which == State_Normal )
+ GetPeer()->SetBitmap(bitmap);
+ else if ( which == State_Pressed )
+ {
+ wxButtonImpl* bi = dynamic_cast<wxButtonImpl*> (GetPeer());
+ if ( bi )
+ bi->SetPressedBitmap(bitmap);
+ }
+ InvalidateBestSize();
+}
+
+void wxAnyButton::DoSetBitmapPosition(wxDirection dir)
+{
+ GetPeer()->SetBitmapPosition(dir);
+ InvalidateBestSize();
+}
+
+#if wxUSE_MARKUP && wxOSX_USE_COCOA
+
+bool wxAnyButton::DoSetLabelMarkup(const wxString& markup)
+{
+ if ( !wxAnyButtonBase::DoSetLabelMarkup(markup) )
+ return false;
+
+ GetPeer()->SetLabelMarkup(markup);
+
+ return true;
+}
+
+#endif // wxUSE_MARKUP && wxOSX_USE_COCOA
+
+void wxAnyButton::OnEnterWindow( wxMouseEvent& WXUNUSED(event))
+{
+ if ( DoGetBitmap( State_Current ).IsOk() )
+ GetPeer()->SetBitmap( DoGetBitmap( State_Current ) );
+}
+
+void wxAnyButton::OnLeaveWindow( wxMouseEvent& WXUNUSED(event))
+{
+ if ( DoGetBitmap( State_Current ).IsOk() )
+ GetPeer()->SetBitmap( DoGetBitmap( State_Normal ) );
+}
} // anonymous namespace
-BEGIN_EVENT_TABLE(wxButton, wxControl)
- EVT_ENTER_WINDOW(wxButton::OnEnterWindow)
- EVT_LEAVE_WINDOW(wxButton::OnLeaveWindow)
-END_EVENT_TABLE()
-
bool wxButton::Create(wxWindow *parent,
wxWindowID id,
const wxString& labelOrig,
return;
}
- if ( HasFlag(wxBU_NOTEXT) )
- {
- // just store the label internally but don't really use it for the
- // button
- m_labelOrig =
- m_label = label;
- return;
- }
-
- wxButtonBase::SetLabel(label);
-}
-
-wxBitmap wxButton::DoGetBitmap(State which) const
-{
- return m_bitmaps[which];
-}
-
-void wxButton::DoSetBitmap(const wxBitmap& bitmap, State which)
-{
- m_bitmaps[which] = bitmap;
-
- if ( which == State_Normal )
- GetPeer()->SetBitmap(bitmap);
- else if ( which == State_Pressed )
- {
- wxButtonImpl* bi = dynamic_cast<wxButtonImpl*> (GetPeer());
- if ( bi )
- bi->SetPressedBitmap(bitmap);
- }
- InvalidateBestSize();
-}
-
-void wxButton::DoSetBitmapPosition(wxDirection dir)
-{
- GetPeer()->SetBitmapPosition(dir);
- InvalidateBestSize();
-}
-
-#if wxUSE_MARKUP && wxOSX_USE_COCOA
-
-bool wxButton::DoSetLabelMarkup(const wxString& markup)
-{
- if ( !wxButtonBase::DoSetLabelMarkup(markup) )
- return false;
-
- GetPeer()->SetLabelMarkup(markup);
-
- return true;
+ wxAnyButton::SetLabel(label);
}
-#endif // wxUSE_MARKUP && wxOSX_USE_COCOA
-
wxWindow *wxButton::SetDefault()
{
wxWindow *btnOldDefault = wxButtonBase::SetDefault();
// ProcessCommand(event);
}
-void wxButton::OnEnterWindow( wxMouseEvent& WXUNUSED(event))
-{
- if ( DoGetBitmap( State_Current ).IsOk() )
- GetPeer()->SetBitmap( DoGetBitmap( State_Current ) );
-}
-
-void wxButton::OnLeaveWindow( wxMouseEvent& WXUNUSED(event))
-{
- if ( DoGetBitmap( State_Current ).IsOk() )
- GetPeer()->SetBitmap( DoGetBitmap( State_Normal ) );
-}
-
bool wxButton::OSXHandleClicked( double WXUNUSED(timestampsec) )
{
wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, m_windowId);
--- /dev/null
+/////////////////////////////////////////////////////////////////////////////
+// Name: src/osx/carbon/anybutton.cpp
+// Purpose: wxAnyButton
+// Author: Stefan Csomor
+// Created: 1998-01-01 (extracted from button.cpp)
+// RCS-ID: $Id: anybutton.cpp 67230 2011-03-18 14:20:12Z SC $
+// Copyright: (c) Stefan Csomor
+// Licence: wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#include "wx/wxprec.h"
+
+#include "wx/anybutton.h"
+
+#ifndef WX_PRECOMP
+ #include "wx/panel.h"
+ #include "wx/toplevel.h"
+ #include "wx/dcclient.h"
+#endif
+
+#include "wx/stockitem.h"
+
+#include "wx/osx/private.h"
+
+wxSize wxAnyButton::DoGetBestSize() const
+{
+ if ( GetId() == wxID_HELP )
+ return wxSize( 20 , 20 ) ;
+
+ wxSize sz = GetDefaultSize() ;
+
+ switch (GetWindowVariant())
+ {
+ case wxWINDOW_VARIANT_NORMAL:
+ case wxWINDOW_VARIANT_LARGE:
+ sz.y = 20 ;
+ break;
+
+ case wxWINDOW_VARIANT_SMALL:
+ sz.y = 17 ;
+ break;
+
+ case wxWINDOW_VARIANT_MINI:
+ sz.y = 15 ;
+ break;
+
+ default:
+ break;
+ }
+
+#if wxOSX_USE_CARBON
+ Rect bestsize = { 0 , 0 , 0 , 0 } ;
+ GetPeer()->GetBestRect( &bestsize ) ;
+
+ int wBtn;
+ if ( EmptyRect( &bestsize ) || ( GetWindowStyle() & wxBU_EXACTFIT) )
+ {
+ Point bounds;
+
+ ControlFontStyleRec controlFont;
+ OSStatus err = GetPeer()->GetData<ControlFontStyleRec>( kControlEntireControl, kControlFontStyleTag, &controlFont );
+ verify_noerr( err );
+
+ // GetThemeTextDimensions will cache strings and the documentation
+ // says not to use the NoCopy string creation calls.
+ // This also means that we can't use CFSTR without
+ // -fno-constant-cfstrings if the library might be unloaded,
+ // as GetThemeTextDimensions may cache a pointer to our
+ // unloaded segment.
+ wxCFStringRef str( !m_label.empty() ? m_label : wxString(" "),
+ GetFont().GetEncoding() );
+
+#if wxOSX_USE_ATSU_TEXT
+ SInt16 baseline;
+ if ( m_font.MacGetThemeFontID() != kThemeCurrentPortFont )
+ {
+ err = GetThemeTextDimensions(
+ (CFStringRef)str,
+ m_font.MacGetThemeFontID(), kThemeStateActive, false, &bounds, &baseline );
+ verify_noerr( err );
+ }
+ else
+#endif
+ {
+ wxClientDC dc(const_cast<wxAnyButton*>(this));
+ wxCoord width, height ;
+ dc.GetTextExtent( m_label , &width, &height);
+ bounds.h = width;
+ bounds.v = height;
+ }
+
+ wBtn = bounds.h + sz.y;
+ }
+ else
+ {
+ wBtn = bestsize.right - bestsize.left ;
+ // non 'normal' window variants don't return the correct height
+ // sz.y = bestsize.bottom - bestsize.top ;
+ }
+ if ((wBtn > sz.x) || ( GetWindowStyle() & wxBU_EXACTFIT))
+ sz.x = wBtn;
+#endif
+
+ return sz ;
+}
+
+wxSize wxAnyButton::GetDefaultSize()
+{
+ int wBtn = 70 ;
+ int hBtn = 20 ;
+
+ return wxSize(wBtn, hBtn);
+}
//
//
-wxSize wxButton::DoGetBestSize() const
-{
- if ( GetId() == wxID_HELP )
- return wxSize( 20 , 20 ) ;
-
- wxSize sz = GetDefaultSize() ;
-
- switch (GetWindowVariant())
- {
- case wxWINDOW_VARIANT_NORMAL:
- case wxWINDOW_VARIANT_LARGE:
- sz.y = 20 ;
- break;
-
- case wxWINDOW_VARIANT_SMALL:
- sz.y = 17 ;
- break;
-
- case wxWINDOW_VARIANT_MINI:
- sz.y = 15 ;
- break;
-
- default:
- break;
- }
-
-#if wxOSX_USE_CARBON
- Rect bestsize = { 0 , 0 , 0 , 0 } ;
- GetPeer()->GetBestRect( &bestsize ) ;
-
- int wBtn;
- if ( EmptyRect( &bestsize ) || ( GetWindowStyle() & wxBU_EXACTFIT) )
- {
- Point bounds;
-
- ControlFontStyleRec controlFont;
- OSStatus err = GetPeer()->GetData<ControlFontStyleRec>( kControlEntireControl, kControlFontStyleTag, &controlFont );
- verify_noerr( err );
-
- // GetThemeTextDimensions will cache strings and the documentation
- // says not to use the NoCopy string creation calls.
- // This also means that we can't use CFSTR without
- // -fno-constant-cfstrings if the library might be unloaded,
- // as GetThemeTextDimensions may cache a pointer to our
- // unloaded segment.
- wxCFStringRef str( !m_label.empty() ? m_label : wxString(" "),
- GetFont().GetEncoding() );
-
-#if wxOSX_USE_ATSU_TEXT
- SInt16 baseline;
- if ( m_font.MacGetThemeFontID() != kThemeCurrentPortFont )
- {
- err = GetThemeTextDimensions(
- (CFStringRef)str,
- m_font.MacGetThemeFontID(), kThemeStateActive, false, &bounds, &baseline );
- verify_noerr( err );
- }
- else
-#endif
- {
- wxClientDC dc(const_cast<wxButton*>(this));
- wxCoord width, height ;
- dc.GetTextExtent( m_label , &width, &height);
- bounds.h = width;
- bounds.v = height;
- }
-
- wBtn = bounds.h + sz.y;
- }
- else
- {
- wBtn = bestsize.right - bestsize.left ;
- // non 'normal' window variants don't return the correct height
- // sz.y = bestsize.bottom - bestsize.top ;
- }
- if ((wBtn > sz.x) || ( GetWindowStyle() & wxBU_EXACTFIT))
- sz.x = wBtn;
-#endif
-
- return sz ;
-}
-
-wxSize wxButton::GetDefaultSize()
-{
- int wBtn = 70 ;
- int hBtn = 20 ;
-
- return wxSize(wBtn, hBtn);
-}
-
wxWidgetImplType* wxWidgetImpl::CreateButton( wxWindowMac* wxpeer,
wxWindowMac* parent,
wxWindowID id,
--- /dev/null
+/////////////////////////////////////////////////////////////////////////////
+// Name: src/osx/cocoa/anybutton.mm
+// Purpose: wxAnyButton
+// Author: Stefan Csomor
+// Created: 1998-01-01 (extracted from button.mm)
+// RCS-ID: $Id: anybutton.mm 67681 2011-05-03 16:29:04Z DS $
+// Copyright: (c) Stefan Csomor
+// Licence: wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#include "wx/wxprec.h"
+
+#include "wx/button.h"
+
+#ifndef WX_PRECOMP
+#endif
+
+#include "wx/osx/private.h"
+
+wxSize wxAnyButton::DoGetBestSize() const
+{
+ // We only use help button bezel if we don't have any (non standard) label
+ // to display in the button. Otherwise even wxID_HELP buttons look like
+ // normal push buttons.
+ if ( GetId() == wxID_HELP && GetLabel().empty() )
+ return wxSize( 23 , 23 ) ;
+
+ wxRect r ;
+ GetPeer()->GetBestRect(&r);
+
+ wxSize sz = r.GetSize();
+ sz.x = sz.x + MacGetLeftBorderSize() +
+ MacGetRightBorderSize();
+ sz.y = sz.y + MacGetTopBorderSize() +
+ MacGetBottomBorderSize();
+
+ const int wBtnStd = GetDefaultSize().x;
+
+ if ( (sz.x < wBtnStd) && !HasFlag(wxBU_EXACTFIT) )
+ sz.x = wBtnStd;
+
+ return sz ;
+}
+
+wxSize wxAnyButton::GetDefaultSize()
+{
+ return wxSize(84, 20);
+}
#endif // wxUSE_MARKUP
-wxSize wxButton::DoGetBestSize() const
-{
- // We only use help button bezel if we don't have any (non standard) label
- // to display in the button. Otherwise even wxID_HELP buttons look like
- // normal push buttons.
- if ( GetId() == wxID_HELP && GetLabel().empty() )
- return wxSize( 23 , 23 ) ;
-
- wxRect r ;
- GetPeer()->GetBestRect(&r);
-
- wxSize sz = r.GetSize();
- sz.x = sz.x + MacGetLeftBorderSize() +
- MacGetRightBorderSize();
- sz.y = sz.y + MacGetTopBorderSize() +
- MacGetBottomBorderSize();
-
- const int wBtnStd = GetDefaultSize().x;
-
- if ( (sz.x < wBtnStd) && !HasFlag(wxBU_EXACTFIT) )
- sz.x = wBtnStd;
-
- return sz ;
-}
-
-wxSize wxButton::GetDefaultSize()
-{
- return wxSize(84, 20);
-}
-
@implementation wxNSButton
+ (void)initialize
--- /dev/null
+/////////////////////////////////////////////////////////////////////////////
+// Name: src/osx/iphone/anybutton.mm
+// Purpose: wxAnyButton
+// Author: Stefan Csomor
+// Created: 1998-01-01 (extracted from button.mm)
+// RCS-ID: $Id: anybutton.mm 67232 2011-03-18 15:10:15Z DS $
+// Copyright: (c) Stefan Csomor
+// Licence: wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#include "wx/wxprec.h"
+
+#include "wx/anybutton.h"
+
+#ifndef WX_PRECOMP
+ #include "wx/panel.h"
+ #include "wx/toplevel.h"
+ #include "wx/dcclient.h"
+#endif
+
+#include "wx/stockitem.h"
+
+#include "wx/osx/private.h"
+
+wxSize wxAnyButton::DoGetBestSize() const
+{
+ if ( GetId() == wxID_HELP )
+ return wxSize( 18 , 18 ) ;
+
+ wxSize sz = GetDefaultSize() ;
+
+ wxRect r ;
+
+ GetPeer()->GetBestRect(&r);
+
+ if ( r.GetWidth() == 0 && r.GetHeight() == 0 )
+ {
+ }
+ sz.x = r.GetWidth();
+ sz.y = r.GetHeight();
+
+ int wBtn = 72;
+
+ if ((wBtn > sz.x) || ( GetWindowStyle() & wxBU_EXACTFIT))
+ sz.x = wBtn;
+
+ return sz ;
+}
+
+wxSize wxAnyButton::GetDefaultSize()
+{
+ int wBtn = 72 ;
+ int hBtn = 35 ;
+
+ return wxSize(wBtn, hBtn);
+}
#include "wx/osx/private.h"
-wxSize wxButton::DoGetBestSize() const
-{
- if ( GetId() == wxID_HELP )
- return wxSize( 18 , 18 ) ;
-
- wxSize sz = GetDefaultSize() ;
-
- wxRect r ;
-
- GetPeer()->GetBestRect(&r);
-
- if ( r.GetWidth() == 0 && r.GetHeight() == 0 )
- {
- }
- sz.x = r.GetWidth();
- sz.y = r.GetHeight();
-
- int wBtn = 72;
-
- if ((wBtn > sz.x) || ( GetWindowStyle() & wxBU_EXACTFIT))
- sz.x = wBtn;
-
- return sz ;
-}
-
-wxSize wxButton::GetDefaultSize()
-{
- int wBtn = 72 ;
- int hBtn = 35 ;
-
- return wxSize(wBtn, hBtn);
-}
-
@implementation wxUIButton
+ (void)initialize
{
DontCreatePeer();
+ m_marginX =
+ m_marginY = 0;
+
+ // FIXME: this hack is needed because we're called from
+ // wxBitmapToggleButton::Create() with this style and we currently use a
+ // different wxWidgetImpl method (CreateBitmapToggleButton() rather than
+ // CreateToggleButton()) for creating bitmap buttons, but we really ought
+ // to unify the creation of buttons of all kinds and then remove
+ // this check
+ if ( style & wxBU_NOTEXT )
+ {
+ return wxControl::Create(parent, id, pos, size, style,
+ validator, name);
+ }
+
if ( !wxControl::Create(parent, id, pos, size, style, validator, name) )
return false;
// wxBitmapToggleButton
// ----------------------------------------------------------------------------
-IMPLEMENT_DYNAMIC_CLASS(wxBitmapToggleButton, wxControl)
+IMPLEMENT_DYNAMIC_CLASS(wxBitmapToggleButton, wxToggleButton)
bool wxBitmapToggleButton::Create(wxWindow *parent, wxWindowID id,
const wxBitmap& label,
{
DontCreatePeer();
- m_bitmap = label;
+ if ( !wxToggleButton::Create(parent, id, wxEmptyString, pos, size, style | wxBU_NOTEXT | wxBU_EXACTFIT, validator, name) )
+ return false;
m_marginX =
m_marginY = wxDEFAULT_BUTTON_MARGIN;
- if ( !wxControl::Create(parent, id, pos, size, style, validator, name) )
- return false;
+ m_bitmaps[State_Normal] = label;
SetPeer(wxWidgetImpl::CreateBitmapToggleButton( this, parent, id, label, pos, size, style, GetExtraStyle() ));
wxSize wxBitmapToggleButton::DoGetBestSize() const
{
- if (!m_bitmap.IsOk())
+ if (!GetBitmap().IsOk())
return wxSize(20,20);
wxSize best;
- best.x = m_bitmap.GetWidth() + 2 * m_marginX;
- best.y = m_bitmap.GetHeight() + 2 * m_marginY;
+ best.x = GetBitmap().GetWidth() + 2 * m_marginX;
+ best.y = GetBitmap().GetHeight() + 2 * m_marginY;
return best;
}
-void wxBitmapToggleButton::SetValue(bool val)
-{
- GetPeer()->SetValue( val ) ;
-}
-
-bool wxBitmapToggleButton::GetValue() const
-{
- return GetPeer()->GetValue() ;
-}
-
-void wxBitmapToggleButton::Command(wxCommandEvent & event)
-{
- SetValue((event.GetInt() != 0));
- ProcessCommand(event);
-}
-
-bool wxBitmapToggleButton::OSXHandleClicked( double WXUNUSED(timestampsec) )
-{
- wxCommandEvent event(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, m_windowId);
- event.SetInt(GetValue());
- event.SetEventObject(this);
- ProcessCommand(event);
- return noErr ;
-}
-
#endif // wxUSE_TOGGLEBTN