1 // -*-c++-*- 2 3 // fixg2sxd - a utility to convert fig to sxd format 4 5 // Copyright (C) 2003-2010 Alexander Bürger, acfb@users.sourceforge.net 6 7 // This program is free software; you can redistribute it and/or 8 // modify it under the terms of the GNU General Public License as 9 // published by the Free Software Foundation; either version 2 of the 10 // License, or (at your option) any later version. 11 // 12 // This program is distributed in the hope that it will be useful, but 13 // WITHOUT ANY WARRANTY; without even the implied warranty of 14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 // General Public License for more details. 16 // 17 // You should have received a copy of the GNU General Public License 18 // along with this program; if not, write to the Free Software 19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 21 #ifndef STYLES_H 22 #define STYLES_H 23 24 #include "xmlwrite.h" 25 #include <set> 26 #include <string> 27 #include <iostream> 28 29 using namespace std; 30 31 class TextStyle { 32 public: 33 int color, font, font_flags; 34 float font_size; 35 // (0: Left justified 1: Center justified 2: Right justified) 36 int justification; 37 38 static string base; 39 40 static int number; 41 mutable int mynumber; 42 string stylenumber() const; 43 44 Node& write( Node& styles ) const; 45 bool operator<( TextStyle const& o ) const; TextStyle()46 TextStyle() : justification(0), mynumber(0) { } 47 void check(); 48 }; 49 50 typedef set<TextStyle> tsset; 51 extern tsset textstyles; 52 53 // ------------------------------------------------------------------------ 54 55 class Arrow { 56 public: 57 int arrow_type; 58 // 0 stick, 1 closed triangle, 2 closed with indented butt, 3 59 // closed with pointed butt 60 int arrow_style; // (0 hollow (white fill), 1 filled) 61 float arrow_width; // (Fig units) 62 63 bool operator<(Arrow const&) const; 64 istream& read( istream& ); 65 Node& write( Node& out ) const; 66 string name() const; 67 }; 68 69 typedef set<Arrow> arrowset; 70 extern arrowset arrows; 71 72 // ------------------------------------------------------------------------ 73 74 class LineFillStyle { 75 public: 76 int line_style; // (enumeration type) 77 float line_thickness; // (1/80 inch) 78 int pen_color; // (enumeration type, pen color) 79 int fill_color; // (enumeration type, fill color) 80 int pen_style; // (pen style, not used) 81 int area_fill; // (enumeration type, -1 = no fill) 82 float style_val; // (1/80 inch) 83 84 int linejoin; 85 86 arrowset::iterator forward_arrow, backward_arrow; 87 88 static string base; 89 90 void read( istream& figfile, int& sub_type, int& depth, bool join=false ); 91 void read_arrow( istream& figfile, bool forward ); 92 93 bool operator<(LineFillStyle const& o) const; 94 95 static int number; 96 97 std::string stylename() const; 98 std::string stylename_line() const; 99 std::string stylename_fill() const; 100 Node& write( Node& out ) const; 101 102 bool hasLine() const; 103 bool hasFill() const; 104 105 static float linewith1; 106 LineFillStyle()107 LineFillStyle() 108 : linejoin(-1), 109 forward_arrow(arrows.end()), backward_arrow(arrows.end()), 110 mynumber( 0 ), mynumber_line(0), mynumber_fill(0) 111 { } 112 113 private: 114 mutable int mynumber, mynumber_line, mynumber_fill; 115 }; 116 117 typedef std::set<LineFillStyle> lfsset; 118 extern lfsset linefillstyles; 119 120 #endif // STYLES_H 121