xref: /haiku/src/kits/tracker/Navigator.h (revision 778611c7e6a61b8ba072212756ce53eda826360a)
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 #ifndef _NAVIGATOR_H
35 #define _NAVIGATOR_H
36 
37 
38 #include <PictureButton.h>
39 #include <View.h>
40 
41 #include "ContainerWindow.h"
42 #include "Model.h"
43 
44 
45 class BTextControl;
46 class BEntry;
47 
48 namespace BPrivate {
49 
50 enum NavigationAction
51 {
52 	kActionSet,
53 	kActionForward,
54 	kActionBackward,
55 	kActionUp,
56 	kActionLocation,
57 	kActionUpdatePath,
58 
59 	kNavigatorCommandBackward = 'NVBW',
60 	kNavigatorCommandForward = 'NVFW',
61 	kNavigatorCommandUp = 'NVUP',
62 	kNavigatorCommandLocation = 'NVLC',
63 	kNavigatorCommandSetFocus = 'NVSF'
64 };
65 
66 
67 // Custom BPictureButton which takes
68 // bitmap resource IDs as arguments
69 class BNavigatorButton : public BPictureButton {
70 public:
71 	BNavigatorButton(BRect rect, const char* name, BMessage* message,
72 		int32 resIDon, int32 resIDoff, int32 resIDdisabled);
73 
74 	~BNavigatorButton();
75 
76 	virtual void AttachedToWindow();
77 
78 	void SetPicture(BBitmap*, bool enabled, bool on);
79 
80 private:
81 	int32 fResIDOn;
82 	int32 fResIDOff;
83 	int32 fResIDDisabled;
84 };
85 
86 
87 class BNavigator : public BView {
88 public:
89 	BNavigator(const Model* model, BRect rect,
90 		uint32 resizeMask = B_FOLLOW_LEFT_RIGHT);
91 	~BNavigator();
92 
93 	void UpdateLocation(const Model* newmodel, int32 action);
94 
95 	static float CalcNavigatorHeight(void);
96 
97 	BContainerWindow* Window() const;
98 
99 protected:
100 	virtual void Draw(BRect rect);
101 	virtual void MessageReceived(BMessage* msg);
102 	virtual void AttachedToWindow();
103 	virtual void AllAttached();
104 
105 	void GoForward(bool option);
106 		// is option key held down?
107 	void GoBackward(bool option);
108 	void GoUp(bool option);
109 	void SendNavigationMessage(NavigationAction, BEntry*, bool option);
110 
111 	void GoTo();
112 
113 private:
114 	BPath fPath;
115 	BNavigatorButton* fBack;
116 	BNavigatorButton* fForw;
117 	BNavigatorButton* fUp;
118 	BTextControl* fLocation;
119 
120 	BObjectList<BPath> fBackHistory;
121 	BObjectList<BPath> fForwHistory;
122 
123 	typedef BView _inherited;
124 };
125 
126 
127 inline
128 BContainerWindow*
129 BNavigator::Window() const
130 {
131 	return dynamic_cast<BContainerWindow*>(_inherited::Window());
132 }
133 
134 
135 } // namespace BPrivate
136 
137 using namespace BPrivate;
138 
139 
140 #endif	// _NAVIGATOR_H
141