コード例 #1
0
ファイル: Fonts.cpp プロジェクト: Tjeerdm/XCSoarDktjm
void
Fonts::SizeInfoboxFont(UPixelScalar control_width)
{
  LOGFONT lf = log_infobox;

  if (!IsAltair())
    SizeLogFont(lf, control_width, _T("1234m"));
  infobox.Load(lf);

#ifndef GNAV
  unsigned height = lf.lfHeight;
  lf = log_infobox_units;
  lf.lfHeight = (height * 2) / 5;
  infobox_units.Load(lf);
#endif

  lf = log_infobox_small;
  if (!IsAltair())
    SizeLogFont(lf, control_width, _T("12345m"));
  infobox_small.Load(lf);

#ifdef ENABLE_OPENGL
  TextCache::Flush();
#endif
}
コード例 #2
0
ファイル: TaskEditPanel.cpp プロジェクト: Tjeerdm/XCSoarDktjm
bool
TaskEditPanel::OnKeyDown(unsigned key_code)
{
  switch (key_code){
  case KEY_ESCAPE:
    if (IsAltair() && GetList().HasFocus()){
       dialog.FocusFirstControl();
      return true;
    }
    return false;

  case '6': /* F5 */
    if (IsAltair()) {
      MoveUp();
      return true;
    } else
      return false;

  case '7': /* F6 */
    if (IsAltair()) {
      MoveDown();
      return true;
    } else
      return false;

  default:
    return false;
  }
}
コード例 #3
0
ファイル: TaskEditPanel.cpp プロジェクト: osteocool/XCSoar-1
bool
TaskEditPanel::OnKeyDown(unsigned key_code)
{
  switch (key_code){
  case VK_ESCAPE:
    if (IsAltair() && wTaskPoints->HasFocus()){
       wf.FocusFirstControl();
      return true;
    }
    return false;

  case '6': /* F5 */
    if (IsAltair()) {
      MoveUp();
      return true;
    } else
      return false;

  case '7': /* F6 */
    if (IsAltair()) {
      MoveDown();
      return true;
    } else
      return false;

  default:
    return false;
  }
}
コード例 #4
0
ファイル: AutoFont.cpp プロジェクト: Adrien81/XCSoar
void
AutoSizeInfoBoxFonts(FontSettings &settings, unsigned control_width)
{
  if (!IsAltair())
    AutoSizeFont(settings.infobox, control_width, _T("1234m"));

#ifndef GNAV
  settings.infobox_units.lfHeight = unsigned(settings.infobox.lfHeight) * 2u / 5u;
#endif

  if (!IsAltair())
    AutoSizeFont(settings.infobox_small, control_width, _T("12345m"));
}
コード例 #5
0
ファイル: Float.cpp プロジェクト: DRIZO/xcsoar
fixed
DataFieldFloat::SpeedUp(bool keyup)
{
  if (IsAltair())
    return fixed(1);

  if (keyup != DataFieldKeyUp) {
    mSpeedup = 0;
    DataFieldKeyUp = keyup;
    last_step.Update();
    return fixed(1);
  }

  if (!last_step.Check(200)) {
    mSpeedup++;
    if (mSpeedup > 5) {
      last_step.UpdateWithOffset(350);
      return fixed(10);
    }
  } else
    mSpeedup = 0;

  last_step.Update();

  return fixed(1);
}
コード例 #6
0
ファイル: Integer.cpp プロジェクト: pascaltempez/xcsoar
int
DataFieldInteger::SpeedUp(bool keyup)
{
  int res = 1;

  if (IsAltair())
    return res;

  if (GetDisableSpeedUp() == true)
    return 1;

  if (keyup != DataFieldKeyUp) {
    mSpeedup = 0;
    DataFieldKeyUp = keyup;
    last_step.update();
    return 1;
  }

  if (!last_step.check(200)) {
    mSpeedup++;
    if (mSpeedup > 5) {
      res = 10;
      last_step.update_offset(350);
      return (res);
    }
  } else
    mSpeedup = 0;

  last_step.update();

  return res;
}
コード例 #7
0
ファイル: ComputerSettings.cpp プロジェクト: StefanL74/XCSoar
void
ComputerSettings::SetDefaults()
{
  wind.SetDefaults();
  polar.SetDefaults();
  team_code.SetDefaults();
  voice.SetDefaults();
  poi.SetDefaults();
  features.SetDefaults();
  circling.SetDefaults();

  average_eff_time = ae30seconds;
  set_system_time_from_gps = IsAltair() && IsEmbedded();
  utc_offset = GetSystemUTCOffset();
  forecast_temperature = CelsiusToKelvin(fixed(25));
  pressure = AtmosphericPressure::Standard();
  pressure_available.Clear();
  airspace.SetDefaults();
  task.SetDefaults();
  contest.SetDefaults();
  logger.SetDefaults();

#ifdef HAVE_TRACKING
  tracking.SetDefaults();
#endif
}
コード例 #8
0
ファイル: InputEvents.cpp プロジェクト: MindMil/XCSoar
bool
InputEvents::ProcessKey(Mode mode, unsigned key_code)
{
  if (IsAltair() && key_code == 0xF5) {
    UIActions::SignalShutdown(false);
    return true;
  }

  if (!global_running)
    return false;

#ifdef KOBO
#ifdef ENABLE_SDL
  if (key_code == SDLK_POWER)
    /* the Kobo power button opens the main menu */
    key_code = KEY_MENU;
#else
  // TODO: check the console key code
#endif
#endif

  // Which key - can be defined locally or at default (fall back to default)
  unsigned event_id = key_to_event(mode, overlay_mode, key_code);
  if (event_id == 0)
    return false;

  ProcessEvent(event_id);
  return true;
}
コード例 #9
0
ファイル: Integer.cpp プロジェクト: CnZoom/XcSoarWork
int
DataFieldInteger::SpeedUp(bool keyup)
{
  int res = 1;

  if (IsAltair())
    return res;

  if (keyup != datafield_key_up) {
    speedup = 0;
    datafield_key_up = keyup;
    last_step.Update();
    return 1;
  }

  if (!last_step.Check(200)) {
    speedup++;
    if (speedup > 5) {
      res = 10;
      last_step.UpdateWithOffset(350);
      return (res);
    }
  } else
    speedup = 0;

  last_step.Update();

  return res;
}
コード例 #10
0
ファイル: Profile.cpp プロジェクト: CnZoom/XcSoarPull
void
Profile::SetFiles(const TCHAR *override_path)
{
  /* set the "modified" flag, because we are potentially saving to a
     new file now */
  SetModified(true);

  if (!StringIsEmpty(override_path)) {
    if (IsBaseName(override_path)) {
      LocalPath(startProfileFile, override_path);

      if (StringFind(override_path, '.') == nullptr)
        _tcscat(startProfileFile, _T(".prf"));
    } else
      CopyString(startProfileFile, override_path, MAX_PATH);
    return;
  }

  // Set the default profile file
  LocalPath(startProfileFile, _T(XCSPROFILE));

  if (IsAltair() && !File::Exists(startProfileFile)) {
    /* backwards compatibility with old Altair firmware */
    LocalPath(startProfileFile, _T("config/") _T(OLDXCSPROFILE));
    if (!File::Exists(startProfileFile))
      LocalPath(startProfileFile, _T(XCSPROFILE));
  }
}
コード例 #11
0
ファイル: InputDefaults.cpp プロジェクト: RBE-Avionik/xcsoar
// Read the data files
void
InputEvents::LoadDefaults(InputConfig &input_config)
{
    // Get defaults
    input_config.SetDefaults();

    if (IsAltair()) {
#include "InputEvents_altair.cpp"
        apply_defaults(input_config,
                       default_modes,
                       default_events,
                       ARRAY_SIZE(default_events),
                       default_gesture2event,
                       default_key2event, default_gc2event, default_n2event,
                       default_labels);
    } else {
#include "InputEvents_default.cpp"
        apply_defaults(input_config,
                       default_modes,
                       default_events,
                       ARRAY_SIZE(default_events),
                       default_gesture2event,
                       default_key2event, default_gc2event, default_n2event,
                       default_labels);
    }
}
コード例 #12
0
ファイル: Time.cpp プロジェクト: CnZoom/XcSoarWork
int
DataFieldTime::SpeedUp(bool key_up)
{
  if (IsAltair())
    return 1;

  if (key_up != data_field_key_up) {
    speedup = 0;
    data_field_key_up = key_up;
    last_step.Update();
    return 1;
  }

  if (!last_step.Check(200)) {
    speedup++;
    if (speedup > 5) {
      last_step.UpdateWithOffset(350);
      return 10;
    }
  } else
    speedup = 0;

  last_step.Update();

  return 1;
}
コード例 #13
0
ファイル: MenuBar.cpp プロジェクト: davidswelt/XCSoar
gcc_pure
static PixelRect
GetButtonPosition(unsigned i, PixelRect rc)
{
  UPixelScalar hwidth = rc.right - rc.left;
  UPixelScalar hheight = rc.bottom - rc.top;

  if (hheight > hwidth) {
    // portrait

    hheight /= 6;

    if (i == 0) {
      rc.left = rc.right;
      rc.top = rc.bottom;
    } else if (i < 5) {
      hwidth /= 4;

      rc.left += hwidth * (i - 1);
      rc.top = rc.bottom - hheight;
    } else {
      hwidth /= 3;

      rc.left = rc.right - hwidth;
      PixelScalar k = rc.bottom - rc.top - Layout::Scale(46);

      if (IsAltair()) {
        k = rc.bottom - rc.top;
        // JMW need upside down button order for rotated Altair
        rc.top = rc.bottom - (i - 5) * k / 5 - hheight - Layout::Scale(20);
      } else {
        rc.top += (i - 5) * hheight;
      }
    }

    rc.right = rc.left + hwidth;
    rc.bottom = rc.top + hheight;
  } else {
    // landscape

    hwidth /= 5;
    hheight /= 5;

    if (i == 0) {
      rc.left = rc.right;
      rc.top = rc.bottom;
    } else if (i < 5) {
      rc.top += hheight * (i - 1);
    } else {
      rc.left += hwidth * (i - 5);
      rc.top = rc.bottom - hheight;
    }

    rc.right = rc.left + hwidth;
    rc.bottom = rc.top + hheight;
  }

  return rc;
}
コード例 #14
0
ファイル: StandardFonts.hpp プロジェクト: CnZoom/XcSoarPull
gcc_const
static inline const TCHAR *
GetStandardFontFace()
{
  if (IsAltair())
    return _T("RasterGothicFourteenCond");

  return _T("Tahoma");
}
コード例 #15
0
ファイル: TargetDialog.cpp プロジェクト: j-konopka/XCSoar-TE
static void
UpdateButtons()
{
  if (IsAltair()) {
    // Altair uses the rotary knob
    ShowFormControl(*wf, _T("btnNext"), false);
    ShowFormControl(*wf, _T("btnPrev"), false);
  }
}
コード例 #16
0
ファイル: SerialPort.cpp プロジェクト: osteocool/XCSoar-1
size_t
SerialPort::Write(const void *data, size_t length)
{
  DWORD NumberOfBytesWritten;

  if (hPort == INVALID_HANDLE_VALUE)
    return 0;

#ifdef _WIN32_WCE

#if 0
  /* this workaround is currently disabled because it causes major
    problems with some of our device drivers, causing timeouts; this
    may be a regression on the bugged HP31x, but I prefer to support
    sane platforms any day */

  if (IsWindowsCE() && !IsAltair())
    /* this is needed to work around a driver bug on the HP31x -
       without it, the second consecutive write without a task switch
       will hang the whole PNA; this Sleep() call enforces a task
       switch */
    Sleep(100);
#endif

  // lpNumberOfBytesWritten : This parameter can be NULL only when the lpOverlapped parameter is not NULL.
  if (!::WriteFile(hPort, data, length, &NumberOfBytesWritten, NULL))
    return 0;

  return NumberOfBytesWritten;

#else

  OverlappedEvent osWriter;

  // Start reading data
  if (::WriteFile(hPort, data, length, &NumberOfBytesWritten, osWriter.GetPointer()))
    return NumberOfBytesWritten;

  if (::GetLastError() != ERROR_IO_PENDING)
    return 0;

  // Let's wait for ReadFile() to finish
  unsigned timeout_ms = 1000 + length * 10;
  switch (osWriter.Wait(timeout_ms)) {
  case OverlappedEvent::FINISHED:
    // Get results
    ::GetOverlappedResult(hPort, osWriter.GetPointer(), &NumberOfBytesWritten, FALSE);
    return NumberOfBytesWritten;

  default:
    ::CancelIo(hPort);
    ::SetCommMask(hPort, 0);
    osWriter.Wait();
    return 0;
  }
#endif
}
コード例 #17
0
ファイル: Fonts.cpp プロジェクト: Tjeerdm/XCSoarDktjm
static void
InitialiseLogFonts()
{
  if (IsAltair()) {
    LoadAltairLogFonts();
    return;
  }

#ifndef USE_GDI
  UPixelScalar font_height = Layout::SmallScale(IsAndroid() ? 30 : 24);
#else
  UPixelScalar font_height = Layout::SmallScale(35);
#endif

  // oversize first so can then scale down
  InitialiseLogfont(&log_infobox, GetStandardFontFace(),
                    (int)(font_height * 1.4), true, false, true);

#ifdef WIN32
  log_infobox.lfCharSet = ANSI_CHARSET;
#endif

  InitialiseLogfont(&log_title, GetStandardFontFace(), font_height / 3);

  // new font for CDI Scale
  InitialiseLogfont(&log_cdi, GetStandardFontFace(),
                    UPixelScalar(font_height * 0.6), false, false, false);

  // new font for map labels
  InitialiseLogfont(&log_map_label, GetStandardFontFace(),
                    UPixelScalar(font_height * 0.39), false, true);

  // new font for map labels big/medium cities
  InitialiseLogfont(&log_map_label_important, GetStandardFontFace(),
                    UPixelScalar(font_height * 0.39), false, true);

  // new font for map labels
  InitialiseLogfont(&log_map, GetStandardFontFace(),
                    UPixelScalar(font_height * 0.507));

  // Font for map bold text
  InitialiseLogfont(&log_map_bold, GetStandardFontFace(),
                    UPixelScalar(font_height * 0.507), true);

  InitialiseLogfont(&log_infobox_small, GetStandardFontFace(),
                    Layout::Scale(20));

#ifndef GNAV
  InitialiseLogfont(&log_infobox_units, GetStandardFontFace(),
                    (int)(font_height * 0.56));
#endif

  InitialiseLogfont(&log_monospace, GetStandardMonospaceFontFace(),
                    UPixelScalar(font_height * 0.39), false, false, false);
}
コード例 #18
0
ファイル: dlgTextEntry.cpp プロジェクト: onkelhotte/XCSoar
static bool
FormKeyDown(unsigned key_code)
{
    switch (key_code) {
    case KEY_UP:
    case KEY_LEFT:
        if ((key_code == KEY_LEFT) ^ IsAltair()) {
            if (cursor < 1)
                return true; // min width

            cursor--;
            MoveCursor();
            return true;
        } else {
            lettercursor--;
            UpdateCursor();
            return true;
        }

    case KEY_DOWN:
    case KEY_RIGHT:
        if ((key_code == KEY_RIGHT) ^ IsAltair()) {
            if (cursor + 2 >= max_width)
                return true; // max width

            cursor++;
            MoveCursor();
            return true;
        } else {
            lettercursor++;
            UpdateCursor();
            return true;
        }
    case KEY_RETURN:
        wf->SetModalResult(mrOK);
        return true;

    default:
        return false;
    }
}
コード例 #19
0
ファイル: Event.cpp プロジェクト: davidswelt/XCSoar
/**
 * Checks if we should pass this message to the WIN32 dialog manager.
 */
