mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
CtrlCore: Ctrl::GetAscendant
git-svn-id: svn://ultimatepp.org/upp/trunk@13756 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
3bfe127a5e
commit
cc61e89ff7
2 changed files with 18 additions and 0 deletions
|
|
@ -912,6 +912,8 @@ public:
|
|||
int GetChildIndex(const Ctrl *child) const;
|
||||
Ctrl *GetIndexChild(int i) const;
|
||||
int GetChildCount() const;
|
||||
template <class T>
|
||||
T *GetAscendant() const;
|
||||
|
||||
int GetViewChildIndex(const Ctrl *child) const;
|
||||
int GetViewChildCount() const;
|
||||
|
|
@ -1662,6 +1664,16 @@ void WriteClipboardHTML(const String& html);
|
|||
|
||||
#include GUIPLATFORM_INCLUDE_AFTER
|
||||
|
||||
template <class T>
|
||||
T *Ctrl::GetAscendant() const
|
||||
{
|
||||
T *main;
|
||||
for(Ctrl *p = GetParent(); p; p = p->GetParent())
|
||||
if(T *a = dynamic_cast<T*>(p))
|
||||
return a;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -988,6 +988,12 @@ st]&]
|
|||
sequential scan of child (results in O(n) complexity).&]
|
||||
[s3; &]
|
||||
[s4;%- &]
|
||||
[s5;:Upp`:`:Ctrl`:`:GetAscendant`(`)const:%- [@(0.0.255) template]_<[@(0.0.255) class]_[*@4 T
|
||||
]>_[*@4 T]_`*[* GetAscendant]()_[@(0.0.255) const]&]
|
||||
[s2; Returns first ascendant (parent, parent of parent etc..) that
|
||||
has type [%-*@4 T].&]
|
||||
[s3;%- &]
|
||||
[s4;%- &]
|
||||
[s5;:Ctrl`:`:GetIndexChild`(int`)const:%- [_^Ctrl^ Ctrl]_`*[* GetIndexChild]([@(0.0.255) in
|
||||
t]_[*@3 i])_[@(0.0.255) const]&]
|
||||
[s2; Retruns child at index [%-*@3 i] or NULL if there is none. Note
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue