From cf2810aa394d47a43489d6138edf0497c389a22c Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 6 Jan 2008 14:38:44 +0000 Subject: [PATCH] use wxWindowIDRef to transparently implement auto-generated ids ref-counting (slightly modified patch 1835458) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@51035 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- Makefile.in | 21 +++ build/bakefiles/files.bkl | 2 + build/msw/makefile.bcc | 28 ++++ build/msw/makefile.gcc | 28 ++++ build/msw/makefile.vc | 28 ++++ build/msw/makefile.wat | 28 ++++ build/msw/wx_core.dsp | 8 ++ include/wx/defs.h | 30 +++- include/wx/mac/setup0.h | 10 ++ include/wx/menuitem.h | 2 +- include/wx/motif/setup0.h | 10 ++ include/wx/msw/radiobox.h | 1 + include/wx/msw/setup0.h | 10 ++ include/wx/msw/slider95.h | 3 +- include/wx/msw/wince/setup.h | 10 ++ include/wx/os2/setup0.h | 10 ++ include/wx/palmos/setup0.h | 10 ++ include/wx/setup_inc.h | 10 ++ include/wx/tbarbase.h | 2 +- include/wx/window.h | 32 ++--- include/wx/windowid.h | 189 ++++++++++++++++++++++++++ setup.h.in | 2 + src/common/wincmn.cpp | 129 ------------------ src/common/windowid.cpp | 256 +++++++++++++++++++++++++++++++++++ src/generic/editlbox.cpp | 12 +- src/msw/bmpbuttn.cpp | 2 +- src/msw/mdi.cpp | 2 +- src/msw/radiobox.cpp | 13 +- src/msw/slider95.cpp | 7 +- src/msw/statbr95.cpp | 2 +- src/xrc/xmlres.cpp | 10 +- wxGTK.spec | 8 +- wxMotif.spec | 8 +- wxX11.spec | 8 +- 34 files changed, 745 insertions(+), 186 deletions(-) create mode 100644 include/wx/windowid.h create mode 100644 src/common/windowid.cpp diff --git a/Makefile.in b/Makefile.in index 2905b02bf0..a0a7b3b76e 100644 --- a/Makefile.in +++ b/Makefile.in @@ -3223,6 +3223,7 @@ COND_USE_GUI_1_ALL_GUI_HEADERS = \ wx/validate.h \ wx/valtext.h \ wx/window.h \ + wx/windowid.h \ wx/wupdlock.h \ wx/accel.h \ wx/access.h \ @@ -3892,6 +3893,7 @@ COND_USE_GUI_1_WXUNIV_0___CORE_SRC_OBJECTS = \ monodll_validate.o \ monodll_valtext.o \ monodll_wincmn.o \ + monodll_windowid.o \ monodll_xpmdecod.o \ monodll_busyinfo.o \ monodll_buttonbar.o \ @@ -4074,6 +4076,7 @@ COND_USE_GUI_1_WXUNIV_1___CORE_SRC_OBJECTS = \ monodll_validate.o \ monodll_valtext.o \ monodll_wincmn.o \ + monodll_windowid.o \ monodll_xpmdecod.o \ monodll_busyinfo.o \ monodll_buttonbar.o \ @@ -5780,6 +5783,7 @@ COND_USE_GUI_1_WXUNIV_0___CORE_SRC_OBJECTS_1 = \ monolib_validate.o \ monolib_valtext.o \ monolib_wincmn.o \ + monolib_windowid.o \ monolib_xpmdecod.o \ monolib_busyinfo.o \ monolib_buttonbar.o \ @@ -5962,6 +5966,7 @@ COND_USE_GUI_1_WXUNIV_1___CORE_SRC_OBJECTS_1 = \ monolib_validate.o \ monolib_valtext.o \ monolib_wincmn.o \ + monolib_windowid.o \ monolib_xpmdecod.o \ monolib_busyinfo.o \ monolib_buttonbar.o \ @@ -7949,6 +7954,7 @@ COND_USE_GUI_1_WXUNIV_0___CORE_SRC_OBJECTS_2 = \ coredll_validate.o \ coredll_valtext.o \ coredll_wincmn.o \ + coredll_windowid.o \ coredll_xpmdecod.o \ coredll_busyinfo.o \ coredll_buttonbar.o \ @@ -8131,6 +8137,7 @@ COND_USE_GUI_1_WXUNIV_1___CORE_SRC_OBJECTS_2 = \ coredll_validate.o \ coredll_valtext.o \ coredll_wincmn.o \ + coredll_windowid.o \ coredll_xpmdecod.o \ coredll_busyinfo.o \ coredll_buttonbar.o \ @@ -9441,6 +9448,7 @@ COND_USE_GUI_1_WXUNIV_0___CORE_SRC_OBJECTS_3 = \ corelib_validate.o \ corelib_valtext.o \ corelib_wincmn.o \ + corelib_windowid.o \ corelib_xpmdecod.o \ corelib_busyinfo.o \ corelib_buttonbar.o \ @@ -9623,6 +9631,7 @@ COND_USE_GUI_1_WXUNIV_1___CORE_SRC_OBJECTS_3 = \ corelib_validate.o \ corelib_valtext.o \ corelib_wincmn.o \ + corelib_windowid.o \ corelib_xpmdecod.o \ corelib_busyinfo.o \ corelib_buttonbar.o \ @@ -17589,6 +17598,9 @@ monodll_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(MONODLL_ODEP) @COND_USE_GUI_1@monodll_wincmn.o: $(srcdir)/src/common/wincmn.cpp $(MONODLL_ODEP) @COND_USE_GUI_1@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/common/wincmn.cpp +@COND_USE_GUI_1@monodll_windowid.o: $(srcdir)/src/common/windowid.cpp $(MONODLL_ODEP) +@COND_USE_GUI_1@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/common/windowid.cpp + @COND_USE_GUI_1@monodll_xpmdecod.o: $(srcdir)/src/common/xpmdecod.cpp $(MONODLL_ODEP) @COND_USE_GUI_1@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/common/xpmdecod.cpp @@ -22050,6 +22062,9 @@ monolib_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(MONOLIB_ODEP) @COND_USE_GUI_1@monolib_wincmn.o: $(srcdir)/src/common/wincmn.cpp $(MONOLIB_ODEP) @COND_USE_GUI_1@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/common/wincmn.cpp +@COND_USE_GUI_1@monolib_windowid.o: $(srcdir)/src/common/windowid.cpp $(MONOLIB_ODEP) +@COND_USE_GUI_1@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/common/windowid.cpp + @COND_USE_GUI_1@monolib_xpmdecod.o: $(srcdir)/src/common/xpmdecod.cpp $(MONOLIB_ODEP) @COND_USE_GUI_1@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/common/xpmdecod.cpp @@ -27027,6 +27042,9 @@ coredll_win32.o: $(srcdir)/src/univ/themes/win32.cpp $(COREDLL_ODEP) @COND_USE_GUI_1@coredll_wincmn.o: $(srcdir)/src/common/wincmn.cpp $(COREDLL_ODEP) @COND_USE_GUI_1@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/common/wincmn.cpp +@COND_USE_GUI_1@coredll_windowid.o: $(srcdir)/src/common/windowid.cpp $(COREDLL_ODEP) +@COND_USE_GUI_1@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/common/windowid.cpp + @COND_USE_GUI_1@coredll_xpmdecod.o: $(srcdir)/src/common/xpmdecod.cpp $(COREDLL_ODEP) @COND_USE_GUI_1@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/common/xpmdecod.cpp @@ -30087,6 +30105,9 @@ corelib_win32.o: $(srcdir)/src/univ/themes/win32.cpp $(CORELIB_ODEP) @COND_USE_GUI_1@corelib_wincmn.o: $(srcdir)/src/common/wincmn.cpp $(CORELIB_ODEP) @COND_USE_GUI_1@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/common/wincmn.cpp +@COND_USE_GUI_1@corelib_windowid.o: $(srcdir)/src/common/windowid.cpp $(CORELIB_ODEP) +@COND_USE_GUI_1@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/common/windowid.cpp + @COND_USE_GUI_1@corelib_xpmdecod.o: $(srcdir)/src/common/xpmdecod.cpp $(CORELIB_ODEP) @COND_USE_GUI_1@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/common/xpmdecod.cpp diff --git a/build/bakefiles/files.bkl b/build/bakefiles/files.bkl index 473e5ece3e..83a2de143e 100644 --- a/build/bakefiles/files.bkl +++ b/build/bakefiles/files.bkl @@ -732,6 +732,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file! src/common/validate.cpp src/common/valtext.cpp src/common/wincmn.cpp + src/common/windowid.cpp src/common/xpmdecod.cpp src/generic/busyinfo.cpp src/generic/buttonbar.cpp @@ -852,6 +853,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file! wx/validate.h wx/valtext.h wx/window.h + wx/windowid.h wx/wupdlock.h wx/accel.h diff --git a/build/msw/makefile.bcc b/build/msw/makefile.bcc index 123206e3d9..5175243b46 100644 --- a/build/msw/makefile.bcc +++ b/build/msw/makefile.bcc @@ -1666,6 +1666,7 @@ ____CORE_SRC_FILENAMES_OBJECTS = \ $(OBJS)\monodll_validate.obj \ $(OBJS)\monodll_valtext.obj \ $(OBJS)\monodll_wincmn.obj \ + $(OBJS)\monodll_windowid.obj \ $(OBJS)\monodll_xpmdecod.obj \ $(OBJS)\monodll_busyinfo.obj \ $(OBJS)\monodll_buttonbar.obj \ @@ -1896,6 +1897,7 @@ ____CORE_SRC_FILENAMES_OBJECTS = \ $(OBJS)\monodll_validate.obj \ $(OBJS)\monodll_valtext.obj \ $(OBJS)\monodll_wincmn.obj \ + $(OBJS)\monodll_windowid.obj \ $(OBJS)\monodll_xpmdecod.obj \ $(OBJS)\monodll_busyinfo.obj \ $(OBJS)\monodll_buttonbar.obj \ @@ -2307,6 +2309,7 @@ ____CORE_SRC_FILENAMES_1_OBJECTS = \ $(OBJS)\monolib_validate.obj \ $(OBJS)\monolib_valtext.obj \ $(OBJS)\monolib_wincmn.obj \ + $(OBJS)\monolib_windowid.obj \ $(OBJS)\monolib_xpmdecod.obj \ $(OBJS)\monolib_busyinfo.obj \ $(OBJS)\monolib_buttonbar.obj \ @@ -2537,6 +2540,7 @@ ____CORE_SRC_FILENAMES_1_OBJECTS = \ $(OBJS)\monolib_validate.obj \ $(OBJS)\monolib_valtext.obj \ $(OBJS)\monolib_wincmn.obj \ + $(OBJS)\monolib_windowid.obj \ $(OBJS)\monolib_xpmdecod.obj \ $(OBJS)\monolib_busyinfo.obj \ $(OBJS)\monolib_buttonbar.obj \ @@ -2863,6 +2867,7 @@ ____CORE_SRC_FILENAMES_2_OBJECTS = \ $(OBJS)\coredll_validate.obj \ $(OBJS)\coredll_valtext.obj \ $(OBJS)\coredll_wincmn.obj \ + $(OBJS)\coredll_windowid.obj \ $(OBJS)\coredll_xpmdecod.obj \ $(OBJS)\coredll_busyinfo.obj \ $(OBJS)\coredll_buttonbar.obj \ @@ -3093,6 +3098,7 @@ ____CORE_SRC_FILENAMES_2_OBJECTS = \ $(OBJS)\coredll_validate.obj \ $(OBJS)\coredll_valtext.obj \ $(OBJS)\coredll_wincmn.obj \ + $(OBJS)\coredll_windowid.obj \ $(OBJS)\coredll_xpmdecod.obj \ $(OBJS)\coredll_busyinfo.obj \ $(OBJS)\coredll_buttonbar.obj \ @@ -3325,6 +3331,7 @@ ____CORE_SRC_FILENAMES_3_OBJECTS = \ $(OBJS)\corelib_validate.obj \ $(OBJS)\corelib_valtext.obj \ $(OBJS)\corelib_wincmn.obj \ + $(OBJS)\corelib_windowid.obj \ $(OBJS)\corelib_xpmdecod.obj \ $(OBJS)\corelib_busyinfo.obj \ $(OBJS)\corelib_buttonbar.obj \ @@ -3555,6 +3562,7 @@ ____CORE_SRC_FILENAMES_3_OBJECTS = \ $(OBJS)\corelib_validate.obj \ $(OBJS)\corelib_valtext.obj \ $(OBJS)\corelib_wincmn.obj \ + $(OBJS)\corelib_windowid.obj \ $(OBJS)\corelib_xpmdecod.obj \ $(OBJS)\corelib_busyinfo.obj \ $(OBJS)\corelib_buttonbar.obj \ @@ -6963,6 +6971,11 @@ $(OBJS)\monodll_wincmn.obj: ..\..\src\common\wincmn.cpp $(CXX) -q -c -P -o$@ $(MONODLL_CXXFLAGS) $** !endif +!if "$(USE_GUI)" == "1" +$(OBJS)\monodll_windowid.obj: ..\..\src\common\windowid.cpp + $(CXX) -q -c -P -o$@ $(MONODLL_CXXFLAGS) $** +!endif + !if "$(USE_GUI)" == "1" $(OBJS)\monodll_xpmdecod.obj: ..\..\src\common\xpmdecod.cpp $(CXX) -q -c -P -o$@ $(MONODLL_CXXFLAGS) $** @@ -9061,6 +9074,11 @@ $(OBJS)\monolib_wincmn.obj: ..\..\src\common\wincmn.cpp $(CXX) -q -c -P -o$@ $(MONOLIB_CXXFLAGS) $** !endif +!if "$(USE_GUI)" == "1" +$(OBJS)\monolib_windowid.obj: ..\..\src\common\windowid.cpp + $(CXX) -q -c -P -o$@ $(MONOLIB_CXXFLAGS) $** +!endif + !if "$(USE_GUI)" == "1" $(OBJS)\monolib_xpmdecod.obj: ..\..\src\common\xpmdecod.cpp $(CXX) -q -c -P -o$@ $(MONOLIB_CXXFLAGS) $** @@ -11216,6 +11234,11 @@ $(OBJS)\coredll_wincmn.obj: ..\..\src\common\wincmn.cpp $(CXX) -q -c -P -o$@ $(COREDLL_CXXFLAGS) $** !endif +!if "$(USE_GUI)" == "1" +$(OBJS)\coredll_windowid.obj: ..\..\src\common\windowid.cpp + $(CXX) -q -c -P -o$@ $(COREDLL_CXXFLAGS) $** +!endif + !if "$(USE_GUI)" == "1" $(OBJS)\coredll_xpmdecod.obj: ..\..\src\common\xpmdecod.cpp $(CXX) -q -c -P -o$@ $(COREDLL_CXXFLAGS) $** @@ -12522,6 +12545,11 @@ $(OBJS)\corelib_wincmn.obj: ..\..\src\common\wincmn.cpp $(CXX) -q -c -P -o$@ $(CORELIB_CXXFLAGS) $** !endif +!if "$(USE_GUI)" == "1" +$(OBJS)\corelib_windowid.obj: ..\..\src\common\windowid.cpp + $(CXX) -q -c -P -o$@ $(CORELIB_CXXFLAGS) $** +!endif + !if "$(USE_GUI)" == "1" $(OBJS)\corelib_xpmdecod.obj: ..\..\src\common\xpmdecod.cpp $(CXX) -q -c -P -o$@ $(CORELIB_CXXFLAGS) $** diff --git a/build/msw/makefile.gcc b/build/msw/makefile.gcc index f55a560f9d..813b9354ea 100644 --- a/build/msw/makefile.gcc +++ b/build/msw/makefile.gcc @@ -1681,6 +1681,7 @@ ____CORE_SRC_FILENAMES_OBJECTS = \ $(OBJS)\monodll_validate.o \ $(OBJS)\monodll_valtext.o \ $(OBJS)\monodll_wincmn.o \ + $(OBJS)\monodll_windowid.o \ $(OBJS)\monodll_xpmdecod.o \ $(OBJS)\monodll_busyinfo.o \ $(OBJS)\monodll_buttonbar.o \ @@ -1913,6 +1914,7 @@ ____CORE_SRC_FILENAMES_OBJECTS = \ $(OBJS)\monodll_validate.o \ $(OBJS)\monodll_valtext.o \ $(OBJS)\monodll_wincmn.o \ + $(OBJS)\monodll_windowid.o \ $(OBJS)\monodll_xpmdecod.o \ $(OBJS)\monodll_busyinfo.o \ $(OBJS)\monodll_buttonbar.o \ @@ -2328,6 +2330,7 @@ ____CORE_SRC_FILENAMES_1_OBJECTS = \ $(OBJS)\monolib_validate.o \ $(OBJS)\monolib_valtext.o \ $(OBJS)\monolib_wincmn.o \ + $(OBJS)\monolib_windowid.o \ $(OBJS)\monolib_xpmdecod.o \ $(OBJS)\monolib_busyinfo.o \ $(OBJS)\monolib_buttonbar.o \ @@ -2560,6 +2563,7 @@ ____CORE_SRC_FILENAMES_1_OBJECTS = \ $(OBJS)\monolib_validate.o \ $(OBJS)\monolib_valtext.o \ $(OBJS)\monolib_wincmn.o \ + $(OBJS)\monolib_windowid.o \ $(OBJS)\monolib_xpmdecod.o \ $(OBJS)\monolib_busyinfo.o \ $(OBJS)\monolib_buttonbar.o \ @@ -2900,6 +2904,7 @@ ____CORE_SRC_FILENAMES_2_OBJECTS = \ $(OBJS)\coredll_validate.o \ $(OBJS)\coredll_valtext.o \ $(OBJS)\coredll_wincmn.o \ + $(OBJS)\coredll_windowid.o \ $(OBJS)\coredll_xpmdecod.o \ $(OBJS)\coredll_busyinfo.o \ $(OBJS)\coredll_buttonbar.o \ @@ -3132,6 +3137,7 @@ ____CORE_SRC_FILENAMES_2_OBJECTS = \ $(OBJS)\coredll_validate.o \ $(OBJS)\coredll_valtext.o \ $(OBJS)\coredll_wincmn.o \ + $(OBJS)\coredll_windowid.o \ $(OBJS)\coredll_xpmdecod.o \ $(OBJS)\coredll_busyinfo.o \ $(OBJS)\coredll_buttonbar.o \ @@ -3370,6 +3376,7 @@ ____CORE_SRC_FILENAMES_3_OBJECTS = \ $(OBJS)\corelib_validate.o \ $(OBJS)\corelib_valtext.o \ $(OBJS)\corelib_wincmn.o \ + $(OBJS)\corelib_windowid.o \ $(OBJS)\corelib_xpmdecod.o \ $(OBJS)\corelib_busyinfo.o \ $(OBJS)\corelib_buttonbar.o \ @@ -3602,6 +3609,7 @@ ____CORE_SRC_FILENAMES_3_OBJECTS = \ $(OBJS)\corelib_validate.o \ $(OBJS)\corelib_valtext.o \ $(OBJS)\corelib_wincmn.o \ + $(OBJS)\corelib_windowid.o \ $(OBJS)\corelib_xpmdecod.o \ $(OBJS)\corelib_busyinfo.o \ $(OBJS)\corelib_buttonbar.o \ @@ -7203,6 +7211,11 @@ $(OBJS)\monodll_wincmn.o: ../../src/common/wincmn.cpp $(CXX) -c -o $@ $(MONODLL_CXXFLAGS) $(CPPDEPS) $< endif +ifeq ($(USE_GUI),1) +$(OBJS)\monodll_windowid.o: ../../src/common/windowid.cpp + $(CXX) -c -o $@ $(MONODLL_CXXFLAGS) $(CPPDEPS) $< +endif + ifeq ($(USE_GUI),1) $(OBJS)\monodll_xpmdecod.o: ../../src/common/xpmdecod.cpp $(CXX) -c -o $@ $(MONODLL_CXXFLAGS) $(CPPDEPS) $< @@ -9403,6 +9416,11 @@ $(OBJS)\monolib_wincmn.o: ../../src/common/wincmn.cpp $(CXX) -c -o $@ $(MONOLIB_CXXFLAGS) $(CPPDEPS) $< endif +ifeq ($(USE_GUI),1) +$(OBJS)\monolib_windowid.o: ../../src/common/windowid.cpp + $(CXX) -c -o $@ $(MONOLIB_CXXFLAGS) $(CPPDEPS) $< +endif + ifeq ($(USE_GUI),1) $(OBJS)\monolib_xpmdecod.o: ../../src/common/xpmdecod.cpp $(CXX) -c -o $@ $(MONOLIB_CXXFLAGS) $(CPPDEPS) $< @@ -11660,6 +11678,11 @@ $(OBJS)\coredll_wincmn.o: ../../src/common/wincmn.cpp $(CXX) -c -o $@ $(COREDLL_CXXFLAGS) $(CPPDEPS) $< endif +ifeq ($(USE_GUI),1) +$(OBJS)\coredll_windowid.o: ../../src/common/windowid.cpp + $(CXX) -c -o $@ $(COREDLL_CXXFLAGS) $(CPPDEPS) $< +endif + ifeq ($(USE_GUI),1) $(OBJS)\coredll_xpmdecod.o: ../../src/common/xpmdecod.cpp $(CXX) -c -o $@ $(COREDLL_CXXFLAGS) $(CPPDEPS) $< @@ -13066,6 +13089,11 @@ $(OBJS)\corelib_wincmn.o: ../../src/common/wincmn.cpp $(CXX) -c -o $@ $(CORELIB_CXXFLAGS) $(CPPDEPS) $< endif +ifeq ($(USE_GUI),1) +$(OBJS)\corelib_windowid.o: ../../src/common/windowid.cpp + $(CXX) -c -o $@ $(CORELIB_CXXFLAGS) $(CPPDEPS) $< +endif + ifeq ($(USE_GUI),1) $(OBJS)\corelib_xpmdecod.o: ../../src/common/xpmdecod.cpp $(CXX) -c -o $@ $(CORELIB_CXXFLAGS) $(CPPDEPS) $< diff --git a/build/msw/makefile.vc b/build/msw/makefile.vc index 9947a93a22..0306891d63 100644 --- a/build/msw/makefile.vc +++ b/build/msw/makefile.vc @@ -1840,6 +1840,7 @@ ____CORE_SRC_FILENAMES_OBJECTS = \ $(OBJS)\monodll_validate.obj \ $(OBJS)\monodll_valtext.obj \ $(OBJS)\monodll_wincmn.obj \ + $(OBJS)\monodll_windowid.obj \ $(OBJS)\monodll_xpmdecod.obj \ $(OBJS)\monodll_busyinfo.obj \ $(OBJS)\monodll_buttonbar.obj \ @@ -2070,6 +2071,7 @@ ____CORE_SRC_FILENAMES_OBJECTS = \ $(OBJS)\monodll_validate.obj \ $(OBJS)\monodll_valtext.obj \ $(OBJS)\monodll_wincmn.obj \ + $(OBJS)\monodll_windowid.obj \ $(OBJS)\monodll_xpmdecod.obj \ $(OBJS)\monodll_busyinfo.obj \ $(OBJS)\monodll_buttonbar.obj \ @@ -2487,6 +2489,7 @@ ____CORE_SRC_FILENAMES_1_OBJECTS = \ $(OBJS)\monolib_validate.obj \ $(OBJS)\monolib_valtext.obj \ $(OBJS)\monolib_wincmn.obj \ + $(OBJS)\monolib_windowid.obj \ $(OBJS)\monolib_xpmdecod.obj \ $(OBJS)\monolib_busyinfo.obj \ $(OBJS)\monolib_buttonbar.obj \ @@ -2717,6 +2720,7 @@ ____CORE_SRC_FILENAMES_1_OBJECTS = \ $(OBJS)\monolib_validate.obj \ $(OBJS)\monolib_valtext.obj \ $(OBJS)\monolib_wincmn.obj \ + $(OBJS)\monolib_windowid.obj \ $(OBJS)\monolib_xpmdecod.obj \ $(OBJS)\monolib_busyinfo.obj \ $(OBJS)\monolib_buttonbar.obj \ @@ -3073,6 +3077,7 @@ ____CORE_SRC_FILENAMES_2_OBJECTS = \ $(OBJS)\coredll_validate.obj \ $(OBJS)\coredll_valtext.obj \ $(OBJS)\coredll_wincmn.obj \ + $(OBJS)\coredll_windowid.obj \ $(OBJS)\coredll_xpmdecod.obj \ $(OBJS)\coredll_busyinfo.obj \ $(OBJS)\coredll_buttonbar.obj \ @@ -3303,6 +3308,7 @@ ____CORE_SRC_FILENAMES_2_OBJECTS = \ $(OBJS)\coredll_validate.obj \ $(OBJS)\coredll_valtext.obj \ $(OBJS)\coredll_wincmn.obj \ + $(OBJS)\coredll_windowid.obj \ $(OBJS)\coredll_xpmdecod.obj \ $(OBJS)\coredll_busyinfo.obj \ $(OBJS)\coredll_buttonbar.obj \ @@ -3541,6 +3547,7 @@ ____CORE_SRC_FILENAMES_3_OBJECTS = \ $(OBJS)\corelib_validate.obj \ $(OBJS)\corelib_valtext.obj \ $(OBJS)\corelib_wincmn.obj \ + $(OBJS)\corelib_windowid.obj \ $(OBJS)\corelib_xpmdecod.obj \ $(OBJS)\corelib_busyinfo.obj \ $(OBJS)\corelib_buttonbar.obj \ @@ -3771,6 +3778,7 @@ ____CORE_SRC_FILENAMES_3_OBJECTS = \ $(OBJS)\corelib_validate.obj \ $(OBJS)\corelib_valtext.obj \ $(OBJS)\corelib_wincmn.obj \ + $(OBJS)\corelib_windowid.obj \ $(OBJS)\corelib_xpmdecod.obj \ $(OBJS)\corelib_busyinfo.obj \ $(OBJS)\corelib_buttonbar.obj \ @@ -7295,6 +7303,11 @@ $(OBJS)\monodll_wincmn.obj: ..\..\src\common\wincmn.cpp $(CXX) /c /nologo /TP /Fo$@ $(MONODLL_CXXFLAGS) $** !endif +!if "$(USE_GUI)" == "1" +$(OBJS)\monodll_windowid.obj: ..\..\src\common\windowid.cpp + $(CXX) /c /nologo /TP /Fo$@ $(MONODLL_CXXFLAGS) $** +!endif + !if "$(USE_GUI)" == "1" $(OBJS)\monodll_xpmdecod.obj: ..\..\src\common\xpmdecod.cpp $(CXX) /c /nologo /TP /Fo$@ $(MONODLL_CXXFLAGS) $** @@ -9393,6 +9406,11 @@ $(OBJS)\monolib_wincmn.obj: ..\..\src\common\wincmn.cpp $(CXX) /c /nologo /TP /Fo$@ $(MONOLIB_CXXFLAGS) $** !endif +!if "$(USE_GUI)" == "1" +$(OBJS)\monolib_windowid.obj: ..\..\src\common\windowid.cpp + $(CXX) /c /nologo /TP /Fo$@ $(MONOLIB_CXXFLAGS) $** +!endif + !if "$(USE_GUI)" == "1" $(OBJS)\monolib_xpmdecod.obj: ..\..\src\common\xpmdecod.cpp $(CXX) /c /nologo /TP /Fo$@ $(MONOLIB_CXXFLAGS) $** @@ -11548,6 +11566,11 @@ $(OBJS)\coredll_wincmn.obj: ..\..\src\common\wincmn.cpp $(CXX) /c /nologo /TP /Fo$@ $(COREDLL_CXXFLAGS) $** !endif +!if "$(USE_GUI)" == "1" +$(OBJS)\coredll_windowid.obj: ..\..\src\common\windowid.cpp + $(CXX) /c /nologo /TP /Fo$@ $(COREDLL_CXXFLAGS) $** +!endif + !if "$(USE_GUI)" == "1" $(OBJS)\coredll_xpmdecod.obj: ..\..\src\common\xpmdecod.cpp $(CXX) /c /nologo /TP /Fo$@ $(COREDLL_CXXFLAGS) $** @@ -12854,6 +12877,11 @@ $(OBJS)\corelib_wincmn.obj: ..\..\src\common\wincmn.cpp $(CXX) /c /nologo /TP /Fo$@ $(CORELIB_CXXFLAGS) $** !endif +!if "$(USE_GUI)" == "1" +$(OBJS)\corelib_windowid.obj: ..\..\src\common\windowid.cpp + $(CXX) /c /nologo /TP /Fo$@ $(CORELIB_CXXFLAGS) $** +!endif + !if "$(USE_GUI)" == "1" $(OBJS)\corelib_xpmdecod.obj: ..\..\src\common\xpmdecod.cpp $(CXX) /c /nologo /TP /Fo$@ $(CORELIB_CXXFLAGS) $** diff --git a/build/msw/makefile.wat b/build/msw/makefile.wat index b14382546c..96fa1492f9 100644 --- a/build/msw/makefile.wat +++ b/build/msw/makefile.wat @@ -406,6 +406,7 @@ ____CORE_SRC_FILENAMES_OBJECTS = & $(OBJS)\monodll_validate.obj & $(OBJS)\monodll_valtext.obj & $(OBJS)\monodll_wincmn.obj & + $(OBJS)\monodll_windowid.obj & $(OBJS)\monodll_xpmdecod.obj & $(OBJS)\monodll_busyinfo.obj & $(OBJS)\monodll_buttonbar.obj & @@ -638,6 +639,7 @@ ____CORE_SRC_FILENAMES_OBJECTS = & $(OBJS)\monodll_validate.obj & $(OBJS)\monodll_valtext.obj & $(OBJS)\monodll_wincmn.obj & + $(OBJS)\monodll_windowid.obj & $(OBJS)\monodll_xpmdecod.obj & $(OBJS)\monodll_busyinfo.obj & $(OBJS)\monodll_buttonbar.obj & @@ -1058,6 +1060,7 @@ ____CORE_SRC_FILENAMES_1_OBJECTS = & $(OBJS)\monolib_validate.obj & $(OBJS)\monolib_valtext.obj & $(OBJS)\monolib_wincmn.obj & + $(OBJS)\monolib_windowid.obj & $(OBJS)\monolib_xpmdecod.obj & $(OBJS)\monolib_busyinfo.obj & $(OBJS)\monolib_buttonbar.obj & @@ -1290,6 +1293,7 @@ ____CORE_SRC_FILENAMES_1_OBJECTS = & $(OBJS)\monolib_validate.obj & $(OBJS)\monolib_valtext.obj & $(OBJS)\monolib_wincmn.obj & + $(OBJS)\monolib_windowid.obj & $(OBJS)\monolib_xpmdecod.obj & $(OBJS)\monolib_busyinfo.obj & $(OBJS)\monolib_buttonbar.obj & @@ -1641,6 +1645,7 @@ ____CORE_SRC_FILENAMES_2_OBJECTS = & $(OBJS)\coredll_validate.obj & $(OBJS)\coredll_valtext.obj & $(OBJS)\coredll_wincmn.obj & + $(OBJS)\coredll_windowid.obj & $(OBJS)\coredll_xpmdecod.obj & $(OBJS)\coredll_busyinfo.obj & $(OBJS)\coredll_buttonbar.obj & @@ -1873,6 +1878,7 @@ ____CORE_SRC_FILENAMES_2_OBJECTS = & $(OBJS)\coredll_validate.obj & $(OBJS)\coredll_valtext.obj & $(OBJS)\coredll_wincmn.obj & + $(OBJS)\coredll_windowid.obj & $(OBJS)\coredll_xpmdecod.obj & $(OBJS)\coredll_busyinfo.obj & $(OBJS)\coredll_buttonbar.obj & @@ -2113,6 +2119,7 @@ ____CORE_SRC_FILENAMES_3_OBJECTS = & $(OBJS)\corelib_validate.obj & $(OBJS)\corelib_valtext.obj & $(OBJS)\corelib_wincmn.obj & + $(OBJS)\corelib_windowid.obj & $(OBJS)\corelib_xpmdecod.obj & $(OBJS)\corelib_busyinfo.obj & $(OBJS)\corelib_buttonbar.obj & @@ -2345,6 +2352,7 @@ ____CORE_SRC_FILENAMES_3_OBJECTS = & $(OBJS)\corelib_validate.obj & $(OBJS)\corelib_valtext.obj & $(OBJS)\corelib_wincmn.obj & + $(OBJS)\corelib_windowid.obj & $(OBJS)\corelib_xpmdecod.obj & $(OBJS)\corelib_busyinfo.obj & $(OBJS)\corelib_buttonbar.obj & @@ -7437,6 +7445,11 @@ $(OBJS)\monodll_wincmn.obj : .AUTODEPEND ..\..\src\common\wincmn.cpp $(CXX) -bt=nt -zq -fo=$^@ $(MONODLL_CXXFLAGS) $< !endif +!ifeq USE_GUI 1 +$(OBJS)\monodll_windowid.obj : .AUTODEPEND ..\..\src\common\windowid.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(MONODLL_CXXFLAGS) $< +!endif + !ifeq USE_GUI 1 $(OBJS)\monodll_xpmdecod.obj : .AUTODEPEND ..\..\src\common\xpmdecod.cpp $(CXX) -bt=nt -zq -fo=$^@ $(MONODLL_CXXFLAGS) $< @@ -9637,6 +9650,11 @@ $(OBJS)\monolib_wincmn.obj : .AUTODEPEND ..\..\src\common\wincmn.cpp $(CXX) -bt=nt -zq -fo=$^@ $(MONOLIB_CXXFLAGS) $< !endif +!ifeq USE_GUI 1 +$(OBJS)\monolib_windowid.obj : .AUTODEPEND ..\..\src\common\windowid.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(MONOLIB_CXXFLAGS) $< +!endif + !ifeq USE_GUI 1 $(OBJS)\monolib_xpmdecod.obj : .AUTODEPEND ..\..\src\common\xpmdecod.cpp $(CXX) -bt=nt -zq -fo=$^@ $(MONOLIB_CXXFLAGS) $< @@ -11894,6 +11912,11 @@ $(OBJS)\coredll_wincmn.obj : .AUTODEPEND ..\..\src\common\wincmn.cpp $(CXX) -bt=nt -zq -fo=$^@ $(COREDLL_CXXFLAGS) $< !endif +!ifeq USE_GUI 1 +$(OBJS)\coredll_windowid.obj : .AUTODEPEND ..\..\src\common\windowid.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(COREDLL_CXXFLAGS) $< +!endif + !ifeq USE_GUI 1 $(OBJS)\coredll_xpmdecod.obj : .AUTODEPEND ..\..\src\common\xpmdecod.cpp $(CXX) -bt=nt -zq -fo=$^@ $(COREDLL_CXXFLAGS) $< @@ -13300,6 +13323,11 @@ $(OBJS)\corelib_wincmn.obj : .AUTODEPEND ..\..\src\common\wincmn.cpp $(CXX) -bt=nt -zq -fo=$^@ $(CORELIB_CXXFLAGS) $< !endif +!ifeq USE_GUI 1 +$(OBJS)\corelib_windowid.obj : .AUTODEPEND ..\..\src\common\windowid.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(CORELIB_CXXFLAGS) $< +!endif + !ifeq USE_GUI 1 $(OBJS)\corelib_xpmdecod.obj : .AUTODEPEND ..\..\src\common\xpmdecod.cpp $(CXX) -bt=nt -zq -fo=$^@ $(CORELIB_CXXFLAGS) $< diff --git a/build/msw/wx_core.dsp b/build/msw/wx_core.dsp index bc98429ace..b0e626871f 100644 --- a/build/msw/wx_core.dsp +++ b/build/msw/wx_core.dsp @@ -646,6 +646,10 @@ SOURCE=..\..\src\common\wincmn.cpp # End Source File # Begin Source File +SOURCE=..\..\src\common\windowid.cpp +# End Source File +# Begin Source File + SOURCE=..\..\src\common\xpmdecod.cpp # End Source File # End Group @@ -6376,6 +6380,10 @@ SOURCE=..\..\include\wx\window.h # End Source File # Begin Source File +SOURCE=..\..\include\wx\windowid.h +# End Source File +# Begin Source File + SOURCE=..\..\include\wx\wizard.h # End Source File # Begin Source File diff --git a/include/wx/defs.h b/include/wx/defs.h index 3c5ad72716..4d4b4bbf69 100644 --- a/include/wx/defs.h +++ b/include/wx/defs.h @@ -233,12 +233,6 @@ typedef short int WXTYPE; -/* special care should be taken with this type under Windows where the real */ -/* window id is unsigned, so we must always do the cast before comparing them */ -/* (or else they would be always different!). Using wxGetWindowId() which does */ -/* the cast itself is recommended. Note that this type can't be unsigned */ -/* because wxID_ANY == -1 is a valid (and largely used) value for window id. */ -typedef int wxWindowID; /* ---------------------------------------------------------------------------- */ /* other feature tests */ @@ -1782,8 +1776,19 @@ enum These ids delimit the range used by automatically-generated ids (i.e. those used when wxID_ANY is specified during construction). */ +#if defined(__WXMSW__) || wxUSE_AUTOID_MANAGEMENT + /* + On MSW the range is always restricted no matter if id management + is used or not because the native window ids are limited to short + range. On other platforms the range is only restricted if id + management is used so the reference count buffer won't be so big. + */ wxID_AUTO_LOWEST = -32000, wxID_AUTO_HIGHEST = -2000, +#else + wxID_AUTO_LOWEST = -1000000, + wxID_AUTO_HIGHEST = -2000, +#endif /* no id matches this one when compared to it */ wxID_NONE = -3, @@ -1919,6 +1924,19 @@ enum wxID_HIGHEST = 5999 }; +/* ---------------------------------------------------------------------------- */ +/* wxWindowID type (after wxID_XYZ enum, platform detection, and dlimpexp.h) */ +/* ---------------------------------------------------------------------------- */ + +/* special care should be taken with this type under Windows where the real */ +/* window id is unsigned, so we must always do the cast before comparing them */ +/* (or else they would be always different!). Using wxGetWindowId() which does */ +/* the cast itself is recommended. Note that this type can't be unsigned */ +/* because wxID_ANY == -1 is a valid (and largely used) value for window id. */ +#ifdef __cplusplus + #include "wx/windowid.h" +#endif + /* ---------------------------------------------------------------------------- */ /* other constants */ /* ---------------------------------------------------------------------------- */ diff --git a/include/wx/mac/setup0.h b/include/wx/mac/setup0.h index 1e5083e394..063106af0d 100644 --- a/include/wx/mac/setup0.h +++ b/include/wx/mac/setup0.h @@ -887,6 +887,16 @@ // wxValidator class and related methods #define wxUSE_VALIDATORS 1 +// Use reference counted ID management: this means that wxWidgets will track +// the automatically allocated ids (those used when you use wxID_ANY when +// creating a window, menu or toolbar item &c) instead of just supposing that +// the program never runs out of them. This is mostly useful only under wxMSW +// where the total ids range is limited to SHRT_MIN..SHRT_MAX and where +// long-running programs can run into problems with ids reuse without this. On +// the other platforms, where the ids have the full int range, this shouldn't +// be necessary. +#define wxUSE_AUTOID_MANAGEMENT defined(__WXMSW__) + // ---------------------------------------------------------------------------- // common dialogs // ---------------------------------------------------------------------------- diff --git a/include/wx/menuitem.h b/include/wx/menuitem.h index 55a6a3172f..f8cf44752a 100644 --- a/include/wx/menuitem.h +++ b/include/wx/menuitem.h @@ -145,7 +145,7 @@ public: } protected: - int m_id; // numeric id of the item >= 0 or wxID_ANY or wxID_SEPARATOR + wxWindowIDRef m_id; // numeric id of the item >= 0 or wxID_ANY or wxID_SEPARATOR wxMenu *m_parentMenu, // the menu we belong to *m_subMenu; // our sub menu or NULL wxString m_text, // label of the item diff --git a/include/wx/motif/setup0.h b/include/wx/motif/setup0.h index b9a5c9c6b0..4c6ad8d0e7 100644 --- a/include/wx/motif/setup0.h +++ b/include/wx/motif/setup0.h @@ -886,6 +886,16 @@ // wxValidator class and related methods #define wxUSE_VALIDATORS 1 +// Use reference counted ID management: this means that wxWidgets will track +// the automatically allocated ids (those used when you use wxID_ANY when +// creating a window, menu or toolbar item &c) instead of just supposing that +// the program never runs out of them. This is mostly useful only under wxMSW +// where the total ids range is limited to SHRT_MIN..SHRT_MAX and where +// long-running programs can run into problems with ids reuse without this. On +// the other platforms, where the ids have the full int range, this shouldn't +// be necessary. +#define wxUSE_AUTOID_MANAGEMENT defined(__WXMSW__) + // ---------------------------------------------------------------------------- // common dialogs // ---------------------------------------------------------------------------- diff --git a/include/wx/msw/radiobox.h b/include/wx/msw/radiobox.h index c4e5b280a3..6ff07ce3d9 100644 --- a/include/wx/msw/radiobox.h +++ b/include/wx/msw/radiobox.h @@ -158,6 +158,7 @@ protected: // the buttons we contain wxSubwindows *m_radioButtons; + wxWindowIDRef *m_radioButtonIds; // array of widths and heights of the buttons, may be wxDefaultCoord if the // corresponding quantity should be computed diff --git a/include/wx/msw/setup0.h b/include/wx/msw/setup0.h index d1527cfde0..17d09e4a58 100644 --- a/include/wx/msw/setup0.h +++ b/include/wx/msw/setup0.h @@ -886,6 +886,16 @@ // wxValidator class and related methods #define wxUSE_VALIDATORS 1 +// Use reference counted ID management: this means that wxWidgets will track +// the automatically allocated ids (those used when you use wxID_ANY when +// creating a window, menu or toolbar item &c) instead of just supposing that +// the program never runs out of them. This is mostly useful only under wxMSW +// where the total ids range is limited to SHRT_MIN..SHRT_MAX and where +// long-running programs can run into problems with ids reuse without this. On +// the other platforms, where the ids have the full int range, this shouldn't +// be necessary. +#define wxUSE_AUTOID_MANAGEMENT defined(__WXMSW__) + // ---------------------------------------------------------------------------- // common dialogs // ---------------------------------------------------------------------------- diff --git a/include/wx/msw/slider95.h b/include/wx/msw/slider95.h index 08cf96528a..02ae8699ee 100644 --- a/include/wx/msw/slider95.h +++ b/include/wx/msw/slider95.h @@ -117,7 +117,8 @@ protected: virtual wxSize DoGetBestSize() const; // the labels windows, if any - wxSubwindows *m_labels; + wxSubwindows *m_labels; + wxWindowIDRef *m_labelIds; int m_rangeMin; int m_rangeMax; diff --git a/include/wx/msw/wince/setup.h b/include/wx/msw/wince/setup.h index fb40f30a33..a7e365f3d6 100644 --- a/include/wx/msw/wince/setup.h +++ b/include/wx/msw/wince/setup.h @@ -886,6 +886,16 @@ // wxValidator class and related methods #define wxUSE_VALIDATORS 1 +// Use reference counted ID management: this means that wxWidgets will track +// the automatically allocated ids (those used when you use wxID_ANY when +// creating a window, menu or toolbar item &c) instead of just supposing that +// the program never runs out of them. This is mostly useful only under wxMSW +// where the total ids range is limited to SHRT_MIN..SHRT_MAX and where +// long-running programs can run into problems with ids reuse without this. On +// the other platforms, where the ids have the full int range, this shouldn't +// be necessary. +#define wxUSE_AUTOID_MANAGEMENT defined(__WXMSW__) + // ---------------------------------------------------------------------------- // common dialogs // ---------------------------------------------------------------------------- diff --git a/include/wx/os2/setup0.h b/include/wx/os2/setup0.h index be39d4b4fa..2099ba0fa1 100644 --- a/include/wx/os2/setup0.h +++ b/include/wx/os2/setup0.h @@ -886,6 +886,16 @@ // wxValidator class and related methods #define wxUSE_VALIDATORS 1 +// Use reference counted ID management: this means that wxWidgets will track +// the automatically allocated ids (those used when you use wxID_ANY when +// creating a window, menu or toolbar item &c) instead of just supposing that +// the program never runs out of them. This is mostly useful only under wxMSW +// where the total ids range is limited to SHRT_MIN..SHRT_MAX and where +// long-running programs can run into problems with ids reuse without this. On +// the other platforms, where the ids have the full int range, this shouldn't +// be necessary. +#define wxUSE_AUTOID_MANAGEMENT defined(__WXMSW__) + // ---------------------------------------------------------------------------- // common dialogs // ---------------------------------------------------------------------------- diff --git a/include/wx/palmos/setup0.h b/include/wx/palmos/setup0.h index 01ee5a4cf8..0988baa18d 100644 --- a/include/wx/palmos/setup0.h +++ b/include/wx/palmos/setup0.h @@ -886,6 +886,16 @@ // wxValidator class and related methods #define wxUSE_VALIDATORS 1 +// Use reference counted ID management: this means that wxWidgets will track +// the automatically allocated ids (those used when you use wxID_ANY when +// creating a window, menu or toolbar item &c) instead of just supposing that +// the program never runs out of them. This is mostly useful only under wxMSW +// where the total ids range is limited to SHRT_MIN..SHRT_MAX and where +// long-running programs can run into problems with ids reuse without this. On +// the other platforms, where the ids have the full int range, this shouldn't +// be necessary. +#define wxUSE_AUTOID_MANAGEMENT defined(__WXMSW__) + // ---------------------------------------------------------------------------- // common dialogs // ---------------------------------------------------------------------------- diff --git a/include/wx/setup_inc.h b/include/wx/setup_inc.h index 07ed994071..04f73575c2 100644 --- a/include/wx/setup_inc.h +++ b/include/wx/setup_inc.h @@ -882,6 +882,16 @@ // wxValidator class and related methods #define wxUSE_VALIDATORS 1 +// Use reference counted ID management: this means that wxWidgets will track +// the automatically allocated ids (those used when you use wxID_ANY when +// creating a window, menu or toolbar item &c) instead of just supposing that +// the program never runs out of them. This is mostly useful only under wxMSW +// where the total ids range is limited to SHRT_MIN..SHRT_MAX and where +// long-running programs can run into problems with ids reuse without this. On +// the other platforms, where the ids have the full int range, this shouldn't +// be necessary. +#define wxUSE_AUTOID_MANAGEMENT defined(__WXMSW__) + // ---------------------------------------------------------------------------- // common dialogs // ---------------------------------------------------------------------------- diff --git a/include/wx/tbarbase.h b/include/wx/tbarbase.h index 34928b79f6..0ff7c9373a 100644 --- a/include/wx/tbarbase.h +++ b/include/wx/tbarbase.h @@ -210,7 +210,7 @@ protected: // tool parameters int m_toolStyle; // see enum wxToolBarToolStyle - int m_id; // the tool id, wxID_SEPARATOR for separator + wxWindowIDRef m_id; // the tool id, wxID_SEPARATOR for separator wxItemKind m_kind; // for normal buttons may be wxITEM_NORMAL/CHECK/RADIO // as controls have their own client data, no need to waste memory diff --git a/include/wx/window.h b/include/wx/window.h index 4f5388aaa9..e1fb16519b 100644 --- a/include/wx/window.h +++ b/include/wx/window.h @@ -228,17 +228,21 @@ public: void SetId( wxWindowID winid ) { m_windowId = winid; } wxWindowID GetId() const { return m_windowId; } - // returns true if this id value belong to the range reserved for the - // auto-generated (by NewControlId()) ids (they're always negative) - static bool IsAutoGeneratedId(wxWindowID id); - // generate a unique id (or count of them consecutively), returns a - // valid id in IsAutoGeneratedId() range or wxID_NONE if failed - static wxWindowID NewControlId(int count = 1); + // valid id in the auto-id range or wxID_NONE if failed. If using + // autoid management, it will mark the id as reserved until it is + // used (by assigning it to a wxWindowIDRef) or unreserved. + static wxWindowID NewControlId(int count = 1) + { + return wxIdManager::ReserveId(count); + } - // mark an id previously returned by NewControlId() as being unused any - // more so that it can be reused again for another control later - static void ReleaseControlId(wxWindowID id); + // If an ID generated from NewControlId is not assigned to a wxWindowIDRef, + // it must be unreserved + static void UnreserveControlId(wxWindowID id, int count = 1) + { + wxIdManager::UnreserveId(id, count); + } // moving/resizing @@ -1356,7 +1360,7 @@ protected: // the window id - a number which uniquely identifies a window among // its siblings unless it is wxID_ANY - wxWindowID m_windowId; + wxWindowIDRef m_windowId; // the parent window of this window (or NULL) and the list of the children // of this window @@ -1425,10 +1429,6 @@ protected: // Layout() window automatically when its size changes? bool m_autoLayout:1; - // true if we had automatically allocated the id value for this window - // (i.e. wxID_ANY had been passed to the ctor) - bool m_freeId:1; - // window state bool m_isShown:1; bool m_isEnabled:1; @@ -1747,8 +1747,8 @@ WXDLLEXPORT wxWindow* wxGetTopLevelParent(wxWindow *win); #if WXWIN_COMPATIBILITY_2_6 // deprecated (doesn't start with 'wx' prefix), use wxWindow::NewControlId() - wxDEPRECATED( int NewControlId() ); - inline int NewControlId() { return wxWindowBase::NewControlId(); } + wxDEPRECATED( wxWindowID NewControlId() ); + inline wxWindowID NewControlId() { return wxWindowBase::NewControlId(); } #endif // WXWIN_COMPATIBILITY_2_6 #if wxUSE_ACCESSIBILITY diff --git a/include/wx/windowid.h b/include/wx/windowid.h new file mode 100644 index 0000000000..4b2e3e171c --- /dev/null +++ b/include/wx/windowid.h @@ -0,0 +1,189 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: wx/windowid.h +// Purpose: wxWindowID class - a class for managing window ids +// Author: Brian Vanderburg II +// Created: 2007-09-21 +// RCS-ID: $Id$ +// Copyright: (c) 2007 Brian Vanderburg II +// Licence: wxWindows licence +/////////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_WINDOWID_H_ +#define _WX_WINDOWID_H_ + +// NB: do not include defs.h as we are included from it + +typedef int wxWindowID; + +// ---------------------------------------------------------------------------- +// wxWindowIDRef: reference counted id value +// ---------------------------------------------------------------------------- + +// A wxWindowIDRef object wraps an id value and marks it as (un)used as +// necessary. All ids returned from wxWindow::NewControlId() should be assigned +// to an instance of this class to ensure that the id is marked as being in +// use. +// +// This class is always defined but it is trivial if wxUSE_AUTOID_MANAGEMENT is +// off. +class WXDLLIMPEXP_CORE wxWindowIDRef +{ +public: + // default ctor + wxWindowIDRef() + { + m_id = wxID_NONE; + } + + // ctor taking id values + wxWindowIDRef(int id) + { + Init(id); + } + + wxWindowIDRef(long id) + { + Init(id); + } + + wxWindowIDRef(const wxWindowIDRef& id) + { + Init(id.m_id); + } + + // dtor + ~wxWindowIDRef() + { + Assign(wxID_NONE); + } + + // assignment + wxWindowIDRef& operator=(int id) + { + Assign(id); + return *this; + } + + wxWindowIDRef& operator=(long id) + { + Assign(id); + return *this; + } + + wxWindowIDRef& operator=(const wxWindowIDRef& id) + { + Assign(id.m_id); + return *this; + } + + // access to the stored id value + wxWindowID GetValue() const + { + return m_id; + } + + operator wxWindowID() const + { + return m_id; + } + +private: +#if wxUSE_AUTOID_MANAGEMENT + // common part of all ctors: call Assign() for our new id + void Init(wxWindowID id) + { + // m_id must be initialized before calling Assign() + m_id = wxID_NONE; + Assign(id); + } + + // increase reference count of id, decrease the one of m_id + void Assign(wxWindowID id); +#else // !wxUSE_AUTOID_MANAGEMENT + // trivial stubs for the functions above + void Init(wxWindowID id) + { + m_id = id; + } + + void Assign(wxWindowID id) + { + m_id = id; + } +#endif // wxUSE_AUTOID_MANAGEMENT/!wxUSE_AUTOID_MANAGEMENT + + + wxWindowID m_id; +}; + +// comparison operators +inline bool operator==(const wxWindowIDRef& lhs, const wxWindowIDRef& rhs) +{ + return lhs.GetValue() == rhs.GetValue(); +} + +inline bool operator==(const wxWindowIDRef& lhs, int rhs) +{ + return lhs.GetValue() == rhs; +} + +inline bool operator==(const wxWindowIDRef& lhs, long rhs) +{ + return lhs.GetValue() == rhs; +} + +inline bool operator==(int lhs, const wxWindowIDRef& rhs) +{ + return rhs == lhs; +} + +inline bool operator==(long lhs, const wxWindowIDRef& rhs) +{ + return rhs == lhs; +} + +inline bool operator!=(const wxWindowIDRef& lhs, const wxWindowIDRef& rhs) +{ + return !(lhs == rhs); +} + +inline bool operator!=(const wxWindowIDRef& lhs, int rhs) +{ + return !(lhs == rhs); +} + +inline bool operator!=(const wxWindowIDRef& lhs, long rhs) +{ + return !(lhs == rhs); +} + +inline bool operator!=(int lhs, const wxWindowIDRef& rhs) +{ + return !(lhs == rhs); +} + +inline bool operator!=(long lhs, const wxWindowIDRef& rhs) +{ + return !(lhs == rhs); +} + +// ---------------------------------------------------------------------------- +// wxIdManager +// ---------------------------------------------------------------------------- + +class WXDLLIMPEXP_CORE wxIdManager +{ +public: + // This returns an id value and not an wxWindowIDRef. The returned value + // should be assigned a.s.a.p to a wxWindowIDRef. The IDs are marked as + // reserved so that another call to ReserveId before assigning the id to a + // wxWindowIDRef will not use the same ID + static wxWindowID ReserveId(int count = 1); + + // This will release an unused reserved ID. This should only be called + // if the ID returned by ReserveId was NOT assigned to a wxWindowIDRef + // for some purpose, maybe an early return from a function + static void UnreserveId(wxWindowID id, int count = 1); +}; + +#endif // _WX_WINDOWID_H_ diff --git a/setup.h.in b/setup.h.in index 1443a641c4..e7defed624 100644 --- a/setup.h.in +++ b/setup.h.in @@ -409,6 +409,8 @@ #define wxUSE_VALIDATORS 0 +#define wxUSE_AUTOID_MANAGEMENT defined(__WXMSW__) + #define wxUSE_COMMON_DIALOGS 0 diff --git a/src/common/wincmn.cpp b/src/common/wincmn.cpp index 393f781207..477c4d8c9d 100644 --- a/src/common/wincmn.cpp +++ b/src/common/wincmn.cpp @@ -173,7 +173,6 @@ wxWindowBase::wxWindowBase() m_windowSizer = (wxSizer *) NULL; m_containingSizer = (wxSizer *) NULL; m_autoLayout = false; - m_freeId = false; #if wxUSE_DRAG_AND_DROP m_dropTarget = (wxDropTarget *)NULL; @@ -247,9 +246,6 @@ bool wxWindowBase::CreateBase(wxWindowBase *parent, if ( id == wxID_ANY ) { m_windowId = NewControlId(); - - // remember to call ReleaseControlId() when this window is destroyed - m_freeId = true; } else // valid id specified { @@ -310,10 +306,6 @@ wxWindowBase::~wxWindowBase() { wxASSERT_MSG( GetCapture() != this, wxT("attempt to destroy window with mouse capture") ); - // mark the id as unused if we allocated it for this control - if ( m_freeId ) - ReleaseControlId(m_windowId); - // FIXME if these 2 cases result from programming errors in the user code // we should probably assert here instead of silently fixing them @@ -3195,125 +3187,4 @@ wxWindowBase::AdjustForLayoutDirection(wxCoord x, return x; } -// ---------------------------------------------------------------------------- -// Window (and menu items) identifiers management -// ---------------------------------------------------------------------------- - -namespace -{ - -// this array contains, in packed form, the "in use" flags for the entire -// auto-generated ids range: N-th element of the array contains the flags for -// ids in [wxID_AUTO_LOWEST + 8*N, wxID_AUTO_LOWEST + 8*N + 7] range -// -// initially no ids are in use and we allocate them consecutively, but after we -// exhaust the entire range, we wrap around and reuse the ids freed in the -// meanwhile -wxByte gs_autoIdsInUse[(wxID_AUTO_HIGHEST - wxID_AUTO_LOWEST + 1)/8 + 1] = { 0 }; - -// this is an optimization used until we wrap around wxID_AUTO_HIGHEST: if this -// value is < wxID_AUTO_HIGHEST we know that we haven't wrapped yet and so can -// allocate the ids simply by incrementing it -static wxWindowID gs_nextControlId = wxID_AUTO_LOWEST; - -void MarkAutoIdUsed(wxWindowID id) -{ - id -= wxID_AUTO_LOWEST; - - const int theByte = id / 8; - const int theBit = id % 8; - - gs_autoIdsInUse[theByte] |= 1 << theBit; -} - -void FreeAutoId(wxWindowID id) -{ - id -= wxID_AUTO_LOWEST; - - const int theByte = id / 8; - const int theBit = id % 8; - - gs_autoIdsInUse[theByte] &= ~(1 << theBit); -} - -bool IsAutoIdInUse(wxWindowID id) -{ - id -= wxID_AUTO_LOWEST; - - const int theByte = id / 8; - const int theBit = id % 8; - - return (gs_autoIdsInUse[theByte] & (1 << theBit)) != 0; -} - -} // anonymous namespace - - -/* static */ -bool wxWindowBase::IsAutoGeneratedId(wxWindowID id) -{ - if ( id < wxID_AUTO_LOWEST || id > wxID_AUTO_HIGHEST ) - return false; - - // we shouldn't have any stray ids in this range - wxASSERT_MSG( IsAutoIdInUse(id), "unused automatically generated id?" ); - - return true; -} - -wxWindowID wxWindowBase::NewControlId(int count) -{ - wxASSERT_MSG( count > 0, "can't allocate less than 1 id" ); - - if ( gs_nextControlId + count - 1 <= wxID_AUTO_HIGHEST ) - { - // we haven't wrapped yet, so we can just grab the next count ids - wxWindowID id = gs_nextControlId; - - while ( count-- ) - MarkAutoIdUsed(gs_nextControlId++); - - return id; - } - else // we've already wrapped or are now going to - { - // brute-force search for the id values - - // number of consecutive free ids found so far - int found = 0; - - for ( wxWindowID id = wxID_AUTO_LOWEST; id <= wxID_AUTO_HIGHEST; id++ ) - { - if ( !IsAutoIdInUse(id) ) - { - // found another consecutive available id - found++; - if ( found == count ) - { - // mark all count consecutive free ids we found as being in - // use now and rewind back to the start of available range - // in the process - while ( count-- ) - MarkAutoIdUsed(id--); - - return id; - } - } - else // this id is in use - { - // reset the number of consecutive free values found - found = 0; - } - } - } - - // if we get here, there are not enough consecutive free ids - return wxID_NONE; -} - -void wxWindowBase::ReleaseControlId(wxWindowID id) -{ - wxCHECK_RET( IsAutoGeneratedId(id), "can't release non auto-generated id" ); - FreeAutoId(id); -} diff --git a/src/common/windowid.cpp b/src/common/windowid.cpp new file mode 100644 index 0000000000..aace85973c --- /dev/null +++ b/src/common/windowid.cpp @@ -0,0 +1,256 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: src/common/windowid.cpp +// Purpose: wxWindowID class - a class for managing window ids +// Author: Brian Vanderburg II +// Created: 2007-09-21 +// RCS-ID: $Id$ +// Copyright: (c) 2007 Brian Vanderburg II +// Licence: wxWindows licence +/////////////////////////////////////////////////////////////////////////////// + +// ---------------------------------------------------------------------------- +// Needed headers +// ---------------------------------------------------------------------------- +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#ifndef WX_PRECOMP + #include "wx/log.h" + #include "wx/intl.h" +#endif //WX_PRECOMP + +// Not needed, included in defs.h +// #include "wx/windowid.h" + +#define wxTRACE_WINDOWID _T("windowid") + +namespace +{ + +#if wxUSE_AUTOID_MANAGEMENT + + +// initially no ids are in use and we allocate them consecutively, but after we +// exhaust the entire range, we wrap around and reuse the ids freed in the +// meanwhile +static const wxUint8 ID_FREE = 0; +static const wxUint8 ID_STARTCOUNT = 1; +static const wxUint8 ID_MAXCOUNT = 254; +static const wxUint8 ID_RESERVED = 255; + +wxUint8 gs_autoIdsRefCount[wxID_AUTO_HIGHEST - wxID_AUTO_LOWEST + 1] = { 0 }; + +// this is an optimization used until we wrap around wxID_AUTO_HIGHEST: if this +// value is < wxID_AUTO_HIGHEST we know that we haven't wrapped yet and so can +// allocate the ids simply by incrementing it +wxWindowID gs_nextAutoId = wxID_AUTO_LOWEST; + +// Reserve an ID +void ReserveIdRefCount(wxWindowID id) +{ + wxCHECK_RET(id >= wxID_AUTO_LOWEST && id <= wxID_AUTO_HIGHEST, + wxT("invalid id range")); + + id -= wxID_AUTO_LOWEST; + + wxCHECK_RET(gs_autoIdsRefCount[id] == ID_FREE, + wxT("id already in use or already reserved")); + gs_autoIdsRefCount[id] = ID_RESERVED; +} + +// Unreserve and id +void UnreserveIdRefCount(wxWindowID id) +{ + wxCHECK_RET(id >= wxID_AUTO_LOWEST && id <= wxID_AUTO_HIGHEST, + wxT("invalid id range")); + + id -= wxID_AUTO_LOWEST; + + wxCHECK_RET(gs_autoIdsRefCount[id] == ID_RESERVED, + wxT("id already in use or not reserved")); + gs_autoIdsRefCount[id] = ID_FREE; +} + +// Get the usage count of an id +int GetIdRefCount(wxWindowID id) +{ + wxCHECK_MSG(id >= wxID_AUTO_LOWEST && id <= wxID_AUTO_HIGHEST, 0, + wxT("invalid id range")); + + id -= wxID_AUTO_LOWEST; + return gs_autoIdsRefCount[id]; +} + +// Increase the count for an id +void IncIdRefCount(wxWindowID id) +{ + wxCHECK_RET(id >= wxID_AUTO_LOWEST && id <= wxID_AUTO_HIGHEST, + wxT("invalid id range")); + + id -= wxID_AUTO_LOWEST; + + wxCHECK_RET(gs_autoIdsRefCount[id] != ID_MAXCOUNT, wxT("id count at max")); + wxCHECK_RET(gs_autoIdsRefCount[id] != ID_FREE, wxT("id should first be reserved")); + + if(gs_autoIdsRefCount[id] == ID_RESERVED) + gs_autoIdsRefCount[id] = ID_STARTCOUNT; + else + gs_autoIdsRefCount[id]++; + + wxLogTrace(wxTRACE_WINDOWID, wxT("Increasing ref count of ID %d to %d"), + id + wxID_AUTO_LOWEST, gs_autoIdsRefCount[id]); +} + +// Decrease the count for an id +void DecIdRefCount(wxWindowID id) +{ + wxCHECK_RET(id >= wxID_AUTO_LOWEST && id <= wxID_AUTO_HIGHEST, + wxT("invalid id range")); + + id -= wxID_AUTO_LOWEST; + + wxCHECK_RET(gs_autoIdsRefCount[id] != ID_FREE, wxT("id count already 0")); + + // DecIdRefCount is only called on an ID that has been IncIdRefCount'ed' + // so it should never be reserved, but test anyway + if(gs_autoIdsRefCount[id] == ID_RESERVED) + { + wxASSERT_MSG(false, wxT("reserve id being decreased")); + gs_autoIdsRefCount[id] = ID_FREE; + } + else + gs_autoIdsRefCount[id]--; + + wxLogTrace(wxTRACE_WINDOWID, wxT("Decreasing ref count of ID %d to %d"), + id + wxID_AUTO_LOWEST, gs_autoIdsRefCount[id]); +} + +#else // wxUSE_AUTOID_MANAGEMENT + +static wxWindowID gs_nextAutoId = wxID_AUTO_HIGHEST; + +#endif + +} // anonymous namespace + + +#if wxUSE_AUTOID_MANAGEMENT + +void wxWindowIDRef::Assign(wxWindowID id) +{ + if ( id != m_id ) + { + // decrease count if it is in the managed range + if ( m_id >= wxID_AUTO_LOWEST && m_id <= wxID_AUTO_HIGHEST ) + DecIdRefCount(m_id); + + m_id = id; + + // increase count if it is in the managed range + if ( m_id >= wxID_AUTO_LOWEST && m_id <= wxID_AUTO_HIGHEST ) + IncIdRefCount(m_id); + } +} + +#endif // wxUSE_AUTOID_MANAGEMENT + + + +wxWindowID wxIdManager::ReserveId(int count) +{ + wxASSERT_MSG(count > 0, wxT("can't allocate less than 1 id")); + + +#if wxUSE_AUTOID_MANAGEMENT + if ( gs_nextAutoId + count - 1 <= wxID_AUTO_HIGHEST ) + { + wxWindowID id = gs_nextAutoId; + + while(count--) + { + ReserveIdRefCount(gs_nextAutoId++); + } + + return id; + } + else + { + int found = 0; + + for(wxWindowID id = wxID_AUTO_LOWEST; id <= wxID_AUTO_HIGHEST; id++) + { + if(GetIdRefCount(id) == 0) + { + found++; + if(found == count) + { + // Imagine this: 100 free IDs left. Then NewId(50) takes 50 + // so 50 left. Then, the 25 before that last 50 are freed, but + // gs_nextAutoId does not decrement and stays where it is at + // with 50 free. Then NewId(75) gets called, and since there + // are only 50 left according to gs_nextAutoId, it does a + // search and finds the 75 at the end. Then NewId(10) gets + // called, and accorind to gs_nextAutoId, their are still + // 50 at the end so it returns them without testing the ref + // To fix this, the next ID is also updated here as needed + if(id >= gs_nextAutoId) + gs_nextAutoId = id + 1; + + while(count--) + ReserveIdRefCount(id--); + + return id; + } + } + else + { + found = 0; + } + } + } + + ::wxLogError(_("Out of window IDs. Recommend shutting down application.")); + return wxID_NONE; +#else // !wxUSE_AUTOID_MANAGEMENT + // Make sure enough in the range + wxWindowID id; + + id = gs_nextAutoId - count + 1; + + if ( id >= wxID_AUTO_LOWEST && id <= wxID_AUTO_HIGHEST ) + { + // There is enough, but it may be time to wrap + if(id == wxID_AUTO_LOWEST) + gs_nextAutoId = wxID_AUTO_HIGHEST; + else + gs_nextAutoId = id - 1; + + return id; + } + else + { + // There is not enough at the low end of the range or + // count was big enough to wrap around to the positive + // Surely 'count' is not so big to take up much of the range + gs_nextAutoId = wxID_AUTO_HIGHEST - count; + return gs_nextAutoId + 1; + } +#endif // wxUSE_AUTOID_MANAGEMENT/!wxUSE_AUTOID_MANAGEMENT +} + +void wxIdManager::UnreserveId(wxWindowID id, int count) +{ + wxASSERT_MSG(count > 0, wxT("can't unreserve less than 1 id")); + +#if wxUSE_AUTOID_MANAGEMENT + while (count--) + UnreserveIdRefCount(id++); +#else + wxUnusedVar(id); + wxUnusedVar(count); +#endif +} + diff --git a/src/generic/editlbox.cpp b/src/generic/editlbox.cpp index 26512e0735..c1970a993a 100644 --- a/src/generic/editlbox.cpp +++ b/src/generic/editlbox.cpp @@ -197,12 +197,12 @@ IMPLEMENT_CLASS(wxEditableListBox, wxPanel) // NB: generate the IDs at runtime to avoid conflict with XRCID values, // they could cause XRCCTRL() failures in XRC-based dialogs -const int wxID_ELB_DELETE = wxWindow::NewControlId(); -const int wxID_ELB_EDIT = wxWindow::NewControlId(); -const int wxID_ELB_NEW = wxWindow::NewControlId(); -const int wxID_ELB_UP = wxWindow::NewControlId(); -const int wxID_ELB_DOWN = wxWindow::NewControlId(); -const int wxID_ELB_LISTCTRL = wxWindow::NewControlId(); +const wxWindowIDRef wxID_ELB_DELETE = wxWindow::NewControlId(); +const wxWindowIDRef wxID_ELB_EDIT = wxWindow::NewControlId(); +const wxWindowIDRef wxID_ELB_NEW = wxWindow::NewControlId(); +const wxWindowIDRef wxID_ELB_UP = wxWindow::NewControlId(); +const wxWindowIDRef wxID_ELB_DOWN = wxWindow::NewControlId(); +const wxWindowIDRef wxID_ELB_LISTCTRL = wxWindow::NewControlId(); BEGIN_EVENT_TABLE(wxEditableListBox, wxPanel) EVT_LIST_ITEM_SELECTED(wxID_ELB_LISTCTRL, wxEditableListBox::OnItemSelected) diff --git a/src/msw/bmpbuttn.cpp b/src/msw/bmpbuttn.cpp index 333ab7a25b..7039eb149e 100644 --- a/src/msw/bmpbuttn.cpp +++ b/src/msw/bmpbuttn.cpp @@ -175,7 +175,7 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, msStyle, 0, 0, 0, 0, GetWinHwnd(parent), - (HMENU)m_windowId, + (HMENU)m_windowId.GetValue(), wxGetInstance(), NULL ); diff --git a/src/msw/mdi.cpp b/src/msw/mdi.cpp index 6300654e8f..e4f5961386 100644 --- a/src/msw/mdi.cpp +++ b/src/msw/mdi.cpp @@ -694,7 +694,7 @@ bool wxMDIChildFrame::Create(wxMDIParentFrame *parent, if ( id != wxID_ANY ) m_windowId = id; else - m_windowId = (int)NewControlId(); + m_windowId = NewControlId(); if ( parent ) { diff --git a/src/msw/radiobox.cpp b/src/msw/radiobox.cpp index b29e5eb3e2..7865639116 100644 --- a/src/msw/radiobox.cpp +++ b/src/msw/radiobox.cpp @@ -129,6 +129,7 @@ void wxRadioBox::Init() { m_selectedButton = wxNOT_FOUND; m_radioButtons = NULL; + m_radioButtonIds = NULL; m_radioWidth = NULL; m_radioHeight = NULL; } @@ -156,6 +157,7 @@ bool wxRadioBox::Create(wxWindow *parent, #endif // wxUSE_VALIDATORS/!wxUSE_VALIDATORS m_radioButtons = new wxSubwindows(n); + m_radioButtonIds = new wxWindowIDRef[n + 1]; m_radioWidth = new int[n]; m_radioHeight = new int[n]; @@ -167,14 +169,14 @@ bool wxRadioBox::Create(wxWindow *parent, if ( i == 0 ) styleBtn |= WS_GROUP; - long newId = NewControlId(); + m_radioButtonIds[i] = NewControlId(); HWND hwndBtn = ::CreateWindow(_T("BUTTON"), choices[i].wx_str(), styleBtn, 0, 0, 0, 0, // will be set in SetSize() GetHwndOf(parent), - (HMENU)newId, + (HMENU)(wxWindowID)m_radioButtonIds[i], wxGetInstance(), NULL); @@ -189,15 +191,17 @@ bool wxRadioBox::Create(wxWindow *parent, SubclassRadioButton((WXHWND)hwndBtn); - m_subControls.Add(newId); + m_subControls.Add(m_radioButtonIds[i]); } // Create a dummy radio control to end the group. + m_radioButtonIds[n] = NewControlId(); + (void)::CreateWindow(_T("BUTTON"), wxEmptyString, WS_GROUP | BS_AUTORADIOBUTTON | WS_CHILD, 0, 0, 0, 0, GetHwndOf(parent), - (HMENU)NewControlId(), wxGetInstance(), NULL); + (HMENU)(wxWindowID)m_radioButtonIds[n], wxGetInstance(), NULL); m_radioButtons->SetFont(GetFont()); @@ -237,6 +241,7 @@ wxRadioBox::~wxRadioBox() m_isBeingDeleted = true; delete m_radioButtons; + delete[] m_radioButtonIds; delete[] m_radioWidth; delete[] m_radioHeight; } diff --git a/src/msw/slider95.cpp b/src/msw/slider95.cpp index 3a0dbfb80e..159e0ddea3 100644 --- a/src/msw/slider95.cpp +++ b/src/msw/slider95.cpp @@ -135,6 +135,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxSlider, wxControl) void wxSlider::Init() { m_labels = NULL; + m_labelIds = NULL; m_pageSize = 1; m_lineSize = 1; @@ -204,10 +205,13 @@ wxSlider::Create(wxWindow *parent, if ( m_windowStyle & wxSL_LABELS ) { m_labels = new wxSubwindows(SliderLabel_Last); + m_labelIds = new wxWindowIDRef[SliderLabel_Last]; HWND hwndParent = GetHwndOf(parent); for ( size_t n = 0; n < SliderLabel_Last; n++ ) { + m_labelIds[n] = NewControlId(); + (*m_labels)[n] = ::CreateWindow ( wxT("STATIC"), @@ -215,7 +219,7 @@ wxSlider::Create(wxWindow *parent, WS_CHILD | WS_VISIBLE | SS_CENTER, 0, 0, 0, 0, hwndParent, - (HMENU)NewControlId(), + (HMENU)(wxWindowID)m_labelIds[n], wxGetInstance(), NULL ); @@ -282,6 +286,7 @@ WXDWORD wxSlider::MSWGetStyle(long style, WXDWORD *exstyle) const wxSlider::~wxSlider() { delete m_labels; + delete[] m_labelIds; } // ---------------------------------------------------------------------------- diff --git a/src/msw/statbr95.cpp b/src/msw/statbr95.cpp index 57990a9c80..0913dbf5aa 100644 --- a/src/msw/statbr95.cpp +++ b/src/msw/statbr95.cpp @@ -106,7 +106,7 @@ bool wxStatusBar95::Create(wxWindow *parent, wstyle, 0, 0, 0, 0, GetHwndOf(parent), - (HMENU)m_windowId, + (HMENU)m_windowId.GetValue(), wxGetInstance(), NULL ); diff --git a/src/xrc/xmlres.cpp b/src/xrc/xmlres.cpp index 00af7a26f9..365a721f1d 100644 --- a/src/xrc/xmlres.cpp +++ b/src/xrc/xmlres.cpp @@ -1575,7 +1575,10 @@ void wxXmlResourceHandler::CreateChildrenPrivately(wxObject *parent, wxXmlNode * struct XRCID_record { - int id; + /* Hold the id so that once an id is allocated for a name, it + does not get created again by NewControlId at least + until we are done with it */ + wxWindowIDRef id; char *key; XRCID_record *next; }; @@ -1648,11 +1651,6 @@ static void CleanXRCID_Record(XRCID_record *rec) { CleanXRCID_Record(rec->next); - // if we had generated the value of this id automatically, release it - // now that we don't need it any longer - if ( wxWindow::IsAutoGeneratedId(rec->id) ) - wxWindow::ReleaseControlId(rec->id); - free(rec->key); delete rec; } diff --git a/wxGTK.spec b/wxGTK.spec index b9945f5cfc..90df649c56 100644 --- a/wxGTK.spec +++ b/wxGTK.spec @@ -329,19 +329,19 @@ wx/xtistrm.h wx/zipstrm.h wx/zstream.h wx/private/fdiodispatcher.h -wx/private/gsocketiohandler.h wx/private/selectdispatcher.h wx/unix/app.h wx/unix/apptbase.h wx/unix/apptrait.h wx/unix/chkconf.h -wx/unix/execute.h wx/unix/evtloop.h -wx/unix/mimetype.h wx/unix/pipe.h +wx/unix/stdpaths.h +wx/unix/execute.h +wx/unix/mimetype.h wx/unix/private.h +wx/private/gsocketiohandler.h wx/unix/stackwalk.h -wx/unix/stdpaths.h wx/fs_inet.h wx/gsocket.h wx/protocol/file.h diff --git a/wxMotif.spec b/wxMotif.spec index 232f58c139..d8f00e3f52 100644 --- a/wxMotif.spec +++ b/wxMotif.spec @@ -234,19 +234,19 @@ wx/xtistrm.h wx/zipstrm.h wx/zstream.h wx/private/fdiodispatcher.h -wx/private/gsocketiohandler.h wx/private/selectdispatcher.h wx/unix/app.h wx/unix/apptbase.h wx/unix/apptrait.h wx/unix/chkconf.h -wx/unix/execute.h wx/unix/evtloop.h -wx/unix/mimetype.h wx/unix/pipe.h +wx/unix/stdpaths.h +wx/unix/execute.h +wx/unix/mimetype.h wx/unix/private.h +wx/private/gsocketiohandler.h wx/unix/stackwalk.h -wx/unix/stdpaths.h wx/fs_inet.h wx/gsocket.h wx/protocol/file.h diff --git a/wxX11.spec b/wxX11.spec index 94eba4e03d..bb3a2c0091 100644 --- a/wxX11.spec +++ b/wxX11.spec @@ -258,19 +258,19 @@ wx/xtistrm.h wx/zipstrm.h wx/zstream.h wx/private/fdiodispatcher.h -wx/private/gsocketiohandler.h wx/private/selectdispatcher.h wx/unix/app.h wx/unix/apptbase.h wx/unix/apptrait.h wx/unix/chkconf.h -wx/unix/execute.h wx/unix/evtloop.h -wx/unix/mimetype.h wx/unix/pipe.h +wx/unix/stdpaths.h +wx/unix/execute.h +wx/unix/mimetype.h wx/unix/private.h +wx/private/gsocketiohandler.h wx/unix/stackwalk.h -wx/unix/stdpaths.h wx/fs_inet.h wx/gsocket.h wx/protocol/file.h -- 2.45.2