RemoteDrawingEngine: Reduce RP_READ_BITMAP result timeout.
[haiku.git] / src / kits / tracker / TitleView.h
blobab65772f67411d6afc993955e45c87cc652d068d
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 kEdgeSize = 6;
54 const int32 kTitleColumnLeftExtraMargin = 11;
55 const int32 kTitleColumnRightExtraMargin = 5;
56 const int32 kTitleColumnExtraMargin = kTitleColumnLeftExtraMargin
57 + kTitleColumnRightExtraMargin;
58 const int32 kMinColumnWidth = 20;
59 const int32 kRemoveTitleMargin = 10;
62 class BTitleView : public BView {
63 public:
64 BTitleView(BPoseView*);
65 virtual ~BTitleView();
67 virtual void MouseDown(BPoint where);
68 virtual void MouseUp(BPoint where);
69 virtual void Draw(BRect updateRect);
71 virtual BSize MinSize();
72 virtual BSize MaxSize();
74 void Draw(BRect, bool useOffscreen = false,
75 bool updateOnly = true,
76 const BColumnTitle* pressedColumn = 0,
77 void (*trackRectBlitter)(BView*, BRect) = 0,
78 BRect passThru = BRect(0, 0, 0, 0));
80 void AddTitle(BColumn*, const BColumn* after = 0);
81 void RemoveTitle(BColumn*);
82 void Reset();
84 BPoseView* PoseView() const;
86 protected:
87 void MouseMoved(BPoint, uint32, const BMessage*);
89 private:
90 BColumnTitle* FindColumnTitle(BPoint) const;
91 BColumnTitle* InColumnResizeArea(BPoint) const;
92 BColumnTitle* FindColumnTitle(const BColumn*) const;
94 private:
95 BPoseView* fPoseView;
96 BObjectList<BColumnTitle> fTitleList;
97 BCursor fHorizontalResizeCursor;
98 float fPreferredHeight;
100 BColumnTitle* fPreviouslyClickedColumnTitle;
101 bigtime_t fPreviousLeftClickTime;
102 ColumnTrackState* fTrackingState;
104 static OffscreenBitmap* sOffscreen;
106 typedef BView _inherited;
108 friend class ColumnTrackState;
109 friend class ColumnDragState;
113 class BColumnTitle {
114 public:
115 BColumnTitle(BTitleView*, BColumn*);
116 virtual ~BColumnTitle() {}
118 virtual void Draw(BView*, bool pressed = false);
120 BColumn* Column() const;
121 BRect Bounds() const;
123 bool InColumnResizeArea(BPoint) const;
125 private:
126 BColumn* fColumn;
127 BTitleView* fParent;
129 friend class ColumnResizeState;
133 // Utility classes to handle dragging state
134 class ColumnTrackState {
135 public:
136 ColumnTrackState(BTitleView* titleView, BColumnTitle* columnTitle,
137 BPoint where, bigtime_t pastClickTime);
138 virtual ~ColumnTrackState() {}
140 void MouseMoved(BPoint where, uint32 buttons);
141 void MouseUp(BPoint where);
143 protected:
144 virtual void Moved(BPoint where, uint32 buttons) = 0;
145 virtual void Clicked(BPoint where) = 0;
146 virtual void Done(BPoint where) = 0;
147 virtual bool ValueChanged(BPoint where) = 0;
149 BTitleView* fTitleView;
150 BColumnTitle* fTitle;
151 BPoint fFirstClickPoint;
152 bigtime_t fPastClickTime;
153 bool fHasMoved;
157 class ColumnResizeState : public ColumnTrackState {
158 public:
159 ColumnResizeState(BTitleView* titleView, BColumnTitle* columnTitle,
160 BPoint where, bigtime_t pastClickTime);
162 protected:
163 virtual void Moved(BPoint where, uint32 buttons);
164 virtual void Done(BPoint where);
165 virtual void Clicked(BPoint where);
166 virtual bool ValueChanged(BPoint);
168 void DrawLine();
169 void UndrawLine();
171 private:
172 float fLastLineDrawPos;
173 float fInitialTrackOffset;
175 typedef ColumnTrackState _inherited;
179 class ColumnDragState : public ColumnTrackState {
180 public:
181 ColumnDragState(BTitleView* titleView, BColumnTitle* columnTitle,
182 BPoint where, bigtime_t pastClickTime);
184 protected:
185 virtual void Moved(BPoint where, uint32 buttons);
186 virtual void Done(BPoint where);
187 virtual void Clicked(BPoint where);
188 virtual bool ValueChanged(BPoint);
190 void DrawOutline(float);
191 void UndrawOutline();
192 void DrawPressNoOutline();
194 private:
195 float fInitialMouseTrackOffset;
196 bool fTrackingRemovedColumn;
197 BMallocIO fColumnArchive;
199 typedef ColumnTrackState _inherited;
203 inline BColumn*
204 BColumnTitle::Column() const
206 return fColumn;
210 inline BPoseView*
211 BTitleView::PoseView() const
213 return fPoseView;
217 } // namespace BPrivate
219 using namespace BPrivate;
222 #endif // _TITLE_VIEW_H