void BButton::Draw(BRect updateRect) { if (be_control_look != NULL) { BRect rect(Bounds()); rgb_color background = LowColor(); rgb_color base = background; uint32 flags = be_control_look->Flags(this); if (IsDefault()) flags |= BControlLook::B_DEFAULT_BUTTON; be_control_look->DrawButtonFrame(this, rect, updateRect, base, background, flags); be_control_look->DrawButtonBackground(this, rect, updateRect, base, flags); // always leave some room around the label rect.InsetBy(3.0, 3.0); be_control_look->DrawLabel(this, Label(), rect, updateRect, base, flags, BAlignment(B_ALIGN_CENTER, B_ALIGN_MIDDLE)); return; } font_height fh; GetFontHeight(&fh); const BRect bounds = Bounds(); BRect rect = bounds; const bool enabled = IsEnabled(); const bool pushed = Value() == B_CONTROL_ON; // Default indicator if (IsDefault()) rect = _DrawDefault(rect, enabled); BRect fillArea = rect; fillArea.InsetBy(3.0, 3.0); BString text = Label(); #if 1 // Label truncation BFont font; GetFont(&font); font.TruncateString(&text, B_TRUNCATE_END, fillArea.Width() - 4); #endif // Label position const float stringWidth = StringWidth(text.String()); const float x = (rect.right - stringWidth) / 2.0; const float labelY = bounds.top + ((bounds.Height() - fh.ascent - fh.descent) / 2.0) + fh.ascent + 1.0; const float focusLineY = labelY + fh.descent; /* speed trick: if the focus changes but the button is not pressed then we can redraw only the focus line, if the focus changes and the button is pressed invert the internal rect this block takes care of all the focus changes */ if (IsFocusChanging()) { if (pushed) { rect.InsetBy(2.0, 2.0); InvertRect(rect); } else { _DrawFocusLine(x, focusLineY, stringWidth, IsFocus() && Window()->IsActive()); } return; } // colors rgb_color panelBgColor = ui_color(B_PANEL_BACKGROUND_COLOR); rgb_color buttonBgColor = tint_color(panelBgColor, B_LIGHTEN_1_TINT); rgb_color lightColor; rgb_color maxLightColor; rgb_color dark1BorderColor; rgb_color dark2BorderColor; rgb_color bevelColor1; rgb_color bevelColor2; rgb_color bevelColorRBCorner; rgb_color borderBevelShadow; rgb_color borderBevelLight; if (enabled) { lightColor = tint_color(panelBgColor, B_LIGHTEN_2_TINT); maxLightColor = tint_color(panelBgColor, B_LIGHTEN_MAX_TINT); dark1BorderColor = tint_color(panelBgColor, B_DARKEN_3_TINT); dark2BorderColor = tint_color(panelBgColor, B_DARKEN_4_TINT); bevelColor1 = tint_color(panelBgColor, B_DARKEN_2_TINT); bevelColor2 = panelBgColor; if (IsDefault()) { borderBevelShadow = tint_color(dark1BorderColor, (B_NO_TINT + B_DARKEN_1_TINT) / 2); borderBevelLight = tint_color(dark1BorderColor, B_LIGHTEN_1_TINT); borderBevelLight.red = (borderBevelLight.red + panelBgColor.red) / 2; borderBevelLight.green = (borderBevelLight.green + panelBgColor.green) / 2; borderBevelLight.blue = (borderBevelLight.blue + panelBgColor.blue) / 2; dark1BorderColor = tint_color(dark1BorderColor, B_DARKEN_3_TINT); dark2BorderColor = tint_color(dark1BorderColor, B_DARKEN_4_TINT); bevelColorRBCorner = borderBevelShadow; } else { borderBevelShadow = tint_color(panelBgColor, (B_NO_TINT + B_DARKEN_1_TINT) / 2); borderBevelLight = buttonBgColor; bevelColorRBCorner = dark1BorderColor; } } else { lightColor = tint_color(panelBgColor, B_LIGHTEN_2_TINT); maxLightColor = tint_color(panelBgColor, B_LIGHTEN_1_TINT); dark1BorderColor = tint_color(panelBgColor, B_DARKEN_1_TINT); dark2BorderColor = tint_color(panelBgColor, B_DARKEN_2_TINT); bevelColor1 = panelBgColor; bevelColor2 = buttonBgColor; if (IsDefault()) { borderBevelShadow = dark1BorderColor; borderBevelLight = panelBgColor; dark1BorderColor = tint_color(dark1BorderColor, B_DARKEN_1_TINT); dark2BorderColor = tint_color(dark1BorderColor, 1.16); } else { borderBevelShadow = panelBgColor; borderBevelLight = panelBgColor; } bevelColorRBCorner = tint_color(panelBgColor, 1.08);; } // fill the button area SetHighColor(buttonBgColor); FillRect(fillArea); BeginLineArray(22); // bevel around external border AddLine(BPoint(rect.left, rect.bottom), BPoint(rect.left, rect.top), borderBevelShadow); AddLine(BPoint(rect.left + 1, rect.top), BPoint(rect.right, rect.top), borderBevelShadow); AddLine(BPoint(rect.right, rect.top + 1), BPoint(rect.right, rect.bottom), borderBevelLight); AddLine(BPoint(rect.left + 1, rect.bottom), BPoint(rect.right - 1, rect.bottom), borderBevelLight); rect.InsetBy(1.0, 1.0); // external border AddLine(BPoint(rect.left, rect.bottom), BPoint(rect.left, rect.top), dark1BorderColor); AddLine(BPoint(rect.left + 1, rect.top), BPoint(rect.right, rect.top), dark1BorderColor); AddLine(BPoint(rect.right, rect.top + 1), BPoint(rect.right, rect.bottom), dark2BorderColor); AddLine(BPoint(rect.right - 1, rect.bottom), BPoint(rect.left + 1, rect.bottom), dark2BorderColor); rect.InsetBy(1.0, 1.0); // Light AddLine(BPoint(rect.left, rect.top), BPoint(rect.left, rect.top), buttonBgColor); AddLine(BPoint(rect.left, rect.top + 1), BPoint(rect.left, rect.bottom - 1), lightColor); AddLine(BPoint(rect.left, rect.bottom), BPoint(rect.left, rect.bottom), bevelColor2); AddLine(BPoint(rect.left + 1, rect.top), BPoint(rect.right - 1, rect.top), lightColor); AddLine(BPoint(rect.right, rect.top), BPoint(rect.right, rect.top), bevelColor2); // Shadow AddLine(BPoint(rect.left + 1, rect.bottom), BPoint(rect.right - 1, rect.bottom), bevelColor1); AddLine(BPoint(rect.right, rect.bottom), BPoint(rect.right, rect.bottom), bevelColorRBCorner); AddLine(BPoint(rect.right, rect.bottom - 1), BPoint(rect.right, rect.top + 1), bevelColor1); rect.InsetBy(1.0, 1.0); // Light AddLine(BPoint(rect.left, rect.top), BPoint(rect.left, rect.bottom - 1), maxLightColor); AddLine(BPoint(rect.left, rect.bottom), BPoint(rect.left, rect.bottom), buttonBgColor); AddLine(BPoint(rect.left + 1, rect.top), BPoint(rect.right - 1, rect.top), maxLightColor); AddLine(BPoint(rect.right, rect.top), BPoint(rect.right, rect.top), buttonBgColor); // Shadow AddLine(BPoint(rect.left + 1, rect.bottom), BPoint(rect.right, rect.bottom), bevelColor2); AddLine(BPoint(rect.right, rect.bottom - 1), BPoint(rect.right, rect.top + 1), bevelColor2); rect.InsetBy(1.0,1.0); EndLineArray(); // Invert if clicked if (enabled && pushed) { rect.InsetBy(-2.0, -2.0); InvertRect(rect); } // Label color if (enabled) { if (pushed) { SetHighColor(maxLightColor); SetLowColor(255 - buttonBgColor.red, 255 - buttonBgColor.green, 255 - buttonBgColor.blue); } else { SetHighColor(ui_color(B_CONTROL_TEXT_COLOR)); SetLowColor(buttonBgColor); } } else { SetHighColor(tint_color(panelBgColor, B_DISABLED_LABEL_TINT)); SetLowColor(buttonBgColor); } // Draw the label DrawString(text.String(), BPoint(x, labelY)); // Focus line if (enabled && IsFocus() && Window()->IsActive() && !pushed) _DrawFocusLine(x, focusLineY, stringWidth, true); }
void ColorSwatch::Draw (BRect) { PushState(); SetDrawingMode (B_OP_COPY); rgb_color high (HighColor()); BRect colorPad (Bounds()); SetHighColor (ValueAsColor()); FillRect (colorPad); rgb_color light (ShiftColor (ValueAsColor(), 0.4)); rgb_color dark (ShiftColor (ValueAsColor(), 1.2)); BeginLineArray (10); AddLine ( colorPad.LeftTop(), colorPad.RightTop() - BPoint (1, 0), light); AddLine ( colorPad.LeftTop(), colorPad.LeftBottom() - BPoint (0, 1), light); AddLine ( colorPad.RightTop() + BPoint (0, 1), colorPad.RightBottom(), dark); AddLine ( colorPad.RightBottom(), colorPad.LeftBottom() + BPoint (1, 0), dark); light = ShiftColor (ViewColor(), 0.1); dark = ShiftColor (ViewColor(), 1.4); colorPad.InsetBy (-1, -1); BPoint hless (-1, 0); BPoint hmore (1, 0); BPoint vless (0, -1); BPoint vmore (0, 1); if (IsFocus() && Window()->IsActive()) { light = general_info.mark_color; dark = general_info.mark_color; hless = hmore = vless = vmore = BPoint (0, 0); } else { // A little blue residue clean up AddLine ( colorPad.RightTop(), colorPad.RightTop(), ViewColor()); AddLine ( colorPad.LeftBottom(), colorPad.LeftBottom(), ViewColor()); } AddLine ( colorPad.LeftTop(), colorPad.RightTop() + hless, dark); AddLine ( colorPad.LeftTop(), colorPad.LeftBottom() + vless, dark); AddLine ( colorPad.RightTop() + vmore, colorPad.RightBottom(), light); AddLine ( colorPad.RightBottom(), colorPad.LeftBottom() + hmore, light); EndLineArray(); PopState(); }
void PadView::Draw(BRect updateRect) { rgb_color background = LowColor(); rgb_color light = tint_color(background, B_LIGHTEN_MAX_TINT); rgb_color shadow = tint_color(background, B_DARKEN_2_TINT); BRect r(Bounds()); BeginLineArray(4); AddLine(BPoint(r.left, r.bottom), BPoint(r.left, r.top), light); AddLine(BPoint(r.left + 1.0, r.top), BPoint(r.right, r.top), light); AddLine(BPoint(r.right, r.top + 1.0), BPoint(r.right, r.bottom), shadow); AddLine(BPoint(r.right - 1.0, r.bottom), BPoint(r.left + 1.0, r.bottom), shadow); EndLineArray(); r.InsetBy(1.0, 1.0); StrokeRect(r, B_SOLID_LOW); r.InsetBy(1.0, 1.0); // dots along top BPoint dot = r.LeftTop(); int32 current; int32 stop; BPoint offset; BPoint next; if (Orientation() == B_VERTICAL) { current = (int32)dot.x; stop = (int32)r.right; offset = BPoint(0, 1); next = BPoint(1, -4); r.top += 5.0; } else { current = (int32)dot.y; stop = (int32)r.bottom; offset = BPoint(1, 0); next = BPoint(-4, 1); r.left += 5.0; } int32 num = 1; while (current <= stop) { rgb_color col1; rgb_color col2; if (num == 1) { col1 = shadow; col2 = background; } else if (num == 2) { col1 = background; col2 = light; } else { col1 = background; col2 = background; num = 0; } SetHighColor(col1); StrokeLine(dot, dot, B_SOLID_HIGH); SetHighColor(col2); dot += offset; StrokeLine(dot, dot, B_SOLID_HIGH); dot += offset; StrokeLine(dot, dot, B_SOLID_LOW); dot += offset; SetHighColor(col1); StrokeLine(dot, dot, B_SOLID_HIGH); dot += offset; SetHighColor(col2); StrokeLine(dot, dot, B_SOLID_HIGH); // next pixel num++; dot += next; current++; } FillRect(r, B_SOLID_LOW); }
void DataView::DrawSelectionFrame(view_focus which) { if (fFileSize == 0) return; bool drawBlock = false; bool drawLastLine = false; BRect block, lastLine; int32 spacing = 0; if (which == kAsciiFocus) spacing++; // draw first line int32 start = fStart % kBlockSize; int32 first = (fStart / kBlockSize) * kBlockSize; int32 end = fEnd; if (end > first + (int32)kBlockSize - 1) end = first + kBlockSize - 1; BRect firstLine = SelectionFrame(which, first + start, end); firstLine.right += spacing; first += kBlockSize; // draw block (and last line) if necessary end = fEnd % kBlockSize; int32 last = (fEnd / kBlockSize) * kBlockSize; if (last >= first) { if (end == kBlockSize - 1) last += kBlockSize; if (last > first) { block = SelectionFrame(which, first, last - 1); block.right += spacing; drawBlock = true; } if (end != kBlockSize - 1) { lastLine = SelectionFrame(which, last, last + end); lastLine.right += spacing; drawLastLine = true; } } SetDrawingMode(B_OP_INVERT); BeginLineArray(8); // +******* // | * // +------+ const rgb_color color = {0, 0, 0}; float bottom; if (drawBlock) bottom = block.bottom; else bottom = firstLine.bottom; AddLine(BPoint(firstLine.left + 1, firstLine.top), firstLine.RightTop(), color); AddLine(BPoint(firstLine.right, firstLine.top + 1), BPoint(firstLine.right, bottom), color); // *-------+ // * | // ********* BRect rect; if (start == 0 || (!drawBlock && !drawLastLine)) rect = firstLine; else if (drawBlock) rect = block; else rect = lastLine; if (drawBlock) rect.bottom = block.bottom; if (drawLastLine) { rect.bottom = lastLine.bottom; rect.right = lastLine.right; } rect.bottom++; AddLine(rect.LeftTop(), rect.LeftBottom(), color); AddLine(BPoint(rect.left + 1, rect.bottom), rect.RightBottom(), color); // *--------+ // * | // +**** | // | | if (start && (drawLastLine || drawBlock)) { AddLine(firstLine.LeftTop(), firstLine.LeftBottom(), color); float right = firstLine.left; if (!drawBlock && right > lastLine.right) right = lastLine.right; AddLine(BPoint(rect.left + 1, rect.top), BPoint(right, rect.top), color); } // | | // | ***** // | * // +--------+ if (drawLastLine) { AddLine(lastLine.RightBottom(), BPoint(lastLine.right, lastLine.top + 1), color); if (!drawBlock && lastLine.right <= firstLine.left) lastLine.right = firstLine.left + (lastLine.right < firstLine.left ? 0 : 1); AddLine(BPoint(lastLine.right, lastLine.top), BPoint(firstLine.right, lastLine.top), color); } EndLineArray(); SetDrawingMode(B_OP_COPY); }
void CollapsableBox::draw_switch(int state) { BRect rect(4, 4, 14, 14); SetHighColor(ViewColor()); FillRect(rect); rgb_color switch_color = {150,150,255, 255}; rgb_color light_color = tint_color(switch_color, B_LIGHTEN_2_TINT); rgb_color dark_color = tint_color(switch_color, B_DARKEN_2_TINT); rgb_color outlineColor = dark_color; // {0, 0, 0, 255}; rgb_color middleColor = state == PRESSED ? light_color : switch_color; SetDrawingMode(B_OP_COPY); switch (state) { case COLLAPSED: BeginLineArray(6); AddLine(BPoint(rect.left + 3, rect.top + 1), BPoint(rect.left + 3, rect.bottom - 1), outlineColor); AddLine(BPoint(rect.left + 3, rect.top + 1), BPoint(rect.left + 7, rect.top + 5), outlineColor); AddLine(BPoint(rect.left + 7, rect.top + 5), BPoint(rect.left + 3, rect.bottom - 1), outlineColor); AddLine(BPoint(rect.left + 4, rect.top + 3), BPoint(rect.left + 4, rect.bottom - 3), middleColor); AddLine(BPoint(rect.left + 5, rect.top + 4), BPoint(rect.left + 5, rect.bottom - 4), middleColor); AddLine(BPoint(rect.left + 5, rect.top + 5), BPoint(rect.left + 6, rect.top + 5), middleColor); EndLineArray(); break; case PRESSED: BeginLineArray(7); AddLine(BPoint(rect.left + 1, rect.top + 7), BPoint(rect.left + 7, rect.top + 7), outlineColor); AddLine(BPoint(rect.left + 7, rect.top + 1), BPoint(rect.left + 7, rect.top + 7), outlineColor); AddLine(BPoint(rect.left + 1, rect.top + 7), BPoint(rect.left + 7, rect.top + 1), outlineColor); AddLine(BPoint(rect.left + 3, rect.top + 6), BPoint(rect.left + 6, rect.top + 6), middleColor); AddLine(BPoint(rect.left + 4, rect.top + 5), BPoint(rect.left + 6, rect.top + 5), middleColor); AddLine(BPoint(rect.left + 5, rect.top + 4), BPoint(rect.left + 6, rect.top + 4), middleColor); AddLine(BPoint(rect.left + 6, rect.top + 3), BPoint(rect.left + 6, rect.top + 4), middleColor); EndLineArray(); break; case EXPANDED: BeginLineArray(6); AddLine(BPoint(rect.left + 1, rect.top + 3), BPoint(rect.right - 1, rect.top + 3), outlineColor); AddLine(BPoint(rect.left + 1, rect.top + 3), BPoint(rect.left + 5, rect.top + 7), outlineColor); AddLine(BPoint(rect.left + 5, rect.top + 7), BPoint(rect.right - 1, rect.top + 3), outlineColor); AddLine(BPoint(rect.left + 3, rect.top + 4), BPoint(rect.right - 3, rect.top + 4), middleColor); AddLine(BPoint(rect.left + 4, rect.top + 5), BPoint(rect.right - 4, rect.top + 5), middleColor); AddLine(BPoint(rect.left + 5, rect.top + 5), BPoint(rect.left + 5, rect.top + 6), middleColor); EndLineArray(); break; } }
void BitmapView::Draw(BRect rect) { if (fBitmap) DrawBitmap(fBitmap, fBitmap->Bounds(), fBitmapRect); else { SetHighColor(0, 0, 0, 80); SetDrawingMode(B_OP_ALPHA); DrawString("Drop", fNoPhotoOffsets[0]); DrawString("a", fNoPhotoOffsets[1]); DrawString("Photo", fNoPhotoOffsets[2]); DrawString("Here", fNoPhotoOffsets[3]); SetDrawingMode(B_OP_COPY); } if (fBorderStyle == B_FANCY_BORDER) { rgb_color base= { 216, 216, 216, 255 }; rgb_color work; SetHighColor(base); StrokeRect(Bounds().InsetByCopy(2, 2)); BeginLineArray(12); BRect r(Bounds()); work = tint_color(base, B_DARKEN_2_TINT); AddLine(r.LeftTop(), r.RightTop(), work); AddLine(r.LeftTop(), r.LeftBottom(), work); r.left++; work = tint_color(base, B_DARKEN_4_TINT); AddLine(r.RightTop(), r.RightBottom(), work); AddLine(r.LeftBottom(), r.RightBottom(), work); r.right--; r.top++; r.bottom--; work = tint_color(base, B_LIGHTEN_MAX_TINT); AddLine(r.LeftTop(), r.RightTop(), work); AddLine(r.LeftTop(), r.LeftBottom(), work); r.left++; work = tint_color(base, B_DARKEN_3_TINT); AddLine(r.RightTop(), r.RightBottom(), work); AddLine(r.LeftBottom(), r.RightBottom(), work); // this rect handled by the above StrokeRect, so inset a total of 2 pixels r.left++; r.right -= 2; r.top += 2; r.bottom -= 2; work = tint_color(base, B_DARKEN_3_TINT); AddLine(r.LeftTop(), r.RightTop(), work); AddLine(r.LeftTop(), r.LeftBottom(), work); r.left++; work = tint_color(base, B_LIGHTEN_MAX_TINT); AddLine(r.RightTop(), r.RightBottom(), work); AddLine(r.LeftBottom(), r.RightBottom(), work); r.right--; r.top++; r.bottom--; EndLineArray(); SetHighColor(tint_color(base, B_DARKEN_2_TINT)); StrokeRect(r); } else { // Plain border SetHighColor(0, 0, 0); StrokeRect(fBitmapRect); } }
void CColorSlider::Draw(BRect /* updateRect */) { BRect r = Bounds(); if (IsFocus()) { SetHighColor(keyboard_navigation_color()); StrokeRect(r); } else { SetHighColor(kB_GrayTable[13]); StrokeLine(r.LeftTop(), r.LeftBottom()); StrokeLine(r.LeftTop(), r.RightTop()); SetHighColor(kWhite); StrokeLine(r.LeftBottom(), r.RightBottom()); StrokeLine(r.RightTop(), r.RightBottom()); } r.InsetBy(1, 1); BRect knob; float m = std::min(r.Width(), r.Height()), a; knob.Set(1, 1, m + 1, m + 1); if (fHorizontal) { a = r.Width() - m; knob.OffsetBy(a * fValue, 0); BeginLineArray((int)a + 1); float x = r.left; for (;x <= r.right; x += 1) { float v = (x - 1) / a; rgb_color c = fMax; c.red = (int)((float)c.red * v); c.green = (int)((float)c.green * v); c.blue = (int)((float)c.blue * v); float X = x < knob.left ? x : x + knob.Width(); AddLine(BPoint(X, r.top), BPoint(X, r.bottom), c); } EndLineArray(); } else { a = r.Height() - m; knob.OffsetBy(0, a * (1.0 - fValue)); BeginLineArray((int)a + 1); float y = r.top; for (;y <= r.bottom; y += 1) { float v = 1.0 - (y - 1) / a; rgb_color c = fMax; c.red = (int)((float)c.red * v); c.green = (int)((float)c.green * v); c.blue = (int)((float)c.blue * v); float Y = y < knob.top ? y : y + knob.Height(); AddLine(BPoint(r.left, Y), BPoint(r.right, Y), c); } EndLineArray(); } SetHighColor(kWhite); StrokeLine(knob.LeftTop(), knob.LeftBottom()); StrokeLine(knob.LeftTop(), knob.RightTop()); SetHighColor(kB_GrayTable[13]); StrokeLine(knob.LeftBottom(), knob.RightBottom()); StrokeLine(knob.RightTop(), knob.RightBottom()); SetHighColor(kGray); knob.InsetBy(1, 1); StrokeRect(knob); knob.InsetBy(1, 1); rgb_color c = fMax; c.red = (int)((float)c.red * fValue); c.green = (int)((float)c.green * fValue); c.blue = (int)((float)c.blue * fValue); SetHighColor(c); FillRect(knob); SetHighColor(kBlack); Sync(); } /* CColorSlider::Draw */
void PaneSwitch::DrawInState(PaneSwitch::State state) { BRect rect(0, 0, 10, 10); rgb_color outlineColor = {0, 0, 0, 255}; rgb_color middleColor = state == kPressed ? kHighlightColor : kNormalColor; SetDrawingMode(B_OP_COPY); switch (state) { case kCollapsed: BeginLineArray(6); if (fLeftAligned) { AddLine(BPoint(rect.left + 3, rect.top + 1), BPoint(rect.left + 3, rect.bottom - 1), outlineColor); AddLine(BPoint(rect.left + 3, rect.top + 1), BPoint(rect.left + 7, rect.top + 5), outlineColor); AddLine(BPoint(rect.left + 7, rect.top + 5), BPoint(rect.left + 3, rect.bottom - 1), outlineColor); AddLine(BPoint(rect.left + 4, rect.top + 3), BPoint(rect.left + 4, rect.bottom - 3), middleColor); AddLine(BPoint(rect.left + 5, rect.top + 4), BPoint(rect.left + 5, rect.bottom - 4), middleColor); AddLine(BPoint(rect.left + 5, rect.top + 5), BPoint(rect.left + 6, rect.top + 5), middleColor); } else { AddLine(BPoint(rect.right - 3, rect.top + 1), BPoint(rect.right - 3, rect.bottom - 1), outlineColor); AddLine(BPoint(rect.right - 3, rect.top + 1), BPoint(rect.right - 7, rect.top + 5), outlineColor); AddLine(BPoint(rect.right - 7, rect.top + 5), BPoint(rect.right - 3, rect.bottom - 1), outlineColor); AddLine(BPoint(rect.right - 4, rect.top + 3), BPoint(rect.right - 4, rect.bottom - 3), middleColor); AddLine(BPoint(rect.right - 5, rect.top + 4), BPoint(rect.right - 5, rect.bottom - 4), middleColor); AddLine(BPoint(rect.right - 5, rect.top + 5), BPoint(rect.right - 6, rect.top + 5), middleColor); } EndLineArray(); break; case kPressed: BeginLineArray(7); if (fLeftAligned) { AddLine(BPoint(rect.left + 1, rect.top + 7), BPoint(rect.left + 7, rect.top + 7), outlineColor); AddLine(BPoint(rect.left + 7, rect.top + 1), BPoint(rect.left + 7, rect.top + 7), outlineColor); AddLine(BPoint(rect.left + 1, rect.top + 7), BPoint(rect.left + 7, rect.top + 1), outlineColor); AddLine(BPoint(rect.left + 3, rect.top + 6), BPoint(rect.left + 6, rect.top + 6), middleColor); AddLine(BPoint(rect.left + 4, rect.top + 5), BPoint(rect.left + 6, rect.top + 5), middleColor); AddLine(BPoint(rect.left + 5, rect.top + 4), BPoint(rect.left + 6, rect.top + 4), middleColor); AddLine(BPoint(rect.left + 6, rect.top + 3), BPoint(rect.left + 6, rect.top + 4), middleColor); } else { AddLine(BPoint(rect.right - 1, rect.top + 7), BPoint(rect.right - 7, rect.top + 7), outlineColor); AddLine(BPoint(rect.right - 7, rect.top + 1), BPoint(rect.right - 7, rect.top + 7), outlineColor); AddLine(BPoint(rect.right - 1, rect.top + 7), BPoint(rect.right - 7, rect.top + 1), outlineColor); AddLine(BPoint(rect.right - 3, rect.top + 6), BPoint(rect.right - 6, rect.top + 6), middleColor); AddLine(BPoint(rect.right - 4, rect.top + 5), BPoint(rect.right - 6, rect.top + 5), middleColor); AddLine(BPoint(rect.right - 5, rect.top + 4), BPoint(rect.right - 6, rect.top + 4), middleColor); AddLine(BPoint(rect.right - 6, rect.top + 3), BPoint(rect.right - 6, rect.top + 4), middleColor); } EndLineArray(); break; case kExpanded: BeginLineArray(6); AddLine(BPoint(rect.left + 1, rect.top + 3), BPoint(rect.right - 1, rect.top + 3), outlineColor); AddLine(BPoint(rect.left + 1, rect.top + 3), BPoint(rect.left + 5, rect.top + 7), outlineColor); AddLine(BPoint(rect.left + 5, rect.top + 7), BPoint(rect.right - 1, rect.top + 3), outlineColor); AddLine(BPoint(rect.left + 3, rect.top + 4), BPoint(rect.right - 3, rect.top + 4), middleColor); AddLine(BPoint(rect.left + 4, rect.top + 5), BPoint(rect.right - 4, rect.top + 5), middleColor); AddLine(BPoint(rect.left + 5, rect.top + 5), BPoint(rect.left + 5, rect.top + 6), middleColor); EndLineArray(); break; } }
void ToolbarView::Draw(BRect clip) { BRect r; int i; drawing_mode oldmode = DrawingMode(); SetDrawingMode(B_OP_ALPHA); for (i=0; i<item_count; i++) { r = items[i].rect; if (items[i].bitmap && r.Intersects(clip)) { // We're dawing with alpha, so we need to overdraw the old bitmap // with the toolbar's colour, or they 'overlay' each other. SetHighColor(216,216,216); FillRect(r); if ((items[i].state & ENABLED_MASK)) { DrawBitmapAsync(items[i].bitmap, BPoint(r.left, r.top)); } else { // Disabled icons should be greyed out. // We build a heavily alpha blended grey version of the icon. BBitmap greyedBitmap(items[i].bitmap->Bounds(), B_RGBA32); rgb_color *bitsFrom = static_cast<rgb_color *>(items[i].bitmap->Bits()); rgb_color *bitsTo = static_cast<rgb_color *>(greyedBitmap.Bits()); int pixels = items[i].bitmap->BitsLength()/4; int count; for(count=0; count<pixels; count++) { unsigned char shade = (bitsFrom[count].red/3) + (bitsFrom[count].green/3) + (bitsFrom[count].blue/3); bitsTo[count].red = shade; bitsTo[count].green = shade; bitsTo[count].blue = shade; bitsTo[count].alpha = bitsFrom[count].alpha/4; } // We can't use DrawBitmapAsync, bacause the greyed bitmap is deallocated before it's // drawn. We should really store they greyed versions somewhere permanent. DrawBitmap(&greyedBitmap, BPoint(r.left, r.top)); } // Pressed icons should look like they are pressed (ie down) if (items[i].state & PRESSED_MASK) { HighLightItem(i, 2); } } else if (items[i].type == SEPERATOR) { HighLightItem(i, 1); } } // Draw a nice BeOSey border around the toolbar. r = Bounds(); rgb_color dark={154,154,154}; rgb_color light_dark={186,186,186}; rgb_color light={241,241,241}; SetDrawingMode(B_OP_COPY); BeginLineArray(4); AddLine(BPoint(r.left, r.top), BPoint(r.right, r.top), light); AddLine(BPoint(r.left, r.top), BPoint(r.left, r.bottom), light); AddLine(BPoint(r.left, r.bottom-1), BPoint(r.right, r.bottom-1), light_dark); AddLine(BPoint(r.left, r.bottom), BPoint(r.right, r.bottom), dark); EndLineArray(); SetDrawingMode(oldmode); }
void TOSMagnify::DrawSelection() { if (!fParent->SelectionIsShowing()) return; float x, y; int32 pixelSize = fParent->PixelSize(); int32 squareSize = pixelSize - 2; fParent->SelectionLoc(&x, &y); x *= pixelSize; x++; y *= pixelSize; y++; BRect selRect(x, y, x+squareSize, y+squareSize); short selection = fParent->Selection(); PushState(); SetLowColor(ViewColor()); SetHighColor(kRedColor); StrokeRect(selRect); if (selection == 0) { StrokeLine(BPoint(x,y), BPoint(x+squareSize,y+squareSize)); StrokeLine(BPoint(x,y+squareSize), BPoint(x+squareSize,y)); } bool ch1Showing, ch2Showing; fParent->CrossHairsShowing(&ch1Showing, &ch2Showing); if (ch1Showing) { SetHighColor(kBlueColor); fParent->CrossHair1Loc(&x, &y); x *= pixelSize; x++; y *= pixelSize; y++; selRect.Set(x, y,x+squareSize, y+squareSize); StrokeRect(selRect); BeginLineArray(4); AddLine(BPoint(0, y+(squareSize/2)), BPoint(x, y+(squareSize/2)), kBlueColor); // left AddLine(BPoint(x+squareSize,y+(squareSize/2)), BPoint(Bounds().Width(), y+(squareSize/2)), kBlueColor); // right AddLine(BPoint(x+(squareSize/2), 0), BPoint(x+(squareSize/2), y), kBlueColor); // top AddLine(BPoint(x+(squareSize/2), y+squareSize), BPoint(x+(squareSize/2), Bounds().Height()), kBlueColor); // bottom EndLineArray(); if (selection == 1) { StrokeLine(BPoint(x,y), BPoint(x+squareSize,y+squareSize)); StrokeLine(BPoint(x,y+squareSize), BPoint(x+squareSize,y)); } } if (ch2Showing) { SetHighColor(kBlueColor); fParent->CrossHair2Loc(&x, &y); x *= pixelSize; x++; y *= pixelSize; y++; selRect.Set(x, y,x+squareSize, y+squareSize); StrokeRect(selRect); BeginLineArray(4); AddLine(BPoint(0, y+(squareSize/2)), BPoint(x, y+(squareSize/2)), kBlueColor); // left AddLine(BPoint(x+squareSize,y+(squareSize/2)), BPoint(Bounds().Width(), y+(squareSize/2)), kBlueColor); // right AddLine(BPoint(x+(squareSize/2), 0), BPoint(x+(squareSize/2), y), kBlueColor); // top AddLine(BPoint(x+(squareSize/2), y+squareSize), BPoint(x+(squareSize/2), Bounds().Height()), kBlueColor); // bottom EndLineArray(); if (selection == 2) { StrokeLine(BPoint(x,y), BPoint(x+squareSize,y+squareSize)); StrokeLine(BPoint(x,y+squareSize), BPoint(x+squareSize,y)); } } PopState(); }
void CLVColumnLabelView::Draw(BRect update_rect) { BRect ViewBounds = Bounds(); //Draw each column label in turn float ColumnBegin = 0.0; float ColumnEnd = -1.0; bool MergeWithLeft = false; int32 NumberOfColumns = fDisplayList->CountItems(); BPoint Start,Stop; for(int32 ColumnDraw = 0; ColumnDraw < NumberOfColumns; ColumnDraw++) { CLVColumn* ThisColumn = (CLVColumn*)fDisplayList->ItemAt(ColumnDraw); if(ThisColumn->IsShown()) { //Figure out where this column is ColumnBegin = ThisColumn->fColumnBegin; ColumnEnd = ThisColumn->fColumnEnd; //Start by figuring out if this column will merge with a shown column to the right bool MergeWithRight = false; if(ThisColumn->fFlags & CLV_MERGE_WITH_RIGHT) { for(int32 ColumnCounter = ColumnDraw+1; ColumnCounter < NumberOfColumns; ColumnCounter++) { CLVColumn* NextColumn = (CLVColumn*)fDisplayList->ItemAt(ColumnCounter); if(NextColumn->IsShown()) { //The next column is shown MergeWithRight = true; break; } else if(!(NextColumn->fFlags & CLV_MERGE_WITH_RIGHT)) //The next column is not shown and doesn't pass on the merge break; } } if(update_rect.Intersects(BRect(ColumnBegin,ViewBounds.top,ColumnEnd, ViewBounds.bottom))) { //Need to draw this column BeginLineArray(4); //Top line Start.Set(ColumnBegin,ViewBounds.top); Stop.Set(ColumnEnd-1.0,ViewBounds.top); if(MergeWithRight && !(ThisColumn == fColumnClicked && fColumnResizing)) Stop.x = ColumnEnd; AddLine(Start,Stop,BeHighlight); //Left line if(!MergeWithLeft) AddLine(BPoint(ColumnBegin,ViewBounds.top+1.0), BPoint(ColumnBegin,ViewBounds.bottom),BeHighlight); //Bottom line Start.Set(ColumnBegin+1.0,ViewBounds.bottom); if(MergeWithLeft) Start.x = ColumnBegin; Stop.Set(ColumnEnd-1.0,ViewBounds.bottom); if(MergeWithRight && !(ThisColumn == fColumnClicked && fColumnResizing)) Stop.x = ColumnEnd; AddLine(Start,Stop,BeShadow); //Right line if(ThisColumn == fColumnClicked && fColumnResizing) AddLine(BPoint(ColumnEnd,ViewBounds.top),BPoint(ColumnEnd,ViewBounds.bottom), BeFocusBlue); else if(!MergeWithRight) AddLine(BPoint(ColumnEnd,ViewBounds.top),BPoint(ColumnEnd,ViewBounds.bottom), BeShadow); EndLineArray(); //Add the label //Limit the clipping region to the interior of the box BRect TextRect(ColumnBegin+1.0,ViewBounds.top+1.0,ColumnEnd-1.0, ViewBounds.bottom-1.0); BRegion TextRegion; TextRegion.Include(TextRect); ConstrainClippingRegion(&TextRegion); bool focus; bool sort_key; if(ThisColumn == fColumnClicked && !fColumnResizing) focus = true; else focus = false; if(fParent->fSortKeyList.HasItem(ThisColumn) && ThisColumn->fSortMode != NoSort) sort_key = true; else sort_key = false; ThisColumn->DrawColumnHeader(this,TextRect,sort_key,focus,fFontAscent); //Restore the clipping region ConstrainClippingRegion(NULL); } //Set MergeWithLeft flag for the next column to the appropriate state MergeWithLeft = MergeWithRight; } } //Add highlight and shadow to the region after the columns if necessary if(ColumnEnd < ViewBounds.right) { ColumnBegin = ColumnEnd+1.0; if(update_rect.Intersects(BRect(ColumnEnd+1.0,ViewBounds.top,ViewBounds.right, ViewBounds.bottom))) { BeginLineArray(3); //Top line AddLine(BPoint(ColumnBegin,ViewBounds.top),BPoint(ViewBounds.right,ViewBounds.top), BeHighlight); //Left line AddLine(BPoint(ColumnBegin,ViewBounds.top+1.0),BPoint(ColumnBegin,ViewBounds.bottom), BeHighlight); //Bottom line Start.Set(ColumnBegin+1.0,ViewBounds.bottom); if(MergeWithLeft) Start.x = ColumnBegin; Stop.Set(ViewBounds.right,ViewBounds.bottom); AddLine(Start,Stop,BeShadow); EndLineArray(); } } //Draw the dragging box if necessary if(fColumnClicked && fColumnDragging) { float DragOutlineLeft = fPreviousMousePos.x-fDragBoxMouseHoldOffset; float GroupBegin = ((CLVDragGroup*)fDragGroups.ItemAt(fDragGroup))->GroupBegin; if(DragOutlineLeft < GroupBegin && fSnapGroupBefore == -1) DragOutlineLeft = GroupBegin; if(DragOutlineLeft > GroupBegin && fSnapGroupAfter == -1) DragOutlineLeft = GroupBegin; float DragOutlineRight = DragOutlineLeft + fDragBoxWidth; BeginLineArray(4); AddLine(BPoint(DragOutlineLeft,ViewBounds.top),BPoint(DragOutlineRight, ViewBounds.top),BeFocusBlue); AddLine(BPoint(DragOutlineLeft,ViewBounds.bottom),BPoint(DragOutlineRight, ViewBounds.bottom),BeFocusBlue); AddLine(BPoint(DragOutlineLeft,ViewBounds.top+1.0),BPoint(DragOutlineLeft, ViewBounds.bottom-1.0),BeFocusBlue); AddLine(BPoint(DragOutlineRight,ViewBounds.top+1.0),BPoint(DragOutlineRight, ViewBounds.bottom-1.0),BeFocusBlue); EndLineArray(); fPrevDragOutlineLeft = DragOutlineLeft; fPrevDragOutlineRight = DragOutlineRight; } }
// Draw void SliderView::Draw(BRect updateRect) { fButtonRect.OffsetTo(ButtonOffset(), 6.0); rgb_color background = ui_color(B_PANEL_BACKGROUND_COLOR); rgb_color light = tint_color(background, B_LIGHTEN_MAX_TINT); rgb_color lightShadow = tint_color(background, B_DARKEN_1_TINT); rgb_color shadow = tint_color(background, B_DARKEN_2_TINT); rgb_color darkShadow = tint_color(background, B_DARKEN_4_TINT); BRect r(Bounds()); BeginLineArray(24); // outer dark line AddLine(BPoint(r.left, r.bottom), BPoint(r.left, r.top), lightShadow); AddLine(BPoint(r.left + 1.0, r.top), BPoint(r.right, r.top), lightShadow); AddLine(BPoint(r.right, r.top + 1.0), BPoint(r.right, r.bottom), darkShadow); AddLine(BPoint(r.right - 1.0, r.bottom), BPoint(r.left + 1.0, r.bottom), darkShadow); // second line (raised) r.InsetBy(1.0, 1.0); AddLine(BPoint(r.left, r.bottom), BPoint(r.left, r.top), light); AddLine(BPoint(r.left + 1.0, r.top), BPoint(r.right, r.top), light); AddLine(BPoint(r.right, r.top + 1.0), BPoint(r.right, r.bottom), shadow); AddLine(BPoint(r.right - 1.0, r.bottom), BPoint(r.left + 1.0, r.bottom), shadow); // third line (normal) r.InsetBy(1.0, 1.0); AddLine(BPoint(r.left, r.bottom), BPoint(r.left, r.top), background); AddLine(BPoint(r.left + 1.0, r.top), BPoint(r.right, r.top), background); AddLine(BPoint(r.right, r.top + 1.0), BPoint(r.right, r.bottom), background); AddLine(BPoint(r.right - 1.0, r.bottom), BPoint(r.left + 1.0, r.bottom), background); // fourth line (normal) r.InsetBy(1.0, 1.0); AddLine(BPoint(r.left, r.bottom), BPoint(r.left, r.top), background); AddLine(BPoint(r.left + 1.0, r.top), BPoint(r.right, r.top), background); AddLine(BPoint(r.right, r.top + 1.0), BPoint(r.right, r.bottom), background); AddLine(BPoint(r.right - 1.0, r.bottom), BPoint(r.left + 1.0, r.bottom), background); // fifth line (depressed) r.InsetBy(1.0, 1.0); AddLine(BPoint(r.left, r.bottom), BPoint(r.left, r.top), lightShadow); AddLine(BPoint(r.left + 1.0, r.top), BPoint(r.right, r.top), lightShadow); AddLine(BPoint(r.right, r.top + 1.0), BPoint(r.right, r.bottom), light); AddLine(BPoint(r.right - 1.0, r.bottom), BPoint(r.left + 1.0, r.bottom), light); // fifth line (strongly depressed) r.InsetBy(1.0, 1.0); AddLine(BPoint(r.left, r.bottom), BPoint(r.left, r.top), darkShadow); AddLine(BPoint(r.left + 1.0, r.top), BPoint(r.right, r.top), darkShadow); AddLine(BPoint(r.right, r.top + 1.0), BPoint(r.right, r.bottom), shadow); AddLine(BPoint(r.right - 1.0, r.bottom), BPoint(r.left + 1.0, r.bottom), shadow); EndLineArray(); r.InsetBy(1.0, 1.0); SetLowColor(lightShadow); BRect leftOfButton(r.left + 1.0, r.top + 1.0, fButtonRect.left - 2.0, r.bottom); if (leftOfButton.IsValid()) FillRect(leftOfButton, B_SOLID_LOW); BRect rightOfButton(fButtonRect.right + 2.0, r.top + 1.0, r.right, r.bottom); if (rightOfButton.IsValid()) FillRect(rightOfButton, B_SOLID_LOW); // inner shadow and knob out lines BeginLineArray(5); // shadow AddLine(BPoint(r.left, r.bottom), BPoint(r.left, r.top), shadow); AddLine(BPoint(r.left + 1.0, r.top), BPoint(r.right, r.top), shadow); // at knob if (fButtonRect.left == 6.0) AddLine(BPoint(fButtonRect.left - 1.0, r.top), BPoint(fButtonRect.left - 1.0, r.bottom), darkShadow); else AddLine(BPoint(fButtonRect.left - 1.0, r.top), BPoint(fButtonRect.left - 1.0, r.bottom), shadow); AddLine(BPoint(fButtonRect.left, fButtonRect.bottom + 1.0), BPoint(fButtonRect.right + 1.0, fButtonRect.bottom + 1.0), darkShadow); AddLine(BPoint(fButtonRect.right + 1.0, fButtonRect.bottom), BPoint(fButtonRect.right + 1.0, fButtonRect.top), darkShadow); EndLineArray(); DrawSliderButton(this, fButtonRect, fValue, fFormatString.String(), fTarget->IsEnabled()); }
void SeekSlider::Draw(BRect updateRect) { BRect r(Bounds()); // draw both sides (the original from Be doesn't seem // to make a difference for enabled/disabled state) // DrawBitmapAsync(fLeftSideBits, r.LeftTop()); // DrawBitmapAsync(fRightSideBits, BPoint(sliderEnd + 1.0, r.top)); // colors for the slider area between the two bitmaps rgb_color background = ui_color(B_PANEL_BACKGROUND_COLOR); rgb_color shadow = tint_color(background, B_DARKEN_2_TINT); rgb_color softShadow = tint_color(background, B_DARKEN_1_TINT); rgb_color darkShadow = tint_color(background, B_DARKEN_4_TINT); rgb_color midShadow = tint_color(background, B_DARKEN_3_TINT); rgb_color light = tint_color(background, B_LIGHTEN_MAX_TINT); rgb_color softLight = tint_color(background, B_LIGHTEN_1_TINT); rgb_color green = kSeekGreen; rgb_color greenShadow = kSeekGreenShadow; rgb_color black = kBlack; rgb_color dotGrey = midShadow; rgb_color dotGreen = greenShadow; // draw frame _StrokeFrame(r, softShadow, softShadow, light, light); r.InsetBy(1.0, 1.0); _StrokeFrame(r, black, black, softShadow, softShadow); if (IsEnabled()) { // *** enabled look *** r.InsetBy(1.0, 1.0); // inner shadow _StrokeFrame(r, greenShadow, greenShadow, green, green); r.top++; r.left++; _StrokeFrame(r, greenShadow, greenShadow, green, green); // inside area r.InsetBy(1.0, 1.0); SetHighColor(green); FillRect(r); // dots int32 dotCount = (int32)(r.Width() / 6.0); BPoint dotPos; dotPos.y = r.top + 2.0; SetHighColor(dotGreen); float knobWidth2 = SEEK_SLIDER_KNOB_WIDTH / 2.0; float sliderStart = (r.left + knobWidth2); for (int32 i = 0; i < dotCount; i++) { dotPos.x = sliderStart + i * 6.0; StrokeLine(dotPos, BPoint(dotPos.x, dotPos.y + 6.0)); } // slider handle r.top -= 4.0; r.bottom += 3.0; r.left = fKnobPos - knobWidth2; r.right = fKnobPos + knobWidth2; // black outline float handleBottomSize = 2.0; float handleArrowSize = 6.0; BeginLineArray(10); // upper handle AddLine(BPoint(r.left, r.top + handleBottomSize), BPoint(r.left, r.top), black); AddLine(BPoint(r.left + 1.0, r.top), BPoint(r.right, r.top), black); AddLine(BPoint(r.right, r.top + 1.0), BPoint(r.right, r.top + handleBottomSize), black); AddLine(BPoint(r.right - 1.0, r.top + handleBottomSize + 1.0), BPoint(fKnobPos, r.top + handleArrowSize), black); AddLine(BPoint(fKnobPos - 1.0, r.top + handleArrowSize - 1.0), BPoint(r.left + 1.0, r.top + handleBottomSize + 1.0), black); // lower handle AddLine(BPoint(r.left, r.bottom), BPoint(r.left, r.bottom - handleBottomSize), black); AddLine(BPoint(r.left + 1.0, r.bottom - handleBottomSize - 1.0), BPoint(fKnobPos, r.bottom - handleArrowSize), black); AddLine(BPoint(fKnobPos + 1.0, r.bottom - handleArrowSize + 1.0), BPoint(r.right, r.bottom - handleBottomSize), black); AddLine(BPoint(r.right, r.bottom - handleBottomSize + 1.0), BPoint(r.right, r.bottom), black); AddLine(BPoint(r.right - 1.0, r.bottom), BPoint(r.left + 1.0, r.bottom), black); EndLineArray(); // inner red light and shadow lines r.InsetBy(1.0, 1.0); handleBottomSize--; handleArrowSize -= 2.0; BeginLineArray(10); // upper handle AddLine(BPoint(r.left, r.top + handleBottomSize), BPoint(r.left, r.top), kSeekRedLight); AddLine(BPoint(r.left + 1.0, r.top), BPoint(r.right, r.top), kSeekRedLight); AddLine(BPoint(r.right, r.top + 1.0), BPoint(r.right, r.top + handleBottomSize), kSeekRedShadow); AddLine(BPoint(r.right - 1.0, r.top + handleBottomSize + 1.0), BPoint(fKnobPos, r.top + handleArrowSize), kSeekRedShadow); AddLine(BPoint(fKnobPos - 1.0, r.top + handleArrowSize - 1.0), BPoint(r.left + 1.0, r.top + handleBottomSize + 1.0), kSeekRedLight); // lower handle AddLine(BPoint(r.left, r.bottom), BPoint(r.left, r.bottom - handleBottomSize), kSeekRedLight); AddLine(BPoint(r.left + 1.0, r.bottom - handleBottomSize - 1.0), BPoint(fKnobPos, r.bottom - handleArrowSize), kSeekRedLight); AddLine(BPoint(fKnobPos + 1.0, r.bottom - handleArrowSize + 1.0), BPoint(r.right, r.bottom - handleBottomSize), kSeekRedShadow); AddLine(BPoint(r.right, r.bottom - handleBottomSize + 1.0), BPoint(r.right, r.bottom), kSeekRedShadow); AddLine(BPoint(r.right - 1.0, r.bottom), BPoint(r.left + 1.0, r.bottom), kSeekRedShadow); EndLineArray(); // fill rest of handles with red SetHighColor(kSeekRed); r.InsetBy(1.0, 1.0); handleArrowSize -= 2.0; BPoint arrow[3]; // upper handle arrow arrow[0].x = r.left; arrow[0].y = r.top; arrow[1].x = r.right; arrow[1].y = r.top; arrow[2].x = fKnobPos; arrow[2].y = r.top + handleArrowSize; FillPolygon(arrow, 3); // lower handle arrow arrow[0].x = r.left; arrow[0].y = r.bottom; arrow[1].x = r.right; arrow[1].y = r.bottom; arrow[2].x = fKnobPos; arrow[2].y = r.bottom - handleArrowSize; FillPolygon(arrow, 3); } else { // *** disabled look *** r.InsetBy(1.0, 1.0); _StrokeFrame(r, darkShadow, darkShadow, darkShadow, darkShadow); r.InsetBy(1.0, 1.0); _StrokeFrame(r, darkShadow, darkShadow, darkShadow, darkShadow); r.InsetBy(1.0, 1.0); SetHighColor(darkShadow); SetLowColor(shadow); // stripes float width = floorf(StringWidth(fDisabledString.String())); float textPos = r.left + r.Width() / 2.0 - width / 2.0; pattern stripes = { { 0xc7, 0x8f, 0x1f, 0x3e, 0x7c, 0xf8, 0xf1, 0xe3 } }; BRect stripesRect(r); stripesRect.right = textPos - 5.0; FillRect(stripesRect, stripes); stripesRect.left = textPos + width + 3.0; stripesRect.right = r.right; FillRect(stripesRect, stripes); // info text r.left = textPos - 4.0; r.right = textPos + width + 2.0; FillRect(r); SetHighColor(shadow); SetLowColor(darkShadow); font_height fh; GetFontHeight(&fh); DrawString(fDisabledString.String(), BPoint(textPos, r.top + ceilf(fh.ascent) - 1.0)); } }
void BBox::_DrawFancy(BRect labelBox) { BRect rect = Bounds(); rect.top += TopBorderOffset(); if (be_control_look != NULL) { rgb_color base = ViewColor(); if (rect.Height() == 1.0) { // used as horizontal separator be_control_look->DrawGroupFrame(this, rect, rect, base, BControlLook::B_TOP_BORDER); } else if (rect.Width() == 1.0) { // used as vertical separator be_control_look->DrawGroupFrame(this, rect, rect, base, BControlLook::B_LEFT_BORDER); } else { // used as box be_control_look->DrawGroupFrame(this, rect, rect, base); } return; } rgb_color light = tint_color(ViewColor(), B_LIGHTEN_MAX_TINT); rgb_color shadow = tint_color(ViewColor(), B_DARKEN_3_TINT); if (rect.Height() == 1.0) { // used as horizontal separator BeginLineArray(2); AddLine(BPoint(rect.left, rect.top), BPoint(rect.right, rect.top), shadow); AddLine(BPoint(rect.left, rect.bottom), BPoint(rect.right, rect.bottom), light); EndLineArray(); } else if (rect.Width() == 1.0) { // used as vertical separator BeginLineArray(2); AddLine(BPoint(rect.left, rect.top), BPoint(rect.left, rect.bottom), shadow); AddLine(BPoint(rect.right, rect.top), BPoint(rect.right, rect.bottom), light); EndLineArray(); } else { // used as box BeginLineArray(8); AddLine(BPoint(rect.left, rect.bottom - 1.0), BPoint(rect.left, rect.top), shadow); AddLine(BPoint(rect.left + 1.0, rect.top), BPoint(rect.right - 1.0, rect.top), shadow); AddLine(BPoint(rect.left, rect.bottom), BPoint(rect.right, rect.bottom), light); AddLine(BPoint(rect.right, rect.bottom - 1.0), BPoint(rect.right, rect.top), light); rect.InsetBy(1.0, 1.0); AddLine(BPoint(rect.left, rect.bottom - 1.0), BPoint(rect.left, rect.top), light); AddLine(BPoint(rect.left + 1.0, rect.top), BPoint(rect.right - 1.0, rect.top), light); AddLine(BPoint(rect.left, rect.bottom), BPoint(rect.right, rect.bottom), shadow); AddLine(BPoint(rect.right, rect.bottom - 1.0), BPoint(rect.right, rect.top), shadow); EndLineArray(); } }
void ArpDocumentButton::Draw(BRect) { enum { ShineColor = 0, MedShineColor = 1, ShadowColor = 2, MedShadowColor = 3, NumColors = 4 }; static float ColorTints[NumColors] = { .2, B_DARKEN_2_TINT, B_DARKEN_4_TINT, B_DARKEN_1_TINT }; static int32 StandardMap[NumColors] = { ShineColor, MedShineColor, ShadowColor, MedShadowColor }; static int32 PressedMap[NumColors] = { ShadowColor, MedShadowColor, ShineColor, MedShineColor }; rgb_color bgcolor = LowColor(); if( mDropped ) bgcolor = ui_color(B_KEYBOARD_NAVIGATION_COLOR); BRect bounds(Bounds()); ArpD(cdb << ADH << "Drawing ArpDocument Button..." << endl); ArpD(cdb << ADH << "Initial view bounds=" << bounds << endl); int32* cmap = mPressed ? PressedMap : StandardMap; BeginLineArray(8); rgb_color curcol; if( bounds.IsValid() ) { ArpD(cdb << ADH << "Drawing interior frame at bounds=" << bounds << endl); curcol = tint_color(bgcolor, ColorTints[cmap[MedShineColor]]); AddLine( BPoint(bounds.left, bounds.bottom), BPoint(bounds.left, bounds.top), curcol ); AddLine( BPoint(bounds.left, bounds.top), BPoint(bounds.right, bounds.top), curcol ); curcol = tint_color(bgcolor, ColorTints[cmap[ShadowColor]]); AddLine( BPoint(bounds.right, bounds.top), BPoint(bounds.right, bounds.bottom), curcol ); AddLine( BPoint(bounds.right, bounds.bottom), BPoint(bounds.left, bounds.bottom), curcol ); bounds.InsetBy(1, 1); } if( bounds.IsValid() ) { ArpD(cdb << ADH << "Drawing interior frame at bounds=" << bounds << endl); curcol = tint_color(bgcolor, ColorTints[cmap[ShineColor]]); if( IsFocus() ) curcol = ui_color(B_KEYBOARD_NAVIGATION_COLOR); AddLine( BPoint(bounds.left, bounds.bottom), BPoint(bounds.left, bounds.top), curcol ); AddLine( BPoint(bounds.left, bounds.top), BPoint(bounds.right, bounds.top), curcol ); curcol = tint_color(bgcolor, ColorTints[cmap[MedShadowColor]]); if( IsFocus() ) curcol = ui_color(B_KEYBOARD_NAVIGATION_COLOR); AddLine( BPoint(bounds.right, bounds.top), BPoint(bounds.right, bounds.bottom), curcol ); AddLine( BPoint(bounds.right, bounds.bottom), BPoint(bounds.left, bounds.bottom), curcol ); bounds.InsetBy(1, 1); } EndLineArray(); BRect ibounds; BBitmap* shownBitmap = 0; if( mPressed ) bgcolor = tint_color(LowColor(), B_DARKEN_MAX_TINT); else if( mMenued ) bgcolor = tint_color(LowColor(), B_DARKEN_2_TINT); if( bounds.IsValid() ) { shownBitmap = mDocIcon; if( shownBitmap ) ibounds = shownBitmap->Bounds(); if( mSmallIcon && ( !ibounds.IsValid() || ibounds.Width() > bounds.Width() || ibounds.Height() > bounds.Height() ) ) { shownBitmap = mSmallIcon; ibounds = shownBitmap->Bounds(); } ArpD(cdb << ADH << "Current view bounds=" << bounds << ", icon bounds=" << ibounds << endl); SetHighColor(bgcolor); const float xdiff = bounds.Width() - ibounds.Width(); const float xoff = floor(xdiff/2); if( xdiff > 0 ) { // Fill in background to left and right of bitmap. if( xoff > 0 ) { FillRect(BRect(bounds.left, bounds.top, bounds.left+xoff-1, bounds.bottom)); } FillRect(BRect(bounds.right-(xdiff-xoff)+1, bounds.top, bounds.right, bounds.bottom)); bounds.left += xoff; bounds.right -= (xdiff-xoff); ArpD(cdb << ADH << "Fill view X to bounds=" << bounds << endl); } else { #if 1 ibounds.left -= xoff; ibounds.right += (xdiff-xoff); #endif ArpD(cdb << ADH << "Indent icon X to bounds=" << ibounds << endl); } const float ydiff = bounds.Height() - ibounds.Height(); const float yoff = floor(ydiff/2); if( ydiff > 0 ) { // Fill in background to left and right of bitmap. if( yoff > 0 ) { FillRect(BRect(bounds.left, bounds.top, bounds.right, bounds.top+yoff-1)); } FillRect(BRect(bounds.left, bounds.bottom-(ydiff-yoff)+1, bounds.right, bounds.bottom)); bounds.top += yoff; bounds.bottom -= (ydiff-yoff); ArpD(cdb << ADH << "Fill view Y to bounds=" << bounds << endl); } else { #if 1 ibounds.top -= yoff; ibounds.bottom += (ydiff-yoff); #endif ArpD(cdb << ADH << "Indent icon Y to bounds=" << ibounds << endl); } } if( bounds.IsValid() && ibounds.IsValid() && shownBitmap ) { ArpD(cdb << ADH << "Drawing icon at bounds=" << bounds << ", icon bounds=" << ibounds << endl); SetHighColor(bgcolor); SetLowColor(bgcolor); FillRect(bounds); SetDrawingMode(B_OP_ALPHA); SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_COMPOSITE); DrawBitmapAsync(shownBitmap, ibounds, bounds); SetDrawingMode(B_OP_COPY); } }