Adjust BAlert to position the alert using the revamped BWindow::CenterIn() method.

BAlert::AlertPosition() has been superceded by the new BWindow method and should
be considered deprecated. Note that the alert position is not in the direct center of the
screen, it is offset vertically like before.
This commit is contained in:
John Scipione 2013-04-28 20:27:44 -04:00
parent 54153cc8b2
commit e894fbc0ac
1 changed files with 11 additions and 1 deletions

View File

@ -396,6 +396,7 @@ BAlert::QuitRequested()
}
// This method is deprecated, do not use
BPoint
BAlert::AlertPosition(float width, float height)
{
@ -572,7 +573,16 @@ BAlert::_InitObject(const char* text, const char* button0, const char* button1,
AddCommonFilter(new(std::nothrow) _BAlertFilter_(this));
MoveTo(AlertPosition(Frame().Width(), Frame().Height()));
// Position the alert so that it is centered vertically but offset a bit
// horizontally in the parent window's frame or, if unavailable, the
// screen frame.
BWindow* window =
dynamic_cast<BWindow*>(BLooper::LooperForThread(find_thread(NULL)));
const BRect frame = window != NULL ? window->Frame()
: (BScreen(this)).Frame();
CenterIn(frame.InsetByCopy(0, frame.Height() / 2)
.OffsetBySelf(0, -frame.Height() / 4));
}