Salome HOME
312b9283ebec665854daf335c555e07a41b91263
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_ColorWidget.cxx
1
2 #include <HYDROGUI_ColorWidget.h>
3 #include <QColorDialog>
4
5 HYDROGUI_ColorWidget::HYDROGUI_ColorWidget( QWidget* parent )
6 : QFrame( parent )
7 {
8   setFrameShape( QFrame::Box );
9   //setFixedSize( 40, 20 );
10   //commented for correct layout management
11   //(otherwise the column with color widget can not be resized
12   //and all free space is arranged on sides
13 }
14
15 HYDROGUI_ColorWidget::~HYDROGUI_ColorWidget()
16 {
17 }
18
19 QColor HYDROGUI_ColorWidget::color() const
20 {
21   QPalette aPalette = palette();
22   return aPalette.color( QPalette::Window );
23 }
24
25 void HYDROGUI_ColorWidget::setColor( const QColor& c )
26 {
27   QPalette aPalette = palette();
28   aPalette.setColor( QPalette::Window, c );
29   setAutoFillBackground( true );
30   setPalette( aPalette );
31 }
32
33 void HYDROGUI_ColorWidget::mouseDoubleClickEvent( QMouseEvent* )
34 {
35   QColor c = QColorDialog::getColor( color(), this );
36   if( c.isValid() )
37   {
38     setColor( c );
39     emit colorChanged( c );
40   }
41 }
42 /*
43 int HYDROGUI_ColorWidget::intColor() const
44 {
45   return HYDROGUI_Tools::color2int( color() );
46 }
47
48 void HYDROGUI_ColorWidget::setColor( const int col )
49 {
50   setColor( HYDROGUI_Tools::int2color( col ) );
51 }
52 */
53 /*void HYDROGUI_ColorWidget::setRandColor()
54 {
55   setColor( HYDROGUI_Tools::randColor() );
56 }*/