void PaneSwitch::Draw(BRect) { BRect bounds(Bounds()); // Draw the label, if any const char* label = fLabelOff; if (fLabelOn != NULL && Value() == B_CONTROL_ON) label = fLabelOn; if (label != NULL) { BPoint point; float labelDist = sLatchSize + ceilf(sLatchSize / 2.0); if (fLeftAligned) point.x = labelDist; else point.x = bounds.right - labelDist - StringWidth(label); SetHighUIColor(B_PANEL_TEXT_COLOR); font_height fontHeight; GetFontHeight(&fontHeight); point.y = (bounds.top + bounds.bottom - ceilf(fontHeight.ascent) - ceilf(fontHeight.descent)) / 2 + ceilf(fontHeight.ascent); DrawString(label, point); } // draw the latch if (fPressing) DrawInState(kPressed); else if (Value()) DrawInState(kExpanded); else DrawInState(kCollapsed); // ...and the focus indication if (!IsFocus() || !Window()->IsActive()) return; rgb_color markColor = ui_color(B_KEYBOARD_NAVIGATION_COLOR); BeginLineArray(2); AddLine(BPoint(bounds.left + 2, bounds.bottom - 1), BPoint(bounds.right - 2, bounds.bottom - 1), markColor); AddLine(BPoint(bounds.left + 2, bounds.bottom), BPoint(bounds.right - 2, bounds.bottom), kWhite); EndLineArray(); }
void PaneSwitch::Draw(BRect) { if (fPressing) DrawInState(kPressed); else if (Value()) DrawInState(kExpanded); else DrawInState(kCollapsed); rgb_color markColor = ui_color(B_KEYBOARD_NAVIGATION_COLOR); bool focused = IsFocus() && Window()->IsActive(); BRect bounds(Bounds()); BeginLineArray(2); AddLine(BPoint(bounds.left + 2, bounds.bottom - 1), BPoint(bounds.right - 2, bounds.bottom - 1), focused ? markColor : ViewColor()); AddLine(BPoint(bounds.left + 2, bounds.bottom), BPoint(bounds.right - 2, bounds.bottom), focused ? kWhite : ViewColor()); EndLineArray(); }
void KnobSwitch::Draw(BRect) { DrawInState(fCurrState); }