1 // Copyright (C) 2007-2023 CEA, EDF, 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, or (at your option) any later version.
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
23 #include "ViewerTools_FontWidgetBase.h"
25 #include <QToolButton>
27 #include <QColorDialog>
29 #include <QHBoxLayout>
32 * Class : ViewerTools_FontWidgetBase
33 * Description : Dialog for specifynig font
39 ViewerTools_FontWidgetBase::ViewerTools_FontWidgetBase( QWidget* theParent )
40 : QWidget( theParent )
47 ViewerTools_FontWidgetBase::~ViewerTools_FontWidgetBase()
51 void ViewerTools_FontWidgetBase::Initialize()
53 myColorBtn = new QToolButton( this );
54 myColorBtn->setMinimumWidth( 20 );
56 myFamily = new QComboBox( this );
59 myBold = new QCheckBox( tr( "BOLD" ), this );
60 myItalic = new QCheckBox( tr( "ITALIC" ), this );
61 myShadow = new QCheckBox( tr( "SHADOW" ), this );
63 QHBoxLayout* aHBLayout = new QHBoxLayout;
64 aHBLayout->setMargin( 0 );
65 aHBLayout->setSpacing( 5 );
66 aHBLayout->addWidget(myColorBtn);
67 aHBLayout->addWidget(myFamily);
68 aHBLayout->addWidget(myBold);
69 aHBLayout->addWidget(myItalic);
70 aHBLayout->addWidget(myShadow);
71 aHBLayout->addStretch();
72 this->setLayout(aHBLayout);
74 connect( myColorBtn, SIGNAL( clicked() ), SLOT( onColor() ) );
76 if( myFamily->count() == 0 )
85 void ViewerTools_FontWidgetBase::SetColor( const QColor& theColor )
88 palette.setColor(myColorBtn->backgroundRole(), theColor);
89 myColorBtn->setPalette(palette);
92 QColor ViewerTools_FontWidgetBase::GetColor() const
94 return myColorBtn->palette().color( myColorBtn->backgroundRole() );
97 void ViewerTools_FontWidgetBase::onColor()
99 QColor aColor = QColorDialog::getColor( GetColor(), this );
100 if ( aColor.isValid() )
104 void ViewerTools_FontWidgetBase::SetData( const QColor& theColor,
105 const int /*theFamily*/,
107 const bool theItalic,
108 const bool theShadow )
110 SetColor( theColor );
112 myBold->setChecked( theBold );
113 myItalic->setChecked( theItalic );
114 myShadow->setChecked( theShadow );
117 void ViewerTools_FontWidgetBase::GetData( QColor& theColor,
121 bool& theShadow ) const
123 theColor = GetColor();
125 theBold = myBold->isChecked();
126 theItalic = myItalic->isChecked();
127 theShadow = myShadow->isChecked();