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); }
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(); }
void Move(const PixelRect &rc) override { const Layout layout(rc, waypoint); if (allow_navigation) goto_button.Move(layout.goto_button); if (!images.empty()) { magnify_button.Move(layout.magnify_button); shrink_button.Move(layout.shrink_button); } if (allow_navigation) { previous_button.Move(layout.previous_button); next_button.Move(layout.next_button); } close_button.Move(layout.close_button); info_dock.Move(layout.main); details_panel.Move(layout.main); details_text.Move(layout.details_text); #ifdef HAVE_RUN_FILE if (!waypoint.files_external.empty()) file_list.Move(layout.file_list); #endif commands_dock.Move(layout.main); if (!images.empty()) image_window.Move(layout.main); }
void Show(const PixelRect &rc) override { const Layout layout(rc, *waypoint); if (task_manager != nullptr) goto_button.MoveAndShow(layout.goto_button); if (!images.empty()) { magnify_button.MoveAndShow(layout.magnify_button); shrink_button.MoveAndShow(layout.shrink_button); } previous_button.MoveAndShow(layout.previous_button); next_button.MoveAndShow(layout.next_button); close_button.MoveAndShow(layout.close_button); info_dock.Move(layout.main); details_panel.Move(layout.main); details_text.Move(layout.details_text); #ifdef HAVE_RUN_FILE if (!waypoint->files_external.empty()) file_list.Move(layout.file_list); #endif commands_dock.Move(layout.main); if (!images.empty()) image_window.Move(layout.main); UpdatePage(); }
static bool FormKeyDown(unsigned key_code) { switch (key_code) { LargeTextWindow *edit; case KEY_UP: edit = FindLargeTextWindow(); if (edit != NULL) { edit->ScrollVertically(-3); return true; } else return false; case KEY_DOWN: edit = FindLargeTextWindow(); if (edit != NULL) { edit->ScrollVertically(3); return true; } else return false; case KEY_LEFT: #ifdef GNAV case '6': #endif tab->PreviousPage(); return true; case KEY_RIGHT: #ifdef GNAV case '7': #endif tab->NextPage(); return true; default: return false; } }
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(); }
void dlgWaypointDetailsShowModal(const Waypoint &_waypoint, bool allow_navigation) { waypoint = &_waypoint; form = LoadDialog(CallBackTable, UIGlobals::GetMainWindow(), Layout::landscape ? _T("IDR_XML_WAYPOINTDETAILS_L") : _T("IDR_XML_WAYPOINTDETAILS")); assert(form != nullptr); LastUsedWaypoints::Add(_waypoint); UpdateCaption(); form->SetKeyDownFunction(FormKeyDown); info_widget = (DockWindow *)form->FindByName(_T("info")); assert(info_widget != nullptr); info_widget->SetWidget(new WaypointInfoWidget(UIGlobals::GetDialogLook(), _waypoint)); commands_widget = (DockWindow *)form->FindByName(_T("commands")); assert(commands_widget != nullptr); commands_widget->SetWidget(new WaypointCommandsWidget(UIGlobals::GetDialogLook(), form, _waypoint, protected_task_manager)); commands_widget->Hide(); details_panel = form->FindByName(_T("frmDetails")); assert(details_panel != nullptr); ListControl *wFilesList = (ListControl *)form->FindByName(_T("Files")); assert(wFilesList != nullptr); LargeTextWindow *wDetailsText = (LargeTextWindow *) form->FindByName(_T("Details")); assert(wDetailsText != nullptr); wDetailsText->SetText(waypoint->details.c_str()); #ifdef ANDROID WaypointExternalFileListHandler handler; int num_files = std::distance(waypoint->files_external.begin(), waypoint->files_external.end()); if (num_files > 0) { wFilesList->SetItemRenderer(&handler); wFilesList->SetCursorHandler(&handler); unsigned list_height = wFilesList->GetItemHeight() * std::min(num_files, 5); wFilesList->Resize(wFilesList->GetWidth(), list_height); wFilesList->SetLength(num_files); PixelRect rc = wDetailsText->GetPosition(); rc.top += list_height; wDetailsText->Move(rc); } else #endif wFilesList->Hide(); image_window = (PaintWindow *)form->FindByName(_T("frmImage")); assert(image_window != nullptr); magnify_button = (WndButton *)form->FindByName(_T("cmdMagnify")); assert(magnify_button != nullptr); shrink_button = (WndButton *)form->FindByName(_T("cmdShrink")); assert(shrink_button != nullptr); if (!allow_navigation) { for (const TCHAR *button_name : { _T("cmdPrev"), _T("cmdNext"), _T("cmdGoto") }) { Window *button = form->FindByName(button_name); assert(button != nullptr); button->Hide(); } } for (auto it = waypoint->files_embed.begin(), it_end = waypoint->files_embed.end(); it != it_end && !images.full(); it++) { TCHAR path[MAX_PATH]; LocalPath(path, it->c_str()); if (!images.append().LoadFile(path)) images.shrink(images.size() - 1); } last_page = 2 + images.size(); page = 0; UpdatePage(); form->ShowModal(); delete form; for (auto image = images.begin(); image < images.end(); image++) image->Reset(); images.clear(); }