Example #1
0
void
ChartWindow::OnPaint(Canvas &canvas)
{
  canvas.ClearWhite();
  ChartRenderer renderer(look, canvas, canvas.GetRect());
  DrawChart(renderer);
}
Example #2
0
static void
Draw(Canvas &canvas)
{
  PixelRect rc = canvas.GetRect();
  rc.Grow(-16);

  DrawBanner(canvas, rc);
  DrawFlights(canvas, rc);
}
Example #3
0
  /* virtual methods from AntiFlickerWindow */
  void OnPaintBuffer(Canvas &canvas) override {
    canvas.ClearWhite();

    if (!CommonInterface::Basic().attitude.IsBankAngleUseable() &&
        !CommonInterface::Basic().attitude.IsPitchAngleUseable())
      // TODO: paint "no data" hint
      return;

    HorizonRenderer::Draw(canvas, canvas.GetRect(), look, attitude);
  }
Example #4
0
  virtual void OnPaint(Canvas &canvas) override {
    canvas.ClearWhite();

    const PixelRect rc = canvas.GetRect();
    PixelPoint pt = rc.GetCenter();

    canvas.SelectBlackPen();
    canvas.SelectHollowBrush();
    canvas.DrawCircle(pt.x, pt.y, 2);

    renderer.Draw(canvas, Angle::Zero(), wind, pt, rc, WindArrowStyle::ARROW_HEAD);
  }
void
BufferCanvas::CopyTo(Canvas &other)
{
  assert(IsDefined());
  assert(!active || frame_buffer != NULL);

  OpenGL::glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);

  GLEnable scope(GL_TEXTURE_2D);
  texture->Bind();
  texture->DrawFlipped(other.GetRect(), GetRect());
}
Example #6
0
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 UPixelScalar 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);
    }
  }
}
Example #7
0
void
BufferCanvas::CopyTo(Canvas &other)
{
  assert(IsDefined());
  assert(!active || frame_buffer != nullptr);

#ifdef USE_GLSL
  OpenGL::texture_shader->Use();
#else
  const GLEnable<GL_TEXTURE_2D> scope;
  OpenGL::glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
#endif

  texture->Bind();
  texture->DrawFlipped(other.GetRect(), GetRect());
}
Example #8
0
void
WndButton::OnPaint(Canvas &canvas)
{
  const bool pressed = IsDown();
  const bool focused = HasCursorKeys() ? HasFocus() : pressed;

  PixelRect rc = canvas.GetRect();
  renderer.DrawButton(canvas, rc, focused, pressed);

  // If button has text on it
  const tstring caption = GetText();
  if (caption.empty())
    return;

  rc = renderer.GetDrawingRect(rc, pressed);

  canvas.SetBackgroundTransparent();
  if (!IsEnabled())
    canvas.SetTextColor(look.button.disabled.color);
  else if (focused)
    canvas.SetTextColor(look.button.focused.foreground_color);
  else
    canvas.SetTextColor(look.button.standard.foreground_color);

  canvas.Select(*(look.button.font));

#ifndef USE_GDI
  canvas.DrawFormattedText(&rc, caption.c_str(), GetTextStyle());
#else
  unsigned style = DT_CENTER | DT_NOCLIP | DT_WORDBREAK;

  PixelRect text_rc = rc;
  canvas.DrawFormattedText(&text_rc, caption.c_str(), style | DT_CALCRECT);
  text_rc.right = rc.right;

  PixelScalar offset = rc.bottom - text_rc.bottom;
  if (offset > 0) {
    offset /= 2;
    text_rc.top += offset;
    text_rc.bottom += offset;
  }

  canvas.DrawFormattedText(&text_rc, caption.c_str(), style);
#endif
}
Example #9
0
static void
Draw(Canvas &canvas)
{
  PixelRect rc = canvas.GetRect();
  rc.Grow(-0.2 * rc.GetSize().cx);
  
  /* draw the banner text with a large font */
  Font small_font;
  small_font.LoadFile("/opt/LK8000/share/fonts/DejaVuSansCondensed.ttf", (rc.GetSize().cy / 25));
  canvas.Select(small_font);
  canvas.SetTextColor(COLOR_BLACK);
  canvas.SetBackgroundTransparent();

  const TCHAR *const text = _T("Powered Off");
  const PixelSize text_size = canvas.CalcTextSize(text);
  const RasterPoint text_pos = {
      rc.left + 16,
      rc.bottom - 16 - text_size.cy
  };
  canvas.DrawText(text_pos.x, text_pos.y, text);
  
  Font big_font;
  big_font.LoadFile("/opt/LK8000/share/fonts/DejaVuSansCondensed-Bold.ttf", (rc.GetSize().cy / 10));
  canvas.Select(big_font);
  
  const TCHAR *const text2 = _T("LK8000");
  const PixelSize text2_size = canvas.CalcTextSize(text2);
  const RasterPoint text2_pos = {
      (rc.left + rc.GetSize().cx + text2_size.cx) / 2,
      (rc.top + (rc.GetSize().cy / 10))
  };
  canvas.DrawText(text2_pos.x, text2_pos.y, text2);
  
  const double Scale = (double)rc.GetSize().cx / (double)bird_size.cx;
  
  RasterPoint polygon[array_size(bird_polygon)] = {};
  std::transform(std::begin(bird_polygon), std::end(bird_polygon), std::begin(polygon), [Scale, rc, text2_size, text2_pos]( const RasterPoint& pt ) {
      return RasterPoint(pt.x*Scale + rc.left, pt.y*Scale + text2_pos.y + text2_size.cy);
  });
  
  canvas.SelectBlackBrush();
  canvas.DrawPolygon(polygon, array_size(polygon));
}
 virtual void OnPaint(Canvas &canvas) override {
   canvas.ClearWhite();
   renderer.Draw(canvas, canvas.GetRect(), calculated, glide_settings, true);
 }
Example #11
0
 virtual void OnPaint(Canvas &canvas) override {
   canvas.ClearWhite();
   HorizonRenderer::Draw(canvas, canvas.GetRect(), look, attitude);
 }