Commit 02c6785e authored by bitplane's avatar bitplane

fixed a messagebox bug when no okay button was present

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@663 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 93dc18fc
...@@ -91,6 +91,8 @@ Changes in version 1.3.1 (?? Mar 2007) ...@@ -91,6 +91,8 @@ Changes in version 1.3.1 (?? Mar 2007)
GUI: GUI:
- Fixed a messagebox focus bug when no 'okay' button was present
- Added setColor and setScaleImage to GUIImage. - Added setColor and setScaleImage to GUIImage.
- Made GUIListBox clip properly. - Made GUIListBox clip properly.
......
...@@ -47,6 +47,7 @@ CGUIMessageBox::CGUIMessageBox(IGUIEnvironment* environment, const wchar_t* capt ...@@ -47,6 +47,7 @@ CGUIMessageBox::CGUIMessageBox(IGUIEnvironment* environment, const wchar_t* capt
void CGUIMessageBox::refreshControls() void CGUIMessageBox::refreshControls()
{ {
IGUISkin* skin = Environment->getSkin(); IGUISkin* skin = Environment->getSkin();
IGUIElement* focusMe = 0;
s32 buttonHeight = skin->getSize(EGDS_BUTTON_HEIGHT); s32 buttonHeight = skin->getSize(EGDS_BUTTON_HEIGHT);
s32 buttonWidth = skin->getSize(EGDS_BUTTON_WIDTH); s32 buttonWidth = skin->getSize(EGDS_BUTTON_WIDTH);
...@@ -125,8 +126,7 @@ void CGUIMessageBox::refreshControls() ...@@ -125,8 +126,7 @@ void CGUIMessageBox::refreshControls()
btnRect.LowerRightCorner.X += buttonWidth + buttonDistance; btnRect.LowerRightCorner.X += buttonWidth + buttonDistance;
btnRect.UpperLeftCorner.X += buttonWidth + buttonDistance; btnRect.UpperLeftCorner.X += buttonWidth + buttonDistance;
if (Environment->getFocus() == this) focusMe = OkButton;
Environment->setFocus(OkButton);
} }
else if (OkButton) else if (OkButton)
{ {
...@@ -135,6 +135,35 @@ void CGUIMessageBox::refreshControls() ...@@ -135,6 +135,35 @@ void CGUIMessageBox::refreshControls()
OkButton =0; OkButton =0;
} }
// add cancel button
if (Flags & EMBF_CANCEL)
{
if (!CancelButton)
{
CancelButton = Environment->addButton(btnRect, this);
CancelButton->setSubElement(true);
CancelButton->grab();
}
else
CancelButton->setRelativePosition(btnRect);
CancelButton->setText(skin->getDefaultText(EGDT_MSG_BOX_CANCEL));
CancelButton->grab();
btnRect.LowerRightCorner.X += buttonWidth + buttonDistance;
btnRect.UpperLeftCorner.X += buttonWidth + buttonDistance;
if (!focusMe)
focusMe = CancelButton;
}
else if (CancelButton)
{
CancelButton->drop();
CancelButton->remove();
CancelButton = 0;
}
// add/remove yes button // add/remove yes button
if (Flags & EMBF_YES) if (Flags & EMBF_YES)
...@@ -152,6 +181,9 @@ void CGUIMessageBox::refreshControls() ...@@ -152,6 +181,9 @@ void CGUIMessageBox::refreshControls()
btnRect.LowerRightCorner.X += buttonWidth + buttonDistance; btnRect.LowerRightCorner.X += buttonWidth + buttonDistance;
btnRect.UpperLeftCorner.X += buttonWidth + buttonDistance; btnRect.UpperLeftCorner.X += buttonWidth + buttonDistance;
if (!focusMe)
focusMe = YesButton;
} }
else if (YesButton) else if (YesButton)
{ {
...@@ -160,7 +192,6 @@ void CGUIMessageBox::refreshControls() ...@@ -160,7 +192,6 @@ void CGUIMessageBox::refreshControls()
YesButton = 0; YesButton = 0;
} }
// add no button // add no button
if (Flags & EMBF_NO) if (Flags & EMBF_NO)
{ {
...@@ -177,6 +208,10 @@ void CGUIMessageBox::refreshControls() ...@@ -177,6 +208,10 @@ void CGUIMessageBox::refreshControls()
btnRect.LowerRightCorner.X += buttonWidth + buttonDistance; btnRect.LowerRightCorner.X += buttonWidth + buttonDistance;
btnRect.UpperLeftCorner.X += buttonWidth + buttonDistance; btnRect.UpperLeftCorner.X += buttonWidth + buttonDistance;
if (!focusMe)
focusMe = NoButton;
} }
else if (NoButton) else if (NoButton)
{ {
...@@ -185,30 +220,8 @@ void CGUIMessageBox::refreshControls() ...@@ -185,30 +220,8 @@ void CGUIMessageBox::refreshControls()
NoButton = 0; NoButton = 0;
} }
// add cancel button if (Environment->getFocus() == this && focusMe)
if (Flags & EMBF_CANCEL) Environment->setFocus(focusMe);
{
if (!CancelButton)
{
CancelButton = Environment->addButton(btnRect, this);
CancelButton->setSubElement(true);
CancelButton->grab();
}
else
CancelButton->setRelativePosition(btnRect);
CancelButton->setText(skin->getDefaultText(EGDT_MSG_BOX_CANCEL));
CancelButton->grab();
btnRect.LowerRightCorner.X += buttonWidth + buttonDistance;
btnRect.UpperLeftCorner.X += buttonWidth + buttonDistance;
}
else if (CancelButton)
{
CancelButton->drop();
CancelButton->remove();
CancelButton = 0;
}
} }
...@@ -302,7 +315,7 @@ void CGUIMessageBox::deserializeAttributes(io::IAttributes* in, io::SAttributeRe ...@@ -302,7 +315,7 @@ void CGUIMessageBox::deserializeAttributes(io::IAttributes* in, io::SAttributeRe
Flags = 0; Flags = 0;
Flags = in->getAttributeAsBool("OkayButton") ? EMBF_OK : 0; Flags = in->getAttributeAsBool("OkayButton") ? EMBF_OK : 0;
Flags |= in->getAttributeAsBool("CancelButton") ? EMBF_CANCEL : 0; Flags |= in->getAttributeAsBool("CancelButton")? EMBF_CANCEL : 0;
Flags |= in->getAttributeAsBool("YesButton") ? EMBF_YES : 0; Flags |= in->getAttributeAsBool("YesButton") ? EMBF_YES : 0;
Flags |= in->getAttributeAsBool("NoButton") ? EMBF_NO : 0; Flags |= in->getAttributeAsBool("NoButton") ? EMBF_NO : 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment