|
|
@ -110,7 +110,7 @@ struct TypesetBookImpl : TypesetBook
|
|
|
|
Contents::iterator i = mContents.insert (mContents.end (), Content (text.first, text.second));
|
|
|
|
Contents::iterator i = mContents.insert (mContents.end (), Content (text.first, text.second));
|
|
|
|
|
|
|
|
|
|
|
|
if (i->empty())
|
|
|
|
if (i->empty())
|
|
|
|
return Range (Utf8Point (NULL), Utf8Point (NULL));
|
|
|
|
return Range (Utf8Point (nullptr), Utf8Point (nullptr));
|
|
|
|
|
|
|
|
|
|
|
|
Utf8Point begin = &i->front ();
|
|
|
|
Utf8Point begin = &i->front ();
|
|
|
|
Utf8Point end = &i->front () + i->size ();
|
|
|
|
Utf8Point end = &i->front () + i->size ();
|
|
|
@ -148,7 +148,7 @@ struct TypesetBookImpl : TypesetBook
|
|
|
|
template <typename Visitor>
|
|
|
|
template <typename Visitor>
|
|
|
|
void visitRuns (int top, int bottom, Visitor const & visitor) const
|
|
|
|
void visitRuns (int top, int bottom, Visitor const & visitor) const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
visitRuns (top, bottom, NULL, visitor);
|
|
|
|
visitRuns (top, bottom, nullptr, visitor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// hit test with a margin for error. only hits on interactive text fragments are reported.
|
|
|
|
/// hit test with a margin for error. only hits on interactive text fragments are reported.
|
|
|
@ -176,7 +176,7 @@ struct TypesetBookImpl : TypesetBook
|
|
|
|
return hit;
|
|
|
|
return hit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
StyleImpl * hitTest (int left, int top) const
|
|
|
|
StyleImpl * hitTest (int left, int top) const
|
|
|
@ -213,7 +213,7 @@ struct TypesetBookImpl : TypesetBook
|
|
|
|
for (Styles::iterator i = mStyles.begin (); i != mStyles.end (); ++i)
|
|
|
|
for (Styles::iterator i = mStyles.begin (); i != mStyles.end (); ++i)
|
|
|
|
if (&*i == style)
|
|
|
|
if (&*i == style)
|
|
|
|
return i->mFont;
|
|
|
|
return i->mFont;
|
|
|
|
return NULL;
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct Typesetter;
|
|
|
|
struct Typesetter;
|
|
|
@ -253,8 +253,8 @@ struct TypesetBookImpl::Typesetter : BookTypesetter
|
|
|
|
|
|
|
|
|
|
|
|
Typesetter (size_t width, size_t height) :
|
|
|
|
Typesetter (size_t width, size_t height) :
|
|
|
|
mPageWidth (width), mPageHeight(height),
|
|
|
|
mPageWidth (width), mPageHeight(height),
|
|
|
|
mSection (NULL), mLine (NULL), mRun (NULL),
|
|
|
|
mSection (nullptr), mLine (nullptr), mRun (nullptr),
|
|
|
|
mCurrentContent (NULL),
|
|
|
|
mCurrentContent (nullptr),
|
|
|
|
mCurrentAlignment (AlignLeft)
|
|
|
|
mCurrentAlignment (AlignLeft)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mBook = std::make_shared <Book> ();
|
|
|
|
mBook = std::make_shared <Book> ();
|
|
|
@ -342,7 +342,7 @@ struct TypesetBookImpl::Typesetter : BookTypesetter
|
|
|
|
|
|
|
|
|
|
|
|
void write (Style * style, size_t begin, size_t end)
|
|
|
|
void write (Style * style, size_t begin, size_t end)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
assert (mCurrentContent != NULL);
|
|
|
|
assert (mCurrentContent != nullptr);
|
|
|
|
assert (end <= mCurrentContent->size ());
|
|
|
|
assert (end <= mCurrentContent->size ());
|
|
|
|
assert (begin <= mCurrentContent->size ());
|
|
|
|
assert (begin <= mCurrentContent->size ());
|
|
|
|
|
|
|
|
|
|
|
@ -358,8 +358,8 @@ struct TypesetBookImpl::Typesetter : BookTypesetter
|
|
|
|
|
|
|
|
|
|
|
|
add_partial_text();
|
|
|
|
add_partial_text();
|
|
|
|
|
|
|
|
|
|
|
|
mRun = NULL;
|
|
|
|
mRun = nullptr;
|
|
|
|
mLine = NULL;
|
|
|
|
mLine = nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void sectionBreak (int margin)
|
|
|
|
void sectionBreak (int margin)
|
|
|
@ -368,9 +368,9 @@ struct TypesetBookImpl::Typesetter : BookTypesetter
|
|
|
|
|
|
|
|
|
|
|
|
if (mBook->mSections.size () > 0)
|
|
|
|
if (mBook->mSections.size () > 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mRun = NULL;
|
|
|
|
mRun = nullptr;
|
|
|
|
mLine = NULL;
|
|
|
|
mLine = nullptr;
|
|
|
|
mSection = NULL;
|
|
|
|
mSection = nullptr;
|
|
|
|
|
|
|
|
|
|
|
|
if (mBook->mRect.bottom < (mBook->mSections.back ().mRect.bottom + margin))
|
|
|
|
if (mBook->mRect.bottom < (mBook->mSections.back ().mRect.bottom + margin))
|
|
|
|
mBook->mRect.bottom = (mBook->mSections.back ().mRect.bottom + margin);
|
|
|
|
mBook->mRect.bottom = (mBook->mSections.back ().mRect.bottom + margin);
|
|
|
@ -381,7 +381,7 @@ struct TypesetBookImpl::Typesetter : BookTypesetter
|
|
|
|
{
|
|
|
|
{
|
|
|
|
add_partial_text();
|
|
|
|
add_partial_text();
|
|
|
|
|
|
|
|
|
|
|
|
if (mSection != NULL)
|
|
|
|
if (mSection != nullptr)
|
|
|
|
mSectionAlignment.back () = sectionAlignment;
|
|
|
|
mSectionAlignment.back () = sectionAlignment;
|
|
|
|
mCurrentAlignment = sectionAlignment;
|
|
|
|
mCurrentAlignment = sectionAlignment;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -491,7 +491,7 @@ struct TypesetBookImpl::Typesetter : BookTypesetter
|
|
|
|
{
|
|
|
|
{
|
|
|
|
add_partial_text();
|
|
|
|
add_partial_text();
|
|
|
|
stream.consume ();
|
|
|
|
stream.consume ();
|
|
|
|
mLine = NULL, mRun = NULL;
|
|
|
|
mLine = nullptr, mRun = nullptr;
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -551,7 +551,7 @@ struct TypesetBookImpl::Typesetter : BookTypesetter
|
|
|
|
|
|
|
|
|
|
|
|
if (left + space_width + word_width > mPageWidth)
|
|
|
|
if (left + space_width + word_width > mPageWidth)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mLine = NULL, mRun = NULL, left = 0;
|
|
|
|
mLine = nullptr, mRun = nullptr, left = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -580,7 +580,7 @@ struct TypesetBookImpl::Typesetter : BookTypesetter
|
|
|
|
|
|
|
|
|
|
|
|
void append_run (StyleImpl * style, Utf8Stream::Point begin, Utf8Stream::Point end, int pc, int right, int bottom)
|
|
|
|
void append_run (StyleImpl * style, Utf8Stream::Point begin, Utf8Stream::Point end, int pc, int right, int bottom)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (mSection == NULL)
|
|
|
|
if (mSection == nullptr)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mBook->mSections.push_back (Section ());
|
|
|
|
mBook->mSections.push_back (Section ());
|
|
|
|
mSection = &mBook->mSections.back ();
|
|
|
|
mSection = &mBook->mSections.back ();
|
|
|
@ -588,7 +588,7 @@ struct TypesetBookImpl::Typesetter : BookTypesetter
|
|
|
|
mSectionAlignment.push_back (mCurrentAlignment);
|
|
|
|
mSectionAlignment.push_back (mCurrentAlignment);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (mLine == NULL)
|
|
|
|
if (mLine == nullptr)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mSection->mLines.push_back (Line ());
|
|
|
|
mSection->mLines.push_back (Line ());
|
|
|
|
mLine = &mSection->mLines.back ();
|
|
|
|
mLine = &mSection->mLines.back ();
|
|
|
@ -613,7 +613,7 @@ struct TypesetBookImpl::Typesetter : BookTypesetter
|
|
|
|
if (mLine->mRect.bottom < bottom)
|
|
|
|
if (mLine->mRect.bottom < bottom)
|
|
|
|
mLine->mRect.bottom = bottom;
|
|
|
|
mLine->mRect.bottom = bottom;
|
|
|
|
|
|
|
|
|
|
|
|
if (mRun == NULL || mRun->mStyle != style || mRun->mRange.second != begin)
|
|
|
|
if (mRun == nullptr || mRun->mStyle != style || mRun->mRange.second != begin)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int left = mRun ? mRun->mRight : mLine->mRect.left;
|
|
|
|
int left = mRun ? mRun->mRight : mLine->mRect.left;
|
|
|
|
|
|
|
|
|
|
|
@ -843,17 +843,17 @@ protected:
|
|
|
|
TextFormat (MyGUI::IFont* id, PageDisplay * display) :
|
|
|
|
TextFormat (MyGUI::IFont* id, PageDisplay * display) :
|
|
|
|
mFont (id),
|
|
|
|
mFont (id),
|
|
|
|
mCountVertex (0),
|
|
|
|
mCountVertex (0),
|
|
|
|
mTexture (NULL),
|
|
|
|
mTexture (nullptr),
|
|
|
|
mRenderItem (NULL),
|
|
|
|
mRenderItem (nullptr),
|
|
|
|
mDisplay (display)
|
|
|
|
mDisplay (display)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void createDrawItem (MyGUI::ILayerNode* node)
|
|
|
|
void createDrawItem (MyGUI::ILayerNode* node)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
assert (mRenderItem == NULL);
|
|
|
|
assert (mRenderItem == nullptr);
|
|
|
|
|
|
|
|
|
|
|
|
if (mTexture != NULL)
|
|
|
|
if (mTexture != nullptr)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mRenderItem = node->addToRenderItem(mTexture, false, false);
|
|
|
|
mRenderItem = node->addToRenderItem(mTexture, false, false);
|
|
|
|
mRenderItem->addDrawItem(this, mCountVertex);
|
|
|
|
mRenderItem->addDrawItem(this, mCountVertex);
|
|
|
@ -862,12 +862,12 @@ protected:
|
|
|
|
|
|
|
|
|
|
|
|
void destroyDrawItem (MyGUI::ILayerNode* node)
|
|
|
|
void destroyDrawItem (MyGUI::ILayerNode* node)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
assert (mTexture != NULL ? mRenderItem != NULL : mRenderItem == NULL);
|
|
|
|
assert (mTexture != nullptr ? mRenderItem != nullptr : mRenderItem == nullptr);
|
|
|
|
|
|
|
|
|
|
|
|
if (mTexture != NULL)
|
|
|
|
if (mTexture != nullptr)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mRenderItem->removeDrawItem (this);
|
|
|
|
mRenderItem->removeDrawItem (this);
|
|
|
|
mRenderItem = NULL;
|
|
|
|
mRenderItem = nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -920,9 +920,9 @@ public:
|
|
|
|
resetPage ();
|
|
|
|
resetPage ();
|
|
|
|
mViewTop = 0;
|
|
|
|
mViewTop = 0;
|
|
|
|
mViewBottom = 0;
|
|
|
|
mViewBottom = 0;
|
|
|
|
mFocusItem = NULL;
|
|
|
|
mFocusItem = nullptr;
|
|
|
|
mItemActive = false;
|
|
|
|
mItemActive = false;
|
|
|
|
mNode = NULL;
|
|
|
|
mNode = nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void dirtyFocusItem ()
|
|
|
|
void dirtyFocusItem ()
|
|
|
@ -1053,7 +1053,7 @@ public:
|
|
|
|
|
|
|
|
|
|
|
|
for (ActiveTextFormats::iterator i = mActiveTextFormats.begin (); i != mActiveTextFormats.end (); ++i)
|
|
|
|
for (ActiveTextFormats::iterator i = mActiveTextFormats.begin (); i != mActiveTextFormats.end (); ++i)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (mNode != NULL)
|
|
|
|
if (mNode != nullptr)
|
|
|
|
i->second->destroyDrawItem (mNode);
|
|
|
|
i->second->destroyDrawItem (mNode);
|
|
|
|
i->second.reset();
|
|
|
|
i->second.reset();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1089,7 +1089,7 @@ public:
|
|
|
|
else
|
|
|
|
else
|
|
|
|
if (mBook && isPageDifferent (newPage))
|
|
|
|
if (mBook && isPageDifferent (newPage))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (mNode != NULL)
|
|
|
|
if (mNode != nullptr)
|
|
|
|
for (ActiveTextFormats::iterator i = mActiveTextFormats.begin (); i != mActiveTextFormats.end (); ++i)
|
|
|
|
for (ActiveTextFormats::iterator i = mActiveTextFormats.begin (); i != mActiveTextFormats.end (); ++i)
|
|
|
|
mNode->outOfDate(i->second->mRenderItem);
|
|
|
|
mNode->outOfDate(i->second->mRenderItem);
|
|
|
|
|
|
|
|
|
|
|
@ -1137,7 +1137,7 @@ public:
|
|
|
|
{
|
|
|
|
{
|
|
|
|
newBook->visitRuns (0, 0x7FFFFFFF, CreateActiveFormat (this));
|
|
|
|
newBook->visitRuns (0, 0x7FFFFFFF, CreateActiveFormat (this));
|
|
|
|
|
|
|
|
|
|
|
|
if (mNode != NULL)
|
|
|
|
if (mNode != nullptr)
|
|
|
|
for (ActiveTextFormats::iterator i = mActiveTextFormats.begin (); i != mActiveTextFormats.end (); ++i)
|
|
|
|
for (ActiveTextFormats::iterator i = mActiveTextFormats.begin (); i != mActiveTextFormats.end (); ++i)
|
|
|
|
i->second->createDrawItem (mNode);
|
|
|
|
i->second->createDrawItem (mNode);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1238,7 +1238,7 @@ public:
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_checkMargin();
|
|
|
|
_checkMargin();
|
|
|
|
|
|
|
|
|
|
|
|
if (mNode != NULL)
|
|
|
|
if (mNode != nullptr)
|
|
|
|
for (ActiveTextFormats::iterator i = mActiveTextFormats.begin (); i != mActiveTextFormats.end (); ++i)
|
|
|
|
for (ActiveTextFormats::iterator i = mActiveTextFormats.begin (); i != mActiveTextFormats.end (); ++i)
|
|
|
|
mNode->outOfDate (i->second->mRenderItem);
|
|
|
|
mNode->outOfDate (i->second->mRenderItem);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1247,7 +1247,7 @@ public:
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_checkMargin ();
|
|
|
|
_checkMargin ();
|
|
|
|
|
|
|
|
|
|
|
|
if (mNode != NULL)
|
|
|
|
if (mNode != nullptr)
|
|
|
|
for (ActiveTextFormats::iterator i = mActiveTextFormats.begin (); i != mActiveTextFormats.end (); ++i)
|
|
|
|
for (ActiveTextFormats::iterator i = mActiveTextFormats.begin (); i != mActiveTextFormats.end (); ++i)
|
|
|
|
mNode->outOfDate (i->second->mRenderItem);
|
|
|
|
mNode->outOfDate (i->second->mRenderItem);
|
|
|
|
|
|
|
|
|
|
|
@ -1258,7 +1258,7 @@ public:
|
|
|
|
for (ActiveTextFormats::iterator i = mActiveTextFormats.begin (); i != mActiveTextFormats.end (); ++i)
|
|
|
|
for (ActiveTextFormats::iterator i = mActiveTextFormats.begin (); i != mActiveTextFormats.end (); ++i)
|
|
|
|
i->second->destroyDrawItem (mNode);
|
|
|
|
i->second->destroyDrawItem (mNode);
|
|
|
|
|
|
|
|
|
|
|
|
mNode = NULL;
|
|
|
|
mNode = nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
@ -1269,7 +1269,7 @@ MYGUI_RTTI_DERIVED(BookPage)
|
|
|
|
public:
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
|
|
BookPageImpl()
|
|
|
|
BookPageImpl()
|
|
|
|
: mPageDisplay(NULL)
|
|
|
|
: mPageDisplay(nullptr)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|