]> SALOME platform Git repositories - modules/visu.git/blob - src/VISUGUI/VisuGUI_CursorDlg.cxx
Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/visu.git] / src / VISUGUI / VisuGUI_CursorDlg.cxx
1 //  VISU VISUGUI : GUI of VISU component
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //
23 //
24 //  File   : VisuGUI_CursorDlg.cxx
25 //  Author : Laurent CORNABE & Hubert ROLLAND
26 //  Module : VISU
27 //  $Header$
28
29 #include <string>
30 using namespace std;
31
32 #include "VisuGUI.h"
33 #include "VisuGUI_CursorDlg.h"
34
35 #include "SUIT_Session.h"
36 #include "SUIT_MessageBox.h"
37 #include "SUIT_ResourceMgr.h"
38
39 #include "LightApp_Application.h"
40
41 #include <qlayout.h>
42
43 /*!
44   Constructor
45 */
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 )
48 {
49   if ( !name )
50     setName( "VisuGUI_CursorDlg" );
51   setCaption( name );
52   setSizeGripEnabled( TRUE );
53
54   QGridLayout* TopLayout = new QGridLayout( this );
55   TopLayout->setSpacing( 6 );
56   TopLayout->setMargin( 11 );
57
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 );
66
67   Comment1 = new QLabel( tr( "TextLabel1" ), TopGroupBox, "Comment1" );
68   Comment1->setAlignment( QLabel::AlignCenter );
69   TopGroupBoxLayout->addWidget( Comment1, 0, 0 );
70
71   Comment2 = new QLabel(  tr( "TextLabel2" ), TopGroupBox, "Comment2" );
72   Comment2->setAlignment( QLabel::AlignCenter );
73   TopGroupBoxLayout->addWidget( Comment2, 1, 0 );
74
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 );
84
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);
94
95   buttonOk = new QPushButton (tr("&OK"), GroupButtons, "buttonOk");
96   buttonOk->setAutoDefault(TRUE);
97   buttonOk->setDefault(TRUE);
98   GroupButtonsLayout->addWidget(buttonOk, 0, 0);
99
100   GroupButtonsLayout->addItem(new QSpacerItem (5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 1);
101
102   buttonCancel = new QPushButton(tr("&Cancel") , GroupButtons, "buttonCancel");
103   buttonCancel->setAutoDefault(TRUE);
104   GroupButtonsLayout->addWidget(buttonCancel, 0, 2);
105
106   buttonHelp = new QPushButton(tr("&Help") , GroupButtons, "buttonHelp");
107   buttonHelp->setAutoDefault(TRUE);
108   GroupButtonsLayout->addWidget(buttonHelp, 0, 3);
109
110   TopLayout->addWidget(TopGroupBox,  0, 0);
111   TopLayout->addWidget(GroupButtons, 1, 0);
112
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() ) );
117 }
118
119 /*!
120   Destructor
121 */
122 VisuGUI_CursorDlg::~VisuGUI_CursorDlg()
123 {
124 }
125
126 /*!
127   function : onHelp()
128   purpose  :
129 */
130 void VisuGUI_CursorDlg::onHelp()
131 {
132   LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
133   if (app) {
134     VisuGUI* aVisuGUI = dynamic_cast<VisuGUI*>( app->activeModule() );
135     app->onHelpContextModule(aVisuGUI ? app->moduleName(aVisuGUI->moduleName()) : QString(""), helpFileName);
136   }
137   else {
138     QString platform;
139 #ifdef WIN32
140     platform = "winapplication";
141 #else
142     platform = "application";
143 #endif
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"));
148   }
149 }
150
151 /*!
152   function : keyPressEvent()
153   purpose  :
154 */
155 void VisuGUI_CursorDlg::keyPressEvent( QKeyEvent* e )
156 {
157   QDialog::keyPressEvent( e );
158   if ( e->isAccepted() )
159     return;
160
161   if ( e->key() == Key_F1 )
162     {
163       e->accept();
164       onHelp();
165     }
166 }