kivio_line_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_line_style.h"
21
22KivioLineStyle::KivioLineStyle()
23{
24 m_color = TQColor(0,0,0);
25 m_width = 1.0f;
26 m_capStyle = TQt::FlatCap;
27 m_joinStyle = TQt::RoundJoin;
28 m_style = TQt::SolidLine;
29}
30
31KivioLineStyle::KivioLineStyle( const KivioLineStyle &ls )
32{
33 m_color = ls.color();
34 m_width = ls.width();
35 m_capStyle = ls.capStyle();
36 m_joinStyle = ls.joinStyle();
37 m_style = ls.style();
38}
39
40KivioLineStyle::~KivioLineStyle()
41{
42}
43
44void KivioLineStyle::copyInto( KivioLineStyle *pTarget )
45{
46 pTarget->m_color = m_color;
47 pTarget->m_width = m_width;
48 pTarget->m_capStyle = m_capStyle;
49 pTarget->m_joinStyle = m_joinStyle;
50 pTarget->m_style = m_style;
51}
52
53TQDomElement KivioLineStyle::saveXML( TQDomDocument &doc )
54{
55 TQDomElement e = doc.createElement("KivioLineStyle");
56
57 XmlWriteColor( e, "color", m_color );
58 XmlWriteFloat( e, "width", m_width );
59 XmlWriteInt( e, "capStyle", m_capStyle );
60 XmlWriteInt( e, "joinStyle", m_joinStyle );
61 XmlWriteInt( e, "pattern", m_style );
62 return e;
63}
64
65bool KivioLineStyle::loadXML( const TQDomElement &e )
66{
67 m_color = XmlReadColor( e, "color", TQColor(0,0,0) );
68 m_width = XmlReadFloat( e, "width", 1.0f );
69 m_capStyle = XmlReadInt( e, "capStyle", TQt::RoundCap );
70 m_joinStyle = XmlReadInt( e, "joinStyle", TQt::RoundJoin );
71 m_style = XmlReadInt( e, "pattern", TQt::SolidLine );
72 return true;
73}
74
75TQPen KivioLineStyle::pen( float scale ) const
76{
77 TQPen p;
78 float s = m_width * scale;
79
80 p.setColor( m_color );
81 p.setWidth( (int)s );
82 p.setJoinStyle( (TQt::PenJoinStyle)m_joinStyle );
83 p.setCapStyle( (TQt::PenCapStyle)m_capStyle );
84 p.setStyle( (TQt::PenStyle)m_style );
85
86 return p;
87}