1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-04-01 12:06:43 +00:00

Removed using namespace

This commit is contained in:
scrawl 2013-05-06 16:04:28 +02:00
parent 757a26794a
commit b5071ced23
4 changed files with 132 additions and 130 deletions

View file

@ -15,13 +15,9 @@
namespace MWGui namespace MWGui
{ {
struct TypesetBookImpl; struct TypesetBookImpl;
struct PageDisplay; struct PageDisplay;
struct BookPageImpl; struct BookPageImpl;
}
using namespace MyGUI;
using namespace MWGui;
static bool ucsSpace (int codePoint); static bool ucsSpace (int codePoint);
static bool ucsLineBreak (int codePoint); static bool ucsLineBreak (int codePoint);
@ -29,7 +25,7 @@ static bool ucsBreakingSpace (int codePoint);
struct BookTypesetter::Style { virtual ~Style () {} }; struct BookTypesetter::Style { virtual ~Style () {} };
struct MWGui::TypesetBookImpl : TypesetBook struct TypesetBookImpl : TypesetBook
{ {
typedef std::vector <uint8_t> Content; typedef std::vector <uint8_t> Content;
typedef std::list <Content> Contents; typedef std::list <Content> Contents;
@ -38,25 +34,28 @@ struct MWGui::TypesetBookImpl : TypesetBook
struct StyleImpl : BookTypesetter::Style struct StyleImpl : BookTypesetter::Style
{ {
IFont* mFont; MyGUI::IFont* mFont;
Colour mHotColour; MyGUI::Colour mHotColour;
Colour mActiveColour; MyGUI::Colour mActiveColour;
Colour mNormalColour; MyGUI::Colour mNormalColour;
InteractiveId mInteractiveId; InteractiveId mInteractiveId;
bool match (IFont* tstFont, Colour tstHotColour, Colour tstActiveColour, Colour tstNormalColour, intptr_t tstInteractiveId) bool match (MyGUI::IFont* tstFont, MyGUI::Colour tstHotColour, MyGUI::Colour tstActiveColour,
MyGUI::Colour tstNormalColour, intptr_t tstInteractiveId)
{ {
return (mFont == tstFont) && return (mFont == tstFont) &&
partal_match (tstHotColour, tstActiveColour, tstNormalColour, tstInteractiveId); partal_match (tstHotColour, tstActiveColour, tstNormalColour, tstInteractiveId);
} }
bool match (char const * tstFont, Colour tstHotColour, Colour tstActiveColour, Colour tstNormalColour, intptr_t tstInteractiveId) bool match (char const * tstFont, MyGUI::Colour tstHotColour, MyGUI::Colour tstActiveColour,
MyGUI::Colour tstNormalColour, intptr_t tstInteractiveId)
{ {
return (mFont->getResourceName () == tstFont) && return (mFont->getResourceName () == tstFont) &&
partal_match (tstHotColour, tstActiveColour, tstNormalColour, tstInteractiveId); partal_match (tstHotColour, tstActiveColour, tstNormalColour, tstInteractiveId);
} }
bool partal_match (Colour tstHotColour, Colour tstActiveColour, Colour tstNormalColour, intptr_t tstInteractiveId) bool partal_match (MyGUI::Colour tstHotColour, MyGUI::Colour tstActiveColour,
MyGUI::Colour tstNormalColour, intptr_t tstInteractiveId)
{ {
return return
(mHotColour == tstHotColour ) && (mHotColour == tstHotColour ) &&
@ -81,7 +80,7 @@ struct MWGui::TypesetBookImpl : TypesetBook
struct Line struct Line
{ {
Runs mRuns; Runs mRuns;
IntRect mRect; MyGUI::IntRect mRect;
}; };
typedef std::vector <Line> Lines; typedef std::vector <Line> Lines;
@ -89,7 +88,7 @@ struct MWGui::TypesetBookImpl : TypesetBook
struct Section struct Section
{ {
Lines mLines; Lines mLines;
IntRect mRect; MyGUI::IntRect mRect;
}; };
typedef std::vector <Section> Sections; typedef std::vector <Section> Sections;
@ -101,7 +100,7 @@ struct MWGui::TypesetBookImpl : TypesetBook
Sections mSections; Sections mSections;
Contents mContents; Contents mContents;
Styles mStyles; Styles mStyles;
IntRect mRect; MyGUI::IntRect mRect;
virtual ~TypesetBookImpl () {} virtual ~TypesetBookImpl () {}
@ -126,7 +125,7 @@ struct MWGui::TypesetBookImpl : TypesetBook
} }
template <typename Visitor> template <typename Visitor>
void visitRuns (int top, int bottom, IFont* Font, Visitor const & visitor) const void visitRuns (int top, int bottom, MyGUI::IFont* Font, Visitor const & visitor) const
{ {
for (Sections::const_iterator i = mSections.begin (); i != mSections.end (); ++i) for (Sections::const_iterator i = mSections.begin (); i != mSections.end (); ++i)
{ {
@ -180,7 +179,7 @@ struct MWGui::TypesetBookImpl : TypesetBook
return nullptr; return nullptr;
} }
IFont* affectedFont (StyleImpl* style) MyGUI::IFont* affectedFont (StyleImpl* style)
{ {
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)
@ -230,7 +229,7 @@ struct TypesetBookImpl::Typesetter : BookTypesetter
StyleImpl & style = *mBook->mStyles.insert (mBook->mStyles.end (), StyleImpl ()); StyleImpl & style = *mBook->mStyles.insert (mBook->mStyles.end (), StyleImpl ());
style.mFont = FontManager::getInstance().getByName(fontName); style.mFont = MyGUI::FontManager::getInstance().getByName(fontName);
style.mHotColour = fontColour; style.mHotColour = fontColour;
style.mActiveColour = fontColour; style.mActiveColour = fontColour;
style.mNormalColour = fontColour; style.mNormalColour = fontColour;
@ -405,7 +404,7 @@ struct TypesetBookImpl::Typesetter : BookTypesetter
while (!stream.eof () && !ucsLineBreak (stream.peek ()) && ucsBreakingSpace (stream.peek ())) while (!stream.eof () && !ucsLineBreak (stream.peek ()) && ucsBreakingSpace (stream.peek ()))
{ {
GlyphInfo* gi = style->mFont->getGlyphInfo (stream.peek ()); MyGUI::GlyphInfo* gi = style->mFont->getGlyphInfo (stream.peek ());
space_width += gi->advance; space_width += gi->advance;
stream.consume (); stream.consume ();
} }
@ -414,7 +413,7 @@ struct TypesetBookImpl::Typesetter : BookTypesetter
while (!stream.eof () && !ucsLineBreak (stream.peek ()) && !ucsBreakingSpace (stream.peek ())) while (!stream.eof () && !ucsLineBreak (stream.peek ()) && !ucsBreakingSpace (stream.peek ()))
{ {
GlyphInfo* gi = style->mFont->getGlyphInfo (stream.peek ()); MyGUI::GlyphInfo* gi = style->mFont->getGlyphInfo (stream.peek ());
word_width += gi->advance + gi->bearingX; word_width += gi->advance + gi->bearingX;
word_height = line_height; word_height = line_height;
++character_count; ++character_count;
@ -449,7 +448,7 @@ struct TypesetBookImpl::Typesetter : BookTypesetter
{ {
mBook->mSections.push_back (Section ()); mBook->mSections.push_back (Section ());
mSection = &mBook->mSections.back (); mSection = &mBook->mSections.back ();
mSection->mRect = IntRect (0, mBook->mRect.bottom, 0, mBook->mRect.bottom); mSection->mRect = MyGUI::IntRect (0, mBook->mRect.bottom, 0, mBook->mRect.bottom);
mSectionAlignment.push_back (mCurrentAlignment); mSectionAlignment.push_back (mCurrentAlignment);
} }
@ -457,7 +456,7 @@ struct TypesetBookImpl::Typesetter : BookTypesetter
{ {
mSection->mLines.push_back (Line ()); mSection->mLines.push_back (Line ());
mLine = &mSection->mLines.back (); mLine = &mSection->mLines.back ();
mLine->mRect = IntRect (0, mSection->mRect.bottom, 0, mBook->mRect.bottom); mLine->mRect = MyGUI::IntRect (0, mSection->mRect.bottom, 0, mBook->mRect.bottom);
} }
if (mBook->mRect.right < right) if (mBook->mRect.right < right)
@ -527,7 +526,7 @@ namespace
float hOffset; float hOffset;
float vOffset; float vOffset;
RenderXform (ICroppedRectangle* croppedParent, RenderTargetInfo const & renderTargetInfo) RenderXform (MyGUI::ICroppedRectangle* croppedParent, MyGUI::RenderTargetInfo const & renderTargetInfo)
{ {
clipTop = croppedParent->_getMarginTop (); clipTop = croppedParent->_getMarginTop ();
clipLeft = croppedParent->_getMarginLeft (); clipLeft = croppedParent->_getMarginLeft ();
@ -545,7 +544,7 @@ namespace
vOffset = renderTargetInfo.vOffset; vOffset = renderTargetInfo.vOffset;
} }
bool clip (FloatRect & vr, FloatRect & tr) bool clip (MyGUI::FloatRect & vr, MyGUI::FloatRect & tr)
{ {
if (vr.bottom <= clipTop || vr.right <= clipLeft || if (vr.bottom <= clipTop || vr.right <= clipLeft ||
vr.left >= clipRight || vr.top >= clipBottom ) vr.left >= clipRight || vr.top >= clipBottom )
@ -578,7 +577,7 @@ namespace
return true; return true;
} }
FloatPoint operator () (FloatPoint pt) MyGUI::FloatPoint operator () (MyGUI::FloatPoint pt)
{ {
pt.left = absoluteLeft - leftOffset + pt.left; pt.left = absoluteLeft - leftOffset + pt.left;
pt.top = absoluteTop - topOffset + pt.top; pt.top = absoluteTop - topOffset + pt.top;
@ -594,32 +593,32 @@ namespace
{ {
float mZ; float mZ;
uint32_t mC; uint32_t mC;
IFont* mFont; MyGUI::IFont* mFont;
FloatPoint mOrigin; MyGUI::FloatPoint mOrigin;
FloatPoint mCursor; MyGUI::FloatPoint mCursor;
Vertex* mVertices; MyGUI::Vertex* mVertices;
RenderXform mRenderXform; RenderXform mRenderXform;
MyGUI::VertexColourType mVertexColourType; MyGUI::VertexColourType mVertexColourType;
GlyphStream (IFont* font, float left, float top, float Z, GlyphStream (MyGUI::IFont* font, float left, float top, float Z,
Vertex* vertices, RenderXform const & renderXform) : MyGUI::Vertex* vertices, RenderXform const & renderXform) :
mZ(Z), mOrigin (left, top), mZ(Z), mOrigin (left, top),
mFont (font), mVertices (vertices), mFont (font), mVertices (vertices),
mRenderXform (renderXform) mRenderXform (renderXform)
{ {
mVertexColourType = RenderManager::getInstance().getVertexFormat(); mVertexColourType = MyGUI::RenderManager::getInstance().getVertexFormat();
} }
~GlyphStream () ~GlyphStream ()
{ {
} }
Vertex* end () const { return mVertices; } MyGUI::Vertex* end () const { return mVertices; }
void reset (float left, float top, Colour colour) void reset (float left, float top, MyGUI::Colour colour)
{ {
mC = texture_utility::toColourARGB(colour) | 0xFF000000; mC = MyGUI::texture_utility::toColourARGB(colour) | 0xFF000000;
texture_utility::convertColour(mC, mVertexColourType); MyGUI::texture_utility::convertColour(mC, mVertexColourType);
mCursor.left = mOrigin.left + left; mCursor.left = mOrigin.left + left;
mCursor.top = mOrigin.top + top; mCursor.top = mOrigin.top + top;
@ -627,16 +626,16 @@ namespace
void emitGlyph (wchar_t ch) void emitGlyph (wchar_t ch)
{ {
GlyphInfo* gi = mFont->getGlyphInfo (ch); MyGUI::GlyphInfo* gi = mFont->getGlyphInfo (ch);
FloatRect vr; MyGUI::FloatRect vr;
vr.left = mCursor.left + gi->bearingX; vr.left = mCursor.left + gi->bearingX;
vr.top = mCursor.top + gi->bearingY; vr.top = mCursor.top + gi->bearingY;
vr.right = vr.left + gi->width; vr.right = vr.left + gi->width;
vr.bottom = vr.top + gi->height; vr.bottom = vr.top + gi->height;
FloatRect tr = gi->uvRect; MyGUI::FloatRect tr = gi->uvRect;
if (mRenderXform.clip (vr, tr)) if (mRenderXform.clip (vr, tr))
quad (vr, tr); quad (vr, tr);
@ -646,14 +645,14 @@ namespace
void emitSpace (wchar_t ch) void emitSpace (wchar_t ch)
{ {
GlyphInfo* gi = mFont->getGlyphInfo (ch); MyGUI::GlyphInfo* gi = mFont->getGlyphInfo (ch);
mCursor.left += gi->bearingX + gi->advance; mCursor.left += gi->bearingX + gi->advance;
} }
private: private:
void quad (const FloatRect& vr, const FloatRect& tr) void quad (const MyGUI::FloatRect& vr, const MyGUI::FloatRect& tr)
{ {
vertex (vr.left, vr.top, tr.left, tr.top); vertex (vr.left, vr.top, tr.left, tr.top);
vertex (vr.right, vr.top, tr.right, tr.top); vertex (vr.right, vr.top, tr.right, tr.top);
@ -665,7 +664,7 @@ namespace
void vertex (float x, float y, float u, float v) void vertex (float x, float y, float u, float v)
{ {
FloatPoint pt = mRenderXform (FloatPoint (x, y)); MyGUI::FloatPoint pt = mRenderXform (MyGUI::FloatPoint (x, y));
mVertices->x = pt.left; mVertices->x = pt.left;
mVertices->y = pt.top ; mVertices->y = pt.top ;
@ -679,7 +678,7 @@ namespace
}; };
} }
class MWGui::PageDisplay : public ISubWidgetText class PageDisplay : public MyGUI::ISubWidgetText
{ {
MYGUI_RTTI_DERIVED(PageDisplay) MYGUI_RTTI_DERIVED(PageDisplay)
protected: protected:
@ -690,15 +689,15 @@ protected:
struct TextFormat : ISubWidget struct TextFormat : ISubWidget
{ {
typedef IFont* Id; typedef MyGUI::IFont* Id;
Id mFont; Id mFont;
int mCountVertex; int mCountVertex;
ITexture* mTexture; MyGUI::ITexture* mTexture;
RenderItem* mRenderItem; MyGUI::RenderItem* mRenderItem;
PageDisplay * mDisplay; PageDisplay * mDisplay;
TextFormat (IFont* id, PageDisplay * display) : TextFormat (MyGUI::IFont* id, PageDisplay * display) :
mFont (id), mFont (id),
mTexture (NULL), mTexture (NULL),
mRenderItem (NULL), mRenderItem (NULL),
@ -707,7 +706,7 @@ protected:
{ {
} }
void createDrawItem (ILayerNode* node) void createDrawItem (MyGUI::ILayerNode* node)
{ {
assert (mRenderItem == NULL); assert (mRenderItem == NULL);
@ -718,7 +717,7 @@ protected:
} }
} }
void destroyDrawItem (ILayerNode* node) void destroyDrawItem (MyGUI::ILayerNode* node)
{ {
assert (mTexture != NULL ? mRenderItem != NULL : mRenderItem == NULL); assert (mTexture != NULL ? mRenderItem != NULL : mRenderItem == NULL);
@ -733,7 +732,7 @@ protected:
// this isn't really a sub-widget, its just a "drawitem" which // this isn't really a sub-widget, its just a "drawitem" which
// should have its own interface // should have its own interface
void createDrawItem(ITexture* _texture, ILayerNode* _node) {} void createDrawItem(MyGUI::ITexture* _texture, MyGUI::ILayerNode* _node) {}
void destroyDrawItem() {}; void destroyDrawItem() {};
}; };
@ -747,14 +746,14 @@ public:
Style* mFocusItem; Style* mFocusItem;
bool mItemActive; bool mItemActive;
MouseButton mLastDown; MyGUI::MouseButton mLastDown;
boost::function <void (intptr_t)> mLinkClicked; boost::function <void (intptr_t)> mLinkClicked;
boost::shared_ptr <TypesetBookImpl> mBook; boost::shared_ptr <TypesetBookImpl> mBook;
size_t mPage; size_t mPage;
ILayerNode* mNode; MyGUI::ILayerNode* mNode;
ActiveTextFormats mActiveTextFormats; ActiveTextFormats mActiveTextFormats;
PageDisplay () PageDisplay ()
@ -766,7 +765,7 @@ public:
{ {
if (mFocusItem != 0) if (mFocusItem != 0)
{ {
IFont* Font = mBook->affectedFont (mFocusItem); MyGUI::IFont* Font = mBook->affectedFont (mFocusItem);
ActiveTextFormats::iterator i = mActiveTextFormats.find (Font); ActiveTextFormats::iterator i = mActiveTextFormats.find (Font);
@ -795,7 +794,7 @@ public:
Style * Hit = mBook->hitTest (left, mViewTop + top); Style * Hit = mBook->hitTest (left, mViewTop + top);
if (mLastDown == MouseButton::None) if (mLastDown == MyGUI::MouseButton::None)
{ {
if (Hit != mFocusItem) if (Hit != mFocusItem)
{ {
@ -821,7 +820,7 @@ public:
} }
} }
void onMouseButtonPressed (int left, int top, MouseButton id) void onMouseButtonPressed (int left, int top, MyGUI::MouseButton id)
{ {
if (!mBook) if (!mBook)
return; return;
@ -829,7 +828,7 @@ public:
left -= mCroppedParent->getAbsoluteLeft (); left -= mCroppedParent->getAbsoluteLeft ();
top -= mCroppedParent->getAbsoluteTop (); top -= mCroppedParent->getAbsoluteTop ();
if (mLastDown == MouseButton::None) if (mLastDown == MyGUI::MouseButton::None)
{ {
mFocusItem = mBook->hitTest (left, mViewTop + top); mFocusItem = mBook->hitTest (left, mViewTop + top);
mItemActive = true; mItemActive = true;
@ -840,7 +839,7 @@ public:
} }
} }
void onMouseButtonReleased(int left, int top, MouseButton id) void onMouseButtonReleased(int left, int top, MyGUI::MouseButton id)
{ {
if (!mBook) if (!mBook)
return; return;
@ -858,7 +857,7 @@ public:
dirtyFocusItem (); dirtyFocusItem ();
mLastDown = MouseButton::None; mLastDown = MyGUI::MouseButton::None;
if (clicked && mLinkClicked && mItem && mItem->mInteractiveId != 0) if (clicked && mLinkClicked && mItem && mItem->mInteractiveId != 0)
mLinkClicked (mItem->mInteractiveId); mLinkClicked (mItem->mInteractiveId);
@ -939,7 +938,7 @@ public:
void operator () (Section const & section, Line const & line, Run const & run) const void operator () (Section const & section, Line const & line, Run const & run) const
{ {
IFont* Font = run.mStyle->mFont; MyGUI::IFont* Font = run.mStyle->mFont;
ActiveTextFormats::iterator j = this_->mActiveTextFormats.find (Font); ActiveTextFormats::iterator j = this_->mActiveTextFormats.find (Font);
@ -975,7 +974,7 @@ public:
if (mVisible) if (mVisible)
{ {
// reset input state // reset input state
mLastDown = MouseButton::None; mLastDown = MyGUI::MouseButton::None;
mFocusItem = nullptr; mFocusItem = nullptr;
mItemActive = 0; mItemActive = 0;
} }
@ -987,7 +986,7 @@ public:
} }
} }
void createDrawItem(ITexture* texture, ILayerNode* node) void createDrawItem(MyGUI::ITexture* texture, MyGUI::ILayerNode* node)
{ {
//test (); //test ();
@ -1011,7 +1010,7 @@ public:
{ {
bool isActive = run.mStyle->mInteractiveId && (run.mStyle == this_->mFocusItem); bool isActive = run.mStyle->mInteractiveId && (run.mStyle == this_->mFocusItem);
Colour colour = isActive ? (this_->mItemActive ? run.mStyle->mActiveColour: run.mStyle->mHotColour) : run.mStyle->mNormalColour; MyGUI::Colour colour = isActive ? (this_->mItemActive ? run.mStyle->mActiveColour: run.mStyle->mHotColour) : run.mStyle->mNormalColour;
glyphStream.reset (section.mRect.left + line.mRect.left + run.mLeft, line.mRect.top, colour); glyphStream.reset (section.mRect.left + line.mRect.left + run.mLeft, line.mRect.top, colour);
@ -1037,7 +1036,7 @@ public:
if (!mVisible) if (!mVisible)
return; return;
Vertex* vertices = textFormat.mRenderItem->getCurrentVertexBuffer(); MyGUI::Vertex* vertices = textFormat.mRenderItem->getCurrentVertexBuffer();
RenderXform renderXform (mCroppedParent, textFormat.mRenderItem->getRenderTarget()->getInfo()); RenderXform renderXform (mCroppedParent, textFormat.mRenderItem->getRenderTarget()->getInfo());
@ -1080,7 +1079,7 @@ public:
}; };
class MWGui::BookPageImpl : public BookPage class BookPageImpl : public BookPage
{ {
MYGUI_RTTI_DERIVED(BookPage) MYGUI_RTTI_DERIVED(BookPage)
public: public:
@ -1131,7 +1130,7 @@ protected:
Widget::onMouseMove (left, top); Widget::onMouseMove (left, top);
} }
void onMouseButtonPressed (int left, int top, MouseButton id) void onMouseButtonPressed (int left, int top, MyGUI::MouseButton id)
{ {
if (PageDisplay* pd = dynamic_cast <PageDisplay*> (getSubWidgetText ())) if (PageDisplay* pd = dynamic_cast <PageDisplay*> (getSubWidgetText ()))
{ {
@ -1141,7 +1140,7 @@ protected:
Widget::onMouseButtonPressed (left, top, id); Widget::onMouseButtonPressed (left, top, id);
} }
void onMouseButtonReleased(int left, int top, MouseButton id) void onMouseButtonReleased(int left, int top, MyGUI::MouseButton id)
{ {
if (PageDisplay* pd = dynamic_cast <PageDisplay*> (getSubWidgetText ())) if (PageDisplay* pd = dynamic_cast <PageDisplay*> (getSubWidgetText ()))
{ {
@ -1154,7 +1153,7 @@ protected:
void BookPage::registerMyGUIComponents () void BookPage::registerMyGUIComponents ()
{ {
FactoryManager & factory = FactoryManager::getInstance(); MyGUI::FactoryManager & factory = MyGUI::FactoryManager::getInstance();
factory.registerFactory<BookPageImpl>("Widget"); factory.registerFactory<BookPageImpl>("Widget");
factory.registerFactory<PageDisplay>("BasisSkin"); factory.registerFactory<PageDisplay>("BasisSkin");
@ -1224,3 +1223,5 @@ static bool ucsBreakingSpace (int codePoint)
return false; return false;
} }
} }
}

View file

@ -1,16 +1,14 @@
#include "journalbooks.hpp" #include "journalbooks.hpp"
using namespace MWGui;
namespace namespace
{ {
BookTypesetter::Utf8Span to_utf8_span (char const * text) MWGui::BookTypesetter::Utf8Span to_utf8_span (char const * text)
{ {
typedef BookTypesetter::Utf8Point point; typedef MWGui::BookTypesetter::Utf8Point point;
point begin = reinterpret_cast <point> (text); point begin = reinterpret_cast <point> (text);
return BookTypesetter::Utf8Span (begin, begin + strlen (text)); return MWGui::BookTypesetter::Utf8Span (begin, begin + strlen (text));
} }
const MyGUI::Colour linkHot (0.40f, 0.40f, 0.80f); const MyGUI::Colour linkHot (0.40f, 0.40f, 0.80f);
@ -19,10 +17,10 @@ namespace
struct AddContent struct AddContent
{ {
BookTypesetter::Ptr mTypesetter; MWGui::BookTypesetter::Ptr mTypesetter;
BookTypesetter::Style* mBodyStyle; MWGui::BookTypesetter::Style* mBodyStyle;
AddContent (BookTypesetter::Ptr typesetter, BookTypesetter::Style* body_style) : AddContent (MWGui::BookTypesetter::Ptr typesetter, MWGui::BookTypesetter::Style* body_style) :
mTypesetter (typesetter), mBodyStyle (body_style) mTypesetter (typesetter), mBodyStyle (body_style)
{ {
} }
@ -30,14 +28,14 @@ namespace
struct AddSpan : AddContent struct AddSpan : AddContent
{ {
AddSpan (BookTypesetter::Ptr typesetter, BookTypesetter::Style* body_style) : AddSpan (MWGui::BookTypesetter::Ptr typesetter, MWGui::BookTypesetter::Style* body_style) :
AddContent (typesetter, body_style) AddContent (typesetter, body_style)
{ {
} }
void operator () (intptr_t topicId, size_t begin, size_t end) void operator () (intptr_t topicId, size_t begin, size_t end)
{ {
BookTypesetter::Style* style = mBodyStyle; MWGui::BookTypesetter::Style* style = mBodyStyle;
if (topicId) if (topicId)
style = mTypesetter->createHotStyle (mBodyStyle, linkNormal, linkHot, linkActive, topicId); style = mTypesetter->createHotStyle (mBodyStyle, linkNormal, linkHot, linkActive, topicId);
@ -48,15 +46,15 @@ namespace
struct AddEntry struct AddEntry
{ {
BookTypesetter::Ptr mTypesetter; MWGui::BookTypesetter::Ptr mTypesetter;
BookTypesetter::Style* mBodyStyle; MWGui::BookTypesetter::Style* mBodyStyle;
AddEntry (BookTypesetter::Ptr typesetter, BookTypesetter::Style* body_style) : AddEntry (MWGui::BookTypesetter::Ptr typesetter, MWGui::BookTypesetter::Style* body_style) :
mTypesetter (typesetter), mBodyStyle (body_style) mTypesetter (typesetter), mBodyStyle (body_style)
{ {
} }
void operator () (JournalViewModel::Entry const & entry) void operator () (MWGui::JournalViewModel::Entry const & entry)
{ {
mTypesetter->addContent (entry.body ()); mTypesetter->addContent (entry.body ());
@ -67,17 +65,17 @@ namespace
struct AddJournalEntry : AddEntry struct AddJournalEntry : AddEntry
{ {
bool mAddHeader; bool mAddHeader;
BookTypesetter::Style* mHeaderStyle; MWGui::BookTypesetter::Style* mHeaderStyle;
AddJournalEntry (BookTypesetter::Ptr typesetter, BookTypesetter::Style* body_style, AddJournalEntry (MWGui::BookTypesetter::Ptr typesetter, MWGui::BookTypesetter::Style* body_style,
BookTypesetter::Style* header_style, bool add_header) : MWGui::BookTypesetter::Style* header_style, bool add_header) :
AddEntry (typesetter, body_style), AddEntry (typesetter, body_style),
mHeaderStyle (header_style), mHeaderStyle (header_style),
mAddHeader (add_header) mAddHeader (add_header)
{ {
} }
void operator () (JournalViewModel::JournalEntry const & entry) void operator () (MWGui::JournalViewModel::JournalEntry const & entry)
{ {
if (mAddHeader) if (mAddHeader)
{ {
@ -94,15 +92,15 @@ namespace
struct AddTopicEntry : AddEntry struct AddTopicEntry : AddEntry
{ {
intptr_t mContentId; intptr_t mContentId;
BookTypesetter::Style* mHeaderStyle; MWGui::BookTypesetter::Style* mHeaderStyle;
AddTopicEntry (BookTypesetter::Ptr typesetter, BookTypesetter::Style* body_style, AddTopicEntry (MWGui::BookTypesetter::Ptr typesetter, MWGui::BookTypesetter::Style* body_style,
BookTypesetter::Style* header_style, intptr_t contentId) : MWGui::BookTypesetter::Style* header_style, intptr_t contentId) :
AddEntry (typesetter, body_style), mHeaderStyle (header_style), mContentId (contentId) AddEntry (typesetter, body_style), mHeaderStyle (header_style), mContentId (contentId)
{ {
} }
void operator () (JournalViewModel::TopicEntry const & entry) void operator () (MWGui::JournalViewModel::TopicEntry const & entry)
{ {
mTypesetter->write (mBodyStyle, entry.source ()); mTypesetter->write (mBodyStyle, entry.source ());
mTypesetter->write (mBodyStyle, 0, 3);// begin mTypesetter->write (mBodyStyle, 0, 3);// begin
@ -118,12 +116,12 @@ namespace
struct AddTopicName : AddContent struct AddTopicName : AddContent
{ {
AddTopicName (BookTypesetter::Ptr typesetter, BookTypesetter::Style* style) : AddTopicName (MWGui::BookTypesetter::Ptr typesetter, MWGui::BookTypesetter::Style* style) :
AddContent (typesetter, style) AddContent (typesetter, style)
{ {
} }
void operator () (JournalViewModel::Utf8Span topicName) void operator () (MWGui::JournalViewModel::Utf8Span topicName)
{ {
mTypesetter->write (mBodyStyle, topicName); mTypesetter->write (mBodyStyle, topicName);
mTypesetter->sectionBreak (10); mTypesetter->sectionBreak (10);
@ -132,12 +130,12 @@ namespace
struct AddQuestName : AddContent struct AddQuestName : AddContent
{ {
AddQuestName (BookTypesetter::Ptr typesetter, BookTypesetter::Style* style) : AddQuestName (MWGui::BookTypesetter::Ptr typesetter, MWGui::BookTypesetter::Style* style) :
AddContent (typesetter, style) AddContent (typesetter, style)
{ {
} }
void operator () (JournalViewModel::Utf8Span topicName) void operator () (MWGui::JournalViewModel::Utf8Span topicName)
{ {
mTypesetter->write (mBodyStyle, topicName); mTypesetter->write (mBodyStyle, topicName);
mTypesetter->sectionBreak (10); mTypesetter->sectionBreak (10);
@ -146,14 +144,14 @@ namespace
struct AddTopicLink : AddContent struct AddTopicLink : AddContent
{ {
AddTopicLink (BookTypesetter::Ptr typesetter, BookTypesetter::Style* style) : AddTopicLink (MWGui::BookTypesetter::Ptr typesetter, MWGui::BookTypesetter::Style* style) :
AddContent (typesetter, style) AddContent (typesetter, style)
{ {
} }
void operator () (JournalViewModel::TopicId topicId, JournalViewModel::Utf8Span name) void operator () (MWGui::JournalViewModel::TopicId topicId, MWGui::JournalViewModel::Utf8Span name)
{ {
BookTypesetter::Style* link = mTypesetter->createHotStyle (mBodyStyle, MyGUI::Colour::Black, linkHot, linkActive, topicId); MWGui::BookTypesetter::Style* link = mTypesetter->createHotStyle (mBodyStyle, MyGUI::Colour::Black, linkHot, linkActive, topicId);
mTypesetter->write (link, name); mTypesetter->write (link, name);
mTypesetter->lineBreak (); mTypesetter->lineBreak ();
@ -162,14 +160,14 @@ namespace
struct AddQuestLink : AddContent struct AddQuestLink : AddContent
{ {
AddQuestLink (BookTypesetter::Ptr typesetter, BookTypesetter::Style* style) : AddQuestLink (MWGui::BookTypesetter::Ptr typesetter, MWGui::BookTypesetter::Style* style) :
AddContent (typesetter, style) AddContent (typesetter, style)
{ {
} }
void operator () (JournalViewModel::QuestId id, JournalViewModel::Utf8Span name) void operator () (MWGui::JournalViewModel::QuestId id, MWGui::JournalViewModel::Utf8Span name)
{ {
BookTypesetter::Style* style = mTypesetter->createHotStyle (mBodyStyle, MyGUI::Colour::Black, linkHot, linkActive, id); MWGui::BookTypesetter::Style* style = mTypesetter->createHotStyle (mBodyStyle, MyGUI::Colour::Black, linkHot, linkActive, id);
mTypesetter->write (style, name); mTypesetter->write (style, name);
mTypesetter->lineBreak (); mTypesetter->lineBreak ();
@ -177,6 +175,9 @@ namespace
}; };
} }
namespace MWGui
{
typedef TypesetBook::Ptr book; typedef TypesetBook::Ptr book;
JournalBooks::JournalBooks (JournalViewModel::Ptr model) : JournalBooks::JournalBooks (JournalViewModel::Ptr model) :
@ -321,3 +322,5 @@ BookTypesetter::Ptr JournalBooks::createTypesetter ()
//TODO: determine page size from layout... //TODO: determine page size from layout...
return BookTypesetter::create (240, 300); return BookTypesetter::create (240, 300);
} }
}

View file

@ -16,14 +16,13 @@
#include "keywordsearch.hpp" #include "keywordsearch.hpp"
namespace MWGui {
using namespace MWGui; struct JournalViewModelImpl;
namespace MWGui { struct JournalViewModelImpl; }
static void injectMonthName (std::ostream & os, int month); static void injectMonthName (std::ostream & os, int month);
struct MWGui::JournalViewModelImpl : JournalViewModel struct JournalViewModelImpl : JournalViewModel
{ {
typedef KeywordSearch <std::string, intptr_t> KeywordSearchT; typedef KeywordSearch <std::string, intptr_t> KeywordSearchT;
@ -386,3 +385,5 @@ JournalViewModel::Ptr JournalViewModel::create ()
{ {
return boost::make_shared <JournalViewModelImpl> (); return boost::make_shared <JournalViewModelImpl> ();
} }
}

View file

@ -20,9 +20,6 @@
#include "journalviewmodel.hpp" #include "journalviewmodel.hpp"
#include "journalbooks.hpp" #include "journalbooks.hpp"
using namespace MyGUI;
using namespace MWGui;
namespace namespace
{ {
static char const OptionsOverlay [] = "OptionsOverlay"; static char const OptionsOverlay [] = "OptionsOverlay";
@ -47,7 +44,7 @@ namespace
static char const LeftTopicIndex [] = "LeftTopicIndex"; static char const LeftTopicIndex [] = "LeftTopicIndex";
static char const RightTopicIndex [] = "RightTopicIndex"; static char const RightTopicIndex [] = "RightTopicIndex";
struct JournalWindowImpl : WindowBase, JournalBooks, JournalWindow struct JournalWindowImpl : MWGui::WindowBase, MWGui::JournalBooks, MWGui::JournalWindow
{ {
struct DisplayState struct DisplayState
{ {
@ -73,17 +70,17 @@ namespace
template <typename value_type> template <typename value_type>
void setText (char const * name, value_type const & value) void setText (char const * name, value_type const & value)
{ {
getWidget <TextBox> (name) -> getWidget <MyGUI::TextBox> (name) ->
setCaption (boost::lexical_cast <std::string> (value)); setCaption (boost::lexical_cast <std::string> (value));
} }
void setVisible (char const * name, bool visible) void setVisible (char const * name, bool visible)
{ {
getWidget <Widget> (name) -> getWidget <MyGUI::Widget> (name) ->
setVisible (visible); setVisible (visible);
} }
void adviseButtonClick (char const * name, void (JournalWindowImpl::*Handler) (Widget* _sender)) void adviseButtonClick (char const * name, void (JournalWindowImpl::*Handler) (MyGUI::Widget* _sender))
{ {
getWidget <MWGui::ImageButton> (name) -> getWidget <MWGui::ImageButton> (name) ->
eventMouseButtonClick += newDelegate(this, Handler); eventMouseButtonClick += newDelegate(this, Handler);
@ -94,7 +91,7 @@ namespace
return getWidget <MWGui::BookPage> (name); return getWidget <MWGui::BookPage> (name);
} }
JournalWindowImpl (JournalViewModel::Ptr Model) JournalWindowImpl (MWGui::JournalViewModel::Ptr Model)
: WindowBase("openmw_journal.layout"), JournalBooks (Model) : WindowBase("openmw_journal.layout"), JournalBooks (Model)
{ {
mMainWidget->setVisible(false); mMainWidget->setVisible(false);
@ -114,7 +111,7 @@ namespace
adviseButtonClick (ShowActiveBTN, &JournalWindowImpl::notifyShowActive); adviseButtonClick (ShowActiveBTN, &JournalWindowImpl::notifyShowActive);
{ {
BookPage::ClickCallback callback; MWGui::BookPage::ClickCallback callback;
callback = boost::bind (&JournalWindowImpl::notifyTopicClicked, this, _1); callback = boost::bind (&JournalWindowImpl::notifyTopicClicked, this, _1);
@ -124,7 +121,7 @@ namespace
} }
{ {
BookPage::ClickCallback callback; MWGui::BookPage::ClickCallback callback;
callback = boost::bind (&JournalWindowImpl::notifyIndexLinkClicked, this, _1); callback = boost::bind (&JournalWindowImpl::notifyIndexLinkClicked, this, _1);
@ -133,7 +130,7 @@ namespace
} }
{ {
BookPage::ClickCallback callback; MWGui::BookPage::ClickCallback callback;
callback = boost::bind (&JournalWindowImpl::notifyQuestClicked, this, _1); callback = boost::bind (&JournalWindowImpl::notifyQuestClicked, this, _1);
@ -312,7 +309,7 @@ namespace
setVisible (JournalBTN, true); setVisible (JournalBTN, true);
} }
void notifyOptions(Widget* _sender) void notifyOptions(MyGUI::Widget* _sender)
{ {
setOptionsMode (); setOptionsMode ();
@ -323,7 +320,7 @@ namespace
getPage (RightTopicIndex)->showPage (mTopicIndexBook, 1); getPage (RightTopicIndex)->showPage (mTopicIndexBook, 1);
} }
void notifyJournal(Widget* _sender) void notifyJournal(MyGUI::Widget* _sender)
{ {
assert (mStates.size () > 1); assert (mStates.size () > 1);
popBook (); popBook ();
@ -335,10 +332,10 @@ namespace
getPage (pageId)->showPage (book, 0); getPage (pageId)->showPage (book, 0);
getWidget <ScrollView> (listId)->setCanvasSize (size.first, size.second); getWidget <MyGUI::ScrollView> (listId)->setCanvasSize (size.first, size.second);
} }
void notifyIndexLinkClicked (TypesetBook::InteractiveId character) void notifyIndexLinkClicked (MWGui::TypesetBook::InteractiveId character)
{ {
setVisible (LeftTopicIndex, false); setVisible (LeftTopicIndex, false);
setVisible (RightTopicIndex, false); setVisible (RightTopicIndex, false);
@ -347,7 +344,7 @@ namespace
showList (TopicsList, TopicsPage, createTopicIndexBook ((char)character)); showList (TopicsList, TopicsPage, createTopicIndexBook ((char)character));
} }
void notifyTopics(Widget* _sender) void notifyTopics(MyGUI::Widget* _sender)
{ {
mQuestMode = false; mQuestMode = false;
setVisible (LeftTopicIndex, true); setVisible (LeftTopicIndex, true);
@ -358,7 +355,7 @@ namespace
setVisible (ShowActiveBTN, false); setVisible (ShowActiveBTN, false);
} }
void notifyQuests(Widget* _sender) void notifyQuests(MyGUI::Widget* _sender)
{ {
mQuestMode = true; mQuestMode = true;
setVisible (LeftTopicIndex, false); setVisible (LeftTopicIndex, false);
@ -371,7 +368,7 @@ namespace
showList (QuestsList, QuestsPage, createQuestIndexBook (!mAllQuests)); showList (QuestsList, QuestsPage, createQuestIndexBook (!mAllQuests));
} }
void notifyShowAll(Widget* _sender) void notifyShowAll(MyGUI::Widget* _sender)
{ {
mAllQuests = true; mAllQuests = true;
setVisible (ShowAllBTN, !mAllQuests); setVisible (ShowAllBTN, !mAllQuests);
@ -379,7 +376,7 @@ namespace
showList (QuestsList, QuestsPage, createQuestIndexBook (!mAllQuests)); showList (QuestsList, QuestsPage, createQuestIndexBook (!mAllQuests));
} }
void notifyShowActive(Widget* _sender) void notifyShowActive(MyGUI::Widget* _sender)
{ {
mAllQuests = false; mAllQuests = false;
setVisible (ShowAllBTN, !mAllQuests); setVisible (ShowAllBTN, !mAllQuests);
@ -387,18 +384,18 @@ namespace
showList (QuestsList, QuestsPage, createQuestIndexBook (!mAllQuests)); showList (QuestsList, QuestsPage, createQuestIndexBook (!mAllQuests));
} }
void notifyCancel(Widget* _sender) void notifyCancel(MyGUI::Widget* _sender)
{ {
setBookMode (); setBookMode ();
} }
void notifyClose(Widget* _sender) void notifyClose(MyGUI::Widget* _sender)
{ {
MWBase::Environment::get().getWindowManager ()->popGuiMode (); MWBase::Environment::get().getWindowManager ()->popGuiMode ();
} }
void notifyNextPage(Widget* _sender) void notifyNextPage(MyGUI::Widget* _sender)
{ {
if (!mStates.empty ()) if (!mStates.empty ())
{ {
@ -413,7 +410,7 @@ namespace
} }
} }
void notifyPrevPage(Widget* _sender) void notifyPrevPage(MyGUI::Widget* _sender)
{ {
if (!mStates.empty ()) if (!mStates.empty ())
{ {
@ -430,7 +427,7 @@ namespace
} }
// glue the implementation to the interface // glue the implementation to the interface
JournalWindow * MWGui::JournalWindow::create (JournalViewModel::Ptr Model) MWGui::JournalWindow * MWGui::JournalWindow::create (JournalViewModel::Ptr Model)
{ {
return new JournalWindowImpl (Model); return new JournalWindowImpl (Model);
} }