示例#1
0
文件: Asset.cpp 项目: Plantain/XCSoar
void
InitAsset()
{
  if (is_altair()) {
    #ifdef FORCEPORTRAIT
    // JMW testing only for portrait mode of Altair
    Display::Rotate();
    #endif
  }

#if defined(_WIN32_WCE) && !defined(GNAV)
  /*
  LocalPath is called for the very first time by CreateDirectoryIfAbsent.
  In order to be able in the future to behave differently for each PNA device
  and maybe also for common PDAs, we need to know the PNA/PDA Model Type
  BEFORE calling LocalPath. This was critical.
   */

  int Temp = (int)MODELTYPE_PNA_PNA;
  Profile::Get(szProfileAppInfoBoxModel, Temp);
  GlobalModelType = (ModelType)Temp;
  #endif

  // VENTA2- TODO fix these directories are not used always!
  CreateDirectoryIfAbsent(_T(""));  // RLD make sure the LocalPath folder actually exists
  CreateDirectoryIfAbsent(_T("logs"));
  CreateDirectoryIfAbsent(_T("config"));

  if (is_altair())
    CreateDirectoryIfAbsent(_T("persist"));

  StartupLogFreeRamAndStorage();
}
示例#2
0
文件: Chart.cpp 项目: Plantain/XCSoar
Chart::Chart(Canvas &the_canvas, const RECT the_rc) :
  canvas(the_canvas), rc(the_rc)
{
  ResetScale();

  pens[STYLE_BLUETHIN].set(Pen::DASH, is_altair() ? 1 : 2, Color(0, 50, 255));
  pens[STYLE_REDTHICK].set(Pen::DASH, 3, Color(200, 50, 50));
  pens[STYLE_DASHGREEN].set(Pen::DASH, 2, Color::GREEN);
  pens[STYLE_MEDIUMBLACK].set(is_altair() ? 1 : 2, Color(50, 243, 45));
  pens[STYLE_THINDASHPAPER].set(Pen::DASH, 1, Color(0x60, 0x60, 0x60));
}
示例#3
0
文件: Integer.cpp 项目: Mrdini/XCSoar
int
DataFieldInteger::SpeedUp(bool keyup)
{
    int res = 1;

    if (is_altair())
        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;
}
示例#4
0
void
ExperimentalConfigPanel::Init(WndForm *_wf)
{
  assert(_wf != NULL);
  wf = _wf;
  WndProperty *wp;

  if (!is_windows_ce() || is_altair()) {
    wp = (WndProperty*)wf->FindByName(_T("prpAppInfoBoxModel"));
    if (wp) {
      wp->hide();
    }
  }

#if defined(_WIN32_WCE) && !defined(GNAV)
// VENTA-ADDON Model change config menu 11
  wp = (WndProperty*)wf->FindByName(_T("prpAppInfoBoxModel"));
  if (wp) {
    DataFieldEnum* dfe;
    dfe = (DataFieldEnum*)wp->GetDataField();
    dfe->addEnumText(_("Generic"));
    dfe->addEnumText(_T("HP31x"));
    dfe->addEnumText(_T("MedionP5"));
    dfe->addEnumText(_T("MIO"));
    dfe->addEnumText(_T("Nokia500")); // VENTA3
    dfe->addEnumText(_T("PN6000"));
    dfe->Set((int)GlobalModelType);
    wp->RefreshDisplay();
  }
#endif
}
示例#5
0
/**
 * Determine whether the vario gauge should be drawn depending on the
 * display orientation and the infobox layout
 * @return True if vario gauge should be drawn, False otherwise
 */
