/* MainWindow::setupLayout * Sets up the wxWidgets window layout *******************************************************************/ void MainWindow::setupLayout() { // Create the wxAUI manager & related things m_mgr = new wxAuiManager(this); m_mgr->SetArtProvider(getDockArt()); wxAuiPaneInfo p_inf; // Set icon string icon_filename = appPath("slade.ico", DIR_TEMP); theArchiveManager->programResourceArchive()->getEntry("slade.ico")->exportFile(icon_filename); SetIcon(wxIcon(icon_filename, wxBITMAP_TYPE_ICO)); wxRemoveFile(icon_filename); // -- Editor Area -- stc_tabs = new STabCtrl(this, true, true, 27, true); // Setup panel info & add panel p_inf.CenterPane(); p_inf.Name("editor_area"); p_inf.PaneBorder(false); m_mgr->AddPane(stc_tabs, p_inf); // Create Start Page #ifdef USE_WEBVIEW_STARTPAGE html_startpage = wxWebView::New(stc_tabs, -1, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxWebViewBackendDefault, wxBORDER_NONE); html_startpage->SetName("startpage"); #ifdef __WXMAC__ html_startpage->SetZoomType(wxWEBVIEW_ZOOM_TYPE_TEXT); #else // !__WXMAC__ html_startpage->SetZoomType(wxWEBVIEW_ZOOM_TYPE_LAYOUT); #endif // __WXMAC__ if (show_start_page) { stc_tabs->AddPage(html_startpage,"Start Page"); stc_tabs->SetPageBitmap(0, Icons::getIcon(Icons::GENERAL, "logo")); createStartPage(); } else html_startpage->Show(false); #else html_startpage = new wxHtmlWindow(stc_tabs, -1, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_NEVER, "startpage"); html_startpage->SetName("startpage"); if (show_start_page) { stc_tabs->AddPage(html_startpage, "Start Page"); stc_tabs->SetPageBitmap(0, Icons::getIcon(Icons::GENERAL, "logo")); createStartPage(); } else html_startpage->Show(false); #endif // -- Console Panel -- ConsolePanel* panel_console = new ConsolePanel(this, -1); // Setup panel info & add panel p_inf.DefaultPane(); p_inf.Float(); p_inf.FloatingSize(600, 400); p_inf.FloatingPosition(100, 100); p_inf.MinSize(-1, 192); p_inf.Show(false); p_inf.Caption("Console"); p_inf.Name("console"); m_mgr->AddPane(panel_console, p_inf); // -- Archive Manager Panel -- panel_archivemanager = new ArchiveManagerPanel(this, stc_tabs); // Setup panel info & add panel p_inf.DefaultPane(); p_inf.Left(); p_inf.BestSize(192, 480); p_inf.Caption("Archive Manager"); p_inf.Name("archive_manager"); p_inf.Show(true); p_inf.Dock(); m_mgr->AddPane(panel_archivemanager, p_inf); // -- Undo History Panel -- panel_undo_history = new UndoManagerHistoryPanel(this, NULL); // Setup panel info & add panel p_inf.DefaultPane(); p_inf.Right(); p_inf.BestSize(128, 480); p_inf.Caption("Undo History"); p_inf.Name("undo_history"); p_inf.Show(false); p_inf.Dock(); m_mgr->AddPane(panel_undo_history, p_inf); // -- Menu bar -- wxMenuBar* menu = new wxMenuBar(); menu->SetThemeEnabled(false); // File menu wxMenu* fileNewMenu = new wxMenu(""); theApp->getAction("aman_newwad")->addToMenu(fileNewMenu, true, "&Wad Archive"); theApp->getAction("aman_newzip")->addToMenu(fileNewMenu, true, "&Zip Archive"); theApp->getAction("aman_newmap")->addToMenu(fileNewMenu, true, "&Map"); wxMenu* fileMenu = new wxMenu(""); fileMenu->AppendSubMenu(fileNewMenu, "&New", "Create a new Archive"); theApp->getAction("aman_open")->addToMenu(fileMenu, true); theApp->getAction("aman_opendir")->addToMenu(fileMenu, true); fileMenu->AppendSeparator(); theApp->getAction("aman_save")->addToMenu(fileMenu, true); theApp->getAction("aman_saveas")->addToMenu(fileMenu, true); theApp->getAction("aman_saveall")->addToMenu(fileMenu, true); fileMenu->AppendSubMenu(panel_archivemanager->getRecentMenu(), "&Recent Files"); fileMenu->AppendSeparator(); theApp->getAction("aman_close")->addToMenu(fileMenu, true); theApp->getAction("aman_closeall")->addToMenu(fileMenu, true); fileMenu->AppendSeparator(); theApp->getAction("main_exit")->addToMenu(fileMenu, true); menu->Append(fileMenu, "&File"); // Edit menu wxMenu* editorMenu = new wxMenu(""); theApp->getAction("main_undo")->addToMenu(editorMenu, true); theApp->getAction("main_redo")->addToMenu(editorMenu, true); editorMenu->AppendSeparator(); theApp->getAction("main_setbra")->addToMenu(editorMenu, true); theApp->getAction("main_preferences")->addToMenu(editorMenu, true); menu->Append(editorMenu, "E&dit"); // View menu wxMenu* viewMenu = new wxMenu(""); theApp->getAction("main_showam")->addToMenu(viewMenu, true); theApp->getAction("main_showconsole")->addToMenu(viewMenu, true); theApp->getAction("main_showundohistory")->addToMenu(viewMenu, true); menu->Append(viewMenu, "&View"); // Help menu wxMenu* helpMenu = new wxMenu(""); theApp->getAction("main_onlinedocs")->addToMenu(helpMenu, true); theApp->getAction("main_about")->addToMenu(helpMenu, true); #ifdef __WXMSW__ theApp->getAction("main_updatecheck")->addToMenu(helpMenu, true); #endif menu->Append(helpMenu, "&Help"); // Set the menu SetMenuBar(menu); // -- Toolbars -- toolbar = new SToolBar(this, true); // Create File toolbar SToolBarGroup* tbg_file = new SToolBarGroup(toolbar, "_File"); tbg_file->addActionButton("aman_newwad"); tbg_file->addActionButton("aman_newzip"); tbg_file->addActionButton("aman_open"); tbg_file->addActionButton("aman_opendir"); tbg_file->addActionButton("aman_save"); tbg_file->addActionButton("aman_saveas"); tbg_file->addActionButton("aman_saveall"); tbg_file->addActionButton("aman_close"); tbg_file->addActionButton("aman_closeall"); toolbar->addGroup(tbg_file); // Create Archive toolbar SToolBarGroup* tbg_archive = new SToolBarGroup(toolbar, "_Archive"); tbg_archive->addActionButton("arch_newentry"); tbg_archive->addActionButton("arch_newdir"); tbg_archive->addActionButton("arch_importfiles"); tbg_archive->addActionButton("arch_texeditor"); tbg_archive->addActionButton("arch_mapeditor"); tbg_archive->addActionButton("arch_run"); toolbar->addGroup(tbg_archive); // Create Entry toolbar SToolBarGroup* tbg_entry = new SToolBarGroup(toolbar, "_Entry"); tbg_entry->addActionButton("arch_entry_rename"); tbg_entry->addActionButton("arch_entry_delete"); tbg_entry->addActionButton("arch_entry_import"); tbg_entry->addActionButton("arch_entry_export"); tbg_entry->addActionButton("arch_entry_moveup"); tbg_entry->addActionButton("arch_entry_movedown"); toolbar->addGroup(tbg_entry); // Create Base Resource Archive toolbar SToolBarGroup* tbg_bra = new SToolBarGroup(toolbar, "_Base Resource", true); BaseResourceChooser* brc = new BaseResourceChooser(tbg_bra); tbg_bra->addCustomControl(brc); tbg_bra->addActionButton("main_setbra", "settings"); toolbar->addGroup(tbg_bra); // Create Palette Chooser toolbar SToolBarGroup* tbg_palette = new SToolBarGroup(toolbar, "_Palette", true); palette_chooser = new PaletteChooser(tbg_palette, -1); palette_chooser->selectPalette(global_palette); tbg_palette->addCustomControl(palette_chooser); toolbar->addGroup(tbg_palette); // Archive and Entry toolbars are initially disabled toolbar->enableGroup("_archive", false); toolbar->enableGroup("_entry", false); // Add toolbar m_mgr->AddPane(toolbar, wxAuiPaneInfo().Top().CaptionVisible(false).MinSize(-1, SToolBar::getBarHeight()).Resizable(false).PaneBorder(false).Name("toolbar")); // -- Status Bar -- CreateStatusBar(3); // Load previously saved perspective string loadLayout(); // Finalize m_mgr->Update(); Layout(); // Bind events #ifdef USE_WEBVIEW_STARTPAGE html_startpage->Bind(wxEVT_WEBVIEW_NAVIGATING, &MainWindow::onHTMLLinkClicked, this); #else html_startpage->Bind(wxEVT_COMMAND_HTML_LINK_CLICKED, &MainWindow::onHTMLLinkClicked, this); #endif Bind(wxEVT_SIZE, &MainWindow::onSize, this); Bind(wxEVT_CLOSE_WINDOW, &MainWindow::onClose, this); Bind(wxEVT_AUINOTEBOOK_PAGE_CHANGED, &MainWindow::onTabChanged, this); Bind(wxEVT_STOOLBAR_LAYOUT_UPDATED, &MainWindow::onToolBarLayoutChanged, this, toolbar->GetId()); Bind(wxEVT_ACTIVATE, &MainWindow::onActivate, this); }
/* MapEditorWindow::setupLayout * Sets up the basic map editor window layout *******************************************************************/ void MapEditorWindow::setupLayout() { // Create the wxAUI manager & related things wxAuiManager* m_mgr = new wxAuiManager(this); m_mgr->SetArtProvider(getDockArt()); wxAuiPaneInfo p_inf; // Map canvas map_canvas = new MapCanvas(this, -1, &editor); p_inf.CenterPane(); m_mgr->AddPane(map_canvas, p_inf); // --- Menus --- setupMenu(); // --- Toolbars --- toolbar = new SToolBar(this, true); // Map toolbar SToolBarGroup* tbg_map = new SToolBarGroup(toolbar, "_Map"); tbg_map->addActionButton("mapw_save"); tbg_map->addActionButton("mapw_saveas"); tbg_map->addActionButton("mapw_rename"); toolbar->addGroup(tbg_map); // Mode toolbar SToolBarGroup* tbg_mode = new SToolBarGroup(toolbar, "_Mode"); tbg_mode->addActionButton("mapw_mode_vertices"); tbg_mode->addActionButton("mapw_mode_lines"); tbg_mode->addActionButton("mapw_mode_sectors"); tbg_mode->addActionButton("mapw_mode_things"); tbg_mode->addActionButton("mapw_mode_3d"); theApp->toggleAction("mapw_mode_lines"); // Lines mode by default toolbar->addGroup(tbg_mode); // Flat type toolbar SToolBarGroup* tbg_flats = new SToolBarGroup(toolbar, "_Flats Type"); tbg_flats->addActionButton("mapw_flat_none"); tbg_flats->addActionButton("mapw_flat_untextured"); tbg_flats->addActionButton("mapw_flat_textured"); toolbar->addGroup(tbg_flats); // Toggle current flat type if (flat_drawtype == 0) theApp->toggleAction("mapw_flat_none"); else if (flat_drawtype == 1) theApp->toggleAction("mapw_flat_untextured"); else theApp->toggleAction("mapw_flat_textured"); // Edit toolbar SToolBarGroup* tbg_edit = new SToolBarGroup(toolbar, "_Edit"); tbg_edit->addActionButton("mapw_draw_lines"); tbg_edit->addActionButton("mapw_draw_shape"); tbg_edit->addActionButton("mapw_edit_objects"); tbg_edit->addActionButton("mapw_mirror_x"); tbg_edit->addActionButton("mapw_mirror_y"); toolbar->addGroup(tbg_edit); // Extra toolbar SToolBarGroup* tbg_misc = new SToolBarGroup(toolbar, "_Misc"); tbg_misc->addActionButton("mapw_run_map"); toolbar->addGroup(tbg_misc); // Add toolbar m_mgr->AddPane(toolbar, wxAuiPaneInfo().Top().CaptionVisible(false).MinSize(-1, SToolBar::getBarHeight()).Resizable(false).PaneBorder(false).Name("toolbar")); // Status bar CreateStatusBar(4); int status_widths[4] = { -1, 240, 200, 160 }; SetStatusWidths(4, status_widths); // -- Console Panel -- ConsolePanel* panel_console = new ConsolePanel(this, -1); // Setup panel info & add panel p_inf.DefaultPane(); p_inf.Bottom(); p_inf.Dock(); p_inf.BestSize(480, 192); p_inf.FloatingSize(600, 400); p_inf.FloatingPosition(100, 100); p_inf.MinSize(-1, 192); p_inf.Show(false); p_inf.Caption("Console"); p_inf.Name("console"); m_mgr->AddPane(panel_console, p_inf); // -- Map Object Properties Panel -- panel_obj_props = new MapObjectPropsPanel(this); // Setup panel info & add panel p_inf.Right(); p_inf.BestSize(256, 256); p_inf.FloatingSize(400, 600); p_inf.FloatingPosition(120, 120); p_inf.MinSize(256, 256); p_inf.Show(true); p_inf.Caption("Item Properties"); p_inf.Name("item_props"); m_mgr->AddPane(panel_obj_props, p_inf); // --- Script Editor Panel --- panel_script_editor = new ScriptEditorPanel(this); // Setup panel info & add panel p_inf.Float(); p_inf.BestSize(300, 300); p_inf.FloatingSize(500, 400); p_inf.FloatingPosition(150, 150); p_inf.MinSize(300, 300); p_inf.Show(false); p_inf.Caption("Script Editor"); p_inf.Name("script_editor"); m_mgr->AddPane(panel_script_editor, p_inf); // --- Shape Draw Options Panel --- ShapeDrawPanel* panel_shapedraw = new ShapeDrawPanel(this); // Setup panel info & add panel wxSize msize = panel_shapedraw->GetMinSize(); p_inf.DefaultPane(); p_inf.Bottom(); p_inf.Dock(); p_inf.CloseButton(false); p_inf.CaptionVisible(false); p_inf.Resizable(false); p_inf.Layer(2); p_inf.BestSize(msize.x, msize.y); p_inf.FloatingSize(msize.x, msize.y); p_inf.FloatingPosition(140, 140); p_inf.MinSize(msize.x, msize.y); p_inf.Show(false); p_inf.Caption("Shape Drawing"); p_inf.Name("shape_draw"); m_mgr->AddPane(panel_shapedraw, p_inf); // --- Object Edit Panel --- panel_obj_edit = new ObjectEditPanel(this); // Setup panel info & add panel msize = panel_obj_edit->GetBestSize(); p_inf.Bottom(); p_inf.Dock(); p_inf.CloseButton(false); p_inf.CaptionVisible(false); p_inf.Resizable(false); p_inf.Layer(2); p_inf.BestSize(msize.x, msize.y); p_inf.FloatingSize(msize.x, msize.y); p_inf.FloatingPosition(140, 140); p_inf.MinSize(msize.x, msize.y); p_inf.Show(false); p_inf.Caption("Object Edit"); p_inf.Name("object_edit"); m_mgr->AddPane(panel_obj_edit, p_inf); // --- Map Checks Panel --- panel_checks = new MapChecksPanel(this, &(editor.getMap())); // Setup panel info & add panel p_inf.DefaultPane(); p_inf.Left(); p_inf.Dock(); p_inf.BestSize(400, 300); p_inf.FloatingSize(500, 400); p_inf.FloatingPosition(160, 160); p_inf.MinSize(300, 300); p_inf.Show(false); p_inf.Caption("Map Checks"); p_inf.Name("map_checks"); p_inf.Layer(0); m_mgr->AddPane(panel_checks, p_inf); // -- Undo History Panel -- panel_undo_history = new UndoManagerHistoryPanel(this, NULL); panel_undo_history->setManager(editor.undoManager()); // Setup panel info & add panel p_inf.DefaultPane(); p_inf.Right(); p_inf.BestSize(128, 480); p_inf.Caption("Undo History"); p_inf.Name("undo_history"); p_inf.Show(false); p_inf.Dock(); m_mgr->AddPane(panel_undo_history, p_inf); // Load previously saved window layout loadLayout(); m_mgr->Update(); Layout(); // Initial focus on the canvas, so shortcuts work map_canvas->SetFocus(); }