示例#1
0
ConfigPage::ConfigPage(FBReader &fbreader, ZLDialogContent &dialogTab) {
	ZLToggleBooleanOptionEntry *enableEntry =
		new ZLToggleBooleanOptionEntry(fbreader.ConfigAutoSavingOption);
	dialogTab.addOption(ZLResourceKey("autoSave"), enableEntry);

	ZLOptionEntry *timeoutEntry = new TimeoutEntry(fbreader.ConfigAutoSaveTimeoutOption);
	enableEntry->addDependentEntry(timeoutEntry);
	dialogTab.addOption(ZLResourceKey("timeout"), timeoutEntry);

	enableEntry->onStateChanged(enableEntry->initialState());
}
示例#2
0
void OptionsPage::registerEntry(ZLDialogContent &tab, ZLOptionEntry *entry, const std::string &name) {
	if (entry != 0) {
		entry->setVisible(false);
		myEntries[entry] = name;
	}
	tab.addOption(entry);
}
示例#3
0
void OptionsPage::registerEntries(ZLDialogContent &tab, ZLOptionEntry *entry0, ZLOptionEntry *entry1, const std::string &name) {
	if (entry0 != 0) {
		entry0->setVisible(false);
		myEntries[entry0] = name;
	}
	if (entry1 != 0) {
		entry1->setVisible(false);
		myEntries[entry1] = name;
	}
	tab.addOptions(entry0, entry1);
}
NetworkLibraryPage::NetworkLibraryPage(ZLDialogContent &dialogTab) {
	NetworkLinkCollection &linkCollection = NetworkLinkCollection::Instance();
	const size_t linkCollectionSize = linkCollection.size();
	for (size_t i = 0; i < linkCollectionSize; ++i) {
		NetworkLink &link = linkCollection.link(i);
		dialogTab.addOption(link.SiteName, "", new NetworkLinkBooleanOptionEntry(link.OnOption));
	}
	ZLNetworkManager &networkManager = ZLNetworkManager::Instance();
	if (!networkManager.providesProxyInfo()) {
		ZLToggleBooleanOptionEntry *useProxyEntry = new ZLToggleBooleanOptionEntry(networkManager.UseProxyOption());
		dialogTab.addOption(ZLResourceKey("useProxy"), useProxyEntry);
		ZLSimpleStringOptionEntry *proxyHostEntry = new ZLSimpleStringOptionEntry(networkManager.ProxyHostOption());
		dialogTab.addOption(ZLResourceKey("proxyHost"), proxyHostEntry);
		ZLSimpleStringOptionEntry *proxyPortEntry = new ZLSimpleStringOptionEntry(networkManager.ProxyPortOption());
		dialogTab.addOption(ZLResourceKey("proxyPort"), proxyPortEntry);
		useProxyEntry->addDependentEntry(proxyHostEntry);
		useProxyEntry->addDependentEntry(proxyPortEntry);
		useProxyEntry->onStateChanged(useProxyEntry->initialState());
	}
	dialogTab.addOption(ZLResourceKey("timeout"), new ZLSimpleSpinOptionEntry(networkManager.TimeoutOption(), 5));
}
KeyBindingsPage::KeyBindingsPage(FBReader &fbreader, ZLDialogContent &dialogTab) {
	if (ZLBooleanOption(ZLCategoryKey::EMPTY, ZLOption::PLATFORM_GROUP, ZLOption::FULL_KEYBOARD_CONTROL, false).value()) {
		dialogTab.addOption(ZLResourceKey("grabSystemKeys"), new KeyboardControlEntry(fbreader));
	}
	ZLResourceKey actionKey("action");
	MultiKeyOptionEntry *keyEntry = new MultiKeyOptionEntry(dialogTab.resource(actionKey), fbreader);
	OrientationEntry *orientationEntry = new OrientationEntry(*keyEntry);
	ZLBooleanOptionEntry *useSeparateBindingsEntry = new UseSeparateOptionsEntry(fbreader, *keyEntry, *orientationEntry);
	dialogTab.addOption(ZLResourceKey("separate"), useSeparateBindingsEntry);
	dialogTab.addOption(ZLResourceKey("orientation"), orientationEntry);
	dialogTab.addOption("", "", keyEntry);
	ZLOptionEntry *exitOnCancelEntry = new ZLSimpleBooleanOptionEntry(fbreader.QuitOnCancelOption);
	keyEntry->setExitOnCancelEntry(exitOnCancelEntry);
	dialogTab.addOption(ZLResourceKey("quitOnCancel"), exitOnCancelEntry);
	exitOnCancelEntry->setVisible(false);
	useSeparateBindingsEntry->onStateChanged(useSeparateBindingsEntry->initialState());
	dialogTab.addOption(ZLResourceKey("keyDelay"), new ZLSimpleSpinOptionEntry(fbreader.KeyDelayOption, 50));
}
StyleOptionsPage::StyleOptionsPage(ZLDialogContent &dialogTab, ZLPaintContext &context) {
	const ZLResource &styleResource = ZLResource::resource(KEY_STYLE);

	myComboEntry = new ComboOptionEntry(*this, styleResource[KEY_BASE].value());
	myComboEntry->addValue(myComboEntry->initialValue());

	ZLTextStyleCollection &collection = ZLTextStyleCollection::Instance();
	ZLTextKind styles[] = { REGULAR, TITLE, SECTION_TITLE, SUBTITLE, H1, H2, H3, H4, H5, H6, CONTENTS_TABLE_ENTRY, LIBRARY_ENTRY, ANNOTATION, EPIGRAPH, AUTHOR, DATEKIND, POEM_TITLE, STANZA, VERSE, CITE, INTERNAL_HYPERLINK, EXTERNAL_HYPERLINK, BOOK_HYPERLINK, FOOTNOTE, ITALIC, EMPHASIS, BOLD, STRONG, DEFINITION, DEFINITION_DESCRIPTION, PREFORMATTED, CODE };
	const int STYLES_NUMBER = sizeof(styles) / sizeof(ZLTextKind);
	for (int i = 0; i < STYLES_NUMBER; ++i) {
		const ZLTextStyleDecoration *decoration = collection.decoration(styles[i]);
		if (decoration != 0) {
			myComboEntry->addValue(styleResource[decoration->name()].value());
		}
	}
	dialogTab.addOption(ZLResourceKey("optionsFor"), myComboEntry);

	{
		const std::string &name = myComboEntry->initialValue();
		FBTextStyle &baseStyle = FBTextStyle::Instance();

		registerEntry(dialogTab,
			KEY_FONTFAMILY, new ZLFontFamilyOptionEntry(baseStyle.FontFamilyOption, context),
			name
		);

		registerEntry(dialogTab,
			KEY_FONTSIZE, new ZLSimpleSpinOptionEntry(baseStyle.FontSizeOption, 2),
			name
		);

		registerEntry(dialogTab,
			KEY_BOLD, new ZLSimpleBooleanOptionEntry(baseStyle.BoldOption),
			name
		);

		registerEntry(dialogTab,
			KEY_ITALIC, new ZLSimpleBooleanOptionEntry(baseStyle.ItalicOption),
			name
		);

		registerEntry(dialogTab,
			KEY_AUTOHYPHENATIONS, new ZLSimpleBooleanOptionEntry(collection.AutoHyphenationOption),
			name
		);
	}

	for (int i = 0; i < STYLES_NUMBER; ++i) {
		ZLTextStyleDecoration *decoration = collection.decoration(styles[i]);
		if (decoration != 0) {
			const std::string &name = styleResource[decoration->name()].value();

			registerEntry(dialogTab,
				KEY_FONTFAMILY, new ZLTextFontFamilyWithBaseOptionEntry(decoration->FontFamilyOption, dialogTab.resource(KEY_FONTFAMILY), context),
				name
			);

			registerEntry(dialogTab,
				KEY_FONTSIZEDIFFERENCE, new ZLSimpleSpinOptionEntry(decoration->FontSizeDeltaOption, 2),
				name
			);

			registerEntry(dialogTab,
				KEY_BOLD, new ZLSimpleBoolean3OptionEntry(decoration->BoldOption),
				name
			);

			registerEntry(dialogTab,
				KEY_ITALIC, new ZLSimpleBoolean3OptionEntry(decoration->ItalicOption),
				name
			);

			registerEntry(dialogTab,
				KEY_ALLOWHYPHENATIONS, new ZLSimpleBoolean3OptionEntry(decoration->AllowHyphenationsOption),
				name
			);
		}
	}

	myComboEntry->onValueSelected(0);
	myComboEntry->setActive(false);
}
FormatOptionsPage::FormatOptionsPage(ZLDialogContent &dialogTab) {
	const ZLResource &styleResource = ZLResource::resource(KEY_STYLE);

	myComboEntry = new ComboOptionEntry(*this, styleResource[KEY_BASE].value());
	myComboEntry->addValue(myComboEntry->initialValue());

	ZLTextStyleCollection &collection = ZLTextStyleCollection::instance();
	ZLTextKind styles[] = { REGULAR, TITLE, SECTION_TITLE, SUBTITLE, H1, H2, H3, H4, H5, H6, ANNOTATION, EPIGRAPH, PREFORMATTED, AUTHOR, DATEKIND, POEM_TITLE, STANZA, VERSE };
	const int STYLES_NUMBER = sizeof(styles) / sizeof(ZLTextKind);
	for (int i = 0; i < STYLES_NUMBER; ++i) {
		const ZLTextStyleDecoration *decoration = collection.decoration(styles[i]);
		if (decoration != 0) {
			myComboEntry->addValue(styleResource[decoration->name()].value());
		}
	}
	dialogTab.addOption(ZLResourceKey("optionsFor"), myComboEntry);

	{
		const std::string &name = myComboEntry->initialValue();
		ZLTextBaseStyle &baseStyle = collection.baseStyle();

		registerEntries(dialogTab,
			KEY_LINESPACING, new ZLTextLineSpaceOptionEntry(baseStyle.LineSpacePercentOption, dialogTab.resource(KEY_LINESPACING), false),
			KEY_DUMMY, 0,//new ZLSimpleSpinOptionEntry("First Line Indent", baseStyle.firstLineIndentDeltaOption(), -300, 300, 1),
			name
		);

		registerEntries(dialogTab,
			KEY_ALIGNMENT, new ZLTextAlignmentOptionEntry(baseStyle.AlignmentOption, dialogTab.resource(KEY_ALIGNMENT), false),
			KEY_DUMMY, 0,
			name
		);
	}

	for (int i = 0; i < STYLES_NUMBER; ++i) {
		ZLTextStyleDecoration *d = collection.decoration(styles[i]);
		if ((d != 0) && (d->isFullDecoration())) {
			ZLTextFullStyleDecoration *decoration = (ZLTextFullStyleDecoration*)d;
			const std::string &name = styleResource[decoration->name()].value();
			
			registerEntries(dialogTab,
				KEY_SPACEBEFORE, new ZLSimpleSpinOptionEntry(decoration->SpaceBeforeOption, 1),
				KEY_LEFTINDENT, new ZLSimpleSpinOptionEntry(decoration->LeftIndentOption, 1),
				name
			);
			
			registerEntries(dialogTab,
				KEY_SPACEAFTER, new ZLSimpleSpinOptionEntry(decoration->SpaceAfterOption, 1),
				KEY_RIGHTINDENT, new ZLSimpleSpinOptionEntry(decoration->RightIndentOption, 1),
				name
			);
			
			registerEntries(dialogTab,
				KEY_LINESPACING, new ZLTextLineSpaceOptionEntry(decoration->LineSpacePercentOption, dialogTab.resource(KEY_LINESPACING), true),
				KEY_FIRSTLINEINDENT, new ZLSimpleSpinOptionEntry(decoration->FirstLineIndentDeltaOption, 1),
				name
			);

			registerEntries(dialogTab,
				KEY_ALIGNMENT, new ZLTextAlignmentOptionEntry(decoration->AlignmentOption, dialogTab.resource(KEY_ALIGNMENT), true),
				KEY_DUMMY, 0,
				name
			);
		}
	}

	myComboEntry->onValueSelected(0);
}
StyleOptionsPage::StyleOptionsPage(ZLDialogContent &dialogTab, ZLPaintContext &context) {
  myComboEntry = new ComboOptionEntry(*this, "Options For", "Base");
  myComboEntry->addValue(myComboEntry->initialValue());

  TextStyleCollection &collection = TextStyleCollection::instance();
  const int STYLES_NUMBER = 32;
  TextKind styles[STYLES_NUMBER] = { REGULAR, TITLE, SECTION_TITLE, SUBTITLE, H1, H2, H3, H4, H5, H6, CONTENTS_TABLE_ENTRY, RECENT_BOOK_LIST, LIBRARY_AUTHOR_ENTRY, LIBRARY_BOOK_ENTRY, ANNOTATION, EPIGRAPH, AUTHOR, DATE, POEM_TITLE, STANZA, VERSE, CITE, HYPERLINK, FOOTNOTE, ITALIC, EMPHASIS, BOLD, STRONG, DEFINITION, DEFINITION_DESCRIPTION, PREFORMATTED, CODE };
  for (int i = 0; i < STYLES_NUMBER; ++i) {
    const TextStyleDecoration *decoration = collection.decoration(styles[i]);
    if (decoration != 0) {
      myComboEntry->addValue(decoration->name());
    }
  }
  dialogTab.addOption(myComboEntry);

  {
    const std::string &name = myComboEntry->initialValue();
    BaseTextStyle &baseStyle = collection.baseStyle();

    registerEntries(dialogTab,
      new FontFamilyOptionEntry(baseStyle.FontFamilyOption, context, false),
      new ZLSimpleBooleanOptionEntry(BOLD_STRING, baseStyle.BoldOption),
      name
    );

    registerEntries(dialogTab,
      new ZLSimpleSpinOptionEntry("Size", baseStyle.FontSizeOption, 2),
      new ZLSimpleBooleanOptionEntry(ITALIC_STRING, baseStyle.ItalicOption),
      name
    );

    registerEntry(dialogTab,
      new ZLSimpleBooleanOptionEntry("Auto Hyphenations", baseStyle.AutoHyphenationOption),
      name
    );
  }

  for (int i = 0; i < STYLES_NUMBER; ++i) {
    TextStyleDecoration *decoration = collection.decoration(styles[i]);
    if (decoration != 0) {
      const std::string &name = decoration->name();

      registerEntries(dialogTab,
        new FontFamilyOptionEntry(decoration->FontFamilyOption, context, true),
        new ZLSimpleBoolean3OptionEntry(BOLD_STRING, decoration->BoldOption),
        name
      );

      registerEntries(dialogTab,
        new ZLSimpleSpinOptionEntry("Size Difference", decoration->FontSizeDeltaOption, 2),
        new ZLSimpleBoolean3OptionEntry(ITALIC_STRING, decoration->ItalicOption),
        name
      );

      registerEntries(dialogTab,
        new ZLSimpleBoolean3OptionEntry("Allow Hyphenations", decoration->AllowHyphenationsOption),
        0,
        name
      );
    }
  }

  myComboEntry->onValueChange(myComboEntry->initialValue());
}