//----------------------------------------------------------------------------// void GroupBox::removeChild_impl(Element* element) { Window* wnd = static_cast<Window*>(element); if (wnd->isAutoWindow()) Window::removeChild_impl(wnd); else if (Window * pane = getContentPane()) pane->removeChild(wnd); }
/*public*/ RouteCopyFrame::RouteCopyFrame(QWidget* parent) : OperationsFrame(tr("Copy Route"),parent) { //super(tr("TitleRouteCopy")); log = new Logger("RouteCopyFrame"); routeManager = RouteManager::instance(); // labels textCopyRoute = new QLabel(tr("Copy Route")); textRouteName = new QLabel(tr("Route Name")); // text field routeNameTextField = new JTextField(Control::max_len_string_route_name); // check boxes invertCheckBox = new QCheckBox(tr("Invert")); // major buttons copyButton = new QPushButton(tr("Copy")); // combo boxes routeBox = RouteManager::instance()->getComboBox(); // general GUI config //getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS)); QVBoxLayout* thisLayout = new QVBoxLayout(getContentPane()); // Set up the panels QWidget* p1 = new QWidget(); p1->setLayout(new GridBagLayout()); // Layout the panel by rows // row 1 textRouteName addItem(p1, textRouteName, 0, 1); addItemWidth(p1, routeNameTextField, 3, 1, 1); // row 2 addItem(p1, textCopyRoute, 0, 2); addItemWidth(p1, routeBox, 3, 1, 2); // row 4 addItem(p1, invertCheckBox, 0, 4); addItem(p1, copyButton, 1, 4); thisLayout->addWidget(p1); // add help menu to window addHelpMenu("package.jmri.jmrit.operations.Operations_CopyRoute", true); // NOI18N initMinimumSize(QSize(Control::panelWidth600, Control::panelHeight200)); // setup buttons addButtonAction(copyButton); }
//----------------------------------------------------------------------------// void GroupBox::addChild_impl(Element* element) { Window* wnd = dynamic_cast<Window*>(element); if (!wnd) throw InvalidRequestException( "GroupBox can only have Elements of type Window added as children " "(Window path: " + getNamePath() + ")."); if (wnd->isAutoWindow()) Window::addChild_impl(wnd); else if (Window * pane = getContentPane()) pane->addChild(wnd); }
void GroupBox::addChild_impl(Window* wnd) { // Only add it when it's not the __auto_contentpane__ (auto-child) itself if (wnd && wnd->getName().find(ContentPaneNameSuffix) == String::npos) { Window * pane = getContentPane(); if (pane) { pane->addChildWindow(wnd); } else { Window::addChild_impl(wnd); } } }
void GroupBox::removeChild_impl(Window* wnd) { if (wnd) { // Auto pane itself? if (wnd->getName().find(ContentPaneNameSuffix) != String::npos) { // Yes Window::removeChild_impl(wnd); WindowManager::getSingleton().destroyWindow(wnd); } else { // Remove child from out auto pane Window* wndPane = getContentPane(); if (wndPane) { wndPane->removeChildWindow(wnd); if (wnd->isDestroyedByParent()) { WindowManager::getSingleton().destroyWindow(wnd); } } } } }
/*public*/ SetTrainIconRouteFrame::SetTrainIconRouteFrame(QString routeName, QWidget* parent) : OperationsFrame(tr("Train Icon"),parent) { //super(tr("MenuSetTrainIcon")); log = new Logger("SetTrainIconRouteFrame"); value = QMessageBox::No; //JOptionPane.NO_OPTION; FORWARD = 1; BACK = -1; NONE = 0; routeManager = RouteManager::instance(); // labels textX = new JLabel(" X "); textY = new JLabel(" Y "); routeLocationName = new JLabel(); // text field // check boxes // major buttons previousButton = new QPushButton(tr("Previous")); nextButton = new QPushButton(tr("Next")); placeButton = new QPushButton(tr("Place Test Icon")); applyButton = new QPushButton(tr("Apply")); saveButton = new QPushButton(tr("Save")); // combo boxes // Spinners spinTrainIconX = new QSpinBox(); //(new SpinnerNumberModel(0, 0, 10000, 1)); spinTrainIconX->setMinimum(0); spinTrainIconX->setMaximum(10000); spinTrainIconX->setValue(0); spinTrainIconX->setSingleStep(1); spinTrainIconY = new QSpinBox(); //(new SpinnerNumberModel(0, 0, 10000, 1)); spinTrainIconY->setMinimum(0); spinTrainIconY->setMaximum(10000); spinTrainIconY->setValue(0); spinTrainIconY->setSingleStep(1); _routeIndex = 0; _tIon = NULL; // create route if (routeName == NULL) { return; } _route = RouteManager::instance()->getRouteByName(routeName); //_route.addPropertyChangeListener(this); connect(_route->pcs, SIGNAL(propertyChange(PropertyChangeEvent*)), this, SLOT(propertyChange(PropertyChangeEvent*))); // general GUI config //getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS)); getContentPane()->setLayout(new QVBoxLayout); // set tool tips placeButton->setToolTip(tr("Places a set of train icons on panel") + " " + Setup::getPanelName()); applyButton->setToolTip(tr("Update route with the new coordinates")); saveButton->setToolTip(tr("Saves the train icon coordinates for the selected location")); // Set up the panels QGroupBox* pRoute = new QGroupBox(); // pRoute.setBorder(BorderFactory // .createTitledBorder(tr("Route") + " " + _route.getName())); pRoute->setStyleSheet(gbStyleSheet); pRoute->setTitle(tr("Route")); pRoute->setLayout(new GridBagLayout()); addItem(pRoute, previousButton, 0, 0); addItem(pRoute, routeLocationName, 1, 0); addItem(pRoute, nextButton, 2, 0); QGroupBox* pSpin = new QGroupBox(); pSpin->setLayout(new GridBagLayout()); //pSpin.setBorder(BorderFactory.createTitledBorder(tr("TrainIcon"))); pSpin->setStyleSheet(gbStyleSheet); pSpin->setTitle(tr("Train Icon")); addItem(pSpin, textX, 0, 0); addItem(pSpin, spinTrainIconX, 1, 0); addItem(pSpin, textY, 2, 0); addItem(pSpin, spinTrainIconY, 3, 0); QGroupBox* pControl = new QGroupBox(); pControl->setLayout(new GridBagLayout()); //pControl.setBorder(BorderFactory.createTitledBorder("")); pControl->setStyleSheet(gbStyleSheet); pControl->setTitle(tr("Route")); addItem(pControl, placeButton, 0, 0); addItem(pControl, applyButton, 1, 0); addItem(pControl, saveButton, 2, 0); getContentPane()->layout()->addWidget(pRoute); getContentPane()->layout()->addWidget(pSpin); getContentPane()->layout()->addWidget(pControl); // add help menu to window addHelpMenu("package.jmri.jmrit.operations.Operations_SetTrainIconCoordinates", true); // NOI18N // setup buttons addButtonAction(previousButton); addButtonAction(nextButton); addButtonAction(placeButton); addButtonAction(applyButton); addButtonAction(saveButton); // start off with save button disabled saveButton->setEnabled(false); updateRoute(); // setup spinners addSpinnerChangeListerner(spinTrainIconX); addSpinnerChangeListerner(spinTrainIconY); initMinimumSize(QSize(Control::panelWidth400, Control::panelHeight400)); }
// major buttons // javax.swing.JButton addButton = new javax.swing.JButton(); /*public*/ SchedulesTableFrame::SchedulesTableFrame(QWidget* parent) : OperationsFrame(tr("Schedules"), parent) { //super(tr("TitleSchedulesTable")); log = new Logger("SchedulesTableFrame"); schedulesModel = new SchedulesTableModel(); schedulesTable = new JTable(schedulesModel); schedulesTable->setObjectName("SchedulesTable"); //JScrollPane schedulesPane; // labels textSort = new QLabel(); textSep = new QLabel(); // radio buttons sortByName = new QRadioButton(tr("Name")); sortById = new QRadioButton(tr("Id")); // general GUI config //getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS)); QVBoxLayout* thisLayout = new QVBoxLayout(getContentPane()); // Set up the jtable in a Scroll Pane.. // schedulesPane = new JScrollPane(schedulesTable); // schedulesPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); // schedulesPane // .setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); schedulesModel->initTable(this, schedulesTable); thisLayout->addWidget(/*schedulesPane*/schedulesTable); // Set up the control panel QWidget* controlPanel = new QWidget(); controlPanel->setLayout(new FlowLayout()); textSort->setText(tr("SortBy")); controlPanel->layout()->addWidget(textSort); controlPanel->layout()->addWidget(sortByName); sortByName->setChecked(true); controlPanel->layout()->addWidget(sortById); textSep->setText(" "); controlPanel->layout()->addWidget(textSep); // TODO allow user to add schedule to a spur // addButton.setText(tr("Add")); // addButton.setVisible(true); // controlPanel.add (addButton); controlPanel->setMaximumSize(QSize(Control::panelWidth1025, 50)); thisLayout->addWidget(controlPanel); // setup buttons // addButtonAction(addButton); addRadioButtonAction(sortByName); addRadioButtonAction(sortById); // build menu QMenuBar* menuBar = new QMenuBar(); QMenu* toolMenu = new QMenu("Tools"); toolMenu->addAction(new ScheduleCopyAction(this)); toolMenu->addAction(new SchedulesByLoadAction(tr("Show Schedules By Load"),this)); toolMenu->addAction(new SchedulesResetHitsAction(tr("Reset Hit Counts"),this)); toolMenu->addAction(new PrintLocationsAction(tr("Print"), false,this)); toolMenu->addAction(new PrintLocationsAction(tr("Preview"), true,this)); menuBar->addMenu(toolMenu); setMenuBar(menuBar); addHelpMenu("package.jmri.jmrit.operations.Operations_LocationSchedules", true); // NOI18N initMinimumSize(); // make panel a bit wider than minimum if the very first time opened if (width() == Control::panelWidth500) { resize(Control::panelWidth1025, height()); } setLocation(10,20); }
/*public*/ EnginesTableFrame::EnginesTableFrame(QWidget* parent) : OperationsFrame(tr("Engines Table"), parent) { //super(tr("Engines Table")); // general GUI config setObjectName("EnginesTableFrame"); log = new Logger("EnginesTableFrame"); engineManager = EngineManager::instance(); // labels numEngines = new QLabel(); textEngines = new QLabel(); textSep1 = new QLabel(" "); f = NULL; setStatusBar(new QStatusBar()); statusBar()->setSizeGripEnabled(true); // radio buttons sortByNumber = new QRadioButton(tr("Number")); sortByRoad = new QRadioButton(tr("Road")); sortByModel = new QRadioButton(tr("Model")); sortByConsist = new QRadioButton(tr("Consist")); sortByLocation = new QRadioButton(tr("Location")); sortByDestination = new QRadioButton(tr("Destination")); sortByTrain = new QRadioButton(tr("Train")); sortByMoves = new QRadioButton(tr("Moves")); sortByBuilt = new QRadioButton(tr("Built")); sortByOwner = new QRadioButton(tr("Owner")); sortByValue = new QRadioButton(Setup::getValueLabel()); sortByRfid = new QRadioButton(Setup::getRfidLabel()); sortByLast = new QRadioButton(tr("Last")); QButtonGroup* group = new QButtonGroup(); // major buttons addButton = new QPushButton(tr("Add")); findButton = new QPushButton(tr("Find")); saveButton = new QPushButton(tr("Save")); findEngineTextBox = new JTextField(6); QVBoxLayout* thisLayout; log->debug(tr("getContentPane returned %1").arg(getContentPane()->objectName())); getContentPane()->setLayout(thisLayout = new QVBoxLayout); //(getContentPane(), BoxLayout.Y_AXIS)); // Set up the jtable in a Scroll Pane.. enginesModel = new EnginesTableModel(); //sorter = new TableSorter(enginesModel); sorter = new QSortFilterProxyModel(); sorter->setSourceModel(enginesModel); enginesTable = new JTable(sorter); //sorter.setTableHeader(enginesTable.getTableHeader()); // enginesPane = new JScrollPane(enginesTable); // enginesPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); enginesModel->initTable(enginesTable, this); // load the number of engines and listen for changes numEngines->setText(QString::number(engineManager->getNumEntries())); //engineManager.addPropertyChangeListener(this); connect(engineManager->pcs, SIGNAL(propertyChange(PropertyChangeEvent*)), this, SLOT(propertyChange(PropertyChangeEvent*))); textEngines->setText(tr("engines")); // Set up the control panel // row 1 QGroupBox* cp1 = new QGroupBox(); //cp1.setBorder(BorderFactory.createTitledBorder(tr("SortBy"))); QString gbStyleSheet = "QGroupBox { border: 2px solid gray; border-radius: 3px;} QGroupBox::title { /*background-color: transparent;*/ subcontrol-position: top left; /* position at the top left*/ padding:0 0px;} "; cp1->setStyleSheet(gbStyleSheet); FlowLayout * cp1Layout = new FlowLayout(cp1); cp1->setTitle(tr("Sort By")); cp1Layout->addWidget(sortByNumber); cp1Layout->addWidget(sortByRoad); cp1Layout->addWidget(sortByModel); cp1Layout->addWidget(sortByConsist); cp1Layout->addWidget(sortByLocation); cp1Layout->addWidget(sortByDestination); cp1Layout->addWidget(sortByTrain); QFrame* movep = new QFrame(); //movep.setBorder(BorderFactory.createTitledBorder("")); FlowLayout * movepLayout = new FlowLayout(movep); movepLayout->addWidget(sortByMoves); movepLayout->addWidget(sortByBuilt); movepLayout->addWidget(sortByOwner); if (Setup::isValueEnabled()) { movepLayout->addWidget(sortByValue); } if (Setup::isRfidEnabled()) { movepLayout->addWidget(sortByRfid); } movepLayout->addWidget(sortByLast); cp1Layout->addWidget(movep); // row 2 QWidget* cp2 = new QWidget(); //cp2.setLayout(new BoxLayout(cp2, BoxLayout.X_AXIS)); QHBoxLayout* cp2Layout = new QHBoxLayout(cp2); QFrame* cp2Add = new QFrame(); //cp2Add.setBorder(BorderFactory.createTitledBorder("")); cp2Add->setFrameShape(QFrame::StyledPanel); cp2Add->setFrameShadow(QFrame::Raised); QHBoxLayout* cp2AddLayout = new QHBoxLayout(cp2Add); cp2AddLayout->addWidget(numEngines); cp2AddLayout->addWidget(textEngines); cp2AddLayout->addWidget(textSep1); cp2AddLayout->addWidget(addButton); cp2Layout->addWidget(cp2Add); QGroupBox* cp2Find = new QGroupBox(); //cp2Find.setBorder(BorderFactory.createTitledBorder("")); cp2Find->setStyleSheet(gbStyleSheet); cp2Find->setTitle(""); FlowLayout* cp2FindLayout = new FlowLayout(cp2Find); findButton->setToolTip(tr("Find locomotive by road number. Asterisk \"*\" = wild card.")); findEngineTextBox->setToolTip(tr("Find locomotive by road number. Asterisk \"*\" = wild card.")); cp2FindLayout->addWidget(findButton); cp2FindLayout->addWidget(findEngineTextBox); cp2Layout->addWidget(cp2Find); QWidget* cp2Save = new QWidget(); //cp2Save.setBorder(BorderFactory.createTitledBorder("")); FlowLayout* cp2SaveLayout = new FlowLayout(cp2Save); cp2SaveLayout->addWidget(saveButton); cp2Layout->addWidget(cp2Save); // place controls in scroll pane QWidget* controlPanel = new QWidget(); //controlPanel.setLayout(new BoxLayout(controlPanel, BoxLayout.Y_AXIS)); QVBoxLayout* controlPanelLayout = new QVBoxLayout(controlPanel); controlPanelLayout->addWidget(cp1); controlPanelLayout->addWidget(cp2); // some tool tips sortByLast->setToolTip(tr("Last Moved")); QScrollArea* controlPane = new QScrollArea(); controlPane->setWidget(controlPanel); controlPane->setWidgetResizable(true); thisLayout->addWidget(/*enginesPane*/enginesTable); thisLayout->addWidget(controlPane); // setup buttons addButtonAction(addButton); addButtonAction(findButton); addButtonAction(saveButton); sortByNumber->setChecked(true); addRadioButtonAction(sortByNumber); addRadioButtonAction(sortByRoad); addRadioButtonAction(sortByModel); addRadioButtonAction(sortByConsist); addRadioButtonAction(sortByLocation); addRadioButtonAction(sortByDestination); addRadioButtonAction(sortByTrain); addRadioButtonAction(sortByMoves); addRadioButtonAction(sortByBuilt); addRadioButtonAction(sortByOwner); addRadioButtonAction(sortByValue); addRadioButtonAction(sortByRfid); addRadioButtonAction(sortByLast); group->addButton(sortByNumber); group->addButton(sortByRoad); group->addButton(sortByModel); group->addButton(sortByConsist); group->addButton(sortByLocation); group->addButton(sortByDestination); group->addButton(sortByTrain); group->addButton(sortByMoves); group->addButton(sortByBuilt); group->addButton(sortByOwner); group->addButton(sortByValue); group->addButton(sortByRfid); group->addButton(sortByLast); // build menu QMenuBar* menuBar = new QMenuBar(); QMenu* toolMenu = new QMenu(tr("Tools")); toolMenu->addMenu(new EngineRosterMenu(tr("Engine Roster"), EngineRosterMenu::MAINMENU, this)); // toolMenu.add(new NceConsistEngineAction(tr("MenuItemNceSync"), this)); menuBar->addMenu(toolMenu); menuBar->addMenu(new OperationsMenu()); setMenuBar(menuBar); addHelpMenu("package.jmri.jmrit.operations.Operations_Locomotives", true); // NOI18N initMinimumSize(); //addHorizontalScrollBarKludgeFix(controlPane, controlPanel); // create ShutDownTasks createShutDownTask(); }
void GroupBox::initialiseComponents() { // Add the auto-child which got defined in the looknfeel Window::addChild_impl(getContentPane()); Window::initialiseComponents(); }