BScrollView * DTextView::MakeScrollView(const char *name, bool horizontal, bool vertical) { if (Parent()) RemoveSelf(); BScrollView *sv = new BScrollView(name, this, ResizingMode(), 0, horizontal, vertical); sv->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); return sv; }
void BComboBox::Draw(BRect /*updateRect*/) { BRect bounds = Bounds(); font_height fInfo; rgb_color high = HighColor(); rgb_color base = ViewColor(); bool focused; bool enabled; rgb_color white = {255, 255, 255, 255}; rgb_color black = { 0, 0, 0, 255 }; enabled = IsEnabled(); focused = fText->IsFocus() && Window()->IsActive(); BRect fr = fText->Frame(); fr.InsetBy(-3, -3); fr.bottom -= 1; if (enabled) SetHighColor(tint_color(base, B_DARKEN_1_TINT)); else SetHighColor(base); StrokeLine(fr.LeftBottom(), fr.LeftTop()); StrokeLine(fr.RightTop()); if (enabled) SetHighColor(white); else SetHighColor(tint_color(base, B_LIGHTEN_2_TINT)); StrokeLine(fr.LeftBottom()+BPoint(1,0), fr.RightBottom()); StrokeLine(fr.RightTop()+BPoint(0,1)); fr.InsetBy(1,1); if (focused) { // draw UI indication for 'active' SetHighColor(ui_color(B_KEYBOARD_NAVIGATION_COLOR)); StrokeRect(fr); } else { if (enabled) SetHighColor(tint_color(base, B_DARKEN_4_TINT)); else SetHighColor(tint_color(base, B_DARKEN_2_TINT)); StrokeLine(fr.LeftBottom(), fr.LeftTop()); StrokeLine(fr.RightTop()); SetHighColor(base); StrokeLine(fr.LeftBottom()+BPoint(1,0), fr.RightBottom()); StrokeLine(fr.RightTop()+BPoint(0,1)); } fr.InsetBy(1,1); if (!enabled) SetHighColor(tint_color(base, B_DISABLED_MARK_TINT)); else SetHighColor(white); StrokeRect(fr); SetHighColor(high); bounds.right = bounds.left + fDivider; if ((Label()) && (fDivider > 0.0)) { BPoint loc; GetFontHeight(&fInfo); switch (fLabelAlign) { default: case B_ALIGN_LEFT: loc.x = bounds.left + TV_MARGIN; break; case B_ALIGN_CENTER: { float width = StringWidth(Label()); float center = (bounds.right - bounds.left) / 2; loc.x = center - (width/2); break; } case B_ALIGN_RIGHT: { float width = StringWidth(Label()); loc.x = bounds.right - width - TV_MARGIN; break; } } uint32 rmode = ResizingMode(); if ((rmode & _rule_(0xf, 0, 0xf, 0)) == _rule_(_VIEW_TOP_, 0, _VIEW_BOTTOM_, 0)) loc.y = fr.bottom - 2; else loc.y = bounds.bottom - (2 + ceil(fInfo.descent)); MovePenTo(loc); SetHighColor(black); DrawString(Label()); SetHighColor(high); } }
void DialogPane::SetMode(int32 mode, bool initialSetup) { ASSERT(mode < 3 && mode >= 0); if (!initialSetup && mode == fMode) return; int32 oldMode = fMode; fMode = mode; bool followBottom = (ResizingMode() & B_FOLLOW_BOTTOM) != 0; // if we are follow bottom, we will move ourselves, need to place us back float bottomOffset = 0; if (followBottom && Window() != NULL) bottomOffset = Window()->Bounds().bottom - Frame().bottom; BRect newBounds(BoundsForMode(fMode)); if (!initialSetup) ResizeParentWindow(fMode, oldMode); ResizeTo(newBounds.Width(), newBounds.Height()); float delta = 0; if (followBottom && Window() != NULL) delta = (Window()->Bounds().bottom - Frame().bottom) - bottomOffset; if (delta != 0) { MoveBy(0, delta); if (fLatch && (fLatch->ResizingMode() & B_FOLLOW_BOTTOM)) fLatch->MoveBy(0, delta); } switch (fMode) { case 0: { if (oldMode > 1) fMode3Items.RemoveAll(this); if (oldMode > 0) fMode2Items.RemoveAll(this); BView *separator = FindView("separatorLine"); if (separator) { BRect frame(separator->Frame()); frame.InsetBy(-1, -1); RemoveChild(separator); Invalidate(); } AddChild(new SeparatorLine(BPoint(newBounds.left, newBounds.top + newBounds.Height() / 2), newBounds.Width(), false, "separatorLine")); break; } case 1: { if (oldMode > 1) fMode3Items.RemoveAll(this); else fMode2Items.AddAll(this); BView *separator = FindView("separatorLine"); if (separator) { BRect frame(separator->Frame()); frame.InsetBy(-1, -1); RemoveChild(separator); Invalidate(); } break; } case 2: { fMode3Items.AddAll(this); if (oldMode < 1) fMode2Items.AddAll(this); BView *separator = FindView("separatorLine"); if (separator) { BRect frame(separator->Frame()); frame.InsetBy(-1, -1); RemoveChild(separator); Invalidate(); } break; } } }