1/* 2Open Tracker License 3 4Terms and Conditions 5 6Copyright (c) 1991-2000, Be Incorporated. All rights reserved. 7 8Permission is hereby granted, free of charge, to any person obtaining a copy of 9this software and associated documentation files (the "Software"), to deal in 10the Software without restriction, including without limitation the rights to 11use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 12of the Software, and to permit persons to whom the Software is furnished to do 13so, subject to the following conditions: 14 15The above copyright notice and this permission notice applies to all licensees 16and shall be included in all copies or substantial portions of the Software. 17 18THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY, 20FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 22AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION 23WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 25Except as contained in this notice, the name of Be Incorporated shall not be 26used in advertising or otherwise to promote the sale, use or other dealings in 27this Software without prior written authorization from Be Incorporated. 28 29Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks 30of Be Incorporated in the United States and other countries. Other brand product 31names are registered trademarks or trademarks of their respective holders. 32All rights reserved. 33*/ 34#ifndef _POSE_H 35#define _POSE_H 36 37 38#include <Region.h> 39 40#include "TextWidget.h" 41#include "Model.h" 42#include "Utilities.h" 43 44 45namespace BPrivate { 46 47class BPoseView; 48class BTextWidget; 49 50enum { 51 B_NAME_WIDGET, 52 B_ALL_WIDGETS 53}; 54 55 56class BPose { 57public: 58 BPose(Model* adopt, BPoseView*, uint32 clipboardMode, 59 bool selected = false); 60 virtual ~BPose(); 61 62 BTextWidget* AddWidget(BPoseView*, BColumn*); 63 BTextWidget* AddWidget(BPoseView*, BColumn*, 64 ModelNodeLazyOpener &opener); 65 void RemoveWidget(BPoseView*, BColumn*); 66 void SetLocation(BPoint, const BPoseView*); 67 void MoveTo(BPoint, BPoseView*, bool invalidate = true); 68 69 void Draw(BRect poseRect, const BRect& updateRect, BPoseView*, 70 bool fullDraw = true); 71 void Draw(BRect poseRect, const BRect& updateRect, BPoseView*, 72 BView* drawView, bool fullDraw, BPoint offset, bool selected); 73 void DeselectWithoutErasingBackground(BRect rect, 74 BPoseView* poseView); 75 // special purpose draw call for deselecting over a textured 76 // background 77 78 void DrawBar(BPoint where, BView* view, BSize iconSize); 79 80 void DrawIcon(BPoint where, BView* view, BSize size, bool direct, 81 bool drawUnselected = false); 82 void DrawToggleSwitch(BRect, BPoseView*); 83 void MouseUp(BPoint poseLoc, BPoseView*, BPoint where, int32 index); 84 Model* TargetModel() const; 85 Model* ResolvedModel() const; 86 void Select(bool selected); 87 bool IsSelected() const; 88 // Rename to IsHighlighted 89 bigtime_t SelectionTime() const; 90 91 BTextWidget* ActiveWidget() const; 92 BTextWidget* WidgetFor(uint32 hashAttr, int32* index = 0) const; 93 BTextWidget* WidgetFor(BColumn* column, BPoseView* poseView, 94 ModelNodeLazyOpener &opener, int32* index = NULL); 95 // adds the widget if needed 96 97 bool PointInPose(BPoint poseLoc, const BPoseView*, BPoint where, 98 BTextWidget** = NULL) const; 99 bool PointInPose(const BPoseView*, BPoint where) const; 100 BRect CalcRect(BPoint loc, const BPoseView*, 101 bool minimal_rect = false) const; 102 BRect CalcRect(const BPoseView*) const; 103 void UpdateAllWidgets(int32 poseIndex, BPoint poseLoc, BPoseView*); 104 void UpdateWidgetAndModel(Model* resolvedModel, const char* attrName, 105 uint32 attrType, int32 poseIndex, BPoint poseLoc, 106 BPoseView* view, bool visible); 107 bool UpdateVolumeSpaceBar(BVolume* volume); 108 void UpdateIcon(BPoint poseLoc, BPoseView*); 109 110 //void UpdateFixedSymlink(BPoint poseLoc, BPoseView*); 111 void UpdateBrokenSymLink(BPoint poseLoc, BPoseView*); 112 void UpdateWasBrokenSymlink(BPoint poseLoc, BPoseView* poseView); 113 114 void Commit(bool saveChanges, BPoint loc, BPoseView*, int32 index); 115 void EditFirstWidget(BPoint poseLoc, BPoseView*); 116 void EditNextWidget(BPoseView*); 117 void EditPreviousWidget(BPoseView*); 118 119 BPoint Location(const BPoseView* poseView) const; 120 bool DelayedEdit() const; 121 void SetDelayedEdit(bool delay); 122 bool ListModeInited() const; 123 bool HasLocation() const; 124 bool NeedsSaveLocation() const; 125 void SetSaveLocation(); 126 bool WasAutoPlaced() const; 127 void SetAutoPlaced(bool); 128 129 uint32 ClipboardMode() const; 130 void SetClipboardMode(uint32 clipboardMode); 131#if DEBUG 132 void PrintToStream(); 133#endif 134 135private: 136 static bool _PeriodicUpdateCallback(BPose* pose, void* cookie); 137 void EditPreviousNextWidgetCommon(BPoseView* poseView, bool next); 138 void CreateWidgets(BPoseView*); 139 140 BRect _IconRect(const BPoseView* poseView, 141 BPoint location) const; 142 143 Model* fModel; 144 BObjectList<BTextWidget> fWidgetList; 145 BPoint fLocation; 146 147 uint32 fClipboardMode; 148 int32 fPercent; 149 bigtime_t fSelectionTime; 150 151 bool fIsSelected : 1; 152 bool fHasLocation : 1; 153 bool fNeedsSaveLocation : 1; 154 bool fListModeInited : 1; 155 bool fWasAutoPlaced : 1; 156 bool fBrokenSymLink : 1; 157 bool fBackgroundClean : 1; 158}; 159 160 161inline Model* 162BPose::TargetModel() const 163{ 164 return fModel; 165} 166 167 168inline Model* 169BPose::ResolvedModel() const 170{ 171 if (fModel->IsSymLink()) 172 return fModel->LinkTo() != NULL ? fModel->LinkTo() : fModel; 173 else 174 return fModel; 175} 176 177 178inline bool 179BPose::IsSelected() const 180{ 181 return fIsSelected; 182} 183 184 185inline void 186BPose::Select(bool on) 187{ 188 fIsSelected = on; 189 if (on) 190 fSelectionTime = system_time(); 191} 192 193 194inline bigtime_t 195BPose::SelectionTime() const 196{ 197 return fSelectionTime; 198} 199 200 201inline bool 202BPose::NeedsSaveLocation() const 203{ 204 return fNeedsSaveLocation; 205} 206 207 208inline void 209BPose::SetSaveLocation() 210{ 211 fNeedsSaveLocation = true; 212} 213 214 215inline bool 216BPose::ListModeInited() const 217{ 218 return fListModeInited; 219} 220 221 222inline bool 223BPose::WasAutoPlaced() const 224{ 225 return fWasAutoPlaced; 226} 227 228 229inline void 230BPose::SetAutoPlaced(bool on) 231{ 232 fWasAutoPlaced = on; 233} 234 235 236inline bool 237BPose::HasLocation() const 238{ 239 return fHasLocation; 240} 241 242 243inline void 244BPose::Draw(BRect poseRect, const BRect& updateRect, BPoseView* view, 245 bool fullDraw) 246{ 247 Draw(poseRect, updateRect, view, (BView*)view, fullDraw, B_ORIGIN, 248 IsSelected()); 249} 250 251 252inline uint32 253BPose::ClipboardMode() const 254{ 255 return fClipboardMode; 256} 257 258 259inline void 260BPose::SetClipboardMode(uint32 clipboardMode) 261{ 262 fClipboardMode = clipboardMode; 263} 264 265} // namespace BPrivate 266 267using namespace BPrivate; 268 269 270#endif // _POSE_H 271