AddPropertyDialog::AddPropertyDialog(Entity* entity) : wxutil::DialogBase(_(ADDPROPERTY_TITLE)), _entity(entity) { Connect(wxEVT_CLOSE_WINDOW, wxCloseEventHandler(AddPropertyDialog::_onDeleteEvent), NULL, this); wxPanel* mainPanel = loadNamedPanel(this, "AddPropertyDialogPanel"); _treeView = wxutil::TreeView::Create(mainPanel, wxBORDER_STATIC | wxDV_MULTIPLE | wxDV_NO_HEADER); mainPanel->GetSizer()->Prepend(_treeView, 1, wxEXPAND | wxALL, 6); wxButton* okButton = findNamedObject<wxButton>(mainPanel, "OkButton"); okButton->Connect(wxEVT_BUTTON, wxCommandEventHandler(AddPropertyDialog::_onOK), NULL, this); wxButton* cancelButton = findNamedObject<wxButton>(mainPanel, "CancelButton"); cancelButton->Connect(wxEVT_BUTTON, wxCommandEventHandler(AddPropertyDialog::_onCancel), NULL, this); FitToScreen(0.5f, 0.6f); // Populate the tree view with properties setupTreeView(); populateTreeView(); updateUsagePanel(); }
EntityChooser::EntityChooser() : DialogBase(_("Select Entity")), _entityStore(new wxutil::TreeModel(_listColumns, true)), _entityView(NULL) { SetSizer(new wxBoxSizer(wxVERTICAL)); wxBoxSizer* vbox = new wxBoxSizer(wxVERTICAL); GetSizer()->Add(vbox, 1, wxEXPAND | wxALL, 12); _entityView = wxutil::TreeView::Create(this, wxDV_NO_HEADER); vbox->Add(_entityView, 1, wxEXPAND | wxBOTTOM, 12); vbox->Add(CreateStdDialogButtonSizer(wxOK | wxCANCEL), 0, wxALIGN_RIGHT); FitToScreen(0.3f, 0.6f); // Use the TreeModel's full string search function _entityView->AddSearchColumn(_listColumns.name); // Head Name column _entityView->AppendTextColumn("#", _listColumns.name.getColumnIndex(), wxDATAVIEW_CELL_INERT, wxCOL_WIDTH_AUTOSIZE, wxALIGN_NOT, wxDATAVIEW_COL_SORTABLE); populateEntityList(); }
ModelSelector::ModelSelector() : DialogBase(_(MODELSELECTOR_TITLE)), _dialogPanel(loadNamedPanel(this, "ModelSelectorPanel")), _treeStore(new wxutil::TreeModel(_columns)), _treeStoreWithSkins(new wxutil::TreeModel(_columns)), _infoTable(NULL), _materialsList(NULL), _lastModel(""), _lastSkin(""), _populated(false), _showOptions(true) { // Set the default size of the window _position.connect(this); _position.readPosition(); wxPanel* rightPanel = findNamedObject<wxPanel>(this, "ModelSelectorRightPanel"); _modelPreview.reset(new wxutil::ModelPreview(rightPanel)); rightPanel->GetSizer()->Add(_modelPreview->getWidget(), 1, wxEXPAND); // The model preview is half the width and 20% of the parent's height (to // allow vertical shrinking) _modelPreview->setSize(static_cast<int>(_position.getSize()[0]*0.4f), static_cast<int>(_position.getSize()[1]*0.2f)); wxPanel* leftPanel = findNamedObject<wxPanel>(this, "ModelSelectorLeftPanel"); // Set up view widgets setupAdvancedPanel(leftPanel); // Connect buttons findNamedObject<wxButton>(this, "ModelSelectorOkButton")->Connect( wxEVT_BUTTON, wxCommandEventHandler(ModelSelector::onOK), NULL, this); findNamedObject<wxButton>(this, "ModelSelectorCancelButton")->Connect( wxEVT_BUTTON, wxCommandEventHandler(ModelSelector::onCancel), NULL, this); Connect(wxEVT_CLOSE_WINDOW, wxCloseEventHandler(ModelSelector::_onDeleteEvent), NULL, this); FitToScreen(0.8f, 0.8f); wxSplitterWindow* splitter = findNamedObject<wxSplitterWindow>(this, "ModelSelectorSplitter"); splitter->SetSashPosition(static_cast<int>(GetSize().GetWidth() * 0.2f)); splitter->SetMinimumPaneSize(10); // disallow unsplitting _panedPosition.connect(splitter); _panedPosition.loadFromPath(RKEY_SPLIT_POS); }
// Construct the dialog LightTextureChooser::LightTextureChooser() : wxutil::DialogBase(_("Choose texture"), GlobalMainFrame().getWxTopLevelWindow()) { // Create a default panel to this dialog wxPanel* mainPanel = new wxPanel(this, wxID_ANY); mainPanel->SetSizer(new wxBoxSizer(wxVERTICAL)); wxBoxSizer* dialogVBox = new wxBoxSizer(wxVERTICAL); mainPanel->GetSizer()->Add(dialogVBox, 1, wxEXPAND | wxALL, 12); _selector = new ShaderSelector(mainPanel, this, getPrefixList(), true); // true >> render a light texture // Pack in the ShaderSelector and buttons panel dialogVBox->Add(_selector, 1, wxEXPAND); createButtons(mainPanel, dialogVBox); // Set the default size of the window FitToScreen(0.6f, 0.6f); }
ParticlesChooser::ParticlesChooser() : DialogBase(_("Choose particles")), _particlesList(new wxutil::TreeModel(COLUMNS(), true)), _selectedParticle(""), _preview(new wxutil::ParticlePreview(this)) { // Connect the finish callback to load the treestore Connect(wxutil::EV_TREEMODEL_POPULATION_FINISHED, TreeModelPopulationFinishedHandler(ParticlesChooser::onTreeStorePopulationFinished), NULL, this); SetSizer(new wxBoxSizer(wxVERTICAL)); wxBoxSizer* hbox = new wxBoxSizer(wxHORIZONTAL); hbox->Add(createTreeView(this), 1, wxEXPAND); hbox->Add(_preview->getWidget(), 0, wxEXPAND | wxLEFT, 6); GetSizer()->Add(hbox, 1, wxEXPAND | wxALL, 12); GetSizer()->Add(CreateStdDialogButtonSizer(wxOK | wxCANCEL), 0, wxALIGN_RIGHT | wxBOTTOM | wxLEFT | wxRIGHT, 12); FitToScreen(0.5f, 0.6f); }
QvisWindowBase::QvisWindowBase(const QString &captionString, Qt::WindowFlags f) : QMainWindow(parentOfEveryWindow, #if defined(Q_WS_WIN) || defined(Q_WS_MACX) || defined(Q_OS_WIN) || defined(Q_OS_MAC) Qt::Window | f) { // Make each window the child of the first window that is created // when we run on the Windows platform. This prevents the sub-windows // from showing up in the taskbar. if(parentOfEveryWindow == 0) parentOfEveryWindow = this; #else f) { #endif if(!captionString.isEmpty()) setWindowTitle(captionString); else setWindowTitle("VisIt"); saveWindowDefaults = false; } // **************************************************************************** // Method: QvisWindowBase::~QvisWindowBase // // Purpose: // Destructor for the QvisWindowBase class. // // Programmer: Brad Whitlock // Creation: Wed Aug 30 18:15:17 PST 2000 // // Modifications: // // **************************************************************************** QvisWindowBase::~QvisWindowBase() { // nothing here. } // **************************************************************************** // Method: QvisWindowBase::showMinimized // // Purpose: // Is the window is visible, this method minimizes the window. // // Programmer: Brad Whitlock // Creation: Thu Apr 19 10:36:40 PDT 2001 // // Modifications: // // **************************************************************************** void QvisWindowBase::showMinimized() { if(isVisible()) QMainWindow::showMinimized(); } // **************************************************************************** // Method: QvisWindowBase::showNormal // // Purpose: // If the window is minimized, this method shows it normal (de-iconifies it) // // Programmer: Brad Whitlock // Creation: Thu Apr 19 10:37:14 PDT 2001 // // Modifications: // // **************************************************************************** void QvisWindowBase::showNormal() { if(isMinimized()) QMainWindow::showNormal(); } // **************************************************************************** // Method: QvisWindowBase::CreateNode // // Purpose: // Adds the window's geometry and visibility status to the DataNode // tree that will be saved to the VisIt config file. // // Arguments: // parentNode : The parent node under which we'll add a node for // this window. // // Programmer: Brad Whitlock // Creation: Tue Oct 3 15:30:23 PST 2000 // // Modifications: // Brad Whitlock, Fri Jun 6 10:29:33 PDT 2008 // Qt 4. // // **************************************************************************** void QvisWindowBase::CreateNode(DataNode *parentNode) { if(saveWindowDefaults) { DataNode *node = new DataNode(windowTitle().toStdString()); parentNode->AddNode(node); // Add generic window attributes node->AddNode(new DataNode("x", x())); node->AddNode(new DataNode("y", y())); node->AddNode(new DataNode("width", width())); node->AddNode(new DataNode("height", height())); node->AddNode(new DataNode("visible", isVisible())); } } // **************************************************************************** // Method: QvisWindowBase::SetFromNode // // Purpose: // Sets the window's geometry information from the DataNode. // // Arguments: // parentNode : This a pointer to the "GUI" node. // borders : An array of 4 ints containing the sizes of the window // decorations. // // Programmer: Brad Whitlock // Creation: Tue Oct 3 15:41:34 PST 2000 // // Modifications: // Brad Whitlock, Wed Sep 10 09:19:32 PDT 2003 // Added a method to make sure that the window fits on the screen. // // Hank Childs, Mon Nov 14 16:25:27 PST 2005 // Don't allow windows to come up off the screen. // // Brad Whitlock, Wed Nov 22 09:56:26 PDT 2006 // Added code to override the window location if an anchor has been provided. // // Brad Whitlock, Fri Jun 6 10:29:41 PDT 2008 // Qt 4. // // **************************************************************************** void QvisWindowBase::SetFromNode(DataNode *parentNode, const int *borders) { DataNode *winNode = parentNode->GetNode(windowTitle().toStdString()); if(winNode == 0) return; // Indicate that the window should be saved. saveWindowDefaults = true; DataNode *node; bool xy_set = false, wh_set = false; int x = 0, y = 0; int w = width(); int h = height(); // See if any attributes are set. if((node = winNode->GetNode("x")) != 0) { int x_pos = node->AsInt(); if (x_pos < 0) x_pos = 0; x = x_pos + borders[2]; xy_set = true; } if((node = winNode->GetNode("y")) != 0) { int y_pos = node->AsInt(); if (y_pos < 0) y_pos = 0; y = y_pos + borders[0]; xy_set = true; } if((node = winNode->GetNode("width")) != 0) { w = node->AsInt(); wh_set = true; } if((node = winNode->GetNode("height")) != 0) { h = node->AsInt(); wh_set = true; } // Possibly override the window anchor location. xy_set |= GetWindowAnchorLocation(x, y); // Make sure that the window will fit on the screen. FitToScreen(x, y, w, h); // Set the window geometry. if(wh_set && xy_set) setGeometry(x, y, w, h); else if(xy_set) move(x, y); else if(wh_set) resize(w, h); // If the window is visible, show it. if((node = winNode->GetNode("visible")) != 0) { if(node->AsBool()) show(); } }
PrefabSelector::PrefabSelector() : DialogBase(_(PREFABSELECTOR_TITLE)), _treeStore(new wxutil::TreeModel(_columns)), _treeView(NULL), _lastPrefab(""), _populated(false), _description(NULL), _customPath(NULL) { SetSizer(new wxBoxSizer(wxVERTICAL)); wxBoxSizer* vbox = new wxBoxSizer(wxVERTICAL); GetSizer()->Add(vbox, 1, wxEXPAND | wxALL, 12); setupPathSelector(vbox); wxSplitterWindow* splitter = new wxSplitterWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_3D | wxSP_LIVE_UPDATE); splitter->SetMinimumPaneSize(10); // disallow unsplitting setupTreeView(splitter); wxPanel* previewPanel = new wxPanel(splitter, wxID_ANY); previewPanel->SetSizer(new wxBoxSizer(wxVERTICAL)); _preview.reset(new ui::MapPreview(previewPanel)); _description = new wxTextCtrl(previewPanel, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxTE_LEFT | wxTE_MULTILINE | wxTE_READONLY | wxTE_WORDWRAP); _description->SetMinClientSize(wxSize(-1, 60)); previewPanel->GetSizer()->Add(_description, 0, wxEXPAND | wxBOTTOM, 6); previewPanel->GetSizer()->Add(_preview->getWidget(), 1, wxEXPAND); splitter->SplitVertically(_treeView, previewPanel); vbox->Add(splitter, 1, wxEXPAND); wxStdDialogButtonSizer* buttonSizer = CreateStdDialogButtonSizer(wxOK | wxCANCEL); wxButton* reloadButton = new wxButton(this, wxID_ANY, _("Rescan Prefab Folders")); reloadButton->Connect(wxEVT_BUTTON, wxCommandEventHandler(PrefabSelector::onRescanPrefabs), NULL, this); buttonSizer->Prepend(reloadButton, 0, wxRIGHT, 32); vbox->Add(buttonSizer, 0, wxALIGN_RIGHT | wxTOP, 12); // Set the default size of the window _position.connect(this); _position.readPosition(); // The model preview is half the width and 20% of the parent's height (to // allow vertical shrinking) _preview->setSize(static_cast<int>(_position.getSize()[0] * 0.4f), static_cast<int>(_position.getSize()[1] * 0.2f)); FitToScreen(0.8f, 0.8f); splitter->SetSashPosition(static_cast<int>(GetSize().GetWidth() * 0.2f)); _panedPosition.connect(splitter); _panedPosition.loadFromPath(RKEY_SPLIT_POS); Connect(wxutil::EV_TREEMODEL_POPULATION_FINISHED, TreeModelPopulationFinishedHandler(PrefabSelector::onTreeStorePopulationFinished), NULL, this); }