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 |
|
---|
34 | #include <BeBuild.h>
|
---|
35 | #include <Invoker.h>
|
---|
36 | #include <View.h>
|
---|
37 |
|
---|
38 |
|
---|
39 | enum tab_position {
|
---|
40 | B_TAB_FIRST = 999,
|
---|
41 | B_TAB_FRONT,
|
---|
42 | B_TAB_ANY
|
---|
43 | };
|
---|
44 |
|
---|
45 |
|
---|
46 | // BTab class ------------------------------------------------------------------
|
---|
47 | class BTab : public BArchivable {
|
---|
48 |
|
---|
49 | public:
|
---|
50 | BTab(BView * tabView = NULL);
|
---|
51 | virtual ~BTab();
|
---|
52 |
|
---|
53 | BTab(BMessage *archive);
|
---|
54 | static BArchivable *Instantiate(BMessage *archive);
|
---|
55 |
|
---|
56 | virtual status_t Archive(BMessage *archive, bool deep = true) const;
|
---|
57 | virtual status_t Perform(uint32 d, void *arg);
|
---|
58 |
|
---|
59 | const char *Label() const;
|
---|
60 | virtual void SetLabel(const char *label);
|
---|
61 |
|
---|
62 | bool IsSelected() const;
|
---|
63 | virtual void Select(BView *owner);
|
---|
64 | virtual void Deselect();
|
---|
65 |
|
---|
66 | virtual void SetEnabled(bool enabled);
|
---|
67 | bool IsEnabled() const;
|
---|
68 |
|
---|
69 | void MakeFocus(bool inFocus = true);
|
---|
70 | bool IsFocus() const;
|
---|
71 |
|
---|
72 | // sets/gets the view to be displayed for this tab
|
---|
73 | virtual void SetView(BView *view);
|
---|
74 | BView *View() const;
|
---|
75 |
|
---|
76 | virtual void DrawFocusMark(BView *owner, BRect frame);
|
---|
77 | virtual void DrawLabel(BView *owner, BRect frame);
|
---|
78 | virtual void DrawTab(BView *owner, BRect frame, tab_position position,
|
---|
79 | bool full = true);
|
---|
80 |
|
---|
81 | private:
|
---|
82 | virtual void _ReservedTab1();
|
---|
83 | virtual void _ReservedTab2();
|
---|
84 | virtual void _ReservedTab3();
|
---|
85 | virtual void _ReservedTab4();
|
---|
86 | virtual void _ReservedTab5();
|
---|
87 | virtual void _ReservedTab6();
|
---|
88 | virtual void _ReservedTab7();
|
---|
89 | virtual void _ReservedTab8();
|
---|
90 | virtual void _ReservedTab9();
|
---|
91 | virtual void _ReservedTab10();
|
---|
92 | virtual void _ReservedTab11();
|
---|
93 | virtual void _ReservedTab12();
|
---|
94 |
|
---|
95 | BTab &operator=(const BTab &);
|
---|
96 |
|
---|
97 | bool fEnabled;
|
---|
98 | bool fSelected;
|
---|
99 | bool fFocus;
|
---|
100 | BView *fView;
|
---|
101 | uint32 _reserved[12];
|
---|
102 | };
|
---|
103 | //------------------------------------------------------------------------------
|
---|
104 |
|
---|
105 |
|
---|
106 | // BTabView class --------------------------------------------------------------
|
---|
107 | class BTabView : public BView, public BInvoker
|
---|
108 | {
|
---|
109 | public:
|
---|
110 | BTabView(BRect frame, const char *name,
|
---|
111 | button_width width = B_WIDTH_AS_USUAL,
|
---|
112 | uint32 resizingMode = B_FOLLOW_ALL,
|
---|
113 | uint32 flags = B_FULL_UPDATE_ON_RESIZE |
|
---|
114 | B_WILL_DRAW | B_NAVIGABLE_JUMP |
|
---|
115 | B_FRAME_EVENTS | B_NAVIGABLE);
|
---|
116 | ~BTabView();
|
---|
117 |
|
---|
118 | BTabView(BMessage *archive);
|
---|
119 | static BArchivable *Instantiate(BMessage *archive);
|
---|
120 | virtual status_t Archive(BMessage*, bool deep=true) const;
|
---|
121 | virtual status_t Perform(perform_code d, void *arg);
|
---|
122 |
|
---|
123 | virtual void WindowActivated(bool active);
|
---|
124 | virtual void AttachedToWindow();
|
---|
125 | virtual void AllAttached();
|
---|
126 | virtual void AllDetached();
|
---|
127 | virtual void DetachedFromWindow();
|
---|
128 |
|
---|
129 | virtual void MessageReceived(BMessage *message);
|
---|
130 | virtual void FrameMoved(BPoint newLocation);
|
---|
131 | virtual void FrameResized(float width,float height);
|
---|
132 | virtual void KeyDown(const char *bytes, int32 numBytes);
|
---|
133 | virtual void MouseDown(BPoint point);
|
---|
134 | virtual void MouseUp(BPoint point);
|
---|
135 | virtual void MouseMoved(BPoint point, uint32 transit,
|
---|
136 | const BMessage *message);
|
---|
137 | virtual void Pulse();
|
---|
138 |
|
---|
139 | virtual void Select(int32 tab);
|
---|
140 | int32 Selection() const;
|
---|
141 |
|
---|
142 | virtual void MakeFocus(bool focused = true);
|
---|
143 | virtual void SetFocusTab(int32 tab, bool focused);
|
---|
144 | int32 FocusTab() const;
|
---|
145 |
|
---|
146 | virtual void Draw(BRect updateRect);
|
---|
147 | virtual BRect DrawTabs();
|
---|
148 | virtual void DrawBox(BRect selTabRect);
|
---|
149 | virtual BRect TabFrame(int32 tab_index) const;
|
---|
150 |
|
---|
151 | virtual void SetFlags(uint32 flags);
|
---|
152 | virtual void SetResizingMode(uint32 mode);
|
---|
153 |
|
---|
154 | virtual void GetPreferredSize(float *width, float *height);
|
---|
155 | virtual void ResizeToPreferred();
|
---|
156 |
|
---|
157 | virtual BHandler *ResolveSpecifier(BMessage *message, int32 index,
|
---|
158 | BMessage *specifier, int32 what, const char *property);
|
---|
159 | virtual status_t GetSupportedSuites(BMessage *message);
|
---|
160 |
|
---|
161 | virtual void AddTab(BView *target, BTab *tab = NULL);
|
---|
162 | virtual BTab *RemoveTab(int32 tabIndex);
|
---|
163 |
|
---|
164 | virtual BTab *TabAt ( int32 tab_index ) const;
|
---|
165 |
|
---|
166 | virtual void SetTabWidth(button_width width);
|
---|
167 | button_width TabWidth() const;
|
---|
168 |
|
---|
169 | virtual void SetTabHeight(float height);
|
---|
170 | float TabHeight() const;
|
---|
171 |
|
---|
172 | BView *ContainerView() const;
|
---|
173 |
|
---|
174 | int32 CountTabs() const;
|
---|
175 | BView *ViewForTab(int32 tabIndex) const;
|
---|
176 |
|
---|
177 | virtual void SetSelectionMessage(BMessage* message);
|
---|
178 |
|
---|
179 | BMessage* SelectionMessage() const;
|
---|
180 | uint32 SelectionCommand() const;
|
---|
181 |
|
---|
182 | virtual void SelectionChanged();
|
---|
183 |
|
---|
184 | private:
|
---|
185 | void _InitObject();
|
---|
186 |
|
---|
187 | virtual void _ReservedTabView3();
|
---|
188 | virtual void _ReservedTabView4();
|
---|
189 | virtual void _ReservedTabView5();
|
---|
190 | virtual void _ReservedTabView6();
|
---|
191 | virtual void _ReservedTabView7();
|
---|
192 | virtual void _ReservedTabView8();
|
---|
193 | virtual void _ReservedTabView9();
|
---|
194 | virtual void _ReservedTabView10();
|
---|
195 | virtual void _ReservedTabView11();
|
---|
196 | virtual void _ReservedTabView12();
|
---|
197 |
|
---|
198 | BTabView(const BTabView &);
|
---|
199 | BTabView &operator=(const BTabView &);
|
---|
200 |
|
---|
201 | BList *fTabList;
|
---|
202 | BView *fContainerView;
|
---|
203 | button_width fTabWidthSetting;
|
---|
204 | float fTabWidth;
|
---|
205 | float fTabHeight;
|
---|
206 | int32 fSelection;
|
---|
207 | int32 fInitialSelection;
|
---|
208 | int32 fFocus;
|
---|
209 | float fTabOffset;
|
---|
210 | uint32 _reserved[11];
|
---|
211 | };
|
---|
212 |
|
---|
213 | #endif // _TAB_VIEW_H
|
---|