forked from mirror/openmw-tes3mp
Assign the PageDisplay on initialization
This commit is contained in:
parent
5ea7446eeb
commit
373c1e7602
1 changed files with 29 additions and 36 deletions
|
@ -1252,72 +1252,65 @@ class BookPageImpl : public BookPage
|
|||
MYGUI_RTTI_DERIVED(BookPage)
|
||||
public:
|
||||
|
||||
BookPageImpl()
|
||||
: mPageDisplay(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
void showPage (TypesetBook::Ptr book, size_t page)
|
||||
{
|
||||
if (PageDisplay* pd = dynamic_cast <PageDisplay*> (getSubWidgetText ()))
|
||||
pd->showPage (book, page);
|
||||
else
|
||||
throw std::runtime_error ("The main sub-widget for a BookPage must be a PageDisplay.");
|
||||
mPageDisplay->showPage (book, page);
|
||||
}
|
||||
|
||||
void adviseLinkClicked (boost::function <void (InteractiveId)> linkClicked)
|
||||
{
|
||||
if (PageDisplay* pd = dynamic_cast <PageDisplay*> (getSubWidgetText ()))
|
||||
{
|
||||
pd->mLinkClicked = linkClicked;
|
||||
}
|
||||
mPageDisplay->mLinkClicked = linkClicked;
|
||||
}
|
||||
|
||||
void unadviseLinkClicked ()
|
||||
{
|
||||
if (PageDisplay* pd = dynamic_cast <PageDisplay*> (getSubWidgetText ()))
|
||||
{
|
||||
pd->mLinkClicked = boost::function <void (InteractiveId)> ();
|
||||
}
|
||||
mPageDisplay->mLinkClicked = boost::function <void (InteractiveId)> ();
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
virtual void initialiseOverride()
|
||||
{
|
||||
Base::initialiseOverride();
|
||||
|
||||
if (getSubWidgetText())
|
||||
{
|
||||
mPageDisplay = getSubWidgetText()->castType<PageDisplay>();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw std::runtime_error("BookPage unable to find page display sub widget");
|
||||
}
|
||||
}
|
||||
|
||||
void onMouseLostFocus(Widget* _new)
|
||||
{
|
||||
// NOTE: MyGUI also fires eventMouseLostFocus for widgets that are about to be destroyed (if they had focus).
|
||||
// Child widgets may already be destroyed! So be careful.
|
||||
if (PageDisplay* pd = dynamic_cast <PageDisplay*> (getSubWidgetText ()))
|
||||
{
|
||||
pd->onMouseLostFocus ();
|
||||
}
|
||||
else
|
||||
Widget::onMouseLostFocus (_new);
|
||||
mPageDisplay->onMouseLostFocus ();
|
||||
}
|
||||
|
||||
void onMouseMove(int left, int top)
|
||||
{
|
||||
if (PageDisplay* pd = dynamic_cast <PageDisplay*> (getSubWidgetText ()))
|
||||
{
|
||||
pd->onMouseMove (left, top);
|
||||
}
|
||||
else
|
||||
Widget::onMouseMove (left, top);
|
||||
mPageDisplay->onMouseMove (left, top);
|
||||
}
|
||||
|
||||
void onMouseButtonPressed (int left, int top, MyGUI::MouseButton id)
|
||||
{
|
||||
if (PageDisplay* pd = dynamic_cast <PageDisplay*> (getSubWidgetText ()))
|
||||
{
|
||||
pd->onMouseButtonPressed (left, top, id);
|
||||
}
|
||||
else
|
||||
Widget::onMouseButtonPressed (left, top, id);
|
||||
mPageDisplay->onMouseButtonPressed (left, top, id);
|
||||
}
|
||||
|
||||
void onMouseButtonReleased(int left, int top, MyGUI::MouseButton id)
|
||||
{
|
||||
if (PageDisplay* pd = dynamic_cast <PageDisplay*> (getSubWidgetText ()))
|
||||
{
|
||||
pd->onMouseButtonReleased (left, top, id);
|
||||
}
|
||||
else
|
||||
Widget::onMouseButtonReleased (left, top, id);
|
||||
mPageDisplay->onMouseButtonReleased (left, top, id);
|
||||
}
|
||||
|
||||
PageDisplay* mPageDisplay;
|
||||
};
|
||||
|
||||
void BookPage::registerMyGUIComponents ()
|
||||
|
|
Loading…
Reference in a new issue