19ecf9d1cSIngo Weinhold /* 227d84b48SAdrien Destugues * Copyright 2006-2010, Haiku, Inc. All rights reserved. 39ecf9d1cSIngo Weinhold * Distributed under the terms of the MIT License. 49ecf9d1cSIngo Weinhold */ 59ecf9d1cSIngo Weinhold #ifndef _LAYOUT_H 69ecf9d1cSIngo Weinhold #define _LAYOUT_H 79ecf9d1cSIngo Weinhold 8268317bdSAxel Dörfler 99ecf9d1cSIngo Weinhold #include <Alignment.h> 1027d84b48SAdrien Destugues #include <Archivable.h> 119ecf9d1cSIngo Weinhold #include <List.h> 129ecf9d1cSIngo Weinhold #include <Size.h> 139ecf9d1cSIngo Weinhold 14268317bdSAxel Dörfler 159ecf9d1cSIngo Weinhold class BLayoutItem; 169ecf9d1cSIngo Weinhold class BView; 179ecf9d1cSIngo Weinhold 189ecf9d1cSIngo Weinhold 1927d84b48SAdrien Destugues class BLayout : public BArchivable { 209ecf9d1cSIngo Weinhold public: 219ecf9d1cSIngo Weinhold BLayout(); 2227d84b48SAdrien Destugues BLayout(BMessage* archive); 239ecf9d1cSIngo Weinhold virtual ~BLayout(); 249ecf9d1cSIngo Weinhold 259ecf9d1cSIngo Weinhold BView* View() const; 269ecf9d1cSIngo Weinhold 279ecf9d1cSIngo Weinhold virtual BLayoutItem* AddView(BView* child); 289ecf9d1cSIngo Weinhold virtual BLayoutItem* AddView(int32 index, BView* child); 299ecf9d1cSIngo Weinhold 309ecf9d1cSIngo Weinhold virtual bool AddItem(BLayoutItem* item); 319ecf9d1cSIngo Weinhold virtual bool AddItem(int32 index, BLayoutItem* item); 329ecf9d1cSIngo Weinhold 339ecf9d1cSIngo Weinhold virtual bool RemoveView(BView* child); 349ecf9d1cSIngo Weinhold virtual bool RemoveItem(BLayoutItem* item); 359ecf9d1cSIngo Weinhold virtual BLayoutItem* RemoveItem(int32 index); 369ecf9d1cSIngo Weinhold 379ecf9d1cSIngo Weinhold BLayoutItem* ItemAt(int32 index) const; 389ecf9d1cSIngo Weinhold int32 CountItems() const; 3927d84b48SAdrien Destugues int32 IndexOfItem(const BLayoutItem* item) const; 409ecf9d1cSIngo Weinhold int32 IndexOfView(BView* child) const; 419ecf9d1cSIngo Weinhold 429ecf9d1cSIngo Weinhold virtual BSize MinSize() = 0; 439ecf9d1cSIngo Weinhold virtual BSize MaxSize() = 0; 449ecf9d1cSIngo Weinhold virtual BSize PreferredSize() = 0; 459ecf9d1cSIngo Weinhold virtual BAlignment Alignment() = 0; 469ecf9d1cSIngo Weinhold 479ecf9d1cSIngo Weinhold virtual bool HasHeightForWidth() = 0; 489ecf9d1cSIngo Weinhold virtual void GetHeightForWidth(float width, float* min, 499ecf9d1cSIngo Weinhold float* max, float* preferred) = 0; 509ecf9d1cSIngo Weinhold 519ecf9d1cSIngo Weinhold virtual void InvalidateLayout(); 529ecf9d1cSIngo Weinhold 539ecf9d1cSIngo Weinhold virtual void LayoutView() = 0; 549ecf9d1cSIngo Weinhold 5527d84b48SAdrien Destugues virtual status_t Archive(BMessage* into, bool deep = true) const; 5627d84b48SAdrien Destugues virtual status_t AllUnarchived(const BMessage* from); 5727d84b48SAdrien Destugues 58b137ab3eSIngo Weinhold virtual status_t ItemArchived(BMessage* into, BLayoutItem* item, 59b137ab3eSIngo Weinhold int32 index) const; 60b137ab3eSIngo Weinhold virtual status_t ItemUnarchived(const BMessage* from, 61b137ab3eSIngo Weinhold BLayoutItem* item, int32 index); 629ecf9d1cSIngo Weinhold protected: 63*6829d417SAlex Wilson virtual bool ItemAdded(BLayoutItem* item, int32 atIndex); 64*6829d417SAlex Wilson virtual void ItemRemoved(BLayoutItem* item, int32 fromIndex); 659ecf9d1cSIngo Weinhold 669ecf9d1cSIngo Weinhold private: 679ecf9d1cSIngo Weinhold friend class BView; 689ecf9d1cSIngo Weinhold 699ecf9d1cSIngo Weinhold void SetView(BView* view); 709ecf9d1cSIngo Weinhold 719ecf9d1cSIngo Weinhold BView* fView; 729ecf9d1cSIngo Weinhold BList fItems; 739ecf9d1cSIngo Weinhold }; 749ecf9d1cSIngo Weinhold 75268317bdSAxel Dörfler 769ecf9d1cSIngo Weinhold #endif // _LAYOUT_H 77