Limit the number of tabs to 6 per window (at least for now). More tabs

are not that useful, and the terminal doesn't like it anyway.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23700 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini
2008-01-22 09:54:22 +00:00
parent a39bfc19fd
commit a08f19d598
3 changed files with 21 additions and 22 deletions
+1 -1
View File
@@ -39,7 +39,7 @@ public:
virtual void GetPreferredSize(float *width, float *height); virtual void GetPreferredSize(float *width, float *height);
const char *TerminalName() const; const char *TerminalName() const;
void SetTermFont(const BFont *font); void SetTermFont(const BFont *font);
void GetFontSize(int *width, int *height); void GetFontSize(int *width, int *height);
BRect SetTermSize(int rows, int cols, bool resize); BRect SetTermSize(int rows, int cols, bool resize);
+18 -20
View File
@@ -43,6 +43,7 @@
const static float kViewOffset = 3; const static float kViewOffset = 3;
const static uint32 kNewTab = 'NTab'; const static uint32 kNewTab = 'NTab';
const static uint32 kCloseView = 'ClVw'; const static uint32 kCloseView = 'ClVw';
const static int32 kMaxTabs = 6;
class CustomTermView : public TermView { class CustomTermView : public TermView {
@@ -93,10 +94,6 @@ TermWindow::~TermWindow()
} }
// #pragma mark - public methods
/** Initialize Window object. */
void void
TermWindow::_InitWindow() TermWindow::_InitWindow()
{ {
@@ -232,7 +229,8 @@ TermWindow::MessageReceived(BMessage *message)
break; break;
case kNewTab: case kNewTab:
_AddTab(NULL); if (fTabView->CountTabs() < kMaxTabs)
_AddTab(NULL);
break; break;
case kCloseView: case kCloseView:
@@ -614,27 +612,26 @@ TermWindow::_AddTab(Arguments *args)
_SetTermColors(view); _SetTermColors(view);
if (fTabView->CountTabs() >= 1) { int width, height;
int width, height; view->GetFontSize(&width, &height);
view->GetFontSize(&width, &height);
float minimumHeight = 0; float minimumHeight = 0;
if (fMenubar) if (fMenubar)
minimumHeight += fMenubar->Bounds().Height(); minimumHeight += fMenubar->Bounds().Height();
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 * width, MAX_COLS * width,
minimumHeight + MIN_ROWS * height, minimumHeight + MIN_ROWS * height,
minimumHeight + MAX_ROWS * height); minimumHeight + MAX_ROWS * height);
}
// If it's the first time we're called, setup the window // If it's the first time we're called, setup the window
if (fTabView->CountTabs() == 1) { if (fTabView->CountTabs() == 1) {
float fWidth, fHeight; float viewWidth, viewHeight;
view->GetPreferredSize(&fWidth, &fHeight); view->GetPreferredSize(&viewWidth, &viewHeight);
// Resize Window // Resize Window
ResizeTo(fWidth + B_V_SCROLL_BAR_WIDTH, fHeight + fMenubar->Bounds().Height()); ResizeTo(viewWidth + B_V_SCROLL_BAR_WIDTH,
viewHeight + fMenubar->Bounds().Height());
// TODO: If I don't do this, the view won't show up. // TODO: If I don't do this, the view won't show up.
// Bug in BTabView or in my code ? // Bug in BTabView or in my code ?
@@ -646,6 +643,7 @@ TermWindow::_AddTab(Arguments *args)
} }
} }
void void
TermWindow::_RemoveTab(int32 index) TermWindow::_RemoveTab(int32 index)
{ {
+2 -1
View File
@@ -35,7 +35,6 @@
#include <String.h> #include <String.h>
#include <Window.h> #include <Window.h>
class Arguments; class Arguments;
class BFont; class BFont;
class BMenu; class BMenu;
@@ -45,6 +44,7 @@ class PrefWindow;
class TermView; class TermView;
class SmartTabView; class SmartTabView;
class TermWindow : public BWindow { class TermWindow : public BWindow {
public: public:
TermWindow(BRect frame, const char* title, Arguments *args); TermWindow(BRect frame, const char* title, Arguments *args);
@@ -72,6 +72,7 @@ private:
SmartTabView *fTabView; SmartTabView *fTabView;
TermView *fTermView; TermView *fTermView;
BMenuBar *fMenubar; BMenuBar *fMenubar;
BMenu *fFilemenu; BMenu *fFilemenu;
BMenu *fEditmenu; BMenu *fEditmenu;