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

« back to all changes in this revision

Viewing changes to src/ipelib/ipestdstyles.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Steve M. Robbins
  • Date: 2004-06-08 00:44:02 UTC
  • Revision ID: james.westby@ubuntu.com-20040608004402-72yu51xlh7vt6p9m
Tags: upstream-6.0pre16
ImportĀ upstreamĀ versionĀ 6.0pre16

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// --------------------------------------------------------------------
 
2
// Standard Ipe styles (embedded in Ipelib)
 
3
// --------------------------------------------------------------------
 
4
/*
 
5
 
 
6
    This file is part of the extensible drawing editor Ipe.
 
7
    Copyright (C) 1993-2004  Otfried Cheong
 
8
 
 
9
    Ipe is free software; you can redistribute it and/or modify it
 
10
    under the terms of the GNU General Public License as published by
 
11
    the Free Software Foundation; either version 2 of the License, or
 
12
    (at your option) any later version.
 
13
 
 
14
    As a special exception, you have permission to link Ipe with the
 
15
    CGAL library and distribute executables, as long as you follow the
 
16
    requirements of the Gnu General Public License in regard to all of
 
17
    the software in the executable aside from CGAL.
 
18
 
 
19
    Ipe is distributed in the hope that it will be useful, but WITHOUT
 
20
    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 
21
    or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
 
22
    License for more details.
 
23
 
 
24
    You should have received a copy of the GNU General Public License
 
25
    along with Ipe; if not, you can find it at
 
26
    "http://www.gnu.org/copyleft/gpl.html", or write to the Free
 
27
    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
28
 
 
29
*/
 
30
 
 
31
#include "ipebase.h"
 
32
#include "ipestyle.h"
 
33
#include "ipeiml.h"
 
