diff options
author | Michele Calgaro <michele.calgaro@yahoo.it> | 2024-06-07 23:30:05 +0900 |
---|---|---|
committer | Michele Calgaro <michele.calgaro@yahoo.it> | 2024-06-07 23:30:05 +0900 |
commit | 17b259df9cb6b28779d4881b2b6c805ee2e48eea (patch) | |
tree | 5ed61937459cb7081089111b0242c01ec178f1f3 /reader/src/options | |
parent | 1cba8bce178eb2d6719c6f7f21e2c9352c5513a6 (diff) | |
download | tde-ebook-reader-17b259df9cb6b28779d4881b2b6c805ee2e48eea.tar.gz tde-ebook-reader-17b259df9cb6b28779d4881b2b6c805ee2e48eea.zip |
Rename to tde-ebook-reader
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
Diffstat (limited to 'reader/src/options')
-rw-r--r-- | reader/src/options/FBCategoryKey.cpp | 27 | ||||
-rw-r--r-- | reader/src/options/FBCategoryKey.h | 36 | ||||
-rw-r--r-- | reader/src/options/FBOptions.cpp | 64 | ||||
-rw-r--r-- | reader/src/options/FBOptions.h | 65 | ||||
-rw-r--r-- | reader/src/options/FBTextStyle.cpp | 107 | ||||
-rw-r--r-- | reader/src/options/FBTextStyle.h | 71 |
6 files changed, 370 insertions, 0 deletions
diff --git a/reader/src/options/FBCategoryKey.cpp b/reader/src/options/FBCategoryKey.cpp new file mode 100644 index 0000000..b1ab431 --- /dev/null +++ b/reader/src/options/FBCategoryKey.cpp @@ -0,0 +1,27 @@ +/* + * 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. + */ + +#include "FBCategoryKey.h" + +FBCategoryKey::FBCategoryKey(const std::string &name) : ZLCategoryKey(name) { +} + +const FBCategoryKey FBCategoryKey::BOOKS("books"); +const FBCategoryKey FBCategoryKey::SEARCH("search"); +const FBCategoryKey FBCategoryKey::EXTERNAL("external"); diff --git a/reader/src/options/FBCategoryKey.h b/reader/src/options/FBCategoryKey.h new file mode 100644 index 0000000..8550340 --- /dev/null +++ b/reader/src/options/FBCategoryKey.h @@ -0,0 +1,36 @@ +/* + * 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 __FBCATEGORYKEY_H__ +#define __FBCATEGORYKEY_H__ + +#include <ZLOptions.h> + +class FBCategoryKey : public ZLCategoryKey { + +public: + static const FBCategoryKey BOOKS; + static const FBCategoryKey SEARCH; + static const FBCategoryKey EXTERNAL; + +private: + FBCategoryKey(const std::string &name); +}; + +#endif /* __FBCATEGORYKEY_H__ */ diff --git a/reader/src/options/FBOptions.cpp b/reader/src/options/FBOptions.cpp new file mode 100644 index 0000000..c7d8f97 --- /dev/null +++ b/reader/src/options/FBOptions.cpp @@ -0,0 +1,64 @@ +/* + * 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. + */ + +#include "FBOptions.h" + +FBOptions* FBOptions::ourInstance = 0; + +static const std::string OPTIONS = "Options"; +static const std::string COLORS = "Colors"; + +FBOptions::FBOptions() : + LeftMarginOption(ZLCategoryKey::LOOK_AND_FEEL, OPTIONS, "LeftMargin", 0, 1000, 4), + RightMarginOption(ZLCategoryKey::LOOK_AND_FEEL, OPTIONS, "RightMargin", 0, 1000, 4), + TopMarginOption(ZLCategoryKey::LOOK_AND_FEEL, OPTIONS, "TopMargin", 0, 1000, 0), + BottomMarginOption(ZLCategoryKey::LOOK_AND_FEEL, OPTIONS, "BottomMargin", 0, 1000, 4), + BackgroundColorOption(ZLCategoryKey::LOOK_AND_FEEL, COLORS, "Background", ZLColor(255, 255, 255)), + RegularTextColorOption(ZLCategoryKey::LOOK_AND_FEEL, COLORS, "Text", ZLColor(0, 0, 0)) { + myColorOptions["internal"] = new ZLColorOption( + ZLCategoryKey::LOOK_AND_FEEL, COLORS, + "Hyperlink", ZLColor(33, 96, 180) + ); + myColorOptions["external"] = new ZLColorOption( + ZLCategoryKey::LOOK_AND_FEEL, COLORS, + "ExternalHyperlink", ZLColor(33, 96, 180) + ); + myColorOptions["book"] = new ZLColorOption( + ZLCategoryKey::LOOK_AND_FEEL, COLORS, + "BookHyperlink", ZLColor(23, 68, 128) + ); + myColorOptions[ZLTextStyle::SELECTION_BACKGROUND] = new ZLColorOption( + ZLCategoryKey::LOOK_AND_FEEL, COLORS, + "SelectionBackground", ZLColor(82, 131, 194) + ); + myColorOptions[ZLTextStyle::HIGHLIGHTED_TEXT] = new ZLColorOption( + ZLCategoryKey::LOOK_AND_FEEL, COLORS, + "SelectedText", ZLColor(60, 139, 255) + ); + myColorOptions[ZLTextStyle::TREE_LINES] = new ZLColorOption( + ZLCategoryKey::LOOK_AND_FEEL, COLORS, + "TreeLines", ZLColor(127, 127, 127) + ); +} + +ZLColorOption &FBOptions::colorOption(const std::string &style) { + std::map<std::string,shared_ptr<ZLColorOption> >::const_iterator it = + myColorOptions.find(style); + return it != myColorOptions.end() ? *it->second : RegularTextColorOption; +} diff --git a/reader/src/options/FBOptions.h b/reader/src/options/FBOptions.h new file mode 100644 index 0000000..be1e1fc --- /dev/null +++ b/reader/src/options/FBOptions.h @@ -0,0 +1,65 @@ +/* + * 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 __FBOPTIONS_H__ +#define __FBOPTIONS_H__ + +#include <string> +#include <map> + +#include <shared_ptr.h> + +#include <ZLOptions.h> +#include <ZLTextStyle.h> + +class FBOptions { + +public: + static FBOptions& Instance(); + +private: + static FBOptions *ourInstance; + +public: + ZLIntegerRangeOption LeftMarginOption; + ZLIntegerRangeOption RightMarginOption; + ZLIntegerRangeOption TopMarginOption; + ZLIntegerRangeOption BottomMarginOption; + ZLColorOption BackgroundColorOption; + ZLColorOption RegularTextColorOption; + + ZLColorOption &colorOption(const std::string &style); + +private: + FBOptions(); + FBOptions(const FBOptions&); + const FBOptions &operator = (const FBOptions&); + +private: + std::map<std::string,shared_ptr<ZLColorOption> > myColorOptions; +}; + +inline FBOptions& FBOptions::Instance() { + if (ourInstance == 0) { + ourInstance = new FBOptions(); + } + return *ourInstance; +} + +#endif /* __FBOPTIONS_H__ */ diff --git a/reader/src/options/FBTextStyle.cpp b/reader/src/options/FBTextStyle.cpp new file mode 100644 index 0000000..c8ad9c5 --- /dev/null +++ b/reader/src/options/FBTextStyle.cpp @@ -0,0 +1,107 @@ +/* + * 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. + */ + +#include <ZLOptions.h> + +#include "FBTextStyle.h" + +shared_ptr<ZLTextStyle> FBTextStyle::ourInstance; + +shared_ptr<ZLTextStyle> FBTextStyle::InstanceAsPtr() { + if (ourInstance.isNull()) { + ourInstance = new FBTextStyle(); + } + return ourInstance; +} + +FBTextStyle &FBTextStyle::Instance() { + return (FBTextStyle&)*InstanceAsPtr(); +} + +static const std::string GROUP = "Style"; + +FBTextStyle::FBTextStyle() : + FontFamilyOption(ZLCategoryKey::LOOK_AND_FEEL, GROUP, "Base:fontFamily", ""), + FontSizeOption(ZLCategoryKey::LOOK_AND_FEEL, GROUP, "Base:fontSize", 5, 72, 26), + BoldOption(ZLCategoryKey::LOOK_AND_FEEL, GROUP, "Base:bold", false), + ItalicOption(ZLCategoryKey::LOOK_AND_FEEL, GROUP, "Base:italic", false), + AlignmentOption(ZLCategoryKey::LOOK_AND_FEEL, GROUP, "Base:alignment", ALIGN_JUSTIFY), + LineSpaceOption(ZLCategoryKey::LOOK_AND_FEEL, GROUP, "Base:lineSpacing", 1.4), + LineSpacePercentOption(ZLCategoryKey::LOOK_AND_FEEL, GROUP, "Base:lineSpacingPercent", 140) { +} + +const std::string &FBTextStyle::colorStyle() const { + return REGULAR_TEXT; +} + +bool FBTextStyle::isDecorated() const { + return false; +} + +const std::string &FBTextStyle::fontFamily() const { + return FontFamilyOption.value(); +} + +int FBTextStyle::fontSize() const { + return FontSizeOption.value(); +} + +bool FBTextStyle::bold() const { + return BoldOption.value(); +} + +bool FBTextStyle::italic() const { + return ItalicOption.value(); +} + +short FBTextStyle::spaceBefore(const ZLTextStyleEntry::Metrics&) const { + return 0; +} + +short FBTextStyle::spaceAfter(const ZLTextStyleEntry::Metrics&) const { + return 0; +} + +short FBTextStyle::lineStartIndent(const ZLTextStyleEntry::Metrics&, bool) const { + return 0; +} + +short FBTextStyle::lineEndIndent(const ZLTextStyleEntry::Metrics&, bool) const { + return 0; +} + +short FBTextStyle::firstLineIndentDelta(const ZLTextStyleEntry::Metrics&) const { + return 0; +} + +int FBTextStyle::verticalShift() const { + return 0; +} + +ZLTextAlignmentType FBTextStyle::alignment() const { + return (ZLTextAlignmentType)AlignmentOption.value(); +} + +double FBTextStyle::lineSpace() const { + return LineSpacePercentOption.value() / 100.0; +} + +bool FBTextStyle::allowHyphenations() const { + return true; +} diff --git a/reader/src/options/FBTextStyle.h b/reader/src/options/FBTextStyle.h new file mode 100644 index 0000000..8bc0762 --- /dev/null +++ b/reader/src/options/FBTextStyle.h @@ -0,0 +1,71 @@ +/* + * 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 __FBTEXTSTYLE_H__ +#define __FBTEXTSTYLE_H__ + +#include <ZLTextStyle.h> + +class FBTextStyle : public ZLTextStyle { + +public: + static shared_ptr<ZLTextStyle> InstanceAsPtr(); + static FBTextStyle &Instance(); + +private: + static shared_ptr<ZLTextStyle> ourInstance; + +private: + FBTextStyle(); + +public: + bool isDecorated() const; + + const std::string &fontFamily() const; + + int fontSize() const; + bool bold() const; + bool italic() const; + + const std::string &colorStyle() const; + + short spaceBefore(const ZLTextStyleEntry::Metrics &metrics) const; + short spaceAfter(const ZLTextStyleEntry::Metrics &metrics) const; + short lineStartIndent(const ZLTextStyleEntry::Metrics &metrics, bool rtl) const; + short lineEndIndent(const ZLTextStyleEntry::Metrics &metrics, bool rtl) const; + short firstLineIndentDelta(const ZLTextStyleEntry::Metrics &metrics) const; + int verticalShift() const; + + ZLTextAlignmentType alignment() const; + + double lineSpace() const; + + bool allowHyphenations() const; + +public: + ZLStringOption FontFamilyOption; + ZLIntegerRangeOption FontSizeOption; + ZLBooleanOption BoldOption; + ZLBooleanOption ItalicOption; + ZLIntegerOption AlignmentOption; + ZLDoubleOption LineSpaceOption; + ZLIntegerOption LineSpacePercentOption; +}; + +#endif /* __FBTEXTSTYLE_H__ */ |