{Tree,Table}: Add cell rect accessor.
BColumnListView:
- Add helper method for getting the visible rect of a given field.
Refactor SuggestTextPosition to use it.
{Tree,Table}:
- Add wrapper to retrieve table cell rect using the aforementioned
BCLV helper.
This commit is contained in:
@@ -363,6 +363,9 @@ public:
|
|||||||
BPoint SuggestTextPosition(const BRow* row,
|
BPoint SuggestTextPosition(const BRow* row,
|
||||||
const BColumn* column = NULL) const;
|
const BColumn* column = NULL) const;
|
||||||
|
|
||||||
|
BRect GetFieldRect(const BRow* row,
|
||||||
|
const BColumn* column) const;
|
||||||
|
|
||||||
void SetLatchWidth(float width);
|
void SetLatchWidth(float width);
|
||||||
float LatchWidth() const;
|
float LatchWidth() const;
|
||||||
virtual void DrawLatch(BView* view, BRect frame,
|
virtual void DrawLatch(BView* view, BRect frame,
|
||||||
|
|||||||
@@ -499,6 +499,23 @@ Table::RemoveTableListener(TableListener* listener)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
Table::GetCellRectAt(int32 rowIndex, int32 colIndex, BRect& _output) const
|
||||||
|
{
|
||||||
|
BRow* row = fRows.ItemAt(rowIndex);
|
||||||
|
if (row == NULL)
|
||||||
|
return B_ENTRY_NOT_FOUND;
|
||||||
|
|
||||||
|
AbstractColumn* column = fColumns.ItemAt(colIndex);
|
||||||
|
if (column == NULL)
|
||||||
|
return B_ENTRY_NOT_FOUND;
|
||||||
|
|
||||||
|
_output = GetFieldRect(row, column);
|
||||||
|
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
Table::GetToolTipAt(BPoint point, BToolTip** _tip)
|
Table::GetToolTipAt(BPoint point, BToolTip** _tip)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -135,6 +135,9 @@ public:
|
|||||||
bool AddTableListener(TableListener* listener);
|
bool AddTableListener(TableListener* listener);
|
||||||
void RemoveTableListener(TableListener* listener);
|
void RemoveTableListener(TableListener* listener);
|
||||||
|
|
||||||
|
virtual status_t GetCellRectAt(int32 rowIndex, int32 colIndex,
|
||||||
|
BRect& _output) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool GetToolTipAt(BPoint point, BToolTip** _tip);
|
virtual bool GetToolTipAt(BPoint point, BToolTip** _tip);
|
||||||
|
|
||||||
|
|||||||
@@ -843,6 +843,24 @@ TreeTable::RemoveTreeTableListener(TreeTableListener* listener)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
TreeTable::GetCellRectAt(const TreeTablePath& path, int32 colIndex,
|
||||||
|
BRect& _output) const
|
||||||
|
{
|
||||||
|
TreeTableNode* node = _NodeForPath(path);
|
||||||
|
if (node == NULL)
|
||||||
|
return B_ENTRY_NOT_FOUND;
|
||||||
|
|
||||||
|
AbstractColumn* column = fColumns.ItemAt(colIndex);
|
||||||
|
if (column == NULL)
|
||||||
|
return B_ENTRY_NOT_FOUND;
|
||||||
|
|
||||||
|
_output = GetFieldRect(node->Row(), column);
|
||||||
|
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
TreeTable::GetToolTipAt(BPoint point, BToolTip** _tip)
|
TreeTable::GetToolTipAt(BPoint point, BToolTip** _tip)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -195,6 +195,9 @@ public:
|
|||||||
void RemoveTreeTableListener(
|
void RemoveTreeTableListener(
|
||||||
TreeTableListener* listener);
|
TreeTableListener* listener);
|
||||||
|
|
||||||
|
virtual status_t GetCellRectAt(const TreeTablePath& path,
|
||||||
|
int32 colIndex, BRect& _output) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool GetToolTipAt(BPoint point, BToolTip** _tip);
|
virtual bool GetToolTipAt(BPoint point, BToolTip** _tip);
|
||||||
|
|
||||||
|
|||||||
@@ -1501,10 +1501,23 @@ BColumnListView::EditColor() const
|
|||||||
BPoint
|
BPoint
|
||||||
BColumnListView::SuggestTextPosition(const BRow* row,
|
BColumnListView::SuggestTextPosition(const BRow* row,
|
||||||
const BColumn* inColumn) const
|
const BColumn* inColumn) const
|
||||||
|
{
|
||||||
|
BRect rect(GetFieldRect(row, inColumn));
|
||||||
|
|
||||||
|
font_height fh;
|
||||||
|
fOutlineView->GetFontHeight(&fh);
|
||||||
|
float baseline = floor(rect.top + fh.ascent
|
||||||
|
+ (rect.Height() + 1 - (fh.ascent + fh.descent)) / 2);
|
||||||
|
return BPoint(rect.left + 8, baseline);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BRect
|
||||||
|
BColumnListView::GetFieldRect(const BRow* row, const BColumn* inColumn) const
|
||||||
{
|
{
|
||||||
BRect rect;
|
BRect rect;
|
||||||
GetRowRect(row, &rect);
|
GetRowRect(row, &rect);
|
||||||
if (inColumn) {
|
if (inColumn != NULL) {
|
||||||
float leftEdge = MAX(kLeftMargin, LatchWidth());
|
float leftEdge = MAX(kLeftMargin, LatchWidth());
|
||||||
for (int index = 0; index < fColumns.CountItems(); index++) {
|
for (int index = 0; index < fColumns.CountItems(); index++) {
|
||||||
BColumn* column = (BColumn*) fColumns.ItemAt(index);
|
BColumn* column = (BColumn*) fColumns.ItemAt(index);
|
||||||
@@ -1521,11 +1534,7 @@ BColumnListView::SuggestTextPosition(const BRow* row,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
font_height fh;
|
return rect;
|
||||||
fOutlineView->GetFontHeight(&fh);
|
|
||||||
float baseline = floor(rect.top + fh.ascent
|
|
||||||
+ (rect.Height() + 1 - (fh.ascent + fh.descent)) / 2);
|
|
||||||
return BPoint(rect.left + 8, baseline);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user