Beispiel #1
0
bool TModalDlg::show_modal()
{
      do_layout();
	  //mouse_capture(true);

    // center the dialog in the middle of its parent
      Rect rt;
      parent()->get_rect(rt,false);
      int x0 = rt.left, y0 = rt.top,
          W = (rt.right - rt.left), H = (rt.bottom - rt.top);
      get_client_rect(rt);
      move(x0 + (W - rt.right)/2, y0 + (H - rt.bottom)/2);

// show it, and go into the idle loop
      show(SW_SHOW);	  
	  run();
	  // close();
	  TWin::show(0); // hide the window!!
	  m_parent->set_focus();
      return m_modal_result;
}
Beispiel #2
0
/**
 * Handles the drawing of the moving map and is called by the DrawThread
 */
void
MapWindow::on_paint_buffer(Canvas &canvas)
{
#ifndef ENABLE_OPENGL
  unsigned render_generation = ui_generation;

  // Start the drawing timer (for drawing time calculation)
  StartTimer();
#endif

  // Render the moving map
  Render(canvas, get_client_rect());
  draw_sw.Finish();

#ifndef ENABLE_OPENGL
  /* save the generation number which was active when rendering had
     begun */
  buffer_projection = render_projection;
  buffer_generation = render_generation;
#endif
}
Beispiel #3
0
void
WndForm::OnPaint(Canvas &canvas)
{
  ContainerWindow::OnPaint(canvas);

  // Get window coordinates
  PixelRect rcClient = get_client_rect();

  // Draw the borders
  canvas.DrawRaisedEdge(rcClient);

  if (!caption.empty()) {
    // Set the colors
    canvas.SetTextColor(COLOR_WHITE);

    // Set the titlebar font and font-size
    canvas.Select(*look.caption.font);

    // JMW todo add here icons?

#ifdef EYE_CANDY
    canvas.SetBackgroundTransparent();
    canvas.stretch(title_rect.left, title_rect.top,
                   title_rect.right - title_rect.left,
                   title_rect.bottom - title_rect.top,
                   look.caption.background_bitmap);

    // Draw titlebar text
    canvas.text(title_rect.left + Layout::FastScale(2), title_rect.top,
                caption.c_str());
#else
    canvas.SetBackgroundColor(main_window.IsTopDialog(*this)
                              ? look.caption.background_color
                              : look.caption.inactive_background_color);
    canvas.text_opaque(title_rect.left + Layout::FastScale(2),
                       title_rect.top, title_rect, caption.c_str());
#endif
  }
}
Beispiel #4
0
void
ButtonWindow::on_paint(Canvas &canvas)
{
  if (has_focus()) {
    Pen pen(Layout::Scale(1), COLOR_BLACK);
    canvas.select(pen);
    canvas.hollow_brush();
    canvas.rectangle(-1, -1, canvas.get_width(), canvas.get_height());
  }

  PixelRect rc = { 2, 2, canvas.get_width()-4, canvas.get_height()-4 };
  if (down) {
    rc.left += Layout::FastScale(1);
    rc.top += Layout::FastScale(1);
  }

  canvas.draw_button(get_client_rect(), down);

  canvas.set_text_color(is_enabled() ? COLOR_BLACK : COLOR_GRAY);
  canvas.background_transparent();
  canvas.formatted_text(&rc, text.c_str(), get_text_style());
}
Beispiel #5
0
void
MenuBar::Button::on_paint(Canvas &canvas)
{
  canvas.fill_rectangle(0, 0, canvas.get_width(), canvas.get_height(),
                        menu_button_bk_color(is_enabled(), is_down()));

  canvas.set_text_color(is_enabled() ? Color::BLACK : Color::GRAY);
  canvas.background_transparent();

#ifndef ENABLE_SDL
  HFONT font = (HFONT)::SendMessage(hWnd, WM_GETFONT, 0, 0);
  if (font != NULL)
    ::SelectObject(canvas, font);
#endif

  RECT rc = get_client_rect();
  canvas.formatted_text(&rc, get_text().c_str(),
#ifdef ENABLE_SDL
                        DT_VCENTER |
#endif
                        DT_NOPREFIX | DT_CENTER |
                        DT_NOCLIP | DT_WORDBREAK);
}
Beispiel #6
0
// --------------------------------------------------------
// check if a screen point is "owned" by this button
// --------------------------------------------------------
bool t_button::is_contained( t_screen_point point ) const
{
	if (!is_point_in_rect( point, get_client_rect() ))
		return false;
	if (!m_has_transparency)
		return true;
	if (m_current_image == 0)
		return false;

	t_window_list::const_reverse_iterator it;
	t_screen_point screen_point = to_screen( point );

	// We're going to check ALL our children when evaluating if we want to claim
	// a point so that when the button changes state (like when it is clicked)
	// the answer doesn't suddenly change.
	for (it = get_children_rbegin(); it != get_children_rend(); it++)
	{
		if ( (*it)->is_contained( (*it)->to_client( screen_point ) ) )
			return true;
	}

	return false;
}
Beispiel #7
0
void
GlueMapWindow::QuickRedraw(const SETTINGS_MAP &_settings_map)
{
  assert(&_settings_map != &SettingsMap());

  ReadSettingsMap(_settings_map);

  /* update the Projection */

  visible_projection.CalculateOrigin(get_client_rect(),
                                     Basic(), Calculated(),
                                     SettingsComputer(),
                                     SettingsMap());

  visible_projection.ExchangeBlackboard(Calculated(), SettingsMap());

  ++ui_generation;

  /* quickly stretch the existing buffer into the window */

  scale_buffer = 2;
  invalidate();
}
Beispiel #8
0
void
WndForm::on_paint(Canvas &canvas)
{
  ContainerWindow::on_paint(canvas);

  // Get window coordinates
  PixelRect rcClient = get_client_rect();

  // Draw the borders
  canvas.raised_edge(rcClient);

  if (!mCaption.empty()) {
    // Set the colors
    canvas.set_text_color(COLOR_WHITE);

    // Set the titlebar font and font-size
    canvas.select(*look.caption.font);

    // JMW todo add here icons?

#ifdef EYE_CANDY
    canvas.background_transparent();
    canvas.stretch(mTitleRect.left, mTitleRect.top,
                   mTitleRect.right - mTitleRect.left,
                   mTitleRect.bottom - mTitleRect.top,
                   bitmap_title);

    // Draw titlebar text
    canvas.text(mTitleRect.left + Layout::FastScale(2), mTitleRect.top,
                mCaption.c_str());
#else
    canvas.set_background_color(look.caption.background_color);
    canvas.text_opaque(mTitleRect.left + Layout::FastScale(2),
                       mTitleRect.top, mTitleRect, mCaption.c_str());
#endif
  }
}
void
GlueMapWindow::UpdateProjection()
{
    const PixelRect rc = get_client_rect();

    /* not using MapWindowBlackboard here because these methods are
       called by the main thread */
    const NMEAInfo &basic = CommonInterface::Basic();
    const DerivedInfo &calculated = CommonInterface::Calculated();
    const MapSettings &settings_map = CommonInterface::GetMapSettings();

    RasterPoint center;
    center.x = (rc.left + rc.right) / 2;
    center.y = (rc.top + rc.bottom) / 2;

    if (GetDisplayMode() == DM_CIRCLING || !IsNearSelf())
        visible_projection.SetScreenOrigin(center.x, center.y);
    else if (settings_map.cruise_orientation == NORTHUP) {
        RasterPoint offset{0, 0};
        if (settings_map.glider_screen_position != 50 &&
                settings_map.map_shift_bias != MAP_SHIFT_BIAS_NONE) {
            fixed x = fixed_zero;
            fixed y = fixed_zero;
            if (settings_map.map_shift_bias == MAP_SHIFT_BIAS_TRACK) {
                if (basic.track_available &&
                        basic.ground_speed_available &&
                        /* 8 m/s ~ 30 km/h */
                        basic.ground_speed > fixed_int_constant(8)) {
                    const auto sc = basic.track.Reciprocal().SinCos();
                    x = sc.first;
                    y = sc.second;
                }
            } else if (settings_map.map_shift_bias == MAP_SHIFT_BIAS_TARGET) {
                if (calculated.task_stats.current_leg.solution_remaining.IsDefined()) {
                    const auto sc =calculated.task_stats.current_leg.solution_remaining
                                   .vector.bearing.Reciprocal().SinCos();
                    x = sc.first;
                    y = sc.second;
                }
            }
            fixed gspFactor = (fixed) (50 - settings_map.glider_screen_position) / 100;
            offset.x = PixelScalar(x * (rc.right - rc.left) * gspFactor);
            offset.y = PixelScalar(y * (rc.top - rc.bottom) * gspFactor);
            offsetHistory.add(offset);
            offset = offsetHistory.average();
        }
        visible_projection.SetScreenOrigin(center.x + offset.x, center.y + offset.y);
    } else
        visible_projection.SetScreenOrigin(center.x,
                                           ((rc.top - rc.bottom) * settings_map.glider_screen_position / 100) + rc.bottom);

    if (!IsNearSelf()) {
        /* no-op - the Projection's location is updated manually */
    } else if (GetDisplayMode() == DM_CIRCLING &&
               calculated.thermal_locator.estimate_valid) {
        const fixed d_t = calculated.thermal_locator.estimate_location.Distance(basic.location);
        if (!positive(d_t)) {
            SetLocationLazy(basic.location);
        } else {
            const fixed d_max = Double(visible_projection.GetMapScale());
            const fixed t = std::min(d_t, d_max)/d_t;
            SetLocation(basic.location.Interpolate(calculated.thermal_locator.estimate_location,
                                                   t));
        }
    } else
        // Pan is off
        SetLocationLazy(basic.location);

    visible_projection.UpdateScreenBounds();
}
Beispiel #10
0
/**
 * Draws the FLARM traffic icons onto the given canvas
 * @param canvas Canvas for drawing
 */
