Ticket #2198: TabView.h.Invoker

File TabView.h.Invoker, 6.5 KB (added by shinta, 16 years ago)

These 2 files are prototype. These are lacking of at least Notify() overriding.

Line 
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
39enum tab_position {
40 B_TAB_FIRST = 999,
41 B_TAB_FRONT,
42 B_TAB_ANY
43};
44
45
46// BTab class ------------------------------------------------------------------
47class BTab : public BArchivable {
48
49public:
50 BTab(BView * tabView = NULL);
51 virtual ~BTab();
52
53 BTab(BMessage *archive);
54static BArchivable *Instantiate(BMessage *archive);
55
56virtual status_t Archive(BMessage *archive, bool deep = true) const;
57virtual status_t Perform(uint32 d, void *arg);
58
59 const char *Label() const;
60virtual void SetLabel(const char *label);
61
62 bool IsSelected() const;
63virtual void Select(BView *owner);
64virtual void Deselect();
65
66virtual 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
73virtual void SetView(BView *view);
74 BView *View() const;
75
76virtual void DrawFocusMark(BView *owner, BRect frame);
77virtual void DrawLabel(BView *owner, BRect frame);
78virtual void DrawTab(BView *owner, BRect frame, tab_position position,
79 bool full = true);
80
81private:
82virtual void _ReservedTab1();
83virtual void _ReservedTab2();
84virtual void _ReservedTab3();
85virtual void _ReservedTab4();
86virtual void _ReservedTab5();
87virtual void _ReservedTab6();
88virtual void _ReservedTab7();
89virtual void _ReservedTab8();
90virtual void _ReservedTab9();
91virtual void _ReservedTab10();
92virtual void _ReservedTab11();
93virtual 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 --------------------------------------------------------------
107class BTabView : public BView, public BInvoker
108{
109public:
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);
119static BArchivable *Instantiate(BMessage *archive);
120virtual status_t Archive(BMessage*, bool deep=true) const;
121virtual status_t Perform(perform_code d, void *arg);
122
123virtual void WindowActivated(bool active);
124virtual void AttachedToWindow();
125virtual void AllAttached();
126virtual void AllDetached();
127virtual void DetachedFromWindow();
128
129virtual void MessageReceived(BMessage *message);
130virtual void FrameMoved(BPoint newLocation);
131virtual void FrameResized(float width,float height);
132virtual void KeyDown(const char *bytes, int32 numBytes);
133virtual void MouseDown(BPoint point);
134virtual void MouseUp(BPoint point);
135virtual void MouseMoved(BPoint point, uint32 transit,
136 const BMessage *message);
137virtual void Pulse();
138
139virtual void Select(int32 tab);
140 int32 Selection() const;
141
142virtual void MakeFocus(bool focused = true);
143virtual void SetFocusTab(int32 tab, bool focused);
144 int32 FocusTab() const;
145
146virtual void Draw(BRect updateRect);
147virtual BRect DrawTabs();
148virtual void DrawBox(BRect selTabRect);
149virtual BRect TabFrame(int32 tab_index) const;
150
151virtual void SetFlags(uint32 flags);
152virtual void SetResizingMode(uint32 mode);
153
154virtual void GetPreferredSize(float *width, float *height);
155virtual void ResizeToPreferred();
156
157virtual BHandler *ResolveSpecifier(BMessage *message, int32 index,
158 BMessage *specifier, int32 what, const char *property);
159virtual status_t GetSupportedSuites(BMessage *message);
160
161virtual void AddTab(BView *target, BTab *tab = NULL);
162virtual BTab *RemoveTab(int32 tabIndex);
163
164virtual BTab *TabAt ( int32 tab_index ) const;
165
166virtual void SetTabWidth(button_width width);
167 button_width TabWidth() const;
168
169virtual 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
184private:
185 void _InitObject();
186
187virtual void _ReservedTabView3();
188virtual void _ReservedTabView4();
189virtual void _ReservedTabView5();
190virtual void _ReservedTabView6();
191virtual void _ReservedTabView7();
192virtual void _ReservedTabView8();
193virtual void _ReservedTabView9();
194virtual void _ReservedTabView10();
195virtual void _ReservedTabView11();
196virtual 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