1 // Copyright (C) 2007-2008 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
22 // VISU VISUGUI : GUI of VISU component
23 // File : VisuGUI_CursorDlg.cxx
24 // Author : Laurent CORNABE & Hubert ROLLAND
32 #include "VisuGUI_CursorDlg.h"
34 #include "SUIT_Session.h"
35 #include "SUIT_MessageBox.h"
36 #include "SUIT_ResourceMgr.h"
38 #include "LightApp_Application.h"
42 #include <QPushButton>
50 VisuGUI_CursorDlg::VisuGUI_CursorDlg( QWidget* parent, const char* name, bool modal )
51 : QDialog( parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint )//WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
53 setWindowTitle( name );
55 setSizeGripEnabled( TRUE );
57 QGridLayout* TopLayout = new QGridLayout( this );
58 TopLayout->setSpacing( 6 );
59 TopLayout->setMargin( 11 );
61 TopGroupBox = new QGroupBox( this );
62 //TopGroupBox->setColumnLayout(0, Qt::Vertical );
63 //TopGroupBox->layout()->setSpacing( 0 );
64 //TopGroupBox->layout()->setMargin( 0 );
65 QGridLayout* TopGroupBoxLayout = new QGridLayout( TopGroupBox );
66 TopGroupBoxLayout->setAlignment( Qt::AlignTop );
67 TopGroupBoxLayout->setSpacing( 6 );
68 TopGroupBoxLayout->setMargin( 11 );
70 Comment1 = new QLabel( tr( "TextLabel1" ), TopGroupBox );
71 Comment1->setAlignment( Qt::AlignCenter );
72 TopGroupBoxLayout->addWidget( Comment1, 0, 0 );
74 Comment2 = new QLabel( tr( "TextLabel2" ), TopGroupBox );
75 Comment2->setAlignment( Qt::AlignCenter );
76 TopGroupBoxLayout->addWidget( Comment2, 1, 0 );
78 SpinBox1 = new QSpinBox( TopGroupBox );
79 SpinBox1->setMinimum( 0 );
80 SpinBox1->setMaximum(100 );
81 SpinBox1->setSingleStep( 1 );
82 SpinBox1->setValue( 100 );
83 SpinBox1->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
84 SpinBox1->setMinimumSize( 70, 0 );
85 QHBoxLayout* SLayout = new QHBoxLayout;
86 SLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ) );
87 SLayout->addWidget( SpinBox1 );
88 SLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ) );
89 TopGroupBoxLayout->addLayout( SLayout, 2, 0 );
91 GroupButtons = new QGroupBox (this);
92 GroupButtons->setGeometry(QRect(10, 10, 281, 48));
93 //GroupButtons->setColumnLayout(0, Qt::Vertical);
94 //GroupButtons->layout()->setSpacing(0);
95 //GroupButtons->layout()->setMargin(0);
96 QGridLayout* GroupButtonsLayout = new QGridLayout (GroupButtons);
97 GroupButtonsLayout->setAlignment(Qt::AlignTop);
98 GroupButtonsLayout->setSpacing(6);
99 GroupButtonsLayout->setMargin(11);
101 buttonOk = new QPushButton (tr("&OK"), GroupButtons);
102 buttonOk->setAutoDefault(TRUE);
103 buttonOk->setDefault(TRUE);
104 GroupButtonsLayout->addWidget(buttonOk, 0, 0);
106 GroupButtonsLayout->addItem(new QSpacerItem (5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 1);
108 buttonCancel = new QPushButton(tr("&Cancel") , GroupButtons);
109 buttonCancel->setAutoDefault(TRUE);
110 GroupButtonsLayout->addWidget(buttonCancel, 0, 2);
112 buttonHelp = new QPushButton(tr("&Help") , GroupButtons);
113 buttonHelp->setAutoDefault(TRUE);
114 GroupButtonsLayout->addWidget(buttonHelp, 0, 3);
116 TopLayout->addWidget(TopGroupBox, 0, 0);
117 TopLayout->addWidget(GroupButtons, 1, 0);
119 // signals and slots connections
120 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
121 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
122 connect( buttonHelp, SIGNAL( clicked() ), this, SLOT( onHelp() ) );
128 VisuGUI_CursorDlg::~VisuGUI_CursorDlg()
136 void VisuGUI_CursorDlg::onHelp()
138 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
140 VisuGUI* aVisuGUI = dynamic_cast<VisuGUI*>( app->activeModule() );
141 app->onHelpContextModule(aVisuGUI ? app->moduleName(aVisuGUI->moduleName()) : QString(""), helpFileName);
146 platform = "winapplication";
148 platform = "application";
150 SUIT_MessageBox::warning(0, QObject::tr("WRN_WARNING"),
151 QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
152 arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).
158 function : keyPressEvent()
161 void VisuGUI_CursorDlg::keyPressEvent( QKeyEvent* e )
163 QDialog::keyPressEvent( e );
164 if ( e->isAccepted() )
167 if ( e->key() == Qt::Key_F1 )