engine/gui/guiBubbleTextCtrl.cc
2024-01-07 04:36:33 +00:00

74 lines
1.9 KiB
C++

//-----------------------------------------------------------------------------
// V12 Engine
//
// Copyright (c) 2001 GarageGames.Com
// Portions Copyright (c) 2001 by Sierra Online, Inc.
//-----------------------------------------------------------------------------
#include "GUI/guiBubbleTextCtrl.h"
#include "GUI/guiCanvas.h"
IMPLEMENT_CONOBJECT(GuiBubbleTextCtrl);
//------------------------------------------------------------------------------
void GuiBubbleTextCtrl::popBubble()
{
// Release the mouse:
mInAction = false;
mouseUnlock();
// Pop the dialog
getRoot()->popDialogControl(mDlg);
// Kill the popup
mDlg->removeObject(mPopup);
mPopup->removeObject(mMLText);
mMLText->deleteObject();
mPopup->deleteObject();
mDlg->deleteObject();
}
//------------------------------------------------------------------------------
void GuiBubbleTextCtrl::onMouseDown(const GuiEvent &event)
{
if (mInAction)
{
popBubble();
return;
}
mDlg = new GuiControl();
AssertFatal(mDlg, "Failed to create the GuiControl for the BubbleTextCtrl");
mDlg->setField("profile","GuiModelessDialogProfile");
mDlg->setField("horizSizing", "width");
mDlg->setField("vertSizing", "height");
mDlg->setField("extent", "640 480");
mPopup = new GuiControl();
AssertFatal(mPopup, "Failed to create the GuiControl for the BubbleTextCtrl");
mPopup->setField("profile","GuiBubblePopupProfile");
mMLText = new GuiMLTextCtrl();
AssertFatal(mMLText, "Failed to create the GuiMLTextCtrl for the BubbleTextCtrl");
mMLText->setField("profile","GuiBubbleTextProfile");
mMLText->setField("position", "2 2");
mMLText->setField("extent", "296 51");
mMLText->setText(mText,dStrlen(mText));
mMLText->registerObject();
mPopup->registerObject();
mDlg->registerObject();
mPopup->addObject(mMLText);
mDlg->addObject(mPopup);
mPopup->resize(event.mousePoint,Point2I(300,55));
getRoot()->pushDialogControl(mDlg,0);
mouseLock();
mInAction = true;
}