1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // VISU VISUGUI : GUI for SMESH component
24 // Author : Sergey LITONIN
27 #include "SVTK_FontWidget.h"
29 #include <QToolButton>
31 #include <QColorDialog>
33 #include <QHBoxLayout>
35 #include <vtkTextProperty.h>
38 * Class : SVTK_FontWidget
39 * Description : Dialog for specifynig font
45 SVTK_FontWidget::SVTK_FontWidget( QWidget* theParent )
46 : QWidget( theParent )
48 myColorBtn = new QToolButton( this );
49 myColorBtn->setMinimumWidth( 20 );
51 myFamily = new QComboBox( this );
52 myFamily->insertItem( myFamily->count(), tr( "ARIAL" ) );
53 myFamily->insertItem( myFamily->count(), tr( "COURIER" ) );
54 myFamily->insertItem( myFamily->count(), tr( "TIMES" ) );
56 myBold = new QCheckBox( tr( "BOLD" ), this );
57 myItalic = new QCheckBox( tr( "ITALIC" ), this );
58 myShadow = new QCheckBox( tr( "SHADOW" ), this );
60 QHBoxLayout* aHBLayout = new QHBoxLayout;
61 aHBLayout->setSpacing( 5 );
62 aHBLayout->addWidget(myColorBtn);
63 aHBLayout->addWidget(myFamily);
64 aHBLayout->addWidget(myBold);
65 aHBLayout->addWidget(myItalic);
66 aHBLayout->addWidget(myShadow);
67 this->setLayout(aHBLayout);
69 connect( myColorBtn, SIGNAL( clicked() ), SLOT( onColor() ) );
75 SVTK_FontWidget::~SVTK_FontWidget()
79 void SVTK_FontWidget::SetColor( const QColor& theColor )
82 palette.setColor(myColorBtn->backgroundRole(), theColor);
83 myColorBtn->setPalette(palette);
86 QColor SVTK_FontWidget::GetColor() const
88 return myColorBtn->palette().color( myColorBtn->backgroundRole() );
91 void SVTK_FontWidget::onColor()
93 QColor aColor = QColorDialog::getColor( GetColor(), this );
94 if ( aColor.isValid() )
98 void SVTK_FontWidget::SetData( const QColor& theColor,
101 const bool theItalic,
102 const bool theShadow )
104 SetColor( theColor );
106 if ( theFamily == VTK_ARIAL )
107 myFamily->setCurrentIndex( 0 );
108 else if ( theFamily == VTK_COURIER )
109 myFamily->setCurrentIndex( 1 );
111 myFamily->setCurrentIndex( 2 );
113 myBold->setChecked( theBold );
114 myItalic->setChecked( theItalic );
115 myShadow->setChecked( theShadow );
118 void SVTK_FontWidget::GetData( QColor& theColor,
122 bool& theShadow ) const
124 theColor = GetColor();
126 int anItem =myFamily->currentIndex();
128 theFamily = VTK_ARIAL;
129 else if ( anItem == 1 )
130 theFamily = VTK_COURIER;
132 theFamily = VTK_TIMES;
134 theBold = myBold->isChecked();
135 theItalic = myItalic->isChecked();
136 theShadow = myShadow->isChecked();