xref: /haiku/src/tests/kits/interface/menu/menuworld/ViewLayoutFactory.h (revision 372eb8749cfa097031c6ff888508c0b61f577746)
1 //--------------------------------------------------------------------
2 //
3 //	ViewLayoutFactory.h
4 //
5 //	Written by: Owen Smith
6 //
7 //--------------------------------------------------------------------
8 
9 /*
10 	Copyright 1999, Be Incorporated.   All Rights Reserved.
11 	This file may be used under the terms of the Be Sample Code License.
12 */
13 
14 #ifndef _ViewLayoutFactory_h
15 #define _ViewLayoutFactory_h
16 
17 #include <InterfaceKit.h>
18 #include <SupportDefs.h>
19 
20 typedef enum { CORNER_TOPLEFT, CORNER_BOTTOMLEFT,
21 	CORNER_TOPRIGHT, CORNER_BOTTOMRIGHT } corner;
22 
23 // bit flags
24 typedef enum { RECT_WIDTH = 1, RECT_HEIGHT,
25 	RECT_WIDTH_AND_HEIGHT } rect_dim;
26 
27 typedef enum { ALIGN_LEFT, ALIGN_TOP, ALIGN_RIGHT,
28 	ALIGN_BOTTOM, ALIGN_HCENTER, ALIGN_VCENTER } align_side;
29 
30 //====================================================================
31 //	CLASS: ViewLayoutFactory
32 // ---------------------------
33 //  A class, still under construction, that handles some
34 //	simple view layout problems. Primarily, it creates
35 //	standard Interface Kit views that are automatically
36 //	set to their preferred size. In addition, it provides:
37 //
38 //	* Positioning of views using any one of the corners of
39 //	the view's rectangle
40 //	* Alignment of a group of views along one edge or center,
41 //	to a specified distance between views.
42 //	* Adjustment of the width or height of a group of views
43 //	to the maximum value represented by the group.
44 //	* Resizing of a view to surround all of its children,
45 //	plus a specified margin on the right and bottom sides.
46 
47 class ViewLayoutFactory
48 {
49 	//----------------------------------------------------------------
50 	//	Factory generators
51 
52 public:
53 	BButton*		MakeButton(const char* name, const char* label,
54 						uint32 msgID, BPoint pos,
55 						corner posRef = CORNER_TOPLEFT);
56 	BCheckBox*		MakeCheckBox(const char* name, const char* label,
57 						uint32 msgID, BPoint pos,
58 						corner posRef = CORNER_TOPLEFT);
59 	BTextControl*	MakeTextControl(const char* name, const char* label,
60 						const char* text, BPoint pos, float controlWidth,
61 						corner posRef = CORNER_TOPLEFT);
62 
63 	void			LayoutTextControl(BTextControl& control,
64 						BPoint pos, float controlWidth,
65 						corner posRef = CORNER_TOPLEFT);
66 
67 	//----------------------------------------------------------------
68 	//	Other operations
69 
70 public:
71 	void			MoveViewCorner(BView& view, BPoint pos,
72 						corner posRef = CORNER_TOPLEFT);
73 	void			Align(BList& viewList, align_side side,
74 						float alignLen);
75 	void			ResizeToListMax(BList& viewList, rect_dim resizeDim,
76 						corner anchor = CORNER_TOPLEFT);
77 	void			ResizeAroundChildren(BView& view, BPoint margin);
78 };
79 
80 #endif /* _ViewLayoutFactory_h */
81