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
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user