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 #ifndef _POSE_H 36 #define _POSE_H 37 38 #include <Region.h> 39 40 #include "TextWidget.h" 41 #include "Model.h" 42 #include "Utilities.h" 43 44 namespace BPrivate { 45 46 class BPoseView; 47 class BTextWidget; 48 49 enum { 50 B_NAME_WIDGET, 51 B_ALL_WIDGETS 52 }; 53 54 55 class BPose { 56 public: 57 BPose(Model *adopt, BPoseView *, uint32 clipboardMode, bool selected = false); 58 virtual ~BPose(); 59 60 BTextWidget *AddWidget(BPoseView *, BColumn *); 61 BTextWidget *AddWidget(BPoseView *, BColumn *, ModelNodeLazyOpener &opener); 62 void RemoveWidget(BPoseView *, BColumn *); 63 void SetLocation(BPoint, const BPoseView *); 64 void MoveTo(BPoint, BPoseView *, bool inval = true); 65 66 void Draw(BRect poseRect, const BRect& updateRect, BPoseView *, 67 bool fullDraw = true); 68 void Draw(BRect poseRect, const BRect& updateRect, BPoseView *, 69 BView *drawView, bool fullDraw, BPoint offset, bool selected); 70 void DeselectWithoutErasingBackground(BRect rect, BPoseView *poseView); 71 // special purpose draw call for deselecting over a textured 72 // background 73 74 void DrawBar(BPoint where,BView *view,icon_size kind); 75 76 void DrawIcon(BPoint, BView *, icon_size, bool direct, bool drawUnselected = false); 77 void DrawToggleSwitch(BRect, BPoseView *); 78 void MouseUp(BPoint poseLoc, BPoseView *, BPoint where, int32 index); 79 Model* TargetModel() const; 80 Model* ResolvedModel() const; 81 void Select(bool selected); 82 bool IsSelected() const; 83 // Rename to IsHighlighted 84 bigtime_t SelectionTime() const; 85 86 BTextWidget *ActiveWidget() const; 87 BTextWidget *WidgetFor(uint32 hashAttr, int32 *index = 0) const; 88 BTextWidget *WidgetFor(BColumn *column, BPoseView *poseView, ModelNodeLazyOpener &opener, 89 int32 *index = NULL); 90 // adds the widget if needed 91 92 bool PointInPose(BPoint poseLoc, const BPoseView *, BPoint where, 93 BTextWidget ** = NULL) const; 94 bool PointInPose(const BPoseView *, BPoint where) const ; 95 BRect CalcRect(BPoint loc, const BPoseView *, 96 bool minimal_rect = false) const; 97 BRect CalcRect(const BPoseView *) const; 98 void UpdateAllWidgets(int32 poseIndex, BPoint poseLoc, BPoseView *); 99 void UpdateWidgetAndModel(Model *resolvedModel, const char *attrName, 100 uint32 attrType, int32 poseIndex, BPoint poseLoc, 101 BPoseView *view, bool visible); 102 bool UpdateVolumeSpaceBar(BVolume *volume); 103 void UpdateIcon(BPoint poseLoc, BPoseView *); 104 105 //void UpdateFixedSymlink(BPoint poseLoc, BPoseView *); 106 void UpdateBrokenSymLink(BPoint poseLoc, BPoseView *); 107 void UpdateWasBrokenSymlink(BPoint poseLoc, BPoseView *poseView); 108 109 void Commit(bool saveChanges, BPoint loc, BPoseView *, int32 index); 110 void EditFirstWidget(BPoint poseLoc, BPoseView *); 111 void EditNextWidget(BPoseView *); 112 void EditPreviousWidget(BPoseView *); 113 114 BPoint Location(const BPoseView *poseView) const; 115 bool DelayedEdit() const; 116 void SetDelayedEdit(bool delay); 117 bool ListModeInited() const; 118 bool HasLocation() const; 119 bool NeedsSaveLocation() const; 120 void SetSaveLocation(); 121 bool WasAutoPlaced() const; 122 void SetAutoPlaced(bool); 123 124 uint32 ClipboardMode() const; 125 void SetClipboardMode(uint32 clipboardMode); 126 127 #if DEBUG 128 void PrintToStream(); 129 #endif 130 131 private: 132 static bool _PeriodicUpdateCallback(BPose *pose, void *cookie); 133 void EditPreviousNextWidgetCommon(BPoseView *poseView, bool next); 134 void CreateWidgets(BPoseView *); 135 bool TestLargeIconPixel(BPoint) const; 136 137 Model *fModel; 138 BObjectList<BTextWidget> fWidgetList; 139 BPoint fLocation; 140 141 uint32 fClipboardMode; 142 int32 fPercent; 143 bigtime_t fSelectionTime; 144 145 bool fIsSelected : 1; 146 bool fHasLocation : 1; 147 bool fNeedsSaveLocation : 1; 148 bool fListModeInited : 1; 149 bool fWasAutoPlaced : 1; 150 bool fBrokenSymLink : 1; 151 bool fBackgroundClean : 1; 152 }; 153 154 155 inline Model * 156 BPose::TargetModel() const 157 { 158 return fModel; 159 } 160 161 162 inline Model * 163 BPose::ResolvedModel() const 164 { 165 return fModel->IsSymLink() ? 166 (fModel->LinkTo() ? fModel->LinkTo() : fModel) : fModel; 167 } 168 169 170 inline bool 171 BPose::IsSelected() const 172 { 173 return fIsSelected; 174 } 175 176 177 inline void 178 BPose::Select(bool on) 179 { 180 fIsSelected = on; 181 if (on) 182 fSelectionTime = system_time(); 183 } 184 185 186 inline bigtime_t 187 BPose::SelectionTime() const 188 { 189 return fSelectionTime; 190 } 191 192 193 inline bool 194 BPose::NeedsSaveLocation() const 195 { 196 return fNeedsSaveLocation; 197 } 198 199 200 inline void 201 BPose::SetSaveLocation() 202 { 203 fNeedsSaveLocation = true; 204 } 205 206 207 inline bool 208 BPose::ListModeInited() const 209 { 210 return fListModeInited; 211 } 212 213 214 inline bool 215 BPose::WasAutoPlaced() const 216 { 217 return fWasAutoPlaced; 218 } 219 220 221 inline void 222 BPose::SetAutoPlaced(bool on) 223 { 224 fWasAutoPlaced = on; 225 } 226 227 228 inline bool 229 BPose::HasLocation() const 230 { 231 return fHasLocation; 232 } 233 234 235 inline void 236 BPose::Draw(BRect poseRect, const BRect& updateRect, BPoseView *view, 237 bool fullDraw) 238 { 239 Draw(poseRect, updateRect, view, (BView *)view, fullDraw, BPoint(0, 0), 240 IsSelected()); 241 } 242 243 244 inline uint32 245 BPose::ClipboardMode() const 246 { 247 return fClipboardMode; 248 } 249 250 251 inline void 252 BPose::SetClipboardMode(uint32 clipboardMode) 253 { 254 fClipboardMode = clipboardMode; 255 } 256 257 } // namespace BPrivate 258 259 using namespace BPrivate; 260 261 #endif 262