wxWidgets/include/wx/layout.h
Robert Roebling 3417c2cd3d 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
1999-08-09 17:00:51 +00:00

187 lines
5.3 KiB
C++

/////////////////////////////////////////////////////////////////////////////
// Name: layout.h
// Purpose: Layout classes
// Author: Julian Smart
// Modified by:
// Created: 29/01/98
// RCS-ID: $Id$
// Copyright: (c) 1998 Julian Smart
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_LAYOUTH__
#define _WX_LAYOUTH__
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#ifdef __GNUG__
#pragma interface "layout.h"
#endif
#include "wx/defs.h"
// X stupidly defines these in X.h
#ifdef Above
#undef Above
#endif
#ifdef 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
};
// ----------------------------------------------------------------------------
// 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();
}
};
#endif
// _WX_LAYOUTH__