1 /* 2 * Copyright (C) 2010 Stephan Aßmus <superstippi@gmx.de> 3 * 4 * All rights reserved. Distributed under the terms of the MIT License. 5 */ 6 #ifndef TAB_VIEW_H 7 #define TAB_VIEW_H 8 9 #include <AbstractLayoutItem.h> 10 #include <Rect.h> 11 #include <String.h> 12 13 14 class BMessage; 15 class BView; 16 class TabContainerView; 17 class TabLayoutItem; 18 19 20 class TabView { 21 public: 22 TabView(); 23 virtual ~TabView(); 24 25 virtual BSize MinSize(); 26 virtual BSize PreferredSize(); 27 virtual BSize MaxSize(); 28 29 void Draw(BRect updateRect); 30 virtual void DrawBackground(BView* owner, BRect frame, 31 const BRect& updateRect, bool isFirst, 32 bool isLast, bool isFront); 33 virtual void DrawContents(BView* owner, BRect frame, 34 const BRect& updateRect, bool isFirst, 35 bool isLast, bool isFront); 36 37 virtual void MouseDown(BPoint where, uint32 buttons); 38 virtual void MouseUp(BPoint where); 39 virtual void MouseMoved(BPoint where, uint32 transit, 40 const BMessage* dragMessage); 41 42 void SetIsFront(bool isFront); 43 bool IsFront() const; 44 void SetIsLast(bool isLast); 45 virtual void Update(bool isFirst, bool isLast, 46 bool isFront); 47 48 BLayoutItem* LayoutItem() const; 49 void SetContainerView( 50 TabContainerView* containerView); 51 TabContainerView* ContainerView() const; 52 53 void SetLabel(const char* label); 54 const BString& Label() const; 55 56 BRect Frame() const; 57 58 private: 59 float _LabelHeight() const; 60 61 private: 62 TabContainerView* fContainerView; 63 TabLayoutItem* fLayoutItem; 64 65 BString fLabel; 66 67 bool fIsFirst; 68 bool fIsLast; 69 bool fIsFront; 70 }; 71 72 73 class TabLayoutItem : public BAbstractLayoutItem { 74 public: 75 TabLayoutItem(TabView* parent); 76 77 virtual bool IsVisible(); 78 virtual void SetVisible(bool visible); 79 80 virtual BRect Frame(); 81 virtual void SetFrame(BRect frame); 82 83 virtual BView* View(); 84 85 virtual BSize BaseMinSize(); 86 virtual BSize BaseMaxSize(); 87 virtual BSize BasePreferredSize(); 88 virtual BAlignment BaseAlignment(); 89 90 TabView* Parent() const; 91 void InvalidateContainer(); 92 void InvalidateContainer(BRect frame); 93 private: 94 TabView* fParent; 95 BRect fFrame; 96 bool fVisible; 97 }; 98 99 100 101 #endif // TAB_VIEW_H 102