1 /* 2 * Copyright 2001-2009, Haiku, Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _SHELF_H 6 #define _SHELF_H 7 8 9 #include <Dragger.h> 10 #include <Handler.h> 11 #include <List.h> 12 #include <Locker.h> 13 14 15 class BDataIO; 16 class BPoint; 17 class BView; 18 class BEntry; 19 class _BZombieReplicantView_; 20 struct entry_ref; 21 22 namespace BPrivate { 23 struct replicant_data; 24 class ShelfContainerViewFilter; 25 }; 26 27 28 class BShelf : public BHandler { 29 public: 30 BShelf(BView* view, bool allowDrags = true, 31 const char* shelfType = NULL); 32 BShelf(const entry_ref* ref, BView* view, 33 bool allowDrags = true, 34 const char* shelfType = NULL); 35 BShelf(BDataIO* stream, BView* view, 36 bool allowDrags = true, 37 const char* shelfType = NULL); 38 BShelf(BMessage* archive); 39 virtual ~BShelf(); 40 41 static BArchivable* Instantiate(BMessage* archive); 42 virtual status_t Archive(BMessage* archive, 43 bool deep = true) const; 44 45 virtual void MessageReceived(BMessage* message); 46 status_t Save(); 47 virtual void SetDirty(bool state); 48 bool IsDirty() const; 49 50 virtual BHandler* ResolveSpecifier(BMessage* message, 51 int32 index, BMessage* specifier, 52 int32 form, const char* property); 53 virtual status_t GetSupportedSuites(BMessage* data); 54 55 virtual status_t Perform(perform_code code, void* data); 56 57 bool AllowsDragging() const; 58 void SetAllowsDragging(bool state); 59 bool AllowsZombies() const; 60 void SetAllowsZombies(bool state); 61 bool DisplaysZombies() const; 62 void SetDisplaysZombies(bool state); 63 bool IsTypeEnforced() const; 64 void SetTypeEnforced(bool state); 65 66 status_t SetSaveLocation(BDataIO* stream); 67 status_t SetSaveLocation(const entry_ref* ref); 68 BDataIO* SaveLocation(entry_ref* ref) const; 69 70 status_t AddReplicant(BMessage* archive, 71 BPoint location); 72 status_t DeleteReplicant(BView* replicant); 73 status_t DeleteReplicant(BMessage* archive); 74 status_t DeleteReplicant(int32 index); 75 int32 CountReplicants() const; 76 BMessage* ReplicantAt(int32 index, BView** view = NULL, 77 uint32* uid = NULL, 78 status_t* perr = NULL) const; 79 int32 IndexOf(const BView* replicantView) const; 80 int32 IndexOf(const BMessage* archive) const; 81 int32 IndexOf(uint32 id) const; 82 83 protected: 84 virtual bool CanAcceptReplicantMessage( 85 BMessage* archive) const; 86 virtual bool CanAcceptReplicantView(BRect, 87 BView*, BMessage*) const; 88 virtual BPoint AdjustReplicantBy(BRect, BMessage*) const; 89 90 virtual void ReplicantDeleted(int32 index, 91 const BMessage* archive, 92 const BView *replicant); 93 94 private: 95 // FBC padding and forbidden methods 96 virtual void _ReservedShelf2(); 97 virtual void _ReservedShelf3(); 98 virtual void _ReservedShelf4(); 99 virtual void _ReservedShelf5(); 100 virtual void _ReservedShelf6(); 101 virtual void _ReservedShelf7(); 102 virtual void _ReservedShelf8(); 103 104 BShelf(const BShelf& other); 105 BShelf& operator=(const BShelf& other); 106 107 private: 108 friend class BPrivate::ShelfContainerViewFilter; 109 110 status_t _Archive(BMessage* data) const; 111 void _InitData(BEntry* entry, BDataIO* stream, 112 BView* view, bool allowDrags); 113 status_t _DeleteReplicant( 114 BPrivate::replicant_data* replicant); 115 status_t _AddReplicant(BMessage* data, 116 BPoint* location, uint32 uniqueID); 117 BView* _GetReplicant(BMessage* data, BView* view, 118 const BPoint& point, BDragger*& dragger, 119 BDragger::relation& relation); 120 _BZombieReplicantView_* _CreateZombie(BMessage *data, 121 BDragger *&dragger); 122 123 status_t _GetProperty(BMessage* message, 124 BMessage* reply); 125 static void _GetReplicantData(BMessage* message, 126 BView* view, BView*& replicant, 127 BDragger*& dragger, 128 BDragger::relation& relation); 129 static BArchivable* _InstantiateObject(BMessage* archive, 130 image_id* image); 131 132 private: 133 BView* fContainerView; 134 BDataIO* fStream; 135 BEntry* fEntry; 136 BList fReplicants; 137 BPrivate::ShelfContainerViewFilter* fFilter; 138 uint32 fGenCount; 139 bool fAllowDragging; 140 bool fDirty; 141 bool fDisplayZombies; 142 bool fAllowZombies; 143 bool fTypeEnforced; 144 145 uint32 _reserved[8]; 146 }; 147 148 #endif /* _SHELF_H */ 149