Frames are objects derived from CtrlFrame class that form appearance and functionality of area between outer Ctrl border and its view.
class CtrlFrame
Interface definition of frame classes.
~CtrlFrame()
Empty virtual destructor.
virtual void FrameLayout(Rect& r) = 0
Frame reacts to this method by defining its own layout (if needed) and reducing the size of Ctrl view rectangle.
|
r |
Reference to current Ctrl rectangle. When Ctrl recomputes its layout, it starts with Rect equivalent to its external size (GetRect().Size()). Then it calls FrameLayout of all its frames (starting with frame 0) and resulting Rect is the size of Ctrl's view. |
virtual void FrameAddSize(Size& sz) = 0
Adds size of the frame to the current external size of Ctrl. This is used to compute the external size of Ctrl for given size of view.
|
sz |
Reference to actual size of Ctrl. |
virtual void FramePaint(Draw& w, const Rect& r)
Paint the frame. Default implementation is empty.
|
r |
Outer rectangle of the frame (this is the same rectangle as was given in last FrameLayout). |
virtual void FrameAdd(Ctrl& parent)
Called when frame is added to the Ctrl. Frame can use it to add its subctrls to the parent. Default implementation is empty.
virtual void FrameRemove()
Called when frame is removed from the Ctrl. Frame can use it to remove subctrls from its parent. Default implementation is empty.
virtual int OverPaint() const
This method can returns non-zero number that represents paint extension margin of Ctrl rectangle - frame can paint over this margin despite that fact that it does not belong to the Ctrl rectangle. This is useful to represent some specific skinning effect (like glare around the EditField). Default implementation returns zero.
U++ defines several standard static frames. Those frames are mostly used to define (or alter) appearance of border of Ctrls. All of them are obtained as a reference to single global instance by single global function and can be assigned to unlimited number of Ctrls.
Appearance of some of them can be altered by current OS look&feel.
Function
|
altered by look&feel
|
Appearance
|
Comment
|
CtrlFrame& NullFrame()
|
No.
|
|
Default Frame for Ctrl.
|
CtrlFrame& InsetFrame()
|
No.
|
|
|
CtrlFrame& OutsetFrame()
|
No.
|
|
|
CtrlFrame& ButtonFrame()
|
No.
|
|
|
CtrlFrame& ThinInsetFrame()
|
No.
|
|
|
CtrlFrame& ThinOutsetFrame()
|
No.
|
|
|
CtrlFrame& BlackFrame()
|
No.
|
|
|
CtrlFrame& FieldFrame()
|
Yes.
|
|
Good for borders of all Ctrls that display somthing, like EditField or ArrayCtrl.
|
CtrlFrame& TopSeparatorFrame()
|
Yes.
|
|
|
CtrlFrame& BottomSeparatorFrame()
|
Yes.
|
|
|
CtrlFrame& LeftSeparatorFrame()
|
Yes.
|
|
|
CtrlFrame& RightSeparatorFrame()
|
Yes.
|
|
|
|
Simple Ctrl frame templates
|
|
template <class T>
class FrameCtrl : public T, public CtrlFrame
This is the base class of simple Ctrl frames - frames that place single Ctrl at some edge of parent Ctrl.
This class basically overloads FrameAdd and FrameRemove virtual methods of CtrlFrame so that they add/remove 'this' from parent's children-list.
Derived from T, CtrlFrame
Ctrl *GetParent()
Returns a parent to which the Ctrl is attached.
template <class T>
class FrameLR : public FrameCtrl<T>
This class extends CtrlFrame class with width attribute and serves as base class to classes placing Ctrl at the left or right size of parent Ctrl frame. Width is initialized to 0. 0 as width indicates that width is equal to the height.
Derived from FrameCtrl<T>
FrameLR& Width(int _cx)
Sets the new width.
int GetWidth() const
|
Return value |
Current width. |
template <class T>
class FrameLeft : public FrameLR<T>
This class places Ctrl to the parent's left side as frame.
Derived from FrameLR<T>
template <class T>
class FrameRight : public FrameLR<T>
This class places Ctrl to the parent's right side as frame.
Derived from FrameLR<T>
template <class T>
class FrameTB : public FrameCtrl<T>
This class extends CtrlFrame class with height attribute and serves as base class to classes placing Ctrl as the top or bottom side of parent Ctrl frame. Height is initialized to 0. 0 as height indicates that height is equal to the width.
Derived from FrameCtrl<T>
FrameTB& Height(int _cy)
Sets the new height.
int GetHeight() const
|
Return value |
Current height. |
template <class T>
class FrameTop : public FrameTB<T>
This class places Ctrl to the parent's top side as frame.
Derived from FrameTB<T>
template <class T>
class FrameBottom : public FrameTB<T>
This class places Ctrl to the parent's bottom side as frame.
Derived from FrameTB<T>
Following functions are intended as helpers to for implementation of FrameLayout method of CtrlFrame, placing some Ctrl to the side of parent Ctrl. They adjust given Rect (parameter of FrameLayout) and also alter position of given Ctrl.
void LayoutFrameLeft(Rect& r, Ctrl *ctrl, int cx)
Places ctrl at the left side of parent Ctrl.
|
r |
Current parent Ctrl rect. |
void LayoutFrameRight(Rect& r, Ctrl *ctrl, int cx)
Places ctrl at the right side of parent Ctrl.
|
r |
Current parent Ctrl rect. |
void LayoutFrameTop(Rect& r, Ctrl *ctrl, int cy)
Places ctrl at the top side of parent Ctrl.
|
r |
Current parent Ctrl rect. |
void LayoutFrameBottom(Rect& r, Ctrl *ctrl, int cy)
Places ctrl at the bottom side of parent Ctrl.
|
r |
Current parent Ctrl rect. |
|