|
|
|
@@ -0,0 +1,941 @@ |
|
|
|
#ifndef LIB_TEXT_SUITE_HPP |
|
|
|
#define LIB_TEXT_SUITE_HPP |
|
|
|
|
|
|
|
#include <string> |
|
|
|
#include <stdint.h> |
|
|
|
#include <initializer_list> |
|
|
|
|
|
|
|
#if defined(WIN32) || defined(WIN64) || defined(_WIN32) || defined(_WIN64) |
|
|
|
# define LTS_WINDOWS |
|
|
|
# include <windows.h> |
|
|
|
#elif LINUX || __linux__ |
|
|
|
# define LTS_LINUX |
|
|
|
# include <dlfcn.h> |
|
|
|
#else |
|
|
|
# error "unknown operation system" |
|
|
|
#endif |
|
|
|
|
|
|
|
#if __MINGW32__ |
|
|
|
# define WINAPI __stdcall |
|
|
|
#else |
|
|
|
# define WINAPI |
|
|
|
#endif |
|
|
|
|
|
|
|
/**********************************************************************************************************************************/ |
|
|
|
/* public interface */ |
|
|
|
/**********************************************************************************************************************************/ |
|
|
|
namespace lts |
|
|
|
{ |
|
|
|
|
|
|
|
/* enumerations *******************************************************************************************************************/ |
|
|
|
enum class ErrorCode : int32_t |
|
|
|
{ |
|
|
|
Unknown = -1, |
|
|
|
None = 0, |
|
|
|
|
|
|
|
// misc |
|
|
|
NotInitialized = 1, |
|
|
|
InvalidEnum = 2, |
|
|
|
InvalidValue = 3, |
|
|
|
InvalidOperation = 4, |
|
|
|
InvalidType = 5, |
|
|
|
|
|
|
|
// invalid handles |
|
|
|
InvalidContextHandle = 100, |
|
|
|
InvalidRendererHandle = 101, |
|
|
|
InvalidTextBlockHandle = 102, |
|
|
|
InvalidFontHandle = 103, |
|
|
|
InvalidFontCreatorHandle = 104, |
|
|
|
InvalidImageHandle = 105, |
|
|
|
InvalidPostProcHandle = 106, |
|
|
|
|
|
|
|
// library |
|
|
|
InvalidLibName = 200, |
|
|
|
InvalidLibHandle = 201, |
|
|
|
InvalidMethodName = 202 |
|
|
|
}; |
|
|
|
static_assert(sizeof(ErrorCode) == 4, "size of lts::ErrorCode should be 4"); |
|
|
|
|
|
|
|
enum class CodePage : uint32_t |
|
|
|
{ |
|
|
|
cpUTF8, |
|
|
|
cpISO_8859_1, |
|
|
|
cpISO_8859_2, |
|
|
|
cpISO_8859_3, |
|
|
|
cpISO_8859_4, |
|
|
|
cpISO_8859_5, |
|
|
|
cpISO_8859_6, |
|
|
|
cpISO_8859_7, |
|
|
|
cpISO_8859_8, |
|
|
|
cpISO_8859_9, |
|
|
|
cpISO_8859_10, |
|
|
|
cpISO_8859_11, |
|
|
|
cpISO_8859_13, |
|
|
|
cpISO_8859_14, |
|
|
|
cpISO_8859_15, |
|
|
|
cpISO_8859_16, |
|
|
|
cpISO_037, |
|
|
|
cpISO_437, |
|
|
|
cpISO_500, |
|
|
|
cpISO_737, |
|
|
|
cpISO_775, |
|
|
|
cpISO_850, |
|
|
|
cpISO_852, |
|
|
|
cpISO_855, |
|
|
|
cpISO_857, |
|
|
|
cpISO_860, |
|
|
|
cpISO_861, |
|
|
|
cpISO_862, |
|
|
|
cpISO_863, |
|
|
|
cpISO_864, |
|
|
|
cpISO_865, |
|
|
|
cpISO_866, |
|
|
|
cpISO_869, |
|
|
|
cpISO_874, |
|
|
|
cpISO_875, |
|
|
|
cpISO_1026, |
|
|
|
cpISO_1250, |
|
|
|
cpISO_1251, |
|
|
|
cpISO_1252, |
|
|
|
cpISO_1253, |
|
|
|
cpISO_1254, |
|
|
|
cpISO_1255, |
|
|
|
cpISO_1256, |
|
|
|
cpISO_1257, |
|
|
|
cpISO_1258 |
|
|
|
}; |
|
|
|
static_assert(sizeof(CodePage) == 4, "size of lts::CodePage should be 4"); |
|
|
|
|
|
|
|
enum class Format : uint32_t |
|
|
|
{ |
|
|
|
Empty, |
|
|
|
RGBA8, |
|
|
|
LumAlpha8, |
|
|
|
Alpha8, |
|
|
|
Lum8 |
|
|
|
}; |
|
|
|
static_assert(sizeof(Format) == 4, "size of lts::Format should be 4"); |
|
|
|
|
|
|
|
enum class RendererType : uint32_t |
|
|
|
{ |
|
|
|
Unknown, |
|
|
|
OpenGL, |
|
|
|
OpenGLES |
|
|
|
}; |
|
|
|
static_assert(sizeof(RendererType) == 4, "size of lts::RendererType should be 4"); |
|
|
|
|
|
|
|
enum class FontCreatorType : uint32_t |
|
|
|
{ |
|
|
|
Unknown, |
|
|
|
FreeType, |
|
|
|
GDI, |
|
|
|
Custom |
|
|
|
}; |
|
|
|
static_assert(sizeof(FontCreatorType) == 4, "size of lts::FontCreatorType should be 4"); |
|
|
|
|
|
|
|
enum class VertAlign : uint32_t |
|
|
|
{ |
|
|
|
Top, |
|
|
|
Center, |
|
|
|
Bottom |
|
|
|
}; |
|
|
|
static_assert(sizeof(VertAlign) == 4, "size of lts::VertAlign should be 4"); |
|
|
|
|
|
|
|
enum class HorzAlign : uint32_t |
|
|
|
{ |
|
|
|
Left, |
|
|
|
Center, |
|
|
|
Right, |
|
|
|
Justify |
|
|
|
}; |
|
|
|
static_assert(sizeof(HorzAlign) == 4, "size of lts::HorzAlign should be 4"); |
|
|
|
|
|
|
|
enum class Clipping : uint32_t |
|
|
|
{ |
|
|
|
None, |
|
|
|
WordBorder, |
|
|
|
CharBorder, |
|
|
|
WordComplete, |
|
|
|
CharComplete |
|
|
|
}; |
|
|
|
static_assert(sizeof(Clipping) == 4, "size of lts::Clipping should be 4"); |
|
|
|
|
|
|
|
enum class AntiAliasing : uint32_t |
|
|
|
{ |
|
|
|
None, |
|
|
|
Normal |
|
|
|
}; |
|
|
|
static_assert(sizeof(AntiAliasing) == 4, "size of lts::AntiAliasing should be 4"); |
|
|
|
|
|
|
|
enum class CharRangeUsage : uint32_t |
|
|
|
{ |
|
|
|
Include, |
|
|
|
Exclude |
|
|
|
}; |
|
|
|
static_assert(sizeof(CharRangeUsage) == 4, "size of lts::CharRangeUsage should be 4"); |
|
|
|
|
|
|
|
enum class ImageMode : uint32_t |
|
|
|
{ |
|
|
|
Ignore, |
|
|
|
Replace, |
|
|
|
Modulate |
|
|
|
}; |
|
|
|
static_assert(sizeof(ImageMode) == 4, "size of lts::ImageMode should be 4"); |
|
|
|
|
|
|
|
/* flags **************************************************************************************************************************/ |
|
|
|
template <typename TEnum, typename TBase> |
|
|
|
class Flags |
|
|
|
{ |
|
|
|
private: |
|
|
|
TBase _value; |
|
|
|
public: |
|
|
|
inline bool isSet(const TEnum& e) const |
|
|
|
{ return (_value & (1 << e)); }; |
|
|
|
inline void set(const TEnum& e) |
|
|
|
{ _value |= (1 << e); }; |
|
|
|
inline void unset(const TEnum& e) |
|
|
|
{ _value &= ~(1 << e); }; |
|
|
|
inline void clear() |
|
|
|
{ _value = 0; }; |
|
|
|
Flags() : |
|
|
|
_value(0) |
|
|
|
{ }; |
|
|
|
Flags(const TEnum& e) : |
|
|
|
_value(1 << e) |
|
|
|
{ }; |
|
|
|
Flags(const std::initializer_list<TEnum>& vec) : |
|
|
|
_value(0) |
|
|
|
{ |
|
|
|
for (const auto& e : vec) |
|
|
|
set(e); |
|
|
|
}; |
|
|
|
template <typename T> |
|
|
|
Flags(T begIt, T endIt) : |
|
|
|
_value(0) |
|
|
|
{ |
|
|
|
for (auto i = begIt; i != endIt; ++i) |
|
|
|
set(*i); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
enum class BlockFlag |
|
|
|
{ |
|
|
|
WordWrap |
|
|
|
}; |
|
|
|
typedef Flags<BlockFlag, uint32_t> BlockFlags; |
|
|
|
|
|
|
|
enum class FontStyle |
|
|
|
{ |
|
|
|
Bold, |
|
|
|
Italic, |
|
|
|
Underline, |
|
|
|
Strikeout, |
|
|
|
}; |
|
|
|
typedef Flags<FontStyle, uint32_t> FontStyles; |
|
|
|
|
|
|
|
enum class ColorChannel |
|
|
|
{ |
|
|
|
Red, |
|
|
|
Green, |
|
|
|
Blue, |
|
|
|
Alpha |
|
|
|
}; |
|
|
|
typedef Flags<ColorChannel, uint32_t> ColorChannels; |
|
|
|
|
|
|
|
/* structures *********************************************************************************************************************/ |
|
|
|
struct Position |
|
|
|
{ |
|
|
|
int x; |
|
|
|
int y; |
|
|
|
}; |
|
|
|
|
|
|
|
union Rect |
|
|
|
{ |
|
|
|
struct { Position top_left, bottom_right; }; |
|
|
|
struct { int32_t left, top, right, bottom; }; |
|
|
|
}; |
|
|
|
|
|
|
|
union Color4f |
|
|
|
{ |
|
|
|
struct { float r, g, b, a; }; |
|
|
|
float arr[4]; |
|
|
|
}; |
|
|
|
|
|
|
|
struct GlyphMetric |
|
|
|
{ |
|
|
|
Position glyphOrigin; |
|
|
|
Rect glyphRect; |
|
|
|
int32_t advance; |
|
|
|
}; |
|
|
|
|
|
|
|
struct TextMetric |
|
|
|
{ |
|
|
|
int32_t ascent; |
|
|
|
int32_t descent; |
|
|
|
int32_t externalLeading; |
|
|
|
int32_t baseLineOffset; |
|
|
|
int32_t charSpacing; |
|
|
|
int32_t lineHeight; |
|
|
|
int32_t lineSpacing; |
|
|
|
}; |
|
|
|
|
|
|
|
struct FontMetric |
|
|
|
{ |
|
|
|
int32_t size; |
|
|
|
FontStyles styles; |
|
|
|
AntiAliasing antiAliasing; |
|
|
|
wchar_t defaultChar; |
|
|
|
uint8_t __reserved[2]; |
|
|
|
|
|
|
|
int32_t ascent; |
|
|
|
int32_t descent; |
|
|
|
int32_t externalLeading; |
|
|
|
int32_t baseLineOffset; |
|
|
|
|
|
|
|
int32_t underlinePos; |
|
|
|
int32_t underlineSize; |
|
|
|
int32_t strikeoutPos; |
|
|
|
int32_t strikeoutSize; |
|
|
|
}; |
|
|
|
|
|
|
|
typedef float Vector4f[4]; |
|
|
|
typedef Vector4f Matrix4f[4]; |
|
|
|
typedef ImageMode ImageModes[4]; |
|
|
|
|
|
|
|
typedef void* Handle; |
|
|
|
typedef Handle ContextHandle; |
|
|
|
typedef Handle RendererHandle; |
|
|
|
typedef Handle TextBlockHandle; |
|
|
|
typedef Handle FontCreatorHandle; |
|
|
|
typedef Handle FontHandle; |
|
|
|
typedef Handle PostProcessorHandle; |
|
|
|
typedef Handle ImageHandle; |
|
|
|
typedef Handle CharHandle; |
|
|
|
|
|
|
|
class Exception : public std::exception |
|
|
|
{ |
|
|
|
private: |
|
|
|
std::string _message; |
|
|
|
ErrorCode _errorCode; |
|
|
|
|
|
|
|
public: |
|
|
|
ErrorCode getErrorCode() const; |
|
|
|
std::string getMessage() const; |
|
|
|
virtual const char* what() const throw(); |
|
|
|
Exception(std::string message, ErrorCode errorCode = ErrorCode::Unknown); |
|
|
|
~Exception() throw(); |
|
|
|
}; |
|
|
|
|
|
|
|
class Library |
|
|
|
{ |
|
|
|
public: |
|
|
|
#if defined(LTS_WINDOWS) |
|
|
|
typedef HMODULE Handle; //!< shader file handle |
|
|
|
#elif defined(LTS_LINUX) |
|
|
|
typedef void* Handle; //!< shader file handle |
|
|
|
#else |
|
|
|
#error "unknown operation system" |
|
|
|
#endif |
|
|
|
|
|
|
|
private: |
|
|
|
struct Impl; |
|
|
|
Impl* _impl; |
|
|
|
Handle _handle; |
|
|
|
|
|
|
|
public: |
|
|
|
ErrorCode getLastErrorCode() const; |
|
|
|
std::string getLastErrorMsg() const; |
|
|
|
|
|
|
|
Library(const std::string& libName); |
|
|
|
~Library(); |
|
|
|
|
|
|
|
private: |
|
|
|
Library(const Library& that) { }; |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
/**********************************************************************************************************************************/ |
|
|
|
/* private implementation */ |
|
|
|
/**********************************************************************************************************************************/ |
|
|
|
#if defined(LTS_WINDOWS) |
|
|
|
lts::Library::Handle libOpen(const char* name) |
|
|
|
{ return LoadLibrary(name); }; |
|
|
|
|
|
|
|
template <typename T> |
|
|
|
T getAddr(lts::Library::Handle handle, const char* name) |
|
|
|
{ return reinterpret_cast<T>(GetProcAddress(handle, name)); }; |
|
|
|
|
|
|
|
int libClose(lts::Library::Handle handle) |
|
|
|
{ return FreeLibrary(handle); }; |
|
|
|
|
|
|
|
#elif defined(LTS_LINUX) |
|
|
|
lts::Library::Handle libOpen(const char* name) |
|
|
|
{ return dlopen(name, RTLD_LAZY); }; |
|
|
|
|
|
|
|
template <typename T> |
|
|
|
T getAddr(lts::Library::Handle handle, const char* name) |
|
|
|
{ return reinterpret_cast<T>(dlsym(handle, name)); }; |
|
|
|
|
|
|
|
int libClose(lts::Library::Handle handle) |
|
|
|
{ return !dlclose(handle); }; |
|
|
|
|
|
|
|
#else |
|
|
|
# error "unknown operation system" |
|
|
|
#endif |
|
|
|
|
|
|
|
/* Library::Impl ******************************************************************************************************************/ |
|
|
|
struct lts::Library::Impl |
|
|
|
{ |
|
|
|
public: /* stream */ |
|
|
|
struct StreamData |
|
|
|
{ |
|
|
|
enum class Origin : uint32_t |
|
|
|
{ |
|
|
|
Begin = 0, |
|
|
|
Current = 1, |
|
|
|
End = 2 |
|
|
|
}; |
|
|
|
static_assert(sizeof(Origin) == 4, "size of lts::StreamOrigin should be 4"); |
|
|
|
|
|
|
|
typedef int (WINAPI *stream_read_t)(void* args, void* buffer, int count); |
|
|
|
typedef int (WINAPI *stream_seek_t)(void* args, Origin origin, int offset); |
|
|
|
|
|
|
|
void* args; |
|
|
|
stream_read_t read; |
|
|
|
stream_seek_t seek; |
|
|
|
}; |
|
|
|
|
|
|
|
public: /* custom post processor */ |
|
|
|
struct PostProcessorData |
|
|
|
{ |
|
|
|
typedef void (WINAPI *post_processor_execute_t)(lts::CharHandle charHandle, lts::ImageHandle imageHandle); |
|
|
|
|
|
|
|
void* args; |
|
|
|
post_processor_execute_t execute; |
|
|
|
}; |
|
|
|
|
|
|
|
public: /* custom renderer */ |
|
|
|
struct RendererCustomData |
|
|
|
{ |
|
|
|
typedef void (WINAPI *renderer_begin_render_t) (void* args); |
|
|
|
typedef void (WINAPI *renderer_end_render_t) (void* args); |
|
|
|
typedef lts::Position (WINAPI *renderer_get_draw_pos_t) (void* args); |
|
|
|
typedef void (WINAPI *renderer_set_draw_pos_t) (lts::Position value, void* args); |
|
|
|
typedef void (WINAPI *renderer_move_draw_pos_t) (lts::Position value, void* args); |
|
|
|
typedef void (WINAPI *renderer_set_color_t) (lts::Color4f value, void* args); |
|
|
|
typedef void (WINAPI *renderer_render) (void* ref, int forcedWidth, void* args); |
|
|
|
typedef void* (WINAPI *renderer_create_ref) (lts::CharHandle charHandle, lts::ImageHandle imageHandle, void* args); |
|
|
|
typedef void (WINAPI *renderer_free_ref) (void* ref, void* args); |
|
|
|
|
|
|
|
void* args; |
|
|
|
|
|
|
|
renderer_begin_render_t beginRender; |
|
|
|
renderer_end_render_t endRender; |
|
|
|
renderer_get_draw_pos_t getDrawPos; |
|
|
|
renderer_set_draw_pos_t setDrawPos; |
|
|
|
renderer_move_draw_pos_t moveDrawPos; |
|
|
|
renderer_set_color_t setColor; |
|
|
|
renderer_render render; |
|
|
|
|
|
|
|
renderer_create_ref createRef; |
|
|
|
renderer_free_ref freeRef; |
|
|
|
}; |
|
|
|
|
|
|
|
public: /* callbacks */ |
|
|
|
typedef void (WINAPI *image_load_callback_t) (lts::ImageHandle handle, int x, int y, lts::Color4f pixel, void* args); |
|
|
|
typedef void (WINAPI *image_blend_callback_t)(lts::ImageHandle handle, lts::Color4f src, lts::Color4f dst, lts::Color4f& result, void* args); |
|
|
|
|
|
|
|
typedef lts::ContextHandle (WINAPI *context_create_t) (); |
|
|
|
typedef lts::ErrorCode (WINAPI *context_get_code_page_t) (lts::ContextHandle handle, lts::CodePage* value); |
|
|
|
typedef lts::ErrorCode (WINAPI *context_get_default_char_t) (lts::ContextHandle handle, wchar_t& value); |
|
|
|
typedef lts::ErrorCode (WINAPI *context_set_code_page_t) (lts::ContextHandle handle, lts::CodePage value); |
|
|
|
typedef lts::ErrorCode (WINAPI *context_set_default_char_t) (lts::ContextHandle handle, wchar_t value); |
|
|
|
typedef wchar_t* (WINAPI *context_ansi_to_wide_t) (lts::ContextHandle handle, const char* text); |
|
|
|
typedef lts::ErrorCode (WINAPI *context_destroy_t) (lts::ContextHandle handle); |
|
|
|
|
|
|
|
typedef lts::RendererHandle (WINAPI *renderer_create_t) (lts::ContextHandle handle, lts::RendererType type, lts::Format format); |
|
|
|
typedef lts::RendererHandle (WINAPI *renderer_create_custom_t) (lts::ContextHandle handle, lts::Format format, const RendererCustomData& data); |
|
|
|
typedef lts::TextBlockHandle (WINAPI *renderer_begin_block_t) (lts::RendererHandle handle, int top, int left, int width, int height, lts::BlockFlags flags); |
|
|
|
typedef lts::ErrorCode (WINAPI *renderer_end_block_t) (lts::RendererHandle handle, lts::TextBlockHandle block); |
|
|
|
typedef lts::ErrorCode (WINAPI *renderer_abort_block_t) (lts::RendererHandle handle, lts::TextBlockHandle block); |
|
|
|
typedef int (WINAPI *renderer_get_text_width_a_t) (lts::RendererHandle handle, lts::FontHandle font, const char* text); |
|
|
|
typedef int (WINAPI *renderer_get_text_width_w_t) (lts::RendererHandle handle, lts::FontHandle font, const wchar_t* text); |
|
|
|
typedef lts::ErrorCode (WINAPI *renderer_destroy_t) (lts::RendererHandle handle); |
|
|
|
|
|
|
|
typedef lts::FontCreatorHandle (WINAPI *font_creator_create_t) (lts::ContextHandle handle, lts::FontCreatorType type); |
|
|
|
typedef lts::FontHandle (WINAPI *font_creator_get_font_by_name_t) (lts::FontCreatorHandle handle, const char* fontname, int size, lts::FontStyles style, lts::AntiAliasing antialiasing); |
|
|
|
typedef lts::FontHandle (WINAPI *font_creator_get_font_by_file_t) (lts::FontCreatorHandle handle, const char* filename, int size, lts::FontStyles style, lts::AntiAliasing antialiasing); |
|
|
|
typedef lts::FontHandle (WINAPI *font_creator_get_font_by_stream_t) (lts::FontCreatorHandle handle, StreamData* stream, int size, lts::FontStyles style, lts::AntiAliasing antialiasing); |
|
|
|
typedef lts::ErrorCode (WINAPI *font_creator_destroy_t) (lts::FontCreatorHandle handle); |
|
|
|
|
|
|
|
typedef lts::PostProcessorHandle(WINAPI *font_get_post_processor_t) (lts::FontHandle handle); |
|
|
|
typedef lts::ErrorCode (WINAPI *font_get_tab_width_t) (lts::FontHandle handle, int& value); |
|
|
|
typedef lts::ErrorCode (WINAPI *font_get_char_spacing_t) (lts::FontHandle handle, int& value); |
|
|
|
typedef lts::ErrorCode (WINAPI *font_get_line_spacing_t) (lts::FontHandle handle, float& value); |
|
|
|
typedef lts::ErrorCode (WINAPI *font_get_metric_t) (lts::FontHandle handle, lts::FontMetric& value); |
|
|
|
typedef const char* (WINAPI *font_get_fontname_t) (lts::FontHandle handle); |
|
|
|
typedef const char* (WINAPI *font_get_facename_t) (lts::FontHandle handle); |
|
|
|
typedef const char* (WINAPI *font_get_stylename_t) (lts::FontHandle handle); |
|
|
|
typedef const char* (WINAPI *font_get_fillname_t) (lts::FontHandle handle); |
|
|
|
typedef const char* (WINAPI *font_get_copyright_t) (lts::FontHandle handle); |
|
|
|
typedef lts::ErrorCode (WINAPI *font_set_post_processor_t) (lts::FontHandle handle, lts::PostProcessorHandle pp); |
|
|
|
typedef lts::ErrorCode (WINAPI *font_set_tab_width_t) (lts::FontHandle handle, int value); |
|
|
|
typedef lts::ErrorCode (WINAPI *font_set_char_spacing_t) (lts::FontHandle handle, int value); |
|
|
|
typedef lts::ErrorCode (WINAPI *font_set_line_spacing_t) (lts::FontHandle handle, float value); |
|
|
|
typedef lts::ErrorCode (WINAPI *font_destroy_t) (lts::FontHandle handle); |
|
|
|
|
|
|
|
typedef lts::ErrorCode (WINAPI *text_block_get_rect_t) (lts::TextBlockHandle handle, lts::Rect& value); |
|
|
|
typedef lts::ErrorCode (WINAPI *text_block_get_width_t) (lts::TextBlockHandle handle, int& value); |
|
|
|
typedef lts::ErrorCode (WINAPI *text_block_get_height_t) (lts::TextBlockHandle handle, int& value); |
|
|
|
typedef lts::ErrorCode (WINAPI *text_block_get_flags_t) (lts::TextBlockHandle handle, lts::BlockFlags& value); |
|
|
|
typedef lts::ErrorCode (WINAPI *text_block_get_top_t) (lts::TextBlockHandle handle, int& value); |
|
|
|
typedef lts::ErrorCode (WINAPI *text_block_get_left_t) (lts::TextBlockHandle handle, int& value); |
|
|
|
typedef lts::ErrorCode (WINAPI *text_block_get_vert_align_t) (lts::TextBlockHandle handle, lts::VertAlign& value); |
|
|
|
typedef lts::ErrorCode (WINAPI *text_block_get_horz_align_t) (lts::TextBlockHandle handle, lts::HorzAlign& value); |
|
|
|
typedef lts::ErrorCode (WINAPI *text_block_get_clipping_t) (lts::TextBlockHandle handle, lts::Clipping& value); |
|
|
|
typedef lts::ErrorCode (WINAPI *text_block_get_color_t) (lts::TextBlockHandle handle, lts::Color4f& value); |
|
|
|
typedef lts::ErrorCode (WINAPI *text_block_get_font_t) (lts::TextBlockHandle handle, lts::FontHandle& value); |
|
|
|
typedef lts::ErrorCode (WINAPI *text_block_set_top_t) (lts::TextBlockHandle handle, int value); |
|
|
|
typedef lts::ErrorCode (WINAPI *text_block_set_left_t) (lts::TextBlockHandle handle, int value); |
|
|
|
typedef lts::ErrorCode (WINAPI *text_block_set_vert_align_t) (lts::TextBlockHandle handle, lts::VertAlign value); |
|
|
|
typedef lts::ErrorCode (WINAPI *text_block_set_horz_align_t) (lts::TextBlockHandle handle, lts::HorzAlign value); |
|
|
|
typedef lts::ErrorCode (WINAPI *text_block_set_clipping_t) (lts::TextBlockHandle handle, lts::Clipping value); |
|
|
|
typedef lts::ErrorCode (WINAPI *text_block_set_color_t) (lts::TextBlockHandle handle, lts::Color4f value); |
|
|
|
typedef lts::ErrorCode (WINAPI *text_block_set_font_t) (lts::TextBlockHandle handle, lts::FontHandle value); |
|
|
|
typedef int (WINAPI *text_block_get_actual_height_t) (lts::TextBlockHandle handle); |
|
|
|
typedef int (WINAPI *text_block_get_text_width_a_t) (lts::TextBlockHandle handle, const char* text); |
|
|
|
typedef int (WINAPI *text_block_get_text_width_w_t) (lts::TextBlockHandle handle, const wchar_t* text); |
|
|
|
typedef lts::ErrorCode (WINAPI *text_block_text_out_a_t) (lts::TextBlockHandle handle, const char* text); |
|
|
|
typedef lts::ErrorCode (WINAPI *text_block_text_out_w_t) (lts::TextBlockHandle handle, const wchar_t* text); |
|
|
|
typedef lts::ErrorCode (WINAPI *text_block_destroy_t) (lts::TextBlockHandle handle); |
|
|
|
|
|
|
|
typedef lts::ImageHandle (WINAPI *image_create_t) (lts::ContextHandle handle); |
|
|
|
typedef lts::ErrorCode (WINAPI *image_is_empty_t) (lts::ImageHandle handle, bool& value); |
|
|
|
typedef int (WINAPI *image_get_width_t) (lts::ImageHandle handle); |
|
|
|
typedef int (WINAPI *image_get_height_t) (lts::ImageHandle handle); |
|
|
|
typedef int (WINAPI *image_get_line_size_t) (lts::ImageHandle handle); |
|
|
|
typedef int (WINAPI *image_get_data_size_t) (lts::ImageHandle handle); |
|
|
|
typedef lts::ErrorCode (WINAPI *image_get_format_t) (lts::ImageHandle handle, lts::Format& value); |
|
|
|
typedef void* (WINAPI *image_get_data_t) (lts::ImageHandle handle); |
|
|
|
typedef void* (WINAPI *image_get_scanline_t) (lts::ImageHandle handle, int index); |
|
|
|
typedef lts::ErrorCode (WINAPI *image_get_pixel_at_t) (lts::ImageHandle handle, int x, int y, lts::Color4f pixel); |
|
|
|
typedef lts::ErrorCode (WINAPI *image_assign_t) (lts::ImageHandle handle, lts::ImageHandle source); |
|
|
|
typedef lts::ErrorCode (WINAPI *image_create_empty_t) (lts::ImageHandle handle, lts::Format format, int width, int height); |
|
|
|
typedef lts::ErrorCode (WINAPI *image_load_from_func_t) (lts::ImageHandle handle, image_load_callback_t callback, void* args); |
|
|
|
typedef lts::ErrorCode (WINAPI *image_resize_t) (lts::ImageHandle handle, int width, int height, int x, int y); |
|
|
|
typedef lts::ErrorCode (WINAPI *image_fill_color_t) (lts::ImageHandle handle, lts::Color4f color, lts::ColorChannels mask, lts::ImageModes modes); |
|
|
|
typedef lts::ErrorCode (WINAPI *image_fill_pattern_t) (lts::ImageHandle handle, lts::ImageHandle pattern, int x, int y, lts::ColorChannels mask, lts::ImageModes modes); |
|
|
|
typedef lts::ErrorCode (WINAPI *image_blend_t) (lts::ImageHandle handle, lts::ImageHandle source, int x, int y, image_blend_callback_t callback, void* args); |
|
|
|
typedef lts::ErrorCode (WINAPI *image_blur_t) (lts::ImageHandle handle, float horzRad, float horzStr, float vertRad, float vertStr, lts::ColorChannels mask); |
|
|
|
typedef lts::ErrorCode (WINAPI *image_destroy_t) (lts::ImageHandle handle); |
|
|
|
|
|
|
|
typedef lts::ErrorCode (WINAPI *post_processor_add_range_t) (lts::PostProcessorHandle handle, lts::CharRangeUsage usage, wchar_t start, wchar_t stop); |
|
|
|
typedef lts::ErrorCode (WINAPI *post_processor_add_chars_t) (lts::PostProcessorHandle handle, lts::CharRangeUsage usage, const wchar_t* chars); |
|
|
|
typedef lts::ErrorCode (WINAPI *post_processor_clear_ranges_t) (lts::PostProcessorHandle handle); |
|
|
|
typedef lts::ErrorCode (WINAPI *post_processor_execute_t) (lts::PostProcessorHandle handle, lts::CharHandle charHandle, lts::ImageHandle image); |
|
|
|
typedef lts::PostProcessorHandle(WINAPI *post_processor_fill_color_create_t) (lts::PostProcessorHandle handle, lts::Color4f color, lts::ImageModes modes, lts::ColorChannels channels); |
|
|
|
typedef lts::PostProcessorHandle(WINAPI *post_processor_fill_pattern_create_t) (lts::PostProcessorHandle handle, lts::ImageHandle pattern, bool ownsPattern, lts::Position position, lts::ImageModes modes, lts::ColorChannels channels); |
|
|
|
typedef lts::PostProcessorHandle(WINAPI *post_processor_border_create_t) (lts::PostProcessorHandle handle, float width, float strength, lts::Color4f color, bool keepSize); |
|
|
|
typedef lts::PostProcessorHandle(WINAPI *post_processor_shadow_create_t) (lts::PostProcessorHandle handle, float radius, float strength, lts::Position offset, lts::Color4f color); |
|
|
|
typedef lts::PostProcessorHandle(WINAPI *post_processor_custom_create_t) (lts::PostProcessorHandle handle, const PostProcessorData& data); |
|
|
|
typedef lts::ErrorCode (WINAPI *post_processor_destroy_t) (lts::PostProcessorHandle handle); |
|
|
|
|
|
|
|
typedef lts::ErrorCode (WINAPI *char_get_char_code_t) (lts::CharHandle handle, wchar_t* value); |
|
|
|
typedef lts::ErrorCode (WINAPI *char_get_glyph_metric_t) (lts::CharHandle handle, lts::GlyphMetric& value); |
|
|
|
typedef lts::ErrorCode (WINAPI *char_set_glyph_metric_t) (lts::CharHandle handle, lts::GlyphMetric value); |
|
|
|
|
|
|
|
typedef lts::ErrorCode (WINAPI *initialize_t) (); |
|
|
|
typedef lts::ErrorCode (WINAPI *get_last_error_code_t) (); |
|
|
|
typedef const char* (WINAPI *get_last_error_msg_t) (); |
|
|
|
typedef lts::ErrorCode (WINAPI *finalize_t) (); |
|
|
|
|
|
|
|
private: |
|
|
|
lts::Library::Handle _handle; |
|
|
|
|
|
|
|
template <typename T> |
|
|
|
inline void loadProc(T& proc, const char* name) |
|
|
|
{ |
|
|
|
proc = getAddr<T>(_handle, name); |
|
|
|
if (!proc) |
|
|
|
throw lts::Exception(std::string("unable to load method from library: ") + name, lts::ErrorCode::InvalidMethodName); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public: |
|
|
|
context_create_t context_create; |
|
|
|
context_get_code_page_t context_get_code_page; |
|
|
|
context_get_default_char_t context_get_default_char; |
|
|
|
context_set_code_page_t context_set_code_page; |
|
|
|
context_set_default_char_t context_set_default_char; |
|
|
|
context_ansi_to_wide_t context_ansi_to_wide; |
|
|
|
context_destroy_t context_destroy; |
|
|
|
|
|
|
|
renderer_create_t renderer_create; |
|
|
|
renderer_create_custom_t renderer_create_custom; |
|
|
|
renderer_begin_block_t renderer_begin_block; |
|
|
|
renderer_end_block_t renderer_end_block; |
|
|
|
renderer_abort_block_t renderer_abort_block; |
|
|
|
renderer_get_text_width_a_t renderer_get_text_width_a; |
|
|
|
renderer_get_text_width_w_t renderer_get_text_width_w; |
|
|
|
renderer_destroy_t renderer_destroy; |
|
|
|
|
|
|
|
font_creator_create_t font_creator_create; |
|
|
|
font_creator_get_font_by_name_t font_creator_get_font_by_name; |
|
|
|
font_creator_get_font_by_file_t font_creator_get_font_by_file; |
|
|
|
font_creator_get_font_by_stream_t font_creator_get_font_by_stream; |
|
|
|
font_creator_destroy_t font_creator_destroy; |
|
|
|
|
|
|
|
font_get_post_processor_t font_get_post_processor; |
|
|
|
font_get_tab_width_t font_get_tab_width; |
|
|
|
font_get_char_spacing_t font_get_char_spacing; |
|
|
|
font_get_line_spacing_t font_get_line_spacing; |
|
|
|
font_get_metric_t font_get_metric; |
|
|
|
font_get_fontname_t font_get_fontname; |
|
|
|
font_get_facename_t font_get_facename; |
|
|
|
font_get_stylename_t font_get_stylename; |
|
|
|
font_get_fillname_t font_get_fillname; |
|
|
|
font_get_copyright_t font_get_copyright; |
|
|
|
font_set_post_processor_t font_set_post_processor; |
|
|
|
font_set_tab_width_t font_set_tab_width; |
|
|
|
font_set_char_spacing_t font_set_char_spacing; |
|
|
|
font_set_line_spacing_t font_set_line_spacing; |
|
|
|
font_destroy_t font_destroy; |
|
|
|
|
|
|
|
text_block_get_rect_t text_block_get_rect; |
|
|
|
text_block_get_width_t text_block_get_width; |
|
|
|
text_block_get_height_t text_block_get_height; |
|
|
|
text_block_get_flags_t text_block_get_flags; |
|
|
|
text_block_get_top_t text_block_get_top; |
|
|
|
text_block_get_left_t text_block_get_left; |
|
|
|
text_block_get_vert_align_t text_block_get_vert_align; |
|
|
|
text_block_get_horz_align_t text_block_get_horz_align; |
|
|
|
text_block_get_clipping_t text_block_get_clipping; |
|
|
|
text_block_get_color_t text_block_get_color; |
|
|
|
text_block_get_font_t text_block_get_font; |
|
|
|
text_block_set_top_t text_block_set_top; |
|
|
|
text_block_set_left_t text_block_set_left; |
|
|
|
text_block_set_vert_align_t text_block_set_vert_align; |
|
|
|
text_block_set_horz_align_t text_block_set_horz_align; |
|
|
|
text_block_set_clipping_t text_block_set_clipping; |
|
|
|
text_block_set_color_t text_block_set_color; |
|
|
|
text_block_set_font_t text_block_set_font; |
|
|
|
text_block_get_actual_height_t text_block_get_actual_height; |
|
|
|
text_block_get_text_width_a_t text_block_get_text_width_a; |
|
|
|
text_block_get_text_width_w_t text_block_get_text_width_w; |
|
|
|
text_block_text_out_a_t text_block_text_out_a; |
|
|
|
text_block_text_out_w_t text_block_text_out_w; |
|
|
|
text_block_destroy_t text_block_destroy; |
|
|
|
|
|
|
|
image_create_t image_create; |
|
|
|
image_is_empty_t image_is_empty; |
|
|
|
image_get_width_t image_get_width; |
|
|
|
image_get_height_t image_get_height; |
|
|
|
image_get_line_size_t image_get_line_size; |
|
|
|
image_get_data_size_t image_get_data_size; |
|
|
|
image_get_format_t image_get_format; |
|
|
|
image_get_data_t image_get_data; |
|
|
|
image_get_scanline_t image_get_scanline; |
|
|
|
image_get_pixel_at_t image_get_pixel_at; |
|
|
|
image_assign_t image_assign; |
|
|
|
image_create_empty_t image_create_empty; |
|
|
|
image_load_from_func_t image_load_from_func; |
|
|
|
image_resize_t image_resize; |
|
|
|
image_fill_color_t image_fill_color; |
|
|
|
image_fill_pattern_t image_fill_pattern; |
|
|
|
image_blend_t image_blend; |
|
|
|
image_blur_t image_blur; |
|
|
|
image_destroy_t image_destroy; |
|
|
|
|
|
|
|
post_processor_add_range_t post_processor_add_range; |
|
|
|
post_processor_add_chars_t post_processor_add_chars; |
|
|
|
post_processor_clear_ranges_t post_processor_clear_ranges; |
|
|
|
post_processor_execute_t post_processor_execute; |
|
|
|
post_processor_fill_color_create_t post_processor_fill_color_create; |
|
|
|
post_processor_fill_pattern_create_t post_processor_fill_pattern_create; |
|
|
|
post_processor_border_create_t post_processor_border_create; |
|
|
|
post_processor_shadow_create_t post_processor_shadow_create; |
|
|
|
post_processor_custom_create_t post_processor_custom_create; |
|
|
|
post_processor_destroy_t post_processor_destroy; |
|
|
|
|
|
|
|
char_get_char_code_t char_get_char_code; |
|
|
|
char_get_glyph_metric_t char_get_glyph_metric; |
|
|
|
char_set_glyph_metric_t char_set_glyph_metric; |
|
|
|
|
|
|
|
initialize_t initialize; |
|
|
|
get_last_error_code_t get_last_error_code; |
|
|
|
get_last_error_msg_t get_last_error_msg; |
|
|
|
finalize_t finalize; |
|
|
|
|
|
|
|
public: |
|
|
|
Impl(lts::Library::Handle handle) : |
|
|
|
_handle (handle), |
|
|
|
|
|
|
|
context_create (NULL), |
|
|
|
context_get_code_page (NULL), |
|
|
|
context_get_default_char (NULL), |
|
|
|
context_set_code_page (NULL), |
|
|
|
context_set_default_char (NULL), |
|
|
|
context_ansi_to_wide (NULL), |
|
|
|
context_destroy (NULL), |
|
|
|
|
|
|
|
renderer_create (NULL), |
|
|
|
renderer_create_custom (NULL), |
|
|
|
renderer_begin_block (NULL), |
|
|
|
renderer_end_block (NULL), |
|
|
|
renderer_abort_block (NULL), |
|
|
|
renderer_get_text_width_a (NULL), |
|
|
|
renderer_get_text_width_w (NULL), |
|
|
|
renderer_destroy (NULL), |
|
|
|
|
|
|
|
font_creator_create (NULL), |
|
|
|
font_creator_get_font_by_name (NULL), |
|
|
|
font_creator_get_font_by_file (NULL), |
|
|
|
font_creator_get_font_by_stream (NULL), |
|
|
|
font_creator_destroy (NULL), |
|
|
|
|
|
|
|
font_get_post_processor (NULL), |
|
|
|
font_get_tab_width (NULL), |
|
|
|
font_get_char_spacing (NULL), |
|
|
|
font_get_line_spacing (NULL), |
|
|
|
font_get_metric (NULL), |
|
|
|
font_get_fontname (NULL), |
|
|
|
font_get_facename (NULL), |
|
|
|
font_get_stylename (NULL), |
|
|
|
font_get_fillname (NULL), |
|
|
|
font_get_copyright (NULL), |
|
|
|
font_set_post_processor (NULL), |
|
|
|
font_set_tab_width (NULL), |
|
|
|
font_set_char_spacing (NULL), |
|
|
|
font_set_line_spacing (NULL), |
|
|
|
font_destroy (NULL), |
|
|
|
|
|
|
|
text_block_get_rect (NULL), |
|
|
|
text_block_get_width (NULL), |
|
|
|
text_block_get_height (NULL), |
|
|
|
text_block_get_flags (NULL), |
|
|
|
text_block_get_top (NULL), |
|
|
|
text_block_get_left (NULL), |
|
|
|
text_block_get_vert_align (NULL), |
|
|
|
text_block_get_horz_align (NULL), |
|
|
|
text_block_get_clipping (NULL), |
|
|
|
text_block_get_color (NULL), |
|
|
|
text_block_get_font (NULL), |
|
|
|
text_block_set_top (NULL), |
|
|
|
text_block_set_left (NULL), |
|
|
|
text_block_set_vert_align (NULL), |
|
|
|
text_block_set_horz_align (NULL), |
|
|
|
text_block_set_clipping (NULL), |
|
|
|
text_block_set_color (NULL), |
|
|
|
text_block_set_font (NULL), |
|
|
|
text_block_get_actual_height (NULL), |
|
|
|
text_block_get_text_width_a (NULL), |
|
|
|
text_block_get_text_width_w (NULL), |
|
|
|
text_block_text_out_a (NULL), |
|
|
|
text_block_text_out_w (NULL), |
|
|
|
text_block_destroy (NULL), |
|
|
|
|
|
|
|
image_create (NULL), |
|
|
|
image_is_empty (NULL), |
|
|
|
image_get_width (NULL), |
|
|
|
image_get_height (NULL), |
|
|
|
image_get_line_size (NULL), |
|
|
|
image_get_data_size (NULL), |
|
|
|
image_get_format (NULL), |
|
|
|
image_get_data (NULL), |
|
|
|
image_get_scanline (NULL), |
|
|
|
image_get_pixel_at (NULL), |
|
|
|
image_assign (NULL), |
|
|
|
image_create_empty (NULL), |
|
|
|
image_load_from_func (NULL), |
|
|
|
image_resize (NULL), |
|
|
|
image_fill_color (NULL), |
|
|
|
image_fill_pattern (NULL), |
|
|
|
image_blend (NULL), |
|
|
|
image_blur (NULL), |
|
|
|
image_destroy (NULL), |
|
|
|
|
|
|
|
post_processor_add_range (NULL), |
|
|
|
post_processor_add_chars (NULL), |
|
|
|
post_processor_clear_ranges (NULL), |
|
|
|
post_processor_execute (NULL), |
|
|
|
post_processor_fill_color_create (NULL), |
|
|
|
post_processor_fill_pattern_create (NULL), |
|
|
|
post_processor_border_create (NULL), |
|
|
|
post_processor_shadow_create (NULL), |
|
|
|
post_processor_custom_create (NULL), |
|
|
|
post_processor_destroy (NULL), |
|
|
|
|
|
|
|
char_get_char_code (NULL), |
|
|
|
char_get_glyph_metric (NULL), |
|
|
|
char_set_glyph_metric (NULL), |
|
|
|
|
|
|
|
get_last_error_code (NULL), |
|
|
|
get_last_error_msg (NULL) |
|
|
|
{ |
|
|
|
loadProc(context_create, "ltsContextCreate"); |
|
|
|
loadProc(context_get_code_page, "ltsContextGetCodePage"); |
|
|
|
loadProc(context_get_default_char, "ltsContextGetDefaultChar"); |
|
|
|
loadProc(context_set_code_page, "ltsContextSetCodePage"); |
|
|
|
loadProc(context_set_default_char, "ltsContextSetDefaultChar"); |
|
|
|
loadProc(context_ansi_to_wide, "ltsContextAnsiToWide"); |
|
|
|
loadProc(context_destroy, "ltsContextDestroy"); |
|
|
|
|
|
|
|
loadProc(renderer_create, "ltsRendererCreate"); |
|
|
|
loadProc(renderer_create_custom, "ltsRendererCustomCreate"); |
|
|
|
loadProc(renderer_begin_block, "ltsRendererBeginBlock"); |
|
|
|
loadProc(renderer_end_block, "ltsRendererEndBlock"); |
|
|
|
loadProc(renderer_abort_block, "ltsRendererAbortBlock"); |
|
|
|
loadProc(renderer_get_text_width_a, "ltsRendererGetTextWidthA"); |
|
|
|
loadProc(renderer_get_text_width_w, "ltsRendererGetTextWidthW"); |
|
|
|
loadProc(renderer_destroy, "ltsRendererDestroy"); |
|
|
|
|
|
|
|
loadProc(font_creator_create, "ltsFontCreatorCreate"); |
|
|
|
loadProc(font_creator_get_font_by_name, "ltsFontCreatorGetFontByName"); |
|
|
|
loadProc(font_creator_get_font_by_file, "ltsFontCreatorGetFontByFile"); |
|
|
|
loadProc(font_creator_get_font_by_stream, "ltsFontCreatorGetFontByStream"); |
|
|
|
loadProc(font_creator_destroy, "ltsFontCreatorDestroy"); |
|
|
|
|
|
|
|
loadProc(font_get_post_processor, "ltsFontGetPostProcessor"); |
|
|
|
loadProc(font_get_tab_width, "ltsFontGetTabWidth"); |
|
|
|
loadProc(font_get_char_spacing, "ltsFontGetCharSpacing"); |
|
|
|
loadProc(font_get_line_spacing, "ltsFontGetLineSpacing"); |
|
|
|
loadProc(font_get_metric, "ltsFontGetMetric"); |
|
|
|
loadProc(font_get_fontname, "ltsFontGetFontname"); |
|
|
|
loadProc(font_get_facename, "ltsFontGetFacename"); |
|
|
|
loadProc(font_get_stylename, "ltsFontGetStylename"); |
|
|
|
loadProc(font_get_fillname, "ltsFontGetFullname"); |
|
|
|
loadProc(font_get_copyright, "ltsFontGetCopyright"); |
|
|
|
loadProc(font_set_post_processor, "ltsFontSetPostProcessor"); |
|
|
|
loadProc(font_set_tab_width, "ltsFontSetTabWidth"); |
|
|
|
loadProc(font_set_char_spacing, "ltsFontSetCharSpacing"); |
|
|
|
loadProc(font_set_line_spacing, "ltsFontSetLineSpacing"); |
|
|
|
loadProc(font_destroy, "ltsFontDestroy"); |
|
|
|
|
|
|
|
loadProc(text_block_get_rect, "ltsTextBlockGetRect"); |
|
|
|
loadProc(text_block_get_width, "ltsTextBlockGetWidth"); |
|
|
|
loadProc(text_block_get_height, "ltsTextBlockGetHeight"); |
|
|
|
loadProc(text_block_get_flags, "ltsTextBlockGetFlags"); |
|
|
|
loadProc(text_block_get_top, "ltsTextBlockGetTop"); |
|
|
|
loadProc(text_block_get_left, "ltsTextBlockGetLeft"); |
|
|
|
loadProc(text_block_get_vert_align, "ltsTextBlockGetVertAlign"); |
|
|
|
loadProc(text_block_get_horz_align, "ltsTextBlockGetHorzAlign"); |
|
|
|
loadProc(text_block_get_clipping, "ltsTextBlockGetClipping"); |
|
|
|
loadProc(text_block_get_color, "ltsTextBlockGetColor"); |
|
|
|
loadProc(text_block_get_font, "ltsTextBlockGetFont"); |
|
|
|
loadProc(text_block_set_top, "ltsTextBlockSetTop"); |
|
|
|
loadProc(text_block_set_left, "ltsTextBlockSetLeft"); |
|
|
|
loadProc(text_block_set_vert_align, "ltsTextBlockSetVertAlign"); |
|
|
|
loadProc(text_block_set_horz_align, "ltsTextBlockSetHorzAlign"); |
|
|
|
loadProc(text_block_set_clipping, "ltsTextBlockSetClipping"); |
|
|
|
loadProc(text_block_set_color, "ltsTextBlockSetColor"); |
|
|
|
loadProc(text_block_set_font, "ltsTextBlockSetFont"); |
|
|
|
loadProc(text_block_get_actual_height, "ltsTextBlockGetActualHeight"); |
|
|
|
loadProc(text_block_get_text_width_a, "ltsTextBlockGetTextWidthA"); |
|
|
|
loadProc(text_block_get_text_width_w, "ltsTextBlockGetTextWidthW"); |
|
|
|
loadProc(text_block_text_out_a, "ltsTextBlockTextOutA"); |
|
|
|
loadProc(text_block_text_out_w, "ltsTextBlockTextOutW"); |
|
|
|
loadProc(text_block_destroy, "ltsTextBlockDestroy"); |
|
|
|
|
|
|
|
loadProc(image_create, "ltsImageCreate"); |
|
|
|
loadProc(image_is_empty, "ltsImageIsEmpty"); |
|
|
|
loadProc(image_get_width, "ltsImageGetWidth"); |
|
|
|
loadProc(image_get_height, "ltsImageGetHeight"); |
|
|
|
loadProc(image_get_line_size, "ltsImageGetLineSize"); |
|
|
|
loadProc(image_get_data_size, "ltsImageGetDataSize"); |
|
|
|
loadProc(image_get_format, "ltsImageGetFormat"); |
|
|
|
loadProc(image_get_data, "ltsImageGetData"); |
|
|
|
loadProc(image_get_scanline, "ltsImageGetScanline"); |
|
|
|
loadProc(image_get_pixel_at, "ltsImageGetPixelAt"); |
|
|
|
loadProc(image_assign, "ltsImageAssign"); |
|
|
|
loadProc(image_create_empty, "ltsImageCreateEmpty"); |
|
|
|
loadProc(image_load_from_func, "ltsImageLoadFromFunc"); |
|
|
|
loadProc(image_resize, "ltsImageResize"); |
|
|
|
loadProc(image_fill_color, "ltsImageFillColor"); |
|
|
|
loadProc(image_fill_pattern, "ltsImageFillPattern"); |
|
|
|
loadProc(image_blend, "ltsImageBlend"); |
|
|
|
loadProc(image_blur, "ltsImageBlur"); |
|
|
|
loadProc(image_destroy, "ltsImageDestroy"); |
|
|
|
|
|
|
|
loadProc(post_processor_add_range, "ltsPostProcessorAddRange"); |
|
|
|
loadProc(post_processor_add_chars, "ltsPostProcessorAddChars"); |
|
|
|
loadProc(post_processor_clear_ranges, "ltsPostProcessorClearRanges"); |
|
|
|
loadProc(post_processor_execute, "ltsPostProcessorExecute"); |
|
|
|
loadProc(post_processor_fill_color_create, "ltsPostProcessorFillColorCreate"); |
|
|
|
loadProc(post_processor_fill_pattern_create, "ltsPostProcessorFillPatterCreate"); |
|
|
|
loadProc(post_processor_border_create, "ltsPostProcessorBorderCreate"); |
|
|
|
loadProc(post_processor_shadow_create, "ltsPostProcessorShadowCreate"); |
|
|
|
loadProc(post_processor_custom_create, "ltsPostProcessorCustomCreate"); |
|
|
|
loadProc(post_processor_destroy, "ltsPostProcessorDestroy"); |
|
|
|
|
|
|
|
loadProc(char_get_char_code, "ltsCharGetCharCode"); |
|
|
|
loadProc(char_get_glyph_metric, "ltsCharGetGlyphMetric"); |
|
|
|
loadProc(char_set_glyph_metric, "ltsCharSetGlyphMetric"); |
|
|
|
|
|
|
|
loadProc(initialize, "ltsInitialize"); |
|
|
|
loadProc(get_last_error_code, "ltsGetLastErrorCode"); |
|
|
|
loadProc(get_last_error_msg, "ltsGetLastErrorMsg"); |
|
|
|
loadProc(finalize, "ltsFinalize"); |
|
|
|
|
|
|
|
auto err = initialize(); |
|
|
|
if (err != ErrorCode::None) |
|
|
|
throw Exception(std::string("unable to initialize library: ") + get_last_error_msg(), get_last_error_code()); |
|
|
|
}; |
|
|
|
|
|
|
|
~Impl() |
|
|
|
{ |
|
|
|
finalize(); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
/* Exception **********************************************************************************************************************/ |
|
|
|
inline lts::ErrorCode lts::Exception::getErrorCode() const |
|
|
|
{ return _errorCode; } |
|
|
|
|
|
|
|
inline std::string lts::Exception::getMessage() const |
|
|
|
{ return _message; } |
|
|
|
|
|
|
|
const char* lts::Exception::what() const throw() |
|
|
|
{ return _message.c_str(); }; |
|
|
|
|
|
|
|
lts::Exception::Exception(std::string message, ErrorCode errorCode) : |
|
|
|
_message (message), |
|
|
|
_errorCode (errorCode) |
|
|
|
{ } |
|
|
|
|
|
|
|
lts::Exception::~Exception() throw() |
|
|
|
{ } |
|
|
|
|
|
|
|
/* Library ************************************************************************************************************************/ |
|
|
|
inline lts::ErrorCode lts::Library::getLastErrorCode() const |
|
|
|
{ return _impl->get_last_error_code(); } |
|
|
|
|
|
|
|
inline std::string lts::Library::getLastErrorMsg() const |
|
|
|
{ return std::string(_impl->get_last_error_msg()); } |
|
|
|
|
|
|
|
lts::Library::Library(const std::string& libName) : |
|
|
|
_handle (0), |
|
|
|
_impl (NULL) |
|
|
|
{ |
|
|
|
_handle = libOpen(libName.c_str()); |
|
|
|
if (!_handle) |
|
|
|
throw Exception("unable to open shared library: " + libName, lts::ErrorCode::InvalidLibHandle); |
|
|
|
} |
|
|
|
|
|
|
|
lts::Library::~Library() |
|
|
|
{ |
|
|
|
if (_impl) |
|
|
|
{ |
|
|
|
delete _impl; |
|
|
|
_impl = NULL; |
|
|
|
} |
|
|
|
if (_handle) |
|
|
|
{ |
|
|
|
libClose(_handle); |
|
|
|
_handle = NULL; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/* Context ************************************************************************************************************************/ |
|
|
|
|
|
|
|
|
|
|
|
#endif /* LIB_TEXT_SUITE_HPP */ |