1998-05-20 14:01:55 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: layout.h
|
|
|
|
// Purpose: Layout classes
|
|
|
|
// Author: Julian Smart
|
|
|
|
// Modified by:
|
|
|
|
// Created: 29/01/98
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c) 1998 Julian Smart
|
2004-05-23 20:53:33 +00:00
|
|
|
// Licence: wxWindows licence
|
1998-05-20 14:01:55 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
1998-08-15 00:23:28 +00:00
|
|
|
#ifndef _WX_LAYOUTH__
|
|
|
|
#define _WX_LAYOUTH__
|
1998-05-20 14:01:55 +00:00
|
|
|
|
1999-05-09 22:17:03 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// headers
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2003-08-09 12:38:21 +00:00
|
|
|
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
|
1999-05-09 22:17:03 +00:00
|
|
|
#pragma interface "layout.h"
|
1998-05-20 14:01:55 +00:00
|
|
|
#endif
|
|
|
|
|
2002-09-02 18:10:39 +00:00
|
|
|
#include "wx/object.h"
|
1998-05-20 14:01:55 +00:00
|
|
|
|
|
|
|
// X stupidly defines these in X.h
|
|
|
|
#ifdef Above
|
1999-05-09 22:17:03 +00:00
|
|
|
#undef Above
|
1998-05-20 14:01:55 +00:00
|
|
|
#endif
|
|
|
|
#ifdef Below
|
1999-05-09 22:17:03 +00:00
|
|
|
#undef Below
|
1998-05-20 14:01:55 +00:00
|
|
|
#endif
|
|
|
|
|
1999-05-09 22:17:03 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// forward declrations
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class WXDLLEXPORT wxWindowBase;
|
|
|
|
class WXDLLEXPORT wxLayoutConstraints;
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// constants
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
1998-05-20 14:01:55 +00:00
|
|
|
#define wxLAYOUT_DEFAULT_MARGIN 0
|
|
|
|
|
1999-05-09 22:17:03 +00:00
|
|
|
enum wxEdge
|
|
|
|
{
|
|
|
|
wxLeft, wxTop, wxRight, wxBottom, wxWidth, wxHeight,
|
|
|
|
wxCentre, wxCenter = wxCentre, wxCentreX, wxCentreY
|
|
|
|
};
|
1998-05-20 14:01:55 +00:00
|
|
|
|
1999-05-09 22:17:03 +00:00
|
|
|
enum wxRelationship
|
1998-05-20 14:01:55 +00:00
|
|
|
{
|
1999-05-09 22:17:03 +00:00
|
|
|
wxUnconstrained = 0,
|
|
|
|
wxAsIs,
|
|
|
|
wxPercentOf,
|
|
|
|
wxAbove,
|
|
|
|
wxBelow,
|
|
|
|
wxLeftOf,
|
|
|
|
wxRightOf,
|
|
|
|
wxSameAs,
|
|
|
|
wxAbsolute
|
1998-05-20 14:01:55 +00:00
|
|
|
};
|
|
|
|
|
1999-05-09 22:17:03 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxIndividualLayoutConstraint: a constraint on window position
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class WXDLLEXPORT wxIndividualLayoutConstraint : public wxObject
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxIndividualLayoutConstraint();
|
2003-01-02 23:55:28 +00:00
|
|
|
|
|
|
|
// note that default copy ctor and assignment operators are ok
|
|
|
|
|
1999-05-09 22:17:03 +00:00
|
|
|
~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;
|
2003-01-02 23:38:11 +00:00
|
|
|
|
2003-01-02 23:55:28 +00: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 23:59:09 +00:00
|
|
|
|
|
|
|
DECLARE_DYNAMIC_CLASS(wxIndividualLayoutConstraint)
|
1999-05-09 22:17:03 +00: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 23:55:28 +00:00
|
|
|
|
|
|
|
// note that default copy ctor and assignment operators are ok
|
|
|
|
|
1999-05-09 22:17:03 +00:00
|
|
|
~wxLayoutConstraints();
|
|
|
|
|
|
|
|
bool SatisfyConstraints(wxWindowBase *win, int *noChanges);
|
|
|
|
bool AreSatisfied() const
|
|
|
|
{
|
2000-01-21 21:38:51 +00:00
|
|
|
return left.GetDone() && top.GetDone() &&
|
|
|
|
width.GetDone() && height.GetDone();
|
1999-05-09 22:17:03 +00:00
|
|
|
}
|
2003-01-02 23:55:28 +00:00
|
|
|
|
|
|
|
DECLARE_DYNAMIC_CLASS(wxLayoutConstraints)
|
1999-05-09 22:17:03 +00:00
|
|
|
};
|
|
|
|
|
1998-05-20 14:01:55 +00:00
|
|
|
#endif
|
1998-08-15 00:23:28 +00:00
|
|
|
// _WX_LAYOUTH__
|