void
MapWindow::DrawFLARMTraffic(Canvas &canvas,
                            const RasterPoint aircraft_pos) const
{
  // Return if FLARM icons on moving map are disabled
  if (!GetMapSettings().show_flarm_on_map)
    return;

  // Return if FLARM data is not available
  const FlarmState &flarm = Basic().flarm;
  if (!flarm.available)
    return;

  const WindowProjection &projection = render_projection;

  // if zoomed in too far out, dont draw traffic since it will be too close to
  // the glider and so will be meaningless (serves only to clutter, cant help
  // the pilot)
  if (projection.GetMapScale() > fixed_int_constant(7300))
    return;

  // Circle through the FLARM targets
  for (auto it = flarm.traffic.begin(), end = flarm.traffic.end();
      it != end; ++it) {
    const FlarmTraffic &traffic = *it;

    if (!traffic.location_available)
      continue;

    // Save the location of the FLARM target
    GeoPoint target_loc = traffic.location;

    // Points for the screen coordinates for the icon, name and average climb
    RasterPoint sc, sc_name, sc_av;

    // If FLARM target not on the screen, move to the next one
    if (!projection.GeoToScreenIfVisible(target_loc, sc))
      continue;

    // Draw the name 16 points below the icon
    sc_name = sc;
    sc_name.y -= Layout::Scale(20);

    // Draw the average climb value above the icon
    sc_av = sc;
    sc_av.y += Layout::Scale(5);

    TextInBoxMode mode;
    mode.mode = RM_OUTLINED;

    // JMW TODO enhancement: decluttering of FLARM altitudes (sort by max lift)

    int dx = sc_av.x - aircraft_pos.x;
    int dy = sc_av.y - aircraft_pos.y;

    // only draw labels if not close to aircraft
    if (dx * dx + dy * dy > Layout::Scale(30 * 30)) {
      // If FLARM callsign/name available draw it to the canvas
      if (traffic.HasName() && !StringIsEmpty(traffic.name))
        TextInBox(canvas, traffic.name, sc_name.x, sc_name.y,
                  mode, get_client_rect());

      if (traffic.climb_rate_avg30s >= fixed(0.1)) {
        // If average climb data available draw it to the canvas
        TCHAR label_avg[100];
        Units::FormatUserVerticalSpeed(traffic.climb_rate_avg30s,
                                       label_avg, false);
        TextInBox(canvas, label_avg, sc_av.x, sc_av.y, mode, get_client_rect());
      }
    }

    TrafficRenderer::Draw(canvas, traffic_look, traffic,
                          traffic.track - projection.GetScreenAngle(), sc);
  }
}
Beispiel #11
0
static void Win_WarpMouse( int x, int y ) {
    RECT rc;

    get_client_rect( win.wnd, &rc );
    SetCursorPos( rc.left + x, rc.top + y );
}
Beispiel #12
0
void
ChartControl::on_paint(Canvas &canvas)
{
    assert(glide_computer != NULL);

    const SETTINGS_COMPUTER &settings_computer = blackboard->SettingsComputer();
    const SETTINGS_MAP &settings_map = blackboard->SettingsMap();
    const MoreData &basic = blackboard->Basic();
    const DerivedInfo &calculated = blackboard->Calculated();

#ifdef ENABLE_OPENGL
    /* enable clipping */
    GLCanvasScissor scissor(canvas);
#endif

    canvas.clear(COLOR_WHITE);
    canvas.set_text_color(COLOR_BLACK);
    canvas.select(Fonts::Map);

    PixelRect rcgfx = get_client_rect();

    // background is painted in the base-class

    const FlightStatisticsRenderer fs(glide_computer->GetFlightStats(),
                                      chart_look, airspace_look,
                                      aircraft_look, task_look);

    switch (page) {
    case ANALYSIS_PAGE_BAROGRAPH:
        fs.RenderBarograph(canvas, rcgfx, basic,
                           calculated, protected_task_manager);
        break;
    case ANALYSIS_PAGE_CLIMB:
        fs.RenderClimb(canvas, rcgfx, settings_computer.glide_polar_task);
        break;
    case ANALYSIS_PAGE_THERMAL_BAND:
    {
        OrderedTaskBehaviour otb;
        if (protected_task_manager != NULL) {
            otb = protected_task_manager->get_ordered_task_behaviour();
        }

        ThermalBandRenderer renderer(thermal_band_look, chart_look);
        renderer.DrawThermalBand(basic,
                                 calculated,
                                 settings_computer,
                                 canvas, rcgfx,
                                 settings_computer.task,
                                 false,
                                 &otb);
    }
    break;
    case ANALYSIS_PAGE_WIND:
        fs.RenderWind(canvas, rcgfx, basic,
                      glide_computer->GetWindStore());
        break;
    case ANALYSIS_PAGE_POLAR:
        fs.RenderGlidePolar(canvas, rcgfx, calculated.climb_history,
                            settings_computer,
                            settings_computer.glide_polar_task);
        break;
    case ANALYSIS_PAGE_TEMPTRACE:
        fs.RenderTemperature(canvas, rcgfx);
        break;
    case ANALYSIS_PAGE_TASK:
        if (protected_task_manager != NULL) {
            const TraceComputer *trace_computer = glide_computer != NULL
                                                  ? &glide_computer->GetTraceComputer()
                                                  : NULL;
            fs.RenderTask(canvas, rcgfx, basic, calculated,
                          settings_computer, settings_map,
                          *protected_task_manager,
                          trace_computer);
        }
        break;
    case ANALYSIS_PAGE_OLC:
        if (glide_computer != NULL) {
            TracePointVector trace;
            glide_computer->LockedCopyTraceTo(trace);

            fs.RenderOLC(canvas, rcgfx, basic, calculated,
                         settings_computer, settings_map,
                         calculated.contest_stats, trace);
        }
        break;
    case ANALYSIS_PAGE_TASK_SPEED:
        if (protected_task_manager != NULL) {
            ProtectedTaskManager::Lease task(*protected_task_manager);
            fs.RenderSpeed(canvas, rcgfx, basic,
                           calculated, task);
        }
        break;
    default:
        // should never get here!
        break;
    }
}
Beispiel #13
0
void
WndSymbolButton::on_paint(Canvas &canvas)
{
#ifdef HAVE_CLIPPING
    /* background and selector */
    canvas.clear(look.background_brush);
#endif

    // Get button PixelRect and shrink it to make room for the selector/focus
    PixelRect rc = get_client_rect();

    // Draw button to the background
    canvas.draw_button(rc, is_down());

    // Draw focus rectangle
    if (has_focus()) {
        PixelRect focus_rc = rc;
        InflateRect(&focus_rc, -3, -3);
        canvas.draw_focus(focus_rc);
    }

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

    // If button is pressed, offset the text for 3D effect
    if (is_down())
        OffsetRect(&rc, 1, 1);

    canvas.null_pen();
    if (is_enabled())
        canvas.black_brush();
    else
        canvas.select(disabled_brush);

    const char ch = (char)caption[0];

    // Draw arrow symbols instead of < and >
    if (ch == '<' || ch == '>') {
        int size = min(rc.right - rc.left, rc.bottom - rc.top) / 5;

        RasterPoint Arrow[3];
        Arrow[0].x = (rc.left + rc.right) / 2 + (ch == '<' ? size : -size);
        Arrow[0].y = (rc.top + rc.bottom) / 2 + size;
        Arrow[1].x = (rc.left + rc.right) / 2 + (ch == '<' ? -size : size);
        Arrow[1].y = (rc.top + rc.bottom) / 2;
        Arrow[2].x = (rc.left + rc.right) / 2 + (ch == '<' ? size : -size);
        Arrow[2].y = (rc.top + rc.bottom) / 2 - size;

        canvas.TriangleFan(Arrow, 3);
    }

    // Draw arrow symbols instead of v and ^
    else if (ch == '^' || ch == 'v') {
        int size = min(rc.right - rc.left, rc.bottom - rc.top) / 5;

        RasterPoint Arrow[3];
        Arrow[0].x = (rc.left + rc.right) / 2 +
                     size;
        Arrow[0].y = (rc.top + rc.bottom) / 2 +
                     (ch == '^' ? size : -size);
        Arrow[1].x = (rc.left + rc.right) / 2;
        Arrow[1].y = (rc.top + rc.bottom) / 2 +
                     (ch == '^' ? -size : size);
        Arrow[2].x = (rc.left + rc.right) / 2 - size;
        Arrow[2].y = (rc.top + rc.bottom) / 2 +
                     (ch == '^' ? size : -size);

        canvas.TriangleFan(Arrow, 3);
    }

    // Draw symbols instead of + and -
    else if (ch == '+' || ch == '-') {
        int size = min(rc.right - rc.left, rc.bottom - rc.top) / 5;

        canvas.rectangle((rc.left + rc.right) / 2 - size,
                         (rc.top + rc.bottom) / 2 - size / 3,
                         (rc.left + rc.right) / 2 + size,
                         (rc.top + rc.bottom) / 2 + size / 3);

        if (ch == '+')
            canvas.rectangle((rc.left + rc.right) / 2 - size / 3,
                             (rc.top + rc.bottom) / 2 - size,
                             (rc.left + rc.right) / 2 + size / 3,
                             (rc.top + rc.bottom) / 2 + size);
    }

    // Draw Fly bitmap
    else if (caption == _T("Fly")) {
        Bitmap launcher1_bitmap(IDB_LAUNCHER1);
        canvas.clear_white();
        if (is_down())
            canvas.invert_stretch_transparent(launcher1_bitmap, COLOR_YELLOW);
        else
            canvas.stretch_transparent(launcher1_bitmap, COLOR_BLUE);
    }

    // Draw Simulator bitmap
    else if (caption == _T("Simulator")) {
        Bitmap launcher2_bitmap(IDB_LAUNCHER2);
        canvas.clear_white();
        if (is_down())
            canvas.invert_stretch_transparent(launcher2_bitmap, COLOR_YELLOW);
        else
            canvas.stretch_transparent(launcher2_bitmap, COLOR_BLUE);
    }

    else if (caption == _T("Green")) {
        InflateRect(&rc, -3, -3);
        canvas.fill_rectangle(rc, Color(0x74, 0xFF, 0));
    } else if (caption == _T("Blue")) {
        InflateRect(&rc, -3, -3);
        canvas.fill_rectangle(rc, Color(0, 0x90, 0xFF));
    } else if (caption == _T("Magenta")) {
        InflateRect(&rc, -3, -3);
        canvas.fill_rectangle(rc, Color(0xFF, 0, 0xCB));
    } else if (caption == _T("Yellow")) {
        InflateRect(&rc, -3, -3);
        canvas.fill_rectangle(rc, Color(0xFF, 0xE8, 0));
    }
}
Beispiel #14
0
void
WndProperty::on_paint(Canvas &canvas)
{
  const bool focused = edit.has_focus();

  /* background and selector */
  if (focused) {
    canvas.clear(look.focused.background_color);
    PaintSelector(canvas, get_client_rect(), look);
  } else {
    /* don't need to erase the background when it has been done by the
       parent window already */
    if (have_clipping())
      canvas.clear(look.background_color);
  }

  WindowControl::on_paint(canvas);

  /* kludge: don't draw caption if width is too small (but not 0),
     used by the polar configuration panel.  This concept needs to be
     redesigned. */
  if (mCaptionWidth != 0 && !mCaption.empty()) {
    canvas.set_text_color(focused
                          ? look.focused.text_color
                          : look.text_color);
    canvas.background_transparent();
    canvas.select(*GetFont());

    PixelSize tsize = canvas.text_size(mCaption.c_str());

    RasterPoint org;
    if (mCaptionWidth < 0) {
      org.x = mEditPos.x;
      org.y = mEditPos.y - tsize.cy;
    } else {
      org.x = mCaptionWidth - mBitmapSize - (tsize.cx + 1);
      org.y = (get_size().cy - tsize.cy) / 2;
    }

    if (org.x < 1)
      org.x = 1;

    if (have_clipping())
      canvas.text(org.x, org.y, mCaption.c_str());
    else
      canvas.text_clipped(org.x, org.y, mCaptionWidth - org.x,
                          mCaption.c_str());
  }

  // can't but dlgComboPicker here b/c it calls paint when combopicker closes too
  // so it calls dlgCombopicker on the click/focus handlers for the wndproperty & label
  if (!mDialogStyle && edit.has_focus() && !edit.is_read_only()) {
    canvas.stretch(mHitRectDown.left, mHitRectDown.top,
                   mBitmapSize, mBitmapSize,
                   hBmpLeft32,
                   mDownDown ? 32 : 0, 0, 32, 32);

    canvas.stretch(mHitRectUp.left, mHitRectUp.top,
                   mBitmapSize, mBitmapSize,
                   hBmpRight32,
                   mUpDown ? 32 : 0, 0, 32, 32);
  }
}
Beispiel #15
0
/**
 * Draws the FLARM traffic icons onto the given canvas
 * @param canvas Canvas for drawing
 */
