void InfoBoxWindow::Paint(Canvas &canvas) { const Color background_color = pressed ? look.pressed_background_color : (HasFocus() || dragging || force_draw_selector ? look.focused_background_color : look.background_color); if (settings.border_style == InfoBoxSettings::BorderStyle::GLASS) DrawGlassBackground(canvas, canvas.GetRect(), background_color); else canvas.Clear(background_color); if (data.GetCustom() && content != NULL) { /* if there's no comment, the content object may paint that area, too */ const PixelRect &rc = data.comment.empty() ? value_and_comment_rect : value_rect; content->OnCustomPaint(canvas, rc); } canvas.SetBackgroundTransparent(); PaintTitle(canvas); PaintComment(canvas); PaintValue(canvas, background_color); if (border_kind != 0) { canvas.Select(look.border_pen); const unsigned width = canvas.GetWidth(), height = canvas.GetHeight(); if (border_kind & BORDERTOP) { canvas.DrawExactLine(0, 0, width - 1, 0); } if (border_kind & BORDERRIGHT) { canvas.DrawExactLine(width - 1, 0, width - 1, height); } if (border_kind & BORDERBOTTOM) { canvas.DrawExactLine(0, height - 1, width - 1, height - 1); } if (border_kind & BORDERLEFT) { canvas.DrawExactLine(0, 0, 0, height - 1); } } }
void ScrollBar::Paint(Canvas &canvas) const { // ################### // #### ScrollBar #### // ################### // draw rectangle around entire scrollbar area canvas.SelectBlackPen(); canvas.SelectHollowBrush(); canvas.Rectangle(rc.left, rc.top, rc.right, rc.bottom); // ################### // #### Buttons #### // ################### const int arrow_padding = std::max(GetWidth() / 4, 4); PixelRect up_arrow_rect = rc; ++up_arrow_rect.left; up_arrow_rect.bottom = up_arrow_rect.top + GetWidth(); PixelRect down_arrow_rect = rc; ++down_arrow_rect.left; down_arrow_rect.top = down_arrow_rect.bottom - GetWidth(); canvas.DrawExactLine(up_arrow_rect.left, up_arrow_rect.bottom, up_arrow_rect.right, up_arrow_rect.bottom); canvas.DrawExactLine(down_arrow_rect.left, down_arrow_rect.top - 1, down_arrow_rect.right, down_arrow_rect.top - 1); button_renderer.DrawButton(canvas, up_arrow_rect, false, false); button_renderer.DrawButton(canvas, down_arrow_rect, false, false); canvas.SelectNullPen(); canvas.SelectBlackBrush(); const RasterPoint up_arrow[3] = { { (up_arrow_rect.left + rc.right) / 2, up_arrow_rect.top + arrow_padding }, { up_arrow_rect.left + arrow_padding, up_arrow_rect.bottom - arrow_padding }, { rc.right - arrow_padding, up_arrow_rect.bottom - arrow_padding }, }; canvas.DrawTriangleFan(up_arrow, ARRAY_SIZE(up_arrow)); const RasterPoint down_arrow[3] = { { (down_arrow_rect.left + rc.right) / 2, down_arrow_rect.bottom - arrow_padding }, { down_arrow_rect.left + arrow_padding, down_arrow_rect.top + arrow_padding }, { rc.right - arrow_padding, down_arrow_rect.top + arrow_padding }, }; canvas.DrawTriangleFan(down_arrow, ARRAY_SIZE(down_arrow)); // ################### // #### Slider #### // ################### if (rc_slider.top + 4 < rc_slider.bottom) { canvas.SelectBlackPen(); canvas.DrawExactLine(rc_slider.left, rc_slider.top, rc_slider.right, rc_slider.top); canvas.DrawExactLine(rc_slider.left, rc_slider.bottom, rc_slider.right, rc_slider.bottom); PixelRect rc_slider2 = rc_slider; ++rc_slider2.left; ++rc_slider2.top; button_renderer.DrawButton(canvas, rc_slider2, dragging, dragging); } // fill the rest with darker gray const Color background_color = IsDithered() ? COLOR_BLACK : COLOR_GRAY; if (up_arrow_rect.bottom + 1 < rc_slider.top) canvas.DrawFilledRectangle(rc.left + 1, up_arrow_rect.bottom + 1, rc.right, rc_slider.top, background_color); if (rc_slider.bottom + 1 < down_arrow_rect.top - 1) canvas.DrawFilledRectangle(rc.left + 1, rc_slider.bottom + 1, rc.right, down_arrow_rect.top - 1, background_color); }