Salome HOME
Formatting.
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_ColorWidget.cxx
1 // Copyright (C) 2007-2013  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.
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 #include "HYDROGUI_ColorWidget.h"
24
25 #include <QColorDialog>
26
27 HYDROGUI_ColorWidget::HYDROGUI_ColorWidget( QWidget* parent )
28 : QFrame( parent )
29 {
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
35 }
36
37 HYDROGUI_ColorWidget::~HYDROGUI_ColorWidget()
38 {
39 }
40
41 QColor HYDROGUI_ColorWidget::color() const
42 {
43   QPalette aPalette = palette();
44   return aPalette.color( QPalette::Window );
45 }
46
47 void HYDROGUI_ColorWidget::setColor( const QColor& c )
48 {
49   QPalette aPalette = palette();
50   aPalette.setColor( QPalette::Window, c );
51   setAutoFillBackground( true );
52   setPalette( aPalette );
53 }
54
55 void HYDROGUI_ColorWidget::mouseDoubleClickEvent( QMouseEvent* )
56 {
57   QColor c = QColorDialog::getColor( color(), this );
58   if( c.isValid() )
59   {
60     setColor( c );
61     emit colorChanged( c );
62   }
63 }
64 /*
65 int HYDROGUI_ColorWidget::intColor() const
66 {
67   return HYDROGUI_Tools::color2int( color() );
68 }
69
70 void HYDROGUI_ColorWidget::setColor( const int col )
71 {
72   setColor( HYDROGUI_Tools::int2color( col ) );
73 }
74 */
75 /*void HYDROGUI_ColorWidget::setRandColor()
76 {
77   setColor( HYDROGUI_Tools::randColor() );
78 }*/