void XYWndManager::createOrthoView(EViewType viewType) { // Allocate a new XYWindow XYWnd* newWnd = createXY(); // Add the new XYView GL widget to a framed window GtkWidget* window = gtkutil::FramedTransientWidget(XYWnd::getViewTypeTitle(viewType), _globalParentWindow, newWnd->getWidget()); // Connect the destroyed signal to the callback of this class g_signal_connect(G_OBJECT(window), "delete_event", G_CALLBACK(onDeleteOrthoView), newWnd); newWnd->setParent(GTK_WINDOW(window)); // Set the viewtype (and with it the window title) newWnd->setViewType(viewType); }
/** * @brief Create the user settable window layout */ void MainFrame::Create (void) { GtkWindow* window = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL)); // do this here, because the commands are needed _sidebar = new ui::Sidebar(); GtkWidget *sidebar = _sidebar->getWidget(); // Tell the XYManager which window the xyviews should be transient for GlobalXYWnd().setGlobalParentWindow(window); GlobalWindowObservers_connectTopLevel(window); gtk_window_set_transient_for(ui::Splash::Instance().getWindow(), window); #ifndef _WIN32 { GdkPixbuf* pixbuf = gtkutil::getLocalPixbuf(ui::icons::ICON); if (pixbuf != 0) { gtk_window_set_icon(window, pixbuf); g_object_unref(pixbuf); } } #endif gtk_widget_add_events(GTK_WIDGET(window), GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_FOCUS_CHANGE_MASK); g_signal_connect(G_OBJECT(window), "delete_event", G_CALLBACK(mainframe_delete), this); m_position_tracker.connect(window); g_MainWindowActive.connect(window); GtkWidget* vbox = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(window), vbox); gtk_widget_show(vbox); GlobalEventManager().connect(GTK_OBJECT(window)); GlobalEventManager().connectAccelGroup(GTK_WINDOW(window)); m_nCurrentStyle = eSplit; // Create the Filter menu entries ui::FiltersMenu::addItemsToMainMenu(); // Retrieve the "main" menubar from the UIManager GtkMenuBar* mainMenu = GTK_MENU_BAR(GlobalUIManager().getMenuManager()->get("main")); gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(mainMenu), false, false, 0); // Instantiate the ToolbarCreator and retrieve the standard toolbar widget ui::ToolbarCreator toolbarCreator; GtkToolbar* generalToolbar = toolbarCreator.getToolbar("view"); gtk_widget_show(GTK_WIDGET(generalToolbar)); GlobalSelectionSetManager().init(generalToolbar); // Pack it into the main window gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(generalToolbar), FALSE, FALSE, 0); GtkWidget* main_statusbar = create_main_statusbar(m_pStatusLabel); gtk_box_pack_end(GTK_BOX(vbox), main_statusbar, FALSE, TRUE, 2); GtkWidget* hbox = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(hbox), TRUE, TRUE, 0); gtk_widget_show(hbox); GtkToolbar* main_toolbar_v = toolbarCreator.getToolbar("edit"); gtk_widget_show(GTK_WIDGET(main_toolbar_v)); gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(main_toolbar_v), FALSE, FALSE, 0); // Connect the window position tracker _windowPosition.loadFromPath(RKEY_WINDOW_STATE); // Yes, connect the position tracker, this overrides the existing setting. _windowPosition.connect(window); int startMonitor = GlobalRegistry().getInt(RKEY_MULTIMON_START_MONITOR); if (startMonitor < gtkutil::MultiMonitor::getNumMonitors()) { // Load the correct coordinates into the position tracker _windowPosition.fitToScreen(gtkutil::MultiMonitor::getMonitor(startMonitor), 0.8f, 0.8f); } // Apply the position _windowPosition.applyPosition(); int windowState = string::toInt(GlobalRegistry().getAttribute(RKEY_WINDOW_STATE, "state"), GDK_WINDOW_STATE_MAXIMIZED); if (windowState & GDK_WINDOW_STATE_MAXIMIZED) gtk_window_maximize(window); m_window = window; gtk_widget_show(GTK_WIDGET(window)); // The default XYView pointer XYWnd* xyWnd; GtkWidget* mainHBox = gtk_hbox_new(0, 0); gtk_box_pack_start(GTK_BOX(hbox), mainHBox, TRUE, TRUE, 0); gtk_widget_show(mainHBox); int w, h; gtk_window_get_size(window, &w, &h); // camera m_pCamWnd = GlobalCamera().newCamWnd(); GlobalCamera().setCamWnd(m_pCamWnd); GlobalCamera().setParent(m_pCamWnd, window); GtkWidget* camera = m_pCamWnd->getWidget(); // Allocate the three ortho views xyWnd = GlobalXYWnd().createXY(); xyWnd->setViewType(XY); GtkWidget* xy = xyWnd->getWidget(); XYWnd* yzWnd = GlobalXYWnd().createXY(); yzWnd->setViewType(YZ); GtkWidget* yz = yzWnd->getWidget(); XYWnd* xzWnd = GlobalXYWnd().createXY(); xzWnd->setViewType(XZ); GtkWidget* xz = xzWnd->getWidget(); // split view (4 views) GtkHPaned* split = create_split_views(camera, yz, xy, xz); gtk_box_pack_start(GTK_BOX(mainHBox), GTK_WIDGET(split), TRUE, TRUE, 0); // greebo: In any layout, there is at least the XY view present, make it active GlobalXYWnd().setActiveXY(xyWnd); PreferencesDialog_constructWindow(window); GlobalGrid().addGridChangeCallback(FreeCaller<XY_UpdateAllWindows> ()); /* enable button state tracker, set default states for begin */ GlobalUndoSystem().trackerAttach(m_saveStateTracker); gtk_box_pack_start(GTK_BOX(mainHBox), GTK_WIDGET(sidebar), FALSE, FALSE, 0); // Start the autosave timer so that it can periodically check the map for changes map::AutoSaver().startTimer(); }