2006-08-26 20:21:15 +04:00
|
|
|
/*
|
2010-07-08 19:40:49 +04:00
|
|
|
* Copyright 2006-2010, Haiku, Inc. All rights reserved.
|
2006-08-26 20:21:15 +04:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
|
|
|
#ifndef _LAYOUT_H
|
|
|
|
#define _LAYOUT_H
|
|
|
|
|
2010-07-08 20:04:41 +04:00
|
|
|
|
2006-08-26 20:21:15 +04:00
|
|
|
#include <Alignment.h>
|
2010-07-08 19:40:49 +04:00
|
|
|
#include <Archivable.h>
|
2010-08-17 22:43:41 +04:00
|
|
|
#include <LayoutItem.h>
|
2006-08-26 20:21:15 +04:00
|
|
|
#include <List.h>
|
|
|
|
#include <Size.h>
|
|
|
|
|
2010-07-08 20:04:41 +04:00
|
|
|
|
2010-08-17 22:43:41 +04:00
|
|
|
class BLayoutContext;
|
2006-08-26 20:21:15 +04:00
|
|
|
class BLayoutItem;
|
|
|
|
class BView;
|
|
|
|
|
|
|
|
|
2010-08-17 22:43:41 +04:00
|
|
|
class BLayout : public BLayoutItem {
|
2006-08-26 20:21:15 +04:00
|
|
|
public:
|
|
|
|
BLayout();
|
2010-07-08 19:40:49 +04:00
|
|
|
BLayout(BMessage* archive);
|
2006-08-26 20:21:15 +04:00
|
|
|
virtual ~BLayout();
|
|
|
|
|
2010-08-17 22:43:41 +04:00
|
|
|
BView* Owner() const;
|
|
|
|
BView* TargetView() const;
|
|
|
|
virtual BView* View(); // from BLayoutItem
|
2006-08-26 20:21:15 +04:00
|
|
|
|
2010-08-17 22:43:41 +04:00
|
|
|
// methods dealing with items
|
2006-08-26 20:21:15 +04:00
|
|
|
virtual BLayoutItem* AddView(BView* child);
|
|
|
|
virtual BLayoutItem* AddView(int32 index, BView* child);
|
|
|
|
|
|
|
|
virtual bool AddItem(BLayoutItem* item);
|
|
|
|
virtual bool AddItem(int32 index, BLayoutItem* item);
|
|
|
|
|
|
|
|
virtual bool RemoveView(BView* child);
|
|
|
|
virtual bool RemoveItem(BLayoutItem* item);
|
|
|
|
virtual BLayoutItem* RemoveItem(int32 index);
|
|
|
|
|
|
|
|
BLayoutItem* ItemAt(int32 index) const;
|
|
|
|
int32 CountItems() const;
|
2010-07-08 19:40:49 +04:00
|
|
|
int32 IndexOfItem(const BLayoutItem* item) const;
|
2006-08-26 20:21:15 +04:00
|
|
|
int32 IndexOfView(BView* child) const;
|
|
|
|
|
2010-11-20 00:26:54 +03:00
|
|
|
bool AncestorsVisible() const;
|
2006-08-26 20:21:15 +04:00
|
|
|
|
2010-08-17 22:43:41 +04:00
|
|
|
// Layouting related methods
|
2006-08-26 20:21:15 +04:00
|
|
|
|
2010-08-17 22:43:41 +04:00
|
|
|
virtual void InvalidateLayout(bool children = false);
|
2011-09-12 18:56:40 +04:00
|
|
|
void Relayout(bool immediate = false);
|
2010-08-17 22:43:41 +04:00
|
|
|
void RequireLayout();
|
|
|
|
bool IsValid();
|
|
|
|
void EnableLayoutInvalidation();
|
|
|
|
void DisableLayoutInvalidation();
|
2006-08-26 20:21:15 +04:00
|
|
|
|
2010-08-17 22:43:41 +04:00
|
|
|
void LayoutItems(bool force = false);
|
|
|
|
BRect LayoutArea();
|
2010-11-20 00:53:25 +03:00
|
|
|
BLayoutContext* LayoutContext() const;
|
2010-08-17 22:43:41 +04:00
|
|
|
|
|
|
|
// Archiving methods
|
2006-08-26 20:21:15 +04:00
|
|
|
|
2010-07-08 19:40:49 +04:00
|
|
|
virtual status_t Archive(BMessage* into, bool deep = true) const;
|
|
|
|
virtual status_t AllUnarchived(const BMessage* from);
|
|
|
|
|
2010-07-16 20:49:42 +04:00
|
|
|
virtual status_t ItemArchived(BMessage* into, BLayoutItem* item,
|
|
|
|
int32 index) const;
|
|
|
|
virtual status_t ItemUnarchived(const BMessage* from,
|
|
|
|
BLayoutItem* item, int32 index);
|
2010-08-17 22:43:41 +04:00
|
|
|
|
2006-08-26 20:21:15 +04:00
|
|
|
protected:
|
2010-08-17 22:43:41 +04:00
|
|
|
// BLayout hook methods
|
2010-07-30 06:28:17 +04:00
|
|
|
virtual bool ItemAdded(BLayoutItem* item, int32 atIndex);
|
|
|
|
virtual void ItemRemoved(BLayoutItem* item, int32 fromIndex);
|
2011-09-10 01:20:01 +04:00
|
|
|
virtual void DoLayout() = 0;
|
2010-08-17 22:43:41 +04:00
|
|
|
virtual void OwnerChanged(BView* was);
|
|
|
|
|
|
|
|
// BLayoutItem hook methods
|
|
|
|
virtual void AttachedToLayout();
|
|
|
|
virtual void DetachedFromLayout(BLayout* layout);
|
|
|
|
virtual void AncestorVisibilityChanged(bool shown);
|
|
|
|
|
|
|
|
// To be called by sub-classes in SetVisible().
|
|
|
|
void VisibilityChanged(bool show);
|
|
|
|
// To be called when layout data is known to be good
|
|
|
|
void ResetLayoutInvalidation();
|
2006-08-26 20:21:15 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
friend class BView;
|
|
|
|
|
2010-08-17 22:43:41 +04:00
|
|
|
bool InvalidateLayoutsForView(BView* view);
|
|
|
|
bool InvalidationLegal();
|
|
|
|
void SetOwner(BView* owner);
|
|
|
|
void SetTarget(BView* target);
|
|
|
|
|
|
|
|
void _LayoutWithinContext(bool force,
|
|
|
|
BLayoutContext* context);
|
|
|
|
|
|
|
|
uint32 fState;
|
|
|
|
bool fAncestorsVisible;
|
|
|
|
int32 fInvalidationDisabled;
|
|
|
|
BLayoutContext* fContext;
|
|
|
|
BView* fOwner;
|
|
|
|
BView* fTarget;
|
2006-08-26 20:21:15 +04:00
|
|
|
BList fItems;
|
2010-08-17 22:43:41 +04:00
|
|
|
BList fNestedLayouts;
|
2006-08-26 20:21:15 +04:00
|
|
|
};
|
|
|
|
|
2010-07-08 20:04:41 +04:00
|
|
|
|
2006-08-26 20:21:15 +04:00
|
|
|
#endif // _LAYOUT_H
|