From 24a77ea0bee4f9b74b0f7f3839b13bb39e932504 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Sat, 8 Jan 2011 16:14:13 +0000 Subject: [PATCH] * Added ItemAt() method that accepts column and row. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40154 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/os/interface/GridLayout.h | 14 +++++++++----- src/kits/interface/GridLayout.cpp | 13 ++++++++++++- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/headers/os/interface/GridLayout.h b/headers/os/interface/GridLayout.h index 63bfbc8a07..f0acbc9e42 100644 --- a/headers/os/interface/GridLayout.h +++ b/headers/os/interface/GridLayout.h @@ -1,10 +1,11 @@ /* - * Copyright 2006-2010, Haiku, Inc. All rights reserved. + * Copyright 2006-2011, Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. */ #ifndef _GRID_LAYOUT_H #define _GRID_LAYOUT_H + #include @@ -44,6 +45,8 @@ public: float MaxRowHeight(int32 row) const; void SetMaxRowHeight(int32 row, float height); + BLayoutItem* ItemAt(int32 column, int32 row) const; + virtual BLayoutItem* AddView(BView* child); virtual BLayoutItem* AddView(int32 index, BView* child); virtual BLayoutItem* AddView(BView* child, int32 column, int32 row, @@ -63,13 +66,13 @@ public: virtual status_t ItemUnarchived(const BMessage* from, BLayoutItem* item, int32 index); -protected: +protected: virtual bool ItemAdded(BLayoutItem* item, int32 atIndex); virtual void ItemRemoved(BLayoutItem* item, int32 fromIndex); virtual bool HasMultiColumnItems(); virtual bool HasMultiRowItems(); - + virtual int32 InternalCountColumns(); virtual int32 InternalCountRows(); virtual void GetColumnRowConstraints( @@ -79,11 +82,11 @@ protected: virtual void GetItemDimensions(BLayoutItem* item, Dimensions* dimensions); -private: +private: class DummyLayoutItem; class RowInfoArray; struct ItemLayoutData; - + bool _IsGridCellEmpty(int32 column, int32 row); bool _AreGridCellsEmpty(int32 column, int32 row, int32 columnCount, int32 rowCount); @@ -105,4 +108,5 @@ private: int32 fMultiRowItems; }; + #endif // _GRID_LAYOUT_H diff --git a/src/kits/interface/GridLayout.cpp b/src/kits/interface/GridLayout.cpp index 2d286d67c5..ef16c1567c 100644 --- a/src/kits/interface/GridLayout.cpp +++ b/src/kits/interface/GridLayout.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2010, Haiku Inc. + * Copyright 2010-2011, Haiku Inc. * Copyright 2006, Ingo Weinhold . * All rights reserved. Distributed under the terms of the MIT License. */ @@ -372,6 +372,17 @@ BGridLayout::SetMaxRowHeight(int32 row, float height) } +BLayoutItem* +BGridLayout::ItemAt(int32 column, int32 row) const +{ + if (column < 0 || column >= CountColumns() + || row < 0 || row >= CountRows()) + return NULL; + + return fGrid[column][row]; +} + + BLayoutItem* BGridLayout::AddView(BView* child) {