]> SALOME platform Git repositories - modules/visu.git/blob - src/VISUGUI/VisuGUI_CursorDlg.cxx
Salome HOME
Join modifications from branch OCC_debug_for_3_2_0b1
[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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
21 //
22 //
23 //
24 //  File   : VisuGUI_CursorDlg.cxx
25 //  Author : Laurent CORNABE & Hubert ROLLAND
26 //  Module : VISU
27 //  $Header$
28
29 using namespace std;
30
31 #include "VisuGUI.h"
32 #include "VisuGUI_CursorDlg.h"
33
34 #include "SUIT_Session.h"
35 #include "SUIT_MessageBox.h"
36 #include "SUIT_ResourceMgr.h"
37
38 #include "LightApp_Application.h"
39
40 #include <qlayout.h>
41
42 /*!
43   Constructor
44 */
45 VisuGUI_CursorDlg::VisuGUI_CursorDlg( QWidget* parent,  const char* name, bool modal, WFlags fl )
46     : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
47 {
48   if ( !name )
49     setName( "VisuGUI_CursorDlg" );
50   setCaption( name );
51   setSizeGripEnabled( TRUE );
52
53   QGridLayout* TopLayout = new QGridLayout( this );
54   TopLayout->setSpacing( 6 );
55   TopLayout->setMargin( 11 );
56
57   TopGroupBox = new QGroupBox( this, "TopGroupBox" );
58   TopGroupBox->setColumnLayout(0, Qt::Vertical );
59   TopGroupBox->layout()->setSpacing( 0 );
60   TopGroupBox->layout()->setMargin( 0 );
61   QGridLayout* TopGroupBoxLayout = new QGridLayout( TopGroupBox->layout() );
62   TopGroupBoxLayout->setAlignment( Qt::AlignTop );
63   TopGroupBoxLayout->setSpacing( 6 );
64   TopGroupBoxLayout->setMargin( 11 );
65
66   Comment1 = new QLabel( tr( "TextLabel1" ), TopGroupBox, "Comment1" );
67   Comment1->setAlignment( QLabel::AlignCenter );
68   TopGroupBoxLayout->addWidget( Comment1, 0, 0 );
69
70   Comment2 = new QLabel(  tr( "TextLabel2" ), TopGroupBox, "Comment2" );
71   Comment2->setAlignment( QLabel::AlignCenter );
72   TopGroupBoxLayout->addWidget( Comment2, 1, 0 );
73
74   SpinBox1 = new QSpinBox( 1, 100, 1, TopGroupBox, "SpinBox1" );
75   SpinBox1->setValue( 100 );
76   SpinBox1->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
77   SpinBox1->setMinimumSize( 70, 0 );
78   QHBoxLayout* SLayout = new QHBoxLayout;
79   SLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ) );
80   SLayout->addWidget( SpinBox1 );
81   SLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ) );
82   TopGroupBoxLayout->addLayout( SLayout, 2, 0 );
83
84   GroupButtons = new QGroupBox (this, "GroupButtons");
85   GroupButtons->setGeometry(QRect(10, 10, 281, 48));
86   GroupButtons->setColumnLayout(0, Qt::Vertical);
87   GroupButtons->layout()->setSpacing(0);
88   GroupButtons->layout()->setMargin(0);
89   QGridLayout* GroupButtonsLayout = new QGridLayout (GroupButtons->layout());
90   GroupButtonsLayout->setAlignment(Qt::AlignTop);
91   GroupButtonsLayout->setSpacing(6);
92   GroupButtonsLayout->setMargin(11);
93
94   buttonOk = new QPushButton (tr("&OK"), GroupButtons, "buttonOk");
95   buttonOk->setAutoDefault(TRUE);
96   buttonOk->setDefault(TRUE);
97   GroupButtonsLayout->addWidget(buttonOk, 0, 0);
98
99   GroupButtonsLayout->addItem(new QSpacerItem (5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 1);
100
101   buttonCancel = new QPushButton(tr("&Cancel") , GroupButtons, "buttonCancel");
102   buttonCancel->setAutoDefault(TRUE);
103   GroupButtonsLayout->addWidget(buttonCancel, 0, 2);
104
105   buttonHelp = new QPushButton(tr("&Help") , GroupButtons, "buttonHelp");
106   buttonHelp->setAutoDefault(TRUE);
107   GroupButtonsLayout->addWidget(buttonHelp, 0, 3);
108
109   TopLayout->addWidget(TopGroupBox,  0, 0);
110   TopLayout->addWidget(GroupButtons, 1, 0);
111
112   // signals and slots connections
113   connect( buttonOk,     SIGNAL( clicked() ), this, SLOT( accept() ) );
114   connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
115   connect( buttonHelp,   SIGNAL( clicked() ), this, SLOT( onHelp() ) );
116 }
117
118 /*!
119   Destructor
120 */
121 VisuGUI_CursorDlg::~VisuGUI_CursorDlg()
122 {
123 }
124
125 /*!
126   function : onHelp()
127   purpose  :
128 */
129 void VisuGUI_CursorDlg::onHelp()
130 {
131   QString aHelpFileName = "/files/changing_visualization_parameters_of_the_presenetation.htm#Width";
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(""), aHelpFileName);
136   }
137   else {
138     SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
139                            QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
140                            arg(app->resourceMgr()->stringValue("ExternalBrowser", "application")).arg(aHelpFileName),
141                            QObject::tr("BUT_OK"));
142   }
143 }