repository_infos: Enable automatic updates on the main Haiku repostiory.
[haiku.git] / src / apps / cortex / ValControl / ValCtrlLayoutEntry.h
blob14efbf12d661c3d160db0d0e1177dd9682201a5f
1 /*
2 * Copyright (c) 1999-2000, Eric Moon.
3 * All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions, and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions, and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * 3. The name of the author may not be used to endorse or promote products
17 * derived from this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 * OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
23 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
26 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
27 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 // ValCtrlValCtrlLayoutEntry.h
33 // +++++ cortex integration 23aug99:
34 // hide this class!
36 // e.moon 28jan99
37 #ifndef VAL_CTRL_LAYOUT_ENTRY_H
38 #define VAL_CTRL_LAYOUT_ENTRY_H
41 #include "cortex_defs.h"
43 #include <View.h>
46 __BEGIN_CORTEX_NAMESPACE
48 // a ValCtrlLayoutEntry manages the layout state information for
49 // a single child view
51 class ValCtrlLayoutEntry {
52 public:
53 friend class ValControl;
55 public: // static instances
56 static ValCtrlLayoutEntry decimalPoint;
58 public:
59 enum entry_type {
60 SEGMENT_ENTRY,
61 VIEW_ENTRY,
62 DECIMAL_POINT_ENTRY
65 enum layout_flags {
66 LAYOUT_NONE = 0,
67 LAYOUT_NO_PADDING = 1, // disables left/right padding
70 public:
71 ValCtrlLayoutEntry() {}
72 // stl compatibility ctor
74 // standard: yes, the frame is left invalid; that's for
75 // ValControl::insertEntry() to fix
76 ValCtrlLayoutEntry(BView* _pView, entry_type t,
77 layout_flags f = LAYOUT_NONE)
79 pView(_pView),
80 type(t),
81 flags(f),
82 fPadding(0.0)
85 ValCtrlLayoutEntry(entry_type t, layout_flags f = LAYOUT_NONE)
87 pView(0),
88 type(t),
89 flags(f),
90 fPadding(0.0)
93 ValCtrlLayoutEntry(const ValCtrlLayoutEntry& clone) {
94 operator=(clone);
97 ValCtrlLayoutEntry& operator=(const ValCtrlLayoutEntry& clone) {
98 type = clone.type;
99 flags = clone.flags;
100 pView = clone.pView;
102 frame = clone.frame;
103 fPadding = clone.fPadding;
104 return *this;
107 // order first by x position, then by y:
108 bool operator<(const ValCtrlLayoutEntry& b) const {
109 return frame.left < b.frame.left ||
110 frame.top < b.frame.top;
113 protected:
114 // move & size ref'd child view to match 'frame'
115 static void InitChildFrame(ValCtrlLayoutEntry& e);
117 public:
118 BView* pView;
120 entry_type type;
121 layout_flags flags;
123 // layout state info (filled in by ValControl):
124 BRect frame;
125 float fPadding;
128 __END_CORTEX_NAMESPACE
129 #endif // VAL_CTRL_LAYOUT_ENTRY_H