Пример #1
0
void
RowFormWidget::AddMultiLine(const TCHAR *text)
{
  assert(IsDefined());

  const PixelRect rc =
    InitialControlRect(Layout::GetMinimumControlHeight());

  LargeTextWindowStyle style;
  if (IsEmbedded() || Layout::scale_1024 < 2048)
    /* sunken edge doesn't fit well on the tiny screen of an embedded
       device */
    style.Border();
  else
    style.SunkenEdge();

  PanelControl &panel = *(PanelControl *)GetWindow();
  LargeTextWindow *ltw = new LargeTextWindow();
  ltw->Create(panel, rc, style);
  ltw->SetFont(*look.text_font);

  if (text != nullptr)
    ltw->SetText(text);

  Add(Row::Type::MULTI_LINE, ltw);
}
Пример #2
0
void
FontEditWidget::Prepare(ContainerWindow &parent, const PixelRect &rc)
{
  RowFormWidget::Prepare(parent, rc);

#ifdef USE_GDI
  WndProperty *wp = AddEnum(_("Font face"), NULL, this);
  {
    DataFieldEnum &df = *(DataFieldEnum *)wp->GetDataField();
    df.addEnumText(_T("Tahoma"));
    df.addEnumText(_T("TahomaBD"));
    df.addEnumText(_T("DejaVu Sans Condensed"));
  }
#else
  /* we cannot obtain a list of fonts on SDL/OpenGL currently */
#endif

  AddInteger(_("Height"), NULL, _T("%d"), _T("%d"), 1, 200, 1, 0, this);
  AddBoolean(_("Bold"), NULL, false, this);
  AddBoolean(_("Italic"), NULL, false, this);

  PixelRect preview_rc { 0, 0, Layout::Scale(250), Layout::Scale(100) };
  LargeTextWindowStyle preview_style;
  preview_style.Border();
  LargeTextWindow *preview = new LargeTextWindow();
  preview->Create((ContainerWindow &)GetWindow(), preview_rc, preview_style);
  Add(preview);

  Load();
}
Пример #3
0
void
WaypointDetailsWidget::Prepare(ContainerWindow &parent, const PixelRect &rc)
{
  for (const auto &i : waypoint.files_embed) {
    if (images.full())
      break;

    try {
      if (!images.append().LoadFile(LocalPath(i.c_str())))
        images.shrink(images.size() - 1);
    } catch (const std::exception &e) {
      LogFormat("Failed to load %s: %s",
                (const char *)NarrowPathName(Path(i.c_str())),
                e.what());
      images.shrink(images.size() - 1);
    }
  }

  const Layout layout(rc, waypoint);

  WindowStyle dock_style;
  dock_style.Hide();
  dock_style.ControlParent();

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

  if (allow_navigation)
    goto_button.Create(parent, look.button, _("GoTo"), layout.goto_button,
                       button_style, *this, GOTO);

  if (!images.empty()) {
    magnify_button.Create(parent, layout.magnify_button, button_style,
                          new SymbolButtonRenderer(look.button, _T("+")),
                          *this, MAGNIFY);
    shrink_button.Create(parent, layout.shrink_button, button_style,
                         new SymbolButtonRenderer(look.button, _T("-")),
                         *this, SHRINK);
  }

  if (allow_navigation) {
    previous_button.Create(parent, layout.previous_button, button_style,
                           new SymbolButtonRenderer(look.button, _T("<")),
                           *this, PREVIOUS);
    next_button.Create(parent, layout.next_button, button_style,
                       new SymbolButtonRenderer(look.button, _T(">")),
                       *this, NEXT);
  }

  close_button.Create(parent, look.button, _("Close"), layout.close_button,
                      button_style, dialog, mrOK);

  info_dock.Create(parent, layout.main, dock_style);
  info_dock.SetWidget(&info_widget);

  details_panel.Create(parent, look, layout.main, dock_style);
  details_text.Create(details_panel, layout.details_text);
  details_text.SetFont(look.text_font);
  details_text.SetText(waypoint.details.c_str());

#ifdef HAVE_RUN_FILE
  const unsigned num_files = std::distance(waypoint.files_external.begin(),
                                           waypoint.files_external.end());
  if (num_files > 0) {
    file_list.Create(details_panel, layout.file_list,
                     WindowStyle(), layout.file_list_item_height);
    file_list.SetItemRenderer(&file_list_handler);
    file_list.SetCursorHandler(&file_list_handler);
    file_list.SetLength(num_files);
  }
#endif

  commands_dock.Create(parent, layout.main, dock_style);
  commands_dock.SetWidget(&commands_widget);

  if (!images.empty())
    image_window.Create(parent, layout.main, dock_style,
                        [this](Canvas &canvas, const PixelRect &rc){
                          OnImagePaint(canvas, rc);
                        });

  last_page = 2 + images.size();
}