1 /* 2 * Copyright 2006-2010, Haiku, Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _LIST_ITEM_H 6 #define _LIST_ITEM_H 7 8 9 #include <Archivable.h> 10 #include <Rect.h> 11 12 13 class BFont; 14 class BList; 15 class BMessage; 16 class BOutlineListView; 17 class BView; 18 19 20 class BListItem : public BArchivable { 21 public: 22 BListItem(uint32 outlineLevel = 0, 23 bool expanded = true); 24 BListItem(BMessage* archive); 25 virtual ~BListItem(); 26 27 virtual status_t Archive(BMessage* archive, 28 bool deep = true) const; 29 30 float Height() const; 31 float Width() const; 32 bool IsSelected() const; 33 void Select(); 34 void Deselect(); 35 36 virtual void SetEnabled(bool enabled); 37 bool IsEnabled() const; 38 39 void SetHeight(float height); 40 void SetWidth(float width); 41 virtual void DrawItem(BView* owner, BRect frame, 42 bool complete = false) = 0; 43 virtual void Update(BView* owner, const BFont* font); 44 45 bool IsExpanded() const; 46 void SetExpanded(bool expanded); 47 uint32 OutlineLevel() const; 48 void SetOutlineLevel(uint32 level); 49 50 virtual status_t Perform(perform_code code, void* arg); 51 52 private: 53 // FBC padding 54 virtual void _ReservedListItem1(); 55 virtual void _ReservedListItem2(); 56 57 // Forbidden 58 BListItem(const BListItem& item); 59 BListItem& operator=(const BListItem& item); 60 61 private: 62 friend class BOutlineListView; 63 friend class BListView; 64 65 bool HasSubitems() const; 66 67 bool IsItemVisible() const; 68 void SetItemVisible(bool visible); 69 inline float Top() const; 70 inline float Bottom() const; 71 void SetTop(float top); 72 73 private: 74 float fTop; 75 BList* fTemporaryList; 76 float fWidth; 77 float fHeight; 78 uint32 fLevel; 79 bool fSelected; 80 bool fEnabled; 81 bool fExpanded; 82 bool fHasSubitems : 1; 83 bool fVisible : 1; 84 }; 85 86 87 inline float 88 BListItem::Top(void) const 89 { 90 return fTop; 91 } 92 93 94 inline float 95 BListItem::Bottom(void) const 96 { 97 return fTop + ceilf(fHeight) - 1.0; 98 } 99 100 101 #include <StringItem.h> 102 // to maintain source compatibility 103 104 105 #endif // _LIST_ITEM_H 106