InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
DrawPassInfo.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: dwaterfa
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 __DrawPassInfo__
25 #define __DrawPassInfo__
26 
27 #include "K2Vector.h"
28 #include "IPMStream.h"
29 
30 
31 //
32 // The drawing of Parcels is organized through the use of DrawPassInfo
33 // and DrawPriorities. Standard page items get a single call to draw through
34 // their IShape interface and internally various logical passes are made
35 // across the page item for the stoke, fill, page item adornments, text, etc.
36 //
37 // The Text system requires a finer and more efficient notion of draw order
38 // than is available through the background, before foreground, after
39 // foreground, etc type of arrangement. Their system has been adapted from
40 // ITextAdornment.h through TextDrawPriority.h and now, hopefully, finally
41 // ends here.
42 //
43 // DrawPassInfo is made up of the following elements -
44 //
45 // Pass This is the "pass" portion of a valid DrawPriority expressed as
46 // an integer.
47 //
48 // ClassID This is the ClassID of the boss that optionally requires this
49 // pass. If this element is equal to kInvalidClass then the pass
50 // is required, not optional.
51 //
52 // The boss of an optional pass must have an
53 // IID_IGLOBALTEXTADORNMENT interface and return kTrue for
54 // GetIsActive().
55 //
56 // The idea here is that some passes across the Parcel are only
57 // needed if some external state is set appropriately. If the
58 // ONLY reason the pass exists is because of this boss then we
59 // will not make the pass if the boss is not active.
60 //
61 // Note that if some Parcel has two elements sharing the same
62 // pass, one which is optional and one which is required, then the
63 // pass will always be made without regard to the optional boss.
64 //
65 // A good example of how this is used is the GlobalTextAdornment ShowInvisibles.
66 // ShowInvisibles wants to draw at kPassPriForeground but by being optional,
67 // unless it is active we do not make the extra pass.
68 //
69 namespace Text {
70 
72 {
73 public:
74  typedef base_type data_type;
75  //
76  // Passes are expressed on a 16 bit scale with lower pass numbers having
77  // a higher priority (get drawn first) than higher pass numbers (drawn
78  // later).
79  //
80  // We have defined three well known pass numbers to assist people in
81  // selecting appropriate pass values. Note that a full pass over a Parcel
82  // is expensive so unless you have a special reason, most usages to use
83  // one of these three pre-defined passes.
84  //
85  // See TextDrawPriority for more information and examples.
86  //
87  typedef int32 Pass;
88 
89  enum {
90  kPassMax = -32768,
91  kPassBackground = -16384,
92  kPassText = 0,
93  kPassForeground = 16384,
94  kPassMin = 32767
95  };
96 
97  DrawPassInfo() :
98  fPass(kPassMin)
99  { }
100  DrawPassInfo(Pass pass, ClassID id) :
101  fPass(pass), fID(id)
102  { }
103  Pass GetPass() const
104  { return fPass; }
105  void SetPass(Pass pass)
106  { fPass = pass; }
107  ClassID GetClassID() const
108  { return fID; }
109  void SetClassID(ClassID id)
110  { fID = id; }
111 
112  bool16 operator==(const DrawPassInfo& t) const
113  {
114  return ((fPass == t.fPass) && (fID == t.fID));
115  }
116 
117  void ReadWrite(IPMStream *s, ImplementationID)
118  {
119  s->XferInt32(fPass);
120  s->XferID(fID);
121  }
122 
123 private:
124  Pass fPass;
125  ClassID fID;
126 
127 };
128 
130 
131 }
132 
133 #endif