* Removed BeOS work-around in TermScrollView.cpp.
* Improved comments. * Coding style cleanup, no functional change. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33869 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -6,6 +6,14 @@
|
||||
* Stefano Ceccherini ([email protected])
|
||||
*/
|
||||
|
||||
|
||||
/*! The SmartTabView class is a BTabView descendant that hides the tab bar
|
||||
as long as there is only a single tab.
|
||||
Furthermore, it provides a tab context menu, as well as allowing you to
|
||||
close buttons with the middle mouse button.
|
||||
*/
|
||||
|
||||
|
||||
#include "SmartTabView.h"
|
||||
|
||||
#include <MenuItem.h>
|
||||
@@ -17,8 +25,10 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
const static uint32 kCloseTab = 'ClTb';
|
||||
|
||||
|
||||
SmartTabView::SmartTabView(BRect frame, const char* name, button_width width,
|
||||
uint32 resizingMode, uint32 flags)
|
||||
:
|
||||
@@ -59,7 +69,7 @@ SmartTabView::MouseDown(BPoint point)
|
||||
if (tabIndex >= 0) {
|
||||
int32 buttons;
|
||||
Window()->CurrentMessage()->FindInt32("buttons", &buttons);
|
||||
if (buttons & B_SECONDARY_MOUSE_BUTTON) {
|
||||
if ((buttons & B_SECONDARY_MOUSE_BUTTON) != 0) {
|
||||
BMessage* message = new BMessage(kCloseTab);
|
||||
message->AddInt32("index", tabIndex);
|
||||
|
||||
@@ -70,7 +80,7 @@ SmartTabView::MouseDown(BPoint point)
|
||||
popUpMenu->Go(ConvertToScreen(point), true, true, true);
|
||||
|
||||
handled = true;
|
||||
} else if (buttons & B_TERTIARY_MOUSE_BUTTON) {
|
||||
} else if ((buttons & B_TERTIARY_MOUSE_BUTTON) != 0) {
|
||||
RemoveAndDeleteTab(tabIndex);
|
||||
handled = true;
|
||||
}
|
||||
@@ -79,7 +89,6 @@ SmartTabView::MouseDown(BPoint point)
|
||||
|
||||
if (!handled)
|
||||
BTabView::MouseDown(point);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -157,11 +166,13 @@ SmartTabView::AddTab(BView *target, BTab *tab)
|
||||
// inside that function
|
||||
Select(0);
|
||||
} else if (CountTabs() == 2) {
|
||||
// Need to resize the view, since we're
|
||||
// switching from "normal" to tabbed mode
|
||||
// Need to resize the view, since we're switching from "normal"
|
||||
// to tabbed mode
|
||||
ContainerView()->ResizeBy(0, -TabHeight());
|
||||
ContainerView()->MoveBy(0, TabHeight());
|
||||
|
||||
// Make sure the content size stays the same, but take special care
|
||||
// of full screen mode
|
||||
BScreen screen(Window());
|
||||
if (Window()->DecoratorFrame().Height() + 2 * TabHeight()
|
||||
< screen.Frame().Height()) {
|
||||
@@ -182,7 +193,10 @@ BTab *
|
||||
SmartTabView::RemoveTab(int32 index)
|
||||
{
|
||||
if (CountTabs() == 2) {
|
||||
// see AddTab()
|
||||
// Hide the tab bar again by resizing the container view
|
||||
|
||||
// Make sure the content size stays the same, but take special care
|
||||
// of full screen mode
|
||||
BScreen screen(Window());
|
||||
if (Window()->DecoratorFrame().Height() + 2 * TabHeight()
|
||||
< screen.Frame().Height()) {
|
||||
@@ -196,6 +210,7 @@ SmartTabView::RemoveTab(int32 index)
|
||||
ContainerView()->MoveBy(0, -TabHeight());
|
||||
ContainerView()->ResizeBy(0, TabHeight());
|
||||
}
|
||||
|
||||
return BTabView::RemoveTab(index);
|
||||
}
|
||||
|
||||
@@ -205,6 +220,7 @@ SmartTabView::DrawTabs()
|
||||
{
|
||||
if (CountTabs() > 1)
|
||||
return BTabView::DrawTabs();
|
||||
|
||||
return BRect();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,27 +1,32 @@
|
||||
/*
|
||||
* Copyright 2007, Haiku. All rights reserved.
|
||||
* Copyright 2007-2009, Haiku. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Stefano Ceccherini ([email protected])
|
||||
*/
|
||||
#ifndef __SMARTTABVIEW_H
|
||||
#define __SMARTTABVIEW_H
|
||||
#ifndef SMART_TAB_VIEW_H
|
||||
#define SMART_TAB_VIEW_H
|
||||
|
||||
|
||||
#include <TabView.h>
|
||||
|
||||
|
||||
class BPopUpMenu;
|
||||
|
||||
|
||||
class SmartTabView : public BTabView {
|
||||
public:
|
||||
SmartTabView(BRect frame, const char* name,
|
||||
button_width width = B_WIDTH_AS_USUAL,
|
||||
uint32 resizingMode = B_FOLLOW_ALL,
|
||||
uint32 flags = B_FULL_UPDATE_ON_RESIZE |
|
||||
B_WILL_DRAW | B_NAVIGABLE_JUMP |
|
||||
B_FRAME_EVENTS | B_NAVIGABLE);
|
||||
uint32 flags = B_FULL_UPDATE_ON_RESIZE
|
||||
| B_WILL_DRAW | B_NAVIGABLE_JUMP
|
||||
| B_FRAME_EVENTS | B_NAVIGABLE);
|
||||
virtual ~SmartTabView();
|
||||
|
||||
void SetInsets(float left, float top, float right, float bottom);
|
||||
void SetInsets(float left, float top, float right,
|
||||
float bottom);
|
||||
|
||||
virtual void MouseDown(BPoint where);
|
||||
|
||||
@@ -46,5 +51,4 @@ private:
|
||||
BRect fInsets;
|
||||
};
|
||||
|
||||
#endif // __SMARTTABVIEW_H
|
||||
|
||||
#endif // SMART_TAB_VIEW_H
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
// NOTE: Nasty hack to get access to BScrollView's private parts.
|
||||
#include <ScrollBar.h>
|
||||
#define private protected
|
||||
@@ -11,9 +12,6 @@
|
||||
|
||||
#include "TermScrollView.h"
|
||||
|
||||
#ifndef __HAIKU__
|
||||
#define fVerticalScrollBar fVSB
|
||||
#endif
|
||||
|
||||
class TermScrollBar : public BScrollBar {
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user