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