Salome HOME
Copyright update 2020
[modules/gui.git] / src / SVTK / SVTK_FontWidget.cxx
1 // Copyright (C) 2007-2020  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  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, or (at your option) any later version.
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 //  VISU VISUGUI : GUI for SMESH component
24 //  File   : 
25 //  Author : Sergey LITONIN
26 //  Module : 
27 //
28 #include "SVTK_FontWidget.h"
29
30 #include <QComboBox>
31
32 #include <vtkTextProperty.h>
33
34 /*!
35  * Class       : SVTK_FontWidget
36  * Description : Dialog for specifynig font
37  */
38
39 /*!
40   Constructor
41 */
42 SVTK_FontWidget::SVTK_FontWidget( QWidget* theParent )
43 : ViewerTools_FontWidgetBase( theParent )
44 {
45 }
46
47 /*!
48   Destructor
49 */
50 SVTK_FontWidget::~SVTK_FontWidget()
51 {
52 }
53
54 void SVTK_FontWidget::InitializeFamilies()
55 {
56   myFamily->insertItem( myFamily->count(), tr( "ARIAL" ) );
57   myFamily->insertItem( myFamily->count(), tr( "COURIER" ) );
58   myFamily->insertItem( myFamily->count(), tr( "TIMES" ) );
59 }
60
61 void SVTK_FontWidget::SetData( const QColor& theColor,
62                                const int theFamily,
63                                const bool theBold,
64                                const bool theItalic,
65                                const bool theShadow )
66 {
67   ViewerTools_FontWidgetBase::SetData( theColor,
68                                        theFamily,
69                                        theBold,
70                                        theItalic,
71                                        theShadow );
72
73   if ( theFamily == VTK_ARIAL )
74     myFamily->setCurrentIndex( 0 );
75   else if ( theFamily == VTK_COURIER )
76     myFamily->setCurrentIndex( 1 );
77   else
78     myFamily->setCurrentIndex( 2 );
79 }
80
81 void SVTK_FontWidget::GetData( QColor& theColor,
82                                int& theFamily,
83                                bool& theBold,
84                                bool& theItalic,
85                                bool& theShadow ) const
86 {
87   ViewerTools_FontWidgetBase::GetData( theColor,
88                                        theFamily,
89                                        theBold,
90                                        theItalic,
91                                        theShadow );
92
93   int anItem = myFamily->currentIndex();
94   if ( anItem == 0 )
95     theFamily = VTK_ARIAL;
96   else if ( anItem == 1 )
97     theFamily = VTK_COURIER;
98   else
99     theFamily = VTK_TIMES;
100 }