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