libroot/posix/stdio: Remove unused portions.
[haiku.git] / src / apps / deskbar / StatusView.h
blob14f06e5665582a59bbd1821dcea9c7396b3af0f5
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
30 trademarks of Be Incorporated in the United States and other countries. Other
31 brand product names are registered trademarks or trademarks of their respective
32 holders.
33 All rights reserved.
35 #ifndef __STATUS_VIEW__
36 #define __STATUS_VIEW__
39 #include <Control.h>
40 #include <Node.h>
41 #include <Query.h>
42 #include <Shelf.h>
43 #include <View.h>
45 #include "BarView.h"
46 #include "TimeView.h"
49 const float kDragWidth = 4.0f;
50 const float kMaxReplicantHeight = 16.0f;
51 const float kMaxReplicantWidth = 16.0f;
52 const int32 kMinimumReplicantCount = 6;
53 const int32 kIconGap = 2;
54 const int32 kGutter = 1;
55 const int32 kDragRegionWidth = 6;
56 const int32 kTrayPadding = 3;
57 const int32 kClockMargin = 12;
59 // 1 pixel for left gutter
60 // space for replicant tray (6 items)
61 // 6 pixel drag region
62 const float kMinimumTrayWidth = kIconGap + kMaxReplicantWidth
63 + (kMinimumReplicantCount * kIconGap)
64 + (kMinimumReplicantCount * kMaxReplicantWidth) + kGutter;
65 const float kMinimumTrayHeight = kGutter + kMaxReplicantHeight + kGutter;
67 extern float gMinimumWindowWidth;
68 extern float gMaximumWindowWidth;
70 #ifdef DB_ADDONS
71 struct DeskbarItemInfo {
72 bool isAddOn; // attribute tagged item
73 int32 id; // id given to replicant
74 entry_ref entryRef; // entry_ref to item tagged
75 node_ref nodeRef; // node_ref to boot vol item
77 #endif
79 class TReplicantShelf;
81 class TReplicantTray : public BView {
82 public:
83 TReplicantTray(TBarView* barView,
84 bool vertical);
85 virtual ~TReplicantTray();
87 virtual void AttachedToWindow();
88 virtual void DetachedFromWindow();
89 virtual void MouseDown(BPoint point);
90 virtual void MessageReceived(BMessage*);
91 virtual void GetPreferredSize(float*, float*);
93 void AdjustPlacement();
94 void ShowReplicantMenu(BPoint);
96 void SetMultiRow(bool state);
97 bool IsMultiRow() const
98 { return fMultiRowMode; }
100 TTimeView* Time() const { return fTime; }
101 void ShowHideTime();
103 status_t ItemInfo(int32 target, const char** name);
104 status_t ItemInfo(const char* name, int32* id);
105 status_t ItemInfo(int32 index, const char** name,
106 int32* id);
108 bool IconExists(int32 target, bool byIndex = false);
109 bool IconExists(const char* name);
111 int32 ReplicantCount() const;
113 status_t AddIcon(BMessage*, int32* id,
114 const entry_ref* = NULL);
116 void RemoveIcon(int32 target,
117 bool byIndex = false);
118 void RemoveIcon(const char* name);
120 BRect IconFrame(int32 target,
121 bool byIndex = false);
122 BRect IconFrame(const char* name);
124 bool AcceptAddon(BRect frame,
125 BMessage* message);
126 void RealignReplicants(int32 startIndex = -1);
128 void SaveTimeSettings();
130 #ifdef DB_ADDONS
131 status_t LoadAddOn(BEntry* entry, int32* id,
132 bool addToSettings = true);
133 #endif
135 private:
136 BView* ViewAt(int32* index, int32* id,
137 int32 target,
138 bool byIndex = false);
139 BView* ViewAt(int32* index, int32* id,
140 const char* name);
142 void RealReplicantAdjustment(int32 startindex);
144 #ifdef DB_ADDONS
145 void InitAddOnSupport();
146 void DeleteAddOnSupport();
148 DeskbarItemInfo* DeskbarItemFor(node_ref &nodeRef);
149 DeskbarItemInfo* DeskbarItemFor(int32 id);
150 bool NodeExists(node_ref &nodeRef);
152 void HandleEntryUpdate(BMessage*);
153 status_t AddItem(int32 id, node_ref nodeRef,
154 BEntry &entry, bool isAddon);
156 void UnloadAddOn(node_ref*, dev_t*, bool which,
157 bool removeAll);
158 void RemoveItem(int32 id);
160 void MoveItem(entry_ref*, ino_t toDirectory);
161 #endif
163 BPoint LocationForReplicant(int32 index,
164 float replicantWidth);
165 BShelf* Shelf() const;
167 status_t _SaveSettings();
169 friend class TReplicantShelf;
171 TTimeView* fTime;
172 TBarView* fBarView;
173 TReplicantShelf* fShelf;
174 BRect fRightBottomReplicant;
175 int32 fLastReplicant;
177 bool fMultiRowMode;
178 float fMinimumTrayWidth;
180 bool fAlignmentSupport;
181 #ifdef DB_ADDONS
182 BList* fItemList;
183 BMessage fAddOnSettings;
184 #endif
188 enum {
189 kNoDragRegion,
190 kDontDrawDragRegion,
191 kAutoPlaceDragRegion,
192 kDragRegionLeft,
193 kDragRegionRight,
194 kDragRegionTop,
195 kDragRegionBottom
198 class TDragRegion : public BControl {
199 public:
200 TDragRegion(TBarView* barView, BView* replicantTray);
202 virtual void AttachedToWindow();
203 virtual void GetPreferredSize(float*, float*);
204 virtual void Draw(BRect);
205 virtual void MouseDown(BPoint);
206 virtual void MouseUp(BPoint);
207 virtual void MouseMoved(BPoint, uint32, const BMessage*);
209 void DrawDragRegion();
210 BRect DragRegion() const;
212 bool SwitchModeForRect(BPoint mouse, BRect rect,
213 bool newVertical, bool newLeft, bool newTop, int32 newState);
215 int32 DragRegionLocation() const;
216 void SetDragRegionLocation(int32);
218 bool IsDragging() { return IsTracking(); };
220 private:
221 TBarView* fBarView;
222 BView* fReplicantTray;
223 BPoint fPreviousPosition;
224 int32 fDragLocation;
227 class TResizeControl : public BControl {
228 public:
229 TResizeControl(TBarView* barView);
230 virtual ~TResizeControl();
232 virtual void AttachedToWindow();
233 virtual void Draw(BRect);
234 virtual void MouseDown(BPoint);
235 virtual void MouseUp(BPoint);
236 virtual void MouseMoved(BPoint, uint32, const BMessage*);
238 bool IsResizing() { return IsTracking(); };
240 private:
241 TBarView* fBarView;
245 #endif /* __STATUS_VIEW__ */