InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
CSprite.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: Jack Kirstein
6 //
7 // $Author$
8 //
9 // $DateTime$
10 //
11 // $Revision$
12 //
13 // $Change$
14 //
15 // Copyright 1997-2010 Adobe Systems Incorporated. All rights reserved.
16 //
17 // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance
18 // with the terms of the Adobe license agreement accompanying it. If you have received
19 // this file from a source other than Adobe, then your use, modification, or
20 // distribution of it requires the prior written permission of Adobe.
21 //
22 //========================================================================================
23 
24 #ifndef __CSprite__
25 #define __CSprite__
26 
27 #include "ISprite.h"
28 #include "ICallback.h"
29 
30 #include "PMPoint.h"
31 #include "PMRect.h"
32 #include "HelperInterface.h"
33 #include "PMMatrix.h"
34 #include "IColorData.h"
35 
37 class IGraphicsPort;
38 class IHandleShape;
39 class ISpread;
40 class SpriteAGMStream;
41 class UIDList;
42 class ILayoutRenderer;
43 
44 //---------------------------------------------------------------
45 // static functions
46 //---------------------------------------------------------------
47 
48 inline bool16 IsPatientUser (int32 flags);
49 inline bool16 IsPatientUser (int32 flags)
50 {
51  return flags & IShape::kPatientUser;
52 }
53 
54 //---------------------------------------------------------------
55 // static functions
56 //---------------------------------------------------------------
57 
58 inline bool16 IsDynamicPause (int32 flags);
59 inline bool16 IsDynamicPause (int32 flags)
60 {
61  return (flags & IShape::kPatientUser && flags & IShape::kDynamicPause);
62 }
63 
73 class CSprite : public ISprite
74 {
75 public:
78  CSprite(IPMUnknown *boss);
79 
82  virtual ~CSprite();
83 
100  virtual bool16 CreateSprite(IGraphicsContext* gc, UIDList* itemList, const PMPoint& startPt, bool16 bDrawItemList);
101 
107  virtual void DestroySprite(IGraphicsContext* gc);
108 
118  virtual bool16 Show(IGraphicsContext* gc, const PMPoint& where, int32 flags, PMMatrix* xForm);
119 
129  virtual bool16 Scroll(IGraphicsContext* gc, const PMPoint& delta, int32 flags, PMMatrix* xForm);
130 
144  virtual void Erase(IGraphicsContext* gc, const PMPoint& where, int32 flags, PMMatrix* xForm);
145 
155  virtual void Hide(IGraphicsContext* gc, bool16 bForceRedraw, PMMatrix* extraXform);
156 
160  virtual void InvalidateBBox();
161 
170  virtual void DisableShapes (IGraphicsContext *gc, bool16 disable);
171 
182  virtual SysRect GetDeviceBounds (IGraphicsContext* gc, int32 flags, PMMatrix* xForm);
183 
186  virtual bool16 ValidSprite() const
187  {
188  return fValidSprite;
189  };
190 
192  virtual bool16 NeedsUpdate(const PMPoint& where, int32 flags) const
193  {
194  // #2910574 - we added a timer to DrawSprite to limit recomposition frequency.
195  // However if mouse moves before timer elapses this will return true and we'll
196  // continually redraw with no further movement until the timer elapses. This is
197  // a major hit on drag performance. So we don't signal we need to update until the mouse moves.
198  // #3112261 - we now allow the sprite to recompose and update one extra time when the
199  // composition interval is reached.
200  return (IsPatientUser (flags) &&
201  ((where != fCurrentPoint) ||
202  (where != fLastCompositionPoint && (SystemUtils::TickCount() - fLastCompositionTicks > kSubsequentCompositionThreshold))));
203  }
204 
205 protected:
208  virtual void DisableHandleShapes(IGraphicsContext *gc, bool16 disable);
209 
217  virtual PMRect GetShapeDeviceBounds(IGraphicsContext* gc, int32 flags);
218 
228  virtual PMRect GetHandleDeviceBounds(IGraphicsContext* gc, int32 flags, PMMatrix* xForm);
229 
237  virtual PMRect GetTrackerBounds(IGraphicsContext* gc, int32 flags);
238 
246 
252  virtual void DrawTrackerExtra(IGraphicsContext* gc, int32 flags);
253 
262  virtual void ShowFirstTime(IGraphicsContext* gc, const PMPoint& where, int32 flags, PMMatrix* xForm);
263 
273  virtual void ShowSprite(IGraphicsContext* gc, const PMPoint& where, int32 flags, PMMatrix* xForm);
274 
283  virtual void ScrollSprite(IGraphicsContext* gc, const PMPoint& delta, int32 flags, PMMatrix* xForm);
284 
292  virtual void ShowLowMemory(IGraphicsContext* gc, const PMPoint& where, int32 flags, PMMatrix* xForm);
293 
301  virtual void ShowLowMemoryFirstTime(IGraphicsContext* gc, const PMPoint& where, int32 flags, PMMatrix* xForm);
302 
311  virtual void ScrollLowMemory(IGraphicsContext* gc, const PMPoint& delta, int32 flags, PMMatrix* xForm);
312 
319  virtual void HideSprite(IGraphicsContext* gc, bool16 bForceRedraw, PMMatrix* extraXform);
320 
328  virtual void HideLowMemory(IGraphicsContext* gc, bool16 bForceRedraw, PMMatrix* extraXform);
329 
338  virtual void EraseAndRedrawShapes(IGraphicsContext* gc, const PMPoint& where, int32 flags, PMMatrix* xForm);
339 
343  virtual void SetHiliteColor (UID layerUID);
344 
352  virtual void DrawShapes (IGraphicsContext* gc, SysRgn clipRgn = nil, bool16 bDisable = kFalse);
353 
357  virtual void DrawSelection (IGraphicsContext* gc);
358 
363  virtual void DrawSpriteShapes(IGraphicsContext* gc, int32 flags);
364 
372  virtual void DrawSpriteHandles(IGraphicsContext* gc, int32 flags, PMMatrix* xForm);
373 
379  virtual void CreateTrackerPaths(IGraphicsContext* gc);
380 
385  virtual void CreateHandlePaths(IGraphicsContext* gc, bool16 bDoDirectionHandles = kTrue);
386 
391  virtual void ClipToView(IGraphicsContext* gc, SysRect* bounds);
392 
398  virtual void ClipToView(IGraphicsContext* gc, PMRect& bounds);
399 
410  virtual PMRect GetStandOffBBox( IShape *pShape, IGraphicsContext *gc, int32 flags, const PMRect &bBox );
411 
416  virtual int32 GetDrawFlags() const;
417 
422  virtual bool16 UseDisplayList (int32 flags);
423 
429  void AddInvalidOffscreenBounds (IControlView* iView, PMRect* invalidBounds);
430 
436  void AddInvalidLayoutBounds (IControlView* iView, PMRect* invalidBounds);
437 
442  static void DrawCenterX( IGraphicsPort* gPort, const PBPMPoint& center ) ;
443 
450  void DrawSmartGuides(IGraphicsContext *gc, const PBPMPoint where, const PMMatrix *xForm);
451 
452  PMMatrix fXformFromLastShow;
453  SysRect fLastBounds;
454  ColorArray fRGBColorValue;
455  PMPoint fStartPoint;
456  PMPoint fCurrentPoint;
457  SysPoint fLastMouseLoc;
458 
459  IControlView* fControlView;
460  UIDList* fItemList;
461  IDVOffscreenPortData* fBackgroundVP;
462  IDVOffscreenPortData* fForegroundVP;
463  IDataBase* fDataBase;
464 
465  int32 fDrawFlags;
466 
467  bool16 fValidDeviceBounds;
468 
469  bool16 fFirstTime;
470  bool16 fValidSprite;
471  bool16 fLowMemory;
472  bool16 fIsFrontView;
473 
474 
475  bool16 fDrawItemList;
476  bool16 fIsPathSelection;
477  bool16 fHandlesDisabled;
478 
479  bool16 fDoRevealAllImageData;
480  bool16 fSmartGuidesDrawn;
481  bool16 fDrawSmartGuides;
482 
483 private:
484  //-------------------------------------------------------------------------------
489 
490  void DrawBackgroundFirstTime (IGraphicsContext* gc);
491 
492  void CreateItemDisplayList (IGraphicsContext* gc, int32 flags);
493 
494  UIDRef GetPageGuideColor();
495  UIDRef GetSmartGuideColor();
496 
497  void CreateTimer();
498  void CleanupTimer();
499 
500  void DrawSelectionPort(ILayoutRenderer* renderer, SysRgn updateRgn, const PMPoint& where, int32 flags, PMMatrix* xForm);
501  void DrawSpriteGfx(IGraphicsContext* oc, const PMPoint& where, int32 flags, PMMatrix* xForm);
502 
503  PMMatrix fOriginalMat;
504  PMMatrix fLastMatrix;
505  PMRect fHandleDeviceBounds;
506  PMRect fLastShapeDeviceBounds;
507  PMPoint fLastCompositionPoint;
508  UIDRef fSmartGuideColor;
509  UIDRef fPageGuideColor;
510  SpriteAGMStream* fAGMStream;
511  void* fItemDLPort;
512  uint32 fStartTicks;
513  uint32 fLastCompositionTicks;
514  bool16 fUseDisplayList;
515 
516 #ifdef DEBUG
517 public:
518  bool16 gDebugDontUseOffscreen;
519 #endif
520 
521 
522 
523 };
524 
530 {
531 public:
540  FindMasterItemsIterator(const ISpread *drawingSpread, UIDList *masterItemsFound, const UIDList *candidates, PMMatrixCollection *masterInner2DrawingSpreadPBList);
541 
543  virtual void ExecuteCallback(const PMMatrix *xform, IPMUnknown *iThing, int32 flags);
544 
546  virtual int32 IterateChildren();
547 
549  virtual IDrawMgr* GetCallbackDrawManager();
550 
551 private:
552  const ISpread* fSpread;
553  IDrawMgr* fDrawMgr;
554  UIDList *fVisibleMasterItems;
555  const UIDList* fCandidates;
556  PMMatrixCollection *fMatrices;
557  bool fMasterItemsDone;
558 };
559 
560 #ifdef DEBUG
561  void ToggleDebugSpriteLowMem();
562 #endif
563 
564 #endif