mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-04 18:29:23 +02:00
refactoring: ZLTextStyleEntry has been moved to a separate header
This commit is contained in:
parent
7a3c54c00a
commit
2422f080a8
12 changed files with 188 additions and 161 deletions
|
@ -24,6 +24,7 @@
|
||||||
#include <ZLFileImage.h>
|
#include <ZLFileImage.h>
|
||||||
#include <ZLLogger.h>
|
#include <ZLLogger.h>
|
||||||
#include <ZLCachedMemoryAllocator.h>
|
#include <ZLCachedMemoryAllocator.h>
|
||||||
|
#include <ZLTextStyleEntry.h>
|
||||||
|
|
||||||
#include "BookReader.h"
|
#include "BookReader.h"
|
||||||
#include "BookModel.h"
|
#include "BookModel.h"
|
||||||
|
|
|
@ -33,6 +33,7 @@ class BookModel;
|
||||||
class ZLTextModel;
|
class ZLTextModel;
|
||||||
class ZLInputStream;
|
class ZLInputStream;
|
||||||
class ZLCachedMemoryAllocator;
|
class ZLCachedMemoryAllocator;
|
||||||
|
class ZLTextStyleEntry;
|
||||||
|
|
||||||
class BookReader {
|
class BookReader {
|
||||||
|
|
||||||
|
|
|
@ -160,28 +160,26 @@ shared_ptr<ZLTextStyleEntry> StyleSheetTable::createControl(const AttributeMap &
|
||||||
num = 700;
|
num = 700;
|
||||||
} else if (bold[0] == "normal") {
|
} else if (bold[0] == "normal") {
|
||||||
num = 400;
|
num = 400;
|
||||||
} else if ((bold[0].length() == 3) &&
|
|
||||||
(bold[0][1] == '0') &&
|
|
||||||
(bold[0][2] == '0') &&
|
|
||||||
(bold[0][0] >= '1') &&
|
|
||||||
(bold[0][0] <= '9')) {
|
|
||||||
num = 100 * (bold[0][0] - '0');
|
|
||||||
} else if (bold[0] == "bolder") {
|
} else if (bold[0] == "bolder") {
|
||||||
|
// TODO: implement
|
||||||
} else if (bold[0] == "lighter") {
|
} else if (bold[0] == "lighter") {
|
||||||
|
// TODO: implement
|
||||||
|
} else {
|
||||||
|
num = ZLStringUtil::stringToInteger(bold[0], -1);
|
||||||
}
|
}
|
||||||
if (num != -1) {
|
if (num != -1) {
|
||||||
entry->setFontModifier(FONT_MODIFIER_BOLD, num >= 600);
|
entry->setFontModifier(ZLTextStyleEntry::FONT_MODIFIER_BOLD, num >= 600);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<std::string> &italic = values(styles, "font-style");
|
const std::vector<std::string> &italic = values(styles, "font-style");
|
||||||
if (!italic.empty()) {
|
if (!italic.empty()) {
|
||||||
entry->setFontModifier(FONT_MODIFIER_ITALIC, italic[0] == "italic");
|
entry->setFontModifier(ZLTextStyleEntry::FONT_MODIFIER_ITALIC, italic[0] == "italic");
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<std::string> &variant = values(styles, "font-variant");
|
const std::vector<std::string> &variant = values(styles, "font-variant");
|
||||||
if (!variant.empty()) {
|
if (!variant.empty()) {
|
||||||
entry->setFontModifier(FONT_MODIFIER_SMALLCAPS, variant[0] == "small-caps");
|
entry->setFontModifier(ZLTextStyleEntry::FONT_MODIFIER_SMALLCAPS, variant[0] == "small-caps");
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<std::string> &fontFamily = values(styles, "font-family");
|
const std::vector<std::string> &fontFamily = values(styles, "font-family");
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include <shared_ptr.h>
|
#include <shared_ptr.h>
|
||||||
|
|
||||||
#include <ZLTextParagraph.h>
|
#include <ZLTextParagraph.h>
|
||||||
|
#include <ZLTextStyleEntry.h>
|
||||||
|
|
||||||
class StyleSheetTable {
|
class StyleSheetTable {
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
#include <ZLStringUtil.h>
|
#include <ZLStringUtil.h>
|
||||||
#include <ZLFileImage.h>
|
#include <ZLFileImage.h>
|
||||||
|
#include <ZLTextStyleEntry.h>
|
||||||
|
|
||||||
#include "RtfBookReader.h"
|
#include "RtfBookReader.h"
|
||||||
#include "../../bookmodel/BookModel.h"
|
#include "../../bookmodel/BookModel.h"
|
||||||
|
|
|
@ -105,11 +105,28 @@ std::string ZLStringUtil::doubleToString(double value) {
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
double ZLStringUtil::stringToDouble(const std::string &value, double defaultValue) {
|
double ZLStringUtil::stringToDouble(const std::string &str, double defaultValue) {
|
||||||
if (!value.empty()) {
|
if (!str.empty()) {
|
||||||
setlocale(LC_NUMERIC, "C");
|
setlocale(LC_NUMERIC, "C");
|
||||||
return atof(value.c_str());
|
return atof(str.c_str());
|
||||||
} else {
|
} else {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ZLStringUtil::stringToInteger(const std::string &str, int defaultValue) {
|
||||||
|
if (str.empty()) {
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
if (!isdigit(str[0]) && (str.length() == 1 || str[0] != '-' || !isdigit(str[1]))) {
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (size_t i = 1; i < str.length(); ++i) {
|
||||||
|
if (!isdigit(str[i])) {
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return atoi(str.c_str());
|
||||||
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ private:
|
||||||
public:
|
public:
|
||||||
static bool stringStartsWith(const std::string &str, const std::string &start);
|
static bool stringStartsWith(const std::string &str, const std::string &start);
|
||||||
static bool stringEndsWith(const std::string &str, const std::string &end);
|
static bool stringEndsWith(const std::string &str, const std::string &end);
|
||||||
|
|
||||||
static void appendNumber(std::string &str, unsigned int n);
|
static void appendNumber(std::string &str, unsigned int n);
|
||||||
static void append(std::string &str, const std::vector<std::string> &buffer);
|
static void append(std::string &str, const std::vector<std::string> &buffer);
|
||||||
static void stripWhiteSpaces(std::string &str);
|
static void stripWhiteSpaces(std::string &str);
|
||||||
|
@ -39,6 +40,7 @@ public:
|
||||||
|
|
||||||
static std::string doubleToString(double value);
|
static std::string doubleToString(double value);
|
||||||
static double stringToDouble(const std::string &value, double defaultValue);
|
static double stringToDouble(const std::string &value, double defaultValue);
|
||||||
|
static int stringToInteger(const std::string &str, int defaultValue);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* __ZLSTRINGUTIL_H__ */
|
#endif /* __ZLSTRINGUTIL_H__ */
|
||||||
|
|
|
@ -1,30 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
||||||
* 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __ZLTEXTFONTMODIFIER_H__
|
|
||||||
#define __ZLTEXTFONTMODIFIER_H__
|
|
||||||
|
|
||||||
enum ZLTextFontModifier {
|
|
||||||
FONT_MODIFIER_DEFAULT = 0,
|
|
||||||
FONT_MODIFIER_BOLD = 1 << 0,
|
|
||||||
FONT_MODIFIER_ITALIC = 1 << 1,
|
|
||||||
FONT_MODIFIER_SMALLCAPS = 1 << 2,
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* __ZLTEXTFONTMODIFIER_H__ */
|
|
|
@ -32,8 +32,7 @@
|
||||||
//#include <ZLTextMark.h>
|
//#include <ZLTextMark.h>
|
||||||
#include <ZLCachedMemoryAllocator.h>
|
#include <ZLCachedMemoryAllocator.h>
|
||||||
|
|
||||||
class ZLTextParagraph;
|
class ZLTextStyleEntry;
|
||||||
class ZLTextTreeParagraph;
|
|
||||||
|
|
||||||
class ZLTextModel {
|
class ZLTextModel {
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
#include "ZLCachedMemoryAllocator.h"
|
#include "ZLCachedMemoryAllocator.h"
|
||||||
#include "ZLTextParagraph.h"
|
#include "ZLTextParagraph.h"
|
||||||
|
#include "ZLTextStyleEntry.h"
|
||||||
|
|
||||||
const shared_ptr<ZLTextParagraphEntry> ResetBidiEntry::Instance = new ResetBidiEntry();
|
const shared_ptr<ZLTextParagraphEntry> ResetBidiEntry::Instance = new ResetBidiEntry();
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,6 @@
|
||||||
#include <ZLHyperlinkType.h>
|
#include <ZLHyperlinkType.h>
|
||||||
#include <ZLTextKind.h>
|
#include <ZLTextKind.h>
|
||||||
#include <ZLTextAlignmentType.h>
|
#include <ZLTextAlignmentType.h>
|
||||||
#include <ZLTextFontModifier.h>
|
|
||||||
|
|
||||||
class ZLImage;
|
class ZLImage;
|
||||||
typedef std::map<std::string,shared_ptr<const ZLImage> > ZLImageMap;
|
typedef std::map<std::string,shared_ptr<const ZLImage> > ZLImageMap;
|
||||||
|
@ -58,85 +57,6 @@ private: // disable copying
|
||||||
const ZLTextParagraphEntry &operator = (const ZLTextParagraphEntry &entry);
|
const ZLTextParagraphEntry &operator = (const ZLTextParagraphEntry &entry);
|
||||||
};
|
};
|
||||||
|
|
||||||
class ZLTextStyleEntry : public ZLTextParagraphEntry {
|
|
||||||
|
|
||||||
public:
|
|
||||||
enum SizeUnit {
|
|
||||||
SIZE_UNIT_PIXEL,
|
|
||||||
SIZE_UNIT_EM_100,
|
|
||||||
SIZE_UNIT_EX_100,
|
|
||||||
SIZE_UNIT_PERCENT
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Metrics {
|
|
||||||
Metrics(int fontSize, int fontXHeight, int fullWidth, int fullHeight);
|
|
||||||
|
|
||||||
int FontSize;
|
|
||||||
int FontXHeight;
|
|
||||||
int FullWidth;
|
|
||||||
int FullHeight;
|
|
||||||
};
|
|
||||||
|
|
||||||
enum Length {
|
|
||||||
LENGTH_LEFT_INDENT = 0,
|
|
||||||
LENGTH_RIGHT_INDENT = 1,
|
|
||||||
LENGTH_FIRST_LINE_INDENT_DELTA = 2,
|
|
||||||
LENGTH_SPACE_BEFORE = 3,
|
|
||||||
LENGTH_SPACE_AFTER = 4,
|
|
||||||
NUMBER_OF_LENGTHS = 5,
|
|
||||||
};
|
|
||||||
|
|
||||||
private:
|
|
||||||
struct LengthType {
|
|
||||||
SizeUnit Unit;
|
|
||||||
short Size;
|
|
||||||
};
|
|
||||||
|
|
||||||
public:
|
|
||||||
ZLTextStyleEntry();
|
|
||||||
ZLTextStyleEntry(char *address);
|
|
||||||
~ZLTextStyleEntry();
|
|
||||||
|
|
||||||
bool isEmpty() const;
|
|
||||||
|
|
||||||
bool isLengthSupported(Length name) const;
|
|
||||||
short length(Length name, const Metrics &metrics) const;
|
|
||||||
void setLength(Length name, short length, SizeUnit unit);
|
|
||||||
|
|
||||||
bool isAlignmentTypeSupported() const;
|
|
||||||
ZLTextAlignmentType alignmentType() const;
|
|
||||||
void setAlignmentType(ZLTextAlignmentType alignmentType);
|
|
||||||
|
|
||||||
unsigned char supportedFontModifier() const;
|
|
||||||
unsigned char fontModifier() const;
|
|
||||||
void setFontModifier(ZLTextFontModifier style, bool set);
|
|
||||||
|
|
||||||
bool isFontSizeMagSupported() const;
|
|
||||||
signed char fontSizeMag() const;
|
|
||||||
void setFontSizeMag(signed char fontSizeMag);
|
|
||||||
|
|
||||||
bool isFontFamilySupported() const;
|
|
||||||
const std::string &fontFamily() const;
|
|
||||||
void setFontFamily(const std::string &fontFamily);
|
|
||||||
|
|
||||||
static const unsigned int SUPPORTS_ALIGNMENT_TYPE = 1U << NUMBER_OF_LENGTHS;
|
|
||||||
static const unsigned int SUPPORTS_FONT_SIZE_MAG = 1U << (NUMBER_OF_LENGTHS + 1);
|
|
||||||
static const unsigned int SUPPORTS_FONT_FAMILY = 1U << (NUMBER_OF_LENGTHS + 2);
|
|
||||||
|
|
||||||
private:
|
|
||||||
unsigned int myMask;
|
|
||||||
|
|
||||||
LengthType myLengths[NUMBER_OF_LENGTHS];
|
|
||||||
|
|
||||||
ZLTextAlignmentType myAlignmentType;
|
|
||||||
unsigned char mySupportedFontModifier;
|
|
||||||
unsigned char myFontModifier;
|
|
||||||
signed char myFontSizeMag;
|
|
||||||
std::string myFontFamily;
|
|
||||||
|
|
||||||
friend class ZLTextModel;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ZLTextControlEntry : public ZLTextParagraphEntry {
|
class ZLTextControlEntry : public ZLTextParagraphEntry {
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -330,43 +250,6 @@ private:
|
||||||
inline ZLTextParagraphEntry::ZLTextParagraphEntry() {}
|
inline ZLTextParagraphEntry::ZLTextParagraphEntry() {}
|
||||||
inline ZLTextParagraphEntry::~ZLTextParagraphEntry() {}
|
inline ZLTextParagraphEntry::~ZLTextParagraphEntry() {}
|
||||||
|
|
||||||
inline ZLTextStyleEntry::ZLTextStyleEntry() : myMask(0), myAlignmentType(ALIGN_UNDEFINED), mySupportedFontModifier(0), myFontModifier(0), myFontSizeMag(0) {}
|
|
||||||
inline ZLTextStyleEntry::~ZLTextStyleEntry() {}
|
|
||||||
|
|
||||||
inline ZLTextStyleEntry::Metrics::Metrics(int fontSize, int fontXHeight, int fullWidth, int fullHeight) : FontSize(fontSize), FontXHeight(fontXHeight), FullWidth(fullWidth), FullHeight(fullHeight) {}
|
|
||||||
|
|
||||||
inline bool ZLTextStyleEntry::isEmpty() const { return myMask == 0; }
|
|
||||||
|
|
||||||
inline bool ZLTextStyleEntry::isLengthSupported(Length name) const { return (myMask & (1U << name)) != 0; }
|
|
||||||
inline void ZLTextStyleEntry::setLength(Length name, short length, SizeUnit unit) {
|
|
||||||
myLengths[name].Size = length;
|
|
||||||
myLengths[name].Unit = unit;
|
|
||||||
myMask |= 1U << name;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool ZLTextStyleEntry::isAlignmentTypeSupported() const { return (myMask & SUPPORTS_ALIGNMENT_TYPE) == SUPPORTS_ALIGNMENT_TYPE; }
|
|
||||||
inline ZLTextAlignmentType ZLTextStyleEntry::alignmentType() const { return myAlignmentType; }
|
|
||||||
inline void ZLTextStyleEntry::setAlignmentType(ZLTextAlignmentType alignmentType) { myAlignmentType = alignmentType; myMask |= SUPPORTS_ALIGNMENT_TYPE; }
|
|
||||||
|
|
||||||
inline unsigned char ZLTextStyleEntry::supportedFontModifier() const { return mySupportedFontModifier; }
|
|
||||||
inline unsigned char ZLTextStyleEntry::fontModifier() const { return myFontModifier; }
|
|
||||||
inline void ZLTextStyleEntry::setFontModifier(ZLTextFontModifier style, bool set) {
|
|
||||||
if (set) {
|
|
||||||
myFontModifier |= style;
|
|
||||||
} else {
|
|
||||||
myFontModifier &= ~style;
|
|
||||||
}
|
|
||||||
mySupportedFontModifier |= style;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool ZLTextStyleEntry::isFontSizeMagSupported() const { return (myMask & SUPPORTS_FONT_SIZE_MAG) == SUPPORTS_FONT_SIZE_MAG; }
|
|
||||||
inline signed char ZLTextStyleEntry::fontSizeMag() const { return myFontSizeMag; }
|
|
||||||
inline void ZLTextStyleEntry::setFontSizeMag(signed char fontSizeMag) { myFontSizeMag = fontSizeMag; myMask |= SUPPORTS_FONT_SIZE_MAG; }
|
|
||||||
|
|
||||||
inline bool ZLTextStyleEntry::isFontFamilySupported() const { return (myMask & SUPPORTS_FONT_FAMILY) == SUPPORTS_FONT_FAMILY; }
|
|
||||||
inline const std::string &ZLTextStyleEntry::fontFamily() const { return myFontFamily; }
|
|
||||||
inline void ZLTextStyleEntry::setFontFamily(const std::string &fontFamily) { myFontFamily = fontFamily; myMask |= SUPPORTS_FONT_FAMILY; }
|
|
||||||
|
|
||||||
inline ZLTextControlEntry::ZLTextControlEntry(ZLTextKind kind, bool isStart) : myKind(kind), myStart(isStart) {}
|
inline ZLTextControlEntry::ZLTextControlEntry(ZLTextKind kind, bool isStart) : myKind(kind), myStart(isStart) {}
|
||||||
inline ZLTextControlEntry::~ZLTextControlEntry() {}
|
inline ZLTextControlEntry::~ZLTextControlEntry() {}
|
||||||
inline ZLTextKind ZLTextControlEntry::kind() const { return myKind; }
|
inline ZLTextKind ZLTextControlEntry::kind() const { return myKind; }
|
||||||
|
|
153
jni/NativeFormats/zlibrary/text/src/model/ZLTextStyleEntry.h
Normal file
153
jni/NativeFormats/zlibrary/text/src/model/ZLTextStyleEntry.h
Normal file
|
@ -0,0 +1,153 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2004-2012 Geometer Plus <contact@geometerplus.com>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||||
|
* 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __ZLTEXTSTYLEENTRY_H__
|
||||||
|
#define __ZLTEXTSTYLEENTRY_H__
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include <ZLTextParagraph.h>
|
||||||
|
#include <ZLTextAlignmentType.h>
|
||||||
|
|
||||||
|
class ZLTextStyleEntry : public ZLTextParagraphEntry {
|
||||||
|
|
||||||
|
public:
|
||||||
|
enum SizeUnit {
|
||||||
|
SIZE_UNIT_PIXEL,
|
||||||
|
SIZE_UNIT_EM_100,
|
||||||
|
SIZE_UNIT_EX_100,
|
||||||
|
SIZE_UNIT_PERCENT
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Metrics {
|
||||||
|
Metrics(int fontSize, int fontXHeight, int fullWidth, int fullHeight);
|
||||||
|
|
||||||
|
int FontSize;
|
||||||
|
int FontXHeight;
|
||||||
|
int FullWidth;
|
||||||
|
int FullHeight;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum FontModifier {
|
||||||
|
FONT_MODIFIER_DEFAULT = 0,
|
||||||
|
FONT_MODIFIER_BOLD = 1 << 0,
|
||||||
|
FONT_MODIFIER_ITALIC = 1 << 1,
|
||||||
|
FONT_MODIFIER_UNDERLINED = 1 << 2,
|
||||||
|
FONT_MODIFIER_STRIKEDTHROUGH = 1 << 3,
|
||||||
|
FONT_MODIFIER_SMALLCAPS = 1 << 4,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum Length {
|
||||||
|
LENGTH_LEFT_INDENT = 0,
|
||||||
|
LENGTH_RIGHT_INDENT = 1,
|
||||||
|
LENGTH_FIRST_LINE_INDENT_DELTA = 2,
|
||||||
|
LENGTH_SPACE_BEFORE = 3,
|
||||||
|
LENGTH_SPACE_AFTER = 4,
|
||||||
|
NUMBER_OF_LENGTHS = 5,
|
||||||
|
};
|
||||||
|
|
||||||
|
static const unsigned int SUPPORTS_ALIGNMENT_TYPE = 1U << NUMBER_OF_LENGTHS;
|
||||||
|
static const unsigned int SUPPORTS_FONT_SIZE_MAG = 1U << (NUMBER_OF_LENGTHS + 1);
|
||||||
|
static const unsigned int SUPPORTS_FONT_FAMILY = 1U << (NUMBER_OF_LENGTHS + 2);
|
||||||
|
|
||||||
|
private:
|
||||||
|
struct LengthType {
|
||||||
|
SizeUnit Unit;
|
||||||
|
short Size;
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
ZLTextStyleEntry();
|
||||||
|
ZLTextStyleEntry(char *address);
|
||||||
|
~ZLTextStyleEntry();
|
||||||
|
|
||||||
|
bool isEmpty() const;
|
||||||
|
|
||||||
|
bool isLengthSupported(Length name) const;
|
||||||
|
short length(Length name, const Metrics &metrics) const;
|
||||||
|
void setLength(Length name, short length, SizeUnit unit);
|
||||||
|
|
||||||
|
bool isAlignmentTypeSupported() const;
|
||||||
|
ZLTextAlignmentType alignmentType() const;
|
||||||
|
void setAlignmentType(ZLTextAlignmentType alignmentType);
|
||||||
|
|
||||||
|
unsigned char supportedFontModifier() const;
|
||||||
|
unsigned char fontModifier() const;
|
||||||
|
void setFontModifier(FontModifier style, bool set);
|
||||||
|
|
||||||
|
bool isFontSizeMagSupported() const;
|
||||||
|
signed char fontSizeMag() const;
|
||||||
|
void setFontSizeMag(signed char fontSizeMag);
|
||||||
|
|
||||||
|
bool isFontFamilySupported() const;
|
||||||
|
const std::string &fontFamily() const;
|
||||||
|
void setFontFamily(const std::string &fontFamily);
|
||||||
|
|
||||||
|
private:
|
||||||
|
unsigned int myMask;
|
||||||
|
|
||||||
|
LengthType myLengths[NUMBER_OF_LENGTHS];
|
||||||
|
|
||||||
|
ZLTextAlignmentType myAlignmentType;
|
||||||
|
unsigned char mySupportedFontModifier;
|
||||||
|
unsigned char myFontModifier;
|
||||||
|
signed char myFontSizeMag;
|
||||||
|
std::string myFontFamily;
|
||||||
|
|
||||||
|
friend class ZLTextModel;
|
||||||
|
};
|
||||||
|
|
||||||
|
inline ZLTextStyleEntry::ZLTextStyleEntry() : myMask(0), myAlignmentType(ALIGN_UNDEFINED), mySupportedFontModifier(0), myFontModifier(0), myFontSizeMag(0) {}
|
||||||
|
inline ZLTextStyleEntry::~ZLTextStyleEntry() {}
|
||||||
|
|
||||||
|
inline ZLTextStyleEntry::Metrics::Metrics(int fontSize, int fontXHeight, int fullWidth, int fullHeight) : FontSize(fontSize), FontXHeight(fontXHeight), FullWidth(fullWidth), FullHeight(fullHeight) {}
|
||||||
|
|
||||||
|
inline bool ZLTextStyleEntry::isEmpty() const { return myMask == 0; }
|
||||||
|
|
||||||
|
inline bool ZLTextStyleEntry::isLengthSupported(Length name) const { return (myMask & (1U << name)) != 0; }
|
||||||
|
inline void ZLTextStyleEntry::setLength(Length name, short length, SizeUnit unit) {
|
||||||
|
myLengths[name].Size = length;
|
||||||
|
myLengths[name].Unit = unit;
|
||||||
|
myMask |= 1U << name;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool ZLTextStyleEntry::isAlignmentTypeSupported() const { return (myMask & SUPPORTS_ALIGNMENT_TYPE) == SUPPORTS_ALIGNMENT_TYPE; }
|
||||||
|
inline ZLTextAlignmentType ZLTextStyleEntry::alignmentType() const { return myAlignmentType; }
|
||||||
|
inline void ZLTextStyleEntry::setAlignmentType(ZLTextAlignmentType alignmentType) { myAlignmentType = alignmentType; myMask |= SUPPORTS_ALIGNMENT_TYPE; }
|
||||||
|
|
||||||
|
inline unsigned char ZLTextStyleEntry::supportedFontModifier() const { return mySupportedFontModifier; }
|
||||||
|
inline unsigned char ZLTextStyleEntry::fontModifier() const { return myFontModifier; }
|
||||||
|
inline void ZLTextStyleEntry::setFontModifier(FontModifier style, bool set) {
|
||||||
|
if (set) {
|
||||||
|
myFontModifier |= style;
|
||||||
|
} else {
|
||||||
|
myFontModifier &= ~style;
|
||||||
|
}
|
||||||
|
mySupportedFontModifier |= style;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool ZLTextStyleEntry::isFontSizeMagSupported() const { return (myMask & SUPPORTS_FONT_SIZE_MAG) == SUPPORTS_FONT_SIZE_MAG; }
|
||||||
|
inline signed char ZLTextStyleEntry::fontSizeMag() const { return myFontSizeMag; }
|
||||||
|
inline void ZLTextStyleEntry::setFontSizeMag(signed char fontSizeMag) { myFontSizeMag = fontSizeMag; myMask |= SUPPORTS_FONT_SIZE_MAG; }
|
||||||
|
|
||||||
|
inline bool ZLTextStyleEntry::isFontFamilySupported() const { return (myMask & SUPPORTS_FONT_FAMILY) == SUPPORTS_FONT_FAMILY; }
|
||||||
|
inline const std::string &ZLTextStyleEntry::fontFamily() const { return myFontFamily; }
|
||||||
|
inline void ZLTextStyleEntry::setFontFamily(const std::string &fontFamily) { myFontFamily = fontFamily; myMask |= SUPPORTS_FONT_FAMILY; }
|
||||||
|
|
||||||
|
#endif /* __ZLTEXTSTYLEENTRY_H__ */
|
Loading…
Add table
Add a link
Reference in a new issue