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