Exemplo n.º 1
0
bool
dlgTaskPointType(OrderedTask &task, const unsigned index)
{
  point_types.clear();
  task.GetFactory().GetValidTypes(index)
    .CopyTo(std::back_inserter(point_types));

  if (point_types.empty()) {
    assert(1);
    return false;
  }

  if (point_types.size() == 1)
    return SetPointType(task, index, point_types[0]);

  const auto &point = task.GetPoint(index);
  const auto current_type = task.GetFactory().GetType(point);

  unsigned initial_index = 0;
  const auto b = point_types.begin(), e = point_types.end();
  auto i = std::find(b, e, current_type);
  if (i != e)
    initial_index = std::distance(b, i);

  MutateTaskPointRenderer item_renderer(current_type);

  int result = ListPicker(_("Task Point Type"),
                          point_types.size(), initial_index,
                          item_renderer.CalculateLayout(UIGlobals::GetDialogLook()),
                          item_renderer, false,
                          nullptr, TPTypeItemHelp);
  return result >= 0 && SetPointType(task, index, point_types[result]);
}
Exemplo n.º 2
0
void
ManagedFileListWidget::RefreshList()
{
  items.clear();

  bool download_active = false;
  for (auto i = repository.begin(), end = repository.end(); i != end; ++i) {
    const auto &remote_file = *i;
    DownloadStatus download_status;
    const bool is_downloading = IsDownloading(remote_file, download_status);

    TCHAR path[MAX_PATH];
    if (LocalPath(path, remote_file) &&
        (is_downloading || File::Exists(path))) {
      download_active |= is_downloading;
      items.append().Set(BaseName(path),
                         is_downloading ? &download_status : NULL,
                         HasFailed(remote_file));
    }
  }

  ListControl &list = GetList();
  list.SetLength(items.size());
  list.Invalidate();

#ifdef HAVE_DOWNLOAD_MANAGER
  if (download_active && !Timer::IsActive())
    Timer::Schedule(1000);
#endif
}
Exemplo n.º 3
0
bool
dlgTaskPointType(OrderedTask** task, const unsigned index)
{
  ordered_task = *task;
  active_index = index;

  point = &ordered_task->GetPoint(active_index);

  point_types.clear();
  ordered_task->GetFactory().GetValidTypes(index)
    .CopyTo(std::back_inserter(point_types));

  if (point_types.empty()) {
    assert(1);
    return false;
  }

  if (point_types.size() == 1)
    return SetPointType(point_types[0]);

  unsigned initial_index = 0;
  const auto b = point_types.begin(), e = point_types.end();
  auto i = std::find(b, e, get_point_type());
  if (i != e)
    initial_index = std::distance(b, i);

  FunctionListItemRenderer item_renderer(OnPointPaintListItem);

  int result = ListPicker(_("Task Point Type"),
                          point_types.size(), initial_index,
                          Layout::Scale(18),
                          item_renderer, false,
                          nullptr, TPTypeItemHelp);
  return result >= 0 && SetPointType(point_types[result]);
}
Exemplo n.º 4
0
void
ManagedFileListWidget::RefreshList()
{
  items.clear();

  bool download_active = false;
  for (auto i = repository.begin(), end = repository.end(); i != end; ++i) {
    const auto &remote_file = *i;
    DownloadStatus download_status;
    const bool is_downloading = IsDownloading(remote_file, download_status);

    const auto path = LocalPath(remote_file);
    if (!path.IsNull() &&
        (is_downloading || File::Exists(path))) {
      download_active |= is_downloading;

      const Path base = path.GetBase();
      if (base.IsNull())
        continue;

      items.append().Set(base.c_str(),
                         is_downloading ? &download_status : nullptr,
                         HasFailed(remote_file));
    }
  }

  ListControl &list = GetList();
  list.SetLength(items.size());
  list.Invalidate();

#ifdef HAVE_DOWNLOAD_MANAGER
  if (download_active && !Timer::IsActive())
    Timer::Schedule(1000);
#endif
}
Exemplo n.º 5
0
bool
KRT2Device::DataReceived(const void *_data, size_t length,
                         struct NMEAInfo &info)
{
  assert(length > 0);

  const char *data = static_cast<const char *>(_data);
  const char *end = data + length;
  bool result = false;

