1 /* 2 * Copyright 2006-2010, Haiku, Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _LAYOUT_ITEM_H 6 #define _LAYOUT_ITEM_H 7 8 9 #include <Alignment.h> 10 #include <Archivable.h> 11 #include <Rect.h> 12 #include <Size.h> 13 14 15 class BLayout; 16 class BView; 17 18 19 class BLayoutItem : public BArchivable { 20 public: 21 BLayoutItem(); 22 BLayoutItem(BMessage* from); 23 virtual ~BLayoutItem(); 24 25 BLayout* Layout() const; 26 27 virtual BSize MinSize() = 0; 28 virtual BSize MaxSize() = 0; 29 virtual BSize PreferredSize() = 0; 30 virtual BAlignment Alignment() = 0; 31 32 virtual void SetExplicitMinSize(BSize size) = 0; 33 virtual void SetExplicitMaxSize(BSize size) = 0; 34 virtual void SetExplicitPreferredSize(BSize size) = 0; 35 void SetExplicitSize(BSize size); 36 virtual void SetExplicitAlignment(BAlignment alignment) = 0; 37 38 virtual bool IsVisible() = 0; 39 virtual void SetVisible(bool visible) = 0; 40 41 virtual BRect Frame() = 0; 42 virtual void SetFrame(BRect frame) = 0; 43 44 virtual bool HasHeightForWidth(); 45 virtual void GetHeightForWidth(float width, float* min, 46 float* max, float* preferred); 47 48 virtual BView* View(); 49 50 virtual void InvalidateLayout(bool children = false); 51 virtual void Relayout(bool immediate = false); 52 53 void* LayoutData() const; 54 void SetLayoutData(void* data); 55 56 void AlignInFrame(BRect frame); 57 58 virtual status_t Archive(BMessage* into, bool deep = true) const; 59 60 virtual status_t Perform(perform_code d, void* arg); 61 62 protected: 63 // archiving methods 64 virtual status_t AllArchived(BMessage* into) const; 65 virtual status_t AllUnarchived(const BMessage* from); 66 67 // hook methods 68 virtual void LayoutInvalidated(bool children); 69 70 virtual void AttachedToLayout(); 71 virtual void DetachedFromLayout(BLayout* layout); 72 73 virtual void AncestorVisibilityChanged(bool shown); 74 75 private: 76 void SetLayout(BLayout* layout); 77 78 virtual void _ReservedLayoutItem1(); 79 virtual void _ReservedLayoutItem2(); 80 virtual void _ReservedLayoutItem3(); 81 virtual void _ReservedLayoutItem4(); 82 virtual void _ReservedLayoutItem5(); 83 virtual void _ReservedLayoutItem6(); 84 virtual void _ReservedLayoutItem7(); 85 virtual void _ReservedLayoutItem8(); 86 virtual void _ReservedLayoutItem9(); 87 virtual void _ReservedLayoutItem10(); 88 89 // forbidden methods 90 BLayoutItem(const BLayoutItem&); 91 void operator =(const BLayoutItem&); 92 93 friend class BLayout; 94 95 BLayout* fLayout; 96 void* fLayoutData; 97 98 uint32 _reserved[5]; 99 }; 100 101 102 #endif // _LAYOUT_ITEM_H 103