void
MapWindow::DrawFLARMTraffic(Canvas &canvas,
                            const RasterPoint aircraft_pos) const
{
  // Return if FLARM icons on moving map are disabled
  if (!SettingsMap().EnableFLARMMap)
    return;

  // Return if FLARM data is not available
  const FLARM_STATE &flarm = Basic().flarm;
  if (!flarm.available)
    return;

  const MapWindowProjection &projection = render_projection;

  // Create point array that will form that arrow polygon
  RasterPoint Arrow[5];

  // Circle through the FLARM targets
  for (unsigned i = 0; i < flarm.traffic.size(); i++) {
    const FLARM_TRAFFIC &traffic = flarm.traffic[i];

    if (!traffic.location_available)
      continue;

    // Save the location of the FLARM target
    GeoPoint target_loc = traffic.location;

    // Points for the screen coordinates for the icon, name and average climb
    RasterPoint sc, sc_name, sc_av;

    // If FLARM target not on the screen, move to the next one
    if (!projection.GeoToScreenIfVisible(target_loc, sc))
      continue;

    // Draw the name 16 points below the icon
    sc_name = sc;
    sc_name.y -= Layout::Scale(20);

    // Draw the average climb value above the icon
    sc_av = sc;
    sc_av.y += Layout::Scale(5);

    TextInBoxMode_t mode;
    mode.Mode = Outlined;

    // JMW TODO enhancement: decluttering of FLARM altitudes (sort by max lift)

    int dx = sc_av.x - aircraft_pos.x;
    int dy = sc_av.y - aircraft_pos.y;

    // only draw labels if not close to aircraft
    if (dx * dx + dy * dy > Layout::Scale(30 * 30)) {
      // If FLARM callsign/name available draw it to the canvas
      if (traffic.HasName() && !string_is_empty(traffic.name))
        TextInBox(canvas, traffic.name, sc_name.x, sc_name.y,
                  mode, get_client_rect());

      if (traffic.climb_rate_avg30s >= fixed(0.1)) {
        // If average climb data available draw it to the canvas
        TCHAR label_avg[100];
        Units::FormatUserVSpeed(traffic.climb_rate_avg30s, label_avg, 100, false);
        TextInBox(canvas, label_avg, sc_av.x, sc_av.y, mode, get_client_rect());
      }
    }

    // If FLARM alarm draw alarm icon below corresponding target
    if ((traffic.alarm_level > 0) && (traffic.alarm_level < 4))
      Graphics::hFLARMTraffic.draw(canvas, sc);

    // Fill the Arrow array with a normal arrow pointing north
    Arrow[0].x = -4;
    Arrow[0].y = 6;
    Arrow[1].x = 0;
    Arrow[1].y = -8;
    Arrow[2].x = 4;
    Arrow[2].y = 6;
    Arrow[3].x = 0;
    Arrow[3].y = 3;
    Arrow[4].x = -4;
    Arrow[4].y = 6;

    // Select brush depending on AlarmLevel
    switch (traffic.alarm_level) {
    case 1:
      canvas.select(Graphics::WarningBrush);
      break;
    case 2:
    case 3:
      canvas.select(Graphics::AlarmBrush);
      break;
    case 0:
    case 4:
      canvas.select(Graphics::TrafficBrush);
      break;
    }

    // Select black pen
    canvas.black_pen();

    // Rotate and shift the arrow to the right position and angle
    PolygonRotateShift(Arrow, 5, sc.x, sc.y,
                       traffic.track - projection.GetScreenAngle());

    // Draw the arrow
    canvas.polygon(Arrow, 5);
  }
}
Beispiel #16
0
void
WndSymbolButton::on_paint(Canvas &canvas)
{
  /* background and selector */
  canvas.clear(background_brush);

  // Get button RECT and shrink it to make room for the selector/focus
  RECT rc = get_client_rect();

  // Draw button to the background
  canvas.draw_button(rc, is_down());

  // Draw focus rectangle
  if (has_focus()) {
    RECT focus_rc = rc;
    InflateRect(&focus_rc, -3, -3);
    canvas.draw_focus(focus_rc);
  }

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

  // If button is pressed, offset the text for 3D effect
  if (is_down())
    OffsetRect(&rc, 1, 1);

  canvas.null_pen();
  canvas.black_brush();

  const char ch = (char)caption[0];

  // Draw arrow symbols instead of < and >
  if (ch == '<' || ch == '>') {
    int size = min(rc.right - rc.left, rc.bottom - rc.top) / 5;

    static RasterPoint Arrow[4];
    Arrow[0].x = (rc.left + rc.right) / 2 + (ch == '<' ? size : -size);
    Arrow[0].y = (rc.top + rc.bottom) / 2 + size;
    Arrow[1].x = (rc.left + rc.right) / 2 + (ch == '<' ? -size : size);
    Arrow[1].y = (rc.top + rc.bottom) / 2;
    Arrow[2].x = (rc.left + rc.right) / 2 + (ch == '<' ? size : -size);
    Arrow[2].y = (rc.top + rc.bottom) / 2 - size;
    Arrow[3].x = Arrow[0].x;
    Arrow[3].y = Arrow[0].y;

    canvas.polygon(Arrow, 4);
  }

  // Draw arrow symbols instead of v and ^
  if (ch == '^' || ch == 'v') {
    int size = min(rc.right - rc.left, rc.bottom - rc.top) / 5;

    RasterPoint Arrow[3];
    Arrow[0].x = (rc.left + rc.right) / 2 +
                 size;
    Arrow[0].y = (rc.top + rc.bottom) / 2 +
                 (ch == '^' ? size : -size);
    Arrow[1].x = (rc.left + rc.right) / 2;
    Arrow[1].y = (rc.top + rc.bottom) / 2 +
                 (ch == '^' ? -size : size);
    Arrow[2].x = (rc.left + rc.right) / 2 - size;
    Arrow[2].y = (rc.top + rc.bottom) / 2 +
                 (ch == '^' ? size : -size);

    canvas.polygon(Arrow, 3);
  }

  // Draw symbols instead of + and -
  if (ch == '+' || ch == '-') {
    int size = min(rc.right - rc.left, rc.bottom - rc.top) / 5;

    canvas.rectangle((rc.left + rc.right) / 2 - size,
                     (rc.top + rc.bottom) / 2 - size / 3,
                     (rc.left + rc.right) / 2 + size,
                     (rc.top + rc.bottom) / 2 + size / 3);

    if (ch == '+')
      canvas.rectangle((rc.left + rc.right) / 2 - size / 3,
                       (rc.top + rc.bottom) / 2 - size,
                       (rc.left + rc.right) / 2 + size / 3,
                       (rc.top + rc.bottom) / 2 + size);
  }

  // Draw Fly bitmap
  if (caption == _T("Fly")) {
    Bitmap launcher1_bitmap(IDB_LAUNCHER1);
    if (is_down())
      canvas.stretch(launcher1_bitmap);
    else {
      canvas.clear_white();
      canvas.stretch_transparent(launcher1_bitmap, Color::BLUE);
    }
  }

  // Draw Simulator bitmap
  if (caption == _T("Simulator")) {
    Bitmap launcher2_bitmap(IDB_LAUNCHER2);
    if (is_down())
      canvas.stretch(launcher2_bitmap);
    else {
      canvas.clear_white();
      canvas.stretch_transparent(launcher2_bitmap, Color::BLUE);
    }
  }

}
Beispiel #17
0
void
MainWindow::ReinitialiseLayout()
{
  if (!map.defined()) {
#ifdef ANDROID
    if (has_dialog())
      dialogs.top()->ReinitialiseLayout();  // adapt simulator prompt
#endif
    /* without the MapWindow, it is safe to assume that the MainWindow
       is just being initialized, and the InfoBoxes aren't initialized
       yet either, so there is nothing to do here */
    return;
  }

#ifndef ENABLE_SDL
  if (draw_thread == NULL)
    /* no layout changes during startup */
    return;
#endif

  InfoBoxManager::Destroy();

  PixelRect rc = get_client_rect();
  InfoBoxLayout::Init(rc);
  const InfoBoxLayout::Layout ib_layout =
    InfoBoxLayout::Calculate(rc, InfoBoxLayout::InfoBoxGeometry);

  Fonts::SizeInfoboxFont(ib_layout.control_width);

  InfoBoxManager::Create(rc, ib_layout);
  map_rect = ib_layout.remaining;

  popup.reset();
  popup.set(rc);

  if (vario != NULL)
    vario->move(rc.right - ib_layout.control_width, 0,
                ib_layout.control_width,
                ib_layout.control_height * 3);

  if (flarm != NULL)
    flarm->move(rc.right - ib_layout.control_width * 2 + 1,
                rc.bottom - ib_layout.control_height * 2 + 1,
                ib_layout.control_width * 2 - 1,
                ib_layout.control_height * 2 - 1);

  if (ta != NULL) {
    unsigned sz = std::min(ib_layout.control_height,
                           ib_layout.control_width) * 2;
    ta->move(0, rc.bottom - sz, sz, sz);
  }

  if (!FullScreen) {
    map.move(map_rect.left, map_rect.top,
             map_rect.right - map_rect.left,
             map_rect.bottom - map_rect.top);
    map.FullRedraw();
  }

#ifdef ANDROID
  // move topmost dialog to fit into the current layout, or close it
  if (has_dialog())
    dialogs.top()->ReinitialiseLayout();
#endif

  map.BringToBottom();
}
Beispiel #18
0
void
ChartControl::OnPaint(Canvas &canvas)
{
  assert(glide_computer != NULL);

  const ComputerSettings &settings_computer = blackboard->GetComputerSettings();
  const MapSettings &settings_map = blackboard->GetMapSettings();
  const MoreData &basic = blackboard->Basic();
  const DerivedInfo &calculated = blackboard->Calculated();

#ifdef ENABLE_OPENGL
  /* enable clipping */
  GLCanvasScissor scissor(canvas);
#endif

  canvas.clear(COLOR_WHITE);
  canvas.SetTextColor(COLOR_BLACK);

  PixelRect rcgfx = get_client_rect();

  // background is painted in the base-class

  switch (page) {
  case ANALYSIS_PAGE_BAROGRAPH:
    RenderBarograph(canvas, rcgfx, chart_look, look->cross_section,
                    glide_computer->GetFlightStats(),
                    basic, calculated, protected_task_manager);
    break;
  case ANALYSIS_PAGE_CLIMB:
    RenderClimbChart(canvas, rcgfx, chart_look,
                     glide_computer->GetFlightStats(),
                     settings_computer.polar.glide_polar_task);
    break;
  case ANALYSIS_PAGE_THERMAL_BAND:
  {
    OrderedTaskBehaviour otb;
    if (protected_task_manager != NULL) {
      otb = protected_task_manager->GetOrderedTaskBehaviour();
    }

    ThermalBandRenderer renderer(thermal_band_look, chart_look);
    renderer.DrawThermalBand(basic,
                             calculated,
                             settings_computer,
                             canvas, rcgfx,
                             settings_computer.task,
                             false,
                             &otb);
  }
    break;
  case ANALYSIS_PAGE_WIND:
    RenderWindChart(canvas, rcgfx, chart_look,
                    glide_computer->GetFlightStats(),
                    basic, glide_computer->GetWindStore());
    break;
  case ANALYSIS_PAGE_POLAR:
    RenderGlidePolar(canvas, rcgfx, look->chart,
                     calculated.climb_history,
                     settings_computer,
                     settings_computer.polar.glide_polar_task);
    break;
  case ANALYSIS_PAGE_TEMPTRACE:
    RenderTemperatureChart(canvas, rcgfx, chart_look,
                           glide_computer->GetCuSonde());
    break;
  case ANALYSIS_PAGE_TASK:
    if (protected_task_manager != NULL) {
      const TraceComputer *trace_computer = glide_computer != NULL
        ? &glide_computer->GetTraceComputer()
        : NULL;
      const FlightStatisticsRenderer fs(glide_computer->GetFlightStats(),
                                        chart_look, look->map);
      fs.RenderTask(canvas, rcgfx, basic, calculated,
                    settings_computer, settings_map,
                    *protected_task_manager,
                    trace_computer);
    }
    break;
  case ANALYSIS_PAGE_OLC:
    if (glide_computer != NULL) {
      const FlightStatisticsRenderer fs(glide_computer->GetFlightStats(),
                                        chart_look, look->map);
      fs.RenderOLC(canvas, rcgfx, basic, calculated,
                   settings_computer, settings_map,
                   calculated.contest_stats,
                   glide_computer->GetTraceComputer());
    }
    break;
  case ANALYSIS_PAGE_TASK_SPEED:
    if (protected_task_manager != NULL) {
      ProtectedTaskManager::Lease task(*protected_task_manager);
      RenderSpeed(canvas, rcgfx, chart_look,
                  glide_computer->GetFlightStats(),
                  basic, calculated, task);
    }
    break;
  default:
    // should never get here!
    break;
  }
}