Use automatically generated ID values for wxPG sub-controls.

Currently in wxPG there are used fixed "magic" ID values to identify sub-controls and this can lead to side effects if these values overlap with ID values assigned to another controls in the application (like e.g. menu items).

Closes #13634.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76882 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Artur Wieczorek
2014-07-09 18:56:36 +00:00
parent 954ee459b4
commit 63a9cc4c2e
4 changed files with 11 additions and 25 deletions

View File

@@ -332,15 +332,6 @@ wxPG_EX_TOOLBAR_SEPARATOR = 0x10000000
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
//
// Ids for sub-controls
// NB: It should not matter what these are.
#define wxPG_SUBID1 2
#define wxPG_SUBID2 3
#define wxPG_SUBID_TEMP1 4
// -----------------------------------------------------------------------
/** @class wxPGCommonValue /** @class wxPGCommonValue
wxPropertyGrid stores information about common values in these wxPropertyGrid stores information about common values in these

View File

@@ -271,7 +271,7 @@ wxPGWindowList wxPGSpinCtrlEditor::CreateControls( wxPropertyGrid* propgrid, wxP
#ifdef __WXMSW__ #ifdef __WXMSW__
wnd2->Hide(); wnd2->Hide();
#endif #endif
wnd2->Create( propgrid->GetPanel(), wxPG_SUBID2, butPos, butSz, wxSP_VERTICAL ); wnd2->Create( propgrid->GetPanel(), wxID_ANY, butPos, butSz, wxSP_VERTICAL );
wnd2->SetRange( INT_MIN, INT_MAX ); wnd2->SetRange( INT_MIN, INT_MAX );
wnd2->SetValue( 0 ); wnd2->SetValue( 0 );
@@ -487,7 +487,7 @@ wxPGWindowList wxPGDatePickerCtrlEditor::CreateControls( wxPropertyGrid* propgri
dateValue = value.GetDateTime(); dateValue = value.GetDateTime();
ctrl->Create(propgrid->GetPanel(), ctrl->Create(propgrid->GetPanel(),
wxPG_SUBID1, wxID_ANY,
dateValue, dateValue,
pos, pos,
useSz, useSz,

View File

@@ -1039,7 +1039,7 @@ wxWindow* wxPGChoiceEditor::CreateControlsBase( wxPropertyGrid* propGrid,
cb->Hide(); cb->Hide();
#endif #endif
cb->Create(ctrlParent, cb->Create(ctrlParent,
wxPG_SUBID1, wxID_ANY,
wxString(), wxString(),
po, po,
si, si,
@@ -1599,7 +1599,7 @@ wxPGWindowList wxPGCheckBoxEditor::CreateControls( wxPropertyGrid* propGrid,
sz.x = propGrid->GetFontHeight() + (wxPG_XBEFOREWIDGET*2) + 4; sz.x = propGrid->GetFontHeight() + (wxPG_XBEFOREWIDGET*2) + 4;
wxSimpleCheckBox* cb = new wxSimpleCheckBox(propGrid->GetPanel(), wxSimpleCheckBox* cb = new wxSimpleCheckBox(propGrid->GetPanel(),
wxPG_SUBID1, pt, sz); wxID_ANY, pt, sz);
cb->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); cb->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
@@ -1865,7 +1865,6 @@ wxWindow* wxPropertyGrid::GenerateEditorTextCtrl( const wxPoint& pos,
int maxLen, int maxLen,
unsigned int forColumn ) unsigned int forColumn )
{ {
wxWindowID id = wxPG_SUBID1;
wxPGProperty* prop = GetSelection(); wxPGProperty* prop = GetSelection();
wxASSERT(prop); wxASSERT(prop);
@@ -1910,7 +1909,7 @@ wxWindow* wxPropertyGrid::GenerateEditorTextCtrl( const wxPoint& pos,
tc->Hide(); tc->Hide();
#endif #endif
SetupTextCtrlValue(value); SetupTextCtrlValue(value);
tc->Create(ctrlParent,id,value, p, s,tcFlags); tc->Create(ctrlParent,wxID_ANY,value, p, s,tcFlags);
#if defined(__WXMSW__) #if defined(__WXMSW__)
// On Windows, we need to override read-only text ctrl's background // On Windows, we need to override read-only text ctrl's background
@@ -1968,7 +1967,6 @@ wxWindow* wxPropertyGrid::GenerateEditorTextCtrl( const wxPoint& pos,
wxWindow* wxPropertyGrid::GenerateEditorButton( const wxPoint& pos, const wxSize& sz ) wxWindow* wxPropertyGrid::GenerateEditorButton( const wxPoint& pos, const wxSize& sz )
{ {
wxWindowID id = wxPG_SUBID2;
wxPGProperty* selected = GetSelection(); wxPGProperty* selected = GetSelection();
wxASSERT(selected); wxASSERT(selected);
@@ -1981,7 +1979,7 @@ wxWindow* wxPropertyGrid::GenerateEditorButton( const wxPoint& pos, const wxSize
wxSize s(25, -1); wxSize s(25, -1);
wxButton* but = new wxButton(); wxButton* but = new wxButton();
but->Create(GetPanel(),id,wxS("..."),p,s,wxWANTS_CHARS); but->Create(GetPanel(),wxID_ANY,wxS("..."),p,s,wxWANTS_CHARS);
// Now that we know the size, move to the correct position // Now that we know the size, move to the correct position
p.x = pos.x + sz.x - but->GetSize().x - 2; p.x = pos.x + sz.x - but->GetSize().x - 2;
@@ -2008,7 +2006,7 @@ wxWindow* wxPropertyGrid::GenerateEditorButton( const wxPoint& pos, const wxSize
#ifdef __WXMSW__ #ifdef __WXMSW__
but->Hide(); but->Hide();
#endif #endif
but->Create(GetPanel(),id,wxS("..."),p,s,wxWANTS_CHARS); but->Create(GetPanel(),wxID_ANY,wxS("..."),p,s,wxWANTS_CHARS);
#ifdef __WXGTK__ #ifdef __WXGTK__
wxFont font = GetFont(); wxFont font = GetFont();
@@ -2135,7 +2133,7 @@ bool wxPGEditorDialogAdapter::ShowDialog( wxPropertyGrid* propGrid, wxPGProperty
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
wxPGMultiButton::wxPGMultiButton( wxPropertyGrid* pg, const wxSize& sz ) wxPGMultiButton::wxPGMultiButton( wxPropertyGrid* pg, const wxSize& sz )
: wxWindow( pg->GetPanel(), wxPG_SUBID2, wxPoint(-100,-100), wxSize(0, sz.y) ), : wxWindow( pg->GetPanel(), wxID_ANY, wxPoint(-100,-100), wxSize(0, sz.y) ),
m_fullEditorSize(sz), m_buttonsWidth(0) m_fullEditorSize(sz), m_buttonsWidth(0)
{ {
SetBackgroundColour(pg->GetCellBackgroundColour()); SetBackgroundColour(pg->GetCellBackgroundColour());
@@ -2151,10 +2149,7 @@ int wxPGMultiButton::GenId( int itemid ) const
{ {
if ( itemid < -1 ) if ( itemid < -1 )
{ {
if ( m_buttons.size() ) itemid = wxID_ANY;
itemid = GetButton(m_buttons.size()-1)->GetId() + 1;
else
itemid = wxPG_SUBID2;
} }
return itemid; return itemid;
} }

View File

@@ -2181,7 +2181,7 @@ bool wxLongStringProperty::DisplayEditorDialog( wxPGProperty* prop, wxPropertyGr
long edStyle = wxTE_MULTILINE; long edStyle = wxTE_MULTILINE;
if ( prop->HasFlag(wxPG_PROP_READONLY) ) if ( prop->HasFlag(wxPG_PROP_READONLY) )
edStyle |= wxTE_READONLY; edStyle |= wxTE_READONLY;
wxTextCtrl* ed = new wxTextCtrl(dlg,11,value, wxTextCtrl* ed = new wxTextCtrl(dlg,wxID_ANY,value,
wxDefaultPosition,wxDefaultSize,edStyle); wxDefaultPosition,wxDefaultSize,edStyle);
rowsizer->Add( ed, 1, wxEXPAND|wxALL, spacing ); rowsizer->Add( ed, 1, wxEXPAND|wxALL, spacing );
@@ -2870,7 +2870,7 @@ bool wxPGInDialogValidator::DoValidate( wxPropertyGrid* propGrid,
if ( !tc ) if ( !tc )
{ {
{ {
tc = new wxTextCtrl( propGrid, wxPG_SUBID_TEMP1, wxEmptyString, tc = new wxTextCtrl( propGrid, wxID_ANY, wxEmptyString,
wxPoint(30000,30000)); wxPoint(30000,30000));
tc->Hide(); tc->Hide();
} }