void dlgWaypointDetailsShowModal(SingleWindow &parent, const Waypoint &_waypoint, bool allow_navigation) { waypoint = &_waypoint; wf = LoadDialog(CallBackTable, parent, Layout::landscape ? _T("IDR_XML_WAYPOINTDETAILS_L") : _T("IDR_XML_WAYPOINTDETAILS")); assert(wf != NULL); LastUsedWaypoints::Add(_waypoint); UpdateCaption(waypoint->name.c_str(), waypoint->file_num); wf->SetKeyDownNotify(FormKeyDown); wInfo = (DockWindow *)wf->FindByName(_T("info")); assert(wInfo != NULL); wInfo->SetWidget(new WaypointInfoWidget(UIGlobals::GetDialogLook(), _waypoint)); wCommand = (DockWindow *)wf->FindByName(_T("commands")); assert(wCommand != NULL); wCommand->SetWidget(new WaypointCommandsWidget(UIGlobals::GetDialogLook(), wf, _waypoint, protected_task_manager)); wCommand->Hide(); wDetails = wf->FindByName(_T("frmDetails")); assert(wDetails != NULL); ListControl *wFilesList = (ListControl *)wf->FindByName(_T("Files")); assert(wFilesList != NULL); EditWindow *wDetailsText = (EditWindow *)wf->FindByName(_T("Details")); assert(wDetailsText != NULL); wDetailsText->SetText(waypoint->details.c_str()); #ifdef ANDROID int num_files = std::distance(waypoint->files_external.begin(), waypoint->files_external.end()); if (num_files > 0) { wFilesList->SetPaintItemCallback(OnFileListItemPaint); wFilesList->SetCursorCallback(OnFileListEnter); wFilesList->SetActivateCallback(OnFileListEnter); 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(); wImage = (PaintWindow *)wf->FindByName(_T("frmImage")); assert(wImage != NULL); wMagnify = (WndButton *)wf->FindByName(_T("cmdMagnify")); assert(wMagnify != NULL); wShrink = (WndButton *)wf->FindByName(_T("cmdShrink")); assert(wShrink != NULL); if (!allow_navigation) { WndButton* butnav = (WndButton *)wf->FindByName(_T("cmdPrev")); assert(butnav != NULL); butnav->Hide(); butnav = (WndButton *)wf->FindByName(_T("cmdNext")); assert(butnav != NULL); butnav->Hide(); butnav = (WndButton *)wf->FindByName(_T("cmdGoto")); assert(butnav != NULL); butnav->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); } page = 0; NextPage(0); // JMW just to turn proper pages on/off wf->ShowModal(); delete wf; for (auto image = images.begin(); image < images.end(); image++) image->Reset(); images.clear(); }
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(); }