limit TLW size to display size in wxSizer::Fit() instead of doing it in wxTLW::GetMaxSize(), this allows creating or manually resizing TLWs to be larger than the display while still avoiding making them too big by default
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43617 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -575,7 +575,6 @@ protected:
|
|||||||
wxSize GetMinWindowSize( wxWindow *window );
|
wxSize GetMinWindowSize( wxWindow *window );
|
||||||
wxSize GetMaxClientSize( wxWindow *window ) const;
|
wxSize GetMaxClientSize( wxWindow *window ) const;
|
||||||
wxSize GetMinClientSize( wxWindow *window );
|
wxSize GetMinClientSize( wxWindow *window );
|
||||||
wxSize FitSize( wxWindow *window );
|
|
||||||
wxSize VirtualFitSize( wxWindow *window );
|
wxSize VirtualFitSize( wxWindow *window );
|
||||||
|
|
||||||
virtual void DoSetMinSize( int width, int height );
|
virtual void DoSetMinSize( int width, int height );
|
||||||
|
@@ -233,7 +233,6 @@ public:
|
|||||||
virtual bool Destroy();
|
virtual bool Destroy();
|
||||||
virtual bool IsTopLevel() const { return true; }
|
virtual bool IsTopLevel() const { return true; }
|
||||||
virtual bool IsVisible() const { return IsShown(); }
|
virtual bool IsVisible() const { return IsShown(); }
|
||||||
virtual wxSize GetMaxSize() const;
|
|
||||||
|
|
||||||
// event handlers
|
// event handlers
|
||||||
void OnCloseWindow(wxCloseEvent& event);
|
void OnCloseWindow(wxCloseEvent& event);
|
||||||
|
@@ -17,6 +17,7 @@
|
|||||||
#pragma hdrstop
|
#pragma hdrstop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "wx/display.h"
|
||||||
#include "wx/sizer.h"
|
#include "wx/sizer.h"
|
||||||
|
|
||||||
#ifndef WX_PRECOMP
|
#ifndef WX_PRECOMP
|
||||||
@@ -760,8 +761,37 @@ void wxSizer::DeleteWindows()
|
|||||||
|
|
||||||
wxSize wxSizer::Fit( wxWindow *window )
|
wxSize wxSizer::Fit( wxWindow *window )
|
||||||
{
|
{
|
||||||
wxSize size(window->IsTopLevel() ? FitSize(window)
|
// take the min size by default and limit it by max size
|
||||||
: GetMinWindowSize(window));
|
wxSize size = GetMinWindowSize(window);
|
||||||
|
wxSize sizeMax = GetMaxWindowSize(window);
|
||||||
|
|
||||||
|
wxTopLevelWindow *tlw = wxDynamicCast(window, wxTopLevelWindow);
|
||||||
|
if ( tlw )
|
||||||
|
{
|
||||||
|
// hack for small screen devices where TLWs are always full screen
|
||||||
|
if ( tlw->IsAlwaysMaximized() )
|
||||||
|
{
|
||||||
|
size = tlw->GetSize();
|
||||||
|
}
|
||||||
|
else // normal situation
|
||||||
|
{
|
||||||
|
// limit the window to the size of the display it is on
|
||||||
|
int disp = wxDisplay::GetFromWindow(window);
|
||||||
|
if ( disp == wxNOT_FOUND )
|
||||||
|
{
|
||||||
|
// or, if we don't know which one it is, of the main one
|
||||||
|
disp = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
sizeMax = wxDisplay(disp).GetClientArea().GetSize();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( sizeMax.x != wxDefaultCoord && size.x > sizeMax.x )
|
||||||
|
size.x = sizeMax.x;
|
||||||
|
if ( sizeMax.y != wxDefaultCoord && size.y > sizeMax.y )
|
||||||
|
size.y = sizeMax.y;
|
||||||
|
|
||||||
|
|
||||||
window->SetSize( size );
|
window->SetSize( size );
|
||||||
|
|
||||||
@@ -833,32 +863,6 @@ wxSize wxSizer::GetMinWindowSize( wxWindow *window )
|
|||||||
// TODO on mac we need a function that determines how much free space this
|
// TODO on mac we need a function that determines how much free space this
|
||||||
// min size contains, in order to make sure that we have 20 pixels of free
|
// min size contains, in order to make sure that we have 20 pixels of free
|
||||||
// space around the controls
|
// space around the controls
|
||||||
|
|
||||||
// Return a window size that will fit within the screens dimensions
|
|
||||||
wxSize wxSizer::FitSize( wxWindow *window )
|
|
||||||
{
|
|
||||||
if ( window->IsTopLevel() )
|
|
||||||
{
|
|
||||||
wxTopLevelWindow *tlw = wxDynamicCast(window, wxTopLevelWindow);
|
|
||||||
if ( tlw && tlw->IsAlwaysMaximized() )
|
|
||||||
{
|
|
||||||
return tlw->GetClientSize();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
wxSize size = GetMinWindowSize( window );
|
|
||||||
wxSize sizeMax = GetMaxWindowSize( window );
|
|
||||||
|
|
||||||
// Limit the size if sizeMax != wxDefaultSize
|
|
||||||
|
|
||||||
if ( size.x > sizeMax.x && sizeMax.x != wxDefaultCoord )
|
|
||||||
size.x = sizeMax.x;
|
|
||||||
if ( size.y > sizeMax.y && sizeMax.y != wxDefaultCoord )
|
|
||||||
size.y = sizeMax.y;
|
|
||||||
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
|
|
||||||
wxSize wxSizer::GetMaxClientSize( wxWindow *window ) const
|
wxSize wxSizer::GetMaxClientSize( wxWindow *window ) const
|
||||||
{
|
{
|
||||||
wxSize maxSize( window->GetMaxSize() );
|
wxSize maxSize( window->GetMaxSize() );
|
||||||
|
@@ -173,22 +173,6 @@ void wxTopLevelWindowBase::GetRectForTopLevelChildren(int *x, int *y, int *w, in
|
|||||||
GetSize(w,h);
|
GetSize(w,h);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxSize wxTopLevelWindowBase::GetMaxSize() const
|
|
||||||
{
|
|
||||||
wxSize size = wxWindow::GetMaxSize();
|
|
||||||
|
|
||||||
int w, h;
|
|
||||||
wxClientDisplayRect(NULL, NULL, &w, &h );
|
|
||||||
|
|
||||||
if ( size.GetWidth() == wxDefaultCoord )
|
|
||||||
size.SetWidth(w);
|
|
||||||
|
|
||||||
if ( size.GetHeight() == wxDefaultCoord )
|
|
||||||
size.SetHeight(h);
|
|
||||||
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* static */
|
/* static */
|
||||||
wxSize wxTopLevelWindowBase::GetDefaultSize()
|
wxSize wxTopLevelWindowBase::GetDefaultSize()
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user