Use field for columns count instead of out integer

pull/1768/head
Andrei Kortunov 6 years ago
parent 7a986f38da
commit e300a16b24

@ -157,7 +157,7 @@ MWGui::BookTypesetter::Utf8Span to_utf8_span (char const * text)
typedef TypesetBook::Ptr book;
JournalBooks::JournalBooks (JournalViewModel::Ptr model, ToUTF8::FromType encoding) :
mModel (model), mEncoding(encoding)
mModel (model), mEncoding(encoding), mIndexPagesCount(0)
{
}
@ -218,23 +218,23 @@ book JournalBooks::createQuestBook (const std::string& questName)
return typesetter->complete ();
}
book JournalBooks::createTopicIndexBook (int& columnsCount)
book JournalBooks::createTopicIndexBook ()
{
bool isRussian = (mEncoding == ToUTF8::WINDOWS_1251);
BookTypesetter::Ptr typesetter = isRussian ? createCyrillicJournalIndex(columnsCount) : createLatinJournalIndex(columnsCount);
BookTypesetter::Ptr typesetter = isRussian ? createCyrillicJournalIndex() : createLatinJournalIndex();
return typesetter->complete ();
}
BookTypesetter::Ptr JournalBooks::createLatinJournalIndex (int& columnsCount)
BookTypesetter::Ptr JournalBooks::createLatinJournalIndex ()
{
BookTypesetter::Ptr typesetter = BookTypesetter::create (92, 260);
typesetter->setSectionAlignment (BookTypesetter::AlignCenter);
// Latin journal index always has two columns for now.
columnsCount = 2;
mIndexPagesCount = 2;
char ch = 'A';
@ -261,7 +261,7 @@ BookTypesetter::Ptr JournalBooks::createLatinJournalIndex (int& columnsCount)
return typesetter;
}
BookTypesetter::Ptr JournalBooks::createCyrillicJournalIndex (int& columnsCount)
BookTypesetter::Ptr JournalBooks::createCyrillicJournalIndex ()
{
BookTypesetter::Ptr typesetter = BookTypesetter::create (92, 260);
@ -273,11 +273,11 @@ BookTypesetter::Ptr JournalBooks::createCyrillicJournalIndex (int& columnsCount)
// for small font size split alphabet to two columns (2x15 characers), for big font size split it to three colums (3x10 characters).
int sectionBreak = 10;
columnsCount = 3;
mIndexPagesCount = 3;
if (fontHeight < 18)
{
sectionBreak = 15;
columnsCount = 2;
mIndexPagesCount = 2;
}
unsigned char ch[2] = {0xd0, 0x90}; // CYRILLIC CAPITAL A is a 0xd090 in UTF-8

@ -22,14 +22,15 @@ namespace MWGui
Book createTopicBook (uintptr_t topicId);
Book createTopicBook (const std::string& topicId);
Book createQuestBook (const std::string& questName);
Book createTopicIndexBook (int& columnsCount);
Book createTopicIndexBook ();
ToUTF8::FromType mEncoding;
int mIndexPagesCount;
private:
BookTypesetter::Ptr createTypesetter ();
BookTypesetter::Ptr createLatinJournalIndex (int& columnsCount);
BookTypesetter::Ptr createCyrillicJournalIndex (int& columnsCount);
BookTypesetter::Ptr createLatinJournalIndex ();
BookTypesetter::Ptr createCyrillicJournalIndex ();
};
}

@ -465,11 +465,10 @@ namespace
{
setOptionsMode ();
int pagesCount;
if (!mTopicIndexBook)
mTopicIndexBook = createTopicIndexBook (pagesCount);
mTopicIndexBook = createTopicIndexBook ();
if (pagesCount == 3)
if (mIndexPagesCount == 3)
{
getPage (LeftTopicIndex)->showPage (mTopicIndexBook, 0);
getPage (CenterTopicIndex)->showPage (mTopicIndexBook, 1);

Loading…
Cancel
Save