haiku/headers/os/interface/Layout.h
Alex Wilson 1d6c7b6cb6 Big change deriving BLayout from BLayoutItem, and allowing viewless BLayouts.
a few highlights:
* BLayout now derives publicly from BLayoutItem
* Added BAbstractLayout class, which our layouts now derive from
* updated layout builders to avoid creating views when they don't need to
* updated layout classes
* updated AboutSystem to fix a little regression
* more details on #6407
* please tell me about any regressions, I've tried to find them all, but some
  may have slipped by.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38207 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-08-17 18:43:41 +00:00

113 lines
3.0 KiB
C++

/*
* Copyright 2006-2010, Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _LAYOUT_H
#define _LAYOUT_H
#include <Alignment.h>
#include <Archivable.h>
#include <LayoutItem.h>
#include <List.h>
#include <Size.h>
class BLayoutContext;
class BLayoutItem;
class BView;
class BLayout : public BLayoutItem {
public:
BLayout();
BLayout(BMessage* archive);
virtual ~BLayout();
BView* Owner() const;
BView* TargetView() const;
virtual BView* View(); // from BLayoutItem
// methods dealing with items
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;
int32 IndexOfItem(const BLayoutItem* item) const;
int32 IndexOfView(BView* child) const;
bool AncestorsVisible();
// Layouting related methods
virtual void InvalidateLayout(bool children = false);
virtual void Relayout(bool immediate = false);
void RequireLayout();
bool IsValid();
void EnableLayoutInvalidation();
void DisableLayoutInvalidation();
void LayoutItems(bool force = false);
BRect LayoutArea();
BLayoutContext* LayoutContext();
// Archiving methods
virtual status_t Archive(BMessage* into, bool deep = true) const;
virtual status_t AllUnarchived(const BMessage* from);
virtual status_t ItemArchived(BMessage* into, BLayoutItem* item,
int32 index) const;
virtual status_t ItemUnarchived(const BMessage* from,
BLayoutItem* item, int32 index);
protected:
// BLayout hook methods
virtual bool ItemAdded(BLayoutItem* item, int32 atIndex);
virtual void ItemRemoved(BLayoutItem* item, int32 fromIndex);
virtual void DerivedLayoutItems() = 0;
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();
private:
friend class BView;
bool RemoveViewRecursive(BView* view);
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;
BList fItems;
BList fNestedLayouts;
};
#endif // _LAYOUT_H