2 * Copyright (C) 2004-2008 Geometer Plus <contact@geometerplus.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 #include <ZLOptionsDialog.h>
22 #include <optionEntries/ZLSimpleOptionEntry.h>
24 #include <ZLTextStyle.h>
25 #include <ZLTextStyleOptions.h>
27 #include "FormatOptionsPage.h"
29 #include "../bookmodel/FBTextKind.h"
31 static const ZLResourceKey
KEY_STYLE("style");
32 static const ZLResourceKey
KEY_BASE("Base");
34 static const ZLResourceKey
KEY_DUMMY("");
35 static const ZLResourceKey
KEY_LINESPACING("lineSpacing");
36 static const ZLResourceKey
KEY_FIRSTLINEINDENT("firstLineIndent");
37 static const ZLResourceKey
KEY_ALIGNMENT("alignment");
38 static const ZLResourceKey
KEY_SPACEBEFORE("spaceBefore");
39 static const ZLResourceKey
KEY_SPACEAFTER("spaceAfter");
40 static const ZLResourceKey
KEY_LEFTINDENT("leftIndent");
41 static const ZLResourceKey
KEY_RIGHTINDENT("rightIndent");
43 FormatOptionsPage::FormatOptionsPage(ZLDialogContent
&dialogTab
) {
44 const ZLResource
&styleResource
= ZLResource::resource(KEY_STYLE
);
46 myComboEntry
= new ComboOptionEntry(*this, styleResource
[KEY_BASE
].value());
47 myComboEntry
->addValue(myComboEntry
->initialValue());
49 ZLTextStyleCollection
&collection
= ZLTextStyleCollection::instance();
50 ZLTextKind styles
[] = { REGULAR
, TITLE
, SECTION_TITLE
, SUBTITLE
, H1
, H2
, H3
, H4
, H5
, H6
, ANNOTATION
, EPIGRAPH
, PREFORMATTED
, AUTHOR
, DATE
, POEM_TITLE
, STANZA
, VERSE
};
51 const int STYLES_NUMBER
= sizeof(styles
) / sizeof(ZLTextKind
);
52 for (int i
= 0; i
< STYLES_NUMBER
; ++i
) {
53 const ZLTextStyleDecoration
*decoration
= collection
.decoration(styles
[i
]);
54 if (decoration
!= 0) {
55 myComboEntry
->addValue(styleResource
[decoration
->name()].value());
58 dialogTab
.addOption(ZLResourceKey("optionsFor"), myComboEntry
);
61 const std::string
&name
= myComboEntry
->initialValue();
62 ZLTextBaseStyle
&baseStyle
= collection
.baseStyle();
64 registerEntries(dialogTab
,
65 KEY_LINESPACING
, new ZLTextLineSpaceOptionEntry(baseStyle
.LineSpacePercentOption
, dialogTab
.resource(KEY_LINESPACING
), false),
66 KEY_DUMMY
, 0,//new ZLSimpleSpinOptionEntry("First Line Indent", baseStyle.firstLineIndentDeltaOption(), -300, 300, 1),
70 registerEntries(dialogTab
,
71 KEY_ALIGNMENT
, new ZLTextAlignmentOptionEntry(baseStyle
.AlignmentOption
, dialogTab
.resource(KEY_ALIGNMENT
), false),
77 for (int i
= 0; i
< STYLES_NUMBER
; ++i
) {
78 ZLTextStyleDecoration
*d
= collection
.decoration(styles
[i
]);
79 if ((d
!= 0) && (d
->isFullDecoration())) {
80 ZLTextFullStyleDecoration
*decoration
= (ZLTextFullStyleDecoration
*)d
;
81 const std::string
&name
= styleResource
[decoration
->name()].value();
83 registerEntries(dialogTab
,
84 KEY_SPACEBEFORE
, new ZLSimpleSpinOptionEntry(decoration
->SpaceBeforeOption
, 1),
85 KEY_LEFTINDENT
, new ZLSimpleSpinOptionEntry(decoration
->LeftIndentOption
, 1),
89 registerEntries(dialogTab
,
90 KEY_SPACEAFTER
, new ZLSimpleSpinOptionEntry(decoration
->SpaceAfterOption
, 1),
91 KEY_RIGHTINDENT
, new ZLSimpleSpinOptionEntry(decoration
->RightIndentOption
, 1),
95 registerEntries(dialogTab
,
96 KEY_LINESPACING
, new ZLTextLineSpaceOptionEntry(decoration
->LineSpacePercentOption
, dialogTab
.resource(KEY_LINESPACING
), true),
97 KEY_FIRSTLINEINDENT
, new ZLSimpleSpinOptionEntry(decoration
->FirstLineIndentDeltaOption
, 1),
101 registerEntries(dialogTab
,
102 KEY_ALIGNMENT
, new ZLTextAlignmentOptionEntry(decoration
->AlignmentOption
, dialogTab
.resource(KEY_ALIGNMENT
), true),
109 myComboEntry
->onValueSelected(0);