From 1490792706c8e82f209b25f731d3a986561351ff Mon Sep 17 00:00:00 2001 From: Stefano Ceccherini Date: Fri, 18 Jan 2008 10:11:03 +0000 Subject: [PATCH] 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 --- src/apps/terminal/TermView.cpp | 22 ++++++++++------------ src/apps/terminal/TermWindow.cpp | 20 +++++++++++--------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/apps/terminal/TermView.cpp b/src/apps/terminal/TermView.cpp index a9f8c6c7db..35a38436d4 100644 --- a/src/apps/terminal/TermView.cpp +++ b/src/apps/terminal/TermView.cpp @@ -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(); diff --git a/src/apps/terminal/TermWindow.cpp b/src/apps/terminal/TermWindow.cpp index 8660dc25c2..4a63716900 100644 --- a/src/apps/terminal/TermWindow.cpp +++ b/src/apps/terminal/TermWindow.cpp @@ -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;