kivio

kivio_fill_style.cpp

00001 /*
00002  * Kivio - Visual Modelling and Flowcharting
00003  * Copyright (C) 2000-2001 theKompany.com & Dave Marotti
00004  *
00005  * This program is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * as published by the Free Software Foundation; either version 2
00008  * of the License, or (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00018  */
00019 #include "kivio_common.h"
00020 #include "kivio_fill_style.h"
00021 
00022 #include <kdebug.h>
00023 
00030 KivioFillStyle::KivioFillStyle()
00031 {
00032     m_colorStyle = kcsSolid;
00033     m_color = QColor(255,255,255);
00034     m_color2 = QColor(255,255,255);
00035     m_brushStyle = QBrush::SolidPattern;
00036     m_gradientType = KImageEffect::VerticalGradient;
00037 }
00038 
00039 
00040 
00048 KivioFillStyle::KivioFillStyle( const KivioFillStyle &source )
00049 {
00050     m_colorStyle = source.colorStyle();
00051     m_color = source.color();
00052     m_brushStyle = source.brushStyle();
00053     m_gradientType = source.gradientType();
00054     m_color2 = source.color2();
00055 }
00056 
00057 
00058 
00066 void KivioFillStyle::copyInto( KivioFillStyle *pTarget ) const
00067 {
00068     if( !pTarget )
00069         return;
00070 
00071     pTarget->setKivioColorStyle(m_colorStyle);
00072     pTarget->setColor(m_color);
00073     pTarget->setBrushStyle(m_brushStyle);
00074     pTarget->setGradientType(m_gradientType);
00075     pTarget->setColor2(m_color2);
00076 }
00077 
00078 
00084 bool KivioFillStyle::loadXML( const QDomElement &e )
00085 {
00086   QDomElement ele;
00087   QDomNode node;
00088 
00089   m_color = XmlReadColor( e, "color", QColor(255,255,255).rgb() );
00090   m_color2 = XmlReadColor( e, "gradientColor", QColor(255,255,255).rgb() );
00091 
00092   m_colorStyle = static_cast<KivioColorStyle>(XmlReadInt( e, "colorStyle", kcsSolid ));
00093 
00094   m_gradientType = static_cast<KImageEffect::GradientType>(XmlReadInt(e, "gradientType", KImageEffect::VerticalGradient));
00095 
00096   return true;
00097 }
00098 
00099 
00100 
00108 QDomElement KivioFillStyle::saveXML( QDomDocument &doc )
00109 {
00110   QDomElement e = doc.createElement("KivioFillStyle");
00111 
00112   XmlWriteColor( e, "color", m_color );
00113   XmlWriteColor( e, "gradientColor", m_color2 );
00114 
00115   XmlWriteInt( e, "colorStyle", static_cast<int>(m_colorStyle) );
00116 
00117   XmlWriteInt( e, "gradientType", static_cast<int>(m_gradientType) );
00118 
00119   return e;
00120 }
00121 
00122 QBrush KivioFillStyle::brush()
00123 {
00124   QBrush b;
00125   b.setColor(m_color);
00126 
00127   switch(m_colorStyle) {
00128     case kcsSolid:
00129       b.setStyle(m_brushStyle);
00130       break;
00131 
00132     case kcsNone:
00133       b.setStyle(QBrush::NoBrush);
00134       break;
00135 
00136     case kcsGradient:
00137     case kcsPixmap:
00138     default:
00139       break;
00140   }
00141 
00142   return b;
00143 }
KDE Home | KDE Accessibility Home | Description of Access Keys