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

KDevelop Property Editing Library

  • lib
  • widgets
  • propeditor
plinestyleedit.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 "plinestyleedit.h"
21
22#include <tqpainter.h>
23#include <tqpixmap.h>
24#include <tqcombobox.h>
25#include <tqlayout.h>
26
27namespace PropertyLib {
28
29 const char *nopen[]={
30 "48 16 1 1",
31 ". c None",
32 "................................................",
33 "................................................",
34 "................................................",
35 "................................................",
36 "................................................",
37 "................................................",
38 "................................................",
39 "................................................",
40 "................................................",
41 "................................................",
42 "................................................",
43 "................................................",
44 "................................................",
45 "................................................",
46 "................................................",
47 "................................................"};
48 const char *solid[]={
49 "48 16 2 1",
50 ". c None",
51 "# c #000000",
52 "................................................",
53 "................................................",
54 "................................................",
55 "................................................",
56 "................................................",
57 "................................................",
58 "................................................",
59 ".###########################################....",
60 ".###########################################....",
61 "................................................",
62 "................................................",
63 "................................................",
64 "................................................",
65 "................................................",
66 "................................................",
67 "................................................"};
68 const char *dash[]={
69 "48 16 2 1",
70 ". c None",
71 "# c #000000",
72 "................................................",
73 "................................................",
74 "................................................",
75 "................................................",
76 "................................................",
77 "................................................",
78 "................................................",
79 ".#########..#########..#########..##########....",
80 ".#########..#########..#########..##########....",
81 "................................................",
82 "................................................",
83 "................................................",
84 "................................................",
85 "................................................",
86 "................................................",
87 "................................................"};
88 const char *dashdot[]={
89 "48 16 2 1",
90 ". c None",
91 "# c #000000",
92 "................................................",
93 "................................................",
94 "................................................",
95 "................................................",
96 "................................................",
97 "................................................",
98 "................................................",
99 ".#########..##..#########..##..#########..##....",
100 ".#########..##..#########..##..#########..##....",
101 "................................................",
102 "................................................",
103 "................................................",
104 "................................................",
105 "................................................",
106 "................................................",
107 "................................................"};
108 const char *dashdotdot[]={
109 "48 16 2 1",
110 ". c None",
111 "# c #000000",
112 "................................................",
113 "................................................",
114 "................................................",
115 "................................................",
116 "................................................",
117 "................................................",
118 "................................................",
119 ".#########..##..##..#########..##..##..#####....",
120 ".#########..##..##..#########..##..##..#####....",
121 "................................................",
122 "................................................",
123 "................................................",
124 "................................................",
125 "................................................",
126 "................................................",
127 "................................................"};
128
129
130PLineStyleEdit::PLineStyleEdit(MultiProperty* property, TQWidget* parent, const char* name): PropertyWidget(property, parent, name)
131{
132 TQHBoxLayout *l = new TQHBoxLayout(this, 0, 0);
133 m_edit = new TQComboBox(this);
134 m_edit->setSizePolicy(TQSizePolicy::MinimumExpanding, TQSizePolicy::MinimumExpanding);
135 l->addWidget(m_edit);
136
137 m_edit->insertItem(TQPixmap(nopen));
138 m_edit->insertItem(TQPixmap(solid));
139 m_edit->insertItem(TQPixmap(dash));
140 m_edit->insertItem(TQPixmap(dashdot));
141 m_edit->insertItem(TQPixmap(dashdotdot));
142
143 connect(m_edit, TQ_SIGNAL(activated(int)), this, TQ_SLOT(updateProperty(int)));
144}
145
146TQVariant PLineStyleEdit::value() const
147{
148 return m_edit->currentItem();
149}
150
151void PLineStyleEdit::drawViewer(TQPainter* p, const TQColorGroup& cg, const TQRect& r, const TQVariant& value)
152{
153 p->setPen(TQt::NoPen);
154 p->setBrush(cg.background());
155 p->drawRect(r);
156
157 if (!value.canCast(TQVariant::Int))
158 if ((value.toInt() > 5) || (value.toInt() < 0))
159 return;
160
161 switch (value.toInt()) {
162 case 0:
163 p->drawPixmap(r, TQPixmap(nopen));
164 break;
165 case 1:
166 p->drawPixmap(r, TQPixmap(solid));
167 break;
168 case 2:
169 p->drawPixmap(r, TQPixmap(dash));
170 break;
171 case 3:
172 p->drawPixmap(r, TQPixmap(dashdot));
173 break;
174 case 4:
175 p->drawPixmap(r, TQPixmap(dashdot));
176 break;
177 case 5:
178 p->drawPixmap(r, TQPixmap(dashdotdot));
179 break;
180 }
181}
182
183void PLineStyleEdit::setValue(const TQVariant& value, bool emitChange)
184{
185 if (!value.canCast(TQVariant::Int))
186 return;
187 if ((value.toInt() > 5) || (value.toInt() < 0))
188 return;
189 disconnect(m_edit, TQ_SIGNAL(activated(int)), this, TQ_SLOT(updateProperty(int)));
190 m_edit->setCurrentItem(value.toInt());
191 connect(m_edit, TQ_SIGNAL(activated(int)), this, TQ_SLOT(updateProperty(int)));
192 if (emitChange)
193 emit propertyChanged(m_property, value);
194}
195
196void PLineStyleEdit::updateProperty(int val)
197{
198 emit propertyChanged(m_property, TQVariant(val));
199}
200
201}
202
203#ifndef PURE_QT
204#include "plinestyleedit.moc"
205#endif
PropertyLib::MultiProperty
Holds a list of properties with the same name and type.
Definition multiproperty.h:50
PropertyLib::PLineStyleEdit::value
virtual TQVariant value() const
Definition plinestyleedit.cpp:146
PropertyLib::PLineStyleEdit::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't shown.
Definition plinestyleedit.cpp:151
PropertyLib::PLineStyleEdit::setValue
virtual void setValue(const TQVariant &value, bool emitChange)
Sets the value shown in the editor widget.
Definition plinestyleedit.cpp:183
PropertyLib::PropertyWidget
An abstract base class of property viewer and editor vidget.
Definition propertywidget.h:49
PropertyLib::PropertyWidget::propertyChanged
void propertyChanged(MultiProperty *property, const TQVariant &value)
Emit this signal when property value is changed.
PropertyLib
Namespace which contain property editing classes.
Definition childproperty.cpp:29

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.15.0
This website is maintained by Timothy Pearson.