1 // Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // VISU VISUGUI : GUI of VISU component
24 // File : VisuGUI_CursorDlg.cxx
25 // Author : Laurent CORNABE & Hubert ROLLAND
33 #include "VisuGUI_CursorDlg.h"
35 #include "SUIT_Session.h"
36 #include "SUIT_MessageBox.h"
37 #include "SUIT_ResourceMgr.h"
39 #include "LightApp_Application.h"
41 #include <SalomeApp_IntSpinBox.h>
45 #include <QPushButton>
52 VisuGUI_CursorDlg::VisuGUI_CursorDlg( QWidget* parent, const char* name, bool modal )
53 : QDialog( parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint )//WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
55 setWindowTitle( name );
57 setSizeGripEnabled( TRUE );
59 QGridLayout* TopLayout = new QGridLayout( this );
60 TopLayout->setSpacing( 6 );
61 TopLayout->setMargin( 11 );
63 TopGroupBox = new QGroupBox( this );
64 //TopGroupBox->setColumnLayout(0, Qt::Vertical );
65 //TopGroupBox->layout()->setSpacing( 0 );
66 //TopGroupBox->layout()->setMargin( 0 );
67 QGridLayout* TopGroupBoxLayout = new QGridLayout( TopGroupBox );
68 TopGroupBoxLayout->setAlignment( Qt::AlignTop );
69 TopGroupBoxLayout->setSpacing( 6 );
70 TopGroupBoxLayout->setMargin( 11 );
72 Comment1 = new QLabel( tr( "TextLabel1" ), TopGroupBox );
73 Comment1->setAlignment( Qt::AlignCenter );
74 TopGroupBoxLayout->addWidget( Comment1, 0, 0 );
76 Comment2 = new QLabel( tr( "TextLabel2" ), TopGroupBox );
77 Comment2->setAlignment( Qt::AlignCenter );
78 TopGroupBoxLayout->addWidget( Comment2, 1, 0 );
80 SpinBox1 = new SalomeApp_IntSpinBox( TopGroupBox );
81 SpinBox1->setAcceptNames( false );
82 SpinBox1->setMinimum( 0 );
83 SpinBox1->setMaximum(100 );
84 SpinBox1->setSingleStep( 1 );
85 SpinBox1->setValue( 100 );
86 SpinBox1->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
87 SpinBox1->setMinimumSize( 70, 0 );
88 QHBoxLayout* SLayout = new QHBoxLayout;
89 SLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ) );
90 SLayout->addWidget( SpinBox1 );
91 SLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ) );
92 TopGroupBoxLayout->addLayout( SLayout, 2, 0 );
94 GroupButtons = new QGroupBox (this);
95 GroupButtons->setGeometry(QRect(10, 10, 281, 48));
96 //GroupButtons->setColumnLayout(0, Qt::Vertical);
97 //GroupButtons->layout()->setSpacing(0);
98 //GroupButtons->layout()->setMargin(0);
99 QGridLayout* GroupButtonsLayout = new QGridLayout (GroupButtons);
100 GroupButtonsLayout->setAlignment(Qt::AlignTop);
101 GroupButtonsLayout->setSpacing(6);
102 GroupButtonsLayout->setMargin(11);
104 buttonOk = new QPushButton (tr("&OK"), GroupButtons);
105 buttonOk->setAutoDefault(TRUE);
106 buttonOk->setDefault(TRUE);
107 GroupButtonsLayout->addWidget(buttonOk, 0, 0);
109 GroupButtonsLayout->addItem(new QSpacerItem (5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 1);
111 buttonCancel = new QPushButton(tr("&Cancel") , GroupButtons);
112 buttonCancel->setAutoDefault(TRUE);
113 GroupButtonsLayout->addWidget(buttonCancel, 0, 2);
115 buttonHelp = new QPushButton(tr("&Help") , GroupButtons);
116 buttonHelp->setAutoDefault(TRUE);
117 GroupButtonsLayout->addWidget(buttonHelp, 0, 3);
119 TopLayout->addWidget(TopGroupBox, 0, 0);
120 TopLayout->addWidget(GroupButtons, 1, 0);
122 // signals and slots connections
123 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
124 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
125 connect( buttonHelp, SIGNAL( clicked() ), this, SLOT( onHelp() ) );
131 VisuGUI_CursorDlg::~VisuGUI_CursorDlg()
139 void VisuGUI_CursorDlg::onHelp()
141 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
143 VisuGUI* aVisuGUI = dynamic_cast<VisuGUI*>( app->activeModule() );
144 app->onHelpContextModule(aVisuGUI ? app->moduleName(aVisuGUI->moduleName()) : QString(""), helpFileName);
149 platform = "winapplication";
151 platform = "application";
153 SUIT_MessageBox::warning(0, QObject::tr("WRN_WARNING"),
154 QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
155 arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).
161 function : keyPressEvent()
164 void VisuGUI_CursorDlg::keyPressEvent( QKeyEvent* e )
166 QDialog::keyPressEvent( e );
167 if ( e->isAccepted() )
170 if ( e->key() == Qt::Key_F1 )