use wxWindow::NewControlId() instead of wxNewId() to avoid clashes with user-defined ids; bug fixes in wxMSW for negative menu and toolbar items ids
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@48840 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -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;
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -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)
|
||||
|
@@ -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);
|
||||
|
@@ -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);
|
||||
|
@@ -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())
|
||||
|
@@ -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);
|
||||
|
@@ -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);
|
||||
|
@@ -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;
|
||||
|
@@ -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 )
|
||||
|
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user