  unsigned expected_size = 0;
  do {
    if (!input_buffer.empty()) {
      input_buffer.append(*data);
      if (!expected_size)
        expected_size = FrameSize(input_buffer[1]);

      if (input_buffer.size() == expected_size) {
        // frame complete
        result |= ParseFrame(info);
        input_buffer.clear();
      } else if (input_buffer.full()) {
        // too much data (will never happen when buffer >= max(expected_size))
        input_buffer.clear();
      }
    } else if (*data == SYNC) {
      // reply to SYNC from radio
      port.Write(SYNC_ACK);
    } else if (*data == STX) {
      // found start of new frame
      input_buffer.append(*data);
      expected_size = 0;
    } else if (*data == ACK) {
      // previous command accepted
    } else if (*data == NAK) {
      // previous command rejected
    }
  } while (++data != end);

  return result;
}
Exemplo n.º 6
0
void
WifiListWidget::UpdateList()
{
  status.Clear();

  if (EnsureConnected()) {
    wpa_supplicant.Status(status);

    for (auto &i : networks)
      i.old_visible = i.old_configured = true;

    UpdateScanResults();
    UpdateConfigured();

    /* remove items that are still marked as "old" */
    SweepList();
  } else
    networks.clear();

  GetList().SetLength(networks.size());

  UpdateButtons();
}
Exemplo n.º 7
0
void
NOAAListWidget::UpdateList()
{
  stations.clear();

  for (auto i = noaa_store->begin(), end = noaa_store->end(); i != end; ++i) {
    NOAAListItem item;
    item.code = i->GetCodeT();
    item.iterator = i;
    stations.push_back(item);
  }

  std::sort(stations.begin(), stations.end());

  ListControl &list = GetList();
  list.SetLength(stations.size());
  list.Invalidate();

  const bool empty = stations.empty(), full = stations.full();
  add_button->SetEnabled(!full);
  update_button->SetEnabled(!empty);
  remove_button->SetEnabled(!empty);
  details_button->SetEnabled(!empty);
}
Exemplo n.º 8
0
 void Clear() {
   new_traffic.Clear();
   list.clear();
 }
Exemplo n.º 9
0
void
dlgQuickMenuShowModal(SingleWindow &parent)
{
  const Menu *menu = InputEvents::GetMenu(_T("RemoteStick"));
  if (menu == NULL)
    return;

  const DialogLook &dialog_look = UIGlobals::GetDialogLook();

  WindowStyle dialogStyle;
  dialogStyle.Hide();
  dialogStyle.ControlParent();

  wf = new WndForm(parent, dialog_look, parent.get_client_rect(),
                   _T("Quick Menu"), dialogStyle);

  ContainerWindow &client_area = wf->GetClientAreaWindow();

  PixelRect r = client_area.get_client_rect();

  WindowStyle grid_view_style;
  grid_view_style.ControlParent();

  grid_view = new GridView(client_area,
                           r.left, r.top,
                           r.right - r.left, r.bottom - r.top,
                           dialog_look, grid_view_style);

  WindowStyle buttonStyle;
  buttonStyle.TabStop();

  for (unsigned i = 0; i < menu->MAX_ITEMS; ++i) {
    if (buttons.full())
      continue;

    const MenuItem &menuItem = (*menu)[i];
    if (!menuItem.IsDefined())
      continue;

    TCHAR buffer[100];
    ButtonLabel::Expanded expanded =
      ButtonLabel::Expand(menuItem.label, buffer, ARRAY_SIZE(buffer));
    if (!expanded.visible)
      continue;

    PixelRect button_rc;
    button_rc.left = 0;
    button_rc.top = 0;
    button_rc.right = 80;
    button_rc.bottom = 30;
    WndButton *button =
      new WndCustomButton(*grid_view, dialog_look, expanded.text,
                          button_rc, buttonStyle, OnButtonClicked);
    button->set_enabled(expanded.enabled);

    buttons.append(button);
    events.append(menuItem.event);
  }

  grid_view->SetItems(buttons);
  SetFormDefaultFocus();
  SetFormCaption();

  wf->SetKeyDownNotify(FormKeyDown);

  wf->ShowModal();

  for (auto it = buttons.begin(), end = buttons.end(); it != end; ++it)
    delete *it;

  buttons.clear();
  events.clear();

  delete wf;
  delete grid_view;
}