Replaced old wxSizer,
Converted two of wxGTK's standard dialogs to use them, Applied two fixes to wxDC code, Made wxRadiobox a little smaller, Added sizer.h to wx.h git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3325 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -62,19 +62,6 @@ enum wxRelationship
|
||||
wxAbsolute
|
||||
};
|
||||
|
||||
enum wxSizerBehaviour
|
||||
{
|
||||
wxSizerShrink,
|
||||
wxSizerExpand,
|
||||
wxSizerNone
|
||||
};
|
||||
|
||||
#define wxTYPE_SIZER 90
|
||||
|
||||
// =============================================================================
|
||||
// classes
|
||||
// =============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxIndividualLayoutConstraint: a constraint on window position
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -195,157 +182,5 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// sizers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
|
||||
Algorithm:
|
||||
|
||||
Each sizer has a Layout function.
|
||||
|
||||
wxExpandSizer::Layout ; E.g. for resizeable windows
|
||||
|
||||
- parent size must be known (i.e. called
|
||||
from OnSize or explicitly)
|
||||
- call Layout on each child to give it a chance to resize
|
||||
(e.g. child shrinks around its own children):
|
||||
stop when all children return TRUE, or no change
|
||||
- evaluate constraints on self to set size
|
||||
|
||||
wxShrinkSizer::Layout ; E.g. fit-to-contents windows
|
||||
; Perhaps 2 rowcols, one above other.
|
||||
|
||||
- call Layout on each child to give it a chance to resize
|
||||
(e.g. child shrinks around its own children):
|
||||
stop when each returns TRUE, or no change
|
||||
- fit around children
|
||||
(what if some want to be centred? E.g. OK/Cancel rowcol.
|
||||
- done by centring e.g. bottom sizer w.r.t. top sizer.
|
||||
(sibling relationship only))
|
||||
- evaluate own constraints (e.g. may be below another window)
|
||||
- IF parent is a real window (remember: a real window can
|
||||
have only one child sizer, although a sizer can have several child
|
||||
(real) windows), then resize this parent WITHOUT invoking Layout
|
||||
again.
|
||||
Frame and dialog box OnSizes can check if the sizer is a shrink
|
||||
sizer; if not, can call layout. Maybe have virtual bool AutoSizeLayout()
|
||||
to determine this.
|
||||
|
||||
How to relayout if a child sizer/window changes? Need to go all the way
|
||||
to the top of the hierarchy and call Layout() again.
|
||||
|
||||
wxRowColSizer::Layout
|
||||
|
||||
- Similar to wxShrinkSizer only instead of shrinking to fit
|
||||
contents, more sophisticated layout of contents, and THEN
|
||||
shrinking (possibly).
|
||||
- Do the same parent window check/setsize as for wxShrinkSizer.
|
||||
|
||||
*/
|
||||
|
||||
class WXDLLEXPORT wxSizer : public wxWindow
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxSizer)
|
||||
|
||||
protected:
|
||||
wxSizerBehaviour sizerBehaviour;
|
||||
int borderX;
|
||||
int borderY;
|
||||
int sizerWidth;
|
||||
int sizerHeight;
|
||||
int sizerX;
|
||||
int sizerY;
|
||||
|
||||
public:
|
||||
wxSizer();
|
||||
wxSizer(wxWindowBase *parent, wxSizerBehaviour behav = wxSizerNone);
|
||||
~wxSizer();
|
||||
|
||||
bool Create(wxWindowBase *parent, wxSizerBehaviour behav = wxSizerNone);
|
||||
|
||||
virtual void DoGetSize(int *w, int *h) const;
|
||||
virtual void DoGetClientSize(int *w, int *h) const { GetSize(w, h); }
|
||||
virtual void DoGetPosition(int *x, int *y) const;
|
||||
|
||||
void SizerSetSize(int x, int y, int w, int h) { SetSize(x, y, w, h); }
|
||||
void SizerMove(int x, int y) { Move(x, y); }
|
||||
|
||||
virtual void SetBorder(int w, int h);
|
||||
int GetBorderX() { return borderX ; }
|
||||
int GetBorderY() { return borderY ; }
|
||||
|
||||
virtual void AddSizerChild(wxWindowBase *child);
|
||||
virtual void RemoveSizerChild(wxWindowBase *child);
|
||||
|
||||
virtual void SetBehaviour(wxSizerBehaviour b) { sizerBehaviour = b; }
|
||||
virtual wxSizerBehaviour GetBehaviour() { return sizerBehaviour; }
|
||||
|
||||
virtual bool LayoutPhase1(int *);
|
||||
virtual bool LayoutPhase2(int *);
|
||||
|
||||
protected:
|
||||
virtual void DoSetSize(int x, int y,
|
||||
int width, int height,
|
||||
int sizeFlags = wxSIZE_AUTO);
|
||||
};
|
||||
|
||||
#define wxSIZER_ROWS TRUE
|
||||
#define wxSIZER_COLS FALSE
|
||||
|
||||
class WXDLLEXPORT wxRowColSizer : public wxSizer
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxRowColSizer)
|
||||
|
||||
protected:
|
||||
bool rowOrCol;
|
||||
int rowOrColSize;
|
||||
int xSpacing;
|
||||
int ySpacing;
|
||||
|
||||
public:
|
||||
// rowOrCol = TRUE to be laid out in rows, otherwise in columns.
|
||||
wxRowColSizer();
|
||||
wxRowColSizer(wxWindowBase *parent, bool rowOrCol = wxSIZER_ROWS,
|
||||
int rowsOrColSize = 20, wxSizerBehaviour = wxSizerShrink);
|
||||
~wxRowColSizer();
|
||||
|
||||
bool Create(wxWindowBase *parent, bool rowOrCol = wxSIZER_ROWS,
|
||||
int rowsOrColSize = 20, wxSizerBehaviour = wxSizerShrink);
|
||||
|
||||
virtual void SetRowOrCol(bool rc) { rowOrCol = rc; }
|
||||
virtual bool GetRowOrCol() { return rowOrCol; }
|
||||
virtual void SetRowOrColSize(int n) { rowOrColSize = n; }
|
||||
virtual int GetRowOrColSize() { return rowOrColSize; }
|
||||
virtual void SetSpacing(int x, int y) { xSpacing = x; ySpacing = y; }
|
||||
virtual void GetSpacing(int *x, int *y) { *x = xSpacing; *y = ySpacing; }
|
||||
|
||||
bool LayoutPhase1(int *);
|
||||
bool LayoutPhase2(int *);
|
||||
};
|
||||
|
||||
class WXDLLEXPORT wxSpacingSizer : public wxSizer
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxSpacingSizer)
|
||||
|
||||
public:
|
||||
wxSpacingSizer();
|
||||
wxSpacingSizer(wxWindowBase *parent, wxRelationship rel, wxWindowBase *other, int spacing);
|
||||
wxSpacingSizer(wxWindowBase *parent);
|
||||
~wxSpacingSizer();
|
||||
|
||||
bool Create(wxWindowBase *parent, wxRelationship rel, wxWindowBase *other, int sp);
|
||||
bool Create(wxWindowBase *parent);
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// global functions
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if WXWIN_COMPATIBILITY
|
||||
extern bool WXDLLEXPORT wxOldDoLayout(wxWindowBase *win);
|
||||
#endif // WXWIN_COMPATIBILITY
|
||||
|
||||
#endif
|
||||
// _WX_LAYOUTH__
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: sizer.h
|
||||
// Purpose: provide wxNewSizer class for layounting
|
||||
// Purpose: provide wxSizer class for layounting
|
||||
// Author: Robert Roebling and Robin Dunn
|
||||
// Modified by:
|
||||
// Created:
|
||||
@@ -26,38 +26,37 @@
|
||||
// classes
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
class wxNewSizerItem;
|
||||
class wxNewSizer;
|
||||
class wxBorderNewSizer;
|
||||
class wxBoxNewSizer;
|
||||
class wxSizerItem;
|
||||
class wxSizer;
|
||||
class wxBox;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// wxNewSizerItem
|
||||
// wxSizerItem
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxNewSizerItem: public wxObject
|
||||
class WXDLLEXPORT wxSizerItem: public wxObject
|
||||
{
|
||||
public:
|
||||
// spacer
|
||||
wxNewSizerItem( int width, int height, int option, int flag, int border );
|
||||
wxSizerItem( int width, int height, int option, int flag, int border );
|
||||
|
||||
// window
|
||||
wxNewSizerItem( wxWindow *window, int option, int flag, int border );
|
||||
wxSizerItem( wxWindow *window, int option, int flag, int border );
|
||||
|
||||
// subsizer
|
||||
wxNewSizerItem( wxNewSizer *sizer, int option, int flag, int border );
|
||||
wxSizerItem( wxSizer *sizer, int option, int flag, int border );
|
||||
|
||||
virtual wxSize GetSize();
|
||||
virtual wxSize CalcMin();
|
||||
virtual void SetDimension( wxPoint pos, wxSize size );
|
||||
|
||||
bool IsWindow();
|
||||
bool IsNewSizer();
|
||||
bool IsSizer();
|
||||
bool IsSpacer();
|
||||
|
||||
wxWindow *GetWindow() const
|
||||
{ return m_window; }
|
||||
wxNewSizer *GetNewSizer() const
|
||||
wxSizer *GetSizer() const
|
||||
{ return m_sizer; }
|
||||
int GetOption() const
|
||||
{ return m_option; }
|
||||
@@ -68,7 +67,7 @@ public:
|
||||
|
||||
protected:
|
||||
wxWindow *m_window;
|
||||
wxNewSizer *m_sizer;
|
||||
wxSizer *m_sizer;
|
||||
wxSize m_size;
|
||||
wxSize m_minSize;
|
||||
int m_option;
|
||||
@@ -77,17 +76,17 @@ protected:
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// wxNewSizer
|
||||
// wxSizer
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxNewSizer: public wxObject
|
||||
class WXDLLEXPORT wxSizer: public wxObject
|
||||
{
|
||||
public:
|
||||
wxNewSizer();
|
||||
~wxNewSizer();
|
||||
wxSizer();
|
||||
~wxSizer();
|
||||
|
||||
virtual void Add( wxWindow *window, int option = 0, int flag = 0, int border = 0 );
|
||||
virtual void Add( wxNewSizer *sizer, int option = 0, int flag = 0, int border = 0 );
|
||||
virtual void Add( wxSizer *sizer, int option = 0, int flag = 0, int border = 0 );
|
||||
virtual void Add( int width, int height, int option = 0, int flag = 0, int border = 0 );
|
||||
|
||||
void SetDimension( int x, int y, int width, int height );
|
||||
@@ -119,7 +118,7 @@ protected:
|
||||
// wxBox
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxBox: public wxNewSizer
|
||||
class WXDLLEXPORT wxBox: public wxSizer
|
||||
{
|
||||
public:
|
||||
wxBox( int orient );
|
||||
|
@@ -606,7 +606,6 @@ public:
|
||||
virtual bool DoPhase(int);
|
||||
|
||||
// these methods are virtual but normally won't be overridden
|
||||
virtual void TransformSizerToActual(int *x, int *y) const ;
|
||||
virtual void SetSizeConstraint(int x, int y, int w, int h);
|
||||
virtual void MoveConstraint(int x, int y);
|
||||
virtual void GetSizeConstraint(int *w, int *h) const ;
|
||||
@@ -617,12 +616,6 @@ public:
|
||||
// TODO: what are they and how do they work??
|
||||
void SetSizer( wxSizer *sizer );
|
||||
wxSizer *GetSizer() const { return m_windowSizer; }
|
||||
|
||||
void SetSizerParent( wxWindowBase *win ) { m_sizerParent = win; }
|
||||
wxWindowBase *GetSizerParent() const { return m_sizerParent; }
|
||||
|
||||
virtual void SizerSetSize(int x, int y, int w, int h);
|
||||
virtual void SizerMove(int x, int y);
|
||||
#endif // wxUSE_CONSTRAINTS
|
||||
|
||||
// backward compatibility
|
||||
|
@@ -56,6 +56,7 @@
|
||||
#include "wx/gauge.h"
|
||||
#include "wx/combobox.h"
|
||||
#include "wx/layout.h"
|
||||
#include "wx/sizer.h"
|
||||
#include "wx/memory.h"
|
||||
#include "wx/mdi.h"
|
||||
#include "wx/scrolwin.h"
|
||||
|
Reference in New Issue
Block a user