Back to index

plt-scheme  4.2.1
Layout.h
Go to the documentation of this file.
00001 /*                                                      -*- C++ -*-
00002  *
00003  * Purpose: layout classes
00004  *
00005  * Authors: Markus Holzem and Julian Smart
00006  *
00007  * Copyright: (C) 2004-2009 PLT Scheme Inc.
00008  * Copyright: (C) 1995, AIAI, University of Edinburgh (Julian)
00009  * Copyright: (C) 1995, GNU (Markus)
00010  *
00011  * This program is free software; you can redistribute it and/or modify
00012  * it under the terms of the GNU General Public License as published by
00013  * the Free Software Foundation; either version 2 of the License, or
00014  * (at your option) any later version.
00015  *
00016  * This program is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU General Public License
00022  * along with this program; if not, write to the Free Software
00023  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00024  * 02110-1301 USA.
00025  */
00026 
00027 #ifndef Layout_h
00028 #define Layout_h
00029 
00030 #ifdef __GNUG__
00031 #pragma interface
00032 #endif
00033 
00034 class wxWindow;
00035 class wxLayoutConstraints;
00036 
00037 class wxIndividualLayoutConstraint : public wxObject {
00038 public:
00039     wxIndividualLayoutConstraint(void);
00040 
00041     void  Set(wxRelationship rel, wxWindow **otherWSR, wxEdge otherE,
00042              int val = 0, int marg = wxLAYOUT_DEFAULT_MARGIN);
00043     // Sibling relationships
00044     inline void  LeftOf(wxWindow **sibling, int marg = wxLAYOUT_DEFAULT_MARGIN)
00045        { Set(wxLeftOf, sibling, wxLeft, 0, marg); }
00046     inline void  RightOf(wxWindow **sibling, int marg = wxLAYOUT_DEFAULT_MARGIN)
00047        { Set(wxRightOf, sibling, wxRight, 0, marg); }
00048     inline void  Above(wxWindow **sibling, int marg = wxLAYOUT_DEFAULT_MARGIN)
00049        { Set(wxAbove, sibling, wxTop, 0, marg); }
00050     inline void  Below(wxWindow **sibling, int marg = wxLAYOUT_DEFAULT_MARGIN)
00051        { Set(wxBelow, sibling, wxBottom, 0, marg); }
00052     // 'Same edge' alignment
00053     inline void  SameAs(wxWindow **otherW, wxEdge edge, int marg=wxLAYOUT_DEFAULT_MARGIN)
00054        { Set(wxPercentOf, otherW, edge, 0, marg); percent = 100; }
00055     // The edge is a percentage of the other window's edge
00056     void  PercentOf(wxWindow **otherWSR, wxEdge wh, int per);
00057     // Edge has absolute value
00058     inline void Absolute(int val)
00059        { value = val; relationship = wxAbsolute; }
00060     // Dimension is unconstrained
00061     inline void Unconstrained(void)
00062        { relationship = wxUnconstrained; }
00063     // Dimension is 'as is' (use current size settings)
00064     inline void AsIs(void)
00065        { relationship = wxAsIs; }
00066     // Try to satisfy constraint
00067     Bool SatisfyConstraint(wxLayoutConstraints *constraints, wxWindow *win);
00068     // Get the value of this edge or dimension, or if this
00069     // is not determinable, -1.
00070     int GetEdge(wxEdge which, wxWindow *thisWin, wxWindow *other);
00071 private:
00072     friend class wxLayoutConstraints;
00073     friend class wxWindow;
00074 
00075     wxWindow  **otherWinSR; // parent or sibling of 'this' window
00076     wxEdge    otherEdge;    // edge of parent or sibling
00077 
00078     wxEdge       myEdge;    // constraints for this edge
00079     wxRelationship relationship;// relationship to otherWin
00080     int                 margin;    // margin to otherWin
00081     int                 value;     // value of this contraint
00082     int                 percent;   // percent of otherWin's edge
00083     Bool         done;      // used for wxDoLayout
00084 };
00085 
00086 #ifdef MZ_PRECISE_GC
00087 # define wxLC_DECL(x) *x
00088 # define wxLC_MEM(x, m) x->m
00089 # define wxLC_ADDR(x) x
00090 #else
00091 # define wxLC_DECL(x) x
00092 # define wxLC_MEM(x, m) x.m
00093 # define wxLC_ADDR(x) &x
00094 #endif
00095 
00096 class wxLayoutConstraints : public wxObject {
00097 public:
00098     wxLayoutConstraints(void);
00099 
00100     // satisfy all individual constraints
00101     Bool SatisfyConstraints(wxWindow *child);
00102     void UnDone(void);
00103 
00104     // Edge constraints
00105     wxIndividualLayoutConstraint wxLC_DECL(left);
00106     wxIndividualLayoutConstraint wxLC_DECL(top);
00107     wxIndividualLayoutConstraint wxLC_DECL(right);
00108     wxIndividualLayoutConstraint wxLC_DECL(bottom);
00109     // Size constraints
00110     wxIndividualLayoutConstraint wxLC_DECL(width);
00111     wxIndividualLayoutConstraint wxLC_DECL(height);
00112     // Centre constraints
00113     wxIndividualLayoutConstraint wxLC_DECL(centreX);
00114     wxIndividualLayoutConstraint wxLC_DECL(centreY);
00115 };
00116 
00117 #endif // Layout_h