当前位置: 首页>>代码示例>>C++>>正文


C++ Canvas::DrawTwoLinesExact方法代码示例

本文整理汇总了C++中Canvas::DrawTwoLinesExact方法的典型用法代码示例。如果您正苦于以下问题:C++ Canvas::DrawTwoLinesExact方法的具体用法?C++ Canvas::DrawTwoLinesExact怎么用?C++ Canvas::DrawTwoLinesExact使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Canvas的用法示例。


在下文中一共展示了Canvas::DrawTwoLinesExact方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GetMargin

void
ButtonFrameRenderer::DrawButton(Canvas &canvas, PixelRect rc,
                                bool focused, bool pressed) const
{
  const ButtonLook::StateLook &_look = focused ? look.focused : look.standard;

  canvas.DrawFilledRectangle(rc, _look.background_color);

  const unsigned margin = GetMargin();

  if (margin < 4) {
    /* draw 1-pixel lines */

    canvas.Select(pressed ? _look.dark_border_pen : _look.light_border_pen);
    for (unsigned i = 0; i < margin; ++i)
      canvas.DrawTwoLinesExact(rc.left + i, rc.bottom - 2 - i,
                               rc.left + i, rc.top + i,
                               rc.right - 2 - i, rc.top + i);

    canvas.Select(pressed ? _look.light_border_pen : _look.dark_border_pen);
    for (unsigned i = 0; i < margin; ++i)
      canvas.DrawTwoLinesExact(rc.left + 1 + i, rc.bottom - 1 - i,
                               rc.right - 1 - i, rc.bottom - 1 - i,
                               rc.right - 1 - i, rc.top + 1 + i);
  } else {
    /* at 4 pixels or more, it's more efficient to draw a filled
       polygon */

    const RasterPoint p1[] = {
      RasterPoint(rc.left, rc.top),
      RasterPoint(rc.right, rc.top),
      RasterPoint(rc.right - margin, rc.top + margin),
      RasterPoint(rc.left + margin, rc.top + margin),
      RasterPoint(rc.left + margin, rc.bottom - margin),
      RasterPoint(rc.left, rc.bottom),
    };

    canvas.SelectNullPen();
    canvas.Select(pressed
                  ? _look.dark_border_brush
                  : _look.light_border_brush);
    canvas.DrawTriangleFan(p1, ARRAY_SIZE(p1));

    const RasterPoint p2[] = {
      RasterPoint(rc.right, rc.bottom),
      RasterPoint(rc.right, rc.top),
      RasterPoint(rc.right - margin, rc.top + margin),
      RasterPoint(rc.right - margin, rc.bottom - margin),
      RasterPoint(rc.left + margin, rc.bottom - margin),
      RasterPoint(rc.left, rc.bottom),
    };

    canvas.Select(pressed
                  ? _look.light_border_brush
                  : _look.dark_border_brush);
    canvas.DrawTriangleFan(p2, ARRAY_SIZE(p2));
}
}
开发者ID:kwtskran,项目名称:XCSoar,代码行数:58,代码来源:ButtonRenderer.cpp

示例2:

void
ButtonFrameRenderer::DrawButton(Canvas &canvas, PixelRect rc,
                                bool focused, bool pressed) const
{
  const ButtonLook::StateLook &_look = focused ? look.focused : look.standard;

  canvas.DrawFilledRectangle(rc, _look.background_color);

  canvas.Select(pressed ? _look.dark_border_pen : _look.light_border_pen);
  canvas.DrawTwoLinesExact(rc.left, rc.bottom - 2, rc.left, rc.top, rc.right - 2,
                           rc.top);
  canvas.DrawTwoLinesExact(rc.left + 1, rc.bottom - 3, rc.left + 1, rc.top + 1,
                           rc.right - 3, rc.top + 1);

  canvas.Select(pressed ? _look.light_border_pen : _look.dark_border_pen);
  canvas.DrawTwoLinesExact(rc.left + 1, rc.bottom - 1, rc.right - 1, rc.bottom - 1,
                           rc.right - 1, rc.top + 1);
  canvas.DrawTwoLinesExact(rc.left + 2, rc.bottom - 2, rc.right - 2, rc.bottom - 2,
                           rc.right - 2, rc.top + 2);
}
开发者ID:ppara,项目名称:XCSoar,代码行数:20,代码来源:ButtonRenderer.cpp


注:本文中的Canvas::DrawTwoLinesExact方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。