Revert "FX_BOOL considered harmful, part 2."
[pdfium.git] / fpdfsdk / include / fsdk_baseannot.h
1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7 #ifndef FPDFSDK_INCLUDE_FSDK_BASEANNOT_H_
8 #define FPDFSDK_INCLUDE_FSDK_BASEANNOT_H_
9
10 #if _FX_OS_ == _FX_ANDROID_
11 #include "time.h"
12 #else
13 #include <ctime>
14 #endif
15
16 #include "../../core/include/fpdfdoc/fpdf_doc.h"
17 #include "../../core/include/fxcrt/fx_basic.h"
18 #include "fx_systemhandler.h"
19
20 class CPDFSDK_PageView;
21 class CPDF_Annot;
22 class CPDF_Page;
23 class CPDF_Rect;
24 class CPDF_Matrix;
25 class CPDF_RenderOptions;
26 class CFX_RenderDevice;
27
28 #define CFX_IntArray                            CFX_ArrayTemplate<int>
29
30 class  CPDFSDK_DateTime
31 {
32 public:
33         CPDFSDK_DateTime();
34         CPDFSDK_DateTime(const CFX_ByteString& dtStr);
35         CPDFSDK_DateTime(const CPDFSDK_DateTime& datetime);
36         CPDFSDK_DateTime(const FX_SYSTEMTIME& st);
37
38
39         CPDFSDK_DateTime&       operator = (const CPDFSDK_DateTime& datetime);
40         CPDFSDK_DateTime&       operator = (const FX_SYSTEMTIME& st);
41         FX_BOOL                         operator == (CPDFSDK_DateTime& datetime);
42         FX_BOOL                         operator != (CPDFSDK_DateTime& datetime);
43         FX_BOOL                         operator > (CPDFSDK_DateTime& datetime);
44         FX_BOOL                         operator >= (CPDFSDK_DateTime& datetime);
45         FX_BOOL                         operator < (CPDFSDK_DateTime& datetime);
46         FX_BOOL                         operator <= (CPDFSDK_DateTime& datetime);
47                                                 operator time_t();
48
49         CPDFSDK_DateTime&       FromPDFDateTimeString(const CFX_ByteString& dtStr);
50         CFX_ByteString          ToCommonDateTimeString();
51         CFX_ByteString          ToPDFDateTimeString();
52         void                            ToSystemTime(FX_SYSTEMTIME& st);
53         CPDFSDK_DateTime        ToGMT();
54         CPDFSDK_DateTime&       AddDays(short days);
55         CPDFSDK_DateTime&       AddSeconds(int seconds);
56
57         void                            ResetDateTime();
58
59         struct FX_DATETIME
60         {
61                 int16_t year;
62                 uint8_t         month;
63                 uint8_t         day;
64                 uint8_t         hour;
65                 uint8_t         minute;
66                 uint8_t         second;
67                 int8_t  tzHour;
68                 uint8_t         tzMinute;
69         }dt;
70 };
71
72 class CPDFSDK_Annot
73 {
74 public:
75         CPDFSDK_Annot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPageView);
76         virtual ~CPDFSDK_Annot();
77 public:
78         virtual FX_FLOAT                        GetMinWidth() const;
79         virtual FX_FLOAT                        GetMinHeight() const;
80         //define layout order to 5.
81         virtual int                                     GetLayoutOrder() const { return 5; }
82
83 public:
84         CPDF_Annot*                                     GetPDFAnnot();
85
86         void                                            SetPage(CPDFSDK_PageView* pPageView);
87         CPDFSDK_PageView*                       GetPageView();
88         FX_DWORD                                        GetFlags();
89
90         // Tab Order
91         int                                                     GetTabOrder();
92         void                                            SetTabOrder(int iTabOrder);
93
94         // Selection
95         FX_BOOL                                         IsSelected();
96         void                                            SetSelected(FX_BOOL bSelected);
97
98         CFX_ByteString                          GetType() const;
99         virtual CFX_ByteString          GetSubType() const;
100
101         CPDF_Page*                                      GetPDFPage();
102
103 public:
104         CPDF_Dictionary*                        GetAnnotDict() const;
105
106         void                                            SetRect(const CPDF_Rect& rect);
107         CPDF_Rect                                       GetRect() const;
108
109         void                                            SetContents(const CFX_WideString& sContents);
110         CFX_WideString                          GetContents() const;
111
112         void                                            SetAnnotName(const CFX_WideString& sName);
113         CFX_WideString                          GetAnnotName() const;
114
115         void                                            SetModifiedDate(const FX_SYSTEMTIME& st);
116         FX_SYSTEMTIME                           GetModifiedDate() const;
117
118         void                                            SetFlags(int nFlags);
119         int                                                     GetFlags() const;
120
121         void                                            SetAppState(const CFX_ByteString& str);
122         CFX_ByteString                          GetAppState() const;
123
124         void                                            SetStructParent(int key);
125         int                                                     GetStructParent() const;
126
127         //border
128         void                                            SetBorderWidth(int nWidth);
129         int                                                     GetBorderWidth() const;
130
131         //BBS_SOLID
132         //BBS_DASH
133         //BBS_BEVELED
134         //BBS_INSET
135         //BBS_UNDERLINE
136
137         void                                            SetBorderStyle(int nStyle);
138         int                                                     GetBorderStyle() const;
139
140         void                                            SetBorderDash(const CFX_IntArray& array);
141         void                                            GetBorderDash(CFX_IntArray& array) const;
142
143         //The background of the annotation's icon when closed
144         //The title bar of the annotation's pop-up window
145         //The border of a link annotation
146
147         void                                            SetColor(FX_COLORREF color);
148         void                                            RemoveColor();
149         FX_BOOL                                         GetColor(FX_COLORREF& color) const;
150
151         FX_BOOL                                         IsVisible() const;
152         //action
153
154         CPDF_Action                                     GetAction() const;
155         void                                            SetAction(const CPDF_Action& a);
156         void                                            RemoveAction();
157
158         CPDF_AAction                            GetAAction() const;
159         void                                            SetAAction(const CPDF_AAction& aa);
160         void                                            RemoveAAction();
161
162         virtual CPDF_Action                     GetAAction(CPDF_AAction::AActionType eAAT);
163
164 public:
165         FX_BOOL                                         IsAppearanceValid();
166         FX_BOOL                                         IsAppearanceValid(CPDF_Annot::AppearanceMode mode);
167         void                                            DrawAppearance(CFX_RenderDevice* pDevice, const CPDF_Matrix* pUser2Device,
168                 CPDF_Annot::AppearanceMode mode, const CPDF_RenderOptions* pOptions);
169         void                                            DrawBorder(CFX_RenderDevice* pDevice, const CPDF_Matrix* pUser2Device,
170                 const CPDF_RenderOptions* pOptions);
171
172         void                                            ClearCachedAP();
173
174         void                                            WriteAppearance(const CFX_ByteString& sAPType, const CPDF_Rect& rcBBox,
175                 const CPDF_Matrix& matrix, const CFX_ByteString& sContents,
176                 const CFX_ByteString& sAPState = "");
177
178 public:
179         virtual void                    Annot_OnDraw(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,CPDF_RenderOptions* pOptions);
180 public:
181
182
183 private:
184         FX_BOOL CreateFormFiller();
185 protected:
186         CPDF_Annot*                     m_pAnnot;
187         CPDFSDK_PageView*       m_pPageView;
188         FX_BOOL                         m_bSelected;
189         int                                     m_nTabOrder;
190
191 };
192
193 #endif  // FPDFSDK_INCLUDE_FSDK_BASEANNOT_H_