tcp: Fix 64 bit build with debugging features enabled.
[haiku.git] / src / kits / interface / ListItem.cpp
blob12c4625c2c5f6e1097940339ed1f160d5c6ed9c8
1 /*
2 * Copyright 2001-2010 Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Ulrich Wimboeck
7 * Marc Flerackers (mflerackers@androme.be)
8 * Rene Gollent
9 */
12 #include <ListItem.h>
14 #include <Message.h>
15 #include <View.h>
18 BListItem::BListItem(uint32 level, bool expanded)
20 fTop(0.0),
21 fTemporaryList(0),
22 fWidth(0),
23 fHeight(0),
24 fLevel(level),
25 fSelected(false),
26 fEnabled(true),
27 fExpanded(expanded),
28 fHasSubitems(false),
29 fVisible(true)
34 BListItem::BListItem(BMessage* data)
36 BArchivable(data),
37 fTop(0.0),
38 fWidth(0),
39 fHeight(0),
40 fLevel(0),
41 fSelected(false),
42 fEnabled(true),
43 fExpanded(false),
44 fHasSubitems(false),
45 fVisible(true)
47 data->FindBool("_sel", &fSelected);
49 if (data->FindBool("_disable", &fEnabled) != B_OK)
50 fEnabled = true;
51 else
52 fEnabled = false;
54 data->FindBool("_li_expanded", &fExpanded);
55 data->FindInt32("_li_outline_level", (int32*)&fLevel);
59 BListItem::~BListItem()
64 status_t
65 BListItem::Archive(BMessage* archive, bool deep) const
67 status_t status = BArchivable::Archive(archive, deep);
68 if (status == B_OK && fSelected)
69 status = archive->AddBool("_sel", true);
71 if (status == B_OK && !fEnabled)
72 status = archive->AddBool("_disable", true);
74 if (status == B_OK && fExpanded)
75 status = archive->AddBool("_li_expanded", true);
77 if (status == B_OK && fLevel != 0)
78 status = archive->AddInt32("_li_outline_level", fLevel);
80 return status;
84 float
85 BListItem::Height() const
87 return fHeight;
91 float
92 BListItem::Width() const
94 return fWidth;
98 bool
99 BListItem::IsSelected() const
101 return fSelected;
105 void
106 BListItem::Select()
108 fSelected = true;
112 void
113 BListItem::Deselect()
115 fSelected = false;
119 void
120 BListItem::SetEnabled(bool on)
122 fEnabled = on;
126 bool
127 BListItem::IsEnabled() const
129 return fEnabled;
133 void
134 BListItem::SetHeight(float height)
136 fHeight = height;
140 void
141 BListItem::SetWidth(float width)
143 fWidth = width;
147 void
148 BListItem::Update(BView* owner, const BFont* font)
150 font_height fh;
151 font->GetHeight(&fh);
153 SetWidth(owner->Bounds().Width());
154 SetHeight(ceilf(fh.ascent + fh.descent + fh.leading));
158 status_t
159 BListItem::Perform(perform_code d, void* arg)
161 return BArchivable::Perform(d, arg);
165 void
166 BListItem::SetExpanded(bool expanded)
168 fExpanded = expanded;
172 bool
173 BListItem::IsExpanded() const
175 return fExpanded;
179 uint32
180 BListItem::OutlineLevel() const
182 return fLevel;
186 void
187 BListItem::SetOutlineLevel(uint32 level)
189 fLevel = level;
193 bool
194 BListItem::HasSubitems() const
196 return fHasSubitems;
200 void BListItem::_ReservedListItem1() {}
201 void BListItem::_ReservedListItem2() {}
204 bool
205 BListItem::IsItemVisible() const
207 return fVisible;
211 void
212 BListItem::SetTop(float top)
214 fTop = top;
218 void
219 BListItem::SetItemVisible(bool visible)
221 fVisible = visible;