InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
TextDrawPriority.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 __TextDrawPriority__
25 #define __TextDrawPriority__
26 
27 #include "DrawPassInfo.h"
28 #include "IPMStream.h"
29 
30 //
31 // TextAdornments affect when they are called by the priority value they
32 // return via their GetDrawPriority() method. Higher priorities (smaller
33 // numbers) are called before lower priorities (larger numbers).
34 //
35 // In addition, drawing priorities are further broken down into two pieces -
36 // Pass (whole part) and Run (fractional part). For each unique Pass value
37 // across all the active adornments in a frame, a full iteration of the wax
38 // runs will be made calling all the adornments which share that pass value.
39 // Then, within each wax run, the adornments will be called based on their Run
40 // priority.
41 //
42 namespace Text {
43 
44  const PMReal kTAMaxPassPri = (Text::DrawPassInfo::kPassMax + 0.0);
45  const PMReal kTAPassPriBackground = (Text::DrawPassInfo::kPassBackground + 0.0);
46  const PMReal kTAPassPriText = (Text::DrawPassInfo::kPassText + 0.0);
47  const PMReal kTAPassPriForeground = (Text::DrawPassInfo::kPassForeground + 0.0);
48  const PMReal kTAMinPassPri = (Text::DrawPassInfo::kPassMin + 0.99998);
49 
50  //
51  // Inner draw priority class to hide the implementation.
52  //
53  class DrawPriority {
54  public:
55  DrawPriority() : fVal(0)
56  { }
58  {
59  if (v < kTAMaxPassPri)
60  v = kTAMaxPassPri;
61  else if (v > kTAMinPassPri)
62  v = kTAMinPassPri;
63  fVal = ToFixed(v);
64  }
65 
66  DrawPriority(const DrawPriority& other)
67  { fVal = other.fVal; }
68 
69  DrawPriority& operator=(const DrawPriority& other)
70  { fVal = other.fVal; return *this; }
71 
72  bool16 operator==(const DrawPriority& other) const
73  { return (fVal == other.fVal); }
74 
75  bool16 operator<(const DrawPriority& other) const
76  { return (fVal < other.fVal); }
77 
78  bool16 operator>(const DrawPriority& other) const
79  { return (fVal > other.fVal); }
80 
81  Text::DrawPassInfo::Pass GetPass() const
82  { return (fVal / 65536); }
83 
84  void ReadWrite(IPMStream *s)
85  { s->XferInt32(fVal); }
86 
87  // Debug only.
88  // To dump priority values of all adornments.
89  #ifdef DEBUG
90  int32 GetRunPriority() { return fVal % 65536; }
91  #endif
92 
93  private:
94  Fixed fVal;
95  };
96 
97 }
98 
99 #endif