Add IndexOf methods.

This commit is contained in:
czeidler 2012-03-17 17:16:50 +00:00 committed by Alex Wilson
parent 15ef732f0d
commit d7568eabd2
2 changed files with 26 additions and 0 deletions

View File

@ -50,6 +50,8 @@ public:
int32 CountYTabs() const;
XTab* XTabAt(int32 index, bool ordered = false);
YTab* YTabAt(int32 index, bool ordered = false);
int32 IndexOf(XTab* tab, bool ordered = false);
int32 IndexOf(YTab* tab, bool ordered = false);
Row* AddRow(YTab* top, YTab* bottom);
Column* AddColumn(XTab* left, XTab* right);

View File

@ -279,6 +279,30 @@ BALMLayout::YTabAt(int32 index, bool ordered)
}
int32
BALMLayout::IndexOf(XTab* tab, bool ordered)
{
if (ordered && !fXTabsSorted) {
Layout();
fXTabList.SortItems(CompareXTabFunc);
fXTabsSorted = true;
}
return fXTabList.IndexOf(tab);
}
int32
BALMLayout::IndexOf(YTab* tab, bool ordered)
{
if (ordered && !fYTabsSorted) {
Layout();
fYTabList.SortItems(CompareYTabFunc);
fYTabsSorted = true;
}
return fYTabList.IndexOf(tab);
}
int
CompareXTabFunc(const XTab* tab1, const XTab* tab2)
{