1 // VISU VISUGUI : GUI of VISU component
3 // Copyright (C) 2003 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
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"
46 VisuGUI_CursorDlg::VisuGUI_CursorDlg( QWidget* parent, const char* name, bool modal, WFlags fl )
47 : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
50 setName( "VisuGUI_CursorDlg" );
52 setSizeGripEnabled( TRUE );
54 QGridLayout* TopLayout = new QGridLayout( this );
55 TopLayout->setSpacing( 6 );
56 TopLayout->setMargin( 11 );
58 TopGroupBox = new QGroupBox( this, "TopGroupBox" );
59 TopGroupBox->setColumnLayout(0, Qt::Vertical );
60 TopGroupBox->layout()->setSpacing( 0 );
61 TopGroupBox->layout()->setMargin( 0 );
62 QGridLayout* TopGroupBoxLayout = new QGridLayout( TopGroupBox->layout() );
63 TopGroupBoxLayout->setAlignment( Qt::AlignTop );
64 TopGroupBoxLayout->setSpacing( 6 );
65 TopGroupBoxLayout->setMargin( 11 );
67 Comment1 = new QLabel( tr( "TextLabel1" ), TopGroupBox, "Comment1" );
68 Comment1->setAlignment( QLabel::AlignCenter );
69 TopGroupBoxLayout->addWidget( Comment1, 0, 0 );
71 Comment2 = new QLabel( tr( "TextLabel2" ), TopGroupBox, "Comment2" );
72 Comment2->setAlignment( QLabel::AlignCenter );
73 TopGroupBoxLayout->addWidget( Comment2, 1, 0 );
75 SpinBox1 = new QSpinBox( 1, 100, 1, TopGroupBox, "SpinBox1" );
76 SpinBox1->setValue( 100 );
77 SpinBox1->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
78 SpinBox1->setMinimumSize( 70, 0 );
79 QHBoxLayout* SLayout = new QHBoxLayout;
80 SLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ) );
81 SLayout->addWidget( SpinBox1 );
82 SLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ) );
83 TopGroupBoxLayout->addLayout( SLayout, 2, 0 );
85 GroupButtons = new QGroupBox (this, "GroupButtons");
86 GroupButtons->setGeometry(QRect(10, 10, 281, 48));
87 GroupButtons->setColumnLayout(0, Qt::Vertical);
88 GroupButtons->layout()->setSpacing(0);
89 GroupButtons->layout()->setMargin(0);
90 QGridLayout* GroupButtonsLayout = new QGridLayout (GroupButtons->layout());
91 GroupButtonsLayout->setAlignment(Qt::AlignTop);
92 GroupButtonsLayout->setSpacing(6);
93 GroupButtonsLayout->setMargin(11);
95 buttonOk = new QPushButton (tr("&OK"), GroupButtons, "buttonOk");
96 buttonOk->setAutoDefault(TRUE);
97 buttonOk->setDefault(TRUE);
98 GroupButtonsLayout->addWidget(buttonOk, 0, 0);
100 GroupButtonsLayout->addItem(new QSpacerItem (5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 1);
102 buttonCancel = new QPushButton(tr("&Cancel") , GroupButtons, "buttonCancel");
103 buttonCancel->setAutoDefault(TRUE);
104 GroupButtonsLayout->addWidget(buttonCancel, 0, 2);
106 buttonHelp = new QPushButton(tr("&Help") , GroupButtons, "buttonHelp");
107 buttonHelp->setAutoDefault(TRUE);
108 GroupButtonsLayout->addWidget(buttonHelp, 0, 3);
110 TopLayout->addWidget(TopGroupBox, 0, 0);
111 TopLayout->addWidget(GroupButtons, 1, 0);
113 // signals and slots connections
114 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
115 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
116 connect( buttonHelp, SIGNAL( clicked() ), this, SLOT( onHelp() ) );
122 VisuGUI_CursorDlg::~VisuGUI_CursorDlg()
130 void VisuGUI_CursorDlg::onHelp()
132 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
134 VisuGUI* aVisuGUI = dynamic_cast<VisuGUI*>( app->activeModule() );
135 app->onHelpContextModule(aVisuGUI ? app->moduleName(aVisuGUI->moduleName()) : QString(""), helpFileName);
140 platform = "winapplication";
142 platform = "application";
144 SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
145 QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
146 arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(helpFileName),
147 QObject::tr("BUT_OK"));
152 function : keyPressEvent()
155 void VisuGUI_CursorDlg::keyPressEvent( QKeyEvent* e )
157 QDialog::keyPressEvent( e );
158 if ( e->isAccepted() )
161 if ( e->key() == Key_F1 )