]> SALOME platform Git repositories - modules/gui.git/blob - src/SVTK/SVTK_FontWidget.cxx
Salome HOME
92f16923e9d4dd7091defeb48d8d26f9c28a7b0d
[modules/gui.git] / src / SVTK / SVTK_FontWidget.cxx
1 //  VISU VISUGUI : GUI for SMESH 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   : 
25 //  Author : Sergey LITONIN
26 //  Module : 
27
28 #include "SVTK_FontWidget.h"
29
30 #include <qtoolbutton.h>
31 #include <qcombobox.h>
32 #include <qcolordialog.h>
33 #include <qcheckbox.h>
34
35 #include <vtkTextProperty.h>
36
37 /*!
38  * Class       : SVTK_FontWidget
39  * Description : Dialog for specifynig font
40  */
41
42 /*!
43   Constructor
44 */
45 SVTK_FontWidget::SVTK_FontWidget( QWidget* theParent )
46 : QHBox( theParent )
47 {
48   setSpacing( 5 );
49   myColorBtn = new QToolButton( this );
50   myColorBtn->setMinimumWidth( 20 );
51
52   myFamily = new QComboBox( this );
53   myFamily->insertItem( tr( "ARIAL" ) );
54   myFamily->insertItem( tr( "COURIER" ) );
55   myFamily->insertItem( tr( "TIMES" ) );
56
57   myBold = new QCheckBox( tr( "BOLD" ), this );
58   myItalic = new QCheckBox( tr( "ITALIC" ), this );
59   myShadow = new QCheckBox( tr( "SHADOW" ), this );
60
61   connect( myColorBtn, SIGNAL( clicked() ), SLOT( onColor() ) );
62 }
63
64 /*!
65   Destructor
66 */
67 SVTK_FontWidget::~SVTK_FontWidget()
68 {
69 }
70
71 void SVTK_FontWidget::SetColor( const QColor& theColor )
72 {
73   myColorBtn->setPaletteBackgroundColor( theColor );
74 }
75
76 QColor SVTK_FontWidget::GetColor() const
77 {
78   return myColorBtn->paletteBackgroundColor();
79 }
80
81 void SVTK_FontWidget::onColor()
82 {
83   QColor aColor = QColorDialog::getColor( GetColor(), this );
84   if ( aColor.isValid() )
85     SetColor( aColor );
86 }
87
88 void SVTK_FontWidget::SetData( const QColor& theColor,
89                               const int theFamily,
90                               const bool theBold,
91                               const bool theItalic,
92                               const bool theShadow )
93 {
94   SetColor( theColor );
95
96   if ( theFamily == VTK_ARIAL )
97     myFamily->setCurrentItem( 0 );
98   else if ( theFamily == VTK_COURIER )
99     myFamily->setCurrentItem( 1 );
100   else
101     myFamily->setCurrentItem( 2 );
102
103   myBold->setChecked( theBold );
104   myItalic->setChecked( theItalic );
105   myShadow->setChecked( theShadow );
106 }
107
108 void SVTK_FontWidget::GetData( QColor& theColor,
109                                int& theFamily,
110                                bool& theBold,
111                                bool& theItalic,
112                                bool& theShadow ) const
113 {
114   theColor = GetColor();
115
116   int anItem =myFamily->currentItem();
117   if ( anItem == 0 )
118     theFamily = VTK_ARIAL;
119   else if ( anItem == 1 )
120     theFamily = VTK_COURIER;
121   else
122     theFamily = VTK_TIMES;
123
124   theBold = myBold->isChecked();
125   theItalic = myItalic->isChecked();
126   theShadow = myShadow->isChecked();
127 }