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:
@@ -231,9 +231,9 @@ TermView::TermView(BMessage *archive)
|
|||||||
if (archive->FindInt32("encoding", (int32 *)&fEncoding) < B_OK)
|
if (archive->FindInt32("encoding", (int32 *)&fEncoding) < B_OK)
|
||||||
fEncoding = M_UTF8;
|
fEncoding = M_UTF8;
|
||||||
if (archive->FindInt32("columns", (int32 *)&fTermColumns) < B_OK)
|
if (archive->FindInt32("columns", (int32 *)&fTermColumns) < B_OK)
|
||||||
fTermColumns = 80;
|
fTermColumns = COLUMNS_DEFAULT;
|
||||||
if (archive->FindInt32("rows", (int32 *)&fTermRows) < B_OK)
|
if (archive->FindInt32("rows", (int32 *)&fTermRows) < B_OK)
|
||||||
fTermRows = 25;
|
fTermRows = ROWS_DEFAULT;
|
||||||
|
|
||||||
// TODO: Retrieve arguments, colors, history size, etc. from archive
|
// TODO: Retrieve arguments, colors, history size, etc. from archive
|
||||||
_InitObject(0, NULL);
|
_InitObject(0, NULL);
|
||||||
@@ -243,8 +243,6 @@ TermView::TermView(BMessage *archive)
|
|||||||
status_t
|
status_t
|
||||||
TermView::_InitObject(int32 argc, const char **argv)
|
TermView::_InitObject(int32 argc, const char **argv)
|
||||||
{
|
{
|
||||||
SetTermFont(be_fixed_font);
|
|
||||||
|
|
||||||
fTextBuffer = new (std::nothrow) TermBuffer(fTermRows, fTermColumns, fScrBufSize);
|
fTextBuffer = new (std::nothrow) TermBuffer(fTermRows, fTermColumns, fScrBufSize);
|
||||||
if (fTextBuffer == NULL)
|
if (fTextBuffer == NULL)
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
@@ -253,6 +251,10 @@ TermView::_InitObject(int32 argc, const char **argv)
|
|||||||
if (fShell == NULL)
|
if (fShell == NULL)
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
|
SetTermFont(be_fixed_font);
|
||||||
|
SetTermSize(fTermRows, fTermColumns, false);
|
||||||
|
//SetIMAware(false);
|
||||||
|
|
||||||
status_t status = fShell->Open(fTermRows, fTermColumns,
|
status_t status = fShell->Open(fTermRows, fTermColumns,
|
||||||
longname2shortname(id2longname(fEncoding)), argc, argv);
|
longname2shortname(id2longname(fEncoding)), argc, argv);
|
||||||
|
|
||||||
@@ -263,9 +265,6 @@ TermView::_InitObject(int32 argc, const char **argv)
|
|||||||
if (status < B_OK)
|
if (status < B_OK)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
SetTermSize(fTermRows, fTermColumns, false);
|
|
||||||
//SetIMAware(false);
|
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -314,9 +313,9 @@ void
|
|||||||
TermView::GetPreferredSize(float *width, float *height)
|
TermView::GetPreferredSize(float *width, float *height)
|
||||||
{
|
{
|
||||||
if (width)
|
if (width)
|
||||||
*width = fTermColumns * fFontWidth;
|
*width = fTermColumns * fFontWidth - 1;
|
||||||
if (height)
|
if (height)
|
||||||
*height = fTermRows * fFontHeight;
|
*height = fTermRows * fFontHeight - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -549,7 +548,6 @@ TermView::Clear()
|
|||||||
|
|
||||||
if (LockLooper()) {
|
if (LockLooper()) {
|
||||||
SetHighColor(fTextBackColor);
|
SetHighColor(fTextBackColor);
|
||||||
|
|
||||||
FillRect(Bounds());
|
FillRect(Bounds());
|
||||||
SetHighColor(fTextForeColor);
|
SetHighColor(fTextForeColor);
|
||||||
UnlockLooper();
|
UnlockLooper();
|
||||||
|
|||||||
@@ -366,10 +366,9 @@ TermWindow::MessageReceived(BMessage *message)
|
|||||||
BFont font;
|
BFont font;
|
||||||
_GetPreferredFont(font);
|
_GetPreferredFont(font);
|
||||||
_ActiveTermView()->SetTermFont(&font);
|
_ActiveTermView()->SetTermFont(&font);
|
||||||
BRect rect = _ActiveTermView()->SetTermSize(0, 0, 0);
|
|
||||||
|
|
||||||
int width, height;
|
int fontWidth, fontHeight;
|
||||||
_ActiveTermView()->GetFontSize(&width, &height);
|
_ActiveTermView()->GetFontSize(&fontWidth, &fontHeight);
|
||||||
|
|
||||||
float minimumHeight = 0;
|
float minimumHeight = 0;
|
||||||
if (fMenubar)
|
if (fMenubar)
|
||||||
@@ -377,12 +376,15 @@ TermWindow::MessageReceived(BMessage *message)
|
|||||||
if (fTabView && fTabView->CountTabs() > 1)
|
if (fTabView && fTabView->CountTabs() > 1)
|
||||||
minimumHeight += fTabView->TabHeight();
|
minimumHeight += fTabView->TabHeight();
|
||||||
|
|
||||||
SetSizeLimits(MIN_COLS * width, MAX_COLS * width,
|
SetSizeLimits(MIN_COLS * fontWidth, MAX_COLS * fontWidth,
|
||||||
minimumHeight + MIN_ROWS * height,
|
minimumHeight + MIN_ROWS * fontHeight,
|
||||||
minimumHeight + MAX_ROWS * height);
|
minimumHeight + MAX_ROWS * fontHeight);
|
||||||
|
|
||||||
ResizeTo(rect.Width() + B_V_SCROLL_BAR_WIDTH + kViewOffset * 2,
|
float width, height;
|
||||||
rect.Height() +fMenubar->Bounds().Height() + kViewOffset * 2);
|
_ActiveTermView()->GetPreferredSize(&width, &height);
|
||||||
|
width += B_V_SCROLL_BAR_WIDTH + kViewOffset * 2;
|
||||||
|
height += fMenubar->Bounds().Height() + kViewOffset * 2;
|
||||||
|
ResizeTo(width, height);
|
||||||
|
|
||||||
_ActiveTermView()->Invalidate();
|
_ActiveTermView()->Invalidate();
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user