bool vario_visible() {
  bool gaugeVarioInPortrait = is_altair();
  bool enable_gauge;

  // TODO TB: logic update...

  // VENTA3 disable gauge vario for geometry 5 in landscape mode, use 8
  // box right instead beside those boxes were painted and overwritten
  // by the gauge already and gauge was graphically too much stretched,
  // requiring a restyle!

  if (InfoBoxLayout::gnav) {
    if ((InfoBoxLayout::landscape == true) &&
        (InfoBoxLayout::InfoBoxGeometry == 5))
      enable_gauge = false;
    else
      enable_gauge = true;
  } else {
    enable_gauge = false;
  }

 // Disable vario gauge in geometry 5 landscape mode, leave 8 boxes on
 // the right
  if ((InfoBoxLayout::landscape == true)
      && (InfoBoxLayout::InfoBoxGeometry == 5)) return false; // VENTA3

  if (gaugeVarioInPortrait || InfoBoxLayout::landscape) {
    return enable_gauge;
  }
  return false;
}
示例#6
0
文件: Float.cpp 项目: macsux/XCSoar
fixed
DataFieldFloat::SpeedUp(bool keyup)
{
  if (is_altair())
    return fixed_one;

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

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

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

  last_step.update();

  return fixed_one;
}
示例#7
0
文件: Fonts.cpp 项目: hnpilot/XCSoar
const TCHAR*
Fonts::GetStandardFontFace()
{
  if (is_altair())
    return _T("RasterGothicFourteenCond");

  return _T("Tahoma");
}
示例#8
0
文件: Event.cpp 项目: macsux/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::on_key_check() */
  if (is_altair() && (msg.message == WM_KEYDOWN || msg.message == WM_KEYUP) &&
      (msg.wParam == VK_LEFT || msg.wParam == VK_RIGHT))
    return false;

  return true;
}
示例#9
0
bool
dlgStartupShowModal()
{
  LogStartUp(_T("Startup dialog"));

  logo = new LogoView();

  wf = LoadDialog(CallBackTable, XCSoarInterface::main_window,
                  Layout::landscape ? _T("IDR_XML_STARTUP_L") :
                                      _T("IDR_XML_STARTUP"));
  assert(wf != NULL);

  WndProperty* wp = ((WndProperty *)wf->FindByName(_T("prpProfile")));
  assert(wp != NULL);

  DataFieldFileReader* dfe = (DataFieldFileReader*)wp->GetDataField();
  assert(dfe != NULL);

  ((WndButton *)wf->FindByName(_T("cmdClose")))
    ->SetOnClickNotify(OnCloseClicked);

  ((WndButton *)wf->FindByName(_T("cmdQuit")))->SetOnClickNotify(OnQuit);

  dfe->ScanDirectoryTop(is_altair() ? _T("config/*.prf") : _T("*.prf"));
  dfe->Lookup(startProfileFile);
  wp->RefreshDisplay();

  if (dfe->GetNumFiles() <= 2) {
    delete wf;
    return true;
  }

  if (wf->ShowModal() != mrOK) {
    delete wf;
    return false;
  }

  const TCHAR *path = dfe->GetPathFile();
  if (!string_is_empty(path)) {
    _tcscpy(startProfileFile, path);

    /* When a profile from a secondary data path is used, this path
       becomes the primary data path */
    TCHAR temp[MAX_PATH];
    SetPrimaryDataPath(DirName(path, temp));
  }

  delete wf;
  delete logo;
  return true;
}
示例#10
0
static TCHAR *
FindDataPath()
{
  if (is_altair() && is_embedded())
    /* hard-coded path for Altair */
    return _tcsdup(_T("\\NOR Flash"));

  if (is_android()) {
    /* XXX use Environment.getExternalStorageDirectory() */

#ifdef ANDROID
    /* hack for Samsung Galaxy S and Samsung Galaxy Tab (which has a
       build-in and an external SD card) */
    struct stat st;
    if (stat("/sdcard/external_sd", &st) == 0 &&
        (st.st_mode & S_IFDIR) != 0 &&
        fgrep("/proc/mounts", "/sdcard/external_sd "))
      return strdup("/sdcard/external_sd/XCSoarData");
#endif

    /* hard-coded path for Android */
    return _tcsdup(_T("/sdcard/XCSoarData"));
  }

#ifdef _WIN32_WCE
  /* if XCSoar was started from a flash disk, put the XCSoarData onto
     it, too */
  {
    TCHAR buffer[MAX_PATH];
    if (ModuleInFlash(NULL, buffer) != NULL) {
      _tcscat(buffer, _T(DIR_SEPARATOR_S));
      _tcscat(buffer, XCSDATADIR);
      if (Directory::Exists(buffer))
        return _tcsdup(buffer);
    }

    /* if a flash disk with XCSoarData exists, use it */
    if (ExistingDataOnFlash(buffer) != NULL)
      return _tcsdup(buffer);
  }
#endif

  {
    TCHAR buffer[MAX_PATH];
    const TCHAR *path = GetHomeDataPath(buffer);
    if (path != NULL)
      return _tcsdup(path);
  }

  return NULL;
}
示例#11
0
void
Font::calculate_heights()
{
  VirtualCanvas canvas(1, 1);
  canvas.select(*this);

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

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

  if (is_altair()) {
    // 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.background_opaque();
    buffer.set_background_color(COLOR_WHITE);
    buffer.set_text_color(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"));

    int top = tm.tmHeight, bottom = 0;

    for (int x = 0; x < tm.tmAveCharWidth; ++x) {
      for (int y = 0; y < tm.tmHeight; ++y) {
        if (buffer.get_pixel(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;
  }
}
void
ContainerWindow::focus_next_control()
{
  HWND hControl = ::GetNextDlgTabItem(hWnd, ::GetFocus(), false);
  if (hControl == NULL)
    return;

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

  ::SetFocus(hControl);
}
示例#13
0
bool
Font::set(const TCHAR* facename, int 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 (is_altair()) // better would be: if (screen.dpi() < 100)
    font.lfQuality = NONANTIALIASED_QUALITY;
  else
    font.lfQuality = ANTIALIASED_QUALITY;
  return Font::set(font);
}
示例#14
0
文件: Event.cpp 项目: macsux/XCSoar
void
DialogEventLoop::dispatch(MSG &msg)
{
  assert_none_locked();

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

  if (is_altair() && 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);
}
示例#15
0
文件: Fonts.cpp 项目: hnpilot/XCSoar
static void
InitialiseLogFonts()
{
  if (is_altair()) {
    LoadAltairLogFonts();
    return;
  }

#ifdef ENABLE_SDL
  int FontHeight = Layout::SmallScale(20);
#else
  int FontHeight = Layout::SmallScale(35);
#endif

  // oversize first so can then scale down
  InitialiseLogfont(&LogInfoBox, Fonts::GetStandardFontFace(),
                    (int)(FontHeight * 1.4), true, false, true);

  LogInfoBox.lfCharSet = ANSI_CHARSET;

  InitialiseLogfont(&LogTitle, Fonts::GetStandardFontFace(),
                    FontHeight / 3, true);

  // new font for CDI Scale
  InitialiseLogfont(&LogCDI, Fonts::GetStandardFontFace(),
                    (int)(FontHeight * 0.6), false, false, false);

  // new font for map labels
  InitialiseLogfont(&LogMapLabel, Fonts::GetStandardFontFace(),
                    (int)(FontHeight * 0.39), false, true);

  // new font for map labels
  InitialiseLogfont(&LogMap, Fonts::GetStandardFontFace(),
                    (int)(FontHeight * 0.507));

  // Font for map bold text
  InitialiseLogfont(&LogMapBold, Fonts::GetStandardFontFace(),
                    (int)(FontHeight * 0.507), true);

  InitialiseLogfont(&LogInfoBoxSmall, Fonts::GetStandardFontFace(),
                    Layout::Scale(20));
}
示例#16
0
文件: Other.cpp 项目: Plantain/XCSoar
void
InfoBoxContentBattery::Update(InfoBoxWindow &infobox)
{
  // Set Value
#ifdef HAVE_BATTERY
  TCHAR tmp[32];
  if (!is_altair()) {
    _stprintf(tmp, _T("%2.1fV"), PDABatteryPercent);
  } else {
    if (negative(XCSoarInterface::Basic().SupplyBatteryVoltage)) {
      infobox.SetInvalid();
      return;
    }
    _stprintf(tmp, _T("%d%%"),
              (int)XCSoarInterface::Basic().SupplyBatteryVoltage);
  }
  infobox.SetValue(tmp);
#else
  infobox.SetInvalid();
#endif
}
示例#17
0
static TCHAR *
FindDataPath()
{
    if (is_altair())
        /* hard-coded path for Altair */
        return _tcsdup(_T("\\NOR Flash"));

    if (is_android())
        /* hard-coded path for Android */
        return _tcsdup(_T("/sdcard/XCSoarData"));

#ifdef _WIN32_WCE
    /* if XCSoar was started from a flash disk, put the XCSoarData onto
       it, too */
    {
        TCHAR buffer[MAX_PATH];
        if (ModuleInFlash(NULL, buffer) != NULL) {
            _tcscat(buffer, _T(DIR_SEPARATOR_S));
            _tcscat(buffer, XCSDATADIR);
            if (Directory::Exists(buffer))
                return _tcsdup(buffer);
        }

        /* if a flash disk with XCSoarData exists, use it */
        if (ExistingDataOnFlash(buffer) != NULL)
            return _tcsdup(buffer);
    }
#endif

    {
        TCHAR buffer[MAX_PATH];
        const TCHAR *path = GetHomeDataPath(buffer);
        if (path != NULL)
            return _tcsdup(path);
    }

    return NULL;
}
示例#18
0
void
Simulator::Process(NMEAInfo &basic)
{
  if (!is_simulator())
    return;

  basic.UpdateClock();
  basic.connected.Update(basic.clock);
  basic.gps.satellites_used = -1;
  basic.gps.simulator = true;
  basic.gps.real = false;

#ifdef ANDROID
  basic.gps.android_internal_gps = false;
#endif

  basic.location = FindLatitudeLongitude(basic.location, basic.track,
                                         basic.ground_speed);
  basic.location_available.Update(basic.clock);
  basic.gps_altitude_available.Update(basic.clock);
  basic.track_available.Update(basic.clock);
  basic.ground_speed_available.Update(basic.clock);

  basic.time_available.Update(basic.clock);
  basic.time += fixed_one;
  (BrokenTime &)basic.date_time_utc =
    BrokenTime::FromSecondOfDayChecked((unsigned)basic.time);

  // use this to test FLARM parsing/display
  if (is_debug() && !is_altair())
    GenerateFLARMTraffic(basic);

  // clear Airspeed as it is not available in simulation mode
  basic.airspeed_available.Clear();
  basic.airspeed_real = false;
}
示例#19
0
void
Profile::GetDeviceConfig(unsigned n, DeviceConfig &config)
{
  TCHAR buffer[64];
  unsigned Temp = 0;

  config.port_type = ReadPortType(n);

  MakeDeviceSettingName(buffer, CONF("Port"), n, _T("Index"));
  if (Get(buffer, Temp))
    config.port_index = Temp;
  else if (is_altair() && n == 0)
    config.port_index = 2;
  else if (is_altair() && n == 2)
    config.port_index = 1;
  else
    config.port_index = 0;

  MakeDeviceSettingName(buffer, CONF("Speed"), n, _T("Index"));
  if (Get(buffer, Temp))
    config.speed_index = Temp;
  else if (is_altair())
    config.speed_index = 5;
  else
    config.speed_index = 2;

  _tcscpy(buffer, CONF("DeviceA"));
  buffer[_tcslen(buffer) - 1] += n;
  if (!Get(buffer, config.driver_name,
           sizeof(config.driver_name) / sizeof(config.driver_name[0]))) {
    if (is_altair() && n == 0)
      _tcscpy(config.driver_name, _T("Altair RU"));
    else if (is_altair() && n == 1)
      _tcscpy(config.driver_name, _T("Vega"));
    else if (is_altair() && n == 2)
      _tcscpy(config.driver_name, _T("NmeaOut"));
    else
      config.driver_name[0] = '\0';
  }
}
示例#20
0
文件: Form.cpp 项目: Plantain/XCSoar
static bool
is_allowed_map(HWND hWnd, UINT message, bool enable_map)
{
  return !is_altair() && enable_map && MapWindow::identify(hWnd) &&
    is_allowed_map_message(message);
}
示例#21
0
文件: Form.cpp 项目: macsux/XCSoar
int
WndForm::ShowModal()
{
  assert_none_locked();

#define OPENCLOSESUPPRESSTIME 500
#ifndef USE_GDI
  ContainerWindow *root = get_root_owner();
  WindowReference old_focus_reference = root->GetFocusedWindowReference();
#else
  HWND oldFocusHwnd;
#endif /* USE_GDI */

  PeriodClock enter_clock;
  if (is_embedded() && !is_altair())
    enter_clock.update();

  show_on_top();

  mModalResult = 0;

#ifdef USE_GDI
  oldFocusHwnd = ::GetFocus();
  if (oldFocusHwnd != NULL)
    ::SendMessage(oldFocusHwnd, WM_CANCELMODE, 0, 0);
#endif /* USE_GDI */
  set_focus();
  focus_first_control();

  bool hastimed = false;
  WndForm::timeAnyOpenClose.update(); // when current dlg opens or child closes

  main_window.add_dialog(this);

#ifndef USE_GDI
  main_window.refresh();
#endif

#ifdef ANDROID
  EventLoop loop(*event_queue, main_window);
  Event event;
#elif defined(ENABLE_SDL)
  EventLoop loop(main_window);
  SDL_Event event;
#else
  DialogEventLoop loop(*this);
  MSG event;
#endif

  while ((mModalResult == 0 || force) && loop.get(event)) {
#if defined(ENABLE_SDL) && !defined(ANDROID)
    if (event.type == SDL_QUIT) {
      mModalResult = mrCancel;
      continue;
    }
#endif

    if (!main_window.FilterEvent(event, this))
      continue;

    // hack to stop exiting immediately
    if (is_embedded() && !is_altair() && !hastimed &&
        is_user_input(event)) {
      if (!enter_clock.check(200))
        /* ignore user input in the first 200ms */
        continue;
      else
        hastimed = true;
    }

    if (is_embedded() && is_mouse_up(event) &&
        !timeAnyOpenClose.check(OPENCLOSESUPPRESSTIME))
      /* prevents child click from being repeat-handled by parent if
         buttons overlap */
      continue;

    if (mOnKeyDownNotify != NULL && is_key_down(event) &&
#ifdef USE_GDI
        identify_descendant(event.hwnd) &&
#endif
        !check_special_key(this, event) &&
        mOnKeyDownNotify(*this, get_key_code(event)))
      continue;

#if defined(ENABLE_SDL) && !defined(ANDROID)
    if (event.type == SDL_KEYDOWN && event.key.keysym.sym == SDLK_TAB) {
      /* the Tab key moves the keyboard focus */
      const Uint8 *keystate = ::SDL_GetKeyState(NULL);
      event.key.keysym.sym = keystate[SDLK_LSHIFT] || keystate[SDLK_RSHIFT]
        ? SDLK_UP : SDLK_DOWN;
    }
#endif

    if (is_key_down(event) &&
#ifdef USE_GDI
        identify_descendant(event.hwnd) &&
#endif
        (get_key_code(event) == VK_UP || get_key_code(event) == VK_DOWN)) {
      /* VK_UP and VK_DOWN move the focus only within the current
         control group - but we want it to behave like Shift-Tab and
         Tab */

      if (!check_key(this, event)) {
        /* this window doesn't handle VK_UP/VK_DOWN */
        if (get_key_code(event) == VK_DOWN)
          focus_next_control();
        else
          focus_previous_control();
        continue;
      }
    }

#ifndef USE_GDI
    if (is_key_down(event) && get_key_code(event) == VK_ESCAPE) {
      mModalResult = mrCancel;
      continue;
    }
#endif

    /* map VK_ESCAPE to mrOK on Altair, because the Escape key is expected to 
       be the one that saves and closes a dialog */
    if (is_altair() && is_key_down(event) && get_key_code(event) == VK_ESCAPE) {
      mModalResult = mrOK;
      continue;
    }

    loop.dispatch(event);
  } // End Modal Loop

  main_window.remove_dialog(this);

  // static.  this is current open/close or child open/close
  WndForm::timeAnyOpenClose.update();

#ifdef USE_GDI
  SetFocus(oldFocusHwnd);
#else
  if (old_focus_reference.Defined()) {
    Window *old_focus = old_focus_reference.Get(*root);
    if (old_focus != NULL)
      old_focus->set_focus();
  }
#endif /* !USE_GDI */

  return mModalResult;
}
示例#22
0
int
ProcessTimer::ConnectionProcessTimer(int itimeout)
{
  devConnectionMonitor();

  static bool connected_last = false;
  static bool wait_connect = false;
  static bool wait_lock = false;

  if (!Basic().gps.Connected) {
    // if gps is not connected, set navwarning to true so
    // calculations flight timers don't get updated
    device_blackboard.SetNAVWarning(true);
  }

  bool connected_now = device_blackboard.LowerConnection();
  if (connected_now && Basic().gps.NAVWarning) {
    if (!wait_lock) {
      // waiting for lock first time
      wait_lock = true;
      itimeout = 0;
      InputEvents::processGlideComputer(GCE_GPS_FIX_WAIT);
#ifndef DISABLEAUDIO
      MessageBeep(MB_ICONEXCLAMATION);
#endif
    }

    // If GPS connected but no lock, must be in hangar
    if (InterfaceTimeoutCheck()) {
      if (is_altair()) {
        // TODO feature: ask question about shutdown or give warning
        // then shutdown if no activity.
        // Shutdown();
      }
    }
  } else if (connected_now) {
    // !navwarning
    wait_connect = false;
    wait_lock = false;
    itimeout = 0;
  } else {
    // not connected
    wait_lock = false;
  }

  if (!connected_now && !connected_last) {
    AllDevicesLinkTimeout();

    if (!wait_connect) {
      // gps is waiting for connection first time
      wait_connect = true;
      InputEvents::processGlideComputer(GCE_GPS_CONNECTION_WAIT);
#ifndef DISABLEAUDIO
      MessageBeep(MB_ICONEXCLAMATION);
#endif
    } else if (itimeout % 60 == 0) {
      itimeout = 0;
      // we've been waiting for connection a long time
      // no activity for 30 seconds, so assume PDA has been
      // switched off and on again
      //
#ifdef _WIN32_WCE
      if (!is_altair()) {
        InputEvents::processGlideComputer(GCE_COMMPORT_RESTART);
        devRestart();
      }
#endif
    }
  }

  connected_last = connected_now;
  return itimeout;
}
示例#23
0
bool
dlgConfigInfoboxesShowModal(SingleWindow &parent,
                            const DialogLook &dialog_look,
                            InfoBoxLayout::Geometry geometry,
                            InfoBoxSettings::Panel &data_r,
                            bool allow_name_change)
{
  current_preview = 0;
  data = data_r;

  PixelRect rc = parent.get_client_rect();
  wf = new WndForm(parent, dialog_look, rc.left, rc.top,
                   rc.right - rc.left, rc.bottom - rc.top);

#ifdef _WIN32_WCE
  if (is_altair())
    wf->SetKeyDownNotify(OnKeyDown);
#endif

  ContainerWindow &client_area = wf->GetClientAreaWindow();
  rc = client_area.get_client_rect();

  InflateRect(&rc, Layout::FastScale(-2), Layout::FastScale(-2));
  info_box_layout = InfoBoxLayout::Calculate(rc, geometry);

  WindowStyle preview_style;
  preview_style.enable_double_clicks();
  for (unsigned i = 0; i < info_box_layout.count; ++i) {
    rc = info_box_layout.positions[i];
    previews[i].set(client_area, rc.left, rc.top,
                    rc.right - rc.left, rc.bottom - rc.top,
                    preview_style);
  }

  rc = info_box_layout.remaining;

  WindowStyle style;
  style.control_parent();

  EditWindowStyle edit_style;
  edit_style.tab_stop();

  if (is_embedded() || Layout::scale_1024 < 2048)
    /* sunken edge doesn't fit well on the tiny screen of an
       embedded device */
    edit_style.border();
  else
    edit_style.sunken_edge();

  const int x = rc.left;
  const unsigned width = rc.right - rc.left - Layout::FastScale(2);
  const unsigned height = Layout::Scale(22);
  const unsigned caption_width = Layout::Scale(60);

  int y = rc.top;

  ButtonWindowStyle button_style;
  button_style.tab_stop();

  buttonPanelName =
    new WndButton(client_area, dialog_look, _T(""),
                  x, y, width, height, button_style, OnNameAccess);
  buttonPanelName->set_enabled(allow_name_change);
  UpdatePanelName();

  y += height;

  edit_select = new WndProperty(client_area, dialog_look, _("InfoBox"),
                                x, y, width, height, caption_width,
                                style, edit_style,
                                NULL);

  DataFieldEnum *dfe = new DataFieldEnum(OnSelectAccess);
  for (unsigned i = 0; i < info_box_layout.count; ++i) {
    TCHAR label[32];
    _stprintf(label, _T("%u"), i + 1);
    dfe->addEnumText(label, i);
  }

  edit_select->SetDataField(dfe);

  y += height;

  edit_content = new WndProperty(client_area, dialog_look, _("Content"),
                                 x, y, width, height, caption_width,
                                 style, edit_style,
                                 NULL);

  dfe = new DataFieldEnum(OnContentAccess);
  for (unsigned i = 0; i < InfoBoxFactory::NUM_TYPES; ++i) {
    const TCHAR *name = InfoBoxFactory::GetName(i);
    if (name != NULL)
      dfe->addEnumText(gettext(name), i);
  }

  dfe->Sort(0);

  edit_content->SetDataField(dfe);
  edit_content->SetOnHelpCallback(OnContentHelp);

  RefreshEditContent();

  const unsigned button_width = Layout::Scale(60);
  const unsigned button_height = Layout::Scale(28);
  const int button_y = rc.bottom - button_height;
  int button_x = rc.left;
  WndButton *close_button =
    new WndButton(client_area, dialog_look, _("Close"),
                  button_x, button_y, button_width, button_height,
                  button_style, OnCloseClicked);
  button_x += button_width + Layout::Scale(2);
  WndButton *copy_button =
    new WndButton(client_area, dialog_look, _("Copy"),
                  button_x, button_y, button_width, button_height,
                  button_style, OnCopy);
  button_x += button_width + Layout::Scale(2);
  buttonPaste =
    new WndButton(client_area, dialog_look, _("Paste"),
                  button_x, button_y, button_width, button_height,
                  button_style, OnPaste);

  RefreshPasteButton();

  int result = wf->ShowModal();

  delete wf;
  delete buttonPanelName;
  delete edit_select;
  delete edit_content;
  delete close_button;
  delete copy_button;
  delete buttonPaste;

  bool changed = false;
  if (result == mrOK) {
    for (unsigned i = 0; i < InfoBoxSettings::Panel::MAX_CONTENTS; ++i)
      if (data.contents[i] != data_r.contents[i])
        changed = true;
    changed |= (_tcscmp(data.name, data_r.name) != 0);

    if (changed)
      data_r = data;
  }

  return changed;
}
示例#24
0
static void
GetButtonPosition(unsigned i, RECT rc, int *x, int *y, int *sizex, int *sizey)
{
  unsigned hwidth = rc.right - rc.left;
  unsigned hheight = rc.bottom - rc.top;

  const unsigned margin = Layout::FastScale(2);

  if (hheight > hwidth) {
    // portrait

    hheight /= 6;

    *sizex = hwidth - margin * 2;
    *sizey = hheight - margin * 2;

    if (i == 0) {
      *sizex = IBLSCALE(52);
      *sizey = IBLSCALE(37);
      *x = rc.left - (*sizex); // JMW make it offscreen for now
      *y = rc.bottom - (*sizey);
    } else if (i < 5) {
      hwidth /= 4;

      *sizex = hwidth - margin * 2;
      *sizey = hheight - margin * 2;
      *x = rc.left + margin + hwidth * (i - 1);
      *y = rc.bottom - hheight + margin;
    } else {
      hwidth /= 3;

      *sizex = hwidth - margin * 2;
      *sizey = hheight - margin * 2;

      *x = rc.right - hwidth + margin;
      int k = rc.bottom - rc.top - IBLSCALE(46);

      if (is_altair()) {
        k = rc.bottom - rc.top;
        // JMW need upside down button order for rotated Altair
        *y = rc.bottom - (i - 5) * k / 5 - (*sizey) - IBLSCALE(20);
      } else {
        *y = rc.top + (i - 5) * hheight + margin;
      }
    }
  } else {
    // landscape

    hwidth /= 5;
    hheight /= 5;

    *sizex = hwidth - margin * 2;
    *sizey = hheight - margin * 2;

    if (i == 0) {
      *x = rc.left - (*sizex); // JMW make it offscreen for now
      *y = (rc.top);
    } else if (i < 5) {
      *x = rc.left + margin;
      *y = rc.top + margin + hheight * (i - 1);
    } else {
      *x = rc.left + hwidth * (i - 5);
      *y = rc.bottom - hheight + margin;
    }
  }
}
示例#25
0
void
ButtonLabel::GetButtonPosition(unsigned i, RECT rc, int *x, int *y,
    int *sizex, int *sizey)
{
  TCHAR reggeompx[50];
  TCHAR reggeompy[50];
  TCHAR reggeomsx[50];
  TCHAR reggeomsy[50];

  _stprintf(reggeompx, TEXT("ScreenButtonPosX%d"), i);
  _stprintf(reggeompy, TEXT("ScreenButtonPosY%d"), i);
  _stprintf(reggeomsx, TEXT("ScreenButtonSizeX%d"), i);
  _stprintf(reggeomsy, TEXT("ScreenButtonSizeY%d"), i);

  GetFromRegistry(reggeompx,*x);
  GetFromRegistry(reggeompy,*y);
  GetFromRegistry(reggeomsx,*sizex);
  GetFromRegistry(reggeomsy,*sizey);

  bool geometrychanged = true; // JMW testing

  if ((*sizex == 0) || (*sizey == 0) || geometrychanged) {
    // not defined in registry so go with defaults
    // these will be saved back to registry
    int hwidth = (rc.right - rc.left) / 4;
    int hheight = (rc.bottom - rc.top) / 4;

    switch (ButtonLabelGeometry) {
    case 0: // portrait
      if (i == 0) {
        *sizex = IBLSCALE(52);
        *sizey = IBLSCALE(37);
        *x = rc.left - (*sizex); // JMW make it offscreen for now
        *y = rc.bottom - (*sizey);
      } else {
        if (i < 5) {
          *sizex = IBLSCALE(52);
          *sizey = IBLSCALE(40);
          *x = rc.left + 3 + hwidth * (i - 1);
          *y = rc.bottom - (*sizey);
        } else {
          *sizex = IBLSCALE(80);
          *sizey = IBLSCALE(40);
          *x = rc.right - (*sizex);
          int k = rc.bottom - rc.top - IBLSCALE(46);

          if (is_altair()) {
            k = rc.bottom - rc.top;
            // JMW need upside down button order for rotated Altair
            *y = rc.bottom - (i - 5) * k / 5 - (*sizey) - IBLSCALE(20);
          } else {
            *y = rc.top + (i - 5) * k / 6 + (*sizey / 2 + IBLSCALE(3));
          }
        }
      }
      break;

    case 1: // landscape
      hwidth = (rc.right - rc.left) / 5;
      hheight = (rc.bottom - rc.top) / 5;

      if (i == 0) {
        *sizex = IBLSCALE(52);
        *sizey = IBLSCALE(20);
        *x = rc.left - (*sizex); // JMW make it offscreen for now
        *y = (rc.top);
      } else {
        if (i < 5) {
          *sizex = IBLSCALE(52);
          *sizey = is_altair() ? IBLSCALE(20) : IBLSCALE(35);
          *x = rc.left + 3;
          *y = (rc.top + hheight * i - (*sizey) / 2);
        } else {
          *sizex = IBLSCALE(60);
          *sizey = is_altair() ? IBLSCALE(40) : IBLSCALE(35);
          *x = rc.left + hwidth * (i - 5);
          *y = (rc.bottom - (*sizey));
        }
      }
      break;
    }

    SetToRegistry(reggeompx, *x);
    SetToRegistry(reggeompy, *y);
    SetToRegistry(reggeomsx, *sizex);
    SetToRegistry(reggeomsy, *sizey);
  }
}
示例#26
0
文件: Base.cpp 项目: bugburner/xcsoar
void InfoBoxFormatter::AssignValue(int i) {
  switch (i) {
  case 0:
    Value = ALTITUDEMODIFY*Basic().Altitude;
    break;
  case 1:
    Value = ALTITUDEMODIFY*Calculated().AltitudeAGL  ;
    Valid = Calculated().TerrainValid;
    break;
  case 2:
    Value = LIFTMODIFY*Calculated().Average30s;
    break;
  case 3:
    Value = Calculated().WaypointBearing;
    Valid = Calculated().WaypointDistance > 10.0;
    break;
  case 4:
    if (Calculated().LD== 999) {
      Valid = false;
    } else {
      Valid = true;
      Value = Calculated().LD;
    }
    break;
  case 5:
    if (Calculated().CruiseLD== 999) {
      Valid = false;
    } else {
      Valid = true;
      Value = Calculated().CruiseLD;
    }
    break;
  case 6:
    Value = SPEEDMODIFY*Basic().Speed;
    break;
  case 7:
    Value = LIFTMODIFY*Calculated().LastThermalAverage;
    break;
  case 8:
    Value = ALTITUDEMODIFY*Calculated().LastThermalGain;
    break;
  case 10:
    Value = iround(LIFTMODIFY*GlidePolar::GetMacCready()*10)/10.0;
    break;
  case 11:
    Value = DISTANCEMODIFY*Calculated().WaypointDistance;
    Valid = task.ValidTaskPoint(task.getActiveIndex());
    break;
  case 12:
    Value = ALTITUDEMODIFY*Calculated().NextAltitudeDifference;
    Valid = task.ValidTaskPoint(task.getActiveIndex());
    break;
  case 13:
    Value = ALTITUDEMODIFY*Calculated().NextAltitudeRequired;
    Valid = task.ValidTaskPoint(task.getActiveIndex());
    break;
  case 14:
    Value = 0; // Next Waypoint Text
    break;
  case 15:
    Value = ALTITUDEMODIFY*Calculated().TaskAltitudeDifference;
    Valid = task.ValidTaskPoint(task.getActiveIndex());
    break;
  case 16:
    Value = ALTITUDEMODIFY*Calculated().TaskAltitudeRequired;
    Valid = task.ValidTaskPoint(task.getActiveIndex());
    break;
  case 17:
    Value = TASKSPEEDMODIFY*Calculated().TaskSpeed;
    if (task.getActiveIndex()>=1) {
      Valid = task.ValidTaskPoint(task.getActiveIndex());
    } else {
      Valid = false;
    }
    break;
  case 18:
    if (Calculated().ValidFinish) {
      Value = DISTANCEMODIFY*Calculated().WaypointDistance;
    } else {
      Value = DISTANCEMODIFY*Calculated().TaskDistanceToGo;
    }
    Valid = task.ValidTaskPoint(task.getActiveIndex());
    break;
  case 19:
    if (Calculated().LDFinish== 999) {
      Valid = false;
    } else {
      Valid = task.ValidTaskPoint(task.getActiveIndex());
      if (Calculated().ValidFinish) {
        Value = 0;
      } else {
        Value = Calculated().LDFinish;
      }
    }
    break;
  case 20:
    Value = ALTITUDEMODIFY*Calculated().TerrainAlt ;
    Valid = Calculated().TerrainValid;
    break;
  case 21:
    Value = LIFTMODIFY*Calculated().AverageThermal;
    break;
  case 22:
    Value = ALTITUDEMODIFY*Calculated().ThermalGain;
    break;
  case 23:
    Value = Basic().TrackBearing;
    break;
  case 24:
    if (Basic().VarioAvailable) {
      Value = LIFTMODIFY*Basic().Vario;
    } else {
      Value = LIFTMODIFY*Calculated().Vario;
    }
    break;
  case 25:
    Value = SPEEDMODIFY*Calculated().WindSpeed;
    break;
  case 26:
    Value = Calculated().WindBearing;
    break;
  case 28:
    Value = DISTANCEMODIFY*Calculated().AATMaxDistance ;
    Valid = task.ValidTaskPoint(task.getActiveIndex()) && task.getSettings().AATEnabled;
    break;
  case 29:
    Value = DISTANCEMODIFY*Calculated().AATMinDistance ;
    Valid = task.ValidTaskPoint(task.getActiveIndex()) && task.getSettings().AATEnabled;
    break;
  case 30:
    Value = TASKSPEEDMODIFY*Calculated().AATMaxSpeed;
    Valid = task.ValidTaskPoint(task.getActiveIndex()) && task.getSettings().AATEnabled;
    if (Calculated().AATTimeToGo<1) {
      Valid = false;
    }
    break;
  case 31:
    Value = TASKSPEEDMODIFY*Calculated().AATMinSpeed;
    Valid = task.ValidTaskPoint(task.getActiveIndex()) && task.getSettings().AATEnabled;
    if (Calculated().AATTimeToGo<1) {
      Valid = false;
    }
    break;
  case 32:
    Valid = Basic().AirspeedAvailable;
    Value = SPEEDMODIFY*Basic().IndicatedAirspeed;
    break;
  case 33:
    Valid = Basic().BaroAltitudeAvailable;
    Value = ALTITUDEMODIFY*Basic().BaroAltitude;
    break;
  case 34:
    Value = SPEEDMODIFY*Calculated().VMacCready;
    break;
  case 35:
    Value = Calculated().PercentCircling;
    break;
  case 37:
    Valid = Basic().AccelerationAvailable;
    Value = Basic().Gload;
    break;
  case 38:
    if (Calculated().LDNext== 999) {
      Valid = false;
    } else {
      Valid = task.ValidTaskPoint(task.getActiveIndex());
      Value = Calculated().LDNext;
    }
    break;
  case 43:
    //    Valid = Basic().AirspeedAvailable;
    Value = Calculated().VOpt*SPEEDMODIFY;
    break;
  case 44:
    //    Valid = Basic().AirspeedAvailable;
    Value = Calculated().NettoVario*LIFTMODIFY;
    break;
  case 48:
    Value = Basic().OutsideAirTemperature;
    break;
  case 49:
    Value = Basic().RelativeHumidity;
    break;
  case 50:
    Value = CuSonde::maxGroundTemperature;
    break;
  case 51:
    Value = DISTANCEMODIFY*Calculated().AATTargetDistance ;
    Valid = task.ValidTaskPoint(task.getActiveIndex()) && task.getSettings().AATEnabled;
    break;
  case 52:
    Value = TASKSPEEDMODIFY*Calculated().AATTargetSpeed;
    Valid = task.ValidTaskPoint(task.getActiveIndex()) && task.getSettings().AATEnabled;
    if (Calculated().AATTimeToGo<1) {
      Valid = false;
    }
    break;
  case 53:
    if (Calculated().LDvario== 999) {
      Valid = false;
    } else {
      Valid = Basic().VarioAvailable && Basic().AirspeedAvailable;
      Value = Calculated().LDvario;
    }
    break;
  case 54:
    Valid = Basic().AirspeedAvailable;
    Value = SPEEDMODIFY*Basic().TrueAirspeed;
    break;
  case 56: // team bearing
    Value = Calculated().TeammateBearing;
    Valid = true;
  case 58: // team range
    if (SettingsComputer().TeammateCodeValid)
      {
	Value = DISTANCEMODIFY*Calculated().TeammateRange;
	if (Value > 100)
	  {
	    _tcscpy(Format, _T("%.0lf"));
	  }
	else
	  {
	    _tcscpy(Format, _T("%.1lf"));
	  }
	Valid = true;
      }
    else
      {
	Valid = false;
      }
    break;
  case 59:
    Value = TASKSPEEDMODIFY*Calculated().TaskSpeedInstantaneous;
    if (task.getActiveIndex()>=1) {
      Valid = task.ValidTaskPoint(task.getActiveIndex());
    } else {
      Valid = false;
    }
    break;
  case 60:
    Value = DISTANCEMODIFY*Calculated().HomeDistance ;
    if (SettingsComputer().HomeWaypoint>=0) {
      Valid = way_points.verify_index(SettingsComputer().HomeWaypoint);
    } else {
      Valid = false;
    }
    break;
  case 61:
    Value = TASKSPEEDMODIFY*Calculated().TaskSpeedAchieved;
    if (task.getActiveIndex()>=1) {
      Valid = task.ValidTaskPoint(task.getActiveIndex());
    } else {
      Valid = false;
    }
    break;
  case 63:
    if (Calculated().timeCircling>0) {
      Value = LIFTMODIFY*Calculated().TotalHeightClimb
        /Calculated().timeCircling;
      Valid = true;
    } else {
      Value = 0.0;
      Valid = false;
    }
    break;
  case 64:
    Value = LIFTMODIFY*Calculated().DistanceVario;
    if (task.getActiveIndex()>=1) {
      Valid = task.ValidTaskPoint(task.getActiveIndex());
    } else {
      Valid = false;
    }
    break;
  case 65: // battery voltage
#if !defined(WINDOWSPC) && !defined(HAVE_POSIX)
    if (!is_altair()) {
      Value = PDABatteryPercent;
      Valid = true;
    } else {
      Value = Basic().SupplyBatteryVoltage;
      if (Value>0.0) {
        Valid = true;
      } else {
        Valid = false;
      }
    }
#else
    Value = 0.0;
    Valid = false;
#endif
    break;
  case 66: // VENTA-ADDON added GR Final
    if (Calculated().GRFinish== 999) {
      Valid = false;
    } else {
      Valid = task.ValidTaskPoint(task.getActiveIndex());
      if (Calculated().ValidFinish) {
	Value = 0;
      } else {
	Value = Calculated().GRFinish;
	if (Value >100 )
	  {
	    _tcscpy(Format, _T("%1.0f"));
	  }
	else
	  {
	    _tcscpy(Format, _T("%1.1f"));
	  }
      }
    }
    break;
  case 70:	// VENTA3 QFE
//    Valid = Basic().Altitude;
    Value = ALTITUDEMODIFY* (Basic().Altitude-QFEAltitudeOffset);
    break;
  case 71:
    if ( Calculated().AverageLD == 0) {
      Valid = false;
    } else {
      Valid = true;
      Value = Calculated().AverageLD;
      if (Value<0)
	    _tcscpy(Format, _T("^^^"));
      else if (Value>=999)
	    _tcscpy(Format, _T("+++"));
      else
	    _tcscpy(Format, _T("%2.0f"));

    }
    break;
  case 72:
    Value = Calculated().Experimental;
    Valid = true;
    break;
    /* TODO feature: add extra infoboxes from Lars
  case 68: // distance flown
    if (Calculated().TaskDistanceCovered != 0)
      {
	Value = DISTANCEMODIFY*Calculated().TaskDistanceCovered;
	Valid = true;
      }
    else
      {
	Value = 0.0;
	Valid = false;
      }
    break;
  case 67: // termik liga points
    if (Calculated().TermikLigaPoints != 0)
      {
	Value = Calculated().TermikLigaPoints;
	Valid = true;
      }
    else
      {
	Value = 0.0;
	Valid = false;
      }
    break;
    */
  default:
    break;
  };
}
示例#27
0
void dlgStartupShowModal(void){
  WndProperty* wp;
  StartupStore(TEXT("Startup dialog\n"));

  if (!InfoBoxLayout::landscape) {
    wf = dlgLoadFromXML(CallBackTable,
                        TEXT("dlgStartup_L.xml"),
                        XCSoarInterface::main_window,
                        TEXT("IDR_XML_STARTUP_L"));
  } else {
    wf = dlgLoadFromXML(CallBackTable,
                        TEXT("dlgStartup.xml"),
                        XCSoarInterface::main_window,
                        TEXT("IDR_XML_STARTUP"));
  }
  if (!wf) return;

  wSplash = (WndOwnerDrawFrame*)wf->FindByName(TEXT("frmSplash"));

  ((WndButton *)wf->FindByName(TEXT("cmdClose")))
    ->SetOnClickNotify(OnCloseClicked);

  TCHAR temp[MAX_PATH];

  _stprintf(temp,TEXT("XCSoar: Version %s"), XCSoar_Version);
  wf->SetCaption(temp);

  wp = ((WndProperty *)wf->FindByName(TEXT("prpDisclaimer")));
  if (wp)
    wp->SetText(TEXT("Pilot assumes complete\r\nresponsibility to operate\r\nthe aircraft safely.\r\nMaintain effective lookout.\r\n"));

  wp = ((WndProperty *)wf->FindByName(TEXT("prpProfile")));
  if (wp) {
    DataFieldFileReader* dfe;
    dfe = (DataFieldFileReader*)wp->GetDataField();
    if (is_altair())
      dfe->ScanDirectoryTop(TEXT("config/*.prf"));
    else
      dfe->ScanDirectoryTop(TEXT("*.prf"));
    dfe->Lookup(startProfileFile);
    wp->RefreshDisplay();
    if (dfe->GetNumFiles()<=2) {
      delete wf;
      wf = NULL;
      return;
    }
  }

  wf->ShowModal();

  wp = (WndProperty*)wf->FindByName(TEXT("prpProfile"));
  if (wp) {
    DataFieldFileReader* dfe;
    dfe = (DataFieldFileReader*)wp->GetDataField();
    if (_tcslen(dfe->GetPathFile())>0) {
      _tcscpy(startProfileFile,dfe->GetPathFile());
    }
  }

  delete wf;

  wf = NULL;

}
示例#28
0
文件: Asset.hpp 项目: galippi/xcsoar
/**
 * Does this device have a pointer device? (mouse or touch screen)
 * @return True if a touch screen or mouse is assumed for the hardware
 * that XCSoar is running on, False if the hardware has only buttons
 */
static inline bool
has_pointer()
{
  return !is_altair();
}
示例#29
0
文件: Form.cpp 项目: Plantain/XCSoar
int WndForm::ShowModal(bool bEnableMap) {
  assert_none_locked();

#define OPENCLOSESUPPRESSTIME 500
#ifndef ENABLE_SDL
  MSG msg;
  HWND oldFocusHwnd;
#endif /* !ENABLE_SDL */

  PeriodClock enter_clock;
  if (is_embedded() && !is_altair())
    enter_clock.update();

  show_on_top();

  mModalResult = 0;

#ifndef ENABLE_SDL
  oldFocusHwnd = ::GetFocus();
  if (oldFocusHwnd != NULL)
    ::SendMessage(oldFocusHwnd, WM_CANCELMODE, 0, 0);
#endif /* !ENABLE_SDL */
  set_focus();
  focus_first_control();

#ifndef ENABLE_SDL
  bool hastimed = false;
#endif /* !ENABLE_SDL */
  WndForm::timeAnyOpenClose.update(); // when current dlg opens or child closes

  main_window.add_dialog(this);

#ifdef ENABLE_SDL

  update();

  SDL_Event event;
  while (mModalResult == 0 && SDL_WaitEvent(&event)) {
    if (event.type == SDL_QUIT)
      break;

    if (event.type >= SDL_USEREVENT && event.type <= SDL_NUMEVENTS-1 &&
        event.user.data1 != NULL) {
      Window *window = (Window *)event.user.data1;
      window->on_user(event.type - SDL_USEREVENT);
    } else
      parent->on_event(event);
  }

#else /* !ENABLE_SDL */
  while ((mModalResult == 0) && GetMessage(&msg, NULL, 0, 0)) {
//hack!

    // JMW update display timeout so we don't get blanking
    /*
    if (msg.message == WM_KEYDOWN) {
      if (!Debounce()) {
        continue;
      }
    }
    */

    if (msg.message == WM_KEYDOWN) {
      XCSoarInterface::InterfaceTimeoutReset();
    }

    if (is_user_input(msg.message)
        && !identify_descendant(msg.hwnd) // not current window or child
        && !is_allowed_map(msg.hwnd, msg.message, bEnableMap))
      continue;   // make it modal

    // hack to stop exiting immediately
    if (is_embedded() && !is_altair() && !hastimed &&
        is_user_input(msg.message)) {
      if (!enter_clock.check(200))
        /* ignore user input in the first 200ms */
        continue;
      else
        hastimed = true;
    }

    if (is_embedded() && msg.message == WM_LBUTTONUP &&
        !timeAnyOpenClose.check(OPENCLOSESUPPRESSTIME))
      /* prevents child click from being repeat-handled by parent if
         buttons overlap */
      continue;

    if (msg.message == WM_KEYDOWN && mOnKeyDownNotify != NULL &&
        mOnKeyDownNotify(this, msg.wParam))
      continue;

    if (msg.message == WM_KEYDOWN && identify_descendant(msg.hwnd) &&
        (msg.wParam == VK_UP || msg.wParam == VK_DOWN)) {
      /* VK_UP and VK_DOWN move the focus only within the current
         control group - but we want it to behave like Shift-Tab and
         Tab */

      LRESULT r = ::SendMessage(msg.hwnd, WM_GETDLGCODE, msg.wParam,
                                (LPARAM)&msg);
      if ((r & DLGC_WANTMESSAGE) == 0) {
        /* this window doesn't handle VK_UP/VK_DOWN */
        if (msg.wParam == VK_DOWN)
          focus_next_control();
        else
          focus_previous_control();
        continue;
      }
    }

    /* let the WIN32 dialog manager handle hot keys like Tab */
    if (::IsDialogMessage(hWnd, &msg))
      continue;

    TranslateMessage(&msg);
    assert_none_locked();
    DispatchMessage(&msg);
    assert_none_locked();
  } // End Modal Loop
#endif /* !ENABLE_SDL */

  main_window.remove_dialog(this);

  // static.  this is current open/close or child open/close
  WndForm::timeAnyOpenClose.update();

#ifndef ENABLE_SDL
  SetFocus(oldFocusHwnd);
#endif /* !ENABLE_SDL */

  return mModalResult;
}
示例#30
0
文件: Event.cpp 项目: macsux/XCSoar
unsigned
TranscodeKey(unsigned key_code)
{
#ifdef _WIN32_WCE
  /* VK_F23 is the "action" key on some iPaqs */
  if (key_code == VK_F23)
    return VK_RETURN;
#endif

  if (GlobalModelType == MODELTYPE_PNA_HP31X) {
    if (key_code == 0x7b)
      key_code = 0x1b;
  } else if (GlobalModelType == MODELTYPE_PNA_PN6000) {
    switch(key_code) {
    case 0x79: // Upper Silver key short press
      key_code = 0xc1; // F10 -> APP1
      break;
    case 0x7b: // Lower Silver key short press
      key_code = 0xc2; // F12 -> APP2
      break;
    case 0x72: // Back key plus
      key_code = 0xc3; // F3  -> APP3
      break;
    case 0x71: // Back key minus
      key_code = 0xc4; // F2  -> APP4
      break;
    case 0x7a: // Upper silver key LONG press
      key_code = 0x70; // F11 -> F1
      break;
    case 0x7c: // Lower silver key LONG press
      key_code = 0x71; // F13 -> F2
      break;
    }
  } else if (GlobalModelType == MODELTYPE_PNA_NOKIA_500) {
    switch(key_code) {
    case 0xc1:
      key_code = 0x0d; // middle key = enter
      break;
    case 0xc5:
      key_code = 0x26; // + key = pg Up
      break;
    case 0xc6:
      key_code = 0x28; // - key = pg Down
      break;
    }
  } else if (GlobalModelType == MODELTYPE_PNA_MEDION_P5) {
    switch(key_code) {
    case 0x79:
      key_code = 0x0d; // middle key = enter
      break;
    case 0x75:
      key_code = 0x26; // + key = pg Up
      break;
    case 0x76:
      key_code = 0x28; // - key = pg Down
      break;
    }
  } else if (is_altair()){  // handles new keypad driver button codes
    switch(key_code) {
    case VK_F1:
      return VK_APP1;

    case VK_F2:
      return VK_APP2;

    case VK_F3:
      return VK_APP3;

    case VK_F4:
      return VK_APP4;

    case VK_F5:
      key_code = '6';
      break;
    case VK_F6:
      key_code = '7';
      break;
    case VK_F7:
      key_code = '8';
      break;
    case VK_F8:
      key_code = '9';
      break;
    case VK_F9:
      key_code = '0';
      break;
    }
  }

  return key_code;
}