Added MoveTab() method.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39489 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2010-11-19 01:06:02 +00:00
parent 92b0038ec0
commit 52474b49a3
2 changed files with 24 additions and 0 deletions

View File

@ -206,6 +206,29 @@ SmartTabView::RemoveTab(int32 index)
}
void
SmartTabView::MoveTab(int32 index, int32 newIndex)
{
// check the indexes
int32 count = CountTabs();
if (index == newIndex || index < 0 || newIndex < 0 || index >= count
|| newIndex >= count) {
return;
}
// Remove the tab from its position and add it to the end. Then cycle the
// tabs starting after the new position (save the tab already moved) to the
// end.
BTab* tab = BTabView::RemoveTab(index);
BTabView::AddTab(tab->View(), tab);
for (int32 i = newIndex; i < count - 1; i++) {
tab = BTabView::RemoveTab(newIndex);
BTabView::AddTab(tab->View(), tab);
}
}
BRect
SmartTabView::DrawTabs()
{

View File

@ -48,6 +48,7 @@ public:
virtual void AddTab(BView* target, BTab* tab = NULL);
virtual BTab* RemoveTab(int32 index);
void MoveTab(int32 index, int32 newIndex);
virtual BRect DrawTabs();