34
 
 
35
const char *StyleStandard[] = {
 
36
  "<ipestyle>",
 
37
  "<color name=\"red\" value=\"1 0 0\"/>",
 
38
  "<color name=\"green\" value=\"0 1 0\"/>",
 
39
  "<color name=\"blue\" value=\"0 0 1\"/>",
 
40
  "<color name=\"yellow\" value=\"1 1 0\"/>",
 
41
  "<color name=\"gray1\" value=\"0.125\"/>",
 
42
  "<color name=\"gray2\" value=\"0.25\"/>",
 
43
  "<color name=\"gray3\" value=\"0.375\"/>",
 
44
  "<color name=\"gray4\" value=\"0.5\"/>",
 
45
  "<color name=\"gray5\" value=\"0.625\"/>",
 
46
  "<color name=\"gray6\" value=\"0.75\"/>",
 
47
  "<color name=\"gray7\" value=\"0.875\"/>",
 
48
  "<dashstyle name=\"dashed\" value=\"[4] 0\"/>",
 
49
  "<dashstyle name=\"dotted\" value=\"[1 3] 0\"/>",
 
50
  "<dashstyle name=\"dash dotted\" value=\"[4 2 1 2] 0\"/>",
 
51
  "<dashstyle name=\"dash dot dotted\" value=\"[4 2 1 2 1 2] 0\"/>",
 
52
  "<linewidth name=\"normal\" value=\"0.4\"/>",
 
53
  "<linewidth name=\"heavier\" value=\"0.8\"/>",
 
54
  "<linewidth name=\"fat\" value=\"1.2\"/>",
 
55
  "<linewidth name=\"ultrafat\" value=\"2\"/>",
 
56
  "<textsize name=\"normal\" value=\"\\normalsize\"/>",
 
57
  "<textsize name=\"large\" value=\"\\large\"/>",
 
58
  "<textsize name=\"Large\" value=\"\\Large\"/>",
 
59
  "<textsize name=\"LARGE\" value=\"\\LARGE\"/>",
 
60
  "<textsize name=\"huge\" value=\"\\huge\"/>",
 
61
  "<textsize name=\"Huge\" value=\"\\Huge\"/>",
 
62
  "<textsize name=\"small\" value=\"\\small\"/>",
 
63
  "<textsize name=\"footnote\" value=\"\\footnotesize\"/>",
 
64
  "<textsize name=\"tiny\" value=\"\\tiny\"/>",
 
65
  "<marksize name=\"normal\" value=\"3\"/>",
 
66
  "<marksize name=\"small\" value=\"2\"/>",
 
67
  "<marksize name=\"tiny\" value=\"1.1\"/>",
 
68
  "<marksize name=\"large\" value=\"5\"/>",
 
69
  "<arrowsize name=\"normal\" value=\"7\"/>",
 
70
  "<arrowsize name=\"small\" value=\"5\"/>",
 
71
  "<arrowsize name=\"tiny\" value=\"3\"/>",
 
72
  "<arrowsize name=\"large\" value=\"10\"/>",
 
73
  "<grid name=\"4 pts\" value=\"4\"/>",
 
74
  "<grid name=\"8 pts\" value=\"8\"/>",
 
75
  "<grid name=\"16 pts\" value=\"16\"/>",
 
76
  "<grid name=\"32 pts\" value=\"32\"/>",
 
77
  "<grid name=\"5 mm\" value=\"14.17\"/>",
 
78
  "<grid name=\"10 mm\" value=\"28.34\"/>",
 
79
  "<grid name=\"20 mm\" value=\"46.68\"/>",
 
80
  "<angle name=\"90\" value=\"90\"/>",
 
81
  "<angle name=\"60\" value=\"60\"/>",
 
82
  "<angle name=\"45\" value=\"45\"/>",
 
83
  "<angle name=\"30\" value=\"30\"/>",
 
84
  "<angle name=\"22.5\" value=\"22.5\"/>",
 
85
  "<media name=\"A4\" value=\"595 842\"/>",
 
86
  "<media name=\"A4R\" value=\"842 595\"/>",
 
87
  "<media name=\"Letter\" value=\"612 792\"/>",
 
88
  "<media name=\"800 x 600\" value=\"800 600\"/>",
 
89
  "<media name=\"1024 x 768\" value=\"1024 768\"/>",
 
90
  "<media name=\"1280 x 1024\" value=\"1280 1024\"/>",
 
91
  "<margins tl=\"36 36\" br=\"36 36\"/>",
 
92
  "</ipestyle>",
 
93
  0 };
 
94
 
 
95
class IpeStandardStyleSource : public IpeXmlDataSource {
 
96
public:
 
97
  IpeStandardStyleSource(const char **lines)
 
98
    : iLine(lines), iChar(lines[0]) { /* nothing */ }
 
99
  int GetChar();
 
100
private:
 
101
  const char **iLine;
 
102
  const char *iChar;
 
103
};
 
104
 
 
105
int IpeStandardStyleSource::GetChar()
 
106
{
 
107
  if (!*iLine)
 
108
    return EOF;
 
109
  // not yet at end of data
 
110
  if (!*iChar) {
 
111
    iLine++;
 
112
    iChar = *iLine;
 
113
    return '\n'; // important: iChar may be 0 now!
 
114
  }
 
115
  return *iChar++;
 
116
}
 
117
 
 
118
//! Create standard built-in style sheet.
 
119
IpeStyleSheet *IpeStyleSheet::Standard(IpeRepository *rep)
 
120
{
 
121
  IpeStandardStyleSource source(StyleStandard);
 
122
  IpeImlParser parser(source, rep);
 
123
  IpeStyleSheet *sheet = parser.ParseStyleSheet();
 
124
  assert(sheet);
 
125
  sheet->iStandard = true;
 
126
  sheet->iName = "standard";
 
127
  sheet->iRepository = rep;
 
128
  return sheet;
 
129
}
 
130
 
 
131
// --------------------------------------------------------------------