DHCP initial timeout 0.25s from 4s
[haiku.git] / src / apps / deskbar / StatusView.h
blob8a7e88dad3fb2563bb4f3a71f30eac99537b0797
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 kMaxReplicantHeight = 16.0f;
50 const float kMaxReplicantWidth = 16.0f;
51 const int32 kMinimumReplicantCount = 6;
52 const int32 kIconGap = 2;
53 const int32 kGutter = 1;
54 const int32 kDragRegionWidth = 6;
56 // 1 pixel for left gutter
57 // space for replicant tray (6 items)
58 // 6 pixel drag region
59 const float kMinimumTrayWidth = kIconGap
60 + (kMinimumReplicantCount * kIconGap)
61 + (kMinimumReplicantCount * kMaxReplicantWidth) + kGutter;
62 const float kMinimumTrayHeight = kGutter + kMaxReplicantHeight + kGutter;
64 extern float gMinimumWindowWidth;
66 #ifdef DB_ADDONS
67 struct DeskbarItemInfo {
68 bool isAddOn; // attribute tagged item
69 int32 id; // id given to replicant
70 entry_ref entryRef; // entry_ref to item tagged
71 node_ref nodeRef; // node_ref to boot vol item
73 #endif
75 class TReplicantShelf;
77 class TReplicantTray : public BView {
78 public:
79 TReplicantTray(TBarView* barView,
80 bool vertical);
81 virtual ~TReplicantTray();
83 virtual void AttachedToWindow();
84 virtual void DetachedFromWindow();
85 virtual void MouseDown(BPoint point);
86 virtual void MessageReceived(BMessage*);
87 virtual void GetPreferredSize(float*, float*);
89 void AdjustPlacement();
90 void ShowReplicantMenu(BPoint);
92 void SetMultiRow(bool state);
93 bool IsMultiRow() const
94 { return fMultiRowMode; }
96 TTimeView* Time() const { return fTime; }
97 void ShowHideTime();
99 status_t ItemInfo(int32 target, const char** name);
100 status_t ItemInfo(const char* name, int32* id);
101 status_t ItemInfo(int32 index, const char** name,
102 int32* id);
104 bool IconExists(int32 target, bool byIndex = false);
105 bool IconExists(const char* name);
107 int32 IconCount() const;
109 status_t AddIcon(BMessage*, int32* id,
110 const entry_ref* = NULL);
112 void RemoveIcon(int32 target,
113 bool byIndex = false);
114 void RemoveIcon(const char* name);
116 BRect IconFrame(int32 target,
117 bool byIndex = false);
118 BRect IconFrame(const char* name);
120 bool AcceptAddon(BRect frame,
121 BMessage* message);
122 void RealignReplicants(int32 startIndex = -1);
124 void SaveTimeSettings();
126 #ifdef DB_ADDONS
127 status_t LoadAddOn(BEntry* entry, int32* id,
128 bool addToSettings = true);
129 #endif
131 private:
132 BView* ViewAt(int32* index, int32* id,
133 int32 target,
134 bool byIndex = false);
135 BView* ViewAt(int32* index, int32* id,
136 const char* name);
138 void RealReplicantAdjustment(int32 startindex);
140 #ifdef DB_ADDONS
141 void InitAddOnSupport();
142 void DeleteAddOnSupport();
144 DeskbarItemInfo* DeskbarItemFor(node_ref &nodeRef);
145 DeskbarItemInfo* DeskbarItemFor(int32 id);
146 bool NodeExists(node_ref &nodeRef);
148 void HandleEntryUpdate(BMessage*);
149 status_t AddItem(int32 id, node_ref nodeRef,
150 BEntry &entry, bool isAddon);
152 void UnloadAddOn(node_ref*, dev_t*, bool which,
153 bool removeAll);
154 void RemoveItem(int32 id);
156 void MoveItem(entry_ref*, ino_t toDirectory);
157 #endif
159 BPoint LocationForReplicant(int32 index,
160 float width);
161 BShelf* Shelf() const;
163 status_t _SaveSettings();
165 friend class TReplicantShelf;
167 TTimeView* fTime;
168 TBarView* fBarView;
169 TReplicantShelf* fShelf;
170 BRect fRightBottomReplicant;
171 int32 fLastReplicant;
173 bool fMultiRowMode;
174 float fMinimumTrayWidth;
176 bool fAlignmentSupport;
177 #ifdef DB_ADDONS
178 BList* fItemList;
179 BMessage fAddOnSettings;
180 #endif
184 enum {
185 kNoDragRegion,
186 kDontDrawDragRegion,
187 kAutoPlaceDragRegion,
188 kDragRegionLeft,
189 kDragRegionRight,
190 kDragRegionTop,
191 kDragRegionBottom
194 class TDragRegion : public BControl {
195 public:
196 TDragRegion(TBarView*, BView*);
198 virtual void AttachedToWindow();
199 virtual void GetPreferredSize(float*, float*);
200 virtual void Draw(BRect);
201 virtual void FrameMoved(BPoint);
202 virtual void MouseDown(BPoint );
203 virtual void MouseUp(BPoint );
204 virtual void MouseMoved(BPoint , uint32 , const BMessage*);
206 void DrawDragRegion();
207 BRect DragRegion() const;
209 bool SwitchModeForRect(BPoint mouse, BRect rect,
210 bool newVertical, bool newLeft, bool newTop, int32 newState);
212 int32 DragRegionLocation() const;
213 void SetDragRegionLocation(int32);
215 bool IsDragging() {return IsTracking();}
217 private:
218 TBarView* fBarView;
219 BView* fChild;
220 BPoint fPreviousPosition;
221 int32 fDragLocation;
225 #endif /* __STATUS_VIEW__ */