1 //------------------------------------------------------------------------------ 2 // Copyright (c) 2001-2002, OpenBeOS 3 // 4 // Permission is hereby granted, free of charge, to any person obtaining a 5 // copy of this software and associated documentation files (the "Software"), 6 // to deal in the Software without restriction, including without limitation 7 // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 // and/or sell copies of the Software, and to permit persons to whom the 9 // Software is furnished to do so, subject to the following conditions: 10 // 11 // The above copyright notice and this permission notice shall be included in 12 // all copies or substantial portions of the Software. 13 // 14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 // DEALINGS IN THE SOFTWARE. 21 // 22 // File Name: TabView.h 23 // Author: Marc Flerackers (mflerackers@androme.be) 24 // Description: BTab creates individual "tabs" that can be assigned 25 // to specific views. 26 // BTabView provides the framework for containing and 27 // managing groups of BTab objects. 28 //------------------------------------------------------------------------------ 29 30 #ifndef _TAB_VIEW_H 31 #define _TAB_VIEW_H 32 33 // Standard Includes ----------------------------------------------------------- 34 35 // System Includes ------------------------------------------------------------- 36 #include <BeBuild.h> 37 #include <View.h> 38 39 // Project Includes ------------------------------------------------------------ 40 41 // Local Includes -------------------------------------------------------------- 42 43 // Local Defines --------------------------------------------------------------- 44 enum tab_position { 45 B_TAB_FIRST = 999, 46 B_TAB_FRONT, 47 B_TAB_ANY 48 }; 49 50 // Globals --------------------------------------------------------------------- 51 52 53 // BTab class ------------------------------------------------------------------ 54 class BTab : public BArchivable { 55 56 public: 57 BTab(BView * tabView = NULL); 58 virtual ~BTab(); 59 60 BTab(BMessage *archive); 61 static BArchivable *Instantiate(BMessage *archive); 62 63 virtual status_t Archive(BMessage *archive, bool deep = true) const; 64 virtual status_t Perform(uint32 d, void *arg); 65 66 const char *Label() const; 67 virtual void SetLabel(const char *label); 68 69 bool IsSelected() const; 70 virtual void Select(BView *owner); 71 virtual void Deselect(); 72 73 virtual void SetEnabled(bool enabled); 74 bool IsEnabled() const; 75 76 void MakeFocus(bool inFocus = true); 77 bool IsFocus() const; 78 79 // sets/gets the view to be displayed for this tab 80 virtual void SetView(BView *view); 81 BView *View() const; 82 83 virtual void DrawFocusMark(BView *owner, BRect frame); 84 virtual void DrawLabel(BView *owner, BRect frame); 85 virtual void DrawTab(BView *owner, BRect frame, tab_position position, 86 bool full = true); 87 88 private: 89 virtual void _ReservedTab1(); 90 virtual void _ReservedTab2(); 91 virtual void _ReservedTab3(); 92 virtual void _ReservedTab4(); 93 virtual void _ReservedTab5(); 94 virtual void _ReservedTab6(); 95 virtual void _ReservedTab7(); 96 virtual void _ReservedTab8(); 97 virtual void _ReservedTab9(); 98 virtual void _ReservedTab10(); 99 virtual void _ReservedTab11(); 100 virtual void _ReservedTab12(); 101 102 BTab &operator=(const BTab &); 103 104 bool fEnabled; 105 bool fSelected; 106 bool fFocus; 107 BView *fView; 108 uint32 _reserved[12]; 109 }; 110 //------------------------------------------------------------------------------ 111 112 113 // BTabView class -------------------------------------------------------------- 114 class BTabView : public BView 115 { 116 public: 117 BTabView(BRect frame, const char *name, 118 button_width width = B_WIDTH_AS_USUAL, 119 uint32 resizingMode = B_FOLLOW_ALL, 120 uint32 flags = B_FULL_UPDATE_ON_RESIZE | 121 B_WILL_DRAW | B_NAVIGABLE_JUMP | 122 B_FRAME_EVENTS | B_NAVIGABLE); 123 ~BTabView(); 124 125 BTabView(BMessage *archive); 126 static BArchivable *Instantiate(BMessage *archive); 127 virtual status_t Archive(BMessage*, bool deep=true) const; 128 virtual status_t Perform(perform_code d, void *arg); 129 130 virtual void WindowActivated(bool active); 131 virtual void AttachedToWindow(); 132 virtual void AllAttached(); 133 virtual void AllDetached(); 134 virtual void DetachedFromWindow(); 135 136 virtual void MessageReceived(BMessage *message); 137 virtual void FrameMoved(BPoint newLocation); 138 virtual void FrameResized(float width,float height); 139 virtual void KeyDown(const char *bytes, int32 numBytes); 140 virtual void MouseDown(BPoint point); 141 virtual void MouseUp(BPoint point); 142 virtual void MouseMoved(BPoint point, uint32 transit, 143 const BMessage *message); 144 virtual void Pulse(); 145 146 virtual void Select(int32 tab); 147 int32 Selection() const; 148 149 virtual void MakeFocus(bool focused = true); 150 virtual void SetFocusTab(int32 tab, bool focused); 151 int32 FocusTab() const; 152 153 virtual void Draw(BRect updateRect); 154 virtual BRect DrawTabs(); 155 virtual void DrawBox(BRect selTabRect); 156 virtual BRect TabFrame(int32 tab_index) const; 157 158 virtual void SetFlags(uint32 flags); 159 virtual void SetResizingMode(uint32 mode); 160 161 virtual void GetPreferredSize(float *width, float *height); 162 virtual void ResizeToPreferred(); 163 164 virtual BHandler *ResolveSpecifier(BMessage *message, int32 index, 165 BMessage *specifier, int32 what, const char *property); 166 virtual status_t GetSupportedSuites(BMessage *message); 167 168 virtual void AddTab(BView *target, BTab *tab = NULL); 169 #if !_PR3_COMPATIBLE_ 170 virtual BTab *RemoveTab(int32 tabIndex); 171 #else 172 virtual BTab *RemoveTab(int32 tabIndex) const; 173 #endif 174 175 virtual BTab *TabAt ( int32 tab_index ) const; 176 177 virtual void SetTabWidth(button_width width); 178 button_width TabWidth() const; 179 180 virtual void SetTabHeight(float height); 181 float TabHeight() const; 182 183 BView *ContainerView() const; 184 185 int32 CountTabs() const; 186 BView *ViewForTab(int32 tabIndex) const; 187 188 private: 189 void _InitObject(); 190 191 virtual void _ReservedTabView1(); 192 virtual void _ReservedTabView2(); 193 virtual void _ReservedTabView3(); 194 virtual void _ReservedTabView4(); 195 virtual void _ReservedTabView5(); 196 virtual void _ReservedTabView6(); 197 virtual void _ReservedTabView7(); 198 virtual void _ReservedTabView8(); 199 virtual void _ReservedTabView9(); 200 virtual void _ReservedTabView10(); 201 virtual void _ReservedTabView11(); 202 virtual void _ReservedTabView12(); 203 204 BTabView(const BTabView &); 205 BTabView &operator=(const BTabView &); 206 207 BList *fTabList; 208 BView *fContainerView; 209 button_width fTabWidthSetting; 210 float fTabWidth; 211 float fTabHeight; 212 int32 fSelection; 213 int32 fInitialSelection; 214 int32 fFocus; 215 uint32 _reserved[12]; 216 }; 217 //------------------------------------------------------------------------------ 218 219 #endif // _TAB_VIEW_H 220 221 /* 222 * $Log $ 223 * 224 * $Id $ 225 * 226 */ 227