|
OWLNext 6.32
|
#include <layoutwi.h>
Public Member Functions | |
| TLayoutMetrics () | |
| void | SetMeasurementUnits (TMeasurementUnits units) |
Public Attributes | |
| TEdgeConstraint | X |
| TEdgeConstraint | Y |
| TEdgeOrWidthConstraint | Width |
| TEdgeOrHeightConstraint | Height |
When specifying the layout metrics for a window, four layout constraints are needed.
TLayoutMetrics contains the four layout constraints used to define the layout metrics for a window. The following table lists the constraints you can use for the X, Y, Height, and Width fields.
X lmLeft, lmCenter, lmRightY lmTop, lmCenter, lmBottomHeight lmCenter, lmRight, lmWidthWidth lmCenter, lmBottom, lmHeightIf the metrics for the child window are relative to the parent window, the relation window pointer needs to be lmParent (not the actual parent window pointer). For example,
TWindow* child = new TWindow(this, ""); TLayoutMetrics metrics; metrics.X.Set(lmCenter, lmSameAs, lm()t, lmCenter); metrics.Y.Set(lmCenter, lmSameAs, lm()t, lmCenter); SetChildLayoutMetrics(*child, metrics);
The parent window pointer (this) should not be used as the relation window pointer of the child window.
| owl::TLayoutMetrics::TLayoutMetrics | ( | ) |
Defaults each co: RelWin=0, MyEdge=(1st from above), Relationship=AsIs.
Creates a TLayoutMetrics object and initializes the object. It sets the units for the child and parent window to the specified layout units, and the relationship between the two windows to what is defined in ImAsIs (of TRelationship). TLayoutMetrics sets the following default values:
X.RelWin = 0; X.MyEdge = lmLeft; X.Relationship = lmAsIs; X.Units = lmLayoutUnits; X.Value = 0; Y.RelWin = 0; Y.MyEdge = lmTop; Y.Relationship = lmAsIs; Y.Units = lmLayoutUnits; Y.Value = 0; Width.RelWin = 0; Width.MyEdge = lmWidth; Width.Relationship = lmAsIs; Width.Units = lmLayoutUnits; Width.Value = 0; Height.RelWin = 0; Height.MyEdge = lmHeight; Height.Relationship = lmAsIs; Height.Units = lmLayoutUnits; Height.Value = 0;
The following program creates two child windows and a frame into which you can add layout constraints.
#include <owl/owl.h> #include <owl/framewin.h> #include <owl/applicat.h> #include <owl/layoutwi.h> #include <owl/decorate.h> #include <owl/decmdifr.h> #include <owl/layoutco.h> #pragma hdrstop // Create a derived class. // class TMyDecoratedFrame : public TDecoratedFrame { public: TMyDecoratedFrame(TWindow* parent, const char far* title, TWindow& clientWnd, TWindow* MyChildWindow); void SetupWindow(); { TDecoratedFrame::SetupWindow(); MyChildWindow->ShowWindow(SW_NORMAL); MyChildWindow->BringWindowToTop(); } }; // Setup a frame window. // TMyDecoratedFrame::TMyDecoratedFrame(TWindow * parent, const char far * title, TWindow& clientWnd) : TDecoratedFrame(parent, title, clientWnd), TFrameWindow(parent, title, &clientWnd), TWindow(parent, title) { // Create a new TMyChildWindow. // MyChildWindow = new TWindow(this, ""); MyChildWindow->Attr.Style |= WS_BORDER |WS_VISIBLE |WS_CHILD; MyChildwindow->SetBkgndColor(RGB(0,100,0)); // Establish metrics for the child window. // TLayoutMetrics layoutMetrics; layoutMetrics.X.Absolute(lmLeft, 10); layoutMetrics.Y.Absolute(lmTop, 10); layoutMetrics.Width.Absolute( 80 ); layoutMetrics.Height.Absolute( 80 ); } SetChildLayoutMetrics(*MyChildWindow, layoutMetrics); class TMyApp : public TApplication { public: virtual void InitMainWindow() { TWindow* client = new TWindow(0, "title"); MainWindow = new TMyDecoratedFrame(0, "Layout Window Ex", *client); } }; int OwlMain(int, char**) { return TMyApp.Run(); }
References Height, owl::lmLeft, owl::lmTop, owl::TLayoutConstraint::MyEdge, owl::TLayoutConstraint::OtherEdge, owl::TLayoutConstraint::Relationship, owl::TLayoutConstraint::RelWin, owl::TLayoutConstraint::Units, owl::TLayoutConstraint::Value, Width, X, and Y.
Vert2 can be lmHeight, lmCenter, lmBottom.
Contains the height size constraint, center edge constraint, or bottom edge constraint of the window.
Horz2 can be lmWidth, lmCenter, lmRight.
Contains the width size constraint, center edge constraint, or right edge (lmRight) constraint of the window.
X contains the X (left, center, right) edge constraint of the window.
Horz1 can be lmLeft, lmCenter, lmRight
Y contains the Y (top, center, bottom) edge constraint of the window.
Vert1 can be lmTop, lmCenter, lmBottom
1.7.4