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