コード例 #1
0
void
InfoBoxesConfigWidget::OnCopy()
{
  clipboard = data;
  clipboard_size = InfoBoxSettings::Panel::MAX_CONTENTS;

  RefreshPasteButton();
}
コード例 #2
0
ファイル: dlgConfigInfoboxes.cpp プロジェクト: macsux/XCSoar
static void
OnCopy(gcc_unused WndButton &button)
{
  clipboard = data;
  clipboard_size = InfoBoxSettings::Panel::MAX_CONTENTS;

  RefreshPasteButton();
}
コード例 #3
0
void
InfoBoxesConfigWidget::Prepare(ContainerWindow &parent,
                               const PixelRect &rc)
{
  const Layout layout(rc, geometry);

  AddText(_("Name"), nullptr,
          allow_name_change ? (const TCHAR *)data.name : gettext(data.name));
  SetReadOnly(NAME, !allow_name_change);

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

  Add(_("InfoBox"), nullptr, dfe);

  dfe = new DataFieldEnum(this);
  for (unsigned i = InfoBoxFactory::MIN_TYPE_VAL; i < InfoBoxFactory::NUM_TYPES; i++) {
    const TCHAR *name = InfoBoxFactory::GetName((InfoBoxFactory::Type) i);
    const TCHAR *desc = InfoBoxFactory::GetDescription((InfoBoxFactory::Type) i);
    if (name != NULL)
      dfe->addEnumText(gettext(name), i, desc != NULL ? gettext(desc) : NULL);
  }

  dfe->EnableItemHelp(true);
  dfe->Sort(0);

  Add(_("Content"), nullptr, dfe);

  ContainerWindow &form_parent = (ContainerWindow &)RowFormWidget::GetWindow();
  AddRemaining(new WndFrame(form_parent, GetLook(), rc));

  WindowStyle button_style;
  button_style.Hide();
  button_style.TabStop();

  const auto &button_look = GetLook().button;
  copy_button.Create(parent, button_look, _("Copy"), layout.copy_button,
                     button_style, *this, COPY);
  paste_button.Create(parent, button_look, _("Paste"), layout.paste_button,
                      button_style, *this, PASTE);
  close_button.Create(parent, button_look, _("Close"), layout.close_button,
                      button_style, dialog, mrOK);

  WindowStyle preview_style;
  preview_style.EnableDoubleClicks();
  preview_style.Hide();

  previews.resize(layout.info_boxes.count);
  for (unsigned i = 0; i < layout.info_boxes.count; ++i) {
    previews[i].SetParent(*this, i);
    previews[i].Create(parent, layout.info_boxes.positions[i],
                       preview_style);
  }

  current_preview = 0;

  RefreshEditContent();
  RefreshPasteButton();
}
コード例 #4
0
ファイル: dlgConfigInfoboxes.cpp プロジェクト: macsux/XCSoar
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;
}
コード例 #5
0
bool
dlgConfigInfoboxesShowModal(SingleWindow &parent,
                            const DialogLook &dialog_look,
                            const InfoBoxLook &_look,
                            InfoBoxSettings::Geometry geometry,
                            InfoBoxSettings::Panel &data_r,
                            bool allow_name_change)
{
  current_preview = 0;
  look = &_look;
  data = data_r;

  PixelRect rc = parent.GetClientRect();
  wf = new WndForm(parent, dialog_look, rc);

#ifdef _WIN32_WCE
  if (IsAltair())
    wf->SetKeyDownFunction(OnKeyDown);
#endif

  ContainerWindow &client_area = wf->GetClientAreaWindow();
  rc = client_area.GetClientRect();
  rc.Grow(Layout::FastScale(-2));
  info_box_layout = InfoBoxLayout::Calculate(rc, geometry);

  WindowStyle preview_style;
  preview_style.EnableDoubleClicks();
  for (unsigned i = 0; i < info_box_layout.count; ++i) {
    rc = info_box_layout.positions[i];
    previews[i].Create(client_area, rc, preview_style);
  }

  rc = info_box_layout.remaining;

  WindowStyle style;
  style.TabStop();

  PixelRect control_rc = rc;
  control_rc.right -= Layout::FastScale(2);

  const UPixelScalar height = Layout::Scale(22);
  const UPixelScalar caption_width = Layout::Scale(60);

  ButtonWindowStyle button_style;
  button_style.TabStop();

  control_rc.bottom = control_rc.top + height;
  edit_name = new WndProperty(client_area, dialog_look, _("Name"),
                              control_rc, caption_width,
                              style);
  DataFieldString *dfs = new DataFieldString(allow_name_change
                                             ? (const TCHAR *)data.name
                                             : gettext(data.name));
  edit_name->SetDataField(dfs);
  edit_name->SetReadOnly(!allow_name_change);

  control_rc.top = control_rc.bottom;
  control_rc.bottom = control_rc.top + height;

  edit_select = new WndProperty(client_area, dialog_look, _("InfoBox"),
                                control_rc, caption_width,
                                style);

  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);

  control_rc.top += height;
  control_rc.bottom += height;

  edit_content = new WndProperty(client_area, dialog_look, _("Content"),
                                 control_rc, caption_width,
                                 style);

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

  dfe->EnableItemHelp(true);
  dfe->Sort(0);

  edit_content->SetDataField(dfe);

  control_rc.top += height;
  control_rc.bottom += height * 5;
  edit_content_description = new WndFrame(client_area, dialog_look,
                                          control_rc, style);

  RefreshEditContent();

  const UPixelScalar button_width = Layout::Scale(60);
  const UPixelScalar button_height = Layout::Scale(28);

  PixelRect button_rc = rc;
  button_rc.right = button_rc.left + button_width;
  button_rc.top = button_rc.bottom - button_height;

  WndButton *close_button =
    new WndButton(client_area, dialog_look.button, _("Close"),
                  button_rc, button_style, *wf, mrOK);

  button_rc.left += button_width + Layout::Scale(2);
  button_rc.right += button_width + Layout::Scale(2);
  WndButton *copy_button =
    new WndButton(client_area, dialog_look.button, _("Copy"),
                  button_rc, button_style, OnCopy);

  button_rc.left += button_width + Layout::Scale(2);
  button_rc.right += button_width + Layout::Scale(2);
  buttonPaste =
    new WndButton(client_area, dialog_look.button, _("Paste"),
                  button_rc, button_style, OnPaste);

  RefreshPasteButton();

  int result = wf->ShowModal();

  if (result == mrOK && allow_name_change)
    data.name = edit_name->GetDataField()->GetAsString();

  delete wf;
  delete edit_name;
  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;
}