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