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 *, 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); 64 void MoveTo(BPoint, BPoseView *, bool inval = true); 65 66 void Draw(BRect, BPoseView *, bool fullDraw = true, const BRegion * = 0, 67 bool recalculateText = false); 68 void Draw(BRect, BPoseView *, BView *drawView, bool fullDraw, 69 const BRegion *, BPoint offset, bool selected, bool recalculateText = false); 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 85 BTextWidget *ActiveWidget() const; 86 BTextWidget *WidgetFor(uint32 hashAttr, int32 *index = 0) const; 87 BTextWidget *WidgetFor(BColumn *column, BPoseView *poseView, ModelNodeLazyOpener &opener, 88 int32 *index = NULL); 89 // adds the widget if needed 90 91 bool PointInPose(BPoint poseLoc, const BPoseView *, BPoint where, 92 BTextWidget ** = NULL) const; 93 bool PointInPose(const BPoseView *, BPoint where) const ; 94 BRect CalcRect(BPoint loc, const BPoseView *, bool minimal_rect = false); 95 BRect CalcRect(const BPoseView *); 96 void UpdateAllWidgets(int32 poseIndex, BPoint poseLoc, BPoseView *); 97 void UpdateWidgetAndModel(Model *resolvedModel, const char *attrName, 98 uint32 attrType, int32 poseIndex, BPoint poseLoc, BPoseView *view); 99 bool UpdateVolumeSpaceBar(bool enabled); 100 void UpdateIcon(BPoint poseLoc, BPoseView *); 101 102 //void UpdateFixedSymlink(BPoint poseLoc, BPoseView *); 103 void UpdateBrokenSymLink(BPoint poseLoc, BPoseView *); 104 void UpdateWasBrokenSymlink(BPoint poseLoc, BPoseView *poseView); 105 106 void Commit(bool saveChanges, BPoint loc, BPoseView *, int32 index); 107 void EditFirstWidget(BPoint poseLoc, BPoseView *); 108 void EditNextWidget(BPoseView *); 109 void EditPreviousWidget(BPoseView *); 110 111 BPoint Location() const; 112 bool DelayedEdit() const; 113 void SetDelayedEdit(bool delay); 114 bool ListModeInited() const; 115 bool HasLocation() const; 116 bool NeedsSaveLocation() const; 117 void SetSaveLocation(); 118 bool WasAutoPlaced() const; 119 void SetAutoPlaced(bool); 120 121 uint32 ClipboardMode() const; 122 void SetClipboardMode(uint32 clipboardMode); 123 124 #if DEBUG 125 void PrintToStream(); 126 #endif 127 128 private: 129 void EditPreviousNextWidgetCommon(BPoseView *poseView, bool next); 130 void CreateWidgets(BPoseView *); 131 bool TestLargeIconPixel(BPoint) const; 132 133 Model *fModel; 134 BObjectList<BTextWidget> fWidgetList; 135 BPoint fLocation; 136 137 uint32 fClipboardMode; 138 int32 fPercent; 139 140 bool fIsSelected : 1; 141 bool fDelayedEdit : 1; 142 bool fHasLocation : 1; 143 bool fNeedsSaveLocation : 1; 144 bool fListModeInited : 1; 145 bool fWasAutoPlaced : 1; 146 bool fBrokenSymLink : 1; 147 bool fBackgroundClean : 1; 148 }; 149 150 151 inline Model * 152 BPose::TargetModel() const 153 { 154 return fModel; 155 } 156 157 158 inline Model * 159 BPose::ResolvedModel() const 160 { 161 return fModel->IsSymLink() ? 162 (fModel->LinkTo() ? fModel->LinkTo() : fModel) : fModel; 163 } 164 165 166 inline bool 167 BPose::IsSelected() const 168 { 169 return fIsSelected; 170 } 171 172 173 inline void 174 BPose::Select(bool on) 175 { 176 fIsSelected = on; 177 } 178 179 180 inline bool 181 BPose::DelayedEdit() const 182 { 183 return fDelayedEdit; 184 } 185 186 187 inline void 188 BPose::SetDelayedEdit(bool on) 189 { 190 fDelayedEdit = on; 191 } 192 193 194 inline bool 195 BPose::NeedsSaveLocation() const 196 { 197 return fNeedsSaveLocation; 198 } 199 200 201 inline void 202 BPose::SetSaveLocation() 203 { 204 fNeedsSaveLocation = true; 205 } 206 207 208 inline bool 209 BPose::ListModeInited() const 210 { 211 return fListModeInited; 212 } 213 214 215 inline bool 216 BPose::WasAutoPlaced() const 217 { 218 return fWasAutoPlaced; 219 } 220 221 222 inline void 223 BPose::SetAutoPlaced(bool on) 224 { 225 fWasAutoPlaced = on; 226 } 227 228 229 inline bool 230 BPose::HasLocation() const 231 { 232 return fHasLocation; 233 } 234 235 236 inline BPoint 237 BPose::Location() const 238 { 239 return fLocation; 240 } 241 242 243 inline void 244 BPose::SetLocation(BPoint point) 245 { 246 fLocation = BPoint(floorf(point.x), floorf(point.y)); 247 fHasLocation = true; 248 } 249 250 251 inline void 252 BPose::Draw(BRect rect, BPoseView *view, bool fullDraw, const BRegion *updateRgn, 253 bool recalculateText) 254 { 255 Draw(rect, view, (BView *)view, fullDraw, updateRgn, BPoint(0, 0), 256 IsSelected(), recalculateText); 257 } 258 259 260 inline uint32 261 BPose::ClipboardMode() const 262 { 263 return fClipboardMode; 264 } 265 266 267 inline void 268 BPose::SetClipboardMode(uint32 clipboardMode) 269 { 270 fClipboardMode = clipboardMode; 271 } 272 273 } // namespace BPrivate 274 275 using namespace BPrivate; 276 277 #endif 278