Exemple #1
0
void
ButtonRenderer::DrawButton(Canvas &canvas, PixelRect rc, bool focused,
                           bool pressed)
{
  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.DrawTwoLines(rc.left, rc.bottom - 2, rc.left, rc.top, rc.right - 2,
                      rc.top);
  canvas.DrawTwoLines(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.DrawTwoLines(rc.left + 1, rc.bottom - 1, rc.right - 1, rc.bottom - 1,
                      rc.right - 1, rc.top + 1);
  canvas.DrawTwoLines(rc.left + 2, rc.bottom - 2, rc.right - 2, rc.bottom - 2,
                      rc.right - 2, rc.top + 2);
}
Exemple #2
0
void
OZRenderer::Draw(Canvas &canvas, Layer layer, const Projection &projection,
                 const ObservationZonePoint &_oz, int offset)
{
  if (layer == LAYER_SHADE && offset < 0)
    return;

  Prepare(canvas, layer, offset);

  switch (_oz.shape) {
  case ObservationZonePoint::LINE:
  case ObservationZonePoint::FAI_SECTOR: {
    const SectorZone &oz = (const SectorZone &)_oz;

    RasterPoint p_center = projection.GeoToScreen(oz.get_location());
    if (layer != LAYER_ACTIVE)
      canvas.DrawSegment(p_center.x, p_center.y,
                         projection.GeoToScreenDistance(oz.getRadius()),
                         oz.getStartRadial() - projection.GetScreenAngle(),
                         oz.getEndRadial() - projection.GetScreenAngle());
    else {
      RasterPoint p_start = projection.GeoToScreen(oz.get_SectorStart());
      RasterPoint p_end = projection.GeoToScreen(oz.get_SectorEnd());

      canvas.DrawTwoLines(p_start, p_center, p_end);
    }

    break;
  }

  case ObservationZonePoint::CYLINDER: {
    const CylinderZone &oz = (const CylinderZone &)_oz;

    if (layer != LAYER_INACTIVE) {
      RasterPoint p_center = projection.GeoToScreen(oz.get_location());
      canvas.circle(p_center.x, p_center.y,
                    projection.GeoToScreenDistance(oz.getRadius()));
    }

    break;
  }

  case ObservationZonePoint::BGA_START:
  case ObservationZonePoint::SECTOR: {
    const SectorZone &oz = (const SectorZone &)_oz;

    if (layer != LAYER_INACTIVE) {
      RasterPoint p_center = projection.GeoToScreen(oz.get_location());

      canvas.DrawSegment(p_center.x, p_center.y,
                         projection.GeoToScreenDistance(oz.getRadius()),
                         oz.getStartRadial() - projection.GetScreenAngle(),
                         oz.getEndRadial() - projection.GetScreenAngle());

      RasterPoint p_start = projection.GeoToScreen(oz.get_SectorStart());
      RasterPoint p_end = projection.GeoToScreen(oz.get_SectorEnd());
      canvas.DrawTwoLines(p_start, p_center, p_end);
    }

    break;
  }

  case ObservationZonePoint::KEYHOLE:
  case ObservationZonePoint::BGAFIXEDCOURSE:
  case ObservationZonePoint::BGAENHANCEDOPTION: {
    const SectorZone &oz = (const SectorZone &)_oz;
    RasterPoint p_center = projection.GeoToScreen(oz.get_location());
    canvas.DrawKeyhole(p_center.x, p_center.y,
                       projection.GeoToScreenDistance(fixed(500)),
                       projection.GeoToScreenDistance(oz.getRadius()),
                       oz.getStartRadial() - projection.GetScreenAngle(),
                       oz.getEndRadial() - projection.GetScreenAngle());

    break;
  }

  case ObservationZonePoint::ANNULAR_SECTOR: {
    const AnnularSectorZone &oz = (const AnnularSectorZone &)_oz;
    RasterPoint p_center = projection.GeoToScreen(oz.get_location());
    canvas.DrawAnnulus(p_center.x, p_center.y,
                       projection.GeoToScreenDistance(oz.getInnerRadius()),
                       projection.GeoToScreenDistance(oz.getRadius()),
                       oz.getStartRadial() - projection.GetScreenAngle(),
                       oz.getEndRadial() - projection.GetScreenAngle());
  }

  }

  Finish(canvas, layer);
}
Exemple #3
0
void
ScrollBar::Paint(Canvas &canvas) const
{
  // Prepare Pen
  canvas.SelectBlackPen();

  // ###################
  // #### ScrollBar ####
  // ###################

  // draw rectangle around entire scrollbar area
  canvas.DrawTwoLines(rc.left, rc.top, rc.left, rc.bottom,
                   rc.right, rc.bottom);
  canvas.DrawTwoLines(rc.right, rc.bottom, rc.right, rc.top,
                   rc.left, rc.top);

  // ###################
  // ####  Buttons  ####
  // ###################

  UPixelScalar arrow_padding = max(UPixelScalar(GetWidth() / 4),
                                   UPixelScalar(4));
  canvas.SelectBlackBrush();

  PixelRect up_arrow_rect = rc;
  ++up_arrow_rect.left;
  up_arrow_rect.bottom = up_arrow_rect.top + GetWidth();
  canvas.DrawLine(up_arrow_rect.left, up_arrow_rect.bottom,
              up_arrow_rect.right, up_arrow_rect.bottom);
  canvas.DrawButton(up_arrow_rect, false);

  RasterPoint up_arrow[3] = {
    { PixelScalar((up_arrow_rect.left + rc.right) / 2),
      PixelScalar(up_arrow_rect.top + arrow_padding) },
    { PixelScalar(up_arrow_rect.left + arrow_padding),
      PixelScalar(up_arrow_rect.bottom - arrow_padding) },
    { PixelScalar(rc.right - arrow_padding),
      PixelScalar(up_arrow_rect.bottom - arrow_padding) },
  };
  canvas.DrawTriangleFan(up_arrow, ARRAY_SIZE(up_arrow));

  PixelRect down_arrow_rect = rc;
  ++down_arrow_rect.left;
  down_arrow_rect.top = down_arrow_rect.bottom - GetWidth();
  canvas.DrawLine(down_arrow_rect.left, down_arrow_rect.top - 1,
              down_arrow_rect.right, down_arrow_rect.top - 1);
  canvas.DrawButton(down_arrow_rect, false);

  RasterPoint down_arrow[3] = {
    { PixelScalar((down_arrow_rect.left + rc.right) / 2),
      PixelScalar(down_arrow_rect.bottom - arrow_padding) },
    { PixelScalar(down_arrow_rect.left + arrow_padding),
      PixelScalar(down_arrow_rect.top + arrow_padding) },
    { PixelScalar(rc.right - arrow_padding),
      PixelScalar(down_arrow_rect.top + arrow_padding) },
  };
  canvas.DrawTriangleFan(down_arrow, ARRAY_SIZE(down_arrow));

  // ###################
  // ####  Slider   ####
  // ###################

  if (rc_slider.top + 4 < rc_slider.bottom) {
    canvas.DrawLine(rc_slider.left, rc_slider.top,
                rc_slider.right, rc_slider.top);
    canvas.DrawLine(rc_slider.left, rc_slider.bottom,
                rc_slider.right, rc_slider.bottom);

    PixelRect rc_slider2 = rc_slider;
    ++rc_slider2.left;
    ++rc_slider2.top;
    canvas.DrawButton(rc_slider2, false);
  }

  // fill the rest with darker 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, COLOR_GRAY);

  if (rc_slider.bottom < down_arrow_rect.top)
    canvas.DrawFilledRectangle(rc.left + 1, rc_slider.bottom,
                               rc.right, down_arrow_rect.top, COLOR_GRAY);
}