• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • KDevelop Property Editing Library
 

KDevelop Property Editing Library

  • lib
  • widgets
  • propeditor
pcolorbutton.cpp
1 /***************************************************************************
2  * Copyright (C) 2004 by Alexander Dymo *
3  * cloudtemple@mskat.net *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU Library General Public License as *
7  * published by the Free Software Foundation; either version 2 of the *
8  * License, or (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU Library General Public *
16  * License along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19  ***************************************************************************/
20 #include "pcolorbutton.h"
21 
22 #include <tqlayout.h>
23 #include <tqpainter.h>
24 
25 #ifndef PURE_QT
26 #include <kcolorbutton.h>
27 #else
28 #include <tqpushbutton.h>
29 #include <tqpixmap.h>
30 #include <tqiconset.h>
31 #endif
32 #include <tqcolordialog.h>
33 
34 namespace PropertyLib {
35 
36 PColorButton::PColorButton(MultiProperty* property, TQWidget* parent, const char* name)
37  :PropertyWidget(property, parent, name)
38 {
39  TQHBoxLayout *l = new TQHBoxLayout(this, 0, 0);
40 #ifndef PURE_QT
41  m_edit = new KColorButton(this);
42  connect(m_edit, TQT_SIGNAL(changed(const TQColor&)), this, TQT_SLOT(updateProperty(const TQColor&)));
43 #else
44  m_edit = new TQPushButton(this);
45  connect(m_edit, TQT_SIGNAL(clicked()), this, TQT_SLOT(changeColor()));
46 #endif
47 
48  m_edit->setSizePolicy(TQSizePolicy::MinimumExpanding, TQSizePolicy::MinimumExpanding);
49  l->addWidget(m_edit);
50 }
51 
52 TQVariant PColorButton::value() const
53 {
54 #ifndef PURE_QT
55  return TQVariant(m_edit->color());
56 #else
57  return TQVariant(m_color);
58 #endif
59 }
60 
61 void PColorButton::drawViewer(TQPainter* p, const TQColorGroup& cg, const TQRect& r, const TQVariant& value)
62 {
63 /* p->setBrush(value.toColor());
64  p->setPen(TQt::NoPen);
65  p->drawRect(r);*/
66  p->setPen(TQt::NoPen);
67  p->setBrush(cg.background());
68  p->drawRect(r);
69 
70  p->setBrush(value.toColor());
71  p->setPen(TQt::SolidLine);
72  TQRect r2(r);
73  r2.setTopLeft(r.topLeft() + TQPoint(5,5));
74  r2.setBottomRight(r.bottomRight() - TQPoint(5,5));
75  p->drawRect(r2);
76 }
77 
78 void PColorButton::setValue(const TQVariant& value, bool emitChange)
79 {
80 #ifndef PURE_QT
81  disconnect(m_edit, TQT_SIGNAL(changed(const TQColor&)), this, TQT_SLOT(updateProperty(const TQColor&)));
82  m_edit->setColor(value.toColor());
83  connect(m_edit, TQT_SIGNAL(changed(const TQColor&)), this, TQT_SLOT(updateProperty(const TQColor&)));
84 #else
85  m_color = value.toColor();
86  m_edit->setText(m_color.name());
87  TQPixmap px;
88  px.resize(14,14);
89  px.fill(m_color);
90  m_edit->setIconSet(px);
91 #endif
92  if (emitChange)
93  emit propertyChanged(m_property, value);
94 
95 }
96 
97 void PColorButton::updateProperty(const TQColor &// color
98  )
99 {
100  emit propertyChanged(m_property, value());
101 }
102 
103 void PColorButton::changeColor()
104 {
105 #ifdef PURE_QT
106  m_color = TQColorDialog::getColor(m_color,this);
107  updateProperty(m_color);
108  m_edit->setText(m_color.name());
109  TQPixmap px;
110  px.resize(14,14);
111  px.fill(m_color);
112  m_edit->setIconSet(px);
113 
114 #endif
115 }
116 
117 }
118 #ifndef PURE_QT
119 #include "pcolorbutton.moc"
120 #endif
PropertyLib::PCheckBox::value
virtual TQVariant value() const
Definition: pcheckbox.cpp:45
PropertyLib::PColorButton::drawViewer
virtual void drawViewer(TQPainter *p, const TQColorGroup &cg, const TQRect &r, const TQVariant &value)
Function to draw a property viewer when the editor isn&#39;t shown.
Definition: pcolorbutton.cpp:61
PropertyLib
Namespace which contain property editing classes.
Definition: childproperty.cpp:29
PropertyLib::PColorButton::setValue
virtual void setValue(const TQVariant &value, bool emitChange)
Sets the value shown in the editor widget.
Definition: pcolorbutton.cpp:78
PropertyLib::PropertyWidget::propertyChanged
void propertyChanged(MultiProperty *property, const TQVariant &value)
Emit this signal when property value is changed.
PropertyLib::PColorButton::value
virtual TQVariant value() const
Definition: pcolorbutton.cpp:52

KDevelop Property Editing Library

Skip menu "KDevelop Property Editing Library"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

KDevelop Property Editing Library

Skip menu "KDevelop Property Editing Library"
  • buildtools
  •   lib
  •     base
  •     parsers
  •       autotools
  •       qmake
  •     widgets
  •   api
  • languages
  •   lib
  •     debugger
  •     designer_integration
  •     interfaces
  • lib
  •   catalog
  •   interfaces
  •     extensions
  •     external
  •     extras
  •   util
  •   widgets
  •     propeditor
  • parts
  •   documentation
  •     interfaces
  • src
  •   profileengine
  •     lib
Generated for KDevelop Property Editing Library by doxygen 1.8.13
This website is maintained by Timothy Pearson.