wxWindow split into wxWindowBase and wxWindow (wxGTK part)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2383 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
1999-05-09 22:17:03 +00:00
parent 358d140ac9
commit f03fc89fff
101 changed files with 6352 additions and 7343 deletions

View File

@@ -12,150 +12,192 @@
#ifndef _WX_LAYOUTH__
#define _WX_LAYOUTH__
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#ifdef __GNUG__
#pragma interface "layout.h"
#pragma interface "layout.h"
#endif
#include "wx/defs.h"
class WXDLLEXPORT wxWindow;
// X stupidly defines these in X.h
#ifdef Above
#undef Above
#undef Above
#endif
#ifdef Below
#undef Below
#undef Below
#endif
// ----------------------------------------------------------------------------
// forward declrations
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxWindowBase;
class WXDLLEXPORT wxLayoutConstraints;
// ----------------------------------------------------------------------------
// constants
// ----------------------------------------------------------------------------
#define wxLAYOUT_DEFAULT_MARGIN 0
enum wxEdge { wxLeft, wxTop, wxRight, wxBottom, wxWidth, wxHeight,
wxCentre, wxCenter = wxCentre, wxCentreX, wxCentreY };
enum wxRelationship { wxUnconstrained = 0,
wxAsIs,
wxPercentOf,
wxAbove,
wxBelow,
wxLeftOf,
wxRightOf,
wxSameAs,
wxAbsolute };
class WXDLLEXPORT wxLayoutConstraints;
class WXDLLEXPORT wxIndividualLayoutConstraint: public wxObject
enum wxEdge
{
DECLARE_DYNAMIC_CLASS(wxIndividualLayoutConstraint)
protected:
// To be allowed to modify the internal variables
friend class wxIndividualLayoutConstraint_Serialize;
// 'This' window is the parent or sibling of otherWin
wxWindow *otherWin;
wxEdge myEdge;
wxRelationship relationship;
int margin;
int value;
int percent;
wxEdge otherEdge;
bool done;
public:
wxIndividualLayoutConstraint();
~wxIndividualLayoutConstraint();
void Set(wxRelationship rel, wxWindow *otherW, wxEdge otherE, int val = 0, int marg = wxLAYOUT_DEFAULT_MARGIN);
//
// Sibling relationships
//
void LeftOf(wxWindow *sibling, int marg = wxLAYOUT_DEFAULT_MARGIN);
void RightOf(wxWindow *sibling, int marg = wxLAYOUT_DEFAULT_MARGIN);
void Above(wxWindow *sibling, int marg = wxLAYOUT_DEFAULT_MARGIN);
void Below(wxWindow *sibling, int marg = wxLAYOUT_DEFAULT_MARGIN);
//
// 'Same edge' alignment
//
void SameAs(wxWindow *otherW, wxEdge edge, int marg = wxLAYOUT_DEFAULT_MARGIN);
// The edge is a percentage of the other window's edge
void PercentOf(wxWindow *otherW, wxEdge wh, int per);
//
// Edge has absolute value
//
void Absolute(int val);
//
// Dimension is unconstrained
//
inline void Unconstrained() { relationship = wxUnconstrained; }
//
// Dimension is 'as is' (use current size settings)
//
inline void AsIs() { relationship = wxAsIs; }
//
// Accessors
//
inline wxWindow *GetOtherWindow() { return otherWin; }
inline wxEdge GetMyEdge() const { return myEdge; }
inline void SetEdge(wxEdge which) { myEdge = which; }
inline void SetValue(int v) { value = v; }
inline int GetMargin() { return margin; }
inline void SetMargin(int m) { margin = m; }
inline int GetValue() const { return value; }
inline int GetPercent() const { return percent; }
inline int GetOtherEdge() const { return otherEdge; }
inline bool GetDone() const { return done; }
inline void SetDone(bool d) { done = d; }
inline wxRelationship GetRelationship() { return relationship; }
inline void SetRelationship(wxRelationship r) { relationship = r; }
// Reset constraint if it mentions otherWin
bool ResetIfWin(wxWindow *otherW);
// Try to satisfy constraint
bool SatisfyConstraint(wxLayoutConstraints *constraints, wxWindow *win);
// Get the value of this edge or dimension, or if this
// is not determinable, -1.
int GetEdge(wxEdge which, wxWindow *thisWin, wxWindow *other) const;
wxLeft, wxTop, wxRight, wxBottom, wxWidth, wxHeight,
wxCentre, wxCenter = wxCentre, wxCentreX, wxCentreY
};
class WXDLLEXPORT wxLayoutConstraints: public wxObject
enum wxRelationship
{
DECLARE_DYNAMIC_CLASS(wxLayoutConstraints)
public:
// Edge constraints
wxIndividualLayoutConstraint left;
wxIndividualLayoutConstraint top;
wxIndividualLayoutConstraint right;
wxIndividualLayoutConstraint bottom;
// Size constraints
wxIndividualLayoutConstraint width;
wxIndividualLayoutConstraint height;
// Centre constraints
wxIndividualLayoutConstraint centreX;
wxIndividualLayoutConstraint centreY;
wxLayoutConstraints();
~wxLayoutConstraints();
bool SatisfyConstraints(wxWindow *win, int *noChanges);
bool AreSatisfied() const
{
return left.GetDone() && top.GetDone() && right.GetDone() &&
bottom.GetDone() && centreX.GetDone() && centreY.GetDone();
}
wxUnconstrained = 0,
wxAsIs,
wxPercentOf,
wxAbove,
wxBelow,
wxLeftOf,
wxRightOf,
wxSameAs,
wxAbsolute
};
bool WXDLLEXPORT wxOldDoLayout(wxWindow *win);
enum wxSizerBehaviour
{
wxSizerShrink,
wxSizerExpand,
wxSizerNone
};
#define wxTYPE_SIZER 90
// =============================================================================
// classes
// =============================================================================
// ----------------------------------------------------------------------------
// wxIndividualLayoutConstraint: a constraint on window position
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxIndividualLayoutConstraint : public wxObject
{
DECLARE_DYNAMIC_CLASS(wxIndividualLayoutConstraint)
protected:
// To be allowed to modify the internal variables
friend class wxIndividualLayoutConstraint_Serialize;
// 'This' window is the parent or sibling of otherWin
wxWindowBase *otherWin;
wxEdge myEdge;
wxRelationship relationship;
int margin;
int value;
int percent;
wxEdge otherEdge;
bool done;
public:
wxIndividualLayoutConstraint();
~wxIndividualLayoutConstraint();
void Set(wxRelationship rel, wxWindowBase *otherW, wxEdge otherE, int val = 0, int marg = wxLAYOUT_DEFAULT_MARGIN);
//
// Sibling relationships
//
void LeftOf(wxWindowBase *sibling, int marg = wxLAYOUT_DEFAULT_MARGIN);
void RightOf(wxWindowBase *sibling, int marg = wxLAYOUT_DEFAULT_MARGIN);
void Above(wxWindowBase *sibling, int marg = wxLAYOUT_DEFAULT_MARGIN);
void Below(wxWindowBase *sibling, int marg = wxLAYOUT_DEFAULT_MARGIN);
//
// 'Same edge' alignment
//
void SameAs(wxWindowBase *otherW, wxEdge edge, int marg = wxLAYOUT_DEFAULT_MARGIN);
// The edge is a percentage of the other window's edge
void PercentOf(wxWindowBase *otherW, wxEdge wh, int per);
//
// Edge has absolute value
//
void Absolute(int val);
//
// Dimension is unconstrained
//
void Unconstrained() { relationship = wxUnconstrained; }
//
// Dimension is 'as is' (use current size settings)
//
void AsIs() { relationship = wxAsIs; }
//
// Accessors
//
wxWindowBase *GetOtherWindow() { return otherWin; }
wxEdge GetMyEdge() const { return myEdge; }
void SetEdge(wxEdge which) { myEdge = which; }
void SetValue(int v) { value = v; }
int GetMargin() { return margin; }
void SetMargin(int m) { margin = m; }
int GetValue() const { return value; }
int GetPercent() const { return percent; }
int GetOtherEdge() const { return otherEdge; }
bool GetDone() const { return done; }
void SetDone(bool d) { done = d; }
wxRelationship GetRelationship() { return relationship; }
void SetRelationship(wxRelationship r) { relationship = r; }
// Reset constraint if it mentions otherWin
bool ResetIfWin(wxWindowBase *otherW);
// Try to satisfy constraint
bool SatisfyConstraint(wxLayoutConstraints *constraints, wxWindowBase *win);
// Get the value of this edge or dimension, or if this
// is not determinable, -1.
int GetEdge(wxEdge which, wxWindowBase *thisWin, wxWindowBase *other) const;
};
// ----------------------------------------------------------------------------
// wxLayoutConstraints: the complete set of constraints for a window
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxLayoutConstraints : public wxObject
{
DECLARE_DYNAMIC_CLASS(wxLayoutConstraints)
public:
// Edge constraints
wxIndividualLayoutConstraint left;
wxIndividualLayoutConstraint top;
wxIndividualLayoutConstraint right;
wxIndividualLayoutConstraint bottom;
// Size constraints
wxIndividualLayoutConstraint width;
wxIndividualLayoutConstraint height;
// Centre constraints
wxIndividualLayoutConstraint centreX;
wxIndividualLayoutConstraint centreY;
wxLayoutConstraints();
~wxLayoutConstraints();
bool SatisfyConstraints(wxWindowBase *win, int *noChanges);
bool AreSatisfied() const
{
return left.GetDone() && top.GetDone() && right.GetDone() &&
bottom.GetDone() && centreX.GetDone() && centreY.GetDone();
}
};
// ----------------------------------------------------------------------------
// sizers
// ----------------------------------------------------------------------------
/*
@@ -203,18 +245,9 @@ to the top of the hierarchy and call Layout() again.
*/
enum wxSizerBehaviour
{
wxSizerShrink,
wxSizerExpand,
wxSizerNone
};
#define wxTYPE_SIZER 90
class WXDLLEXPORT wxSizer : public wxWindow
{
DECLARE_DYNAMIC_CLASS(wxSizer)
DECLARE_DYNAMIC_CLASS(wxSizer)
protected:
wxSizerBehaviour sizerBehaviour;
@@ -227,10 +260,10 @@ protected:
public:
wxSizer();
wxSizer(wxWindow *parent, wxSizerBehaviour behav = wxSizerNone);
wxSizer(wxWindowBase *parent, wxSizerBehaviour behav = wxSizerNone);
~wxSizer();
bool Create(wxWindow *parent, wxSizerBehaviour behav = wxSizerNone);
bool Create(wxWindowBase *parent, wxSizerBehaviour behav = wxSizerNone);
virtual void GetSize(int *w, int *h) const;
@@ -245,8 +278,8 @@ public:
int GetBorderX() { return borderX ; }
int GetBorderY() { return borderY ; }
virtual void AddSizerChild(wxWindow *child);
virtual void RemoveSizerChild(wxWindow *child);
virtual void AddSizerChild(wxWindowBase *child);
virtual void RemoveSizerChild(wxWindowBase *child);
virtual void SetBehaviour(wxSizerBehaviour b) { sizerBehaviour = b; }
virtual wxSizerBehaviour GetBehaviour() { return sizerBehaviour; }
@@ -265,7 +298,7 @@ protected:
class WXDLLEXPORT wxRowColSizer : public wxSizer
{
DECLARE_DYNAMIC_CLASS(wxRowColSizer)
DECLARE_DYNAMIC_CLASS(wxRowColSizer)
protected:
bool rowOrCol;
@@ -276,11 +309,11 @@ protected:
public:
// rowOrCol = TRUE to be laid out in rows, otherwise in columns.
wxRowColSizer();
wxRowColSizer(wxWindow *parent, bool rowOrCol = wxSIZER_ROWS,
wxRowColSizer(wxWindowBase *parent, bool rowOrCol = wxSIZER_ROWS,
int rowsOrColSize = 20, wxSizerBehaviour = wxSizerShrink);
~wxRowColSizer();
bool Create(wxWindow *parent, bool rowOrCol = wxSIZER_ROWS,
bool Create(wxWindowBase *parent, bool rowOrCol = wxSIZER_ROWS,
int rowsOrColSize = 20, wxSizerBehaviour = wxSizerShrink);
virtual void SetRowOrCol(bool rc) { rowOrCol = rc; }
@@ -296,17 +329,25 @@ public:
class WXDLLEXPORT wxSpacingSizer : public wxSizer
{
DECLARE_DYNAMIC_CLASS(wxSpacingSizer)
DECLARE_DYNAMIC_CLASS(wxSpacingSizer)
public:
wxSpacingSizer();
wxSpacingSizer(wxWindow *parent, wxRelationship rel, wxWindow *other, int spacing);
wxSpacingSizer(wxWindow *parent);
wxSpacingSizer(wxWindowBase *parent, wxRelationship rel, wxWindowBase *other, int spacing);
wxSpacingSizer(wxWindowBase *parent);
~wxSpacingSizer();
bool Create(wxWindow *parent, wxRelationship rel, wxWindow *other, int sp);
bool Create(wxWindow *parent);
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__