00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
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
00039 typedef enum
00040 {
00044 Invalid,
00048 Family,
00052 Size,
00056 Style,
00060 Weight,
00064 Variant,
00068 Stretch,
00072 Underline,
00076 Overline,
00080 Strikethrough,
00084 Foreground,
00088 Background,
00092 Rise,
00096 Position,
00100 NewLine,
00104 MaxTag
00105 } Tag;
00106
00110 typedef enum
00111 {
00116 TagPriorityFirst,
00120 TagPriorityLast,
00121 } TagPriority;
00122
00128 class TextTag
00129 {
00130 public:
00137 TextTag (Tag tag, TagPriority priority = TagPriorityFirst);
00141 virtual ~TextTag ();
00142
00152 virtual void Filter (PangoAttrList *l, unsigned start, unsigned end) = 0;
00160 virtual bool operator== (TextTag const& tag) const = 0;
00166 virtual TextTag *Duplicate () const = 0;
00170 virtual bool NeedsNewRun () {return false;}
00178 virtual TextTag *Restrict (TextTag *tag);
00179
00185 static Tag RegisterTagType ();
00189 static Tag MaxTag;
00197 static bool Order (TextTag *first, TextTag *last);
00198
00202 GCU_RO_PROP (Tag, Tag)
00206 GCU_RO_PROP (TagPriority, Priority)
00218 GCU_PROP (unsigned, StartIndex)
00230 GCU_PROP (unsigned, EndIndex)
00238 GCU_PROT_PROP (bool, Stacked)
00245 GCU_PROT_PROP (bool, NewLine)
00246 };
00247
00253 class FamilyTextTag: public TextTag
00254 {
00255 public:
00261 FamilyTextTag (std::string const &family);
00267 FamilyTextTag (char const *family);
00271 virtual ~FamilyTextTag ();
00272
00280 void Filter (PangoAttrList *l, unsigned start, unsigned end);
00288 bool operator== (TextTag const& tag) const;
00293 TextTag *Duplicate () const;
00297 std::string const &GetFamily () const {return m_Family;}
00298
00299 private:
00300 std::string m_Family;
00301 };
00302
00308 class SizeTextTag: public TextTag
00309 {
00310 public:
00316 SizeTextTag (double size);
00320 virtual ~SizeTextTag ();
00321
00329 void Filter (PangoAttrList *l, unsigned start, unsigned end);
00337 bool operator== (TextTag const& tag) const;
00342 TextTag *Duplicate () const;
00346 double GetSize () const {return m_Size;}
00347
00348 private:
00349 double m_Size;
00350 };
00351
00352
00358 class StyleTextTag: public TextTag
00359 {
00360 public:
00366 StyleTextTag (PangoStyle style);
00370 virtual ~StyleTextTag ();
00371
00379 void Filter (PangoAttrList *l, unsigned start, unsigned end);
00387 bool operator== (TextTag const& tag) const;
00392 TextTag *Duplicate () const;
00396 PangoStyle GetStyle () const {return m_Style;}
00397
00398 private:
00399 PangoStyle m_Style;
00400 };
00401
00402
00408 class WeightTextTag: public TextTag
00409 {
00410 public:
00416 WeightTextTag (PangoWeight weight);
00420 virtual ~WeightTextTag ();
00421
00429 void Filter (PangoAttrList *l, unsigned start, unsigned end);
00437 bool operator== (TextTag const& tag) const;
00442 TextTag *Duplicate () const;
00446 PangoWeight GetWeight () const {return m_Weight;}
00447
00448 private:
00449 PangoWeight m_Weight;
00450 };
00451
00452
00458 class VariantTextTag: public TextTag
00459 {
00460 public:
00466 VariantTextTag (PangoVariant variant);
00470 virtual ~VariantTextTag ();
00471
00479 void Filter (PangoAttrList *l, unsigned start, unsigned end);
00487 bool operator== (TextTag const& tag) const;
00492 TextTag *Duplicate () const;
00496 PangoVariant GetVariant () const {return m_Variant;}
00497
00498 private:
00499 PangoVariant m_Variant;
00500 };
00501
00502
00508 class StretchTextTag: public TextTag
00509 {
00510 public:
00516 StretchTextTag (PangoStretch stretch);
00520 virtual ~StretchTextTag ();
00521
00529 void Filter (PangoAttrList *l, unsigned start, unsigned end);
00537 bool operator== (TextTag const& tag) const;
00542 TextTag *Duplicate () const;
00546 PangoStretch GetStretch () const {return m_Stretch;}
00547
00548 private:
00549 PangoStretch m_Stretch;
00550 };
00551
00552
00558 class UnderlineTextTag: public TextTag
00559 {
00560 public:
00568 UnderlineTextTag (TextDecoration underline, GOColor color = GO_COLOR_BLACK);
00572 virtual ~UnderlineTextTag ();
00573
00581 void Filter (PangoAttrList *l, unsigned start, unsigned end);
00589 bool operator== (TextTag const& tag) const;
00594 TextTag *Duplicate () const;
00598 TextDecoration GetUnderline () const {return m_Underline;}
00599
00600 private:
00601 TextDecoration m_Underline;
00602
00603 GCU_PROP (GOColor, Color)
00604 };
00605
00611 class OverlineTextTag: public TextTag
00612 {
00613 public:
00621 OverlineTextTag (TextDecoration overline, GOColor color = GO_COLOR_BLACK);
00625 virtual ~OverlineTextTag ();
00626
00634 void Filter (PangoAttrList *l, unsigned start, unsigned end);
00642 bool operator== (TextTag const& tag) const;
00647 TextTag *Duplicate () const;
00651 TextDecoration GetOverline () const {return m_Overline;}
00652
00653 private:
00654 TextDecoration m_Overline;
00655
00656 GCU_PROP (GOColor, Color)
00657 };
00658
00664 class StrikethroughTextTag: public TextTag
00665 {
00666 public:
00674 StrikethroughTextTag (TextDecoration strikethrough, GOColor color = GO_COLOR_BLACK);
00678 virtual ~StrikethroughTextTag ();
00679
00687 void Filter (PangoAttrList *l, unsigned start, unsigned end);
00695 bool operator== (TextTag const& tag) const;
00700 TextTag *Duplicate () const;
00704 TextDecoration GetStrikethrough () const {return m_Strikethrough;}
00705
00706 private:
00707 TextDecoration m_Strikethrough;
00708
00709 GCU_PROP (GOColor, Color)
00710 };
00711
00717 class ForegroundTextTag: public TextTag
00718 {
00719 public:
00725 ForegroundTextTag (GOColor color);
00729 virtual ~ForegroundTextTag ();
00730
00738 void Filter (PangoAttrList *l, unsigned start, unsigned end);
00746 bool operator== (TextTag const& tag) const;
00751 TextTag *Duplicate () const;
00755 GOColor GetColor () const {return m_Color;}
00756
00757 private:
00758 GOColor m_Color;
00759 };
00760
00766 class BackgroundTextTag: public TextTag
00767 {
00768 public:
00774 BackgroundTextTag (GOColor color);
00778 virtual ~BackgroundTextTag ();
00779
00787 void Filter (PangoAttrList *l, unsigned start, unsigned end);
00795 bool operator== (TextTag const& tag) const;
00800 TextTag *Duplicate () const;
00804 GOColor GetColor () const {return m_Color;}
00805
00806 private:
00807 GOColor m_Color;
00808 };
00809
00815 class RiseTextTag: public TextTag
00816 {
00817 public:
00824 RiseTextTag (double rise);
00828 virtual ~RiseTextTag ();
00829
00837 void Filter (PangoAttrList *l, unsigned start, unsigned end);
00845 bool operator== (TextTag const& tag) const;
00850 TextTag *Duplicate () const;
00854 double GetRise () const {return m_Rise;}
00855
00856 private:
00857 double m_Rise;
00858 };
00859
00866 class PositionTextTag: public TextTag
00867 {
00868 public:
00880 PositionTextTag (TextPosition position, double size, bool stacked = false, Tag tag = Position);
00884 virtual ~PositionTextTag ();
00885
00893 void Filter (PangoAttrList *l, unsigned start, unsigned end);
00901 bool operator== (TextTag const& tag) const;
00907 TextTag *Duplicate () const;
00914 TextPosition GetPosition (bool &stacked, double &size) const {stacked = m_Stacked; size = m_Size; return m_Position;}
00918 virtual bool NeedsNewRun () {return false;}
00925 TextTag *Restrict (G_GNUC_UNUSED TextTag *tag) {return NULL;}
00926
00927 private:
00928 TextPosition m_Position;
00929 double m_Size;
00930 };
00931
00937 class NewLineTextTag: public TextTag
00938 {
00939 public:
00943 NewLineTextTag ();
00947 virtual ~NewLineTextTag ();
00948
00956 void Filter (PangoAttrList *l, unsigned start, unsigned end);
00963 bool operator== (TextTag const& tag) const;
00968 TextTag *Duplicate () const;
00969 };
00970
00976 class TextTagList:public std::list <TextTag *>
00977 {
00978 public:
00982 TextTagList ();
00987 ~TextTagList ();
00988 };
00989
00990 }
00991
00992 #endif // GCCV_TEXT_TAG_H