Added knowledge of virtual size to wx(Scrolled)Windows, they can now

manage their own scrollbars with the help of a sizer or other user
clues (SetVirtualSizeHints) without the need for an ancillary container.
Added SetSizerAndFit convenience method.
SetSizer now enables/disables AutoLayout automagically.
Logic bugfix for scrollsub sample.
Syntax bugfix in parser.y.
Compiler warning fix in textctrl.cpp.

 Modified Files:
    docs/latex/wx/scrolwin.tex docs/latex/wx/sizer.tex
    docs/latex/wx/window.tex include/wx/scrolwin.h
    include/wx/sizer.h include/wx/window.h
    include/wx/generic/scrolwin.h include/wx/gtk/scrolwin.h
    samples/scrollsub/scrollsub.cpp src/common/parser.y
    src/common/sizer.cpp src/common/wincmn.cpp
    src/generic/scrlwing.cpp src/gtk/scrolwin.cpp
    src/msw/textctrl.cpp


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15210 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Ron Lee
2002-04-19 22:12:38 +00:00
parent 1d0edc0f73
commit 566d84a7c3
17 changed files with 601 additions and 309 deletions

View File

@@ -2,7 +2,7 @@
// Name: sizer.cpp
// Purpose: provide new wxSizer class for layout
// Author: Robert Roebling and Robin Dunn
// Modified by:
// Modified by: Ron Lee
// Created:
// RCS-ID: $Id$
// Copyright: (c) Robin Dunn, Dirk Holtwick and Robert Roebling
@@ -412,6 +412,17 @@ void wxSizer::Fit( wxWindow *window )
window->SetSize( size );
}
void wxSizer::FitInside( wxWindow *window )
{
wxSize size;
if (window->IsTopLevel())
size = VirtualFitSize( window );
else
size = GetMinClientSize( window );
window->SetVirtualSize( size );
}
void wxSizer::Layout()
{
CalcMin();
@@ -423,13 +434,27 @@ void wxSizer::SetSizeHints( wxWindow *window )
// Preserve the window's max size hints, but set the
// lower bound according to the sizer calculations.
wxSize size = FitSize( window );
Fit( window );
wxSize size( window->GetSize() );
window->SetSizeHints( size.x,
size.y,
window->GetMaxWidth(),
window->GetMaxHeight() );
}
void wxSizer::SetVirtualSizeHints( wxWindow *window )
{
// Preserve the window's max size hints, but set the
// lower bound according to the sizer calculations.
FitInside( window );
wxSize size( window->GetVirtualSize() );
window->SetVirtualSizeHints( size.x,
size.y,
window->GetMaxWidth(),
window->GetMaxHeight() );
}
wxSize wxSizer::GetMaxWindowSize( wxWindow *window )
{
return window->GetMaxSize();
@@ -460,6 +485,42 @@ wxSize wxSizer::FitSize( wxWindow *window )
return size;
}
wxSize wxSizer::GetMaxClientSize( wxWindow *window )
{
wxSize maxSize( window->GetMaxSize() );
if( maxSize != wxDefaultSize )
{
wxSize size( window->GetSize() );
wxSize client_size( window->GetClientSize() );
return wxSize( maxSize.x + client_size.x - size.x,
maxSize.y + client_size.y - size.y );
}
else
return wxDefaultSize;
}
wxSize wxSizer::GetMinClientSize( wxWindow *window )
{
return GetMinSize(); // Already returns client size.
}
wxSize wxSizer::VirtualFitSize( wxWindow *window )
{
wxSize size = GetMinClientSize( window );
wxSize sizeMax = GetMaxClientSize( window );
// Limit the size if sizeMax != wxDefaultSize
if ( size.x > sizeMax.x && sizeMax.x != -1 )
size.x = sizeMax.x;
if ( size.y > sizeMax.y && sizeMax.y != -1 )
size.y = sizeMax.y;
return size;
}
void wxSizer::SetDimension( int x, int y, int width, int height )
{
m_position.x = x;