1998-05-20 10:01:55 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2006-03-30 19:01:11 -05:00
|
|
|
// Name: wx/layout.h
|
|
|
|
// Purpose: OBSOLETE layout constraint classes, use sizers instead
|
1998-05-20 10:01:55 -04:00
|
|
|
// Author: Julian Smart
|
|
|
|
// Modified by:
|
|
|
|
// Created: 29/01/98
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c) 1998 Julian Smart
|
2004-05-23 16:53:33 -04:00
|
|
|
// Licence: wxWindows licence
|
1998-05-20 10:01:55 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2006-03-30 19:01:11 -05:00
|
|
|
#ifndef _WX_LAYOUT_H_
|
|
|
|
#define _WX_LAYOUT_H_
|
1998-05-20 10:01:55 -04:00
|
|
|
|
1999-05-09 18:17:03 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// headers
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2002-09-02 14:10:39 -04:00
|
|
|
#include "wx/object.h"
|
1998-05-20 10:01:55 -04:00
|
|
|
|
|
|
|
// X stupidly defines these in X.h
|
|
|
|
#ifdef Above
|
1999-05-09 18:17:03 -04:00
|
|
|
#undef Above
|
1998-05-20 10:01:55 -04:00
|
|
|
#endif
|
|
|
|
#ifdef Below
|
1999-05-09 18:17:03 -04:00
|
|
|
#undef Below
|
1998-05-20 10:01:55 -04:00
|
|
|
#endif
|
|
|
|
|
2006-03-30 19:01:11 -05:00
|
|
|
#if wxUSE_CONSTRAINTS
|
|
|
|
|
1999-05-09 18:17:03 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// forward declrations
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class WXDLLEXPORT wxWindowBase;
|
|
|
|
class WXDLLEXPORT wxLayoutConstraints;
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// constants
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
1998-05-20 10:01:55 -04:00
|
|
|
#define wxLAYOUT_DEFAULT_MARGIN 0
|
|
|
|
|
1999-05-09 18:17:03 -04:00
|
|
|
enum wxEdge
|
|
|
|
{
|
|
|
|
wxLeft, wxTop, wxRight, wxBottom, wxWidth, wxHeight,
|
|
|
|
wxCentre, wxCenter = wxCentre, wxCentreX, wxCentreY
|
|
|
|
};
|
1998-05-20 10:01:55 -04:00
|
|
|
|
1999-05-09 18:17:03 -04:00
|
|
|
enum wxRelationship
|
1998-05-20 10:01:55 -04:00
|
|
|
{
|
1999-05-09 18:17:03 -04:00
|
|
|
wxUnconstrained = 0,
|
|
|
|
wxAsIs,
|
|
|
|
wxPercentOf,
|
|
|
|
wxAbove,
|
|
|
|
wxBelow,
|
|
|
|
wxLeftOf,
|
|
|
|
wxRightOf,
|
|
|
|
wxSameAs,
|
|
|
|
wxAbsolute
|
1998-05-20 10:01:55 -04:00
|
|
|
};
|
|
|
|
|
1999-05-09 18:17:03 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxIndividualLayoutConstraint: a constraint on window position
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class WXDLLEXPORT wxIndividualLayoutConstraint : public wxObject
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxIndividualLayoutConstraint();
|
2003-01-02 18:55:28 -05:00
|
|
|
|
|
|
|
// note that default copy ctor and assignment operators are ok
|
|
|
|
|
2006-09-05 16:47:48 -04:00
|
|
|
virtual ~wxIndividualLayoutConstraint(){}
|
1999-05-09 18:17:03 -04:00
|
|
|
|
|
|
|
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;
|
2003-01-02 18:38:11 -05:00
|
|
|
|
2003-01-02 18:55:28 -05:00
|
|
|
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;
|
2003-01-02 18:59:09 -05:00
|
|
|
|
|
|
|
DECLARE_DYNAMIC_CLASS(wxIndividualLayoutConstraint)
|
1999-05-09 18:17:03 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxLayoutConstraints: the complete set of constraints for a window
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class WXDLLEXPORT wxLayoutConstraints : public wxObject
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
// Edge constraints
|
|
|
|
wxIndividualLayoutConstraint left;
|
|
|
|
wxIndividualLayoutConstraint top;
|
|
|
|
wxIndividualLayoutConstraint right;
|
|
|
|
wxIndividualLayoutConstraint bottom;
|
|
|
|
// Size constraints
|
|
|
|
wxIndividualLayoutConstraint width;
|
|
|
|
wxIndividualLayoutConstraint height;
|
|
|
|
// Centre constraints
|
|
|
|
wxIndividualLayoutConstraint centreX;
|
|
|
|
wxIndividualLayoutConstraint centreY;
|
|
|
|
|
|
|
|
wxLayoutConstraints();
|
2003-01-02 18:55:28 -05:00
|
|
|
|
|
|
|
// note that default copy ctor and assignment operators are ok
|
|
|
|
|
2006-09-05 16:47:48 -04:00
|
|
|
virtual ~wxLayoutConstraints(){}
|
1999-05-09 18:17:03 -04:00
|
|
|
|
|
|
|
bool SatisfyConstraints(wxWindowBase *win, int *noChanges);
|
|
|
|
bool AreSatisfied() const
|
|
|
|
{
|
2000-01-21 16:38:51 -05:00
|
|
|
return left.GetDone() && top.GetDone() &&
|
|
|
|
width.GetDone() && height.GetDone();
|
1999-05-09 18:17:03 -04:00
|
|
|
}
|
2003-01-02 18:55:28 -05:00
|
|
|
|
|
|
|
DECLARE_DYNAMIC_CLASS(wxLayoutConstraints)
|
1999-05-09 18:17:03 -04:00
|
|
|
};
|
|
|
|
|
2006-03-30 19:01:11 -05:00
|
|
|
#endif // wxUSE_CONSTRAINTS
|
|
|
|
|
|
|
|
#endif // _WX_LAYOUT_H_
|