text-tag.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 /* 
00004  * Gnome Chemistry Utils
00005  * gccv/text-tag.h 
00006  *
00007  * Copyright (C) 2008-2009 Jean Bréfort <jean.brefort@normalesup.org>
00008  *
00009  * This program is free software; you can redistribute it and/or 
00010  * modify it under the terms of the GNU General Public License as 
00011  * published by the Free Software Foundation; either version 2 of the
00012  * License, or (at your option) any later version.
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software
00021  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
00022  * USA
00023  */
00024 
00025 #ifndef GCCV_TEXT_TAG_H
00026 #define GCCV_TEXT_TAG_H
00027 
00028 #include "structs.h"
00029 #include <gcu/macros.h>
00030 #include <list>
00031 #include <string>
00032 
00034 namespace gccv {
00035 
00036 // Text attributes support
00037 typedef enum
00038 {
00039         Invalid,
00040         Family,
00041         Size,
00042         Style,
00043         Weight,
00044         Variant,
00045         Stretch,
00046         Underline,
00047         Strikethrough,
00048         Foreground,
00049         Background,
00050         Rise,
00051         Position,
00052         NewLine,
00053         MaxTag
00054 } Tag;
00055 
00056 typedef enum
00057 {
00058         TagPriorityFirst,
00059         TagPriorityLast,
00060 } TagPriority;
00061 
00062 class TextTag
00063 {
00064 public:
00065         TextTag (Tag tag, TagPriority priority = TagPriorityFirst);
00066         virtual ~TextTag ();
00067 
00068         virtual void Filter (PangoAttrList *l, unsigned start, unsigned end) = 0;
00069         virtual bool operator== (TextTag const& tag) const = 0;
00070         virtual TextTag *Duplicate () const = 0;
00071         virtual bool NeedsNewRun () {return false;}
00072 
00073         static Tag RegisterTagType ();
00074         static Tag MaxTag;
00075         static bool Order (TextTag *first, TextTag *last);
00076 
00077 GCU_RO_PROP (Tag, Tag)
00078 GCU_RO_PROP (TagPriority, Priority)
00079 GCU_PROP (unsigned, StartIndex)
00080 GCU_PROP (unsigned, EndIndex)
00081 GCU_PROT_PROP (bool, Stacked)
00082 GCU_PROT_PROP (bool, NewLine)
00083 };
00084 
00085 class FamilyTextTag: public TextTag
00086 {
00087 public:
00088         FamilyTextTag (std::string const &family);
00089         FamilyTextTag (char const *family);
00090         virtual ~FamilyTextTag ();
00091 
00092         void Filter (PangoAttrList *l, unsigned start, unsigned end);
00093         bool operator== (TextTag const& tag) const;
00094         TextTag *Duplicate () const;
00095         std::string const &GetFamily () const {return m_Family;}
00096 
00097 private:
00098         std::string m_Family;
00099 };
00100 
00101 class SizeTextTag: public TextTag
00102 {
00103 public:
00104         SizeTextTag (double size);
00105         virtual ~SizeTextTag ();
00106 
00107         void Filter (PangoAttrList *l, unsigned start, unsigned end);
00108         bool operator== (TextTag const& tag) const;
00109         TextTag *Duplicate () const;
00110         double GetSize () const {return m_Size;}
00111 
00112 private:
00113         double m_Size;
00114 };
00115 
00116 class StyleTextTag: public TextTag
00117 {
00118 public:
00119         StyleTextTag (PangoStyle style);
00120         virtual ~StyleTextTag ();
00121 
00122         void Filter (PangoAttrList *l, unsigned start, unsigned end);
00123         bool operator== (TextTag const& tag) const;
00124         TextTag *Duplicate () const;
00125         PangoStyle GetStyle () const {return m_Style;}
00126 
00127 private:
00128         PangoStyle m_Style;
00129 };
00130 
00131 class WeightTextTag: public TextTag
00132 {
00133 public:
00134         WeightTextTag (PangoWeight weight);
00135         virtual ~WeightTextTag ();
00136 
00137         void Filter (PangoAttrList *l, unsigned start, unsigned end);
00138         bool operator== (TextTag const& tag) const;
00139         TextTag *Duplicate () const;
00140         PangoWeight GetWeight () const {return m_Weight;}
00141 
00142 private:
00143         PangoWeight m_Weight;
00144 };
00145 
00146 class VariantTextTag: public TextTag
00147 {
00148 public:
00149         VariantTextTag (PangoVariant variant);
00150         virtual ~VariantTextTag ();
00151 
00152         void Filter (PangoAttrList *l, unsigned start, unsigned end);
00153         bool operator== (TextTag const& tag) const;
00154         TextTag *Duplicate () const;
00155         PangoVariant GetVariant () const {return m_Variant;}
00156 
00157 private:
00158         PangoVariant m_Variant;
00159 };
00160 
00161 class StretchTextTag: public TextTag
00162 {
00163 public:
00164         StretchTextTag (PangoStretch stretch);
00165         virtual ~StretchTextTag ();
00166 
00167         void Filter (PangoAttrList *l, unsigned start, unsigned end);
00168         bool operator== (TextTag const& tag) const;
00169         TextTag *Duplicate () const;
00170         PangoStretch GetStretch () const {return m_Stretch;}
00171 
00172 private:
00173         PangoStretch m_Stretch;
00174 };
00175 
00176 class UnderlineTextTag: public TextTag
00177 {
00178 public:
00179         UnderlineTextTag (PangoUnderline underline);
00180         virtual ~UnderlineTextTag ();
00181 
00182         void Filter (PangoAttrList *l, unsigned start, unsigned end);
00183         bool operator== (TextTag const& tag) const;
00184         TextTag *Duplicate () const;
00185         PangoUnderline GetUnderline () const {return m_Underline;}
00186 
00187 private:
00188         PangoUnderline m_Underline;
00189 };
00190 
00191 class StrikethroughTextTag: public TextTag
00192 {
00193 public:
00194         StrikethroughTextTag (bool strikethrough);
00195         virtual ~StrikethroughTextTag ();
00196 
00197         void Filter (PangoAttrList *l, unsigned start, unsigned end);
00198         bool operator== (TextTag const& tag) const;
00199         TextTag *Duplicate () const;
00200         bool GetStrikethrough () const {return m_Strikethrough;}
00201 
00202 private:
00203         bool m_Strikethrough;
00204 };
00205 
00206 class ForegroundTextTag: public TextTag
00207 {
00208 public:
00209         ForegroundTextTag (GOColor m_Color);
00210         virtual ~ForegroundTextTag ();
00211 
00212         void Filter (PangoAttrList *l, unsigned start, unsigned end);
00213         bool operator== (TextTag const& tag) const;
00214         TextTag *Duplicate () const;
00215         GOColor GetColor () const {return m_Color;}
00216 
00217 private:
00218         GOColor m_Color;
00219 };
00220 
00221 class BackgroundTextTag: public TextTag
00222 {
00223 public:
00224         BackgroundTextTag (GOColor m_Color);
00225         virtual ~BackgroundTextTag ();
00226 
00227         void Filter (PangoAttrList *l, unsigned start, unsigned end);
00228         bool operator== (TextTag const& tag) const;
00229         TextTag *Duplicate () const;
00230         GOColor GetColor () const {return m_Color;}
00231 
00232 private:
00233         GOColor m_Color;
00234 };
00235 
00236 class RiseTextTag: public TextTag
00237 {
00238 public:
00239         RiseTextTag (double size);
00240         virtual ~RiseTextTag ();
00241 
00242         void Filter (PangoAttrList *l, unsigned start, unsigned end);
00243         bool operator== (TextTag const& tag) const;
00244         TextTag *Duplicate () const;
00245         double GetRise () const {return m_Rise;}
00246 
00247 private:
00248         double m_Rise;
00249 };
00250 
00251 class PositionTextTag: public TextTag
00252 {
00253 public:
00254         PositionTextTag (TextPosition position, double size, bool stacked = false, Tag tag = Position);
00255         virtual ~PositionTextTag ();
00256 
00257         void Filter (PangoAttrList *l, unsigned start, unsigned end);
00258         bool operator== (TextTag const& tag) const;
00259         TextTag *Duplicate () const;
00260         TextPosition GetPosition (bool &stacked, double &size) const {stacked = m_Stacked; size = m_Size; return m_Position;}
00261         bool NeedsNewRun () {return m_Stacked;}
00262 
00263 private:
00264         TextPosition m_Position;
00265         double m_Size; // default size
00266 };
00267 
00268 class NewLineTextTag: public TextTag
00269 {
00270         NewLineTextTag (double interline);
00271         virtual ~NewLineTextTag ();
00272         
00273         void Filter (PangoAttrList *l, unsigned start, unsigned end);
00274         bool operator== (TextTag const& tag) const;
00275         TextTag *Duplicate () const;
00276 
00277         GCU_RO_PROP (double, Interline)
00278 };
00279 
00280 class TextTagList:public std::list <TextTag *>
00281 {
00282 public:
00283         TextTagList ();
00284         ~TextTagList ();
00285 };
00286 
00287 }   //  namespace gccv
00288 
00289 #endif  //      GCCV_TEXT_TAG_H

Generated on Thu Jun 25 13:24:20 2009 for The Gnome Chemistry Utils by  doxygen 1.5.9