diff --git a/headers/os/interface/TabView.h b/headers/os/interface/TabView.h index 90f193b7f9..9a8830a738 100644 --- a/headers/os/interface/TabView.h +++ b/headers/os/interface/TabView.h @@ -52,7 +52,11 @@ public: virtual void DrawTab(BView* owner, BRect frame, tab_position position, bool full = true); + class Private; + private: + friend class Private; + // FBC padding and forbidden methods virtual void _ReservedTab1(); virtual void _ReservedTab2(); @@ -70,8 +74,6 @@ private: BTab& operator=(const BTab&); private: - friend class BTabView; - bool fEnabled; bool fSelected; bool fFocus; diff --git a/headers/private/interface/TabViewPrivate.h b/headers/private/interface/TabViewPrivate.h new file mode 100644 index 0000000000..8b6c9c47a0 --- /dev/null +++ b/headers/private/interface/TabViewPrivate.h @@ -0,0 +1,31 @@ +/* + * Copyright 2015, Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Augustin Cavalier + */ +#ifndef TABVIEW_PRIVATE_H +#define TABVIEW_PRIVATE_H + + +#include + + +class BTab::Private { +public: + Private(BTab* tab) + : + fTab(tab) + { + } + + void SetTabView(BTabView* tabView) + { fTab->fTabView = tabView; } + +private: + BTab* fTab; +}; + + +#endif /* TABVIEW_PRIVATE_H */ diff --git a/src/kits/interface/TabView.cpp b/src/kits/interface/TabView.cpp index 1c09b9680a..1dbc59f637 100644 --- a/src/kits/interface/TabView.cpp +++ b/src/kits/interface/TabView.cpp @@ -12,6 +12,7 @@ #include +#include #include #include @@ -153,12 +154,12 @@ BTab::Select(BView* owner) { fSelected = true; - if (!owner || !View() || !owner->Window()) + if (!owner || !View()) return; // NOTE: Views are not added/removed, if there is layout, // they are made visible/invisible in that case. - if (!owner->GetLayout() && View()->Parent() == NULL) + if (!owner->GetLayout() && View()->Parent() == NULL) owner->AddChild(fView); } @@ -223,7 +224,7 @@ BTab::SetView(BView* view) fView = view; if (fTabView != NULL && fSelected) { - Select(NULL); + Select(fTabView->ContainerView()); fTabView->Invalidate(); } } @@ -1151,7 +1152,7 @@ BTabView::AddTab(BView* target, BTab* tab) fContainerView->GetLayout()->AddView(CountTabs(), target); fTabList->AddItem(tab); - tab->fTabView = this; + BTab::Private(tab).SetTabView(this); // When we haven't had a any tabs before, but are already attached to the // window, select this one. @@ -1171,7 +1172,7 @@ BTabView::RemoveTab(int32 index) return NULL; tab->Deselect(); - tab->fTabView = NULL; + BTab::Private(tab).SetTabView(NULL); if (fContainerView->GetLayout()) fContainerView->GetLayout()->RemoveItem(index);