xref: /haiku/src/kits/tracker/infowindow/HeaderView.h (revision 830f67ef991407f287dbc1238aa5f5906d90c991)
1 /*
2 Open Tracker License
3 
4 Terms and Conditions
5 
6 Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
7 
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:
14 
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.
17 
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.
24 
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.
28 
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.
33 */
34 
35 
36 #ifndef HEADERVIEW_H
37 #define HEADERVIEW_H
38 
39 
40 #include <Bitmap.h>
41 #include <Handler.h>
42 #include <Message.h>
43 #include <MessageFilter.h>
44 #include <Rect.h>
45 #include <TextView.h>
46 #include <View.h>
47 
48 #include "Model.h"
49 
50 
51 class HeaderView: public BView {
52 public:
53 	HeaderView(Model*);
54 	~HeaderView();
55 
56 	void ModelChanged(Model*, BMessage*);
57 	void ReLinkTargetModel(Model*);
58 	void BeginEditingTitle();
59 	void FinishEditingTitle(bool);
60 	virtual void Draw(BRect);
61 	virtual void MakeFocus(bool focus);
62 	virtual void WindowActivated(bool active);
63 
64 	BTextView* TextView() const { return fTitleEditView; }
65 
66 protected:
67 	virtual void MouseDown(BPoint where);
68 	virtual void MouseMoved(BPoint where, uint32, const BMessage* dragMessage);
69 	virtual void MouseUp(BPoint where);
70 	virtual void MessageReceived(BMessage* message);
71 
72 	status_t BuildContextMenu(BMenu* parent);
73 	static filter_result TextViewFilter(BMessage*, BHandler**,
74 		BMessageFilter*);
75 
76 	float CurrentFontHeight();
77 
78 private:
79 	// States for tracking the mouse
80 	enum track_state {
81 		no_track = 0,
82 		icon_track,
83 		open_only_track
84 			// This is for items that can be opened, but can't be
85 			// drag and dropped or renamed (Trash, Desktop Folder...)
86 	};
87 
88 	// Layouting
89 	BRect fTitleRect;
90 	BRect fIconRect;
91 	BPoint fClickPoint;
92 
93 	// Model data
94 	Model* fModel;
95 	Model* fIconModel;
96 	BBitmap* fIcon;
97 	BTextView* fTitleEditView;
98 
99 	// Mouse tracking
100 	track_state fTrackingState;
101 	bool fMouseDown;
102 	bool fIsDropTarget;
103 	bool fDoubleClick;
104 	bool fDragging;
105 
106 	typedef BView _inherited;
107 };
108 
109 
110 #endif /* !HEADERVIEW_H */
111