linestyle.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef LINESTYLE_H
00018 #define LINESTYLE_H
00019
00020 #include <QString>
00021 #include "style.h"
00022 #include "styles/stylecontextproxy.h"
00023
00024 class SCRIBUS_API LineStyle : public Style {
00025 public:
00026
00027
00028 LineStyle() : Style(), lineStyleProxy(this) {
00029 #define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
00030 m_##attr_NAME = attr_DEFAULT; \
00031 inh_##attr_NAME = true;
00032 #include "linestyle.attrdefs.cxx"
00033 #undef ATTRDEF
00034 };
00035
00036 LineStyle(double width, const QString& color, double shade=100) : Style(), lineStyleProxy(this) {
00037 #define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
00038 m_##attr_NAME = attr_DEFAULT; \
00039 inh_##attr_NAME = true;
00040 #include "linestyle.attrdefs.cxx"
00041 #undef ATTRDEF
00042 setWidth(width);
00043 setColor(color);
00044 setShade(shade);
00045 };
00046
00047 LineStyle(const LineStyle & other);
00048
00049 LineStyle & operator=(const LineStyle & other);
00050
00051 static const Xml_string saxxDefaultElem;
00052 static void desaxeRules(const Xml_string& prefixPattern, desaxe::Digester& ruleset, Xml_string elemtag = saxxDefaultElem);
00053
00054 virtual void saxx(SaxHandler& handler, const Xml_string& elemtag) const;
00055 virtual void saxx(SaxHandler& handler) const { saxx(handler, saxxDefaultElem); }
00056
00057 void getNamedResources(ResourceCollection& lists) const;
00058 void replaceNamedResources(ResourceCollection& newNames);
00059
00060 QString displayName() const;
00061
00062 void update(const StyleContext * b);
00063
00064 bool equiv(const Style& other) const;
00065
00066 void applyLineStyle(const LineStyle & other);
00067 void eraseLineStyle(const LineStyle & other);
00068 void setStyle(const LineStyle & other);
00069 void erase() { eraseLineStyle(*this); }
00070
00071 QString asString() const;
00072
00075 #define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
00076 attr_TYPE attr_GETTER() const { validate(); return m_##attr_NAME; }
00077 #include "linestyle.attrdefs.cxx"
00078 #undef ATTRDEF
00079
00082 #define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
00083 void set##attr_NAME(attr_TYPE v) { m_##attr_NAME = v; inh_##attr_NAME = false; }
00084 #include "linestyle.attrdefs.cxx"
00085 #undef ATTRDEF
00086 void appendSubline(const LineStyle& subline) { validate(); m_Sublines.append(subline); inh_Sublines = false; }
00087
00090 #define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
00091 void reset##attr_NAME() { m_##attr_NAME = attr_DEFAULT; inh_##attr_NAME = true; }
00092 #include "linestyle.attrdefs.cxx"
00093 #undef ATTRDEF
00094
00096 #define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
00097 bool isInh##attr_NAME() const { return inh_##attr_NAME; }
00098 #include "linestyle.attrdefs.cxx"
00099 #undef ATTRDEF
00100
00101
00103 #define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
00104 bool isDef##attr_NAME() const { \
00105 if ( !inh_##attr_NAME ) return true; \
00106 const LineStyle * par = dynamic_cast<const LineStyle*>(parentStyle()); \
00107 return par && par->isDef##attr_NAME(); \
00108 }
00109 #include "linestyle.attrdefs.cxx"
00110 #undef ATTRDEF
00111
00112
00113 private:
00114
00115 StyleContextProxy lineStyleProxy;
00116
00117
00118
00119
00120
00121 #define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
00122 attr_TYPE m_##attr_NAME; \
00123 bool inh_##attr_NAME;
00124 #include "linestyle.attrdefs.cxx"
00125 #undef ATTRDEF
00126 };
00127
00128
00129 inline LineStyle & LineStyle::operator=(const LineStyle & other)
00130 {
00131 static_cast<Style&>(*this) = static_cast<const Style&>(other);
00132 #define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
00133 m_##attr_NAME = other.m_##attr_NAME; \
00134 inh_##attr_NAME = other.inh_##attr_NAME;
00135 #include "linestyle.attrdefs.cxx"
00136 #undef ATTRDEF
00137 m_contextversion = -1;
00138 return *this;
00139 }
00140
00141 inline LineStyle::LineStyle(const LineStyle & other) : Style(other), lineStyleProxy(this)
00142 {
00143 #define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
00144 m_##attr_NAME = other.m_##attr_NAME; \
00145 inh_##attr_NAME = other.inh_##attr_NAME;
00146 #include "linestyle.attrdefs.cxx"
00147 #undef ATTRDEF
00148 m_contextversion = -1;
00149 }
00150
00151 #endif