1 // Copyright (C) 2007-2013 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
23 #include "HYDROGUI_ColorWidget.h"
25 #include <QColorDialog>
27 HYDROGUI_ColorWidget::HYDROGUI_ColorWidget( QWidget* parent )
30 setFrameShape( QFrame::Box );
31 //setFixedSize( 40, 20 );
32 //commented for correct layout management
33 //(otherwise the column with color widget can not be resized
34 //and all free space is arranged on sides
37 HYDROGUI_ColorWidget::~HYDROGUI_ColorWidget()
41 QColor HYDROGUI_ColorWidget::color() const
43 QPalette aPalette = palette();
44 return aPalette.color( QPalette::Window );
47 void HYDROGUI_ColorWidget::setColor( const QColor& c )
49 QPalette aPalette = palette();
50 aPalette.setColor( QPalette::Window, c );
51 setAutoFillBackground( true );
52 setPalette( aPalette );
55 void HYDROGUI_ColorWidget::mouseDoubleClickEvent( QMouseEvent* )
57 QColor c = QColorDialog::getColor( color(), this );
61 emit colorChanged( c );
65 int HYDROGUI_ColorWidget::intColor() const
67 return HYDROGUI_Tools::color2int( color() );
70 void HYDROGUI_ColorWidget::setColor( const int col )
72 setColor( HYDROGUI_Tools::int2color( col ) );
75 /*void HYDROGUI_ColorWidget::setRandColor()
77 setColor( HYDROGUI_Tools::randColor() );