Cleaned up a bit the code. Use GetPreferredSize() instead of

SetTermSize() to get the size of the view.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23602 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini 2008-01-18 10:11:03 +00:00
parent 0ccf70c877
commit 1490792706
2 changed files with 21 additions and 21 deletions

View File

@ -231,9 +231,9 @@ TermView::TermView(BMessage *archive)
if (archive->FindInt32("encoding", (int32 *)&fEncoding) < B_OK)
fEncoding = M_UTF8;
if (archive->FindInt32("columns", (int32 *)&fTermColumns) < B_OK)
fTermColumns = 80;
fTermColumns = COLUMNS_DEFAULT;
if (archive->FindInt32("rows", (int32 *)&fTermRows) < B_OK)
fTermRows = 25;
fTermRows = ROWS_DEFAULT;
// TODO: Retrieve arguments, colors, history size, etc. from archive
_InitObject(0, NULL);
@ -243,8 +243,6 @@ TermView::TermView(BMessage *archive)
status_t
TermView::_InitObject(int32 argc, const char **argv)
{
SetTermFont(be_fixed_font);
fTextBuffer = new (std::nothrow) TermBuffer(fTermRows, fTermColumns, fScrBufSize);
if (fTextBuffer == NULL)
return B_NO_MEMORY;
@ -253,19 +251,20 @@ TermView::_InitObject(int32 argc, const char **argv)
if (fShell == NULL)
return B_NO_MEMORY;
SetTermFont(be_fixed_font);
SetTermSize(fTermRows, fTermColumns, false);
//SetIMAware(false);
status_t status = fShell->Open(fTermRows, fTermColumns,
longname2shortname(id2longname(fEncoding)), argc, argv);
if (status < B_OK)
return status;
status = _AttachShell(fShell);
if (status < B_OK)
return status;
SetTermSize(fTermRows, fTermColumns, false);
//SetIMAware(false);
return B_OK;
}
@ -314,9 +313,9 @@ void
TermView::GetPreferredSize(float *width, float *height)
{
if (width)
*width = fTermColumns * fFontWidth;
*width = fTermColumns * fFontWidth - 1;
if (height)
*height = fTermRows * fFontHeight;
*height = fTermRows * fFontHeight - 1;
}
@ -549,7 +548,6 @@ TermView::Clear()
if (LockLooper()) {
SetHighColor(fTextBackColor);
FillRect(Bounds());
SetHighColor(fTextForeColor);
UnlockLooper();

View File

@ -366,10 +366,9 @@ TermWindow::MessageReceived(BMessage *message)
BFont font;
_GetPreferredFont(font);
_ActiveTermView()->SetTermFont(&font);
BRect rect = _ActiveTermView()->SetTermSize(0, 0, 0);
int width, height;
_ActiveTermView()->GetFontSize(&width, &height);
int fontWidth, fontHeight;
_ActiveTermView()->GetFontSize(&fontWidth, &fontHeight);
float minimumHeight = 0;
if (fMenubar)
@ -377,12 +376,15 @@ TermWindow::MessageReceived(BMessage *message)
if (fTabView && fTabView->CountTabs() > 1)
minimumHeight += fTabView->TabHeight();
SetSizeLimits(MIN_COLS * width, MAX_COLS * width,
minimumHeight + MIN_ROWS * height,
minimumHeight + MAX_ROWS * height);
SetSizeLimits(MIN_COLS * fontWidth, MAX_COLS * fontWidth,
minimumHeight + MIN_ROWS * fontHeight,
minimumHeight + MAX_ROWS * fontHeight);
ResizeTo(rect.Width() + B_V_SCROLL_BAR_WIDTH + kViewOffset * 2,
rect.Height() +fMenubar->Bounds().Height() + kViewOffset * 2);
float width, height;
_ActiveTermView()->GetPreferredSize(&width, &height);
width += B_V_SCROLL_BAR_WIDTH + kViewOffset * 2;
height += fMenubar->Bounds().Height() + kViewOffset * 2;
ResizeTo(width, height);
_ActiveTermView()->Invalidate();
break;