1/* 2 * Copyright 2007-2010, Haiku. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Stefano Ceccherini (burton666@libero.it) 7 * Ingo Weinhold (ingo_weinhold@gmx.de) 8 */ 9#ifndef SMART_TAB_VIEW_H 10#define SMART_TAB_VIEW_H 11 12 13#include <TabView.h> 14 15 16class BButton; 17class BPopUpMenu; 18class BScrollView; 19 20 21class SmartTabView : public BTabView { 22public: 23 class Listener; 24 25public: 26 SmartTabView(BRect frame, const char* name, 27 button_width width = B_WIDTH_AS_USUAL, 28 uint32 resizingMode = B_FOLLOW_ALL, 29 uint32 flags = B_FULL_UPDATE_ON_RESIZE 30 | B_WILL_DRAW | B_NAVIGABLE_JUMP 31 | B_FRAME_EVENTS | B_NAVIGABLE); 32 SmartTabView(const char* name, 33 button_width width = B_WIDTH_AS_USUAL, 34 uint32 flags = B_FULL_UPDATE_ON_RESIZE 35 | B_WILL_DRAW | B_NAVIGABLE_JUMP 36 | B_FRAME_EVENTS | B_NAVIGABLE 37 | B_SUPPORTS_LAYOUT); 38 virtual ~SmartTabView(); 39 40 void SetInsets(float left, float top, float right, 41 float bottom); 42 43 virtual void MouseDown(BPoint where); 44 45 virtual void AttachedToWindow(); 46 virtual void AllAttached(); 47 48 virtual void Select(int32 tab); 49 50 virtual void AddTab(BView* target, BTab* tab = NULL); 51 virtual BTab* RemoveTab(int32 index); 52 void MoveTab(int32 index, int32 newIndex); 53 54 virtual BRect DrawTabs(); 55 56 void SetScrollView(BScrollView* scrollView); 57 58 void SetListener(Listener* listener) 59 { fListener = listener; } 60 61private: 62 int32 _ClickedTabIndex(const BPoint& point); 63 64private: 65 BRect fInsets; 66 BScrollView* fScrollView; 67 Listener* fListener; 68 BButton* fFullScreenButton; 69}; 70 71 72class SmartTabView::Listener { 73public: 74 virtual ~Listener(); 75 76 virtual void TabSelected(SmartTabView* tabView, int32 index); 77 virtual void TabDoubleClicked(SmartTabView* tabView, 78 BPoint point, int32 index); 79 virtual void TabMiddleClicked(SmartTabView* tabView, 80 BPoint point, int32 index); 81 virtual void TabRightClicked(SmartTabView* tabView, 82 BPoint point, int32 index); 83}; 84 85 86#endif // SMART_TAB_VIEW_H 87