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