BRect YabTabView::TabFrame(int32 tab_index) const { float width = 100.0; float height = fTabHeight;; BRect tabFrame(Bounds()); switch (fTabWidthSetting) { case B_WIDTH_FROM_LABEL: { float x = 0.0; for (int32 i = 0; i < tab_index; i++){ x += StringWidth(GetTabName(i)) + 20.0; } if(fTabOrientation == B_TAB_TOP) tabFrame.Set(x, 0.0, x + StringWidth(GetTabName(tab_index)) + 20.0, height); else tabFrame.Set(x, tabFrame.bottom - height, x + StringWidth(GetTabName(tab_index)) + 20.0, tabFrame.bottom); return tabFrame; } case B_WIDTH_FROM_WIDEST: width = 0.0; for (int32 i = 0; i < CountTabs(); i++) { float tabWidth = StringWidth(GetTabName(i)) + 20.0; if (tabWidth > width) width = tabWidth; } // fall through case B_WIDTH_AS_USUAL: default: if(fTabOrientation == B_TAB_TOP) tabFrame.Set(tab_index * width, 0.0, tab_index * width + width, height); else tabFrame.Set(tab_index * width, tabFrame.bottom - height, tab_index * width + width, tabFrame.bottom); return tabFrame; } }
void ArpConfigurePanel::RebuildPanes() { //const bool isHidden = IsHidden(); //Hide(); BView* parent = Parent(); if( parent != 0 ) RemoveSelf(); ClearPanes(); const ArpVectorI<ArpConfigurableI*>& configs = mConfig.Configs(); ArpPtrVector<BView*> getViews; const BFont* font = be_plain_font; font_height fh; font->GetHeight(&fh); const float spaceh = ceil((fh.ascent+fh.descent+fh.leading)/2); const float spacew = ceil(font->StringWidth("W")/2); try { size_t i; ArpD(cdb << ADH << "Allocating vectors for " << configs.size() << " configurable objects." << endl); // Initialize lists of configurable objects. mInitSettings = new ArpPtrVector<BMessage*>; mInitSettings->resize(configs.size(), 0); for( i=0; i<configs.size(); i++ ) { mInitSettings->at(i) = new BMessage; } // Retrieve all configuration views. mConfigViews = new ArpPtrVector<BView*>; for( i=0; i<configs.size(); i++ ) { configs[i]->GetConfiguration(mInitSettings->at(i)); getViews.resize(0); ArpD(cdb << ADH << "Getting views for config #" << i << " (" << configs[i] << ")" << endl); if( configs[i] && configs[i]->Configure(getViews) == B_OK ) { ArpD(cdb << ADH << "Found " << getViews.size() << endl); for( size_t j=0; j<getViews.size(); j++ ) { if( getViews[j] != 0 ) { mConfigViews->push_back(getViews[j]); getViews[j] = 0; } } } } // Set up dimensions of the tab view. BRect tabBound(Bounds()); BRect tabFrame(Frame()); mTabWidth = ceil(spacew*4 + (tabBound.Width()-tabFrame.Width())); mTabHeight = ceil(spaceh*4 + (tabBound.Height()-tabFrame.Height()) + TabHeight()); ArpD(cdb << ADH << "Tab bounds=" << tabBound << ", frame=" << tabFrame << endl); ArpD(cdb << ADH << "mTabWidth=" << mTabWidth << ", mTabHeight=" << mTabHeight << endl); // Add configuration panels to the tab view. for( i=0; i<mConfigViews->size(); i++ ) { if( mConfigViews->at(i) ) { ArpD(cdb << ADH << "Adding tab #" << i << ", name=" << mConfigViews->at(i)->Name() << endl); AddTab(mConfigViews->at(i)); mConfigViews->at(i)->MoveTo(tabBound.left+spacew*2, tabBound.top+spaceh*2); mConfigViews->at(i)->ResizeTo(tabFrame.Width()-mTabWidth, tabFrame.Height()-mTabHeight); ArpD(cdb << ADH << "This panel's frame = " << mConfigViews->at(i)->Frame() << endl); } } } catch( ... ) { size_t i; for( i=0; i<getViews.size(); i++ ) delete getViews[i]; if( mConfigViews ) { for( i=0; i<mConfigViews->size(); i++ ) { delete mConfigViews->at(i); } } FreeMemory(); if( parent ) parent->AddChild(this); throw; } if( parent ) parent->AddChild(this); }
void WorkspacesView::_DrawWindow(DrawingEngine* drawingEngine, const BRect& workspaceFrame, const BRect& screenFrame, ::Window* window, BPoint windowPosition, BRegion& backgroundRegion, bool active) { if (window->Feel() == kDesktopWindowFeel || window->IsHidden()) return; BPoint offset = window->Frame().LeftTop() - windowPosition; BRect frame = _WindowFrame(workspaceFrame, screenFrame, window->Frame(), windowPosition); Decorator *decorator = window->Decorator(); BRect tabFrame(0, 0, 0, 0); if (decorator != NULL) tabFrame = decorator->TabRect(); tabFrame = _WindowFrame(workspaceFrame, screenFrame, tabFrame, tabFrame.LeftTop() - offset); if (!workspaceFrame.Intersects(frame) && !workspaceFrame.Intersects(tabFrame)) return; rgb_color activeTabColor = (rgb_color){ 255, 203, 0, 255 }; rgb_color inactiveTabColor = (rgb_color){ 232, 232, 232, 255 }; rgb_color navColor = (rgb_color){ 0, 0, 229, 255 }; if (decorator != NULL) { activeTabColor = decorator->UIColor(B_WINDOW_TAB_COLOR); inactiveTabColor = decorator->UIColor(B_WINDOW_INACTIVE_TAB_COLOR); navColor = decorator->UIColor(B_NAVIGATION_BASE_COLOR); } // TODO: let decorator do this! rgb_color frameColor = (rgb_color){ 180, 180, 180, 255 }; rgb_color white = (rgb_color){ 255, 255, 255, 255 }; rgb_color tabColor = inactiveTabColor; if (window->IsFocus()) tabColor = activeTabColor; if (!active) { _DarkenColor(tabColor); _DarkenColor(frameColor); _DarkenColor(white); } if (window == fSelectedWindow) { frameColor = navColor; } if (tabFrame.left < frame.left) tabFrame.left = frame.left; if (tabFrame.right >= frame.right) tabFrame.right = frame.right - 1; tabFrame.bottom = frame.top - 1; tabFrame.top = min_c(tabFrame.top, tabFrame.bottom); tabFrame = tabFrame & workspaceFrame; if (decorator != NULL && tabFrame.IsValid()) { drawingEngine->FillRect(tabFrame, tabColor); backgroundRegion.Exclude(tabFrame); } drawingEngine->StrokeRect(frame, frameColor); BRect fillFrame = frame.InsetByCopy(1, 1) & workspaceFrame; frame = frame & workspaceFrame; if (!frame.IsValid()) return; // fill the window itself drawingEngine->FillRect(fillFrame, white); // draw title // TODO: the mini-window functionality should probably be moved into the // Window class, so that it has only to be recalculated on demand. With // double buffered windows, this would also open up the door to have a // more detailed preview. BString title(window->Title()); const ServerFont& font = fDrawState->Font(); font.TruncateString(&title, B_TRUNCATE_END, fillFrame.Width() - 4); font_height fontHeight; font.GetHeight(fontHeight); float height = ceilf(fontHeight.ascent) + ceilf(fontHeight.descent); if (title.Length() > 0 && height < frame.Height() - 2) { rgb_color textColor = tint_color(white, B_DARKEN_4_TINT); drawingEngine->SetHighColor(textColor); drawingEngine->SetLowColor(white); float width = font.StringWidth(title.String(), title.Length()); BPoint textOffset; textOffset.x = rintf(frame.left + (frame.Width() - width) / 2); textOffset.y = rintf(frame.top + (frame.Height() - height) / 2 + fontHeight.ascent); drawingEngine->DrawString(title.String(), title.Length(), textOffset); } // prevent the next window down from drawing over this window backgroundRegion.Exclude(frame); }