Assorted whitespace cleanup and typo fixes.
[haiku.git] / src / kits / tracker / TitleView.h
blob959632e098fd562bf7a3f68f06f07a9b366ece41
1 /*
2 Open Tracker License
4 Terms and Conditions
6 Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
8 Permission is hereby granted, free of charge, to any person obtaining a copy of
9 this software and associated documentation files (the "Software"), to deal in
10 the Software without restriction, including without limitation the rights to
11 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
12 of the Software, and to permit persons to whom the Software is furnished to do
13 so, subject to the following conditions:
15 The above copyright notice and this permission notice applies to all licensees
16 and shall be included in all copies or substantial portions of the Software.
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
23 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 Except as contained in this notice, the name of Be Incorporated shall not be
26 used in advertising or otherwise to promote the sale, use or other dealings in
27 this Software without prior written authorization from Be Incorporated.
29 Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
30 of Be Incorporated in the United States and other countries. Other brand product
31 names are registered trademarks or trademarks of their respective holders.
32 All rights reserved.
34 #ifndef _TITLE_VIEW_H
35 #define _TITLE_VIEW_H
38 #include <Cursor.h>
39 #include <DataIO.h>
40 #include <ObjectList.h>
41 #include <View.h>
44 namespace BPrivate {
47 class BPoseView;
48 class BColumn;
49 class BColumnTitle;
50 class ColumnTrackState;
51 class OffscreenBitmap;
53 const int32 kTitleViewHeight = 16;
54 const int32 kEdgeSize = 6;
55 const int32 kTitleColumnLeftExtraMargin = 11;
56 const int32 kTitleColumnRightExtraMargin = 5;
57 const int32 kTitleColumnExtraMargin = kTitleColumnLeftExtraMargin
58 + kTitleColumnRightExtraMargin;
59 const int32 kMinColumnWidth = 20;
60 const int32 kRemoveTitleMargin = 10;
61 const int32 kColumnStart = 40;
64 class BTitleView : public BView {
65 public:
66 BTitleView(BPoseView*);
67 virtual ~BTitleView();
69 virtual void MouseDown(BPoint where);
70 virtual void MouseUp(BPoint where);
71 virtual void Draw(BRect updateRect);
73 void Draw(BRect, bool useOffscreen = false,
74 bool updateOnly = true,
75 const BColumnTitle* pressedColumn = 0,
76 void (*trackRectBlitter)(BView*, BRect) = 0,
77 BRect passThru = BRect(0, 0, 0, 0));
79 void AddTitle(BColumn*, const BColumn* after = 0);
80 void RemoveTitle(BColumn*);
81 void Reset();
83 BPoseView* PoseView() const;
85 protected:
86 void MouseMoved(BPoint, uint32, const BMessage*);
88 private:
89 BColumnTitle* FindColumnTitle(BPoint) const;
90 BColumnTitle* InColumnResizeArea(BPoint) const;
91 BColumnTitle* FindColumnTitle(const BColumn*) const;
93 BPoseView* fPoseView;
94 BObjectList<BColumnTitle> fTitleList;
95 BCursor fHorizontalResizeCursor;
97 BColumnTitle* fPreviouslyClickedColumnTitle;
98 bigtime_t fPreviousLeftClickTime;
99 ColumnTrackState* fTrackingState;
101 static OffscreenBitmap* sOffscreen;
103 typedef BView _inherited;
105 friend class ColumnTrackState;
106 friend class ColumnDragState;
110 class BColumnTitle {
111 public:
112 BColumnTitle(BTitleView*, BColumn*);
113 virtual ~BColumnTitle() {}
115 virtual void Draw(BView*, bool pressed = false);
117 BColumn* Column() const;
118 BRect Bounds() const;
120 bool InColumnResizeArea(BPoint) const;
122 private:
123 BColumn* fColumn;
124 BTitleView* fParent;
126 friend class ColumnResizeState;
130 // Utility classes to handle dragging state
131 class ColumnTrackState {
132 public:
133 ColumnTrackState(BTitleView* titleView, BColumnTitle* columnTitle,
134 BPoint where, bigtime_t pastClickTime);
135 virtual ~ColumnTrackState() {}
137 void MouseMoved(BPoint where, uint32 buttons);
138 void MouseUp(BPoint where);
140 protected:
141 virtual void Moved(BPoint where, uint32 buttons) = 0;
142 virtual void Clicked(BPoint where) = 0;
143 virtual void Done(BPoint where) = 0;
144 virtual bool ValueChanged(BPoint where) = 0;
146 BTitleView* fTitleView;
147 BColumnTitle* fTitle;
148 BPoint fFirstClickPoint;
149 bigtime_t fPastClickTime;
150 bool fHasMoved;
154 class ColumnResizeState : public ColumnTrackState {
155 public:
156 ColumnResizeState(BTitleView* titleView, BColumnTitle* columnTitle,
157 BPoint where, bigtime_t pastClickTime);
159 protected:
160 virtual void Moved(BPoint where, uint32 buttons);
161 virtual void Done(BPoint where);
162 virtual void Clicked(BPoint where);
163 virtual bool ValueChanged(BPoint);
165 void DrawLine();
166 void UndrawLine();
168 private:
169 float fLastLineDrawPos;
170 float fInitialTrackOffset;
172 typedef ColumnTrackState _inherited;
176 class ColumnDragState : public ColumnTrackState {
177 public:
178 ColumnDragState(BTitleView* titleView, BColumnTitle* columnTitle,
179 BPoint where, bigtime_t pastClickTime);
181 protected:
182 virtual void Moved(BPoint where, uint32 buttons);
183 virtual void Done(BPoint where);
184 virtual void Clicked(BPoint where);
185 virtual bool ValueChanged(BPoint);
187 void DrawOutline(float);
188 void UndrawOutline();
189 void DrawPressNoOutline();
191 private:
192 float fInitialMouseTrackOffset;
193 bool fTrackingRemovedColumn;
194 BMallocIO fColumnArchive;
196 typedef ColumnTrackState _inherited;
200 inline BColumn*
201 BColumnTitle::Column() const
203 return fColumn;
207 inline BPoseView*
208 BTitleView::PoseView() const
210 return fPoseView;
214 } // namespace BPrivate
216 using namespace BPrivate;
219 #endif // _TITLE_VIEW_H