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
This commit is contained in:
Vadim Zeitlin
2010-01-23 13:21:12 +00:00
parent 937d5b6075
commit 98fbab9e7b
26 changed files with 1638 additions and 1394 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -1818,6 +1818,7 @@ ____CORE_SRC_FILENAMES_OBJECTS = \
$(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 \
@@ -2060,6 +2061,7 @@ ____CORE_SRC_FILENAMES_OBJECTS = \
$(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 \
@@ -2518,6 +2520,7 @@ ____CORE_SRC_FILENAMES_1_OBJECTS = \
$(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 \
@@ -2760,6 +2763,7 @@ ____CORE_SRC_FILENAMES_1_OBJECTS = \
$(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 \
@@ -3111,6 +3115,7 @@ ____CORE_SRC_FILENAMES_2_OBJECTS = \
$(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 \
@@ -3353,6 +3358,7 @@ ____CORE_SRC_FILENAMES_2_OBJECTS = \
$(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 \
@@ -3600,6 +3606,7 @@ ____CORE_SRC_FILENAMES_3_OBJECTS = \
$(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 \
@@ -3842,6 +3849,7 @@ ____CORE_SRC_FILENAMES_3_OBJECTS = \
$(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 \
@@ -7306,6 +7314,11 @@ $(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_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
@@ -9483,6 +9496,11 @@ $(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_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
@@ -11663,6 +11681,11 @@ $(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_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
@@ -12937,6 +12960,11 @@ $(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_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

View File

@@ -1845,6 +1845,7 @@ ____CORE_SRC_FILENAMES_OBJECTS = \
$(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 \
@@ -2089,6 +2090,7 @@ ____CORE_SRC_FILENAMES_OBJECTS = \
$(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 \
@@ -2551,6 +2553,7 @@ ____CORE_SRC_FILENAMES_1_OBJECTS = \
$(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 \
@@ -2795,6 +2798,7 @@ ____CORE_SRC_FILENAMES_1_OBJECTS = \
$(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 \
@@ -3160,6 +3164,7 @@ ____CORE_SRC_FILENAMES_2_OBJECTS = \
$(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 \
@@ -3404,6 +3409,7 @@ ____CORE_SRC_FILENAMES_2_OBJECTS = \
$(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 \
@@ -3657,6 +3663,7 @@ ____CORE_SRC_FILENAMES_3_OBJECTS = \
$(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 \
@@ -3901,6 +3908,7 @@ ____CORE_SRC_FILENAMES_3_OBJECTS = \
$(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 \
@@ -7472,6 +7480,11 @@ $(OBJS)\monodll_overlaycmn.o: ../../src/common/overlaycmn.cpp
$(CXX) -c -o $@ $(MONODLL_CXXFLAGS) $(CPPDEPS) $<
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) $<
@@ -9649,6 +9662,11 @@ $(OBJS)\monolib_overlaycmn.o: ../../src/common/overlaycmn.cpp
$(CXX) -c -o $@ $(MONOLIB_CXXFLAGS) $(CPPDEPS) $<
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) $<
@@ -11829,6 +11847,11 @@ $(OBJS)\coredll_overlaycmn.o: ../../src/common/overlaycmn.cpp
$(CXX) -c -o $@ $(COREDLL_CXXFLAGS) $(CPPDEPS) $<
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) $<
@@ -13103,6 +13126,11 @@ $(OBJS)\corelib_overlaycmn.o: ../../src/common/overlaycmn.cpp
$(CXX) -c -o $@ $(CORELIB_CXXFLAGS) $(CPPDEPS) $<
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) $<

View File

@@ -2043,6 +2043,7 @@ ____CORE_SRC_FILENAMES_OBJECTS = \
$(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 \
@@ -2285,6 +2286,7 @@ ____CORE_SRC_FILENAMES_OBJECTS = \
$(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 \
@@ -2749,6 +2751,7 @@ ____CORE_SRC_FILENAMES_1_OBJECTS = \
$(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 \
@@ -2991,6 +2994,7 @@ ____CORE_SRC_FILENAMES_1_OBJECTS = \
$(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 \
@@ -3408,6 +3412,7 @@ ____CORE_SRC_FILENAMES_2_OBJECTS = \
$(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 \
@@ -3650,6 +3655,7 @@ ____CORE_SRC_FILENAMES_2_OBJECTS = \
$(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 \
@@ -3903,6 +3909,7 @@ ____CORE_SRC_FILENAMES_3_OBJECTS = \
$(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 \
@@ -4145,6 +4152,7 @@ ____CORE_SRC_FILENAMES_3_OBJECTS = \
$(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 \
@@ -7903,6 +7911,11 @@ $(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_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
@@ -10080,6 +10093,11 @@ $(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_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
@@ -12260,6 +12278,11 @@ $(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_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
@@ -13534,6 +13557,11 @@ $(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_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

View File

@@ -411,6 +411,7 @@ ____CORE_SRC_FILENAMES_OBJECTS = &
$(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 &
@@ -655,6 +656,7 @@ ____CORE_SRC_FILENAMES_OBJECTS = &
$(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 &
@@ -1122,6 +1124,7 @@ ____CORE_SRC_FILENAMES_1_OBJECTS = &
$(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 &
@@ -1366,6 +1369,7 @@ ____CORE_SRC_FILENAMES_1_OBJECTS = &
$(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 &
@@ -1742,6 +1746,7 @@ ____CORE_SRC_FILENAMES_2_OBJECTS = &
$(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 &
@@ -1986,6 +1991,7 @@ ____CORE_SRC_FILENAMES_2_OBJECTS = &
$(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 &
@@ -2241,6 +2247,7 @@ ____CORE_SRC_FILENAMES_3_OBJECTS = &
$(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 &
@@ -2485,6 +2492,7 @@ ____CORE_SRC_FILENAMES_3_OBJECTS = &
$(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 &
@@ -7731,6 +7739,11 @@ $(OBJS)\monodll_overlaycmn.obj : .AUTODEPEND ..\..\src\common\overlaycmn.cpp
$(CXX) -bt=nt -zq -fo=$^@ $(MONODLL_CXXFLAGS) $<
!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) $<
@@ -9908,6 +9921,11 @@ $(OBJS)\monolib_overlaycmn.obj : .AUTODEPEND ..\..\src\common\overlaycmn.cpp
$(CXX) -bt=nt -zq -fo=$^@ $(MONOLIB_CXXFLAGS) $<
!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) $<
@@ -12088,6 +12106,11 @@ $(OBJS)\coredll_overlaycmn.obj : .AUTODEPEND ..\..\src\common\overlaycmn.cpp
$(CXX) -bt=nt -zq -fo=$^@ $(COREDLL_CXXFLAGS) $<
!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) $<
@@ -13362,6 +13385,11 @@ $(OBJS)\corelib_overlaycmn.obj : .AUTODEPEND ..\..\src\common\overlaycmn.cpp
$(CXX) -bt=nt -zq -fo=$^@ $(CORELIB_CXXFLAGS) $<
!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) $<

View File

@@ -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

View File

@@ -813,6 +813,9 @@
<File
RelativePath="..\..\src\common\overlaycmn.cpp">
</File>
<File
RelativePath="..\..\src\common\ownerdrwcmn.cpp">
</File>
<File
RelativePath="..\..\src\common\paper.cpp">
</File>
@@ -4416,6 +4419,9 @@
<File
RelativePath="..\..\include\wx\msw\ole\oleutils.h">
</File>
<File
RelativePath="..\..\include\wx\msw\ownerdrw.h">
</File>
<File
RelativePath="..\..\include\wx\msw\palette.h">
</File>

View File

@@ -1118,6 +1118,10 @@
RelativePath="..\..\src\common\overlaycmn.cpp"
>
</File>
<File
RelativePath="..\..\src\common\ownerdrwcmn.cpp"
>
</File>
<File
RelativePath="..\..\src\common\paper.cpp"
>
@@ -5907,6 +5911,10 @@
RelativePath="..\..\include\wx\msw\ole\oleutils.h"
>
</File>
<File
RelativePath="..\..\include\wx\msw\ownerdrw.h"
>
</File>
<File
RelativePath="..\..\include\wx\msw\palette.h"
>

View File

@@ -1114,6 +1114,10 @@
RelativePath="..\..\src\common\overlaycmn.cpp"
>
</File>
<File
RelativePath="..\..\src\common\ownerdrwcmn.cpp"
>
</File>
<File
RelativePath="..\..\src\common\paper.cpp"
>
@@ -5903,6 +5907,10 @@
RelativePath="..\..\include\wx\msw\ole\oleutils.h"
>
</File>
<File
RelativePath="..\..\include\wx\msw\ownerdrw.h"
>
</File>
<File
RelativePath="..\..\include\wx\msw\palette.h"
>

View File

@@ -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

View File

@@ -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)
};

29
include/wx/msw/ownerdrw.h Normal file
View File

@@ -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 <me@malcom.pl>
// 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_

View File

@@ -24,6 +24,7 @@
// to write #ifdef's everywhere...
#if wxUSE_OWNER_DRAWN
#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

29
include/wx/os2/ownerdrw.h Normal file
View File

@@ -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 <me@malcom.pl>
// 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_

View File

@@ -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 <zeitlin@dptmaths.ens-cachan.fr>
// 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,95 +28,64 @@
// 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();
wxOwnerDrawnBase()
{
m_ownerDrawn = false;
m_margin = ms_defaultMargin;
}
virtual ~wxOwnerDrawnBase() {}
// fix appearance
void SetFont(const wxFont& font)
{ m_font = font; m_bOwnerDrawn = true; }
{ m_font = font; m_ownerDrawn = true; }
wxFont& GetFont() const
{ return (wxFont&) m_font; }
wxFont& GetFont() const { return (wxFont &)m_font; }
void SetTextColour(const wxColour& colText)
{ m_colText = colText; m_bOwnerDrawn = true; }
{ m_colText = colText; m_ownerDrawn = true; }
wxColour& GetTextColour() const { return (wxColour&) m_colText; }
wxColour& GetTextColour() const
{ return (wxColour&) m_colText; }
void SetBackgroundColour(const wxColour& colBack)
{ m_colBack = colBack; m_bOwnerDrawn = true; }
{ m_colBack = colBack; m_ownerDrawn = 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 SetMarginWidth(int width)
{ m_margin = width; }
void SetDisabledBitmap( const wxBitmap& bmpDisabled )
{ m_bmpDisabled = bmpDisabled;
m_bOwnerDrawn = true; }
int GetMarginWidth() const
{ return m_margin; }
const wxBitmap& GetBitmap(bool bChecked = true) const
{ return (bChecked ? m_bmpChecked : m_bmpUnchecked); }
static int GetDefaultMarginWidth()
{ return ms_defaultMargin; }
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;
}
// get item name (with mnemonics if exist)
virtual wxString GetName() const = 0;
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; }
// 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; }
bool IsOwnerDrawn() const
{ return m_ownerDrawn; }
// switch on/off owner-drawing the item
void SetOwnerDrawn(bool ownerDrawn = true) { m_bOwnerDrawn = ownerDrawn; }
void ResetOwnerDrawn() { m_bOwnerDrawn = false; }
void SetOwnerDrawn(bool ownerDrawn = true)
{ m_ownerDrawn = ownerDrawn; }
public:
// constants used in OnDrawItem
// (they have the same values as corresponding Win32 constants)
enum wxODAction
@@ -139,40 +107,37 @@ public:
};
// 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);
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;
wxString m_strName, // label for a manu item
m_strAccel; // the accel string ("Ctrl-F17") if any
// 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:
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
bool m_ownerDrawn; // true if something is non standard
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;
};
// ----------------------------------------------------------------------------
// include the platform-specific class declaration
// ----------------------------------------------------------------------------
#if defined(__WXMSW__)
#include "wx/msw/ownerdrw.h"
#elif defined(__WXPM__)
#include "wx/os2/ownerdrw.h"
#endif
#endif // wxUSE_OWNER_DRAWN
#endif
// _OWNERDRW_H
#endif // _WX_OWNERDRW_H_BASE

View File

@@ -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 <me@malcom.pl>
// 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

View File

@@ -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());
}

View File

@@ -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<wxListBoxItem*>(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

View File

@@ -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__

View File

@@ -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
// ----------------------------------------------------------------------------

View File

@@ -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 <zeitlin@dptmaths.ens-cachan.fr>
@@ -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;
}
// ----------------------------------------------------------------------------
// constants for base class
// ----------------------------------------------------------------------------
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);
#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)
// we do nothing if item isn't ownerdrawn
if ( !IsOwnerDrawn() )
return true;
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);
}
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;
// using native API because it recognizes '&'
if ( IsOwnerDrawn() )
{
int nPrevMode = SetBkMode(hdc, TRANSPARENT);
AutoHBRUSH hbr(colBack);
AutoHBRUSH hbr(wxColourToPalRGB(colBack));
SelectInHDC selBrush(hdc, hbr);
RECT rectFill;
wxCopyRectToRECT(rc, rectFill);
::FillRect(hdc, &rectFill, hbr);
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;
}
// using native API because it recognizes '&'
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
wxString text = GetName();
SIZE sizeRect;
::GetTextExtentPoint32(hdc, strMenuText.c_str(), strMenuText.length(), &sizeRect);
::GetTextExtentPoint32(hdc, text.c_str(), text.length(), &sizeRect);
int flags = DST_PREFIXTEXT;
if ( (st & wxODDisabled) && !(st & wxODSelected) )
if ( (stat & wxODDisabled) && !(stat & wxODSelected) )
flags |= DSS_DISABLED;
if ( (st & wxODHidePrefix) &&
!wxMSWSystemMenuFontModule::AlwaysShowCues() )
if ( (stat & wxODHidePrefix) )
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
);
int x = rc.x + GetMarginWidth();
int y = rc.y + (rc.GetHeight() - sizeRect.cy) / 2;
int cx = rc.GetWidth() - GetMarginWidth();
int cy = sizeRect.cy;
// ::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));
#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
}
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 = 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
// ----------------------------------------------------------------------------

View File

@@ -39,6 +39,12 @@
#define INCL_PM
#include <os2.h>
// ----------------------------------------------------------------------------
// 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;

View File

@@ -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<wxListBoxItem*>(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--;
@@ -304,11 +297,8 @@ int wxListBox::DoInsertItems(const wxArrayStringsAdapter & items,
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);
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

View File

@@ -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,17 +358,6 @@ 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);
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
{
wxMenuItemBase::SetCheckable(bCheckable);
OWNER_DRAWN_ONLY(wxOwnerDrawn::SetCheckable(bCheckable));
} // end of wxMenuItem::SetCheckable
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 )
{
//
// 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

View File

@@ -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
@@ -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