Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
UppHub
Status & Roadmap
FAQ
Authors & License
Forums
Funding U++
Search on this site











SourceForge.net Logo

SourceForge.net Logo

GitHub Logo

Discord Logo

Frame

Frames are objects derived from CtrlFrame class that form appearance and functionality of area between outer Ctrl border and its view.

 

 

 

 

CtrlFrame

 

class CtrlFrame

Interface definition of frame classes.

 

 

Public Member List

 

~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.

w

Draw.

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.

parent

Parent Ctrl.

 


 

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.  

 

 

 

 

Standard static frames

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.

 

T

Ctrl type.

 

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.

 

T

Ctrl type.

 

Derived from FrameCtrl<T>

 

 

 

FrameLR& Width(int _cx)

Sets the new width.

_cx

Width.

Return value

*this.

 

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.

T

Ctrl type.

 

Derived from FrameLR<T>

 


 

template <class T>

class FrameRight : public FrameLR<T

This class places Ctrl to the parent's right side as frame.

T

Ctrl type.

 

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.

T

Ctrl type.

 

Derived from FrameCtrl<T>

 

 

 

FrameTB& Height(int _cy)

Sets the new height.

_cy

Height.

Return value

*this.

 

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.

T

Ctrl type.

 

Derived from FrameTB<T>

 


 

template <class T>

class FrameBottom : public FrameTB<T

This class places Ctrl to the parent's bottom side as frame.

T

Ctrl type.

 

Derived from FrameTB<T>

 

 

 

 

Frame utility functions

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.

ctrl

Ctrl to be placed.

cx

Required width.

 


 

void LayoutFrameRight(Rect& r, Ctrl *ctrl, int cx)

Places ctrl at the right side of parent Ctrl.

r

Current parent Ctrl rect.

ctrl

Ctrl to be placed.

cx

Required width.

 


 

void LayoutFrameTop(Rect& r, Ctrl *ctrl, int cy)

Places ctrl at the top side of parent Ctrl.

r

Current parent Ctrl rect.

ctrl

Ctrl to be placed.

cy

Required height.

 


 

void LayoutFrameBottom(Rect& r, Ctrl *ctrl, int cy)

Places ctrl at the bottom side of parent Ctrl.

r

Current parent Ctrl rect.

ctrl

Ctrl to be placed.

cy

Required height.

 

 

Do you want to contribute?