To create your own classes that will be able to work with the layout-library, your classes must derive from both MView and BView. You must implement the layoutprefs and layout members of the MView class.
Through the layoutprefs-function, you tell the system about the minimum and maximum size
of your class.
The current grouping classes guarantee that your object will not be asked to become smaller
than the size you give as the minimum size. Note that this guarantee is currently enforced
by making the minimum window-size equal to the minimum size of the root-MView. If you do respect
the minimum size of a grouping class, then the grouping class will not respect the minimum size
of the MViews it contains.
The layoutprefs-function is defined as:
minimax layoutprefs(void)and the minimax class is defined as:
class minimax { public: BPoint mini; BPoint maxi; float weight; minimax(int minx=0,int miny=0, int maxx=65536,int maxy=65536, float weight=1); minimax(BPoint min,BPoint max,float wght=1); };where the mini and maxi members are used to store the minimum and maximum size of the object.
Through the layout function, your class is asked to layout itself. Again, if you have correctly setup the window-limits to be the limits of the root-MView, then it is guaranteed that your object will not be asked to resize to a size that's smaller than its minimum size.
It is possible that your object is asked to resize to a size that is bigger than its maximum size. In this case, the object should center itself within the provided space.
The layout-function is defined as:
BRect layout(BRect size)The size parameter determines where the object should be placed in its parent. A simple implementation of the layout function will simply do
BRect MyClass::layout(BRect rect) { ResizeTo(rect.Width(),rect.Height()); MoveTo(rect.LeftTop()); return rect; }The layout function returns the amount of space actually used by the object.
To create your own grouping classes, you must take a little more responsibility:
Copyright © 1997 Marco Nelissen (marcone@xs4all.nl) All rights reserved.
Be is a registered trademark; BeOS, BeBox, BeWare, GeekPort, the Be logo, and the BeOS logo are trademarks of Be, Inc.