gcc_pure
static bool
AllowDialogMessage(const MSG &msg)
{
  /* this hack disallows the dialog manager to handle VK_LEFT/VK_RIGHT
     on the Altair; some dialogs use the knob as a hot key, and they
     can't implement Window::OnKeyCheck() */
  if (IsAltair() && (msg.message == WM_KEYDOWN || msg.message == WM_KEYUP) &&
      (msg.wParam == VK_LEFT || msg.wParam == VK_RIGHT))
    return false;

  return true;
}
コード例 #20
0
ファイル: Simulator.cpp プロジェクト: davidswelt/XCSoar
void
Simulator::Process(NMEAInfo &basic)
{
  assert(is_simulator());

  Touch(basic);

  basic.location = FindLatitudeLongitude(basic.location, basic.track,
                                         basic.ground_speed);

  // use this to test FLARM parsing/display
  if (IsDebug() && !IsAltair())
    GenerateFLARMTraffic(basic);
}
コード例 #21
0
ファイル: Font.cpp プロジェクト: damianob/xcsoar
void
Font::CalculateHeights()
{
  AnyCanvas canvas;
  canvas.Select(*this);

  TEXTMETRIC tm;
  ::GetTextMetrics(canvas, &tm);

  height = tm.tmHeight;
  ascent_height = tm.tmAscent;

  if (IsAltair()) {
    // JMW: don't know why we need this in GNAV, but we do.

    BufferCanvas buffer(canvas, tm.tmAveCharWidth, tm.tmHeight);
    const HWColor white = buffer.map(COLOR_WHITE);

    buffer.SetBackgroundOpaque();
    buffer.SetBackgroundColor(COLOR_WHITE);
    buffer.SetTextColor(COLOR_BLACK);
    buffer.Select(*this);

    RECT rec;
    rec.left = 0;
    rec.top = 0;
    rec.right = tm.tmAveCharWidth;
    rec.bottom = tm.tmHeight;
    buffer.text_opaque(0, 0, rec, _T("M"));

    UPixelScalar top = tm.tmHeight, bottom = 0;

    for (UPixelScalar x = 0; x < (UPixelScalar)tm.tmAveCharWidth; ++x) {
      for (UPixelScalar y = 0; y < (UPixelScalar)tm.tmHeight; ++y) {
        if (buffer.GetPixel(x, y) != white) {
          if (top > y)
            top = y;
          if (bottom < y)
            bottom = y;
        }
      }
    }

    capital_height = bottom - top + 1;
  } else {
    // This works for PPC
    capital_height = tm.tmAscent - 1 - tm.tmHeight / 10;
  }
}
コード例 #22
0
ファイル: Descriptor.cpp プロジェクト: davidswelt/XCSoar
void
DeviceDescriptor::AutoReopen(OperationEnvironment &env)
{
  if (IsAltair() || !config.IsAvailable() || config.IsServer() ||
      IsConnected() || (driver != NULL && !driver->HasTimeout()) ||
      /* attempt to reopen a failed device every 30 seconds */
      !reopen_clock.CheckUpdate(30000))
    return;

  TCHAR buffer[64];
  LogStartUp(_T("Reconnecting to device %s"), config.GetPortName(buffer, 64));

  InputEvents::processGlideComputer(GCE_COMMPORT_RESTART);
  Reopen(env, false);
}
コード例 #23
0
void
ContainerWindow::focus_next_control()
{
  HWND hControl = ::GetNextDlgTabItem(hWnd, ::GetFocus(), false);
  if (hControl == NULL)
    return;

  if (IsAltair()) { // detect and block wraparound 
    HWND hControl_first = ::GetNextDlgTabItem(hWnd, hWnd, false);
    if (hControl == hControl_first)
      return;
  }

  ::SetFocus(hControl);
}
コード例 #24
0
ファイル: DefaultFonts.cpp プロジェクト: CnZoom/XcSoarPull
static void
InitialiseLogFonts(FontSettings &settings)
{
#ifdef WIN32
  if (IsAltair()) {
    LoadAltairLogFonts(settings);
    return;
  }
#endif

  // new font for map labels
  settings.map = FontDescription(Layout::FontScale(10));

  // Font for map bold text
  settings.map_bold = FontDescription(Layout::FontScale(10), true);
}
コード例 #25
0
ファイル: ContainerWindow.cpp プロジェクト: CnZoom/XcSoarPull
bool
ContainerWindow::FocusNextControl()
{
  HWND hControl = ::GetNextDlgTabItem(hWnd, ::GetFocus(), false);
  if (hControl == nullptr)
    return false;

  if (IsAltair()) { // detect and block wraparound 
    HWND hControl_first = ::GetNextDlgTabItem(hWnd, nullptr, false);
    if (hControl == hControl_first)
      return false;
  }

  ::SetFocus(hControl);
  return true;
}
コード例 #26
0
ファイル: Font.cpp プロジェクト: damianob/xcsoar
bool
Font::Set(const TCHAR* facename, UPixelScalar height, bool bold, bool italic)
{
  LOGFONT font;
  memset((char *)&font, 0, sizeof(LOGFONT));

  _tcscpy(font.lfFaceName, facename);
  font.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
  font.lfHeight = (long)height;
  font.lfWeight = (long)(bold ? FW_BOLD : FW_MEDIUM);
  font.lfItalic = italic;
  if (IsAltair()) // better would be: if (screen.dpi() < 100)
    font.lfQuality = NONANTIALIASED_QUALITY;
  else
    font.lfQuality = ANTIALIASED_QUALITY;
  return Font::Set(font);
}
コード例 #27
0
ファイル: DefaultFonts.cpp プロジェクト: ppara/XCSoar
static void
InitialiseLogFonts(FontSettings &settings)
{
#ifdef WIN32
  if (IsAltair()) {
    LoadAltairLogFonts(settings);
    return;
  }
#endif

  settings.dialog = FontDescription(std::min(Layout::FontScale(12),
                                             Layout::min_screen_pixels / 20));

  settings.infobox = FontDescription(Layout::FontScale(30), true);

  /* the "small" font is derived from the regular font */
  settings.infobox_small = settings.infobox;
  settings.infobox_small.SetHeight(settings.infobox_small.GetHeight() * 4 / 5);
  settings.infobox_small.SetBold(false);

  settings.title = FontDescription(Layout::FontScale(8));

  // new font for CDI Scale
  settings.cdi = FontDescription(Layout::FontScale(10),
                                 false, false, true);

  // new font for map labels
  settings.map_label = FontDescription(Layout::FontScale(8), false, true);

  // new font for map labels big/medium cities
  settings.map_label_important = FontDescription(Layout::FontScale(8),
                                                 true, true);

  // new font for map labels
  settings.map = FontDescription(Layout::FontScale(10));

  // Font for map bold text
  settings.map_bold = FontDescription(Layout::FontScale(10), true);

#ifndef GNAV
  settings.infobox_units = FontDescription(Layout::FontScale(9));
#endif

  settings.monospace = FontDescription(settings.dialog.GetHeight(),
                                       false, false, true);
}
コード例 #28
0
ファイル: Event.cpp プロジェクト: davidswelt/XCSoar
void
DialogEventLoop::Dispatch(MSG &msg)
{
  assert_none_locked();

  if (AllowDialogMessage(msg) && ::IsDialogMessage(dialog, &msg)) {
    assert_none_locked();
    return;
  }

  if (IsAltair() && msg.message == WM_KEYDOWN && msg.wParam == VK_ESCAPE) {
    /* the Windows CE dialog manager does not handle VK_ESCAPE, but
       the Altair needs it - let's roll our own */
    ::SendMessage(dialog, WM_COMMAND, IDCANCEL, 0);
    return;
  }

  EventLoop::Dispatch(msg);
}
コード例 #29
0
ファイル: InputEvents.cpp プロジェクト: damianob/xcsoar_mess
bool
InputEvents::ProcessKey(Mode mode, unsigned key_code)
{
  if (IsAltair() && key_code == 0xF5) {
    XCSoarInterface::SignalShutdown(false);
    return true;
  }

  if (!globalRunningEvent.Test())
    return false;

  // Which key - can be defined locally or at default (fall back to default)
  unsigned event_id = key_to_event(mode, overlay_mode, key_code);
  if (event_id == 0)
    return false;

  ProcessEvent(event_id);
  return true;
}
コード例 #30
0
void
TimeConfigPanel::Prepare(ContainerWindow &parent, const PixelRect &rc)
{
  instance = this;
  LoadWindow(CallBackTable, parent,
             Layout::landscape ? _T("IDR_XML_TIMECONFIGPANEL") :
                               _T("IDR_XML_TIMECONFIGPANEL_L"));

  loading = true;

  int utc_offset = XCSoarInterface::GetComputerSettings().utc_offset;
  LoadFormProperty(form, _T("prpUTCOffset"),
                   fixed(iround(fixed(utc_offset) / 1800)) / 2);
#ifdef WIN32
  if (IsEmbedded() && !IsAltair())
    ((WndProperty*)form.FindByName(_T("prpUTCOffset")))->set_enabled(false);
#endif
  SetLocalTime(utc_offset);

  loading = false;
}