X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/cb719f2e29bd20effa3259d2d7dead9fd857442c..f081c944e891b0cc76ba648982175279bdbce904:/src/common/toplvcmn.cpp?ds=sidebyside diff --git a/src/common/toplvcmn.cpp b/src/common/toplvcmn.cpp index 8d262e70b9..c519fbc7c9 100644 --- a/src/common/toplvcmn.cpp +++ b/src/common/toplvcmn.cpp @@ -16,10 +16,6 @@ // headers // ---------------------------------------------------------------------------- -#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) - #pragma implementation "toplevelbase.h" -#endif - // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" @@ -33,6 +29,8 @@ #include "wx/app.h" #endif // WX_PRECOMP +#include "wx/display.h" + // ---------------------------------------------------------------------------- // event table // ---------------------------------------------------------------------------- @@ -46,7 +44,7 @@ END_EVENT_TABLE() // implementation // ============================================================================ -IMPLEMENT_DYNAMIC_CLASS(wxTopLevelWindow, wxWindow) +IMPLEMENT_ABSTRACT_CLASS(wxTopLevelWindow, wxWindow) // ---------------------------------------------------------------------------- // construction/destruction @@ -109,6 +107,12 @@ bool wxTopLevelWindowBase::IsLastBeforeExit() const // wxTopLevelWindow geometry // ---------------------------------------------------------------------------- +void wxTopLevelWindowBase::GetRectForTopLevelChildren(int *x, int *y, int *w, int *h) +{ + GetPosition(x,y); + GetSize(w,h); +} + wxSize wxTopLevelWindowBase::GetMaxSize() const { wxSize size( GetMaxWidth(), GetMaxHeight() ); @@ -149,6 +153,35 @@ wxSize wxTopLevelWindowBase::GetDefaultSize() return size; } +void wxTopLevelWindowBase::DoCentre(int dir) +{ + wxRect rectCentre; + if ( !(dir & wxCENTRE_ON_SCREEN) && GetParent() ) + { + // centre on parent window + rectCentre = GetParent()->GetRect(); + } + else + { + // we were explicitely asked to centre this window on the entire screen + // or if we have no parent anyhow and so can't centre on it +#if wxUSE_DISPLAY + const int nDisplay = wxDisplay::GetFromWindow(this); + if ( nDisplay != wxNOT_FOUND ) + { + rectCentre = wxDisplay(nDisplay).GetGeometry(); + } + else +#endif // wxUSE_DISPLAY + { + wxDisplaySize(&rectCentre.width, &rectCentre.height); + } + } + + // window may be at -1 if it's centered on a secondary display, for example + SetSize(GetRect().CentreIn(rectCentre, dir), wxSIZE_ALLOW_MINUS_ONE); +} + // ---------------------------------------------------------------------------- // wxTopLevelWindow size management: we exclude the areas taken by // menu/status/toolbars from the client area, so the client area is what's @@ -187,7 +220,7 @@ void wxTopLevelWindowBase::DoClientToScreen(int *x, int *y) const // default resizing behaviour - if only ONE subwindow, resize to fill the // whole client area -void wxTopLevelWindowBase::OnSize(wxSizeEvent& WXUNUSED(event)) +void wxTopLevelWindowBase::DoLayout() { // if we're using constraints or sizers - do use them if ( GetAutoLayout() ) @@ -255,9 +288,12 @@ bool wxTopLevelWindowBase::SendIconizeEvent(bool iconized) // do the window-specific processing after processing the update event void wxTopLevelWindowBase::DoUpdateWindowUI(wxUpdateUIEvent& event) { - if ( event.GetSetEnabled() ) - Enable(event.GetEnabled()); + // call inherited, but skip the wxControl's version, and call directly the + // wxWindow's one instead, because the only reason why we are overriding this + // function is that we want to use SetTitle() instead of wxControl::SetLabel() + wxWindowBase::DoUpdateWindowUI(event); + // update title if ( event.GetSetText() ) { if ( event.GetText() != GetTitle() )