Skip to content

Commit

Permalink
BTextView: implemented height-for-width when read-only.
Browse files Browse the repository at this point in the history
* This is not an ideal implementation, as it actually relayouts
  the text view. IOW it's actually wrong, but it does seem to
  work without any issues.
  • Loading branch information
axeld committed Jul 30, 2015
1 parent fd3e3e7 commit e27a53b
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions src/kits/interface/TextView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2577,18 +2577,33 @@ BTextView::PreferredSize()
bool
BTextView::HasHeightForWidth()
{
// ToDo: When not editable and not embedded in a scroll view, we should
// assume that all text is supposed to be visible.
return BView::HasHeightForWidth();
if (IsEditable())
return BView::HasHeightForWidth();

// When not editable, we assume that all text is supposed to be visible.
return true;
}


void
BTextView::GetHeightForWidth(float width, float* min, float* max,
float* preferred)
{
// ToDo: See above and implement.
BView::GetHeightForWidth(width, min, max, preferred);
if (IsEditable()) {
BView::GetHeightForWidth(width, min, max, preferred);
return;
}

// TODO: don't change the actual text rect!
fTextRect.right = fTextRect.left + width;
_Refresh(0, TextLength(), false);

if (min != NULL)
*min = fTextRect.Height();
if (max != NULL)
*max = fTextRect.Height();
if (preferred != NULL)
*preferred = fTextRect.Height();
}


Expand Down

0 comments on commit e27a53b

Please sign in to comment.