]> git.saurik.com Git - wxWidgets.git/commitdiff
use wxWindow::NewControlId() instead of wxNewId() to avoid clashes with user-defined...
authorVadim Zeitlin <vadim@wxwidgets.org>
Thu, 20 Sep 2007 22:58:55 +0000 (22:58 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Thu, 20 Sep 2007 22:58:55 +0000 (22:58 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@48840 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/tbarbase.h
src/common/menucmn.cpp
src/generic/editlbox.cpp
src/msw/listctrl.cpp
src/msw/menu.cpp
src/msw/radiobox.cpp
src/msw/tbar95.cpp
src/msw/treectrl.cpp
src/msw/wince/tbarwce.cpp
src/msw/window.cpp
src/xrc/xmlres.cpp

index 8c4b93543ba83ad26edfd2986254db6199ba9f6d..47ccd84a01c00e1a7bab91556bd5d3a4cdb2a2aa 100644 (file)
@@ -77,7 +77,7 @@ public:
         m_tbar = tbar;
         m_id = toolid;
         if (m_id == wxID_ANY)
-            m_id = wxNewId();
+            m_id = wxWindow::NewControlId();
         m_clientData = clientData;
 
         m_bmpNormal = bmpNormal;
index edceb72cc52c0e9a4e5819276ef2f508f6ddde59..884fa75167268fcabb89e77f699ba185eeb37541 100644 (file)
@@ -67,7 +67,7 @@ wxMenuItemBase::wxMenuItemBase(wxMenu *parentMenu,
     m_id          = id;
     m_kind        = kind;
     if (m_id == wxID_ANY)
-        m_id = wxNewId();
+        m_id = wxWindow::NewControlId();
     if (m_id == wxID_SEPARATOR)
         m_kind = wxITEM_SEPARATOR;
 
index 6e0dea8563ab8dc22929be21424ebcaf4486dad9..6cc9d187c2016d5a70134603e72fc22109cc9887 100644 (file)
@@ -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 = wxNewId();
-const int wxID_ELB_EDIT = wxNewId();
-const int wxID_ELB_NEW = wxNewId();
-const int wxID_ELB_UP = wxNewId();
-const int wxID_ELB_DOWN = wxNewId();
-const int wxID_ELB_LISTCTRL = wxNewId();
+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();
 
 BEGIN_EVENT_TABLE(wxEditableListBox, wxPanel)
     EVT_LIST_ITEM_SELECTED(wxID_ELB_LISTCTRL, wxEditableListBox::OnItemSelected)
index 221b90cd3b49ef254d00b9ce1e1f1138edca0276..b24838183283226dc834cf0cca3388f441774096 100644 (file)
@@ -1749,8 +1749,9 @@ bool wxListCtrl::MSWShouldPreProcessMessage(WXMSG* msg)
     return wxControl::MSWShouldPreProcessMessage(msg);
 }
 
-bool wxListCtrl::MSWCommand(WXUINT cmd, WXWORD id)
+bool wxListCtrl::MSWCommand(WXUINT cmd, WXWORD id_)
 {
+    const int id = (signed short)id_;
     if (cmd == EN_UPDATE)
     {
         wxCommandEvent event(wxEVT_COMMAND_TEXT_UPDATED, id);
index 915992cf0845e7dd96924aa0eae6b70a231b560d..a6956295e2dcab2610ae3cda67df7397d2ab1ef6 100644 (file)
@@ -788,10 +788,12 @@ void wxMenu::SetTitle(const wxString& label)
 // event processing
 // ---------------------------------------------------------------------------
 
-bool wxMenu::MSWCommand(WXUINT WXUNUSED(param), WXWORD id)
+bool wxMenu::MSWCommand(WXUINT WXUNUSED(param), WXWORD id_)
 {
+    const int id = (signed short)id_;
+
     // ignore commands from the menu title
-    if ( id != (WXWORD)idMenuTitle )
+    if ( id != idMenuTitle )
     {
         // update the check item when it's clicked
         wxMenuItem * const item = FindItem(id);
index f73e2ba3c2d36bd234b681afd6e540261669b952..b29e5eb3e23f71faedddc9fef2736ea56a99535e 100644 (file)
@@ -258,8 +258,10 @@ void wxRadioBox::SubclassRadioButton(WXHWND hWndBtn)
 // events generation
 // ----------------------------------------------------------------------------
 
-bool wxRadioBox::MSWCommand(WXUINT cmd, WXWORD id)
+bool wxRadioBox::MSWCommand(WXUINT cmd, WXWORD id_)
 {
+    const int id = (signed short)id_;
+
     if ( cmd == BN_CLICKED )
     {
         if (id == GetId())
index b653a821d828e2474dde20d7bd6c3788543bcba5..f04e66f35cfdbfcb3511c4600417c6a23d6a8991 100644 (file)
@@ -1185,9 +1185,14 @@ bool wxToolBar::Realize()
 // message handlers
 // ----------------------------------------------------------------------------
 
-bool wxToolBar::MSWCommand(WXUINT WXUNUSED(cmd), WXWORD id)
+bool wxToolBar::MSWCommand(WXUINT WXUNUSED(cmd), WXWORD id_)
 {
-    wxToolBarToolBase *tool = FindById((int)id);
+    // cast to signed is important as we compare this id with (signed) ints in
+    // FindById() and without the cast we'd get a positive int from a
+    // "negative" (i.e. > 32767) WORD
+    const int id = (signed short)id_;
+
+    wxToolBarToolBase *tool = FindById(id);
     if ( !tool )
         return false;
 
@@ -1209,7 +1214,7 @@ bool wxToolBar::MSWCommand(WXUINT WXUNUSED(cmd), WXWORD id)
 
     // OnLeftClick() can veto the button state change - for buttons which
     // may be toggled only, of couse
-    if ( !OnLeftClick((int)id, toggled) && tool->CanBeToggled() )
+    if ( !OnLeftClick(id, toggled) && tool->CanBeToggled() )
     {
         // revert back
         tool->Toggle(!toggled);
index fac8ddbaeeebe070ca79e5e5807e571ccc58c2cb..96bf25a0b5eea4df84a659bf0462327f9cb0686b 100644 (file)
@@ -1902,8 +1902,10 @@ bool wxTreeCtrl::MSWShouldPreProcessMessage(WXMSG* msg)
     return wxTreeCtrlBase::MSWShouldPreProcessMessage(msg);
 }
 
-bool wxTreeCtrl::MSWCommand(WXUINT cmd, WXWORD id)
+bool wxTreeCtrl::MSWCommand(WXUINT cmd, WXWORD id_)
 {
+    const int id = (signed short)id_;
+
     if ( cmd == EN_UPDATE )
     {
         wxCommandEvent event(wxEVT_COMMAND_TEXT_UPDATED, id);
index 04a1efc20f1581202ae47c55249c60780065946a..15e6d13c34f95fdd3e04936b13e2bc6ac9489922 100644 (file)
@@ -482,9 +482,11 @@ bool wxToolMenuBar::Realize()
     return true;
 }
 
-bool wxToolMenuBar::MSWCommand(WXUINT WXUNUSED(cmd), WXWORD id)
+bool wxToolMenuBar::MSWCommand(WXUINT WXUNUSED(cmd), WXWORD id_)
 {
-    wxToolBarToolBase *tool = FindById((int)id);
+    const int id = (signed short)id_;
+
+    wxToolBarToolBase *tool = FindById(id);
     if ( !tool )
     {
         bool checked = false;
index cc05d86fca5285af355cd3b2753a6bf998791e4f..c41f9b1e61a582d350ca2ac2862acfe91b17b828 100644 (file)
@@ -4871,8 +4871,11 @@ bool wxWindowMSW::HandleGetMinMaxInfo(void *WXUNUSED_IN_WINCE(mmInfo))
 // command messages
 // ---------------------------------------------------------------------------
 
-bool wxWindowMSW::HandleCommand(WXWORD id, WXWORD cmd, WXHWND control)
+bool wxWindowMSW::HandleCommand(WXWORD id_, WXWORD cmd, WXHWND control)
 {
+    // sign extend to int from short before comparing with the other int ids
+    int id = (signed short)id_;
+
 #if wxUSE_MENUS_NATIVE
     if ( !cmd && wxCurrentPopupMenu )
     {
@@ -4895,8 +4898,7 @@ bool wxWindowMSW::HandleCommand(WXWORD id, WXWORD cmd, WXHWND control)
     // try the id
     if ( !win )
     {
-        // must cast to a signed type before comparing with other ids!
-        win = FindItem((signed short)id);
+        win = FindItem(id);
     }
 
     if ( win )
index 0d26338fc0337feb4fb71398b2bf5a69aff985c3..ccacf0190560b355ff7ae36b5707adc603458fb4 100644 (file)
@@ -1610,7 +1610,7 @@ static int XRCID_Lookup(const char *str_id, int value_if_not_found = wxID_NONE)
         }
         else
         {
-            (*rec_var)->id = wxNewId();
+            (*rec_var)->id = wxWindow::NewControlId();
         }
     }