InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
TabStop.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: Ric Kamicar
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 __TabStop__
25 #define __TabStop__
26 
27 #include "WideString.h"
28 #include "TextChar.h" // for kTextChar_Period, the default align to char
29 #include "K2Vector.h"
30 
31 class IPMStream;
32 
33 
36 class TabStop
37 {
38  public:
39  typedef base_type data_type;
40 
42  enum { kMaximumLeaderCount = 8 };
43 
46  { kTabAlignLeft, kTabAlignCenter, kTabAlignRight, kTabAlignChar };
47 
49  TabStop() :fAlignment(kTabAlignLeft), fActualLeaderCount(0), fDefaultTab(kFalse),
50  fLocation(0.0), fAlignToChar(tl_DefaultAlignChar.Get()), fLeaders{kTextChar_Space}
51  {}
52 
54  void Reset()
55  { fLocation = 0.0; fActualLeaderCount = 0; }
56 
58  void SetPosition(const PMReal& pos)
59  { fLocation = pos; }
61  void SetAlignment(TabAlignment align)
62  { fAlignment = align; }
64  void SetAlignment(TabAlignment align, UTF32TextChar c)
65  { fAlignment = align; fAlignToChar = c; tl_DefaultAlignChar.Set(c); }
66 
71  void SetLeader(const WideString* leaders = nil);
72  void ClearLeader()
73  { fActualLeaderCount = 0; }
75  const textchar* GetLeaders() const
76  { return fLeaders; }
78  int16 GetLeaderCount() const
79  { return fActualLeaderCount; }
80 
82  PMReal GetPosition() const
83  { return fLocation; }
85  TabAlignment GetAlignment() const
86  { return fAlignment; }
88  UTF32TextChar GetAlignToChar() const
89  { return fAlignToChar; }
90 
91  void ReadWrite(IPMStream *stream);
92 
94  bool16 operator==(const TabStop& other) const
95  { return fLocation == other.fLocation; }
97  bool16 operator>(const TabStop& other) const
98  { return fLocation > other.fLocation; }
100  bool16 operator<(const TabStop& other) const
101  { return fLocation < other.fLocation; }
102 
106  bool16 IsDefaultTab() const
107  { return fDefaultTab; }
109  void SetDefaultTab( bool16 toDefault = kTrue )
110  { fDefaultTab = toDefault; }
111 
112  private:
113  textchar fLeaders[kMaximumLeaderCount];
114  PMReal fLocation;
115  TabAlignment fAlignment;
116  int16 fActualLeaderCount;
117  UTF32TextChar fAlignToChar;
118  bool16 fDefaultTab;
119 
120  static IDThreading::ThreadLocal<UTF32TextChar> tl_DefaultAlignChar;
121 };
122 
123 
127 {
128 public:
129  typedef const TabStop* const_iterator;
130 
132  TabStopTable();
133 
137 
141  const TabStop* GetTabStopAfter( PMReal offset ) const;
142 
144  inline int32 size() const
145  { return fSortedTable.size(); }
147  inline void clear()
148  { fSortedTable.clear(); }
149 
151  const TabStop* begin() const
152  { return fSortedTable.begin(); }
154  const TabStop* end() const
155  { return fSortedTable.end(); }
156 
158  inline const TabStop& operator[] (int32 index) const
159  { return fSortedTable.operator[] (index); }
160 
162  void Insert(const TabStop& stop);
163 
165  inline void Remove(int32 index)
166  { fSortedTable.erase(fSortedTable.begin() + index); }
167 
168  void ReadWrite(IPMStream *stream);
169 
170 protected:
179 };
180 
181 
182 #endif
183  //__TabStop__