* Introduced methods ResizeColumnToPreferred() and
ResizeAllColumnsToPreferred(). * Automatic white space cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30683 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -302,6 +302,8 @@ public:
|
||||
void SetColumnVisible(int32, bool);
|
||||
bool IsColumnVisible(int32) const;
|
||||
void SetColumnFlags(column_flags flags);
|
||||
void ResizeColumnToPreferred(int32 index);
|
||||
void ResizeAllColumnsToPreferred();
|
||||
|
||||
// Row manipulation
|
||||
const BRow* RowAt(int32 index, BRow *parent = 0) const;
|
||||
|
||||
@@ -219,6 +219,7 @@ public:
|
||||
virtual ~TitleView();
|
||||
|
||||
void ColumnAdded(BColumn* column);
|
||||
void ColumnResized(BColumn* column, float oldWidth);
|
||||
void SetColumnVisible(BColumn* column, bool visible);
|
||||
|
||||
virtual void Draw(BRect updateRect);
|
||||
@@ -1149,6 +1150,38 @@ BColumnListView::SetColumnFlags(column_flags flags)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BColumnListView::ResizeColumnToPreferred(int32 index)
|
||||
{
|
||||
BColumn* column = ColumnAt(index);
|
||||
if (column == NULL)
|
||||
return;
|
||||
|
||||
// get the preferred column width
|
||||
float width = fOutlineView->GetColumnPreferredWidth(column);
|
||||
if (width < column->MinWidth())
|
||||
width = column->MinWidth();
|
||||
else if (width > column->MaxWidth())
|
||||
width = column->MaxWidth();
|
||||
|
||||
// set it
|
||||
float oldWidth = column->Width();
|
||||
column->SetWidth(width);
|
||||
|
||||
fTitleView->ColumnResized(column, oldWidth);
|
||||
fOutlineView->Invalidate();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BColumnListView::ResizeAllColumnsToPreferred()
|
||||
{
|
||||
int32 count = CountColumns();
|
||||
for (int32 i = 0; i < count; i++)
|
||||
ResizeColumnToPreferred(i);
|
||||
}
|
||||
|
||||
|
||||
const BRow*
|
||||
BColumnListView::RowAt(int32 Index, BRow* parentRow) const
|
||||
{
|
||||
@@ -2070,6 +2103,15 @@ TitleView::ColumnAdded(BColumn* column)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TitleView::ColumnResized(BColumn* column, float oldWidth)
|
||||
{
|
||||
fColumnsWidth += column->Width() - oldWidth;
|
||||
FixScrollBar(false);
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TitleView::SetColumnVisible(BColumn* column, bool visible)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user