The Gnome Chemistry Utils  0.14.0
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 typedef enum
40 {
105 } Tag;
106 
110 typedef enum
111 {
121 } TagPriority;
122 
128 class TextTag
129 {
130 public:
137  TextTag (Tag tag, TagPriority priority = TagPriorityFirst);
141  virtual ~TextTag ();
142 
152  virtual void Filter (PangoAttrList *l, unsigned start, unsigned end) = 0;
160  virtual bool operator== (TextTag const& tag) const = 0;
166  virtual TextTag *Duplicate () const = 0;
170  virtual bool NeedsNewRun () {return false;}
178  virtual TextTag *Restrict (TextTag *tag);
179 
185  static Tag RegisterTagType ();
189  static Tag MaxTag;
197  static bool Order (TextTag *first, TextTag *last);
198 
218 GCU_PROP (unsigned, StartIndex)
230 GCU_PROP (unsigned, EndIndex)
238 GCU_PROT_PROP (bool, Stacked)
246 };
247 
253 class FamilyTextTag: public TextTag
254 {
255 public:
261  FamilyTextTag (std::string const &family);
267  FamilyTextTag (char const *family);
271  virtual ~FamilyTextTag ();
272 
280  void Filter (PangoAttrList *l, unsigned start, unsigned end);
288  bool operator== (TextTag const& tag) const;
293  TextTag *Duplicate () const;
297  std::string const &GetFamily () const {return m_Family;}
298 
299 private:
300  std::string m_Family;
301 };
302 
308 class SizeTextTag: public TextTag
309 {
310 public:
316  SizeTextTag (double size);
320  virtual ~SizeTextTag ();
321 
329  void Filter (PangoAttrList *l, unsigned start, unsigned end);
337  bool operator== (TextTag const& tag) const;
342  TextTag *Duplicate () const;
346  double GetSize () const {return m_Size;}
347 
348 private:
349  double m_Size;
350 };
351 
352 
358 class StyleTextTag: public TextTag
359 {
360 public:
366  StyleTextTag (PangoStyle style);
370  virtual ~StyleTextTag ();
371 
379  void Filter (PangoAttrList *l, unsigned start, unsigned end);
387  bool operator== (TextTag const& tag) const;
392  TextTag *Duplicate () const;
396  PangoStyle GetStyle () const {return m_Style;}
397 
398 private:
399  PangoStyle m_Style;
400 };
401 
402 
408 class WeightTextTag: public TextTag
409 {
410 public:
416  WeightTextTag (PangoWeight weight);
420  virtual ~WeightTextTag ();
421 
429  void Filter (PangoAttrList *l, unsigned start, unsigned end);
437  bool operator== (TextTag const& tag) const;
442  TextTag *Duplicate () const;
446  PangoWeight GetWeight () const {return m_Weight;}
447 
448 private:
449  PangoWeight m_Weight;
450 };
451 
452 
458 class VariantTextTag: public TextTag
459 {
460 public:
466  VariantTextTag (PangoVariant variant);
470  virtual ~VariantTextTag ();
471 
479  void Filter (PangoAttrList *l, unsigned start, unsigned end);
487  bool operator== (TextTag const& tag) const;
492  TextTag *Duplicate () const;
496  PangoVariant GetVariant () const {return m_Variant;}
497 
498 private:
499  PangoVariant m_Variant;
500 };
501 
502 
508 class StretchTextTag: public TextTag
509 {
510 public:
516  StretchTextTag (PangoStretch stretch);
520  virtual ~StretchTextTag ();
521 
529  void Filter (PangoAttrList *l, unsigned start, unsigned end);
537  bool operator== (TextTag const& tag) const;
542  TextTag *Duplicate () const;
546  PangoStretch GetStretch () const {return m_Stretch;}
547 
548 private:
549  PangoStretch m_Stretch;
550 };
551 
552 
559 {
560 public:
568  UnderlineTextTag (TextDecoration underline, GOColor color = GO_COLOR_BLACK);
572  virtual ~UnderlineTextTag ();
573 
581  void Filter (PangoAttrList *l, unsigned start, unsigned end);
589  bool operator== (TextTag const& tag) const;
594  TextTag *Duplicate () const;
598  TextDecoration GetUnderline () const {return m_Underline;}
599 
600 private:
601  TextDecoration m_Underline;
602 
603 GCU_PROP (GOColor, Color)
604 };
605 
612 {
613 public:
621  OverlineTextTag (TextDecoration overline, GOColor color = GO_COLOR_BLACK);
625  virtual ~OverlineTextTag ();
626 
634  void Filter (PangoAttrList *l, unsigned start, unsigned end);
642  bool operator== (TextTag const& tag) const;
647  TextTag *Duplicate () const;
651  TextDecoration GetOverline () const {return m_Overline;}
652 
653 private:
654  TextDecoration m_Overline;
655 
656 GCU_PROP (GOColor, Color)
657 };
658 
665 {
666 public:
674  StrikethroughTextTag (TextDecoration strikethrough, GOColor color = GO_COLOR_BLACK);
678  virtual ~StrikethroughTextTag ();
679 
687  void Filter (PangoAttrList *l, unsigned start, unsigned end);
695  bool operator== (TextTag const& tag) const;
700  TextTag *Duplicate () const;
704  TextDecoration GetStrikethrough () const {return m_Strikethrough;}
705 
706 private:
707  TextDecoration m_Strikethrough;
708 
709 GCU_PROP (GOColor, Color)
710 };
711 
718 {
719 public:
725  ForegroundTextTag (GOColor color);
729  virtual ~ForegroundTextTag ();
730 
738  void Filter (PangoAttrList *l, unsigned start, unsigned end);
746  bool operator== (TextTag const& tag) const;
751  TextTag *Duplicate () const;
755  GOColor GetColor () const {return m_Color;}
756 
757 private:
758  GOColor m_Color;
759 };
760 
767 {
768 public:
774  BackgroundTextTag (GOColor color);
778  virtual ~BackgroundTextTag ();
779 
787  void Filter (PangoAttrList *l, unsigned start, unsigned end);
795  bool operator== (TextTag const& tag) const;
800  TextTag *Duplicate () const;
804  GOColor GetColor () const {return m_Color;}
805 
806 private:
807  GOColor m_Color;
808 };
809 
815 class RiseTextTag: public TextTag
816 {
817 public:
824  RiseTextTag (double rise);
828  virtual ~RiseTextTag ();
829 
837  void Filter (PangoAttrList *l, unsigned start, unsigned end);
845  bool operator== (TextTag const& tag) const;
850  TextTag *Duplicate () const;
854  double GetRise () const {return m_Rise;}
855 
856 private:
857  double m_Rise;
858 };
859 
867 {
868 public:
880  PositionTextTag (TextPosition position, double size, bool stacked = false, Tag tag = Position);
884  virtual ~PositionTextTag ();
885 
893  void Filter (PangoAttrList *l, unsigned start, unsigned end);
901  bool operator== (TextTag const& tag) const;
907  TextTag *Duplicate () const;
914  TextPosition GetPosition (bool &stacked, double &size) const {stacked = m_Stacked; size = m_Size; return m_Position;}
918  virtual bool NeedsNewRun () {return false;}
925  TextTag *Restrict (G_GNUC_UNUSED TextTag *tag) {return NULL;}
926 
927 private:
928  TextPosition m_Position;
929  double m_Size; // default size
930 };
931 
937 class NewLineTextTag: public TextTag
938 {
939 public:
943  NewLineTextTag ();
947  virtual ~NewLineTextTag ();
948 
956  void Filter (PangoAttrList *l, unsigned start, unsigned end);
963  bool operator== (TextTag const& tag) const;
968  TextTag *Duplicate () const;
969 };
970 
976 class TextTagList:public std::list <TextTag *>
977 {
978 public:
982  TextTagList ();
987  ~TextTagList ();
988 };
989 
990 } // namespace gccv
991 
992 #endif // GCCV_TEXT_TAG_H