From 98fbab9e7bf70ee8af44a78ea2a1d2cbb406880a Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 23 Jan 2010 13:21:12 +0000 Subject: [PATCH] Refactor owner-drawing code. Only keep common code in the base class and extract all menu/listbox-specific stuff into derived classes. This makes the code cleaner and more maintainable but introduces some problems in wxCheckListBox appearance which will be fixed by the next patch. Closes #10635. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63220 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- Makefile.in | 23 ++ build/bakefiles/files.bkl | 3 + build/msw/makefile.bcc | 172 +++++++----- build/msw/makefile.gcc | 172 +++++++----- build/msw/makefile.vc | 172 +++++++----- build/msw/makefile.wat | 172 +++++++----- build/msw/wx_core.dsp | 8 + build/msw/wx_vc7_core.vcproj | 6 + build/msw/wx_vc8_core.vcproj | 8 + build/msw/wx_vc9_core.vcproj | 8 + include/wx/msw/listbox.h | 3 - include/wx/msw/menuitem.h | 58 +++- include/wx/msw/ownerdrw.h | 29 ++ include/wx/os2/menuitem.h | 53 +++- include/wx/os2/ownerdrw.h | 29 ++ include/wx/ownerdrw.h | 233 +++++++--------- src/common/ownerdrwcmn.cpp | 96 +++++++ src/msw/checklst.cpp | 5 +- src/msw/listbox.cpp | 56 ++-- src/msw/menu.cpp | 2 +- src/msw/menuitem.cpp | 383 ++++++++++++++++++++++++-- src/msw/ownerdrw.cpp | 518 +++-------------------------------- src/os2/checklst.cpp | 16 +- src/os2/listbox.cpp | 66 ++--- src/os2/menuitem.cpp | 406 ++++++++++++++++++++++++--- src/os2/ownerdrw.cpp | 377 ++----------------------- 26 files changed, 1659 insertions(+), 1415 deletions(-) create mode 100644 include/wx/msw/ownerdrw.h create mode 100644 include/wx/os2/ownerdrw.h create mode 100644 src/common/ownerdrwcmn.cpp diff --git a/Makefile.in b/Makefile.in index 1956596a75..fdf92bd45c 100644 --- a/Makefile.in +++ b/Makefile.in @@ -2895,6 +2895,7 @@ COND_TOOLKIT_MSW_GUI_HDR = \ wx/msw/ole/dropsrc.h \ wx/msw/ole/droptgt.h \ wx/msw/ole/oleutils.h \ + wx/msw/ownerdrw.h \ wx/msw/palette.h \ wx/msw/pen.h \ wx/msw/printdlg.h \ @@ -3220,6 +3221,7 @@ COND_TOOLKIT_PM_GUI_HDR = \ wx/os2/minifram.h \ wx/os2/msgdlg.h \ wx/os2/notebook.h \ + wx/os2/ownerdrw.h \ wx/os2/palette.h \ wx/os2/pen.h \ wx/os2/pnghand.h \ @@ -3306,6 +3308,7 @@ COND_TOOLKIT_WINCE_GUI_HDR = \ wx/msw/ole/dropsrc.h \ wx/msw/ole/droptgt.h \ wx/msw/ole/oleutils.h \ + wx/msw/ownerdrw.h \ wx/msw/palette.h \ wx/msw/pen.h \ wx/msw/printdlg.h \ @@ -4301,6 +4304,7 @@ COND_USE_GUI_1_WXUNIV_0___CORE_SRC_OBJECTS = \ monodll_mousemanager.o \ monodll_nbkbase.o \ monodll_overlaycmn.o \ + monodll_ownerdrwcmn.o \ monodll_paper.o \ monodll_persist.o \ monodll_pickerbase.o \ @@ -4495,6 +4499,7 @@ COND_USE_GUI_1_WXUNIV_1___CORE_SRC_OBJECTS = \ monodll_mousemanager.o \ monodll_nbkbase.o \ monodll_overlaycmn.o \ + monodll_ownerdrwcmn.o \ monodll_paper.o \ monodll_persist.o \ monodll_pickerbase.o \ @@ -6122,6 +6127,7 @@ COND_USE_GUI_1_WXUNIV_0___CORE_SRC_OBJECTS_1 = \ monolib_mousemanager.o \ monolib_nbkbase.o \ monolib_overlaycmn.o \ + monolib_ownerdrwcmn.o \ monolib_paper.o \ monolib_persist.o \ monolib_pickerbase.o \ @@ -6316,6 +6322,7 @@ COND_USE_GUI_1_WXUNIV_1___CORE_SRC_OBJECTS_1 = \ monolib_mousemanager.o \ monolib_nbkbase.o \ monolib_overlaycmn.o \ + monolib_ownerdrwcmn.o \ monolib_paper.o \ monolib_persist.o \ monolib_pickerbase.o \ @@ -8132,6 +8139,7 @@ COND_USE_GUI_1_WXUNIV_0___CORE_SRC_OBJECTS_2 = \ coredll_mousemanager.o \ coredll_nbkbase.o \ coredll_overlaycmn.o \ + coredll_ownerdrwcmn.o \ coredll_paper.o \ coredll_persist.o \ coredll_pickerbase.o \ @@ -8326,6 +8334,7 @@ COND_USE_GUI_1_WXUNIV_1___CORE_SRC_OBJECTS_2 = \ coredll_mousemanager.o \ coredll_nbkbase.o \ coredll_overlaycmn.o \ + coredll_ownerdrwcmn.o \ coredll_paper.o \ coredll_persist.o \ coredll_pickerbase.o \ @@ -9626,6 +9635,7 @@ COND_USE_GUI_1_WXUNIV_0___CORE_SRC_OBJECTS_3 = \ corelib_mousemanager.o \ corelib_nbkbase.o \ corelib_overlaycmn.o \ + corelib_ownerdrwcmn.o \ corelib_paper.o \ corelib_persist.o \ corelib_pickerbase.o \ @@ -9820,6 +9830,7 @@ COND_USE_GUI_1_WXUNIV_1___CORE_SRC_OBJECTS_3 = \ corelib_mousemanager.o \ corelib_nbkbase.o \ corelib_overlaycmn.o \ + corelib_ownerdrwcmn.o \ corelib_paper.o \ corelib_persist.o \ corelib_pickerbase.o \ @@ -18901,6 +18912,9 @@ monodll_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(MONODLL_ODEP) @COND_USE_GUI_1@monodll_overlaycmn.o: $(srcdir)/src/common/overlaycmn.cpp $(MONODLL_ODEP) @COND_USE_GUI_1@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/common/overlaycmn.cpp +@COND_USE_GUI_1@monodll_ownerdrwcmn.o: $(srcdir)/src/common/ownerdrwcmn.cpp $(MONODLL_ODEP) +@COND_USE_GUI_1@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/common/ownerdrwcmn.cpp + @COND_USE_GUI_1@monodll_paper.o: $(srcdir)/src/common/paper.cpp $(MONODLL_ODEP) @COND_USE_GUI_1@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/common/paper.cpp @@ -23713,6 +23727,9 @@ monolib_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(MONOLIB_ODEP) @COND_USE_GUI_1@monolib_overlaycmn.o: $(srcdir)/src/common/overlaycmn.cpp $(MONOLIB_ODEP) @COND_USE_GUI_1@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/common/overlaycmn.cpp +@COND_USE_GUI_1@monolib_ownerdrwcmn.o: $(srcdir)/src/common/ownerdrwcmn.cpp $(MONOLIB_ODEP) +@COND_USE_GUI_1@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/common/ownerdrwcmn.cpp + @COND_USE_GUI_1@monolib_paper.o: $(srcdir)/src/common/paper.cpp $(MONOLIB_ODEP) @COND_USE_GUI_1@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/common/paper.cpp @@ -28708,6 +28725,9 @@ coredll_win32.o: $(srcdir)/src/univ/themes/win32.cpp $(COREDLL_ODEP) @COND_USE_GUI_1@coredll_overlaycmn.o: $(srcdir)/src/common/overlaycmn.cpp $(COREDLL_ODEP) @COND_USE_GUI_1@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/common/overlaycmn.cpp +@COND_USE_GUI_1@coredll_ownerdrwcmn.o: $(srcdir)/src/common/ownerdrwcmn.cpp $(COREDLL_ODEP) +@COND_USE_GUI_1@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/common/ownerdrwcmn.cpp + @COND_USE_GUI_1@coredll_paper.o: $(srcdir)/src/common/paper.cpp $(COREDLL_ODEP) @COND_USE_GUI_1@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/common/paper.cpp @@ -32251,6 +32271,9 @@ corelib_win32.o: $(srcdir)/src/univ/themes/win32.cpp $(CORELIB_ODEP) @COND_USE_GUI_1@corelib_overlaycmn.o: $(srcdir)/src/common/overlaycmn.cpp $(CORELIB_ODEP) @COND_USE_GUI_1@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/common/overlaycmn.cpp +@COND_USE_GUI_1@corelib_ownerdrwcmn.o: $(srcdir)/src/common/ownerdrwcmn.cpp $(CORELIB_ODEP) +@COND_USE_GUI_1@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/common/ownerdrwcmn.cpp + @COND_USE_GUI_1@corelib_paper.o: $(srcdir)/src/common/paper.cpp $(CORELIB_ODEP) @COND_USE_GUI_1@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/common/paper.cpp diff --git a/build/bakefiles/files.bkl b/build/bakefiles/files.bkl index 7adcb4670b..5facb9bf9e 100644 --- a/build/bakefiles/files.bkl +++ b/build/bakefiles/files.bkl @@ -703,6 +703,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file! src/common/mousemanager.cpp src/common/nbkbase.cpp src/common/overlaycmn.cpp + src/common/ownerdrwcmn.cpp src/common/paper.cpp src/common/persist.cpp src/common/pickerbase.cpp @@ -1770,6 +1771,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file! wx/msw/ole/dropsrc.h wx/msw/ole/droptgt.h wx/msw/ole/oleutils.h + wx/msw/ownerdrw.h wx/msw/palette.h wx/msw/pen.h wx/msw/printdlg.h @@ -2150,6 +2152,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file! wx/os2/minifram.h wx/os2/msgdlg.h wx/os2/notebook.h + wx/os2/ownerdrw.h wx/os2/palette.h wx/os2/pen.h wx/os2/pnghand.h diff --git a/build/msw/makefile.bcc b/build/msw/makefile.bcc index e61002dae0..09309b7893 100644 --- a/build/msw/makefile.bcc +++ b/build/msw/makefile.bcc @@ -1815,12 +1815,13 @@ ____CORE_SRC_FILENAMES_OBJECTS = \ $(OBJS)\monodll_listctrlcmn.obj \ $(OBJS)\monodll_matrix.obj \ $(OBJS)\monodll_menucmn.obj \ - $(OBJS)\monodll_mousemanager.obj \ - $(OBJS)\monodll_nbkbase.obj \ - $(OBJS)\monodll_overlaycmn.obj \ - $(OBJS)\monodll_paper.obj \ - $(OBJS)\monodll_persist.obj \ - $(OBJS)\monodll_pickerbase.obj \ + $(OBJS)\monodll_mousemanager.obj \ + $(OBJS)\monodll_nbkbase.obj \ + $(OBJS)\monodll_overlaycmn.obj \ + $(OBJS)\monodll_ownerdrwcmn.obj \ + $(OBJS)\monodll_paper.obj \ + $(OBJS)\monodll_persist.obj \ + $(OBJS)\monodll_pickerbase.obj \ $(OBJS)\monodll_popupcmn.obj \ $(OBJS)\monodll_prntbase.obj \ $(OBJS)\monodll_quantize.obj \ @@ -2057,12 +2058,13 @@ ____CORE_SRC_FILENAMES_OBJECTS = \ $(OBJS)\monodll_listctrlcmn.obj \ $(OBJS)\monodll_matrix.obj \ $(OBJS)\monodll_menucmn.obj \ - $(OBJS)\monodll_mousemanager.obj \ - $(OBJS)\monodll_nbkbase.obj \ - $(OBJS)\monodll_overlaycmn.obj \ - $(OBJS)\monodll_paper.obj \ - $(OBJS)\monodll_persist.obj \ - $(OBJS)\monodll_pickerbase.obj \ + $(OBJS)\monodll_mousemanager.obj \ + $(OBJS)\monodll_nbkbase.obj \ + $(OBJS)\monodll_overlaycmn.obj \ + $(OBJS)\monodll_ownerdrwcmn.obj \ + $(OBJS)\monodll_paper.obj \ + $(OBJS)\monodll_persist.obj \ + $(OBJS)\monodll_pickerbase.obj \ $(OBJS)\monodll_popupcmn.obj \ $(OBJS)\monodll_prntbase.obj \ $(OBJS)\monodll_quantize.obj \ @@ -2515,12 +2517,13 @@ ____CORE_SRC_FILENAMES_1_OBJECTS = \ $(OBJS)\monolib_listctrlcmn.obj \ $(OBJS)\monolib_matrix.obj \ $(OBJS)\monolib_menucmn.obj \ - $(OBJS)\monolib_mousemanager.obj \ - $(OBJS)\monolib_nbkbase.obj \ - $(OBJS)\monolib_overlaycmn.obj \ - $(OBJS)\monolib_paper.obj \ - $(OBJS)\monolib_persist.obj \ - $(OBJS)\monolib_pickerbase.obj \ + $(OBJS)\monolib_mousemanager.obj \ + $(OBJS)\monolib_nbkbase.obj \ + $(OBJS)\monolib_overlaycmn.obj \ + $(OBJS)\monolib_ownerdrwcmn.obj \ + $(OBJS)\monolib_paper.obj \ + $(OBJS)\monolib_persist.obj \ + $(OBJS)\monolib_pickerbase.obj \ $(OBJS)\monolib_popupcmn.obj \ $(OBJS)\monolib_prntbase.obj \ $(OBJS)\monolib_quantize.obj \ @@ -2757,12 +2760,13 @@ ____CORE_SRC_FILENAMES_1_OBJECTS = \ $(OBJS)\monolib_listctrlcmn.obj \ $(OBJS)\monolib_matrix.obj \ $(OBJS)\monolib_menucmn.obj \ - $(OBJS)\monolib_mousemanager.obj \ - $(OBJS)\monolib_nbkbase.obj \ - $(OBJS)\monolib_overlaycmn.obj \ - $(OBJS)\monolib_paper.obj \ - $(OBJS)\monolib_persist.obj \ - $(OBJS)\monolib_pickerbase.obj \ + $(OBJS)\monolib_mousemanager.obj \ + $(OBJS)\monolib_nbkbase.obj \ + $(OBJS)\monolib_overlaycmn.obj \ + $(OBJS)\monolib_ownerdrwcmn.obj \ + $(OBJS)\monolib_paper.obj \ + $(OBJS)\monolib_persist.obj \ + $(OBJS)\monolib_pickerbase.obj \ $(OBJS)\monolib_popupcmn.obj \ $(OBJS)\monolib_prntbase.obj \ $(OBJS)\monolib_quantize.obj \ @@ -3108,12 +3112,13 @@ ____CORE_SRC_FILENAMES_2_OBJECTS = \ $(OBJS)\coredll_listctrlcmn.obj \ $(OBJS)\coredll_matrix.obj \ $(OBJS)\coredll_menucmn.obj \ - $(OBJS)\coredll_mousemanager.obj \ - $(OBJS)\coredll_nbkbase.obj \ - $(OBJS)\coredll_overlaycmn.obj \ - $(OBJS)\coredll_paper.obj \ - $(OBJS)\coredll_persist.obj \ - $(OBJS)\coredll_pickerbase.obj \ + $(OBJS)\coredll_mousemanager.obj \ + $(OBJS)\coredll_nbkbase.obj \ + $(OBJS)\coredll_overlaycmn.obj \ + $(OBJS)\coredll_ownerdrwcmn.obj \ + $(OBJS)\coredll_paper.obj \ + $(OBJS)\coredll_persist.obj \ + $(OBJS)\coredll_pickerbase.obj \ $(OBJS)\coredll_popupcmn.obj \ $(OBJS)\coredll_prntbase.obj \ $(OBJS)\coredll_quantize.obj \ @@ -3350,12 +3355,13 @@ ____CORE_SRC_FILENAMES_2_OBJECTS = \ $(OBJS)\coredll_listctrlcmn.obj \ $(OBJS)\coredll_matrix.obj \ $(OBJS)\coredll_menucmn.obj \ - $(OBJS)\coredll_mousemanager.obj \ - $(OBJS)\coredll_nbkbase.obj \ - $(OBJS)\coredll_overlaycmn.obj \ - $(OBJS)\coredll_paper.obj \ - $(OBJS)\coredll_persist.obj \ - $(OBJS)\coredll_pickerbase.obj \ + $(OBJS)\coredll_mousemanager.obj \ + $(OBJS)\coredll_nbkbase.obj \ + $(OBJS)\coredll_overlaycmn.obj \ + $(OBJS)\coredll_ownerdrwcmn.obj \ + $(OBJS)\coredll_paper.obj \ + $(OBJS)\coredll_persist.obj \ + $(OBJS)\coredll_pickerbase.obj \ $(OBJS)\coredll_popupcmn.obj \ $(OBJS)\coredll_prntbase.obj \ $(OBJS)\coredll_quantize.obj \ @@ -3597,12 +3603,13 @@ ____CORE_SRC_FILENAMES_3_OBJECTS = \ $(OBJS)\corelib_listctrlcmn.obj \ $(OBJS)\corelib_matrix.obj \ $(OBJS)\corelib_menucmn.obj \ - $(OBJS)\corelib_mousemanager.obj \ - $(OBJS)\corelib_nbkbase.obj \ - $(OBJS)\corelib_overlaycmn.obj \ - $(OBJS)\corelib_paper.obj \ - $(OBJS)\corelib_persist.obj \ - $(OBJS)\corelib_pickerbase.obj \ + $(OBJS)\corelib_mousemanager.obj \ + $(OBJS)\corelib_nbkbase.obj \ + $(OBJS)\corelib_overlaycmn.obj \ + $(OBJS)\corelib_ownerdrwcmn.obj \ + $(OBJS)\corelib_paper.obj \ + $(OBJS)\corelib_persist.obj \ + $(OBJS)\corelib_pickerbase.obj \ $(OBJS)\corelib_popupcmn.obj \ $(OBJS)\corelib_prntbase.obj \ $(OBJS)\corelib_quantize.obj \ @@ -3839,12 +3846,13 @@ ____CORE_SRC_FILENAMES_3_OBJECTS = \ $(OBJS)\corelib_listctrlcmn.obj \ $(OBJS)\corelib_matrix.obj \ $(OBJS)\corelib_menucmn.obj \ - $(OBJS)\corelib_mousemanager.obj \ - $(OBJS)\corelib_nbkbase.obj \ - $(OBJS)\corelib_overlaycmn.obj \ - $(OBJS)\corelib_paper.obj \ - $(OBJS)\corelib_persist.obj \ - $(OBJS)\corelib_pickerbase.obj \ + $(OBJS)\corelib_mousemanager.obj \ + $(OBJS)\corelib_nbkbase.obj \ + $(OBJS)\corelib_overlaycmn.obj \ + $(OBJS)\corelib_ownerdrwcmn.obj \ + $(OBJS)\corelib_paper.obj \ + $(OBJS)\corelib_persist.obj \ + $(OBJS)\corelib_pickerbase.obj \ $(OBJS)\corelib_popupcmn.obj \ $(OBJS)\corelib_prntbase.obj \ $(OBJS)\corelib_quantize.obj \ @@ -7304,12 +7312,17 @@ $(OBJS)\monodll_nbkbase.obj: ..\..\src\common\nbkbase.cpp !if "$(USE_GUI)" == "1" $(OBJS)\monodll_overlaycmn.obj: ..\..\src\common\overlaycmn.cpp $(CXX) -q -c -P -o$@ $(MONODLL_CXXFLAGS) ..\..\src\common\overlaycmn.cpp -!endif - -!if "$(USE_GUI)" == "1" -$(OBJS)\monodll_paper.obj: ..\..\src\common\paper.cpp - $(CXX) -q -c -P -o$@ $(MONODLL_CXXFLAGS) ..\..\src\common\paper.cpp -!endif +!endif + +!if "$(USE_GUI)" == "1" +$(OBJS)\monodll_ownerdrwcmn.obj: ..\..\src\common\ownerdrwcmn.cpp + $(CXX) -q -c -P -o$@ $(MONODLL_CXXFLAGS) ..\..\src\common\ownerdrwcmn.cpp +!endif + +!if "$(USE_GUI)" == "1" +$(OBJS)\monodll_paper.obj: ..\..\src\common\paper.cpp + $(CXX) -q -c -P -o$@ $(MONODLL_CXXFLAGS) ..\..\src\common\paper.cpp +!endif !if "$(USE_GUI)" == "1" $(OBJS)\monodll_persist.obj: ..\..\src\common\persist.cpp @@ -9481,12 +9494,17 @@ $(OBJS)\monolib_nbkbase.obj: ..\..\src\common\nbkbase.cpp !if "$(USE_GUI)" == "1" $(OBJS)\monolib_overlaycmn.obj: ..\..\src\common\overlaycmn.cpp $(CXX) -q -c -P -o$@ $(MONOLIB_CXXFLAGS) ..\..\src\common\overlaycmn.cpp -!endif - -!if "$(USE_GUI)" == "1" -$(OBJS)\monolib_paper.obj: ..\..\src\common\paper.cpp - $(CXX) -q -c -P -o$@ $(MONOLIB_CXXFLAGS) ..\..\src\common\paper.cpp -!endif +!endif + +!if "$(USE_GUI)" == "1" +$(OBJS)\monolib_ownerdrwcmn.obj: ..\..\src\common\ownerdrwcmn.cpp + $(CXX) -q -c -P -o$@ $(MONOLIB_CXXFLAGS) ..\..\src\common\ownerdrwcmn.cpp +!endif + +!if "$(USE_GUI)" == "1" +$(OBJS)\monolib_paper.obj: ..\..\src\common\paper.cpp + $(CXX) -q -c -P -o$@ $(MONOLIB_CXXFLAGS) ..\..\src\common\paper.cpp +!endif !if "$(USE_GUI)" == "1" $(OBJS)\monolib_persist.obj: ..\..\src\common\persist.cpp @@ -11661,12 +11679,17 @@ $(OBJS)\coredll_nbkbase.obj: ..\..\src\common\nbkbase.cpp !if "$(USE_GUI)" == "1" $(OBJS)\coredll_overlaycmn.obj: ..\..\src\common\overlaycmn.cpp $(CXX) -q -c -P -o$@ $(COREDLL_CXXFLAGS) ..\..\src\common\overlaycmn.cpp -!endif - -!if "$(USE_GUI)" == "1" -$(OBJS)\coredll_paper.obj: ..\..\src\common\paper.cpp - $(CXX) -q -c -P -o$@ $(COREDLL_CXXFLAGS) ..\..\src\common\paper.cpp -!endif +!endif + +!if "$(USE_GUI)" == "1" +$(OBJS)\coredll_ownerdrwcmn.obj: ..\..\src\common\ownerdrwcmn.cpp + $(CXX) -q -c -P -o$@ $(COREDLL_CXXFLAGS) ..\..\src\common\ownerdrwcmn.cpp +!endif + +!if "$(USE_GUI)" == "1" +$(OBJS)\coredll_paper.obj: ..\..\src\common\paper.cpp + $(CXX) -q -c -P -o$@ $(COREDLL_CXXFLAGS) ..\..\src\common\paper.cpp +!endif !if "$(USE_GUI)" == "1" $(OBJS)\coredll_persist.obj: ..\..\src\common\persist.cpp @@ -12935,12 +12958,17 @@ $(OBJS)\corelib_nbkbase.obj: ..\..\src\common\nbkbase.cpp !if "$(USE_GUI)" == "1" $(OBJS)\corelib_overlaycmn.obj: ..\..\src\common\overlaycmn.cpp $(CXX) -q -c -P -o$@ $(CORELIB_CXXFLAGS) ..\..\src\common\overlaycmn.cpp -!endif - -!if "$(USE_GUI)" == "1" -$(OBJS)\corelib_paper.obj: ..\..\src\common\paper.cpp - $(CXX) -q -c -P -o$@ $(CORELIB_CXXFLAGS) ..\..\src\common\paper.cpp -!endif +!endif + +!if "$(USE_GUI)" == "1" +$(OBJS)\corelib_ownerdrwcmn.obj: ..\..\src\common\ownerdrwcmn.cpp + $(CXX) -q -c -P -o$@ $(CORELIB_CXXFLAGS) ..\..\src\common\ownerdrwcmn.cpp +!endif + +!if "$(USE_GUI)" == "1" +$(OBJS)\corelib_paper.obj: ..\..\src\common\paper.cpp + $(CXX) -q -c -P -o$@ $(CORELIB_CXXFLAGS) ..\..\src\common\paper.cpp +!endif !if "$(USE_GUI)" == "1" $(OBJS)\corelib_persist.obj: ..\..\src\common\persist.cpp diff --git a/build/msw/makefile.gcc b/build/msw/makefile.gcc index 821254141f..0a669584c0 100644 --- a/build/msw/makefile.gcc +++ b/build/msw/makefile.gcc @@ -1842,12 +1842,13 @@ ____CORE_SRC_FILENAMES_OBJECTS = \ $(OBJS)\monodll_listctrlcmn.o \ $(OBJS)\monodll_matrix.o \ $(OBJS)\monodll_menucmn.o \ - $(OBJS)\monodll_mousemanager.o \ - $(OBJS)\monodll_nbkbase.o \ - $(OBJS)\monodll_overlaycmn.o \ - $(OBJS)\monodll_paper.o \ - $(OBJS)\monodll_persist.o \ - $(OBJS)\monodll_pickerbase.o \ + $(OBJS)\monodll_mousemanager.o \ + $(OBJS)\monodll_nbkbase.o \ + $(OBJS)\monodll_overlaycmn.o \ + $(OBJS)\monodll_ownerdrwcmn.o \ + $(OBJS)\monodll_paper.o \ + $(OBJS)\monodll_persist.o \ + $(OBJS)\monodll_pickerbase.o \ $(OBJS)\monodll_popupcmn.o \ $(OBJS)\monodll_prntbase.o \ $(OBJS)\monodll_quantize.o \ @@ -2086,12 +2087,13 @@ ____CORE_SRC_FILENAMES_OBJECTS = \ $(OBJS)\monodll_listctrlcmn.o \ $(OBJS)\monodll_matrix.o \ $(OBJS)\monodll_menucmn.o \ - $(OBJS)\monodll_mousemanager.o \ - $(OBJS)\monodll_nbkbase.o \ - $(OBJS)\monodll_overlaycmn.o \ - $(OBJS)\monodll_paper.o \ - $(OBJS)\monodll_persist.o \ - $(OBJS)\monodll_pickerbase.o \ + $(OBJS)\monodll_mousemanager.o \ + $(OBJS)\monodll_nbkbase.o \ + $(OBJS)\monodll_overlaycmn.o \ + $(OBJS)\monodll_ownerdrwcmn.o \ + $(OBJS)\monodll_paper.o \ + $(OBJS)\monodll_persist.o \ + $(OBJS)\monodll_pickerbase.o \ $(OBJS)\monodll_popupcmn.o \ $(OBJS)\monodll_prntbase.o \ $(OBJS)\monodll_quantize.o \ @@ -2548,12 +2550,13 @@ ____CORE_SRC_FILENAMES_1_OBJECTS = \ $(OBJS)\monolib_listctrlcmn.o \ $(OBJS)\monolib_matrix.o \ $(OBJS)\monolib_menucmn.o \ - $(OBJS)\monolib_mousemanager.o \ - $(OBJS)\monolib_nbkbase.o \ - $(OBJS)\monolib_overlaycmn.o \ - $(OBJS)\monolib_paper.o \ - $(OBJS)\monolib_persist.o \ - $(OBJS)\monolib_pickerbase.o \ + $(OBJS)\monolib_mousemanager.o \ + $(OBJS)\monolib_nbkbase.o \ + $(OBJS)\monolib_overlaycmn.o \ + $(OBJS)\monolib_ownerdrwcmn.o \ + $(OBJS)\monolib_paper.o \ + $(OBJS)\monolib_persist.o \ + $(OBJS)\monolib_pickerbase.o \ $(OBJS)\monolib_popupcmn.o \ $(OBJS)\monolib_prntbase.o \ $(OBJS)\monolib_quantize.o \ @@ -2792,12 +2795,13 @@ ____CORE_SRC_FILENAMES_1_OBJECTS = \ $(OBJS)\monolib_listctrlcmn.o \ $(OBJS)\monolib_matrix.o \ $(OBJS)\monolib_menucmn.o \ - $(OBJS)\monolib_mousemanager.o \ - $(OBJS)\monolib_nbkbase.o \ - $(OBJS)\monolib_overlaycmn.o \ - $(OBJS)\monolib_paper.o \ - $(OBJS)\monolib_persist.o \ - $(OBJS)\monolib_pickerbase.o \ + $(OBJS)\monolib_mousemanager.o \ + $(OBJS)\monolib_nbkbase.o \ + $(OBJS)\monolib_overlaycmn.o \ + $(OBJS)\monolib_ownerdrwcmn.o \ + $(OBJS)\monolib_paper.o \ + $(OBJS)\monolib_persist.o \ + $(OBJS)\monolib_pickerbase.o \ $(OBJS)\monolib_popupcmn.o \ $(OBJS)\monolib_prntbase.o \ $(OBJS)\monolib_quantize.o \ @@ -3157,12 +3161,13 @@ ____CORE_SRC_FILENAMES_2_OBJECTS = \ $(OBJS)\coredll_listctrlcmn.o \ $(OBJS)\coredll_matrix.o \ $(OBJS)\coredll_menucmn.o \ - $(OBJS)\coredll_mousemanager.o \ - $(OBJS)\coredll_nbkbase.o \ - $(OBJS)\coredll_overlaycmn.o \ - $(OBJS)\coredll_paper.o \ - $(OBJS)\coredll_persist.o \ - $(OBJS)\coredll_pickerbase.o \ + $(OBJS)\coredll_mousemanager.o \ + $(OBJS)\coredll_nbkbase.o \ + $(OBJS)\coredll_overlaycmn.o \ + $(OBJS)\coredll_ownerdrwcmn.o \ + $(OBJS)\coredll_paper.o \ + $(OBJS)\coredll_persist.o \ + $(OBJS)\coredll_pickerbase.o \ $(OBJS)\coredll_popupcmn.o \ $(OBJS)\coredll_prntbase.o \ $(OBJS)\coredll_quantize.o \ @@ -3401,12 +3406,13 @@ ____CORE_SRC_FILENAMES_2_OBJECTS = \ $(OBJS)\coredll_listctrlcmn.o \ $(OBJS)\coredll_matrix.o \ $(OBJS)\coredll_menucmn.o \ - $(OBJS)\coredll_mousemanager.o \ - $(OBJS)\coredll_nbkbase.o \ - $(OBJS)\coredll_overlaycmn.o \ - $(OBJS)\coredll_paper.o \ - $(OBJS)\coredll_persist.o \ - $(OBJS)\coredll_pickerbase.o \ + $(OBJS)\coredll_mousemanager.o \ + $(OBJS)\coredll_nbkbase.o \ + $(OBJS)\coredll_overlaycmn.o \ + $(OBJS)\coredll_ownerdrwcmn.o \ + $(OBJS)\coredll_paper.o \ + $(OBJS)\coredll_persist.o \ + $(OBJS)\coredll_pickerbase.o \ $(OBJS)\coredll_popupcmn.o \ $(OBJS)\coredll_prntbase.o \ $(OBJS)\coredll_quantize.o \ @@ -3654,12 +3660,13 @@ ____CORE_SRC_FILENAMES_3_OBJECTS = \ $(OBJS)\corelib_listctrlcmn.o \ $(OBJS)\corelib_matrix.o \ $(OBJS)\corelib_menucmn.o \ - $(OBJS)\corelib_mousemanager.o \ - $(OBJS)\corelib_nbkbase.o \ - $(OBJS)\corelib_overlaycmn.o \ - $(OBJS)\corelib_paper.o \ - $(OBJS)\corelib_persist.o \ - $(OBJS)\corelib_pickerbase.o \ + $(OBJS)\corelib_mousemanager.o \ + $(OBJS)\corelib_nbkbase.o \ + $(OBJS)\corelib_overlaycmn.o \ + $(OBJS)\corelib_ownerdrwcmn.o \ + $(OBJS)\corelib_paper.o \ + $(OBJS)\corelib_persist.o \ + $(OBJS)\corelib_pickerbase.o \ $(OBJS)\corelib_popupcmn.o \ $(OBJS)\corelib_prntbase.o \ $(OBJS)\corelib_quantize.o \ @@ -3898,12 +3905,13 @@ ____CORE_SRC_FILENAMES_3_OBJECTS = \ $(OBJS)\corelib_listctrlcmn.o \ $(OBJS)\corelib_matrix.o \ $(OBJS)\corelib_menucmn.o \ - $(OBJS)\corelib_mousemanager.o \ - $(OBJS)\corelib_nbkbase.o \ - $(OBJS)\corelib_overlaycmn.o \ - $(OBJS)\corelib_paper.o \ - $(OBJS)\corelib_persist.o \ - $(OBJS)\corelib_pickerbase.o \ + $(OBJS)\corelib_mousemanager.o \ + $(OBJS)\corelib_nbkbase.o \ + $(OBJS)\corelib_overlaycmn.o \ + $(OBJS)\corelib_ownerdrwcmn.o \ + $(OBJS)\corelib_paper.o \ + $(OBJS)\corelib_persist.o \ + $(OBJS)\corelib_pickerbase.o \ $(OBJS)\corelib_popupcmn.o \ $(OBJS)\corelib_prntbase.o \ $(OBJS)\corelib_quantize.o \ @@ -7470,12 +7478,17 @@ endif ifeq ($(USE_GUI),1) $(OBJS)\monodll_overlaycmn.o: ../../src/common/overlaycmn.cpp $(CXX) -c -o $@ $(MONODLL_CXXFLAGS) $(CPPDEPS) $< -endif - -ifeq ($(USE_GUI),1) -$(OBJS)\monodll_paper.o: ../../src/common/paper.cpp - $(CXX) -c -o $@ $(MONODLL_CXXFLAGS) $(CPPDEPS) $< -endif +endif + +ifeq ($(USE_GUI),1) +$(OBJS)\monodll_ownerdrwcmn.o: ../../src/common/ownerdrwcmn.cpp + $(CXX) -c -o $@ $(MONODLL_CXXFLAGS) $(CPPDEPS) $< +endif + +ifeq ($(USE_GUI),1) +$(OBJS)\monodll_paper.o: ../../src/common/paper.cpp + $(CXX) -c -o $@ $(MONODLL_CXXFLAGS) $(CPPDEPS) $< +endif ifeq ($(USE_GUI),1) $(OBJS)\monodll_persist.o: ../../src/common/persist.cpp @@ -9647,12 +9660,17 @@ endif ifeq ($(USE_GUI),1) $(OBJS)\monolib_overlaycmn.o: ../../src/common/overlaycmn.cpp $(CXX) -c -o $@ $(MONOLIB_CXXFLAGS) $(CPPDEPS) $< -endif - -ifeq ($(USE_GUI),1) -$(OBJS)\monolib_paper.o: ../../src/common/paper.cpp - $(CXX) -c -o $@ $(MONOLIB_CXXFLAGS) $(CPPDEPS) $< -endif +endif + +ifeq ($(USE_GUI),1) +$(OBJS)\monolib_ownerdrwcmn.o: ../../src/common/ownerdrwcmn.cpp + $(CXX) -c -o $@ $(MONOLIB_CXXFLAGS) $(CPPDEPS) $< +endif + +ifeq ($(USE_GUI),1) +$(OBJS)\monolib_paper.o: ../../src/common/paper.cpp + $(CXX) -c -o $@ $(MONOLIB_CXXFLAGS) $(CPPDEPS) $< +endif ifeq ($(USE_GUI),1) $(OBJS)\monolib_persist.o: ../../src/common/persist.cpp @@ -11827,12 +11845,17 @@ endif ifeq ($(USE_GUI),1) $(OBJS)\coredll_overlaycmn.o: ../../src/common/overlaycmn.cpp $(CXX) -c -o $@ $(COREDLL_CXXFLAGS) $(CPPDEPS) $< -endif - -ifeq ($(USE_GUI),1) -$(OBJS)\coredll_paper.o: ../../src/common/paper.cpp - $(CXX) -c -o $@ $(COREDLL_CXXFLAGS) $(CPPDEPS) $< -endif +endif + +ifeq ($(USE_GUI),1) +$(OBJS)\coredll_ownerdrwcmn.o: ../../src/common/ownerdrwcmn.cpp + $(CXX) -c -o $@ $(COREDLL_CXXFLAGS) $(CPPDEPS) $< +endif + +ifeq ($(USE_GUI),1) +$(OBJS)\coredll_paper.o: ../../src/common/paper.cpp + $(CXX) -c -o $@ $(COREDLL_CXXFLAGS) $(CPPDEPS) $< +endif ifeq ($(USE_GUI),1) $(OBJS)\coredll_persist.o: ../../src/common/persist.cpp @@ -13101,12 +13124,17 @@ endif ifeq ($(USE_GUI),1) $(OBJS)\corelib_overlaycmn.o: ../../src/common/overlaycmn.cpp $(CXX) -c -o $@ $(CORELIB_CXXFLAGS) $(CPPDEPS) $< -endif - -ifeq ($(USE_GUI),1) -$(OBJS)\corelib_paper.o: ../../src/common/paper.cpp - $(CXX) -c -o $@ $(CORELIB_CXXFLAGS) $(CPPDEPS) $< -endif +endif + +ifeq ($(USE_GUI),1) +$(OBJS)\corelib_ownerdrwcmn.o: ../../src/common/ownerdrwcmn.cpp + $(CXX) -c -o $@ $(CORELIB_CXXFLAGS) $(CPPDEPS) $< +endif + +ifeq ($(USE_GUI),1) +$(OBJS)\corelib_paper.o: ../../src/common/paper.cpp + $(CXX) -c -o $@ $(CORELIB_CXXFLAGS) $(CPPDEPS) $< +endif ifeq ($(USE_GUI),1) $(OBJS)\corelib_persist.o: ../../src/common/persist.cpp diff --git a/build/msw/makefile.vc b/build/msw/makefile.vc index 5470043aec..9ec758c9b5 100644 --- a/build/msw/makefile.vc +++ b/build/msw/makefile.vc @@ -2040,12 +2040,13 @@ ____CORE_SRC_FILENAMES_OBJECTS = \ $(OBJS)\monodll_listctrlcmn.obj \ $(OBJS)\monodll_matrix.obj \ $(OBJS)\monodll_menucmn.obj \ - $(OBJS)\monodll_mousemanager.obj \ - $(OBJS)\monodll_nbkbase.obj \ - $(OBJS)\monodll_overlaycmn.obj \ - $(OBJS)\monodll_paper.obj \ - $(OBJS)\monodll_persist.obj \ - $(OBJS)\monodll_pickerbase.obj \ + $(OBJS)\monodll_mousemanager.obj \ + $(OBJS)\monodll_nbkbase.obj \ + $(OBJS)\monodll_overlaycmn.obj \ + $(OBJS)\monodll_ownerdrwcmn.obj \ + $(OBJS)\monodll_paper.obj \ + $(OBJS)\monodll_persist.obj \ + $(OBJS)\monodll_pickerbase.obj \ $(OBJS)\monodll_popupcmn.obj \ $(OBJS)\monodll_prntbase.obj \ $(OBJS)\monodll_quantize.obj \ @@ -2282,12 +2283,13 @@ ____CORE_SRC_FILENAMES_OBJECTS = \ $(OBJS)\monodll_listctrlcmn.obj \ $(OBJS)\monodll_matrix.obj \ $(OBJS)\monodll_menucmn.obj \ - $(OBJS)\monodll_mousemanager.obj \ - $(OBJS)\monodll_nbkbase.obj \ - $(OBJS)\monodll_overlaycmn.obj \ - $(OBJS)\monodll_paper.obj \ - $(OBJS)\monodll_persist.obj \ - $(OBJS)\monodll_pickerbase.obj \ + $(OBJS)\monodll_mousemanager.obj \ + $(OBJS)\monodll_nbkbase.obj \ + $(OBJS)\monodll_overlaycmn.obj \ + $(OBJS)\monodll_ownerdrwcmn.obj \ + $(OBJS)\monodll_paper.obj \ + $(OBJS)\monodll_persist.obj \ + $(OBJS)\monodll_pickerbase.obj \ $(OBJS)\monodll_popupcmn.obj \ $(OBJS)\monodll_prntbase.obj \ $(OBJS)\monodll_quantize.obj \ @@ -2746,12 +2748,13 @@ ____CORE_SRC_FILENAMES_1_OBJECTS = \ $(OBJS)\monolib_listctrlcmn.obj \ $(OBJS)\monolib_matrix.obj \ $(OBJS)\monolib_menucmn.obj \ - $(OBJS)\monolib_mousemanager.obj \ - $(OBJS)\monolib_nbkbase.obj \ - $(OBJS)\monolib_overlaycmn.obj \ - $(OBJS)\monolib_paper.obj \ - $(OBJS)\monolib_persist.obj \ - $(OBJS)\monolib_pickerbase.obj \ + $(OBJS)\monolib_mousemanager.obj \ + $(OBJS)\monolib_nbkbase.obj \ + $(OBJS)\monolib_overlaycmn.obj \ + $(OBJS)\monolib_ownerdrwcmn.obj \ + $(OBJS)\monolib_paper.obj \ + $(OBJS)\monolib_persist.obj \ + $(OBJS)\monolib_pickerbase.obj \ $(OBJS)\monolib_popupcmn.obj \ $(OBJS)\monolib_prntbase.obj \ $(OBJS)\monolib_quantize.obj \ @@ -2988,12 +2991,13 @@ ____CORE_SRC_FILENAMES_1_OBJECTS = \ $(OBJS)\monolib_listctrlcmn.obj \ $(OBJS)\monolib_matrix.obj \ $(OBJS)\monolib_menucmn.obj \ - $(OBJS)\monolib_mousemanager.obj \ - $(OBJS)\monolib_nbkbase.obj \ - $(OBJS)\monolib_overlaycmn.obj \ - $(OBJS)\monolib_paper.obj \ - $(OBJS)\monolib_persist.obj \ - $(OBJS)\monolib_pickerbase.obj \ + $(OBJS)\monolib_mousemanager.obj \ + $(OBJS)\monolib_nbkbase.obj \ + $(OBJS)\monolib_overlaycmn.obj \ + $(OBJS)\monolib_ownerdrwcmn.obj \ + $(OBJS)\monolib_paper.obj \ + $(OBJS)\monolib_persist.obj \ + $(OBJS)\monolib_pickerbase.obj \ $(OBJS)\monolib_popupcmn.obj \ $(OBJS)\monolib_prntbase.obj \ $(OBJS)\monolib_quantize.obj \ @@ -3405,12 +3409,13 @@ ____CORE_SRC_FILENAMES_2_OBJECTS = \ $(OBJS)\coredll_listctrlcmn.obj \ $(OBJS)\coredll_matrix.obj \ $(OBJS)\coredll_menucmn.obj \ - $(OBJS)\coredll_mousemanager.obj \ - $(OBJS)\coredll_nbkbase.obj \ - $(OBJS)\coredll_overlaycmn.obj \ - $(OBJS)\coredll_paper.obj \ - $(OBJS)\coredll_persist.obj \ - $(OBJS)\coredll_pickerbase.obj \ + $(OBJS)\coredll_mousemanager.obj \ + $(OBJS)\coredll_nbkbase.obj \ + $(OBJS)\coredll_overlaycmn.obj \ + $(OBJS)\coredll_ownerdrwcmn.obj \ + $(OBJS)\coredll_paper.obj \ + $(OBJS)\coredll_persist.obj \ + $(OBJS)\coredll_pickerbase.obj \ $(OBJS)\coredll_popupcmn.obj \ $(OBJS)\coredll_prntbase.obj \ $(OBJS)\coredll_quantize.obj \ @@ -3647,12 +3652,13 @@ ____CORE_SRC_FILENAMES_2_OBJECTS = \ $(OBJS)\coredll_listctrlcmn.obj \ $(OBJS)\coredll_matrix.obj \ $(OBJS)\coredll_menucmn.obj \ - $(OBJS)\coredll_mousemanager.obj \ - $(OBJS)\coredll_nbkbase.obj \ - $(OBJS)\coredll_overlaycmn.obj \ - $(OBJS)\coredll_paper.obj \ - $(OBJS)\coredll_persist.obj \ - $(OBJS)\coredll_pickerbase.obj \ + $(OBJS)\coredll_mousemanager.obj \ + $(OBJS)\coredll_nbkbase.obj \ + $(OBJS)\coredll_overlaycmn.obj \ + $(OBJS)\coredll_ownerdrwcmn.obj \ + $(OBJS)\coredll_paper.obj \ + $(OBJS)\coredll_persist.obj \ + $(OBJS)\coredll_pickerbase.obj \ $(OBJS)\coredll_popupcmn.obj \ $(OBJS)\coredll_prntbase.obj \ $(OBJS)\coredll_quantize.obj \ @@ -3900,12 +3906,13 @@ ____CORE_SRC_FILENAMES_3_OBJECTS = \ $(OBJS)\corelib_listctrlcmn.obj \ $(OBJS)\corelib_matrix.obj \ $(OBJS)\corelib_menucmn.obj \ - $(OBJS)\corelib_mousemanager.obj \ - $(OBJS)\corelib_nbkbase.obj \ - $(OBJS)\corelib_overlaycmn.obj \ - $(OBJS)\corelib_paper.obj \ - $(OBJS)\corelib_persist.obj \ - $(OBJS)\corelib_pickerbase.obj \ + $(OBJS)\corelib_mousemanager.obj \ + $(OBJS)\corelib_nbkbase.obj \ + $(OBJS)\corelib_overlaycmn.obj \ + $(OBJS)\corelib_ownerdrwcmn.obj \ + $(OBJS)\corelib_paper.obj \ + $(OBJS)\corelib_persist.obj \ + $(OBJS)\corelib_pickerbase.obj \ $(OBJS)\corelib_popupcmn.obj \ $(OBJS)\corelib_prntbase.obj \ $(OBJS)\corelib_quantize.obj \ @@ -4142,12 +4149,13 @@ ____CORE_SRC_FILENAMES_3_OBJECTS = \ $(OBJS)\corelib_listctrlcmn.obj \ $(OBJS)\corelib_matrix.obj \ $(OBJS)\corelib_menucmn.obj \ - $(OBJS)\corelib_mousemanager.obj \ - $(OBJS)\corelib_nbkbase.obj \ - $(OBJS)\corelib_overlaycmn.obj \ - $(OBJS)\corelib_paper.obj \ - $(OBJS)\corelib_persist.obj \ - $(OBJS)\corelib_pickerbase.obj \ + $(OBJS)\corelib_mousemanager.obj \ + $(OBJS)\corelib_nbkbase.obj \ + $(OBJS)\corelib_overlaycmn.obj \ + $(OBJS)\corelib_ownerdrwcmn.obj \ + $(OBJS)\corelib_paper.obj \ + $(OBJS)\corelib_persist.obj \ + $(OBJS)\corelib_pickerbase.obj \ $(OBJS)\corelib_popupcmn.obj \ $(OBJS)\corelib_prntbase.obj \ $(OBJS)\corelib_quantize.obj \ @@ -7901,12 +7909,17 @@ $(OBJS)\monodll_nbkbase.obj: ..\..\src\common\nbkbase.cpp !if "$(USE_GUI)" == "1" $(OBJS)\monodll_overlaycmn.obj: ..\..\src\common\overlaycmn.cpp $(CXX) /c /nologo /TP /Fo$@ $(MONODLL_CXXFLAGS) ..\..\src\common\overlaycmn.cpp -!endif - -!if "$(USE_GUI)" == "1" -$(OBJS)\monodll_paper.obj: ..\..\src\common\paper.cpp - $(CXX) /c /nologo /TP /Fo$@ $(MONODLL_CXXFLAGS) ..\..\src\common\paper.cpp -!endif +!endif + +!if "$(USE_GUI)" == "1" +$(OBJS)\monodll_ownerdrwcmn.obj: ..\..\src\common\ownerdrwcmn.cpp + $(CXX) /c /nologo /TP /Fo$@ $(MONODLL_CXXFLAGS) ..\..\src\common\ownerdrwcmn.cpp +!endif + +!if "$(USE_GUI)" == "1" +$(OBJS)\monodll_paper.obj: ..\..\src\common\paper.cpp + $(CXX) /c /nologo /TP /Fo$@ $(MONODLL_CXXFLAGS) ..\..\src\common\paper.cpp +!endif !if "$(USE_GUI)" == "1" $(OBJS)\monodll_persist.obj: ..\..\src\common\persist.cpp @@ -10078,12 +10091,17 @@ $(OBJS)\monolib_nbkbase.obj: ..\..\src\common\nbkbase.cpp !if "$(USE_GUI)" == "1" $(OBJS)\monolib_overlaycmn.obj: ..\..\src\common\overlaycmn.cpp $(CXX) /c /nologo /TP /Fo$@ $(MONOLIB_CXXFLAGS) ..\..\src\common\overlaycmn.cpp -!endif - -!if "$(USE_GUI)" == "1" -$(OBJS)\monolib_paper.obj: ..\..\src\common\paper.cpp - $(CXX) /c /nologo /TP /Fo$@ $(MONOLIB_CXXFLAGS) ..\..\src\common\paper.cpp -!endif +!endif + +!if "$(USE_GUI)" == "1" +$(OBJS)\monolib_ownerdrwcmn.obj: ..\..\src\common\ownerdrwcmn.cpp + $(CXX) /c /nologo /TP /Fo$@ $(MONOLIB_CXXFLAGS) ..\..\src\common\ownerdrwcmn.cpp +!endif + +!if "$(USE_GUI)" == "1" +$(OBJS)\monolib_paper.obj: ..\..\src\common\paper.cpp + $(CXX) /c /nologo /TP /Fo$@ $(MONOLIB_CXXFLAGS) ..\..\src\common\paper.cpp +!endif !if "$(USE_GUI)" == "1" $(OBJS)\monolib_persist.obj: ..\..\src\common\persist.cpp @@ -12258,12 +12276,17 @@ $(OBJS)\coredll_nbkbase.obj: ..\..\src\common\nbkbase.cpp !if "$(USE_GUI)" == "1" $(OBJS)\coredll_overlaycmn.obj: ..\..\src\common\overlaycmn.cpp $(CXX) /c /nologo /TP /Fo$@ $(COREDLL_CXXFLAGS) ..\..\src\common\overlaycmn.cpp -!endif - -!if "$(USE_GUI)" == "1" -$(OBJS)\coredll_paper.obj: ..\..\src\common\paper.cpp - $(CXX) /c /nologo /TP /Fo$@ $(COREDLL_CXXFLAGS) ..\..\src\common\paper.cpp -!endif +!endif + +!if "$(USE_GUI)" == "1" +$(OBJS)\coredll_ownerdrwcmn.obj: ..\..\src\common\ownerdrwcmn.cpp + $(CXX) /c /nologo /TP /Fo$@ $(COREDLL_CXXFLAGS) ..\..\src\common\ownerdrwcmn.cpp +!endif + +!if "$(USE_GUI)" == "1" +$(OBJS)\coredll_paper.obj: ..\..\src\common\paper.cpp + $(CXX) /c /nologo /TP /Fo$@ $(COREDLL_CXXFLAGS) ..\..\src\common\paper.cpp +!endif !if "$(USE_GUI)" == "1" $(OBJS)\coredll_persist.obj: ..\..\src\common\persist.cpp @@ -13532,12 +13555,17 @@ $(OBJS)\corelib_nbkbase.obj: ..\..\src\common\nbkbase.cpp !if "$(USE_GUI)" == "1" $(OBJS)\corelib_overlaycmn.obj: ..\..\src\common\overlaycmn.cpp $(CXX) /c /nologo /TP /Fo$@ $(CORELIB_CXXFLAGS) ..\..\src\common\overlaycmn.cpp -!endif - -!if "$(USE_GUI)" == "1" -$(OBJS)\corelib_paper.obj: ..\..\src\common\paper.cpp - $(CXX) /c /nologo /TP /Fo$@ $(CORELIB_CXXFLAGS) ..\..\src\common\paper.cpp -!endif +!endif + +!if "$(USE_GUI)" == "1" +$(OBJS)\corelib_ownerdrwcmn.obj: ..\..\src\common\ownerdrwcmn.cpp + $(CXX) /c /nologo /TP /Fo$@ $(CORELIB_CXXFLAGS) ..\..\src\common\ownerdrwcmn.cpp +!endif + +!if "$(USE_GUI)" == "1" +$(OBJS)\corelib_paper.obj: ..\..\src\common\paper.cpp + $(CXX) /c /nologo /TP /Fo$@ $(CORELIB_CXXFLAGS) ..\..\src\common\paper.cpp +!endif !if "$(USE_GUI)" == "1" $(OBJS)\corelib_persist.obj: ..\..\src\common\persist.cpp diff --git a/build/msw/makefile.wat b/build/msw/makefile.wat index 105d4bbe92..fcf8be5add 100644 --- a/build/msw/makefile.wat +++ b/build/msw/makefile.wat @@ -408,12 +408,13 @@ ____CORE_SRC_FILENAMES_OBJECTS = & $(OBJS)\monodll_listctrlcmn.obj & $(OBJS)\monodll_matrix.obj & $(OBJS)\monodll_menucmn.obj & - $(OBJS)\monodll_mousemanager.obj & - $(OBJS)\monodll_nbkbase.obj & - $(OBJS)\monodll_overlaycmn.obj & - $(OBJS)\monodll_paper.obj & - $(OBJS)\monodll_persist.obj & - $(OBJS)\monodll_pickerbase.obj & + $(OBJS)\monodll_mousemanager.obj & + $(OBJS)\monodll_nbkbase.obj & + $(OBJS)\monodll_overlaycmn.obj & + $(OBJS)\monodll_ownerdrwcmn.obj & + $(OBJS)\monodll_paper.obj & + $(OBJS)\monodll_persist.obj & + $(OBJS)\monodll_pickerbase.obj & $(OBJS)\monodll_popupcmn.obj & $(OBJS)\monodll_prntbase.obj & $(OBJS)\monodll_quantize.obj & @@ -652,12 +653,13 @@ ____CORE_SRC_FILENAMES_OBJECTS = & $(OBJS)\monodll_listctrlcmn.obj & $(OBJS)\monodll_matrix.obj & $(OBJS)\monodll_menucmn.obj & - $(OBJS)\monodll_mousemanager.obj & - $(OBJS)\monodll_nbkbase.obj & - $(OBJS)\monodll_overlaycmn.obj & - $(OBJS)\monodll_paper.obj & - $(OBJS)\monodll_persist.obj & - $(OBJS)\monodll_pickerbase.obj & + $(OBJS)\monodll_mousemanager.obj & + $(OBJS)\monodll_nbkbase.obj & + $(OBJS)\monodll_overlaycmn.obj & + $(OBJS)\monodll_ownerdrwcmn.obj & + $(OBJS)\monodll_paper.obj & + $(OBJS)\monodll_persist.obj & + $(OBJS)\monodll_pickerbase.obj & $(OBJS)\monodll_popupcmn.obj & $(OBJS)\monodll_prntbase.obj & $(OBJS)\monodll_quantize.obj & @@ -1119,12 +1121,13 @@ ____CORE_SRC_FILENAMES_1_OBJECTS = & $(OBJS)\monolib_listctrlcmn.obj & $(OBJS)\monolib_matrix.obj & $(OBJS)\monolib_menucmn.obj & - $(OBJS)\monolib_mousemanager.obj & - $(OBJS)\monolib_nbkbase.obj & - $(OBJS)\monolib_overlaycmn.obj & - $(OBJS)\monolib_paper.obj & - $(OBJS)\monolib_persist.obj & - $(OBJS)\monolib_pickerbase.obj & + $(OBJS)\monolib_mousemanager.obj & + $(OBJS)\monolib_nbkbase.obj & + $(OBJS)\monolib_overlaycmn.obj & + $(OBJS)\monolib_ownerdrwcmn.obj & + $(OBJS)\monolib_paper.obj & + $(OBJS)\monolib_persist.obj & + $(OBJS)\monolib_pickerbase.obj & $(OBJS)\monolib_popupcmn.obj & $(OBJS)\monolib_prntbase.obj & $(OBJS)\monolib_quantize.obj & @@ -1363,12 +1366,13 @@ ____CORE_SRC_FILENAMES_1_OBJECTS = & $(OBJS)\monolib_listctrlcmn.obj & $(OBJS)\monolib_matrix.obj & $(OBJS)\monolib_menucmn.obj & - $(OBJS)\monolib_mousemanager.obj & - $(OBJS)\monolib_nbkbase.obj & - $(OBJS)\monolib_overlaycmn.obj & - $(OBJS)\monolib_paper.obj & - $(OBJS)\monolib_persist.obj & - $(OBJS)\monolib_pickerbase.obj & + $(OBJS)\monolib_mousemanager.obj & + $(OBJS)\monolib_nbkbase.obj & + $(OBJS)\monolib_overlaycmn.obj & + $(OBJS)\monolib_ownerdrwcmn.obj & + $(OBJS)\monolib_paper.obj & + $(OBJS)\monolib_persist.obj & + $(OBJS)\monolib_pickerbase.obj & $(OBJS)\monolib_popupcmn.obj & $(OBJS)\monolib_prntbase.obj & $(OBJS)\monolib_quantize.obj & @@ -1739,12 +1743,13 @@ ____CORE_SRC_FILENAMES_2_OBJECTS = & $(OBJS)\coredll_listctrlcmn.obj & $(OBJS)\coredll_matrix.obj & $(OBJS)\coredll_menucmn.obj & - $(OBJS)\coredll_mousemanager.obj & - $(OBJS)\coredll_nbkbase.obj & - $(OBJS)\coredll_overlaycmn.obj & - $(OBJS)\coredll_paper.obj & - $(OBJS)\coredll_persist.obj & - $(OBJS)\coredll_pickerbase.obj & + $(OBJS)\coredll_mousemanager.obj & + $(OBJS)\coredll_nbkbase.obj & + $(OBJS)\coredll_overlaycmn.obj & + $(OBJS)\coredll_ownerdrwcmn.obj & + $(OBJS)\coredll_paper.obj & + $(OBJS)\coredll_persist.obj & + $(OBJS)\coredll_pickerbase.obj & $(OBJS)\coredll_popupcmn.obj & $(OBJS)\coredll_prntbase.obj & $(OBJS)\coredll_quantize.obj & @@ -1983,12 +1988,13 @@ ____CORE_SRC_FILENAMES_2_OBJECTS = & $(OBJS)\coredll_listctrlcmn.obj & $(OBJS)\coredll_matrix.obj & $(OBJS)\coredll_menucmn.obj & - $(OBJS)\coredll_mousemanager.obj & - $(OBJS)\coredll_nbkbase.obj & - $(OBJS)\coredll_overlaycmn.obj & - $(OBJS)\coredll_paper.obj & - $(OBJS)\coredll_persist.obj & - $(OBJS)\coredll_pickerbase.obj & + $(OBJS)\coredll_mousemanager.obj & + $(OBJS)\coredll_nbkbase.obj & + $(OBJS)\coredll_overlaycmn.obj & + $(OBJS)\coredll_ownerdrwcmn.obj & + $(OBJS)\coredll_paper.obj & + $(OBJS)\coredll_persist.obj & + $(OBJS)\coredll_pickerbase.obj & $(OBJS)\coredll_popupcmn.obj & $(OBJS)\coredll_prntbase.obj & $(OBJS)\coredll_quantize.obj & @@ -2238,12 +2244,13 @@ ____CORE_SRC_FILENAMES_3_OBJECTS = & $(OBJS)\corelib_listctrlcmn.obj & $(OBJS)\corelib_matrix.obj & $(OBJS)\corelib_menucmn.obj & - $(OBJS)\corelib_mousemanager.obj & - $(OBJS)\corelib_nbkbase.obj & - $(OBJS)\corelib_overlaycmn.obj & - $(OBJS)\corelib_paper.obj & - $(OBJS)\corelib_persist.obj & - $(OBJS)\corelib_pickerbase.obj & + $(OBJS)\corelib_mousemanager.obj & + $(OBJS)\corelib_nbkbase.obj & + $(OBJS)\corelib_overlaycmn.obj & + $(OBJS)\corelib_ownerdrwcmn.obj & + $(OBJS)\corelib_paper.obj & + $(OBJS)\corelib_persist.obj & + $(OBJS)\corelib_pickerbase.obj & $(OBJS)\corelib_popupcmn.obj & $(OBJS)\corelib_prntbase.obj & $(OBJS)\corelib_quantize.obj & @@ -2482,12 +2489,13 @@ ____CORE_SRC_FILENAMES_3_OBJECTS = & $(OBJS)\corelib_listctrlcmn.obj & $(OBJS)\corelib_matrix.obj & $(OBJS)\corelib_menucmn.obj & - $(OBJS)\corelib_mousemanager.obj & - $(OBJS)\corelib_nbkbase.obj & - $(OBJS)\corelib_overlaycmn.obj & - $(OBJS)\corelib_paper.obj & - $(OBJS)\corelib_persist.obj & - $(OBJS)\corelib_pickerbase.obj & + $(OBJS)\corelib_mousemanager.obj & + $(OBJS)\corelib_nbkbase.obj & + $(OBJS)\corelib_overlaycmn.obj & + $(OBJS)\corelib_ownerdrwcmn.obj & + $(OBJS)\corelib_paper.obj & + $(OBJS)\corelib_persist.obj & + $(OBJS)\corelib_pickerbase.obj & $(OBJS)\corelib_popupcmn.obj & $(OBJS)\corelib_prntbase.obj & $(OBJS)\corelib_quantize.obj & @@ -7729,12 +7737,17 @@ $(OBJS)\monodll_nbkbase.obj : .AUTODEPEND ..\..\src\common\nbkbase.cpp !ifeq USE_GUI 1 $(OBJS)\monodll_overlaycmn.obj : .AUTODEPEND ..\..\src\common\overlaycmn.cpp $(CXX) -bt=nt -zq -fo=$^@ $(MONODLL_CXXFLAGS) $< -!endif - -!ifeq USE_GUI 1 -$(OBJS)\monodll_paper.obj : .AUTODEPEND ..\..\src\common\paper.cpp - $(CXX) -bt=nt -zq -fo=$^@ $(MONODLL_CXXFLAGS) $< -!endif +!endif + +!ifeq USE_GUI 1 +$(OBJS)\monodll_ownerdrwcmn.obj : .AUTODEPEND ..\..\src\common\ownerdrwcmn.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(MONODLL_CXXFLAGS) $< +!endif + +!ifeq USE_GUI 1 +$(OBJS)\monodll_paper.obj : .AUTODEPEND ..\..\src\common\paper.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(MONODLL_CXXFLAGS) $< +!endif !ifeq USE_GUI 1 $(OBJS)\monodll_persist.obj : .AUTODEPEND ..\..\src\common\persist.cpp @@ -9906,12 +9919,17 @@ $(OBJS)\monolib_nbkbase.obj : .AUTODEPEND ..\..\src\common\nbkbase.cpp !ifeq USE_GUI 1 $(OBJS)\monolib_overlaycmn.obj : .AUTODEPEND ..\..\src\common\overlaycmn.cpp $(CXX) -bt=nt -zq -fo=$^@ $(MONOLIB_CXXFLAGS) $< -!endif - -!ifeq USE_GUI 1 -$(OBJS)\monolib_paper.obj : .AUTODEPEND ..\..\src\common\paper.cpp - $(CXX) -bt=nt -zq -fo=$^@ $(MONOLIB_CXXFLAGS) $< -!endif +!endif + +!ifeq USE_GUI 1 +$(OBJS)\monolib_ownerdrwcmn.obj : .AUTODEPEND ..\..\src\common\ownerdrwcmn.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(MONOLIB_CXXFLAGS) $< +!endif + +!ifeq USE_GUI 1 +$(OBJS)\monolib_paper.obj : .AUTODEPEND ..\..\src\common\paper.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(MONOLIB_CXXFLAGS) $< +!endif !ifeq USE_GUI 1 $(OBJS)\monolib_persist.obj : .AUTODEPEND ..\..\src\common\persist.cpp @@ -12086,12 +12104,17 @@ $(OBJS)\coredll_nbkbase.obj : .AUTODEPEND ..\..\src\common\nbkbase.cpp !ifeq USE_GUI 1 $(OBJS)\coredll_overlaycmn.obj : .AUTODEPEND ..\..\src\common\overlaycmn.cpp $(CXX) -bt=nt -zq -fo=$^@ $(COREDLL_CXXFLAGS) $< -!endif - -!ifeq USE_GUI 1 -$(OBJS)\coredll_paper.obj : .AUTODEPEND ..\..\src\common\paper.cpp - $(CXX) -bt=nt -zq -fo=$^@ $(COREDLL_CXXFLAGS) $< -!endif +!endif + +!ifeq USE_GUI 1 +$(OBJS)\coredll_ownerdrwcmn.obj : .AUTODEPEND ..\..\src\common\ownerdrwcmn.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(COREDLL_CXXFLAGS) $< +!endif + +!ifeq USE_GUI 1 +$(OBJS)\coredll_paper.obj : .AUTODEPEND ..\..\src\common\paper.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(COREDLL_CXXFLAGS) $< +!endif !ifeq USE_GUI 1 $(OBJS)\coredll_persist.obj : .AUTODEPEND ..\..\src\common\persist.cpp @@ -13360,12 +13383,17 @@ $(OBJS)\corelib_nbkbase.obj : .AUTODEPEND ..\..\src\common\nbkbase.cpp !ifeq USE_GUI 1 $(OBJS)\corelib_overlaycmn.obj : .AUTODEPEND ..\..\src\common\overlaycmn.cpp $(CXX) -bt=nt -zq -fo=$^@ $(CORELIB_CXXFLAGS) $< -!endif - -!ifeq USE_GUI 1 -$(OBJS)\corelib_paper.obj : .AUTODEPEND ..\..\src\common\paper.cpp - $(CXX) -bt=nt -zq -fo=$^@ $(CORELIB_CXXFLAGS) $< -!endif +!endif + +!ifeq USE_GUI 1 +$(OBJS)\corelib_ownerdrwcmn.obj : .AUTODEPEND ..\..\src\common\ownerdrwcmn.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(CORELIB_CXXFLAGS) $< +!endif + +!ifeq USE_GUI 1 +$(OBJS)\corelib_paper.obj : .AUTODEPEND ..\..\src\common\paper.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(CORELIB_CXXFLAGS) $< +!endif !ifeq USE_GUI 1 $(OBJS)\corelib_persist.obj : .AUTODEPEND ..\..\src\common\persist.cpp diff --git a/build/msw/wx_core.dsp b/build/msw/wx_core.dsp index 9a423580a4..d72ce20ed2 100644 --- a/build/msw/wx_core.dsp +++ b/build/msw/wx_core.dsp @@ -562,6 +562,10 @@ SOURCE=..\..\src\common\overlaycmn.cpp # End Source File # Begin Source File +SOURCE=..\..\src\common\ownerdrwcmn.cpp +# End Source File +# Begin Source File + SOURCE=..\..\src\common\paper.cpp # End Source File # Begin Source File @@ -5071,6 +5075,10 @@ SOURCE=..\..\include\wx\msw\ole\oleutils.h # End Source File # Begin Source File +SOURCE=..\..\include\wx\msw\ownerdrw.h +# End Source File +# Begin Source File + SOURCE=..\..\include\wx\msw\palette.h # End Source File # Begin Source File diff --git a/build/msw/wx_vc7_core.vcproj b/build/msw/wx_vc7_core.vcproj index f708979ee1..49348c7a7a 100644 --- a/build/msw/wx_vc7_core.vcproj +++ b/build/msw/wx_vc7_core.vcproj @@ -814,6 +814,9 @@ RelativePath="..\..\src\common\overlaycmn.cpp"> + + + + + + @@ -5908,6 +5912,10 @@ > + + diff --git a/build/msw/wx_vc9_core.vcproj b/build/msw/wx_vc9_core.vcproj index 2b06cc43a8..9492ec5dad 100644 --- a/build/msw/wx_vc9_core.vcproj +++ b/build/msw/wx_vc9_core.vcproj @@ -1115,6 +1115,10 @@ > + + @@ -5904,6 +5908,10 @@ > + + diff --git a/include/wx/msw/listbox.h b/include/wx/msw/listbox.h index 8157cbdcbd..47a94037b3 100644 --- a/include/wx/msw/listbox.h +++ b/include/wx/msw/listbox.h @@ -152,9 +152,6 @@ protected: bool m_updateHorizontalExtent; virtual void OnInternalIdle(); - // free memory (common part of Clear() and dtor) - void Free(); - unsigned int m_noItems; #if wxUSE_OWNER_DRAWN diff --git a/include/wx/msw/menuitem.h b/include/wx/msw/menuitem.h index 4efe3b98b7..0671283cf0 100644 --- a/include/wx/msw/menuitem.h +++ b/include/wx/msw/menuitem.h @@ -17,7 +17,8 @@ // ---------------------------------------------------------------------------- #if wxUSE_OWNER_DRAWN - #include "wx/ownerdrw.h" // base class + #include "wx/ownerdrw.h" + #include "wx/bitmap.h" #endif // ---------------------------------------------------------------------------- @@ -41,7 +42,6 @@ public: // override base class virtuals virtual void SetItemLabel(const wxString& strName); - virtual void SetCheckable(bool checkable); virtual void Enable(bool bDoEnable = true); virtual void Check(bool bDoCheck = true); @@ -76,6 +76,48 @@ public: ); #endif +#if wxUSE_OWNER_DRAWN + + void SetBitmaps(const wxBitmap& bmpChecked, + const wxBitmap& bmpUnchecked = wxNullBitmap) + { + m_bmpChecked = bmpChecked; + m_bmpUnchecked = bmpUnchecked; + SetOwnerDrawn(true); + } + + void SetBitmap(const wxBitmap& bmp, bool bChecked = true) + { + if ( bChecked ) + m_bmpChecked = bmp; + else + m_bmpUnchecked = bmp; + SetOwnerDrawn(true); + } + + void SetDisabledBitmap(const wxBitmap& bmpDisabled) + { + m_bmpDisabled = bmpDisabled; + SetOwnerDrawn(true); + } + + const wxBitmap& GetBitmap(bool bChecked = true) const + { return (bChecked ? m_bmpChecked : m_bmpUnchecked); } + + const wxBitmap& GetDisabledBitmap() const + { return m_bmpDisabled; } + + + // override wxOwnerDrawn base class virtuals + virtual wxString GetName() const; + virtual bool OnMeasureItem(size_t *pwidth, size_t *pheight); + virtual bool OnDrawItem(wxDC& dc, const wxRect& rc, wxODAction act, wxODStatus stat); + +protected: + virtual void GetFontToUse(wxFont& font) const; + +#endif // wxUSE_OWNER_DRAWN + private: // common part of all ctors void Init(); @@ -93,6 +135,18 @@ private: // does this item start a radio group? bool m_isRadioGroupStart; +#if wxUSE_OWNER_DRAWN + // item bitmaps + wxBitmap m_bmpChecked, // bitmap to put near the item + m_bmpUnchecked, // (checked is used also for 'uncheckable' items) + m_bmpDisabled; + + // static variables for cache some system settings + static wxFont ms_systemMenuFont; + static size_t ms_systemMenuHeight; + static bool ms_alwaysShowCues; +#endif // wxUSE_OWNER_DRAWN + DECLARE_DYNAMIC_CLASS_NO_COPY(wxMenuItem) }; diff --git a/include/wx/msw/ownerdrw.h b/include/wx/msw/ownerdrw.h new file mode 100644 index 0000000000..5992294657 --- /dev/null +++ b/include/wx/msw/ownerdrw.h @@ -0,0 +1,29 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: wx/msw/ownerdrw.h +// Purpose: wxOwnerDrawn class +// Author: Marcin Malich +// Modified by: +// Created: 2009-09-22 +// RCS-ID: $Id$ +// Copyright: (c) 2009 Marcin Malich +// Licence: wxWindows licence +/////////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_OWNERDRW_H_ +#define _WX_OWNERDRW_H_ + +#if wxUSE_OWNER_DRAWN + +class WXDLLIMPEXP_CORE wxOwnerDrawn : public wxOwnerDrawnBase +{ +public: + wxOwnerDrawn() {} + virtual ~wxOwnerDrawn() {} + + virtual bool OnDrawItem(wxDC& dc, const wxRect& rc, + wxODAction act, wxODStatus stat); +}; + +#endif // wxUSE_OWNER_DRAWN + +#endif // _WX_OWNERDRW_H_ diff --git a/include/wx/os2/menuitem.h b/include/wx/os2/menuitem.h index 3c726a9226..4cfa9b06b3 100644 --- a/include/wx/os2/menuitem.h +++ b/include/wx/os2/menuitem.h @@ -23,7 +23,8 @@ // headers - only because ownerdrw.h is not always included and I don't want // to write #ifdef's everywhere... #if wxUSE_OWNER_DRAWN - #include "wx/ownerdrw.h" + #include "wx/ownerdrw.h" + #include "wx/bitmap.h" #endif // ---------------------------------------------------------------------------- @@ -66,7 +67,6 @@ public: // Override base class virtuals // virtual void SetItemLabel(const wxString& rStrName); - virtual void SetCheckable(bool bCheckable); virtual void Enable(bool bDoEnable = true); virtual void Check(bool bDoCheck = true); @@ -97,6 +97,48 @@ public: // MENUITEM m_vMenuData; +#if wxUSE_OWNER_DRAWN + + void SetBitmaps(const wxBitmap& bmpChecked, + const wxBitmap& bmpUnchecked = wxNullBitmap) + { + m_bmpChecked = bmpChecked; + m_bmpUnchecked = bmpUnchecked; + SetOwnerDrawn(true); + } + + void SetBitmap(const wxBitmap& bmp, bool bChecked = true) + { + if ( bChecked ) + m_bmpChecked = bmp; + else + m_bmpUnchecked = bmp; + SetOwnerDrawn(true); + } + + void SetDisabledBitmap(const wxBitmap& bmpDisabled) + { + m_bmpDisabled = bmpDisabled; + SetOwnerDrawn(true); + } + + const wxBitmap& GetBitmap(bool bChecked = true) const + { return (bChecked ? m_bmpChecked : m_bmpUnchecked); } + + const wxBitmap& GetDisabledBitmap() const + { return m_bmpDisabled; } + + + // override wxOwnerDrawn base class virtuals + virtual wxString GetName() const; + virtual bool OnMeasureItem(size_t *pwidth, size_t *pheight); + virtual bool OnDrawItem(wxDC& dc, const wxRect& rc, wxODAction act, wxODStatus stat); + +protected: + virtual void GetFontToUse(wxFont& font) const; + +#endif // wxUSE_OWNER_DRAWN + private: void Init(); @@ -117,6 +159,13 @@ private: // bool m_bIsRadioGroupStart; +#if wxUSE_OWNER_DRAWN + // item bitmaps + wxBitmap m_bmpChecked, // bitmap to put near the item + m_bmpUnchecked, // (checked is used also for 'uncheckable' items) + m_bmpDisabled; +#endif // wxUSE_OWNER_DRAWN + DECLARE_DYNAMIC_CLASS(wxMenuItem) }; // end of CLASS wxMenuItem diff --git a/include/wx/os2/ownerdrw.h b/include/wx/os2/ownerdrw.h new file mode 100644 index 0000000000..05dd13b7af --- /dev/null +++ b/include/wx/os2/ownerdrw.h @@ -0,0 +1,29 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: wx/os2/ownerdrw.h +// Purpose: wxOwnerDrawn class +// Author: Marcin Malich +// Modified by: +// Created: 2009-09-22 +// RCS-ID: $Id$ +// Copyright: (c) 2009 Marcin Malich +// Licence: wxWindows licence +/////////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_OWNERDRW_H_ +#define _WX_OWNERDRW_H_ + +#if wxUSE_OWNER_DRAWN + +class WXDLLIMPEXP_CORE wxOwnerDrawn : public wxOwnerDrawnBase +{ +public: + wxOwnerDrawn() {} + virtual ~wxOwnerDrawn() {} + + virtual bool OnDrawItem(wxDC& dc, const wxRect& rc, + wxODAction act, wxODStatus stat); +}; + +#endif // wxUSE_OWNER_DRAWN + +#endif // _WX_OWNERDRW_H_ diff --git a/include/wx/ownerdrw.h b/include/wx/ownerdrw.h index 50e85b4a64..242f508193 100644 --- a/include/wx/ownerdrw.h +++ b/include/wx/ownerdrw.h @@ -2,23 +2,22 @@ // Name: ownerdrw.h // Purpose: interface for owner-drawn GUI elements // Author: Vadim Zeitlin -// Modified by: +// Modified by: Marcin Malich // Created: 11.11.97 // RCS-ID: $Id$ // Copyright: (c) 1998 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// -#ifndef _OWNERDRW_H -#define _OWNERDRW_H +#ifndef _WX_OWNERDRW_H_BASE +#define _WX_OWNERDRW_H_BASE #include "wx/defs.h" #if wxUSE_OWNER_DRAWN -#include "wx/bitmap.h" -#include "wx/colour.h" #include "wx/font.h" +#include "wx/colour.h" // ---------------------------------------------------------------------------- // wxOwnerDrawn - a mix-in base class, derive from it to implement owner-drawn @@ -29,150 +28,116 @@ // element or one unchangeable bitmap otherwise. // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxOwnerDrawn +class WXDLLIMPEXP_CORE wxOwnerDrawnBase { public: - // ctor & dtor - wxOwnerDrawn(const wxString& str = wxEmptyString, - bool bCheckable = false, - bool bMenuItem = false); // FIXME kludge for colors - virtual ~wxOwnerDrawn(); - - // fix appearance - void SetFont(const wxFont& font) - { m_font = font; m_bOwnerDrawn = true; } - - wxFont& GetFont() const { return (wxFont &)m_font; } - - void SetTextColour(const wxColour& colText) - { m_colText = colText; m_bOwnerDrawn = true; } - - wxColour& GetTextColour() const { return (wxColour&) m_colText; } - - void SetBackgroundColour(const wxColour& colBack) - { m_colBack = colBack; m_bOwnerDrawn = true; } - - wxColour& GetBackgroundColour() const - { return (wxColour&) m_colBack ; } - - void SetBitmaps(const wxBitmap& bmpChecked, - const wxBitmap& bmpUnchecked = wxNullBitmap) - { m_bmpChecked = bmpChecked; - m_bmpUnchecked = bmpUnchecked; - m_bOwnerDrawn = true; } - - void SetBitmap(const wxBitmap& bmp, bool bChecked = true) - { - if ( bChecked ) - m_bmpChecked = bmp; - else - m_bmpUnchecked = bmp; - m_bOwnerDrawn = true; - } - - void SetDisabledBitmap( const wxBitmap& bmpDisabled ) - { m_bmpDisabled = bmpDisabled; - m_bOwnerDrawn = true; } - - const wxBitmap& GetBitmap(bool bChecked = true) const - { return (bChecked ? m_bmpChecked : m_bmpUnchecked); } - - const wxBitmap& GetDisabledBitmap() const - { return m_bmpDisabled; } - - // the height of the menu checkmark (or bitmap) is determined by the font - // for the current item, but the width should be always the same (for the - // items to be aligned), so by default it's taken to be the same as for - // the last item (and default width for the first one). - // - // NB: default is too small for bitmaps, but ok for checkmarks. - void SetMarginWidth(int nWidth) - { - ms_nLastMarginWidth = m_nMarginWidth = (size_t) nWidth; - if ( ((size_t) nWidth) != ms_nDefaultMarginWidth ) - m_bOwnerDrawn = true; - } - - int GetMarginWidth() const { return (int) m_nMarginWidth; } - static int GetDefaultMarginWidth() { return (int) ms_nDefaultMarginWidth; } - - // accessors - void SetName(const wxString& strName) { m_strName = strName; } - const wxString& GetName() const { return m_strName; } - void SetCheckable(bool checkable) { m_bCheckable = checkable; } - bool IsCheckable() const { return m_bCheckable; } - - // this is for menu items only: accel string is drawn right aligned after the - // menu item if not empty - void SetAccelString(const wxString& strAccel) { m_strAccel = strAccel; } + wxOwnerDrawnBase() + { + m_ownerDrawn = false; + m_margin = ms_defaultMargin; + } + + virtual ~wxOwnerDrawnBase() {} + + void SetFont(const wxFont& font) + { m_font = font; m_ownerDrawn = true; } + + wxFont& GetFont() const + { return (wxFont&) m_font; } + + + void SetTextColour(const wxColour& colText) + { m_colText = colText; m_ownerDrawn = true; } + + wxColour& GetTextColour() const + { return (wxColour&) m_colText; } + + void SetBackgroundColour(const wxColour& colBack) + { m_colBack = colBack; m_ownerDrawn = true; } + + wxColour& GetBackgroundColour() const + { return (wxColour&) m_colBack ; } + + + void SetMarginWidth(int width) + { m_margin = width; } + + int GetMarginWidth() const + { return m_margin; } + + static int GetDefaultMarginWidth() + { return ms_defaultMargin; } + + + // get item name (with mnemonics if exist) + virtual wxString GetName() const = 0; + // this function might seem strange, but if it returns false it means that // no non-standard attribute are set, so there is no need for this control // to be owner-drawn. Moreover, you can force owner-drawn to false if you // want to change, say, the color for the item but only if it is owner-drawn // (see wxMenuItem::wxMenuItem for example) - bool IsOwnerDrawn() const { return m_bOwnerDrawn; } - - // switch on/off owner-drawing the item - void SetOwnerDrawn(bool ownerDrawn = true) { m_bOwnerDrawn = ownerDrawn; } - void ResetOwnerDrawn() { m_bOwnerDrawn = false; } - -public: - // constants used in OnDrawItem - // (they have the same values as corresponding Win32 constants) - enum wxODAction - { - wxODDrawAll = 0x0001, // redraw entire control - wxODSelectChanged = 0x0002, // selection changed (see Status.Select) - wxODFocusChanged = 0x0004 // keyboard focus changed (see Status.Focus) - }; - - enum wxODStatus - { - wxODSelected = 0x0001, // control is currently selected - wxODGrayed = 0x0002, // item is to be grayed - wxODDisabled = 0x0004, // item is to be drawn as disabled - wxODChecked = 0x0008, // item is to be checked - wxODHasFocus = 0x0010, // item has the keyboard focus - wxODDefault = 0x0020, // item is the default item - wxODHidePrefix= 0x0100 // hide keyboard cues (w2k and xp only) - }; - - // virtual functions to implement drawing (return true if processed) - virtual bool OnMeasureItem(size_t *pwidth, size_t *pheight); - virtual bool OnDrawItem(wxDC& dc, const wxRect& rc, wxODAction act, wxODStatus stat); + bool IsOwnerDrawn() const + { return m_ownerDrawn; } + + // switch on/off owner-drawing the item + void SetOwnerDrawn(bool ownerDrawn = true) + { m_ownerDrawn = ownerDrawn; } + + + // constants used in OnDrawItem + // (they have the same values as corresponding Win32 constants) + enum wxODAction + { + wxODDrawAll = 0x0001, // redraw entire control + wxODSelectChanged = 0x0002, // selection changed (see Status.Select) + wxODFocusChanged = 0x0004 // keyboard focus changed (see Status.Focus) + }; + + enum wxODStatus + { + wxODSelected = 0x0001, // control is currently selected + wxODGrayed = 0x0002, // item is to be grayed + wxODDisabled = 0x0004, // item is to be drawn as disabled + wxODChecked = 0x0008, // item is to be checked + wxODHasFocus = 0x0010, // item has the keyboard focus + wxODDefault = 0x0020, // item is the default item + wxODHidePrefix= 0x0100 // hide keyboard cues (w2k and xp only) + }; + + // virtual functions to implement drawing (return true if processed) + virtual bool OnMeasureItem(size_t *width, size_t *height); + virtual bool OnDrawItem(wxDC& dc, const wxRect& rc, wxODAction act, wxODStatus stat) = 0; protected: - // return true if this is a menu item - bool IsMenuItem() const; - // get the font to use, whether m_font is set or not - wxFont GetFontToUse() const; + // get the font and colour to use, whether it is set or not + virtual void GetFontToUse(wxFont& font) const; + virtual void GetColourToUse(wxODStatus stat, wxColour& colText, wxColour& colBack) const; +private: + bool m_ownerDrawn; // true if something is non standard - wxString m_strName, // label for a manu item - m_strAccel; // the accel string ("Ctrl-F17") if any + wxFont m_font; // font to use for drawing + wxColour m_colText, // color ----"---"---"---- + m_colBack; // background color -private: - static size_t ms_nDefaultMarginWidth; // menu check mark width - static size_t ms_nLastMarginWidth; // handy for aligning all items - - bool m_bCheckable, // used only for menu or check listbox items - m_bOwnerDrawn, // true if something is non standard - m_isMenuItem; // true if this is a menu item - - wxFont m_font; // font to use for drawing - wxColour m_colText, // color ----"---"---"---- - m_colBack; // background color - wxBitmap m_bmpChecked, // bitmap to put near the item - m_bmpUnchecked, // (checked is used also for 'uncheckable' items) - m_bmpDisabled; - - size_t m_nHeight, // font height - m_nMarginWidth; // space occupied by bitmap to the left of the item + int m_margin; // space occupied by bitmap to the left of the item + + static int ms_defaultMargin; }; -#endif // wxUSE_OWNER_DRAWN +// ---------------------------------------------------------------------------- +// include the platform-specific class declaration +// ---------------------------------------------------------------------------- +#if defined(__WXMSW__) + #include "wx/msw/ownerdrw.h" +#elif defined(__WXPM__) + #include "wx/os2/ownerdrw.h" #endif - // _OWNERDRW_H + +#endif // wxUSE_OWNER_DRAWN + +#endif // _WX_OWNERDRW_H_BASE diff --git a/src/common/ownerdrwcmn.cpp b/src/common/ownerdrwcmn.cpp new file mode 100644 index 0000000000..28ebb7b1e5 --- /dev/null +++ b/src/common/ownerdrwcmn.cpp @@ -0,0 +1,96 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: src/common/ownerdrwcmn.cpp +// Purpose: wxOwnerDrawn class methods common to all platforms +// Author: Marcin Malich +// Modified by: +// Created: 2009-09-22 +// RCS-ID: $Id$ +// Copyright: (c) 2009 Marcin Malich +// Licence: wxWindows licence +/////////////////////////////////////////////////////////////////////////////// + +// ============================================================================ +// declarations +// ============================================================================ + +// ---------------------------------------------------------------------------- +// headers +// ---------------------------------------------------------------------------- + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#if wxUSE_OWNER_DRAWN + +#include "wx/ownerdrw.h" + +#ifndef WX_PRECOMP + #include "wx/window.h" + #include "wx/font.h" + #include "wx/colour.h" + #include "wx/dcmemory.h" + #include "wx/settings.h" + #include "wx/utils.h" +#endif + +// ============================================================================ +// implementation +// ============================================================================ + +bool wxOwnerDrawnBase::OnMeasureItem(size_t *width, size_t *height) +{ + if ( IsOwnerDrawn() ) + { + wxMemoryDC dc; + wxFont font; + GetFontToUse(font); + dc.SetFont(font); + + // item name/text without mnemonics + wxString name = wxStripMenuCodes(GetName(), wxStrip_Mnemonics); + + wxCoord w, h; + dc.GetTextExtent(name, &w, &h); + + *width = w + m_margin; + *height = h; + } + else + { + *width = 0; + *height = 0; + } + + return true; +} + +void wxOwnerDrawnBase::GetFontToUse(wxFont& font) const +{ + font = m_font.IsOk() ? m_font : *wxNORMAL_FONT; +} + +void wxOwnerDrawnBase::GetColourToUse(wxODStatus stat, wxColour& colText, wxColour& colBack) const +{ + if ( stat & wxODSelected ) + { + colText = wxSystemSettings::GetColour( + !(stat & wxODDisabled) ? wxSYS_COLOUR_HIGHLIGHTTEXT + : wxSYS_COLOUR_GRAYTEXT); + + colBack = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT); + } + else + { + // fall back to default colors if none explicitly specified + colText = m_colText.Ok() ? m_colText + : wxSystemSettings::GetColour(wxSYS_COLOUR_MENUTEXT); + colBack = m_colBack.Ok() ? m_colBack + : wxSystemSettings::GetColour(wxSYS_COLOUR_MENU); + } +} + +#endif // wxUSE_OWNER_DRAWN diff --git a/src/msw/checklst.cpp b/src/msw/checklst.cpp index 0769cb2f34..fc61953d60 100644 --- a/src/msw/checklst.cpp +++ b/src/msw/checklst.cpp @@ -141,6 +141,8 @@ public: void SendEvent(); + virtual wxString GetName() const { return m_pParent->GetString(m_nIndex); } + private: bool m_bChecked; wxCheckListBox *m_pParent; @@ -150,7 +152,6 @@ private: }; wxCheckListBoxItem::wxCheckListBoxItem(wxCheckListBox *pParent, size_t nIndex) - : wxOwnerDrawn(wxEmptyString, true) // checkable { m_bChecked = false; m_pParent = pParent; @@ -160,7 +161,7 @@ wxCheckListBoxItem::wxCheckListBoxItem(wxCheckListBox *pParent, size_t nIndex) // done in OnMeasure while they are used only in OnDraw and we // know that there will always be OnMeasure before OnDraw - SetMarginWidth(::GetSystemMetrics(SM_CXMENUCHECK) - 2); + SetMarginWidth(::GetSystemMetrics(SM_CXMENUCHECK)); SetBackgroundColour(pParent->GetBackgroundColour()); } diff --git a/src/msw/listbox.cpp b/src/msw/listbox.cpp index 015b6946f4..89b64fbeea 100644 --- a/src/msw/listbox.cpp +++ b/src/msw/listbox.cpp @@ -118,18 +118,25 @@ TODO PROPERTIES class wxListBoxItem : public wxOwnerDrawn { public: - wxListBoxItem(const wxString& str = wxEmptyString); -}; + wxListBoxItem(wxListBox *parent) + { m_parent = parent; } -wxListBoxItem::wxListBoxItem(const wxString& str) : wxOwnerDrawn(str, false) -{ - // no bitmaps/checkmarks - SetMarginWidth(0); -} + wxListBox *GetParent() const + { return m_parent; } + + int GetIndex() const + { return m_parent->GetItemIndex(const_cast(this)); } + + wxString GetName() const + { return m_parent->GetString(GetIndex()); } + +private: + wxListBox *m_parent; +}; wxOwnerDrawn *wxListBox::CreateLboxItem(size_t WXUNUSED(n)) { - return new wxListBoxItem(); + return new wxListBoxItem(this); } #endif //USE_OWNER_DRAWN @@ -279,6 +286,11 @@ void wxListBox::DoDeleteOneItem(unsigned int n) wxCHECK_RET( IsValid(n), wxT("invalid index in wxListBox::Delete") ); +#if wxUSE_OWNER_DRAWN + delete m_aItems[n]; + m_aItems.RemoveAt(n); +#endif // wxUSE_OWNER_DRAWN + SendMessage(GetHwnd(), LB_DELETESTRING, n, 0); m_noItems--; @@ -303,7 +315,12 @@ int wxListBox::FindString(const wxString& s, bool bCase) const void wxListBox::DoClear() { - Free(); +#if wxUSE_OWNER_DRAWN + if ( m_windowStyle & wxLB_OWNERDRAW ) + { + WX_CLEAR_ARRAY(m_aItems); + } +#endif // wxUSE_OWNER_DRAWN ListBox_ResetContent(GetHwnd()); @@ -313,16 +330,6 @@ void wxListBox::DoClear() UpdateOldSelections(); } -void wxListBox::Free() -{ -#if wxUSE_OWNER_DRAWN - if ( m_windowStyle & wxLB_OWNERDRAW ) - { - WX_CLEAR_ARRAY(m_aItems); - } -#endif // wxUSE_OWNER_DRAWN -} - void wxListBox::DoSetSelection(int N, bool select) { wxCHECK_RET( N == wxNOT_FOUND || IsValid(N), @@ -469,7 +476,6 @@ int wxListBox::DoInsertItems(const wxArrayStringsAdapter & items, if ( HasFlag(wxLB_OWNERDRAW) ) { wxOwnerDrawn *pNewItem = CreateLboxItem(n); - pNewItem->SetName(items[i]); pNewItem->SetFont(GetFont()); m_aItems.Insert(pNewItem, n); } @@ -524,14 +530,6 @@ void wxListBox::SetString(unsigned int n, const wxString& s) else if ( oldObjData ) SetClientObject(n, oldObjData); -#if wxUSE_OWNER_DRAWN - if ( m_windowStyle & wxLB_OWNERDRAW ) - { - // update item's text - m_aItems[n]->SetName(s); - } -#endif //USE_OWNER_DRAWN - // we may have lost the selection if ( wasSelected ) Select(n); @@ -745,7 +743,7 @@ bool wxListBox::MSWOnDraw(WXDRAWITEMSTRUCT *item) return pItem->OnDrawItem(dc, wxRectFromRECT(pStruct->rcItem), (wxOwnerDrawn::wxODAction)pStruct->itemAction, - (wxOwnerDrawn::wxODStatus)pStruct->itemState); + (wxOwnerDrawn::wxODStatus)(pStruct->itemState | wxOwnerDrawn::wxODHidePrefix)); } #endif // wxUSE_OWNER_DRAWN diff --git a/src/msw/menu.cpp b/src/msw/menu.cpp index 93984343d1..d1f777f816 100644 --- a/src/msw/menu.cpp +++ b/src/msw/menu.cpp @@ -578,7 +578,7 @@ bool wxMenu::DoInsertOrAppend(wxMenuItem *pItem, size_t pos) // tell the item that it's not really owner-drawn but only // needs to draw its bitmap, the rest is done by Windows - pItem->ResetOwnerDrawn(); + pItem->SetOwnerDrawn(false); } } #endif // __DMC__ diff --git a/src/msw/menuitem.cpp b/src/msw/menuitem.cpp index d1815b969d..c2bfd4d26d 100644 --- a/src/msw/menuitem.cpp +++ b/src/msw/menuitem.cpp @@ -45,6 +45,7 @@ #endif // wxUSE_ACCEL #include "wx/msw/private.h" +#include "wx/msw/dc.h" #ifdef __WXWINCE__ // Implemented in menu.cpp @@ -58,17 +59,25 @@ UINT GetMenuState(HMENU hMenu, UINT id, UINT flags) ; // hide the ugly cast #define GetHMenuOf(menu) ((HMENU)menu->GetHMenu()) -// conditional compilation -#if wxUSE_OWNER_DRAWN - #define OWNER_DRAWN_ONLY( code ) if ( IsOwnerDrawn() ) code -#else // !wxUSE_OWNER_DRAWN - #define OWNER_DRAWN_ONLY( code ) -#endif // wxUSE_OWNER_DRAWN/!wxUSE_OWNER_DRAWN - // ============================================================================ // implementation // ============================================================================ +#if wxUSE_OWNER_DRAWN + +#include "wx/fontutil.h" +#include "wx/msw/private/metrics.h" + +#ifndef SPI_GETKEYBOARDCUES +#define SPI_GETKEYBOARDCUES 0x100A +#endif + +#ifndef DSS_HIDEPREFIX +#define DSS_HIDEPREFIX 0x0200 +#endif + +#endif // wxUSE_OWNER_DRAWN + // ---------------------------------------------------------------------------- // dynamic classes implementation // ---------------------------------------------------------------------------- @@ -120,6 +129,17 @@ IMPLEMENT_DYNAMIC_CLASS(wxMenuItem, wxObject) // wxMenuItem // ---------------------------------------------------------------------------- +#if wxUSE_OWNER_DRAWN + +// these static variables are from the wxMenuItem object for cache +// system settings returned by the Win32 API's SystemParametersInfo() call +wxFont wxMenuItem::ms_systemMenuFont; +size_t wxMenuItem::ms_systemMenuHeight = 0; +bool wxMenuItem::ms_alwaysShowCues = false; + +#endif // wxUSE_OWNER_DRAWN + + // ctor & dtor // ----------- @@ -130,9 +150,6 @@ wxMenuItem::wxMenuItem(wxMenu *pParentMenu, wxItemKind kind, wxMenu *pSubMenu) : wxMenuItemBase(pParentMenu, id, text, strHelp, kind, pSubMenu) -#if wxUSE_OWNER_DRAWN - , wxOwnerDrawn(text, kind == wxITEM_CHECK, true) -#endif // owner drawn { Init(); } @@ -146,9 +163,6 @@ wxMenuItem::wxMenuItem(wxMenu *parentMenu, wxMenu *subMenu) : wxMenuItemBase(parentMenu, id, text, help, isCheckable ? wxITEM_CHECK : wxITEM_NORMAL, subMenu) -#if wxUSE_OWNER_DRAWN - , wxOwnerDrawn(text, isCheckable, true) -#endif // owner drawn { Init(); } @@ -161,6 +175,24 @@ void wxMenuItem::Init() #if wxUSE_OWNER_DRAWN + // init static varaibles + if ( !ms_systemMenuHeight ) + { + const NONCLIENTMETRICS& metrics = wxMSWImpl::GetNonClientMetrics(); + + ms_systemMenuFont = wxFont(wxNativeFontInfo(metrics.lfMenuFont)); + ms_systemMenuHeight = metrics.iMenuHeight; + + if ( ::SystemParametersInfo(SPI_GETKEYBOARDCUES, 0, + &ms_alwaysShowCues, 0) == 0 ) + { + // if it's not supported, we must be on an old Windows version + // which always shows them + ms_alwaysShowCues = true; + } + + } + // when the color is not valid, wxOwnerDraw takes the default ones. // If we set the colors here and they are changed by the user during // the execution, then the colors are not updated until the application @@ -169,14 +201,12 @@ void wxMenuItem::Init() SetBackgroundColour(wxNullColour); // setting default colors switched ownerdraw on: switch it off again - ResetOwnerDrawn(); + SetOwnerDrawn(false); // switch ownerdraw back on if using a non default margin if ( !IsSeparator() ) SetMarginWidth(GetMarginWidth()); - // tell the owner drawing code to show the accel string as well - SetAccelString(m_text.AfterFirst(wxT('\t'))); #endif // wxUSE_OWNER_DRAWN } @@ -365,15 +395,6 @@ void wxMenuItem::SetItemLabel(const wxString& txt) // wxMenuItemBase will do stock ID checks wxMenuItemBase::SetItemLabel(text); - // m_text could now be different from 'text' if we are a stock menu item, - // so use only m_text below - - OWNER_DRAWN_ONLY( wxOwnerDrawn::SetName(m_text) ); -#if wxUSE_OWNER_DRAWN - // tell the owner drawing code to to show the accel string as well - SetAccelString(m_text.AfterFirst(wxT('\t'))); -#endif - // the item can be not attached to any menu yet and SetItemLabel() is still // valid to call in this case and should do nothing else if ( !m_parentMenu ) @@ -430,12 +451,318 @@ void wxMenuItem::SetItemLabel(const wxString& txt) } } -void wxMenuItem::SetCheckable(bool checkable) +#if wxUSE_OWNER_DRAWN + +wxString wxMenuItem::GetName() const { - wxMenuItemBase::SetCheckable(checkable); - OWNER_DRAWN_ONLY( wxOwnerDrawn::SetCheckable(checkable) ); + return GetItemLabelText(); } +bool wxMenuItem::OnMeasureItem(size_t *width, size_t *height) +{ + if ( IsOwnerDrawn() ) + { + + wxString str = GetName(); + + // if we have a valid accel string, then pad out + // the menu string so that the menu and accel string are not + // placed on top of each other. + wxString accel = GetItemLabel().AfterFirst(wxT('\t')); + if ( !accel.empty() ) + { + str.Pad(str.length()%8); + str += accel; + } + + wxMemoryDC dc; + wxFont font; + GetFontToUse(font); + dc.SetFont(font); + + wxCoord w, h; + dc.GetTextExtent(str, &w, &h); + *width = w; + *height = h; + } + else // don't draw the text, just the bitmap (if any) + { + *width = 0; + *height = 0; + } + + // increase size to accommodate bigger bitmaps if necessary + if (m_bmpChecked.Ok()) + { + // Is BMP height larger than text height? + size_t adjustedHeight = m_bmpChecked.GetHeight(); + if ( *height < adjustedHeight ) + *height = adjustedHeight; + + const int widthBmp = m_bmpChecked.GetWidth(); + if ( IsOwnerDrawn() ) + { + // widen the margin to fit the bitmap if necessary + if ( GetMarginWidth() < widthBmp ) + SetMarginWidth(widthBmp); + + } + else // we must allocate enough space for the bitmap + { + *width += widthBmp; + } + } + + // add a 4-pixel separator, otherwise menus look cluttered + *width += 4; + + // notice that this adjustment must be done after (possibly) changing the + // margin width above + if ( IsOwnerDrawn() ) + { + // add space at the end of the menu for the submenu expansion arrow + // this will also allow offsetting the accel string from the right edge + *width += GetMarginWidth() + 16; + } + + // make sure that this item is at least as tall as the system menu height + if ( *height < ms_systemMenuHeight ) + *height = ms_systemMenuHeight; + + return true; +} + +bool wxMenuItem::OnDrawItem(wxDC& dc, const wxRect& rc, + wxODAction WXUNUSED(act), wxODStatus stat) +{ + + // this flag determines whether or not an edge will + // be drawn around the bitmap. In most "windows classic" + // applications, a 1-pixel highlight edge is drawn around + // the bitmap of an item when it is selected. However, + // with the new "luna" theme, no edge is drawn around + // the bitmap because the background is white (this applies + // only to "non-XP style" menus w/ bitmaps -- + // see IE 6 menus for an example) + + bool draw_bitmap_edge = true; + + // set the colors + // -------------- + wxColour colText1, colBack1; + GetColourToUse(stat, colText1, colBack1); + + DWORD colText = wxColourToPalRGB(colText1); + DWORD colBack = wxColourToPalRGB(colBack1); + + if ( IsOwnerDrawn() ) + { + // don't draw an edge around the bitmap, if background is white ... + DWORD menu_bg_color = GetSysColor(COLOR_MENU); + if ( GetRValue( menu_bg_color ) >= 0xf0 && + GetGValue( menu_bg_color ) >= 0xf0 && + GetBValue( menu_bg_color ) >= 0xf0 ) + { + draw_bitmap_edge = false; + } + } + else // edge doesn't look well with default Windows drawing + { + draw_bitmap_edge = false; + } + + + wxMSWDCImpl *impl = (wxMSWDCImpl*) dc.GetImpl(); + HDC hdc = GetHdcOf(*impl); + COLORREF colOldText = ::SetTextColor(hdc, colText); + COLORREF colOldBack = ::SetBkColor(hdc, colBack); + + // *2, as in wxSYS_EDGE_Y + int margin = GetMarginWidth() + 2 * wxSystemSettings::GetMetric(wxSYS_EDGE_X); + + // select the font and draw the text + // --------------------------------- + + + // determine where to draw and leave space for a check-mark. + // + 1 pixel to separate the edge from the highlight rectangle + int xText = rc.x + margin + 1; + + + // using native API because it recognizes '&' + if ( IsOwnerDrawn() ) + { + int prevMode = SetBkMode(hdc, TRANSPARENT); + AutoHBRUSH hbr(colBack); + SelectInHDC selBrush(hdc, hbr); + + RECT rectFill; + wxCopyRectToRECT(rc, rectFill); + + if ( (stat & wxODSelected) && m_bmpChecked.Ok() && draw_bitmap_edge ) + { + // only draw the highlight under the text, not under + // the bitmap or checkmark + rectFill.left = xText; + } + + ::FillRect(hdc, &rectFill, hbr); + + // use default font if no font set + wxFont font; + GetFontToUse(font); + SelectInHDC selFont(hdc, GetHfontOf(font)); + + // item text name with menemonic + wxString text = GetItemLabel().BeforeFirst('\t'); + + xText += 3; // separate text from the highlight rectangle + + SIZE textRect; + ::GetTextExtentPoint32(hdc, text.c_str(), text.length(), &textRect); + + int flags = DST_PREFIXTEXT; + if ( (stat & wxODDisabled) && !(stat & wxODSelected) ) + flags |= DSS_DISABLED; + + if ( (stat & wxODHidePrefix) && !ms_alwaysShowCues ) + flags |= DSS_HIDEPREFIX; + + int x = xText; + int y = rc.y + (rc.GetHeight() - textRect.cy) / 2; + int cx = rc.GetWidth() - GetMarginWidth(); + int cy = textRect.cy; + + ::DrawState(hdc, NULL, NULL, (LPARAM)text.wx_str(), + text.length(), x, y, cx, cy, flags); + + // ::SetTextAlign(hdc, TA_RIGHT) doesn't work with DSS_DISABLED or DSS_MONO + // as the last parameter in DrawState() (at least with Windows98). So we have + // to take care of right alignment ourselves. + wxString accel = GetItemLabel().AfterFirst(wxT('\t')); + if ( !accel.empty() ) + { + SIZE accelRect; + ::GetTextExtentPoint32(hdc, accel.c_str(), accel.length(), &accelRect); + + int flags = DST_TEXT; + if ( (stat & wxODDisabled) && !(stat & wxODSelected) ) + flags |= DSS_DISABLED; + + // right align accel string with right edge of menu + // (offset by the margin width) + + int x = rc.GetWidth() - 16 - accelRect.cx; + int y = rc.y + (rc.GetHeight() - accelRect.cy) / 2; + ::DrawState(hdc, NULL, NULL, (LPARAM)accel.wx_str(), + accel.length(), x, y, 0, 0, flags); + } + + ::SetBkMode(hdc, prevMode); + } + + + // draw the bitmap + // --------------- + if ( IsCheckable() && !m_bmpChecked.Ok() ) + { + if ( stat & wxODChecked ) + { + // what goes on: DrawFrameControl creates a b/w mask, + // then we copy it to screen to have right colors + + // first create a monochrome bitmap in a memory DC + HDC hdcMem = CreateCompatibleDC(hdc); + HBITMAP hbmpCheck = CreateBitmap(margin, rc.GetHeight(), 1, 1, 0); + SelectObject(hdcMem, hbmpCheck); + + // then draw a check mark into it + RECT rect = { 0, 0, margin, rc.GetHeight() }; + if ( rc.GetHeight() > 0 ) + { + ::DrawFrameControl(hdcMem, &rect, DFC_MENU, DFCS_MENUCHECK); + } + + // finally copy it to screen DC and clean up + BitBlt(hdc, rc.x, rc.y, margin, rc.GetHeight(), hdcMem, 0, 0, SRCCOPY); + + DeleteDC(hdcMem); + DeleteObject(hbmpCheck); + } + } + else + { + wxBitmap bmp; + + if ( stat & wxODDisabled ) + { + bmp = GetDisabledBitmap(); + } + + if ( !bmp.Ok() ) + { + // for not checkable bitmaps we should always use unchecked one + // because their checked bitmap is not set + bmp = GetBitmap(!IsCheckable() || (stat & wxODChecked)); + +#if wxUSE_IMAGE + if ( bmp.Ok() && stat & wxODDisabled ) + { + // we need to grey out the bitmap as we don't have any specific + // disabled bitmap + wxImage imgGrey = bmp.ConvertToImage().ConvertToGreyscale(); + if ( imgGrey.Ok() ) + bmp = wxBitmap(imgGrey); + } +#endif // wxUSE_IMAGE + } + + if ( bmp.Ok() ) + { + wxMemoryDC dcMem(&dc); + dcMem.SelectObjectAsSource(bmp); + + // center bitmap + int nBmpWidth = bmp.GetWidth(), + nBmpHeight = bmp.GetHeight(); + + // there should be enough space! + wxASSERT((nBmpWidth <= rc.GetWidth()) && (nBmpHeight <= rc.GetHeight())); + + int heightDiff = rc.GetHeight() - nBmpHeight; + dc.Blit(rc.x + (margin - nBmpWidth) / 2, + rc.y + heightDiff / 2, + nBmpWidth, nBmpHeight, + &dcMem, 0, 0, wxCOPY, true /* use mask */); + + if ( ( stat & wxODSelected ) && !( stat & wxODDisabled ) && draw_bitmap_edge ) + { + RECT rectBmp = { rc.GetLeft(), rc.GetTop(), + rc.GetLeft() + margin, + rc.GetTop() + rc.GetHeight() }; + SetBkColor(hdc, colBack); + + DrawEdge(hdc, &rectBmp, BDR_RAISEDINNER, BF_RECT); + } + } + } + + ::SetTextColor(hdc, colOldText); + ::SetBkColor(hdc, colOldBack); + + return true; + +} + +void wxMenuItem::GetFontToUse(wxFont& font) const +{ + font = GetFont(); + if ( !font.IsOk() ) + font = ms_systemMenuFont; +} + +#endif // wxUSE_OWNER_DRAWN + // ---------------------------------------------------------------------------- // wxMenuItemBase // ---------------------------------------------------------------------------- diff --git a/src/msw/ownerdrw.cpp b/src/msw/ownerdrw.cpp index 29467f8417..3c70d2408e 100644 --- a/src/msw/ownerdrw.cpp +++ b/src/msw/ownerdrw.cpp @@ -2,7 +2,7 @@ // Name: src/msw/ownerdrw.cpp // Purpose: implementation of wxOwnerDrawn class // Author: Vadim Zeitlin -// Modified by: +// Modified by: Marcin Malich // Created: 13.11.97 // RCS-ID: $Id$ // Copyright: (c) 1998 Vadim Zeitlin @@ -18,521 +18,81 @@ #if wxUSE_OWNER_DRAWN -#ifndef WX_PRECOMP - #include "wx/window.h" - #include "wx/font.h" - #include "wx/bitmap.h" - #include "wx/image.h" - #include "wx/dcmemory.h" - #include "wx/menu.h" - #include "wx/utils.h" - #include "wx/settings.h" - #include "wx/menuitem.h" - #include "wx/module.h" - #include "wx/msw/wrapcctl.h" -#endif - #include "wx/ownerdrw.h" -#include "wx/fontutil.h" - -#include "wx/msw/private.h" -#include "wx/msw/private/metrics.h" #include "wx/msw/dc.h" - -#ifndef SPI_GETKEYBOARDCUES -#define SPI_GETKEYBOARDCUES 0x100A -#endif +#include "wx/msw/private.h" +#include "wx/msw/private/dc.h" #ifndef DSS_HIDEPREFIX #define DSS_HIDEPREFIX 0x0200 #endif -class wxMSWSystemMenuFontModule : public wxModule -{ -public: - virtual bool OnInit() - { - return true; - } - - virtual void OnExit() - { - if ( ms_systemMenuFont ) - { - delete ms_systemMenuFont; - ms_systemMenuFont = NULL; - } - } - - static const wxFont& GetSystemMenuFont() - { - if ( !ms_systemMenuFont ) - DoInitFont(); - - return *ms_systemMenuFont; - } - - static int GetSystemMenuHeight() - { - if ( !ms_systemMenuHeight ) - DoInitMetrics(); - - return ms_systemMenuHeight; - } - - static bool AlwaysShowCues() - { - if ( !ms_systemMenuHeight ) - DoInitMetrics(); - - return ms_alwaysShowCues; - } - -private: - static void DoInitMetrics() - { - // iMenuHeight is the menu bar height and the menu items are less tall, - // although I don't know by how much -- below is the value for my system - ms_systemMenuHeight = wxMSWImpl::GetNonClientMetrics().iMenuHeight - 4; - - wxASSERT_MSG( ms_systemMenuHeight > 0, - "menu height should be positive" ); - - if ( ::SystemParametersInfo(SPI_GETKEYBOARDCUES, 0, - &ms_alwaysShowCues, 0) == 0 ) - { - // if it's not supported, we must be on an old Windows version - // which always shows them - ms_alwaysShowCues = true; - } - } - - static void DoInitFont() - { - ms_systemMenuFont = new - wxFont(wxNativeFontInfo(wxMSWImpl::GetNonClientMetrics().lfMenuFont)); - } - - static wxFont* ms_systemMenuFont; - static int ms_systemMenuHeight; - static bool ms_alwaysShowCues; - - - DECLARE_DYNAMIC_CLASS(wxMSWSystemMenuFontModule) -}; - -// these static variables are from the wxMSWSystemMenuFontModule object -// and reflect the system settings returned by the Win32 API's -// SystemParametersInfo() call. - -wxFont* wxMSWSystemMenuFontModule::ms_systemMenuFont = NULL; -int wxMSWSystemMenuFontModule::ms_systemMenuHeight = 0; -bool wxMSWSystemMenuFontModule::ms_alwaysShowCues = false; - -IMPLEMENT_DYNAMIC_CLASS(wxMSWSystemMenuFontModule, wxModule) - - -// VC++ 6 gives a warning here: -// -// return type for 'OwnerDrawnSet_wxImplementation_HashTable::iterator:: -// operator ->' is 'class wxOwnerDrawn ** ' (ie; not a UDT or reference to -// a UDT. Will produce errors if applied using infix notation. -// -// shut it down -#if defined __VISUALC__ && __VISUALC__ <= 1300 - #if __VISUALC__ >= 1200 - #pragma warning(push) - #define POP_WARNINGS - #endif - #pragma warning(disable: 4284) -#endif - -#include "wx/hashset.h" -WX_DECLARE_HASH_SET(wxOwnerDrawn*, wxPointerHash, wxPointerEqual, OwnerDrawnSet); +// ---------------------------------------------------------------------------- +// constants for base class +// ---------------------------------------------------------------------------- -#ifdef POP_WARNINGS - #pragma warning(pop) -#endif +int wxOwnerDrawnBase::ms_defaultMargin = 3; // ============================================================================ // implementation of wxOwnerDrawn class // ============================================================================ -// ctor -// ---- -wxOwnerDrawn::wxOwnerDrawn(const wxString& str, - bool bCheckable, - bool bMenuItem) - : m_strName(str) -{ - if ( ms_nDefaultMarginWidth == 0 ) - { - ms_nDefaultMarginWidth = ::GetSystemMetrics(SM_CXMENUCHECK) + - wxSystemSettings::GetMetric(wxSYS_EDGE_X); - ms_nLastMarginWidth = ms_nDefaultMarginWidth; - } - - m_bCheckable = bCheckable; - m_bOwnerDrawn = false; - m_isMenuItem = bMenuItem; - m_nHeight = 0; - m_nMarginWidth = ms_nLastMarginWidth; -} - -wxOwnerDrawn::~wxOwnerDrawn() -{ -} - -bool wxOwnerDrawn::IsMenuItem() const -{ - return m_isMenuItem; -} - - -// these items will be set during the first invocation of the ctor, -// because the values will be determined by checking the system settings, -// which is a chunk of code -size_t wxOwnerDrawn::ms_nDefaultMarginWidth = 0; -size_t wxOwnerDrawn::ms_nLastMarginWidth = 0; - - -// drawing -// ------- - -wxFont wxOwnerDrawn::GetFontToUse() const -{ - wxFont font = m_font; - if ( !font.Ok() ) - { - if ( IsMenuItem() ) - font = wxMSWSystemMenuFontModule::GetSystemMenuFont(); - - if ( !font.Ok() ) - font = *wxNORMAL_FONT; - } - - return font; -} - -// get size of the item -// The item size includes the menu string, the accel string, -// the bitmap and size for a submenu expansion arrow... -bool wxOwnerDrawn::OnMeasureItem(size_t *pwidth, size_t *pheight) -{ - if ( IsOwnerDrawn() ) - { - wxMemoryDC dc; - - wxString str = wxStripMenuCodes(m_strName); - - // if we have a valid accel string, then pad out - // the menu string so that the menu and accel string are not - // placed on top of each other. - if ( !m_strAccel.empty() ) - { - str.Pad(str.length()%8); - str += m_strAccel; - } - - dc.SetFont(GetFontToUse()); - - wxCoord w, h; - dc.GetTextExtent(str, &w, &h); - *pwidth = w; - *pheight = h; - } - else // don't draw the text, just the bitmap (if any) - { - *pwidth = - *pheight = 0; - } - - // increase size to accommodate bigger bitmaps if necessary - if (m_bmpChecked.Ok()) - { - // Is BMP height larger than text height? - size_t adjustedHeight = m_bmpChecked.GetHeight(); - if ( *pheight < adjustedHeight ) - *pheight = adjustedHeight; - - const int widthBmp = m_bmpChecked.GetWidth(); - if ( IsOwnerDrawn() ) - { - // widen the margin to fit the bitmap if necessary - if ( GetMarginWidth() < widthBmp ) - SetMarginWidth(widthBmp); - } - else // we must allocate enough space for the bitmap - { - *pwidth += widthBmp; - } - } - - // add a 4-pixel separator, otherwise menus look cluttered - *pwidth += 4; - - // notice that this adjustment must be done after (possibly) changing the - // margin width above - if ( IsOwnerDrawn() ) - { - // add space at the end of the menu for the submenu expansion arrow - // this will also allow offsetting the accel string from the right edge - *pwidth += GetMarginWidth() + 16; - } - - // make sure that this item is at least as tall as the system menu height - const size_t heightStd = wxMSWSystemMenuFontModule::GetSystemMenuHeight(); - if ( *pheight < heightStd ) - *pheight = heightStd; - - // remember height for use in OnDrawItem - m_nHeight = *pheight; - - return true; -} - // draw the item -bool wxOwnerDrawn::OnDrawItem(wxDC& dc, - const wxRect& rc, - wxODAction, - wxODStatus st) +bool wxOwnerDrawn::OnDrawItem(wxDC& dc, const wxRect& rc, + wxODAction, wxODStatus stat) { - // this flag determines whether or not an edge will - // be drawn around the bitmap. In most "windows classic" - // applications, a 1-pixel highlight edge is drawn around - // the bitmap of an item when it is selected. However, - // with the new "luna" theme, no edge is drawn around - // the bitmap because the background is white (this applies - // only to "non-XP style" menus w/ bitmaps -- - // see IE 6 menus for an example) - - bool draw_bitmap_edge = true; - - // set the colors - // -------------- - DWORD colBack, colText; - if ( st & wxODSelected ) - { - colBack = GetSysColor(COLOR_HIGHLIGHT); - if (!(st & wxODDisabled)) - { - colText = GetSysColor(COLOR_HIGHLIGHTTEXT); - } - else - { - colText = GetSysColor(COLOR_GRAYTEXT); - } - } - else - { - // fall back to default colors if none explicitly specified - colBack = m_colBack.Ok() ? wxColourToPalRGB(m_colBack) - : GetSysColor(COLOR_MENU); - colText = m_colText.Ok() ? wxColourToPalRGB(m_colText) - : GetSysColor(COLOR_MENUTEXT); - } + // we do nothing if item isn't ownerdrawn + if ( !IsOwnerDrawn() ) + return true; - if ( IsOwnerDrawn() ) - { - // don't draw an edge around the bitmap, if background is white ... - DWORD menu_bg_color = GetSysColor(COLOR_MENU); - if ( ( GetRValue( menu_bg_color ) >= 0xf0 && - GetGValue( menu_bg_color ) >= 0xf0 && - GetBValue( menu_bg_color ) >= 0xf0 ) - ) - { - draw_bitmap_edge = false; - } - } - else // edge doesn't look well with default Windows drawing - { - draw_bitmap_edge = false; - } + // set the font and colors + wxFont font; + GetFontToUse(font); + wxColour colText, colBack; + GetColourToUse(stat, colText, colBack); wxMSWDCImpl *impl = (wxMSWDCImpl*) dc.GetImpl(); HDC hdc = GetHdcOf(*impl); - COLORREF colOldText = ::SetTextColor(hdc, colText), - colOldBack = ::SetBkColor(hdc, colBack); - // *2, as in wxSYS_EDGE_Y - int margin = GetMarginWidth() + 2 * wxSystemSettings::GetMetric(wxSYS_EDGE_X); + SelectInHDC selFont(hdc, GetHfontOf(font)); - // select the font and draw the text - // --------------------------------- + wxMSWImpl::wxTextColoursChanger textCol(hdc, colText, colBack); + wxMSWImpl::wxBkModeChanger bkMode(hdc, wxBRUSHSTYLE_TRANSPARENT); - // determine where to draw and leave space for a check-mark. - // + 1 pixel to separate the edge from the highlight rectangle - int xText = rc.x + margin + 1; + AutoHBRUSH hbr(wxColourToPalRGB(colBack)); + SelectInHDC selBrush(hdc, hbr); + RECT rectFill; + wxCopyRectToRECT(rc, rectFill); + ::FillRect(hdc, &rectFill, hbr); // using native API because it recognizes '&' - if ( IsOwnerDrawn() ) - { - int nPrevMode = SetBkMode(hdc, TRANSPARENT); - AutoHBRUSH hbr(colBack); - SelectInHDC selBrush(hdc, hbr); - - RECT rectFill; - wxCopyRectToRECT(rc, rectFill); - - if ( (st & wxODSelected) && m_bmpChecked.Ok() && draw_bitmap_edge ) - { - // only draw the highlight under the text, not under - // the bitmap or checkmark - rectFill.left = xText; - } - - FillRect(hdc, &rectFill, hbr); - - // use default font if no font set - wxFont fontToUse = GetFontToUse(); - SelectInHDC selFont(hdc, GetHfontOf(fontToUse)); - - wxString strMenuText = m_strName.BeforeFirst('\t'); - - xText += 3; // separate text from the highlight rectangle - - SIZE sizeRect; - ::GetTextExtentPoint32(hdc, strMenuText.c_str(), strMenuText.length(), &sizeRect); - - int flags = DST_PREFIXTEXT; - if ( (st & wxODDisabled) && !(st & wxODSelected) ) - flags |= DSS_DISABLED; - - if ( (st & wxODHidePrefix) && - !wxMSWSystemMenuFontModule::AlwaysShowCues() ) - flags |= DSS_HIDEPREFIX; - - ::DrawState - ( - hdc, - NULL, - NULL, - (LPARAM)strMenuText.wx_str(), - strMenuText.length(), - xText, - rc.y + (rc.height - sizeRect.cy) / 2, // centre vertically - rc.GetWidth() - margin, - sizeRect.cy, - flags - ); - - // ::SetTextAlign(hdc, TA_RIGHT) doesn't work with DSS_DISABLED or DSS_MONO - // as the last parameter in DrawState() (at least with Windows98). So we have - // to take care of right alignment ourselves. - if ( !m_strAccel.empty() ) - { - int accel_width, accel_height; - dc.GetTextExtent(m_strAccel, &accel_width, &accel_height); - // right align accel string with right edge of menu ( offset by the - // margin width ) - ::DrawState(hdc, NULL, NULL, - (LPARAM)m_strAccel.wx_str(), - m_strAccel.length(), - rc.width - 16 - accel_width, rc.y + (rc.height - sizeRect.cy) / 2, - 0, 0, - DST_TEXT | - (((st & wxODDisabled) && !(st & wxODSelected)) ? DSS_DISABLED : 0)); - } - - (void)SetBkMode(hdc, nPrevMode); - } - - - // draw the bitmap - // --------------- - if ( IsCheckable() && !m_bmpChecked.Ok() ) - { - if ( st & wxODChecked ) - { - // what goes on: DrawFrameControl creates a b/w mask, - // then we copy it to screen to have right colors - - // first create a monochrome bitmap in a memory DC - HDC hdcMem = CreateCompatibleDC(hdc); - HBITMAP hbmpCheck = CreateBitmap(margin, m_nHeight, 1, 1, 0); - SelectObject(hdcMem, hbmpCheck); - - // then draw a check mark into it - RECT rect = { 0, 0, margin, m_nHeight }; - if ( m_nHeight > 0 ) - { - ::DrawFrameControl(hdcMem, &rect, DFC_MENU, DFCS_MENUCHECK); - } - - // finally copy it to screen DC and clean up - BitBlt(hdc, rc.x, rc.y, margin, m_nHeight, hdcMem, 0, 0, SRCCOPY); - - DeleteDC(hdcMem); - DeleteObject(hbmpCheck); - } - } - else - { - wxBitmap bmp; - - if ( st & wxODDisabled ) - { - bmp = GetDisabledBitmap(); - } - if ( !bmp.Ok() ) - { - // for not checkable bitmaps we should always use unchecked one - // because their checked bitmap is not set - bmp = GetBitmap(!IsCheckable() || (st & wxODChecked)); + wxString text = GetName(); -#if wxUSE_IMAGE - if ( bmp.Ok() && st & wxODDisabled ) - { - // we need to grey out the bitmap as we don't have any specific - // disabled bitmap - wxImage imgGrey = bmp.ConvertToImage().ConvertToGreyscale(); - if ( imgGrey.Ok() ) - bmp = wxBitmap(imgGrey); - } -#endif // wxUSE_IMAGE - } + SIZE sizeRect; + ::GetTextExtentPoint32(hdc, text.c_str(), text.length(), &sizeRect); - if ( bmp.Ok() ) - { - wxMemoryDC dcMem(&dc); - dcMem.SelectObjectAsSource(bmp); + int flags = DST_PREFIXTEXT; + if ( (stat & wxODDisabled) && !(stat & wxODSelected) ) + flags |= DSS_DISABLED; - // center bitmap - int nBmpWidth = bmp.GetWidth(), - nBmpHeight = bmp.GetHeight(); + if ( (stat & wxODHidePrefix) ) + flags |= DSS_HIDEPREFIX; - // there should be enough space! - wxASSERT((nBmpWidth <= rc.GetWidth()) && (nBmpHeight <= rc.GetHeight())); + int x = rc.x + GetMarginWidth(); + int y = rc.y + (rc.GetHeight() - sizeRect.cy) / 2; + int cx = rc.GetWidth() - GetMarginWidth(); + int cy = sizeRect.cy; - int heightDiff = m_nHeight - nBmpHeight; - dc.Blit(rc.x + (margin - nBmpWidth) / 2, - rc.y + heightDiff / 2, - nBmpWidth, nBmpHeight, - &dcMem, 0, 0, wxCOPY, true /* use mask */); - - if ( ( st & wxODSelected ) && !( st & wxODDisabled ) && draw_bitmap_edge ) - { - RECT rectBmp = { rc.GetLeft(), rc.GetTop(), - rc.GetLeft() + margin, - rc.GetTop() + m_nHeight }; - SetBkColor(hdc, colBack); - - DrawEdge(hdc, &rectBmp, BDR_RAISEDINNER, BF_RECT); - } - } - } - - ::SetTextColor(hdc, colOldText); - ::SetBkColor(hdc, colOldBack); + ::DrawState(hdc, NULL, NULL, (LPARAM)text.wx_str(), + text.length(), x, y, cx, cy, flags); return true; } - // ---------------------------------------------------------------------------- // global helper functions implemented here // ---------------------------------------------------------------------------- diff --git a/src/os2/checklst.cpp b/src/os2/checklst.cpp index f0a3ac723b..d6c4eb08c7 100644 --- a/src/os2/checklst.cpp +++ b/src/os2/checklst.cpp @@ -39,6 +39,12 @@ #define INCL_PM #include +// ---------------------------------------------------------------------------- +// constants for base class +// ---------------------------------------------------------------------------- + +static const int CHECK_MARK_WIDTH = 15; + // ---------------------------------------------------------------------------- // private functions // ---------------------------------------------------------------------------- @@ -81,6 +87,8 @@ public: void Check(bool bCheck); void Toggle(void) { Check(!IsChecked()); } + virtual wxString GetName() const { return m_pParent->GetString(m_nIndex); } + private: bool m_bChecked; wxCheckListBox* m_pParent; @@ -101,7 +109,7 @@ wxCheckListBoxItem::wxCheckListBoxItem(wxCheckListBox* pParent, size_t nIndex) // done in OnMeasure while they are used only in OnDraw and we // know that there will always be OnMeasure before OnDraw // - SetMarginWidth(GetDefaultMarginWidth()); + SetMarginWidth(CHECK_MARK_WIDTH); } // end of wxCheckListBoxItem::wxCheckListBoxItem @@ -128,7 +136,7 @@ bool wxCheckListBoxItem::OnDrawItem ( wxDC& rDc, vRect.y -= 3; if (wxOwnerDrawn::OnDrawItem( rDc, vRect, eAct, eStat)) { - size_t nCheckWidth = GetDefaultMarginWidth(); + size_t nCheckWidth = CHECK_MARK_WIDTH; size_t nCheckHeight = m_pParent->GetItemHeight(); int nParentHeight; int nX = rRect.GetX(); @@ -333,7 +341,7 @@ long wxCheckListBox::OS2OnMeasure ( WXMEASUREITEMSTRUCT* pItem ) // // Add place for the check mark // - pStruct->rclItem.xRight += wxOwnerDrawn::GetDefaultMarginWidth(); + pStruct->rclItem.xRight += CHECK_MARK_WIDTH; return long(MRFROM2SHORT((USHORT)m_nItemHeight, (USHORT)(pStruct->rclItem.xRight - pStruct->rclItem.xLeft))); } return 0L; @@ -374,7 +382,7 @@ void wxCheckListBox::OnLeftClick ( wxMouseEvent& rEvent ) // // Clicking on the item selects it, clicking on the checkmark toggles // - if (rEvent.GetX() <= wxOwnerDrawn::GetDefaultMarginWidth()) + if (rEvent.GetX() <= CHECK_MARK_WIDTH) { int nParentHeight; wxScreenDC vDc; diff --git a/src/os2/listbox.cpp b/src/os2/listbox.cpp index 2c636032e0..ada1db3c6c 100644 --- a/src/os2/listbox.cpp +++ b/src/os2/listbox.cpp @@ -50,25 +50,25 @@ IMPLEMENT_DYNAMIC_CLASS(wxListBox, wxControlWithItems) class wxListBoxItem : public wxOwnerDrawn { public: - wxListBoxItem(const wxString& rsStr = wxEmptyString); -}; + wxListBoxItem(wxListBox *parent) + { m_parent = parent; } -wxListBoxItem::wxListBoxItem( - const wxString& rsStr -) -: wxOwnerDrawn( rsStr - ,false - ) -{ - // - // No bitmaps/checkmarks - // - SetMarginWidth(0); -} // end of wxListBoxItem::wxListBoxItem + wxListBox *GetParent() const + { return m_parent; } + + int GetIndex() const + { return m_parent->GetItemIndex(const_cast(this)); } + + wxString GetName() const + { return m_parent->GetString(GetIndex()); } + +private: + wxListBox *m_parent; +}; wxOwnerDrawn* wxListBox::CreateItem( size_t WXUNUSED(n) ) { - return new wxListBoxItem(); + return new wxListBoxItem(this); } // end of wxListBox::CreateItem #endif //USE_OWNER_DRAWN @@ -225,14 +225,7 @@ bool wxListBox::Create( wxWindow* pParent, wxListBox::~wxListBox() { -#if wxUSE_OWNER_DRAWN - size_t lUiCount = m_aItems.Count(); - - while (lUiCount-- != 0) - { - delete m_aItems[lUiCount]; - } -#endif // wxUSE_OWNER_DRAWN + Clear(); } // end of wxListBox::~wxListBox void wxListBox::SetupColours() @@ -261,7 +254,7 @@ void wxListBox::DoDeleteOneItem(unsigned int n) #if wxUSE_OWNER_DRAWN delete m_aItems[n]; m_aItems.RemoveAt(n); -#endif // wxUSE_OWNER_DRAWN/!wxUSE_OWNER_DRAWN +#endif // wxUSE_OWNER_DRAWN ::WinSendMsg(GetHwnd(), LM_DELETEITEM, (MPARAM)n, (MPARAM)0); m_nNumItems--; @@ -303,12 +296,9 @@ int wxListBox::DoInsertItems(const wxArrayStringsAdapter & items, #if wxUSE_OWNER_DRAWN if (HasFlag(wxLB_OWNERDRAW)) { - wxOwnerDrawn* pNewItem = CreateItem(n); // dummy argument - wxScreenDC vDc; // FIXME: is it really needed here? - - pNewItem->SetName(items[i]); - m_aItems.Insert(pNewItem, n); + wxOwnerDrawn* pNewItem = CreateItem(n); // dummy argument pNewItem->SetFont(GetFont()); + m_aItems.Insert(pNewItem, n); } #endif AssignNewItemClientData(n, clientData, i, type); @@ -323,14 +313,10 @@ int wxListBox::DoInsertItems(const wxArrayStringsAdapter & items, void wxListBox::DoClear() { #if wxUSE_OWNER_DRAWN - unsigned int lUiCount = m_aItems.Count(); - - while (lUiCount-- != 0) + if ( m_windowStyle & wxLB_OWNERDRAW ) { - delete m_aItems[lUiCount]; + WX_CLEAR_ARRAY(m_aItems); } - - m_aItems.Clear(); #endif // wxUSE_OWNER_DRAWN ::WinSendMsg(GetHwnd(), LM_DELETEALL, (MPARAM)0, (MPARAM)0); @@ -537,14 +523,6 @@ void wxListBox::SetString(unsigned int n, const wxString& rsString) // if (bWasSelected) Select(n); - -#if wxUSE_OWNER_DRAWN - if (m_windowStyle & wxLB_OWNERDRAW) - // - // Update item's text - // - m_aItems[n]->SetName(rsString); -#endif //USE_OWNER_DRAWN } // end of wxListBox::SetString unsigned int wxListBox::GetCount() const @@ -793,7 +771,7 @@ bool wxListBox::OS2OnDraw ( return pData->OnDrawItem( vDc ,vRect ,(wxOwnerDrawn::wxODAction)eAction - ,(wxOwnerDrawn::wxODStatus)eStatus + ,(wxOwnerDrawn::wxODStatus)(eStatus | wxOwnerDrawn::wxODHidePrefix) ); } // end of wxListBox::OS2OnDraw diff --git a/src/os2/menuitem.cpp b/src/os2/menuitem.cpp index bffbf97258..6a17b43d41 100644 --- a/src/os2/menuitem.cpp +++ b/src/os2/menuitem.cpp @@ -82,11 +82,6 @@ wxMenuItem::wxMenuItem( ,eKind ,pSubMenu ) -#if wxUSE_OWNER_DRAWN -, wxOwnerDrawn( wxPMTextToLabel(rsText) - ,eKind == wxITEM_CHECK - ) -#endif // owner drawn { wxASSERT_MSG(pParentMenu != NULL, wxT("a menu item should have a parent")); memset(&m_vMenuData, '\0', sizeof(m_vMenuData)); @@ -110,11 +105,6 @@ wxMenuItem::wxMenuItem( ,bIsCheckable ? wxITEM_CHECK : wxITEM_NORMAL ,pSubMenu ) -#if wxUSE_OWNER_DRAWN -, wxOwnerDrawn( wxPMTextToLabel(rsText) - ,bIsCheckable - ) -#endif // owner drawn { wxASSERT_MSG(pParentMenu != NULL, wxT("a menu item should have a parent")); memset(&m_vMenuData, '\0', sizeof(m_vMenuData)); @@ -132,21 +122,13 @@ void wxMenuItem::Init() // // Set default menu colors // - #define SYS_COLOR(c) (wxSystemSettings::GetColour(wxSYS_COLOUR_##c)) - - SetTextColour(SYS_COLOR(MENUTEXT)); - SetBackgroundColour(SYS_COLOR(MENU)); + SetTextColour(wxNullColour); + SetBackgroundColour(wxNullColour); // // We don't want normal items be owner-drawn // - ResetOwnerDrawn(); - #undef SYS_COLOR - - // - // Tell the owner drawing code to to show the accel string as well - // - SetAccelString(m_text.AfterFirst(wxT('\t'))); + SetOwnerDrawn(false); #endif // wxUSE_OWNER_DRAWN } // end of wxMenuItem::Init @@ -376,18 +358,7 @@ void wxMenuItem::SetItemLabel( const wxString& rText ) // wxMenuItemBase will do stock ID checks wxMenuItemBase::SetItemLabel(sText); - // m_text could now be different from 'text' if we are a stock menu item, - // so use only m_text below - - OWNER_DRAWN_ONLY(wxOwnerDrawn::SetName(m_text)); -#if wxUSE_OWNER_DRAWN - if (rText.IsEmpty()) - SetAccelString(m_text.AfterFirst(wxT('\t'))); - else - SetAccelString(rText.AfterFirst(wxT('\t'))); -#endif // wxUSE_OWNER_DRAWN - - HWND hMenu = GetHmenuOf(m_parentMenu); + HWND hMenu = GetHmenuOf(m_parentMenu); wxCHECK_RET(hMenu, wxT("menuitem without menu")); @@ -456,13 +427,370 @@ void wxMenuItem::SetItemLabel( const wxString& rText ) } } // end of wxMenuItem::SetText -void wxMenuItem::SetCheckable( - bool bCheckable -) +#if wxUSE_OWNER_DRAWN + +wxString wxMenuItem::GetName() const +{ + return GetItemLabelText(); +} + +bool wxMenuItem::OnMeasureItem( size_t* pWidth, size_t* pHeight ) +{ + wxMemoryDC vDC; + + wxString sStr = GetName(); + + // + // If we have a valid accel string, then pad out + // the menu string so that the menu and accel string are not + // placed on top of each other. + wxString accel = GetItemLabel().AfterFirst(wxT('\t')); + if (!accel.empty() ) + { + sStr.Pad(sStr.length()%8); + sStr += accel; + } + vDC.SetFont(GetFont()); + vDC.GetTextExtent( sStr + ,(wxCoord *)pWidth + ,(wxCoord *)pHeight + ); + if (!accel.empty()) + { + // + // Measure the accelerator string, and add its width to + // the total item width, plus 16 (Accelerators are right justified, + // with the right edge of the text rectangle 16 pixels left of + // the right edge of the menu) + // + int nAccelWidth; + int nAccelHeight; + + vDC.GetTextExtent( m_strAccel + ,&nAccelWidth + ,&nAccelHeight + ); + *pWidth += nAccelWidth; + } + + // + // Add space at the end of the menu for the submenu expansion arrow. + // This will also allow offsetting the accel string from the right edge + // + *pWidth = (size_t)(*pWidth + GetDefaultMarginWidth() * 1.5); + + // + // JACS: items still look too tightly packed, so adding 5 pixels. + // + (*pHeight) += 5; + + // + // Ray Gilbert's changes - Corrects the problem of a BMP + // being placed next to text in a menu item, and the BMP does + // not match the size expected by the system. This will + // resize the space so the BMP will fit. Without this, BMPs + // must be no larger or smaller than 16x16. + // + if (m_bmpChecked.Ok()) + { + // + // Is BMP height larger then text height? + // + size_t nAdjustedHeight = m_bmpChecked.GetHeight() + + wxSystemSettings::GetMetric(wxSYS_EDGE_Y); + if (*pHeight < nAdjustedHeight) + *pHeight = nAdjustedHeight; + + // + // Does BMP encroach on default check menu position? + // + size_t nAdjustedWidth = m_bmpChecked.GetWidth() + + (wxSystemSettings::GetMetric(wxSYS_EDGE_X) * 2); + + // + // Do we need to widen margin to fit BMP? + // + if ((size_t)GetMarginWidth() < nAdjustedWidth) + SetMarginWidth(nAdjustedWidth); + + // + // Add the size of the bitmap to our total size... + // + *pWidth += GetMarginWidth(); + } + + // + // Add the size of the bitmap to our total size - even if we don't have + // a bitmap we leave room for one... + // + *pWidth += GetMarginWidth(); + + // + // Make sure that this item is at least as + // tall as the user's system settings specify + // + const size_t heightStd = 6; // FIXME: get value from the system + if ( *pHeight < heightStd ) + *pHeight = heightStd; + m_nHeight = *pHeight; // remember height for use in OnDrawItem + return true; +} // end of wxOwnerDrawn::OnMeasureItem + +bool wxMenuItem::OnDrawItem( wxDC& rDC, + const wxRect& rRect, + wxODAction eAction, + wxODStatus eStatus ) { - wxMenuItemBase::SetCheckable(bCheckable); - OWNER_DRAWN_ONLY(wxOwnerDrawn::SetCheckable(bCheckable)); -} // end of wxMenuItem::SetCheckable + + // + // Select the font and draw the text + // --------------------------------- + // + + CHARBUNDLE vCbnd; + wxPMDCImpl *impl = (wxPMDCImpl*) rDC.GetImpl(); + HPS hPS= impl->GetHPS(); + wxFont vFont; + wxColour vColBack; + wxColour vColText; + COLORREF vRef; + RECTL vRect = {rRect.x + 4, rRect.y + 1, rRect.x + (rRect.width - 2), rRect.y + rRect.height}; + + memset(&vCbnd, 0, sizeof(CHARBUNDLE)); + + GetFontToUse(vFont); + GetColourToUse(eStatus, vColText, vColBack); + + rDC.SetFont(vFont); + rDC.SetTextBackground(vColBack); + rDC.SetTextForeground(vColText); + rDC.SetBackgroundMode(wxTRANSPARENT); + + vCbnd.lColor = vColText.GetPixel(); + vCbnd.lBackColor = vColBack.GetPixel(); + ::GpiSetAttrs( hPS + ,PRIM_CHAR + ,CBB_BACK_COLOR | CBB_COLOR + ,0 + ,&vCbnd + ); + ::GpiSetBackMix( hPS + ,BM_LEAVEALONE + ); + + // + // Paint the background + // + ::WinFillRect(hPS, &vRect, vColBack.GetPixel()); + + // + // Determine where to draw and leave space for a check-mark. + // + int nX = rRect.x + GetMarginWidth(); + + // + // Unfortunately, unlike Win32, PM has no owner drawn specific text + // drawing methods like ::DrawState that can cleanly handle accel + // mnemonics and deal, automatically, with various states, so we have + // to handle them ourselves. Notice Win32 can't handle \t in ownerdrawn + // strings either. We cannot handle mnemonics either. We display + // them, though, in the hope we can figure them out some day. + // + + // + // Display main text and accel text separately to align better + // + wxString sTgt = wxT("\t"); + wxString sFullString = GetItemLabel(); // need to save the original text + wxString sAccel; + int nIndex; + size_t nWidth; + size_t nCharWidth; + size_t nHeight; + bool bFoundMnemonic = false; + bool bFoundAccel = false; + + // + // Deal with the tab, extracting the Accel text + // + nIndex = sFullString.Find(sTgt); + if (nIndex != -1) + { + bFoundAccel = true; + sAccel = sFullString.Mid(nIndex + 1); + sFullString.Remove(nIndex); + } + + // + // Deal with the mnemonic character + // + sTgt = wxT("~"); + nIndex = sFullString.Find(sTgt); + if (nIndex != -1) + { + wxString sTmp = sFullString; + + bFoundMnemonic = true; + sTmp.Remove(nIndex); + rDC.GetTextExtent( sTmp + ,(wxCoord *)&nWidth + ,(wxCoord *)&nHeight + ); + sTmp = sFullString[(size_t)(nIndex + 1)]; + rDC.GetTextExtent( sTmp + ,(wxCoord *)&nCharWidth + ,(wxCoord *)&nHeight + ); + sFullString.Replace(sTgt.c_str(), wxEmptyString, true); + } + + // + // Draw the main item text sans the accel text + // + POINTL vPntStart = {nX, rRect.y + 4}; + ::GpiCharStringAt( impl->GetHPS() + ,&vPntStart + ,sFullString.length() + ,sFullString.char_str() + ); + if (bFoundMnemonic) + { + // + // Underline the mnemonic -- still won't work, but at least it "looks" right + // + wxPen vPen; + POINTL vPntEnd = {nX + nWidth + nCharWidth - 3, rRect.y + 2}; //CharWidth is bit wide + + vPntStart.x = nX + nWidth - 1; + vPntStart.y = rRect.y + 2; // Make it look pretty! + vPen = wxPen(vColText, 1, wxSOLID); // Assuming we are always black + rDC.SetPen(vPen); + ::GpiMove(hPS, &vPntStart); + ::GpiLine(hPS, &vPntEnd); + } + + // + // Now draw the accel text + // + if (bFoundAccel) + { + size_t nWidth; + size_t nHeight; + + rDC.GetTextExtent( sAccel + ,(wxCoord *)&nWidth + ,(wxCoord *)&nHeight + ); + // + // Back off the starting position from the right edge + // + vPntStart.x = rRect.width - (nWidth + 7); + vPntStart.y = rRect.y + 4; + ::GpiCharStringAt( impl->GetHPS() + ,&vPntStart + ,sAccel.length() + ,sAccel.char_str() + ); + } + + // + // Draw the bitmap + // --------------- + // + if (IsCheckable() && !m_bmpChecked.Ok()) + { + if (eStatus & wxODChecked) + { + RECTL vRect; + HBITMAP hBmpCheck = ::WinGetSysBitmap(HWND_DESKTOP, SBMP_MENUCHECK); + + vRect.xLeft = rRect.x; + vRect.xRight = rRect.x + GetMarginWidth(); + vRect.yBottom = rRect.y; + vRect.yTop = rRect.y + m_nHeight - 3; + + ::WinDrawBitmap( hPS // PS for this menuitem + ,hBmpCheck // system checkmark + ,NULL // draw the whole bitmap + ,(PPOINTL)&vRect // destination -- bottom left corner of the menuitem area + ,0L // ignored + ,0L // draw a bitmap + ,DBM_NORMAL // draw normal size + ); + } + } + else + { + // + // For uncheckable item we use only the 'checked' bitmap + // + wxBitmap vBmp(GetBitmap(IsCheckable() ? ((eStatus & wxODChecked) != 0) : TRUE)); + + if (vBmp.Ok()) + { + + wxMemoryDC vDCMem(&rDC); + wxMemoryDC* pOldDC = (wxMemoryDC*)vBmp.GetSelectedInto(); + + if(pOldDC != NULL) + { + vBmp.SetSelectedInto(NULL); + } + vDCMem.SelectObject(vBmp); + + // + // Center bitmap + // + int nBmpWidth = vBmp.GetWidth(); + int nBmpHeight = vBmp.GetHeight(); + + // + // There should be enough space! + // + wxASSERT((nBmpWidth <= rRect.width) && (nBmpHeight <= rRect.height)); + + int nHeightDiff = m_nHeight - nBmpHeight; + + rDC.Blit( rRect.x + (GetMarginWidth() - nBmpWidth) / 2 + ,rRect.y + nHeightDiff / 2 + ,nBmpWidth + ,nBmpHeight + ,&vDCMem + ,0 + ,0 + ,wxCOPY + ,true + ); + + if (eStatus & wxODSelected) + { + POINTL vPnt1 = {rRect.x + 1, rRect.y + 3}; // Leave a little background border + POINTL vPnt2 = {rRect.x + GetMarginWidth(), rRect.y + m_nHeight - 3}; + + LINEBUNDLE vLine; + + vLine.lColor = vColBack.GetPixel(); + ::GpiSetAttrs( hPS + ,PRIM_LINE + ,LBB_COLOR + ,0 + ,&vLine + ); + ::GpiMove(hPS, &vPnt1); + ::GpiBox( hPS + ,DRO_OUTLINE + ,&vPnt2 + ,0L + ,0L + ); + } + vBmp.SetSelectedInto(NULL); + } + } + return true; +} // end of wxOwnerDrawn::OnDrawItem + +#endif // wxUSE_OWNER_DRAWN // ---------------------------------------------------------------------------- // wxMenuItemBase diff --git a/src/os2/ownerdrw.cpp b/src/os2/ownerdrw.cpp index 04cec30e30..eb7caf39de 100644 --- a/src/os2/ownerdrw.cpp +++ b/src/os2/ownerdrw.cpp @@ -2,7 +2,7 @@ // Name: src/os2/ownerdrw.cpp // Purpose: implementation of wxOwnerDrawn class // Author: David Webster -// Modified by: +// Modified by: Marcin Malich // Created: 10/12/99 // RCS-ID: $Id$ // Copyright: (c) David Webster @@ -14,166 +14,26 @@ #if wxUSE_OWNER_DRAWN -#ifndef WX_PRECOMP - #include "wx/window.h" - #include "wx/os2/private.h" - #include "wx/font.h" - #include "wx/bitmap.h" - #include "wx/dcmemory.h" - #include "wx/menu.h" - #include "wx/utils.h" - #include "wx/settings.h" - #include "wx/menuitem.h" -#endif - #include "wx/ownerdrw.h" +#include "wx/os2/private.h" #include "wx/os2/dcclient.h" +// ---------------------------------------------------------------------------- +// constants for base class +// ---------------------------------------------------------------------------- + +int wxOwnerDrawnBase::ms_defaultMargin = 3; + // ============================================================================ // implementation of wxOwnerDrawn class // ============================================================================ -// -// ctor -// ---- -// -wxOwnerDrawn::wxOwnerDrawn( const wxString& rsStr, - bool bCheckable, - bool WXUNUSED(bMenuItem) ) -: m_strName(rsStr) -{ - m_bCheckable = bCheckable; - m_bOwnerDrawn = false; - m_nHeight = 0; - m_nMarginWidth = ms_nLastMarginWidth; - if (wxNORMAL_FONT) - m_font = *wxNORMAL_FONT; -} // end of wxOwnerDrawn::wxOwnerDrawn - -wxOwnerDrawn::~wxOwnerDrawn() { } - -size_t wxOwnerDrawn::ms_nDefaultMarginWidth = 15; - -size_t wxOwnerDrawn::ms_nLastMarginWidth = ms_nDefaultMarginWidth; - -// -// Drawing -// ------- -// - -bool wxOwnerDrawn::OnMeasureItem( size_t* pWidth, - size_t* pHeight ) -{ - wxMemoryDC vDC; - - wxString sStr = wxStripMenuCodes(m_strName); - - // - // If we have a valid accel string, then pad out - // the menu string so that the menu and accel string are not - // placed on top of each other. - if (!m_strAccel.empty() ) - { - sStr.Pad(sStr.length()%8); - sStr += m_strAccel; - } - vDC.SetFont(GetFont()); - vDC.GetTextExtent( sStr - ,(wxCoord *)pWidth - ,(wxCoord *)pHeight - ); - if (!m_strAccel.empty()) - { - // - // Measure the accelerator string, and add its width to - // the total item width, plus 16 (Accelerators are right justified, - // with the right edge of the text rectangle 16 pixels left of - // the right edge of the menu) - // - int nAccelWidth; - int nAccelHeight; - - vDC.GetTextExtent( m_strAccel - ,&nAccelWidth - ,&nAccelHeight - ); - *pWidth += nAccelWidth; - } - - // - // Add space at the end of the menu for the submenu expansion arrow. - // This will also allow offsetting the accel string from the right edge - // - *pWidth = (size_t)(*pWidth + GetDefaultMarginWidth() * 1.5); - - // - // JACS: items still look too tightly packed, so adding 5 pixels. - // - (*pHeight) += 5; - - // - // Ray Gilbert's changes - Corrects the problem of a BMP - // being placed next to text in a menu item, and the BMP does - // not match the size expected by the system. This will - // resize the space so the BMP will fit. Without this, BMPs - // must be no larger or smaller than 16x16. - // - if (m_bmpChecked.Ok()) - { - // - // Is BMP height larger then text height? - // - size_t nAdjustedHeight = m_bmpChecked.GetHeight() + - wxSystemSettings::GetMetric(wxSYS_EDGE_Y); - if (*pHeight < nAdjustedHeight) - *pHeight = nAdjustedHeight; - - // - // Does BMP encroach on default check menu position? - // - size_t nAdjustedWidth = m_bmpChecked.GetWidth() + - (wxSystemSettings::GetMetric(wxSYS_EDGE_X) * 2); - - // - // Do we need to widen margin to fit BMP? - // - if ((size_t)GetMarginWidth() < nAdjustedWidth) - SetMarginWidth(nAdjustedWidth); - - // - // Add the size of the bitmap to our total size... - // - *pWidth += GetMarginWidth(); - } - - // - // Add the size of the bitmap to our total size - even if we don't have - // a bitmap we leave room for one... - // - *pWidth += GetMarginWidth(); - - // - // Make sure that this item is at least as - // tall as the user's system settings specify - // - const size_t heightStd = 6; // FIXME: get value from the system - if ( *pHeight < heightStd ) - *pHeight = heightStd; - m_nHeight = *pHeight; // remember height for use in OnDrawItem - return true; -} // end of wxOwnerDrawn::OnMeasureItem - // draw the item bool wxOwnerDrawn::OnDrawItem( wxDC& rDC, const wxRect& rRect, wxODAction eAction, wxODStatus eStatus ) { - // - // We do nothing on focus change - // - if (eAction == wxODFocusChanged ) - return true; // // Select the font and draw the text @@ -183,6 +43,7 @@ bool wxOwnerDrawn::OnDrawItem( wxDC& rDC, CHARBUNDLE vCbnd; wxPMDCImpl *impl = (wxPMDCImpl*) rDC.GetImpl(); HPS hPS= impl->GetHPS(); + wxFont vFont; wxColour vColBack; wxColour vColText; COLORREF vRef; @@ -190,85 +51,14 @@ bool wxOwnerDrawn::OnDrawItem( wxDC& rDC, memset(&vCbnd, 0, sizeof(CHARBUNDLE)); - // - // Use default font if no font set - // - if (m_font.Ok()) - { - m_font.RealizeResource(); - } - else - { - ::GpiSetCharSet(hPS, LCID_DEFAULT); - } - - // - // Based on the status of the menu item, pick the right colors - // - if (eStatus & wxODSelected) - { - vRef = (ULONG)::WinQuerySysColor( HWND_DESKTOP - ,SYSCLR_MENUHILITEBGND - ,0L - ); - vColBack.Set( GetRValue(vRef) - ,GetGValue(vRef) - ,GetBValue(vRef) - ); - vRef = (ULONG)::WinQuerySysColor( HWND_DESKTOP - ,SYSCLR_MENUHILITE - ,0L - ); - vColText.Set( GetRValue(vRef) - ,GetGValue(vRef) - ,GetBValue(vRef) - ); - } - else if (eStatus & wxODDisabled) - { - vRef = (ULONG)::WinQuerySysColor( HWND_DESKTOP - ,SYSCLR_MENU // Light gray - ,0L - ); - vColBack.Set( GetRValue(vRef) - ,GetGValue(vRef) - ,GetBValue(vRef) - ); - vRef = (ULONG)::WinQuerySysColor( HWND_DESKTOP - ,SYSCLR_MENUDISABLEDTEXT // dark gray - ,0L - ); - vColText.Set( GetRValue(vRef) - ,GetGValue(vRef) - ,GetBValue(vRef) - ); - } - else - { - // - // Fall back to default colors if none explicitly specified - // - vRef = ::WinQuerySysColor( HWND_DESKTOP - ,SYSCLR_MENU // we are using gray for all our window backgrounds in wxWidgets - ,0L - ); - vColBack.Set( GetRValue(vRef) - ,GetGValue(vRef) - ,GetBValue(vRef) - ); - vRef = ::WinQuerySysColor( HWND_DESKTOP - ,SYSCLR_WINDOWTEXT // Black - ,0L - ); - vColText.Set( GetRValue(vRef) - ,GetGValue(vRef) - ,GetBValue(vRef) - ); - } + GetFontToUse(vFont); + GetColourToUse(eStatus, vColText, vColBack); + rDC.SetFont(vFont); rDC.SetTextBackground(vColBack); rDC.SetTextForeground(vColText); rDC.SetBackgroundMode(wxTRANSPARENT); + vCbnd.lColor = vColText.GetPixel(); vCbnd.lBackColor = vColBack.GetPixel(); ::GpiSetAttrs( hPS @@ -289,7 +79,7 @@ bool wxOwnerDrawn::OnDrawItem( wxDC& rDC, // // Determine where to draw and leave space for a check-mark. // - int nX = rRect.x + GetMarginWidth(); + int nX = rRect.x + GetMarginWidth(); // // Unfortunately, unlike Win32, PM has no owner drawn specific text @@ -301,34 +91,19 @@ bool wxOwnerDrawn::OnDrawItem( wxDC& rDC, // // - // Display main text and accel text separately to align better + // Display main text // - wxString sTgt = wxT("\t"); - wxString sFullString = m_strName; // need to save the original text - wxString sAccel; + wxString sFullString = GetItemLabel(); // need to save the original text int nIndex; size_t nWidth; size_t nCharWidth; size_t nHeight; bool bFoundMnemonic = false; - bool bFoundAccel = false; - - // - // Deal with the tab, extracting the Accel text - // - nIndex = sFullString.Find(sTgt); - if (nIndex != -1) - { - bFoundAccel = true; - sAccel = sFullString.Mid(nIndex + 1); - sFullString.Remove(nIndex); - } // // Deal with the mnemonic character // - sTgt = wxT("~"); - nIndex = sFullString.Find(sTgt); + nIndex = sFullString.Find(wxT("~")); if (nIndex != -1) { wxString sTmp = sFullString; @@ -372,124 +147,6 @@ bool wxOwnerDrawn::OnDrawItem( wxDC& rDC, ::GpiLine(hPS, &vPntEnd); } - // - // Now draw the accel text - // - if (bFoundAccel) - { - size_t nWidth; - size_t nHeight; - - rDC.GetTextExtent( sAccel - ,(wxCoord *)&nWidth - ,(wxCoord *)&nHeight - ); - // - // Back off the starting position from the right edge - // - vPntStart.x = rRect.width - (nWidth + 7); - vPntStart.y = rRect.y + 4; - ::GpiCharStringAt( impl->GetHPS() - ,&vPntStart - ,sAccel.length() - ,sAccel.char_str() - ); - } - - // - // Draw the bitmap - // --------------- - // - if (IsCheckable() && !m_bmpChecked.Ok()) - { - if (eStatus & wxODChecked) - { - RECTL vRect; - HBITMAP hBmpCheck = ::WinGetSysBitmap(HWND_DESKTOP, SBMP_MENUCHECK); - - vRect.xLeft = rRect.x; - vRect.xRight = rRect.x + GetMarginWidth(); - vRect.yBottom = rRect.y; - vRect.yTop = rRect.y + m_nHeight - 3; - - ::WinDrawBitmap( hPS // PS for this menuitem - ,hBmpCheck // system checkmark - ,NULL // draw the whole bitmap - ,(PPOINTL)&vRect // destination -- bottom left corner of the menuitem area - ,0L // ignored - ,0L // draw a bitmap - ,DBM_NORMAL // draw normal size - ); - } - } - else - { - // - // For uncheckable item we use only the 'checked' bitmap - // - wxBitmap vBmp(GetBitmap(IsCheckable() ? ((eStatus & wxODChecked) != 0) : TRUE)); - - if (vBmp.Ok()) - { - - wxMemoryDC vDCMem(&rDC); - wxMemoryDC* pOldDC = (wxMemoryDC*)vBmp.GetSelectedInto(); - - if(pOldDC != NULL) - { - vBmp.SetSelectedInto(NULL); - } - vDCMem.SelectObject(vBmp); - - // - // Center bitmap - // - int nBmpWidth = vBmp.GetWidth(); - int nBmpHeight = vBmp.GetHeight(); - - // - // There should be enough space! - // - wxASSERT((nBmpWidth <= rRect.width) && (nBmpHeight <= rRect.height)); - - int nHeightDiff = m_nHeight - nBmpHeight; - - rDC.Blit( rRect.x + (GetMarginWidth() - nBmpWidth) / 2 - ,rRect.y + nHeightDiff / 2 - ,nBmpWidth - ,nBmpHeight - ,&vDCMem - ,0 - ,0 - ,wxCOPY - ,true - ); - - if (eStatus & wxODSelected) - { - POINTL vPnt1 = {rRect.x + 1, rRect.y + 3}; // Leave a little background border - POINTL vPnt2 = {rRect.x + GetMarginWidth(), rRect.y + m_nHeight - 3}; - - LINEBUNDLE vLine; - - vLine.lColor = vColBack.GetPixel(); - ::GpiSetAttrs( hPS - ,PRIM_LINE - ,LBB_COLOR - ,0 - ,&vLine - ); - ::GpiMove(hPS, &vPnt1); - ::GpiBox( hPS - ,DRO_OUTLINE - ,&vPnt2 - ,0L - ,0L - ); - } - vBmp.SetSelectedInto(NULL); - } - } return true; } // end of wxOwnerDrawn::OnDrawItem -- 2.45.2