~ubuntu-branches/ubuntu/precise/ipe/precise

« back to all changes in this revision

Viewing changes to src/include/ipestyle.h

  • Committer: Bazaar Package Importer
  • Author(s): Steve M. Robbins
  • Date: 2009-12-11 21:22:35 UTC
  • mfrom: (4.1.6 sid)
  • Revision ID: james.westby@ubuntu.com-20091211212235-5iio4nzpra64snab
Tags: 7.0.10-1
* New upstream.  Closes: #551192.
  - New build-depends: libcairo2-dev, liblua5.1-0-dev, gsfonts
  - patches/config.diff: Remove.  Upstream build system replaced.
  - Runtime lib package changed to libipe7.0.10 from libipe1c2a
  - Devel package renamed to libipe-dev (from libipe1-dev)
  - Package ipe depends on lua5.1 due to ipe-update-master.

* rules: Re-write to use dh.

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
/*
6
6
 
7
7
    This file is part of the extensible drawing editor Ipe.
8
 
    Copyright (C) 1993-2007  Otfried Cheong
 
8
    Copyright (C) 1993-2009  Otfried Cheong
9
9
 
10
10
    Ipe is free software; you can redistribute it and/or modify it
11
11
    under the terms of the GNU General Public License as published by
12
 
    the Free Software Foundation; either version 2 of the License, or
 
12
    the Free Software Foundation; either version 3 of the License, or
13
13
    (at your option) any later version.
14
14
 
15
15
    As a special exception, you have permission to link Ipe with the
32
32
#ifndef IPESTYLE_H
33
33
#define IPESTYLE_H
34
34
 
35
 
#include "ipebase.h"
36
 
#include "ipecolor.h"
 
35
#include "ipeattributes.h"
37
36
#include "ipetext.h"
38
37
 
39
38
// --------------------------------------------------------------------
40
39
 
41
 
class IPE_EXPORT IpeStyleSheet {
42
 
 public:
43
 
 
44
 
  //! Style of the title on a page.
45
 
  struct STitleStyle {
46
 
    //! Is this style undefined (null)?
47
 
    bool isNull() const { return iSize.IsNull(); }
48
 
    //! Position on the page (in Ipe coordinate system)
49
 
    IpeVector iPos;
50
 
    //! Text size.
51
 
    IpeAttribute iSize;
52
 
    //! Text color.
53
 
    IpeAttribute iColor;
54
 
    //! Horizontal alignment.
55
 
    IpeText::THorizontalAlignment iHorizontalAlignment;
56
 
    //! Vertical alignment.
57
 
    IpeText::TVerticalAlignment iVerticalAlignment;
58
 
  };
59
 
 
60
 
  IpeStyleSheet(IpeRepository *rep);
61
 
  ~IpeStyleSheet();
62
 
 
63
 
  static IpeStyleSheet *Standard(IpeRepository *rep);
64
 
 
65
 
  void AddTemplate(IpeAttribute name, const IpeObject *obj);
66
 
  const IpeObject *FindTemplate(IpeAttribute sym) const;
67
 
 
68
 
  void Add(IpeAttribute name, IpeAttribute value);
69
 
  IpeAttribute Find(IpeAttribute sym) const;
70
 
 
71
 
  void SaveAsXml(IpeStream &stream, bool saveBitmaps = false) const;
72
 
  void SaveCascadeAsXml(IpeStream &stream) const;
73
 
 
74
 
  void AllNames(IpeKind kind, IpeAttributeSeq &seq) const;
75
 
  void AllNames(IpeAttributeSeq *attr) const;
76
 
 
77
 
  //! Return whether this is the standard style sheet built into Ipe.
78
 
  inline bool IsStandard() const { return iStandard; }
79
 
 
80
 
  //! Return preamble of this style sheet (not including the cascade).
81
 
  inline IpeString Preamble() const { return iPreamble; }
82
 
  IpeString TotalPreamble() const;
83
 
  //! Set LaTeX preamble.
84
 
  inline void SetPreamble(const IpeString &str) { iPreamble = str; }
85
 
 
86
 
  void setLayout(const IpeLayout &margins);
87
 
  IpeLayout findLayout() const;
88
 
 
89
 
  void setTitleStyle(const STitleStyle &ts);
90
 
  STitleStyle findTitleStyle() const;
91
 
 
92
 
  void SetShading(const IpeShading &s);
93
 
  IpeShading FindShading() const;
94
 
 
95
 
  void AddCMap(IpeString s);
96
 
  void AllCMaps(std::vector<IpeString> &seq) const;
97
 
 
98
 
  void SetStrokeStyle(IpeStrokeStyle s);
99
 
  IpeAttribute LineCap() const;
100
 
  IpeAttribute LineJoin() const;
101
 
  IpeAttribute WindRule() const;
102
 
 
103
 
  inline const IpeStyleSheet *Cascade() const;
104
 
  inline IpeStyleSheet *Cascade();
105
 
 
106
 
  void SetCascade(IpeStyleSheet *sheet);
107
 
 
108
 
  //! Return name of style sheet.
109
 
  inline IpeString Name() const { return iName; }
110
 
  //! Set name of style sheet.
111
 
  inline void SetName(const IpeString &name) { iName = name; }
112
 
 
113
 
  //! Return attribute repository.
114
 
  inline IpeRepository *Repository() { return iRepository; }
115
 
  //! Return attribute repository (const version).
116
 
  inline const IpeRepository *Repository() const { return iRepository; }
117
 
 
118
 
private:
119
 
  IpeStyleSheet(const IpeStyleSheet &rhs);
120
 
  IpeStyleSheet &operator=(const IpeStyleSheet &rhs);
121
 
 private:
122
 
  typedef std::map<int, const IpeObject *> TemplateMap;
123
 
  typedef std::map<int, IpeAttribute> Map;
124
 
 
125
 
  bool iStandard;
126
 
  IpeString iName;
127
 
  IpeStyleSheet *iCascade;
128
 
  TemplateMap iTemplates;
129
 
  Map iMap;
130
 
  IpeString iPreamble;
131
 
  IpeLayout iLayout;
132
 
  STitleStyle iTitleStyle;
133
 
  IpeRepository *iRepository;
134
 
 
135
 
  IpeShading iShading;
136
 
  IpeStrokeStyle iStrokeStyle;
137
 
 
138
 
  std::vector<IpeString> iCMaps;
139
 
};
140
 
 
141
 
// --------------------------------------------------------------------
142
 
 
143
 
//! Return next sheet in cascade (const version).
144
 
inline const IpeStyleSheet *IpeStyleSheet::Cascade() const
145
 
{
146
 
  return iCascade;
147
 
}
148
 
 
149
 
//! Return the next level style sheet.
150
 
inline IpeStyleSheet *IpeStyleSheet::Cascade()
151
 
{
152
 
  return iCascade;
153
 
}
 
40
namespace ipe {
 
41
 
 
42
  struct Symbol {
 
43
    Symbol();
 
44
    Symbol(Object *object);
 
45
    Symbol(const Symbol &rhs);
 
46
    Symbol &operator=(const Symbol &rhs);
 
47
    ~Symbol();
 
48
 
 
49
    bool iXForm;
 
50
    TTransformations iTransformations;
 
51
    Object *iObject;
 
52
  };
 
53
 
 
54
  class StyleSheet {
 
55
  public:
 
56
 
 
57
    //! Style of the title on a page.
 
58
    struct TitleStyle {
 
59
      //! Has a TitleStyle been defined in the style sheet?
 
60
      bool iDefined;
 
61
      //! Position on the page (in Ipe coordinate system)
 
62
      Vector iPos;
 
63
      //! Text size.
 
64
      Attribute iSize;
 
65
      //! Text color.
 
66
      Attribute iColor;
 
67
      //! Horizontal alignment.
 
68
      THorizontalAlignment iHorizontalAlignment;
 
69
      //! Vertical alignment.
 
70
      TVerticalAlignment iVerticalAlignment;
 
71
    };
 
72
 
 
73
    //! How to show page numbers on the paper.
 
74
    struct PageNumberStyle {
 
75
      //! Has a PageNumberStyle been defined in the style sheet?
 
76
      bool iDefined;
 
77
      //! Position on the page
 
78
      Vector iPos;
 
79
      //! Font size.
 
80
      double iFontSize;
 
81
      //! Text color.
 
82
      Color iColor;
 
83
    };
 
84
 
 
85
    StyleSheet();
 
86
 
 
87
    static StyleSheet *standard();
 
88
 
 
89
    void addSymbol(Attribute name, const Symbol &symbol);
 
90
    const Symbol *findSymbol(Attribute sym) const;
 
91
 
 
92
    void addGradient(Attribute name, const Gradient &s);
 
93
    const Gradient *findGradient(Attribute sym) const;
 
94
 
 
95
    void addTiling(Attribute name, const Tiling &s);
 
96
    const Tiling *findTiling(Attribute sym) const;
 
97
 
 
98
    void addEffect(Attribute name, const Effect &e);
 
99
    const Effect *findEffect(Attribute sym) const;
 
100
 
 
101
    void add(Kind kind, Attribute name, Attribute value);
 
102
    bool has(Kind kind, Attribute sym) const;
 
103
    Attribute find(Kind, Attribute sym) const;
 
104
 
 
105
    void saveAsXml(Stream &stream, bool saveBitmaps = false) const;
 
106
 
 
107
    void allNames(Kind kind, AttributeSeq &seq) const;
 
108
 
 
109
    //! Return whether this is the standard style sheet built into Ipe.
 
110
    inline bool isStandard() const { return iStandard; }
 
111
 
 
112
    //! Return Latex preamble.
 
113
    inline String preamble() const { return iPreamble; }
 
114
    //! Set LaTeX preamble.
 
115
    inline void setPreamble(const String &str) { iPreamble = str; }
 
116
 
 
117
    const Layout *layout() const;
 
118
    void setLayout(const Layout &margins);
 
119
 
 
120
    const TitleStyle *titleStyle() const;
 
121
    void setTitleStyle(const TitleStyle &ts);
 
122
 
 
123
    const PageNumberStyle *pageNumberStyle();
 
124
    void setPageNumberStyle(const PageNumberStyle &pns);
 
125
 
 
126
    void addCMap(String s);
 
127
    void allCMaps(std::vector<String> &seq) const;
 
128
 
 
129
    void setLineCap(TLineCap s);
 
130
    void setLineJoin(TLineJoin s);
 
131
    void setFillRule(TFillRule s);
 
132
    //! Return line cap.
 
133
    TLineCap lineCap() const { return iLineCap; }
 
134
    //! Return line join.
 
135
    TLineJoin lineJoin() const { return iLineJoin; }
 
136
    //! Return path fill rule.
 
137
    TFillRule fillRule() const { return iFillRule; }
 
138
 
 
139
    //! Return name of style sheet.
 
140
    inline String name() const { return iName; }
 
141
    //! Set name of style sheet.
 
142
    inline void setName(const String &name) { iName = name; }
 
143
 
 
144
  private:
 
145
    typedef std::map<int, Symbol> SymbolMap;
 
146
    typedef std::map<int, Gradient> GradientMap;
 
147
    typedef std::map<int, Tiling> TilingMap;
 
148
    typedef std::map<int, Effect> EffectMap;
 
149
    typedef std::map<int, Attribute> Map;
 
150
 
 
151
    bool iStandard;
 
152
    String iName;
 
153
    SymbolMap iSymbols;
 
154
    GradientMap iGradients;
 
155
    TilingMap iTilings;
 
156
    EffectMap iEffects;
 
157
    Map iMap;
 
158
    String iPreamble;
 
159
    Layout iLayout;
 
160
    TitleStyle iTitleStyle;
 
161
    PageNumberStyle iPageNumberStyle;
 
162
 
 
163
    TLineJoin iLineJoin;
 
164
    TLineCap iLineCap;
 
165
    TFillRule iFillRule;
 
166
 
 
167
    std::vector<String> iCMaps;
 
168
  };
 
169
 
 
170
 
 
171
  class Cascade {
 
172
  public:
 
173
    Cascade();
 
174
    Cascade(const Cascade &rhs);
 
175
    Cascade &operator=(const Cascade &rhs);
 
176
    ~Cascade();
 
177
 
 
178
    //! Return number of style sheets.
 
179
    inline int count() const { return iSheets.size(); }
 
180
    //! Return StyleSheet at \a index.
 
181
    inline StyleSheet *sheet(int index) { return iSheets[index]; }
 
182
 
 
183
    void insert(int index, StyleSheet *sheet);
 
184
    void remove(int index);
 
185
 
 
186
    void saveAsXml(Stream &stream) const;
 
187
 
 
188
    bool has(Kind kind, Attribute sym) const;
 
189
    Attribute find(Kind, Attribute sym) const;
 
190
    const Symbol *findSymbol(Attribute sym) const;
 
191
    const Gradient *findGradient(Attribute sym) const;
 
192
    const Tiling *findTiling(Attribute sym) const;
 
193
    const Effect *findEffect(Attribute sym) const;
 
194
    const Layout *findLayout() const;
 
195
    const StyleSheet::TitleStyle *findTitleStyle() const;
 
196
    const StyleSheet::PageNumberStyle *findPageNumberStyle() const;
 
197
    String findPreamble() const;
 
198
 
 
199
    TLineCap lineCap() const;
 
200
    TLineJoin lineJoin() const;
 
201
    TFillRule fillRule() const;
 
202
 
 
203
    void allNames(Kind kind, AttributeSeq &seq) const;
 
204
    int findDefinition(Kind kind, Attribute sym) const;
 
205
    void allCMaps(std::vector<String> &seq) const;
 
206
 
 
207
    String update(String dir);
 
208
 
 
209
  private:
 
210
    std::vector<StyleSheet *> iSheets;
 
211
  };
 
212
 
 
213
} // namespace
154
214
 
155
215
// --------------------------------------------------------------------
156
216
#endif