BRect YabTabView::DrawTabs() { float left = 0; for (int32 i = 0; i < CountTabs(); i++) { BRect tabFrame = TabFrame(i); DrawTab(tabFrame, i, i == fSelection ? B_TAB_FRONT : (i == 0) ? B_TAB_FIRST : B_TAB_ANY, i + 1 != fSelection); left = tabFrame.right; } BRect frame(Bounds()); if (left < frame.right) { frame.left = left; if(fTabOrientation == B_TAB_TOP) frame.bottom = fTabHeight; else frame.top = frame.bottom - fTabHeight; rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR); uint32 borders = BControlLook::B_TOP_BORDER | BControlLook::B_BOTTOM_BORDER | BControlLook::B_RIGHT_BORDER; if (left == 0) borders |= BControlLook::B_LEFT_BORDER; if(fTabOrientation == B_TAB_TOP) be_control_look->DrawInactiveTab(this, frame, frame, base, 0, borders); else fYabControlLook.DrawInactiveTabBottom(this, frame, frame, base, 0, borders); } if (fSelection < CountTabs()) return TabFrame(fSelection); return BRect(); }
void YabTabView::SetFocusTab(int32 tab, bool focused) { if (tab >= CountTabs()) tab = 0; if (tab < 0) tab = CountTabs() - 1; if (focused) { if (tab == fFocus) return; if (fFocus != -1){ if (TabAt (fFocus) != NULL) TabAt(fFocus)->MakeFocus(false); Invalidate(TabFrame(fFocus)); } if (TabAt(tab) != NULL){ TabAt(tab)->MakeFocus(true); Invalidate(TabFrame(tab)); fFocus = tab; } } else if (fFocus != -1) { TabAt(fFocus)->MakeFocus(false); Invalidate(TabFrame(fFocus)); fFocus = -1; } }
void YabTabView::Select(int32 index) { if (index < 0 || index >= CountTabs()) index = Selection(); BView *tab = TabAt(Selection()); if (tab) { Invalidate(); tab->Hide(); } tab = TabAt(index); if (tab) { if (index != 0 && !Bounds().Contains(TabFrame(index))){ if (!Bounds().Contains(TabFrame(index).LeftTop())) fTabOffset += TabFrame(index).left - Bounds().left - 20.0f; else fTabOffset += TabFrame(index).right - Bounds().right + 20.0f; } Invalidate(); tab->Show(); fSelection = index; FocusChanged = index+1; } }
void YabTabView::Draw(BRect updateRect) { // DrawBox(DrawTabs()); // SetHighColor(223,223,223); // StrokeLine(BPoint(Bounds().left, Bounds().bottom-TabHeight()-2), BPoint(Bounds().right, Bounds().bottom-TabHeight()-2)); DrawBox(TabFrame(fSelection)); DrawTabs(); if (IsFocus() && fFocus != -1) { DrawFocusMark(TabFrame(fFocus), fFocus); // Invalidate(TabFrame(fFocus)); } }
void TabView::MouseDown(BPoint where) { BTab* fadeTab = TabAt(0); BRect fadeTabFrame(TabFrame(0)); BTab* modulesTab = TabAt(1); BRect modulesTabFrame(TabFrame(1)); ModulesView* modulesView = dynamic_cast<ModulesView*>(modulesTab->View()); if (fadeTab != NULL && Selection() != 0 && fadeTabFrame.Contains(where) && modulesView != NULL) { // clicked on the fade tab modulesView->SaveState(); modulesView->_CloseSaver(); } else if (modulesTab != NULL && Selection() != 1 && modulesTabFrame.Contains(where) && modulesView != NULL) { // clicked on the modules tab BMessage message(kMsgSaverSelected); modulesView->MessageReceived(&message); } BTabView::MouseDown(where); }
void YabTabView::MouseDown(BPoint point) { if (fTabOrientation == B_TAB_TOP && point.y > fTabHeight) return; if (fTabOrientation == B_TAB_BOTTOM && point.y < Bounds().bottom-fTabHeight) return; for (int32 i = 0; i < CountTabs(); i++) { if (TabFrame(i).Contains(point) && i != Selection()) { Select(i); fFocus = -1; return; } } BView::MouseDown(point); }