In another word: does widgets system any special thing to SetTopWindow'ed window?
The answer is Yes. It does.
src/common/appcmn.cpp
wxWindow* wxAppBase::GetTopWindow() const
{
wxWindow* window = m_topWindow;
if (window == NULL && wxTopLevelWindows.GetCount() > 0)
window = wxTopLevelWindows.GetFirst()->GetData();
return window;
}
Without setting, you gets nothing. :p
src/common/dlgcmn.cpp
wxWindow *wxDialogBase::GetParentForModalDialog(wxWindow *parent) const
{
// creating a parent-less modal dialog will result (under e.g. wxGTK2)
// in an unfocused dialog, so try to find a valid parent for it:
if ( parent )
parent = wxGetTopLevelParent(parent);
if ( !parent || !CanBeUsedAsParent(parent) )
parent = wxTheApp->GetTopWindow();
if ( parent && !CanBeUsedAsParent(parent) )
{
// can't use this one, it's going to disappear
parent = NULL;
}
return parent;
}
Setting TopWindow to app affects Modal state.
src/common/cshelp.pp
/ Begin 'context help mode'
bool wxContextHelp::BeginContextHelp(wxWindow* win)
{
if (!win)
win = wxTheApp->GetTopWindow();
if (!win)
return false;
wxCursor cursor(wxCURSOR_QUESTION_ARROW);
wxCursor oldCursor = win->GetCursor();
win->SetCursor(cursor);
It affects context help too.
src/msw/msgdlg.cpp
int wxMessageDialog::ShowModal()
{
if ( !wxTheApp->GetTopWindow() )
{
// when the message box is shown from wxApp::OnInit() (i.e. before the
// message loop is entered), this must be done or the next message box
// will never be shown - just try putting 2 calls to wxMessageBox() in
// OnInit() to see it
while ( wxTheApp->Pending() )
wxTheApp->Dispatch();
}
0 件のコメント:
コメントを投稿