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