InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
SystemUtils.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: ?
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 __SystemUtils__
25 #define __SystemUtils__
26 
27 #ifndef __PMTYPES__
28 #include "PMTypes.h"
29 #endif
30 
31 #ifdef MACINTOSH
32 #include "MSystemUtils.h"
33 #endif
34 
35 #ifdef WINDOWS
36 #include "WSystemUtils.h"
37 #endif
38 
39 #ifdef WASM
40 #include "WasmSystemUtils.h"
41 #endif
42 
43 
44  void SetRect(SysRect *r, SysPoint p1, SysPoint p2);
45  // Create a rectangle out of two points. Rectangle
46  // is "normalized" to reorder the points.
47 
48 
49  void K2ReadWriteSysRect(IPMStream *s, SysRect& rt);
50 
51  void SystemBeep(void);
52 
53 // ----- Some convenient inlines for double numbers.
54 
55 
56 inline bool16 operator==(const SysPoint& pt1, const SysPoint& pt2)
57  { return SysPointH(pt1) == SysPointH(pt2) && SysPointV(pt1) == SysPointV(pt2); }
58 
59 inline bool16 operator!=(const SysPoint& pt1, const SysPoint& pt2)
60  { return SysPointH(pt1) != SysPointH(pt2) || SysPointV(pt1) != SysPointV(pt2); }
61 
62 inline SysPoint operator-(const SysPoint& pt1, const SysPoint& pt2)
63 {
64  SysPoint result;
65 
66  SysPointH(result) = SysPointH(pt1) - SysPointH(pt2);
67  SysPointV(result) = SysPointV(pt1) - SysPointV(pt2);
68 
69  return result;
70 }
71 
72 inline SysPoint operator+(const SysPoint& pt1, const SysPoint& pt2)
73 {
74  SysPoint result;
75 
76  SysPointH(result) = SysPointH(pt1) + SysPointH(pt2);
77  SysPointV(result) = SysPointV(pt1) + SysPointV(pt2);
78 
79  return result;
80 }
81 
82 inline void SysRectOffset( SysRect& rect, int32 dx, int32 dy )
83 {
84  ::OffsetSysRect(rect, dx, dy);
85 }
86 
87 // Stack based utility for managing deletion of SysRgn
89 {
90 
91 public:
92  AutoSysRgn()
93  {
94  fSysRgn = NULL;
95  }
96 
97  explicit AutoSysRgn(const SysRgn& value)
98  {
99  fSysRgn = value;
100  }
101 
104  {
105  if (fSysRgn)
106  ::DeleteSysRgn(fSysRgn);
107  }
108 
110  void Reset(SysRgn value = NULL)
111  {
112  if (value != fSysRgn)
113  {
114  if (fSysRgn)
115  ::DeleteSysRgn(fSysRgn);
116  fSysRgn = value;
117  }
118  }
119 
121  bool IsNull() const
122  {
123  return fSysRgn == NULL;
124  }
125 
126  const SysRgn& operator*() const
127  {
128  return fSysRgn;
129  }
130 
131  SysRgn& operator*()
132  {
133  return fSysRgn;
134  }
135 
136 private:
137  SysRgn fSysRgn;
138 };
139 
140 
141 #endif
142  // __SystemUtils__