xref: /haiku/src/apps/cortex/ValControl/ValCtrlLayoutEntry.h (revision 0562493379cd52eb7103531f895f10bb8e77c085)
1 // ValCtrlValCtrlLayoutEntry.h
2 // +++++ cortex integration 23aug99:
3 //       hide this class!
4 //
5 // e.moon 28jan99
6 #ifndef VAL_CTRL_LAYOUT_ENTRY_H
7 #define VAL_CTRL_LAYOUT_ENTRY_H
8 
9 
10 #include "cortex_defs.h"
11 
12 #include <View.h>
13 
14 
15 __BEGIN_CORTEX_NAMESPACE
16 
17 // a ValCtrlLayoutEntry manages the layout state information for
18 // a single child view
19 
20 class ValCtrlLayoutEntry {
21 	public:
22 		friend class ValControl;
23 
24 	public: // static instances
25 		static ValCtrlLayoutEntry decimalPoint;
26 
27 	public:
28 		enum entry_type {
29 			SEGMENT_ENTRY,
30 			VIEW_ENTRY,
31 			DECIMAL_POINT_ENTRY
32 		};
33 
34 		enum layout_flags {
35 			LAYOUT_NONE	= 0,
36 			LAYOUT_NO_PADDING = 1,	// disables left/right padding
37 		};
38 
39 	public:
40 		ValCtrlLayoutEntry() {}
41 			// stl compatibility ctor
42 
43 		// standard: yes, the frame is left invalid; that's for
44 		// ValControl::insertEntry() to fix
45 		ValCtrlLayoutEntry(BView* _pView, entry_type t,
46 			layout_flags f = LAYOUT_NONE)
47 			:
48 			pView(_pView),
49 			type(t),
50 			flags(f),
51 			fPadding(0.0)
52 			{}
53 
54 		ValCtrlLayoutEntry(entry_type t, layout_flags f = LAYOUT_NONE)
55 			:
56 			pView(0),
57 			type(t),
58 			flags(f),
59 			fPadding(0.0)
60 			{}
61 
62 		ValCtrlLayoutEntry(const ValCtrlLayoutEntry& clone) {
63 			operator=(clone);
64 		}
65 
66 		ValCtrlLayoutEntry& operator=(const ValCtrlLayoutEntry& clone) {
67 			type = clone.type;
68 			flags = clone.flags;
69 			pView = clone.pView;
70 
71 			frame = clone.frame;
72 			fPadding = clone.fPadding;
73 			return *this;
74 		}
75 
76 		// order first by x position, then by y:
77 		bool operator<(const ValCtrlLayoutEntry& b) const {
78 			return frame.left < b.frame.left ||
79 				frame.top < b.frame.top;
80 		}
81 
82 	protected:
83 		// move & size ref'd child view to match 'frame'
84 		static void InitChildFrame(ValCtrlLayoutEntry& e);
85 
86 	public:
87 		BView* pView;
88 
89 		entry_type type;
90 		layout_flags flags;
91 
92 		// layout state info (filled in by ValControl):
93 		BRect frame;
94 		float fPadding;
95 };
96 
97 __END_CORTEX_NAMESPACE
98 #endif	// VAL_CTRL_LAYOUT_ENTRY_H
99