Back to index

scribus-ng  1.3.4.dfsg+svn20071115
linestyle.h
Go to the documentation of this file.
00001 /*
00002  For general Scribus (>=1.3.2) copyright and licensing information please refer
00003  to the COPYING file provided with the program. Following this notice may exist
00004  a copyright and/or license notice that predates the release of Scribus 1.3.2
00005  for which a new license (GPL+exception) is in place.
00006  */
00007 /***************************************************************************
00008 *                                                                         *
00009 *   This program is free software; you can redistribute it and/or modify  *
00010 *   it under the terms of the GNU General Public License as published by  *
00011 *   the Free Software Foundation; either version 2 of the License, or     *
00012 *   (at your option) any later version.                                   *
00013 *                                                                         *
00014 ***************************************************************************/
00015 
00016 
00017 #ifndef LINESTYLE_H
00018 #define LINESTYLE_H
00019 
00020 #include <qstring.h>
00021 #include <qvaluelist.h>
00022 #include "style.h"
00023 #include "styles/stylecontextproxy.h"
00024 
00025 class SCRIBUS_API LineStyle : public Style {
00026 public:
00027 
00028        
00029     LineStyle() : Style(), lineStyleProxy(this) {
00030 #define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
00031               m_##attr_NAME = attr_DEFAULT; \
00032               inh_##attr_NAME = true;
00033 #include "linestyle.attrdefs.cxx"
00034 #undef ATTRDEF
00035     };
00036        
00037     LineStyle(double width, const QString& color, double shade=100) : Style(), lineStyleProxy(this)  {
00038 #define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
00039               m_##attr_NAME = attr_DEFAULT; \
00040               inh_##attr_NAME = true;
00041 #include "linestyle.attrdefs.cxx"
00042 #undef ATTRDEF
00043               setWidth(width);
00044               setColor(color);
00045               setShade(shade);
00046     };
00047        
00048        LineStyle(const LineStyle & other);
00049        
00050        LineStyle & operator=(const LineStyle & other);
00051        
00052        static const Xml_string saxxDefaultElem;
00053        static void  desaxeRules(const Xml_string& prefixPattern, desaxe::Digester& ruleset, Xml_string elemtag = saxxDefaultElem);
00054        
00055        virtual void saxx(SaxHandler& handler, const Xml_string& elemtag) const;
00056        virtual void saxx(SaxHandler& handler)                     const { saxx(handler, saxxDefaultElem); }
00057        
00058        void getNamedResources(ResourceCollection& lists) const;
00059        void replaceNamedResources(ResourceCollection& newNames);
00060 
00061        QString displayName() const;
00062 
00063        void update(const StyleContext * b);
00064        
00065        bool equiv(const Style& other) const;     
00066        
00067        void applyLineStyle(const LineStyle & other);
00068        void eraseLineStyle(const LineStyle & other);
00069        void setStyle(const LineStyle & other);
00070        void erase() { eraseLineStyle(*this); }
00071        
00072        QString asString() const;
00073        
00076 #define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
00077        const attr_TYPE attr_GETTER() const { validate(); return m_##attr_NAME; }
00078 #include "linestyle.attrdefs.cxx"
00079 #undef ATTRDEF
00080        
00083 #define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
00084        void set##attr_NAME(attr_TYPE v) { m_##attr_NAME = v; inh_##attr_NAME = false; }
00085 #include "linestyle.attrdefs.cxx"
00086 #undef ATTRDEF
00087        void appendSubline(const LineStyle& subline) { validate(); m_Sublines.append(subline); inh_Sublines = false; }
00088        
00091 #define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
00092        void reset##attr_NAME() { m_##attr_NAME = attr_DEFAULT; inh_##attr_NAME = true; }
00093 #include "linestyle.attrdefs.cxx"
00094 #undef ATTRDEF
00095        
00097 #define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
00098        bool isInh##attr_NAME() const { return inh_##attr_NAME; }
00099 #include "linestyle.attrdefs.cxx"
00100 #undef ATTRDEF
00101        
00102        
00104 #define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
00105        bool isDef##attr_NAME() const { \
00106               if ( !inh_##attr_NAME ) return true; \
00107               const LineStyle * par = dynamic_cast<const LineStyle*>(parentStyle()); \
00108               return par && par->isDef##attr_NAME(); \
00109        }
00110 #include "linestyle.attrdefs.cxx"
00111 #undef ATTRDEF
00112        
00113        
00114 private:
00115 
00116        StyleContextProxy lineStyleProxy;
00117        // FIXME: see pstyle how this works for nested styles
00118        
00119        
00120        // member declarations:
00121               
00122 #define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
00123        attr_TYPE m_##attr_NAME; \
00124        bool inh_##attr_NAME;
00125 #include "linestyle.attrdefs.cxx"
00126 #undef ATTRDEF
00127 };
00128 
00129 
00130 inline LineStyle & LineStyle::operator=(const LineStyle & other)
00131 {
00132        static_cast<Style&>(*this) = static_cast<const Style&>(other);
00133 #define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
00134        m_##attr_NAME = other.m_##attr_NAME; \
00135        inh_##attr_NAME = other.inh_##attr_NAME;
00136 #include "linestyle.attrdefs.cxx"
00137 #undef ATTRDEF
00138        m_contextversion = -1;
00139        return *this;
00140 }
00141 
00142 inline LineStyle::LineStyle(const LineStyle & other) : Style(other), lineStyleProxy(this)
00143 {
00144 #define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
00145        m_##attr_NAME = other.m_##attr_NAME; \
00146        inh_##attr_NAME = other.inh_##attr_NAME;
00147 #include "linestyle.attrdefs.cxx"
00148 #undef ATTRDEF
00149        m_contextversion = -1;
00150 }
00151 
00152 #endif