Exemplo n.º 1
0
void
MainWindow::on_pause()
{
  if (!map.defined() && has_dialog())
    /* suspending before initialization has finished doesn't leave
       anything worth resuming, so let's just quit now */
    CancelDialog();

  SingleWindow::on_pause();
}
Exemplo n.º 2
0
/**
 * \brief Changes the id of a dialog.
 * \param old_dialog_id Old id of the dialog.
 * \param new_dialog_id New id to set.
 * \return \c true in case of success.
 * In case of failure, the old dialog is unchanged.
 */
bool DialogResources::set_dialog_id(
    const std::string& old_dialog_id, const std::string& new_dialog_id) {

  if (!has_dialog(old_dialog_id)) {
    // No dialog was found with the old id.
    return false;
  }

  if (has_dialog(new_dialog_id)) {
    // The new id is already used.
    return false;
  }

  DialogData dialog = get_dialog(old_dialog_id);
  remove_dialog(old_dialog_id);
  add_dialog(new_dialog_id, dialog);

  return true;
}
Exemplo n.º 3
0
bool
MainWindow::on_setfocus()
{
  if (!has_dialog()) {
    /* the main window should never have the keyboard focus; if we
       happen to get the focus despite of that, forward it to the map
       window to make keyboard shortcuts work */
    if (map.defined())
      map.set_focus();
    return true;
  }

  return SingleWindow::on_setfocus();
}
Exemplo n.º 4
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();
}