kivio_fill_style.cpp
1/*
2 * Kivio - Visual Modelling and Flowcharting
3 * Copyright (C) 2000-2001 theKompany.com & Dave Marotti
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the 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 General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19#include "kivio_common.h"
20#include "kivio_fill_style.h"
21
22#include <kdebug.h>
23
30KivioFillStyle::KivioFillStyle()
31{
32 m_colorStyle = kcsSolid;
33 m_color = TQColor(255,255,255);
34 m_color2 = TQColor(255,255,255);
35 m_brushStyle = TQt::SolidPattern;
36 m_gradientType = KImageEffect::VerticalGradient;
37}
38
39
40
48KivioFillStyle::KivioFillStyle( const KivioFillStyle &source )
49{
50 m_colorStyle = source.colorStyle();
51 m_color = source.color();
52 m_brushStyle = source.brushStyle();
53 m_gradientType = source.gradientType();
54 m_color2 = source.color2();
55}
56
57
58
66void KivioFillStyle::copyInto( KivioFillStyle *pTarget ) const
67{
68 if( !pTarget )
69 return;
70
71 pTarget->setKivioColorStyle(m_colorStyle);
72 pTarget->setColor(m_color);
73 pTarget->setBrushStyle(m_brushStyle);
74 pTarget->setGradientType(m_gradientType);
75 pTarget->setColor2(m_color2);
76}
77
78
84bool KivioFillStyle::loadXML( const TQDomElement &e )
85{
86 TQDomElement ele;
87 TQDomNode node;
88
89 m_color = XmlReadColor( e, "color", TQColor(255,255,255).rgb() );
90 m_color2 = XmlReadColor( e, "gradientColor", TQColor(255,255,255).rgb() );
91
92 m_colorStyle = static_cast<KivioColorStyle>(XmlReadInt( e, "colorStyle", kcsSolid ));
93
94 m_gradientType = static_cast<KImageEffect::GradientType>(XmlReadInt(e, "gradientType", KImageEffect::VerticalGradient));
95
96 return true;
97}
98
99
100
108TQDomElement KivioFillStyle::saveXML( TQDomDocument &doc )
109{
110 TQDomElement e = doc.createElement("KivioFillStyle");
111
112 XmlWriteColor( e, "color", m_color );
113 XmlWriteColor( e, "gradientColor", m_color2 );
114
115 XmlWriteInt( e, "colorStyle", static_cast<int>(m_colorStyle) );
116
117 XmlWriteInt( e, "gradientType", static_cast<int>(m_gradientType) );
118
119 return e;
120}
121
122TQBrush KivioFillStyle::brush()
123{
124 TQBrush b;
125 b.setColor(m_color);
126
127 switch(m_colorStyle) {
128 case kcsSolid:
129 b.setStyle(m_brushStyle);
130 break;
131
132 case kcsNone:
133 b.setStyle(TQt::NoBrush);
134 break;
135
136 case kcsGradient:
137 case kcsPixmap:
138 default:
139 break;
140 }
141
142 return b;
143}