LASi.h | LASi.h | |||
---|---|---|---|---|
skipping to change at line 19 | skipping to change at line 19 | |||
#include <string> | #include <string> | |||
#include <ostream> | #include <ostream> | |||
#include <sstream> | #include <sstream> | |||
#include <map> | #include <map> | |||
#include <pango/pango.h> | #include <pango/pango.h> | |||
#include <freetype/ftglyph.h> | #include <freetype/ftglyph.h> | |||
class FreetypeGlyphMgr; | class FreetypeGlyphMgr; | |||
class ContextMgr; | class ContextMgr; | |||
// These macros are needed for Visual C++ and other Windows compilers. | ||||
// All functions/classes marked with LASIDLLIMPEXP can be imported form/exp | ||||
orted to the dll. | ||||
// Has no impact on other platforms | ||||
#if defined(WIN32) | ||||
/* Visual C/C++, Borland, MinGW and Watcom */ | ||||
#if defined(__VISUALC__) || defined(_MSC_VER) || defined(__BORLANDC__) || | ||||
defined(__GNUC__) || defined(__WATCOMC__) || defined(__CYGWIN__) | ||||
#define LASIDLLEXPORT __declspec(dllexport) | ||||
#define LASIDLLIMPORT __declspec(dllimport) | ||||
#else | ||||
#define LASIDLLEXPORT | ||||
#define LASIDLLIMPORT | ||||
#endif | ||||
#else | ||||
#define LASIDLLEXPORT | ||||
#define LASIDLLIMPORT | ||||
#endif | ||||
#if defined(LASi_EXPORTS) | ||||
#define LASIDLLIMPEXP LASIDLLEXPORT | ||||
#define LASIDLLIMPEXP_DATA(type) LASIDLLEXPORT type | ||||
#elif defined(LASi_DLL) | ||||
#define LASIDLLIMPEXP LASIDLLIMPORT | ||||
#define LASIDLLIMPEXP_DATA(type) LASIDLLIMPORT type | ||||
#else | ||||
#define LASIDLLIMPEXP | ||||
#define LASIDLLIMPEXP_DATA(type) type | ||||
#endif | ||||
namespace LASi { | namespace LASi { | |||
enum FontStyle{ | enum FontStyle{ | |||
NORMAL_STYLE, | NORMAL_STYLE, | |||
OBLIQUE, | OBLIQUE, | |||
ITALIC | ITALIC | |||
}; | }; | |||
enum FontWeight{ | enum FontWeight{ | |||
ULTRALIGHT, | ULTRALIGHT, | |||
skipping to change at line 59 | skipping to change at line 87 | |||
EXTRAEXPANDED, | EXTRAEXPANDED, | |||
ULTRAEXPANDED | ULTRAEXPANDED | |||
}; | }; | |||
class PostscriptDocument; | class PostscriptDocument; | |||
class write_glyph_routine_to_stream; | class write_glyph_routine_to_stream; | |||
/** Just like any ordinary ostringstream, | /** Just like any ordinary ostringstream, | |||
* but maintains a reference to the PostscriptDocument. | * but maintains a reference to the PostscriptDocument. | |||
*/ | */ | |||
class oPostscriptStream : public std::ostringstream { | class LASIDLLIMPEXP oPostscriptStream : public std::ostringstream { | |||
public: | public: | |||
friend class PostscriptDocument; | friend class PostscriptDocument; | |||
friend class show; | friend class show; | |||
friend class setFont; | friend class setFont; | |||
friend class setFontSize; | friend class setFontSize; | |||
oPostscriptStream(PostscriptDocument& psDoc) : _psDoc(psDoc) {} | oPostscriptStream(PostscriptDocument& psDoc) : _psDoc(psDoc) {} | |||
protected: | protected: | |||
PostscriptDocument& doc() {return _psDoc;} | PostscriptDocument& doc() {return _psDoc;} | |||
skipping to change at line 86 | skipping to change at line 114 | |||
inline oPostscriptStream& operator<<(oPostscriptStream& os, T t) { | inline oPostscriptStream& operator<<(oPostscriptStream& os, T t) { | |||
static_cast<std::ostream&>(os) << t; | static_cast<std::ostream&>(os) << t; | |||
return os; | return os; | |||
} | } | |||
/** Composes Postscript document as three separate and independant stream s | /** Composes Postscript document as three separate and independant stream s | |||
* for header, body and footer. Body and footer streams respond to | * for header, body and footer. Body and footer streams respond to | |||
* LASi::show applicator which generates Postscript commands to display a | * LASi::show applicator which generates Postscript commands to display a | |||
* string by using glyph routines instead of a Postscript font. | * string by using glyph routines instead of a Postscript font. | |||
*/ | */ | |||
class PostscriptDocument { | class LASIDLLIMPEXP PostscriptDocument { | |||
public: | public: | |||
friend class write_glyph_routine_to_stream; // helper class | friend class write_glyph_routine_to_stream; // helper class | |||
friend class show; | friend class show; | |||
PostscriptDocument(); | PostscriptDocument(); | |||
~PostscriptDocument(); | ~PostscriptDocument(); | |||
/** Sets the font that all subsequent text written | /** Sets the font that all subsequent text written | |||
* to bodyStream() or footerStream() will be rendered with. | * to bodyStream() or footerStream() will be rendered with. | |||
*/ | */ | |||
skipping to change at line 226 | skipping to change at line 254 | |||
// Requires fwd declarations above. | // Requires fwd declarations above. | |||
ContextMgr* _pContextMgr; // manage PangoContext* | ContextMgr* _pContextMgr; // manage PangoContext* | |||
double _fontSize; // font size to be used when rendering next show() | double _fontSize; // font size to be used when rendering next show() | |||
std::ostringstream _osHeader; // Postscript header | std::ostringstream _osHeader; // Postscript header | |||
oPostscriptStream _osBody; // Postscript body | oPostscriptStream _osBody; // Postscript body | |||
oPostscriptStream _osFooter; // Postscript footer | oPostscriptStream _osFooter; // Postscript footer | |||
}; | }; | |||
/** stream manipulator applied to oPostscriptStream. | /** stream manipulator applied to oPostscriptStream. | |||
*/ | */ | |||
class setFont { | class LASIDLLIMPEXP setFont { | |||
public: | public: | |||
/** Stream inserter for 'setFont' stream manipulator | /** Stream inserter for 'setFont' stream manipulator | |||
*/ | */ | |||
friend inline oPostscriptStream& operator<<(oPostscriptStream& os, co nst setFont& x) { | friend inline oPostscriptStream& operator<<(oPostscriptStream& os, co nst setFont& x) { | |||
x.apply(os); | x.apply(os); | |||
return os; | return os; | |||
} | } | |||
/** Usage: | /** Usage: | |||
* os << setFont("Vera Sans",LASi::ITALIC,LASi::BOLD) << ... | * os << setFont("Vera Sans",LASi::ITALIC,LASi::BOLD) << ... | |||
skipping to change at line 263 | skipping to change at line 291 | |||
const char* const _family; | const char* const _family; | |||
const LASi::FontStyle _style; | const LASi::FontStyle _style; | |||
const LASi::FontWeight _weight; | const LASi::FontWeight _weight; | |||
const LASi::FontVariant _variant; | const LASi::FontVariant _variant; | |||
const LASi::FontStretch _stretch; | const LASi::FontStretch _stretch; | |||
}; | }; | |||
/** stream manipulator applied to oPostscriptStream. | /** stream manipulator applied to oPostscriptStream. | |||
*/ | */ | |||
class setFontSize { | class LASIDLLIMPEXP setFontSize { | |||
public: | public: | |||
/** Stream inserter for 'setFontSize' stream manipulator | /** Stream inserter for 'setFontSize' stream manipulator | |||
*/ | */ | |||
friend inline oPostscriptStream& operator<<(oPostscriptStream& os, co nst setFontSize& x) { | friend inline oPostscriptStream& operator<<(oPostscriptStream& os, co nst setFontSize& x) { | |||
x.apply(os); | x.apply(os); | |||
return os; | return os; | |||
} | } | |||
/** Usage: | /** Usage: | |||
* os << setFontSize(12) << ... | * os << setFontSize(12) << ... | |||
skipping to change at line 289 | skipping to change at line 317 | |||
void apply(oPostscriptStream& os) const { | void apply(oPostscriptStream& os) const { | |||
os.doc().setFontSize(_size); | os.doc().setFontSize(_size); | |||
} | } | |||
private: | private: | |||
double _size; | double _size; | |||
}; | }; | |||
/** stream applicator applied to oPostscriptStream. | /** stream applicator applied to oPostscriptStream. | |||
*/ | */ | |||
class show{ | class LASIDLLIMPEXP show{ | |||
public: | public: | |||
/** stream inserter for 'show' stream applicator | /** stream inserter for 'show' stream applicator | |||
*/ | */ | |||
friend inline oPostscriptStream& operator<<(oPostscriptStream& os, co nst show& x) { | friend inline oPostscriptStream& operator<<(oPostscriptStream& os, co nst show& x) { | |||
x.apply(os); | x.apply(os); | |||
return os; | return os; | |||
} | } | |||
/** Usage: | /** Usage: | |||
* os << show("some UTF-8 text") << ... | * os << show("some UTF-8 text") << ... | |||
End of changes. 6 change blocks. | ||||
5 lines changed or deleted | 35 lines changed or added | |||