The Gnome Chemistry Utils  0.14.17
text-tag.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 
3 /*
4  * Gnome Chemistry Utils
5  * gccv/text-tag.h
6  *
7  * Copyright (C) 2008-2010 Jean Bréfort <jean.brefort@normalesup.org>
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License as
11  * published by the Free Software Foundation; either version 3 of the
12  * License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
22  * USA
23  */
24 
25 #ifndef GCCV_TEXT_TAG_H
26 #define GCCV_TEXT_TAG_H
27 
28 #include "structs.h"
29 #include <gcu/macros.h>
30 #include <list>
31 #include <string>
32 
34 namespace gccv {
35 
39 enum
40 {
105  };
106 
107 typedef int Tag;
108 
112 typedef enum
113 {
123 } TagPriority;
124 
130 class TextTag
131 {
132 public:
139  TextTag (Tag tag, TagPriority priority = TagPriorityFirst);
143  virtual ~TextTag ();
144 
154  virtual void Filter (PangoAttrList *l, unsigned start, unsigned end) = 0;
162  virtual bool operator== (TextTag const& tag) const = 0;
168  virtual TextTag *Duplicate () const = 0;
172  virtual bool NeedsNewRun () {return false;}
180  virtual TextTag *Restrict (TextTag *tag);
181 
187  static Tag RegisterTagType ();
191  static Tag MaxTag;
199  static bool Order (TextTag *first, TextTag *last);
200 
204 GCU_RO_PROP (Tag, Tag)
208 GCU_RO_PROP (TagPriority, Priority)
220 GCU_PROP (unsigned, StartIndex)
232 GCU_PROP (unsigned, EndIndex)
240 GCU_PROT_PROP (bool, Stacked)
248 };
249 
255 class FamilyTextTag: public TextTag
256 {
257 public:
263  FamilyTextTag (std::string const &family);
269  FamilyTextTag (char const *family);
273  virtual ~FamilyTextTag ();
274 
282  void Filter (PangoAttrList *l, unsigned start, unsigned end);
290  bool operator== (TextTag const& tag) const;
295  TextTag *Duplicate () const;
299  std::string const &GetFamily () const {return m_Family;}
300 
301 private:
302  std::string m_Family;
303 };
304 
310 class SizeTextTag: public TextTag
311 {
312 public:
318  SizeTextTag (double size);
322  virtual ~SizeTextTag ();
323 
331  void Filter (PangoAttrList *l, unsigned start, unsigned end);
339  bool operator== (TextTag const& tag) const;
344  TextTag *Duplicate () const;
348  double GetSize () const {return m_Size;}
349 
350 private:
351  double m_Size;
352 };
353 
354 
360 class StyleTextTag: public TextTag
361 {
362 public:
368  StyleTextTag (PangoStyle style);
372  virtual ~StyleTextTag ();
373 
381  void Filter (PangoAttrList *l, unsigned start, unsigned end);
389  bool operator== (TextTag const& tag) const;
394  TextTag *Duplicate () const;
398  PangoStyle GetStyle () const {return m_Style;}
399 
400 private:
401  PangoStyle m_Style;
402 };
403 
404 
410 class WeightTextTag: public TextTag
411 {
412 public:
418  WeightTextTag (PangoWeight weight);
422  virtual ~WeightTextTag ();
423 
431  void Filter (PangoAttrList *l, unsigned start, unsigned end);
439  bool operator== (TextTag const& tag) const;
444  TextTag *Duplicate () const;
448  PangoWeight GetWeight () const {return m_Weight;}
449 
450 private:
451  PangoWeight m_Weight;
452 };
453 
454 
460 class VariantTextTag: public TextTag
461 {
462 public:
468  VariantTextTag (PangoVariant variant);
472  virtual ~VariantTextTag ();
473 
481  void Filter (PangoAttrList *l, unsigned start, unsigned end);
489  bool operator== (TextTag const& tag) const;
494  TextTag *Duplicate () const;
498  PangoVariant GetVariant () const {return m_Variant;}
499 
500 private:
501  PangoVariant m_Variant;
502 };
503 
504 
510 class StretchTextTag: public TextTag
511 {
512 public:
518  StretchTextTag (PangoStretch stretch);
522  virtual ~StretchTextTag ();
523 
531  void Filter (PangoAttrList *l, unsigned start, unsigned end);
539  bool operator== (TextTag const& tag) const;
544  TextTag *Duplicate () const;
548  PangoStretch GetStretch () const {return m_Stretch;}
549 
550 private:
551  PangoStretch m_Stretch;
552 };
553 
554 
561 {
562 public:
570  UnderlineTextTag (TextDecoration underline, GOColor color = GO_COLOR_BLACK);
574  virtual ~UnderlineTextTag ();
575 
583  void Filter (PangoAttrList *l, unsigned start, unsigned end);
591  bool operator== (TextTag const& tag) const;
596  TextTag *Duplicate () const;
600  TextDecoration GetUnderline () const {return m_Underline;}
601 
602 private:
603  TextDecoration m_Underline;
604 
605 GCU_PROP (GOColor, Color)
606 };
607 
614 {
615 public:
623  OverlineTextTag (TextDecoration overline, GOColor color = GO_COLOR_BLACK);
627  virtual ~OverlineTextTag ();
628 
636  void Filter (PangoAttrList *l, unsigned start, unsigned end);
644  bool operator== (TextTag const& tag) const;
649  TextTag *Duplicate () const;
653  TextDecoration GetOverline () const {return m_Overline;}
654 
655 private:
656  TextDecoration m_Overline;
657 
658 GCU_PROP (GOColor, Color)
659 };
660 
667 {
668 public:
676  StrikethroughTextTag (TextDecoration strikethrough, GOColor color = GO_COLOR_BLACK);
680  virtual ~StrikethroughTextTag ();
681 
689  void Filter (PangoAttrList *l, unsigned start, unsigned end);
697  bool operator== (TextTag const& tag) const;
702  TextTag *Duplicate () const;
706  TextDecoration GetStrikethrough () const {return m_Strikethrough;}
707 
708 private:
709  TextDecoration m_Strikethrough;
710 
711 GCU_PROP (GOColor, Color)
712 };
713 
720 {
721 public:
727  ForegroundTextTag (GOColor color);
731  virtual ~ForegroundTextTag ();
732 
740  void Filter (PangoAttrList *l, unsigned start, unsigned end);
748  bool operator== (TextTag const& tag) const;
753  TextTag *Duplicate () const;
757  GOColor GetColor () const {return m_Color;}
758 
759 private:
760  GOColor m_Color;
761 };
762 
769 {
770 public:
776  BackgroundTextTag (GOColor color);
780  virtual ~BackgroundTextTag ();
781 
789  void Filter (PangoAttrList *l, unsigned start, unsigned end);
797  bool operator== (TextTag const& tag) const;
802  TextTag *Duplicate () const;
806  GOColor GetColor () const {return m_Color;}
807 
808 private:
809  GOColor m_Color;
810 };
811 
817 class RiseTextTag: public TextTag
818 {
819 public:
826  RiseTextTag (double rise);
830  virtual ~RiseTextTag ();
831 
839  void Filter (PangoAttrList *l, unsigned start, unsigned end);
847  bool operator== (TextTag const& tag) const;
852  TextTag *Duplicate () const;
856  double GetRise () const {return m_Rise;}
857 
858 private:
859  double m_Rise;
860 };
861 
869 {
870 public:
882  PositionTextTag (TextPosition position, double size, bool stacked = false, Tag tag = Position);
886  virtual ~PositionTextTag ();
887 
895  void Filter (PangoAttrList *l, unsigned start, unsigned end);
903  bool operator== (TextTag const& tag) const;
909  TextTag *Duplicate () const;
916  TextPosition GetPosition (bool &stacked, double &size) const {stacked = m_Stacked; size = m_Size; return m_Position;}
920  virtual bool NeedsNewRun () {return false;}
927  TextTag *Restrict (G_GNUC_UNUSED TextTag *tag) {return NULL;}
928 
929 private:
930  TextPosition m_Position;
931  double m_Size; // default size
932 };
933 
939 class NewLineTextTag: public TextTag
940 {
941 public:
945  NewLineTextTag ();
949  virtual ~NewLineTextTag ();
950 
958  void Filter (PangoAttrList *l, unsigned start, unsigned end);
965  bool operator== (TextTag const& tag) const;
970  TextTag *Duplicate () const;
971 };
972 
978 class TextTagList:public std::list <TextTag *>
979 {
980 public:
984  TextTagList ();
989  ~TextTagList ();
990 };
991 
992 } // namespace gccv
993 
994 #endif // GCCV_TEXT_TAG_H
static Tag MaxTag
Definition: text-tag.h:191
GOColor Color
virtual bool operator==(TextTag const &tag) const =0
PangoStretch GetStretch() const
Definition: text-tag.h:548
#define GCU_RO_PROP(type, member)
Definition: macros.h:117
Foreground color.
Definition: text-tag.h:719
virtual void Filter(PangoAttrList *l, unsigned start, unsigned end)=0
std::string const & GetFamily() const
Definition: text-tag.h:299
Strikethrough.
Definition: text-tag.h:666
PangoWeight GetWeight() const
Definition: text-tag.h:448
TextTag list.
Definition: text-tag.h:978
PangoVariant GetVariant() const
Definition: text-tag.h:498
Font size.
Definition: text-tag.h:310
virtual ~TextTag()
static bool Order(TextTag *first, TextTag *last)
PangoStyle GetStyle() const
Definition: text-tag.h:398
Font family.
Definition: text-tag.h:255
Font weight.
Definition: text-tag.h:410
static Tag RegisterTagType()
Gnome Chemistry Canvas library namespace.
#define GCU_PROT_PROP(type, member)
Definition: macros.h:174
TextDecoration GetUnderline() const
Definition: text-tag.h:600
double GetSize() const
Definition: text-tag.h:348
TextTag * Restrict(G_GNUC_UNUSED TextTag *tag)
Definition: text-tag.h:927
TextDecoration GetOverline() const
Definition: text-tag.h:653
Font stretch.
Definition: text-tag.h:510
virtual TextTag * Duplicate() const =0
TagPriority
Definition: text-tag.h:112
Font style.
Definition: text-tag.h:360
virtual TextTag * Restrict(TextTag *tag)
GOColor GetColor() const
Definition: text-tag.h:757
double GetRise() const
Definition: text-tag.h:856
class for text attributes
Definition: text-tag.h:130
TextDecoration
Definition: gccv/structs.h:116
#define GCU_PROP(type, member)
Definition: macros.h:50
TextPosition
Definition: gccv/structs.h:104
GOColor GetColor() const
Definition: text-tag.h:806
Background color.
Definition: text-tag.h:768
TextDecoration GetStrikethrough() const
Definition: text-tag.h:706
bool m_Stacked
Definition: text-tag.h:240
TextPosition GetPosition(bool &stacked, double &size) const
Definition: text-tag.h:916
virtual bool NeedsNewRun()
Definition: text-tag.h:172
virtual bool NeedsNewRun()
Definition: text-tag.h:920
Font variant.
Definition: text-tag.h:460
TextTag(Tag tag, TagPriority priority=TagPriorityFirst)