Give the area an id.

This commit is contained in:
czeidler 2012-01-11 17:19:29 +13:00 committed by Alex Wilson
parent b7630c4c98
commit c3e57dc36d
4 changed files with 41 additions and 0 deletions

View File

@ -65,6 +65,7 @@ public:
void SetSpacing(float spacing); void SetSpacing(float spacing);
float Spacing() const; float Spacing() const;
Area* AreaFor(int32 id) const;
Area* AreaFor(const BView* view) const; Area* AreaFor(const BView* view) const;
Area* AreaFor(const BLayoutItem* item) const; Area* AreaFor(const BLayoutItem* item) const;
int32 CountAreas() const; int32 CountAreas() const;

View File

@ -65,6 +65,9 @@ class Area {
public: public:
~Area(); ~Area();
int32 ID() const;
void SetID(int32 id);
BLayoutItem* Item(); BLayoutItem* Item();
XTab* Left() const; XTab* Left() const;
@ -121,6 +124,7 @@ private:
void _UpdateMaxSizeConstraint(BSize max); void _UpdateMaxSizeConstraint(BSize max);
private: private:
BLayoutItem* fLayoutItem; BLayoutItem* fLayoutItem;
int32 fID;
LinearSpec* fLS; LinearSpec* fLS;

View File

@ -208,6 +208,19 @@ BALMLayout::AddColumn(XTab* _left, XTab* _right)
} }
Area*
BALMLayout::AreaFor(int32 id) const
{
int32 areaCount = CountAreas();
for (int32 i = 0; i < areaCount; i++) {
Area* area = AreaAt(i);
if (area->ID() == id)
return area;
}
return NULL;
}
/** /**
* Finds the area that contains the given control. * Finds the area that contains the given control.
* *

View File

@ -522,6 +522,15 @@ Area::~Area()
} }
static int32 sAreaID = 0;
static int32
new_area_id()
{
return sAreaID++;
}
/** /**
* Constructor. * Constructor.
* Uses XTabs and YTabs. * Uses XTabs and YTabs.
@ -550,7 +559,21 @@ Area::Area(BLayoutItem* item)
fContentAspectRatio(-1), fContentAspectRatio(-1),
fContentAspectRatioC(NULL) fContentAspectRatioC(NULL)
{ {
fID = new_area_id();
}
int32
Area::ID() const
{
return fID;
}
void
Area::SetID(int32 id)
{
fID = id;
} }