added wxWindow::GetPrev/NextSibling()
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@50108 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
e4346967a2
commit
c944775f72
@ -272,6 +272,14 @@ wxX11:
|
||||
- Make Enter key activate the default button (David Hart).
|
||||
|
||||
|
||||
2.8.8
|
||||
-----
|
||||
|
||||
All (GUI):
|
||||
|
||||
- Added wxWindow::GetNextSibling() and GetPrevSibling()
|
||||
|
||||
|
||||
2.8.7
|
||||
-----
|
||||
|
||||
|
@ -1197,6 +1197,20 @@ name in the window constructor or via \helpref{wxWindow::SetName}{wxwindowsetnam
|
||||
\helpref{wxWindow::SetName}{wxwindowsetname}
|
||||
|
||||
|
||||
\membersection{wxWindow::GetNextSibling}\label{wxwindowgetnextsibling}
|
||||
|
||||
\constfunc{wxWindow *}{GetNextSibling}{\void}
|
||||
|
||||
Returns the next window after this one among the parent children or \NULL if
|
||||
this window is the last child.
|
||||
|
||||
\newsince{2.8.8}
|
||||
|
||||
\wxheading{See also}
|
||||
|
||||
\helpref{GetPrevSibling}{wxwindowgetprevsibling}
|
||||
|
||||
|
||||
\membersection{wxWindow::GetParent}\label{wxwindowgetparent}
|
||||
|
||||
\constfunc{virtual wxWindow*}{GetParent}{\void}
|
||||
@ -1270,6 +1284,20 @@ method:\par
|
||||
\helpref{GetScreenPosition}{wxwindowgetscreenposition}
|
||||
|
||||
|
||||
\membersection{wxWindow::GetPrevSibling}\label{wxwindowgetprevsibling}
|
||||
|
||||
\constfunc{wxWindow *}{GetPrevSibling}{\void}
|
||||
|
||||
Returns the previous window before this one among the parent children or \NULL if
|
||||
this window is the first child.
|
||||
|
||||
\newsince{2.8.8}
|
||||
|
||||
\wxheading{See also}
|
||||
|
||||
\helpref{GetNextSibling}{wxwindowgetnextsibling}
|
||||
|
||||
|
||||
\membersection{wxWindow::GetRect}\label{wxwindowgetrect}
|
||||
|
||||
\constfunc{virtual wxRect}{GetRect}{\void}
|
||||
|
@ -631,9 +631,9 @@ public:
|
||||
// move this window just before/after the specified one in tab order
|
||||
// (the other window must be our sibling!)
|
||||
void MoveBeforeInTabOrder(wxWindow *win)
|
||||
{ DoMoveInTabOrder(win, MoveBefore); }
|
||||
{ DoMoveInTabOrder(win, OrderBefore); }
|
||||
void MoveAfterInTabOrder(wxWindow *win)
|
||||
{ DoMoveInTabOrder(win, MoveAfter); }
|
||||
{ DoMoveInTabOrder(win, OrderAfter); }
|
||||
|
||||
|
||||
// parent/children relations
|
||||
@ -646,6 +646,11 @@ public:
|
||||
// needed just for extended runtime
|
||||
const wxWindowList& GetWindowChildren() const { return GetChildren() ; }
|
||||
|
||||
// get the window before/after this one in the parents children list,
|
||||
// returns NULL if this is the first/last window
|
||||
wxWindow *GetPrevSibling() const { return DoGetSibling(OrderBefore); }
|
||||
wxWindow *GetNextSibling() const { return DoGetSibling(OrderAfter); }
|
||||
|
||||
// get the parent or the parent of the parent
|
||||
wxWindow *GetParent() const { return m_parent; }
|
||||
inline wxWindow *GetGrandParent() const;
|
||||
@ -1257,13 +1262,17 @@ protected:
|
||||
virtual bool TryValidator(wxEvent& event);
|
||||
virtual bool TryParent(wxEvent& event);
|
||||
|
||||
// common part of MoveBefore/AfterInTabOrder()
|
||||
enum MoveKind
|
||||
enum WindowOrder
|
||||
{
|
||||
MoveBefore, // insert before the given window
|
||||
MoveAfter // insert after the given window
|
||||
OrderBefore, // insert before the given window
|
||||
OrderAfter // insert after the given window
|
||||
};
|
||||
virtual void DoMoveInTabOrder(wxWindow *win, MoveKind move);
|
||||
|
||||
// common part of GetPrev/NextSibling()
|
||||
wxWindow *DoGetSibling(WindowOrder order) const;
|
||||
|
||||
// common part of MoveBefore/AfterInTabOrder()
|
||||
virtual void DoMoveInTabOrder(wxWindow *win, WindowOrder move);
|
||||
|
||||
// implementation of Navigate() and NavigateIn()
|
||||
virtual bool DoNavigateIn(int flags);
|
||||
|
@ -2635,6 +2635,27 @@ bool wxWindowBase::TryParent(wxEvent& event)
|
||||
return wxEvtHandler::TryParent(event);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// window relationships
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxWindow *wxWindowBase::DoGetSibling(WindowOrder order) const
|
||||
{
|
||||
wxCHECK_MSG( GetParent(), NULL,
|
||||
_T("GetPrev/NextSibling() don't work for TLWs!") );
|
||||
|
||||
wxWindowList& siblings = GetParent()->GetChildren();
|
||||
wxWindowList::compatibility_iterator i = siblings.Find(this);
|
||||
wxCHECK_MSG( i, NULL, _T("window not a child of its parent?") );
|
||||
|
||||
if ( order == OrderBefore )
|
||||
i = i->GetPrevious();
|
||||
else // OrderAfter
|
||||
i = i->GetNext();
|
||||
|
||||
return i ? i->GetData() : NULL;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// keyboard navigation
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -2654,7 +2675,7 @@ bool wxWindowBase::DoNavigateIn(int flags)
|
||||
#endif // wxHAS_NATIVE_TAB_TRAVERSAL/!wxHAS_NATIVE_TAB_TRAVERSAL
|
||||
}
|
||||
|
||||
void wxWindowBase::DoMoveInTabOrder(wxWindow *win, MoveKind move)
|
||||
void wxWindowBase::DoMoveInTabOrder(wxWindow *win, WindowOrder move)
|
||||
{
|
||||
// check that we're not a top level window
|
||||
wxCHECK_RET( GetParent(),
|
||||
@ -2674,7 +2695,7 @@ void wxWindowBase::DoMoveInTabOrder(wxWindow *win, MoveKind move)
|
||||
// can't just move the node around
|
||||
wxWindow *self = (wxWindow *)this;
|
||||
siblings.DeleteObject(self);
|
||||
if ( move == MoveAfter )
|
||||
if ( move == OrderAfter )
|
||||
{
|
||||
i = i->GetNext();
|
||||
}
|
||||
@ -2683,7 +2704,7 @@ void wxWindowBase::DoMoveInTabOrder(wxWindow *win, MoveKind move)
|
||||
{
|
||||
siblings.Insert(i, self);
|
||||
}
|
||||
else // MoveAfter and win was the last sibling
|
||||
else // OrderAfter and win was the last sibling
|
||||
{
|
||||
siblings.Append(self);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user