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.
40 #include <ObjectList.h>
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
{
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
*);
84 BPoseView
* PoseView() const;
87 void MouseMoved(BPoint
, uint32
, const BMessage
*);
90 BColumnTitle
* FindColumnTitle(BPoint
) const;
91 BColumnTitle
* InColumnResizeArea(BPoint
) const;
92 BColumnTitle
* FindColumnTitle(const BColumn
*) const;
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
;
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;
129 friend class ColumnResizeState
;
133 // Utility classes to handle dragging state
134 class ColumnTrackState
{
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
);
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
;
157 class ColumnResizeState
: public ColumnTrackState
{
159 ColumnResizeState(BTitleView
* titleView
, BColumnTitle
* columnTitle
,
160 BPoint where
, bigtime_t pastClickTime
);
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
);
172 float fLastLineDrawPos
;
173 float fInitialTrackOffset
;
175 typedef ColumnTrackState _inherited
;
179 class ColumnDragState
: public ColumnTrackState
{
181 ColumnDragState(BTitleView
* titleView
, BColumnTitle
* columnTitle
,
182 BPoint where
, bigtime_t pastClickTime
);
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();
195 float fInitialMouseTrackOffset
;
196 bool fTrackingRemovedColumn
;
197 BMallocIO fColumnArchive
;
199 typedef ColumnTrackState _inherited
;
204 BColumnTitle::Column() const
211 BTitleView::PoseView() const
217 } // namespace BPrivate
219 using namespace BPrivate
;
222 #endif // _TITLE_VIEW_H