1 // VISU VISUGUI : GUI for SMESH 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
25 // Author : Sergey LITONIN
28 #include "SVTK_FontWidget.h"
30 #include <qtoolbutton.h>
31 #include <qcombobox.h>
32 #include <qcolordialog.h>
33 #include <qcheckbox.h>
35 #include <vtkTextProperty.h>
38 * Class : SVTK_FontWidget
39 * Description : Dialog for specifynig font
45 SVTK_FontWidget::SVTK_FontWidget( QWidget* theParent )
49 myColorBtn = new QToolButton( this );
50 myColorBtn->setMinimumWidth( 20 );
52 myFamily = new QComboBox( this );
53 myFamily->insertItem( tr( "ARIAL" ) );
54 myFamily->insertItem( tr( "COURIER" ) );
55 myFamily->insertItem( tr( "TIMES" ) );
57 myBold = new QCheckBox( tr( "BOLD" ), this );
58 myItalic = new QCheckBox( tr( "ITALIC" ), this );
59 myShadow = new QCheckBox( tr( "SHADOW" ), this );
61 connect( myColorBtn, SIGNAL( clicked() ), SLOT( onColor() ) );
67 SVTK_FontWidget::~SVTK_FontWidget()
71 void SVTK_FontWidget::SetColor( const QColor& theColor )
73 myColorBtn->setPaletteBackgroundColor( theColor );
76 QColor SVTK_FontWidget::GetColor() const
78 return myColorBtn->paletteBackgroundColor();
81 void SVTK_FontWidget::onColor()
83 QColor aColor = QColorDialog::getColor( GetColor(), this );
84 if ( aColor.isValid() )
88 void SVTK_FontWidget::SetData( const QColor& theColor,
92 const bool theShadow )
96 if ( theFamily == VTK_ARIAL )
97 myFamily->setCurrentItem( 0 );
98 else if ( theFamily == VTK_COURIER )
99 myFamily->setCurrentItem( 1 );
101 myFamily->setCurrentItem( 2 );
103 myBold->setChecked( theBold );
104 myItalic->setChecked( theItalic );
105 myShadow->setChecked( theShadow );
108 void SVTK_FontWidget::GetData( QColor& theColor,
112 bool& theShadow ) const
114 theColor = GetColor();
116 int anItem =myFamily->currentItem();
118 theFamily = VTK_ARIAL;
119 else if ( anItem == 1 )
120 theFamily = VTK_COURIER;
122 theFamily = VTK_TIMES;
124 theBold = myBold->isChecked();
125 theItalic = myItalic->isChecked();
126 theShadow = myShadow->isChecked();