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(); }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, #ifdef _WIN32_WCE LPWSTR lpCmdLine, #else LPSTR lpCmdLine2, #endif int nCmdShow) #endif { #ifdef WIN32 #ifndef _WIN32_WCE /* on Windows (non-CE), the lpCmdLine argument is narrow, and we have to use GetCommandLine() to get the UNICODE string */ LPCTSTR lpCmdLine = GetCommandLine(); #endif #ifdef _WIN32_WCE int argc = 2; WCHAR arg0[] = _T(""); LPWSTR argv[] = { arg0, lpCmdLine, NULL }; #else int argc; LPWSTR* argv = CommandLineToArgvW(lpCmdLine, &argc); #endif ResourceLoader::Init(hInstance); #endif if (argc < 2) { fprintf(stderr, "Usage: RunDialog XMLFILE [-portrait]\n"); return 1; } unsigned screen_width = 320, screen_height = 240; if (argc > 2 && _tcscmp(argv[2], _T("-portrait")) == 0) { screen_width = 240; screen_height = 320; } ScreenGlobalInit screen_init; Layout::Initialize(screen_width, screen_height); SingleWindow main_window; main_window.set(_T("STATIC"), _T("RunDialog"), 0, 0, screen_width, screen_height); main_window.show(); WndForm *form = LoadDialog(NULL, main_window, argv[1]); if (form == NULL) { fprintf(stderr, "Failed to load resource '%s'\n", (const char *)NarrowPathName(argv[1])); return 1; } form->ShowModal(); delete form; return 0; }