Replace XFA_HWIDGET with IXFA_Widget*
[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                 FX_SHORT        year;
62                 FX_BYTE         month;
63                 FX_BYTE         day;
64                 FX_BYTE         hour;
65                 FX_BYTE         minute;
66                 FX_BYTE         second;
67                 FX_INT8         tzHour;
68                 FX_BYTE         tzMinute;
69         }dt;
70 };
71
72 class CPDFSDK_Annot
73 {
74 public:
75         CPDFSDK_Annot(CPDFSDK_PageView* pPageView);
76     virtual ~CPDFSDK_Annot() {};
77 public:
78         virtual FX_BOOL                         IsXFAField() { return FALSE; }
79
80         virtual FX_FLOAT                        GetMinWidth() const;
81         virtual FX_FLOAT                        GetMinHeight() const;
82         //define layout order to 5.
83         virtual int                                     GetLayoutOrder() const { return 5; }
84
85         virtual CPDF_Annot*                     GetPDFAnnot() { return NULL; }
86         virtual IXFA_Widget*            GetXFAWidget() { return NULL; }
87         
88         virtual CFX_ByteString          GetType() const { return ""; }
89         virtual CFX_ByteString          GetSubType() const { return ""; }
90
91         virtual void                            SetRect(const CPDF_Rect& rect) {}
92         virtual CPDF_Rect                       GetRect() const { return CPDF_Rect(); }
93
94         virtual void                            Annot_OnDraw(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,CPDF_RenderOptions* pOptions) {}
95
96 public:
97         CPDF_Page*                                      GetPDFPage();
98         CPDFXFA_Page*                           GetPDFXFAPage();
99         
100         void                                            SetPage(CPDFSDK_PageView* pPageView) { m_pPageView = pPageView; }
101         CPDFSDK_PageView*                       GetPageView() { return m_pPageView; }
102         
103         // Tab Order    
104         int                                                     GetTabOrder();
105         void                                            SetTabOrder(int iTabOrder);
106         
107         // Selection
108         FX_BOOL                                         IsSelected();
109         void                                            SetSelected(FX_BOOL bSelected);
110         
111 protected:
112         CPDF_Annot*                     m_pAnnot;
113         CPDFSDK_PageView*       m_pPageView;
114         FX_BOOL                         m_bSelected;
115         int                                     m_nTabOrder;
116         
117 };
118
119 class CPDFSDK_BAAnnot : public CPDFSDK_Annot
120 {
121 public:
122         CPDFSDK_BAAnnot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPageView);
123         virtual ~CPDFSDK_BAAnnot();
124
125 public:
126         virtual FX_BOOL                         IsXFAField();
127
128         virtual CFX_ByteString          GetType() const;
129         virtual CFX_ByteString          GetSubType() const;
130
131         virtual void                            SetRect(const CPDF_Rect& rect);
132         virtual CPDF_Rect                       GetRect() const;
133
134         virtual CPDF_Annot*                     GetPDFAnnot();
135
136         virtual void                            Annot_OnDraw(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,CPDF_RenderOptions* pOptions);
137 public:
138         CPDF_Dictionary*                        GetAnnotDict() const;
139         
140         void                                            SetContents(const CFX_WideString& sContents);
141         CFX_WideString                          GetContents() const;
142         
143         void                                            SetAnnotName(const CFX_WideString& sName);
144         CFX_WideString                          GetAnnotName() const;
145         
146         void                                            SetModifiedDate(const FX_SYSTEMTIME& st);
147         FX_SYSTEMTIME                           GetModifiedDate() const;
148
149         void                                            SetFlags(int nFlags);
150         int                                                     GetFlags() const;
151
152         void                                            SetAppState(const CFX_ByteString& str);
153         CFX_ByteString                          GetAppState() const;
154         
155         void                                            SetStructParent(int key);
156         int                                                     GetStructParent() const;
157         
158         //border
159         void                                            SetBorderWidth(int nWidth);
160         int                                                     GetBorderWidth() const;
161         
162         //BBS_SOLID
163         //BBS_DASH
164         //BBS_BEVELED
165         //BBS_INSET
166         //BBS_UNDERLINE
167         
168         void                                            SetBorderStyle(int nStyle);
169         int                                                     GetBorderStyle() const;
170         
171         void                                            SetBorderDash(const CFX_IntArray& array);
172         void                                            GetBorderDash(CFX_IntArray& array) const;
173         
174         //The background of the annotation's icon when closed
175         //The title bar of the annotation's pop-up window
176         //The border of a link annotation
177         
178         void                                            SetColor(FX_COLORREF color);
179         void                                            RemoveColor();
180         FX_BOOL                                         GetColor(FX_COLORREF& color) const;
181         
182         FX_BOOL                                         IsVisible() const;
183         //action
184
185         CPDF_Action                                     GetAction() const;
186         void                                            SetAction(const CPDF_Action& a);
187         void                                            RemoveAction();
188         
189         CPDF_AAction                            GetAAction() const;
190         void                                            SetAAction(const CPDF_AAction& aa);
191         void                                            RemoveAAction();
192         
193         virtual CPDF_Action                     GetAAction(CPDF_AAction::AActionType eAAT);
194         
195 public:
196         virtual FX_BOOL                         IsAppearanceValid();
197         virtual FX_BOOL                         IsAppearanceValid(CPDF_Annot::AppearanceMode mode);
198         virtual void                            DrawAppearance(CFX_RenderDevice* pDevice, const CPDF_Matrix* pUser2Device,
199                 CPDF_Annot::AppearanceMode mode, const CPDF_RenderOptions* pOptions);
200         void                                            DrawBorder(CFX_RenderDevice* pDevice, const CPDF_Matrix* pUser2Device,
201                 const CPDF_RenderOptions* pOptions);
202         
203         void                                            ClearCachedAP();
204         
205         virtual void                            ResetAppearance();
206         void                                            WriteAppearance(const CFX_ByteString& sAPType, const CPDF_Rect& rcBBox, 
207                 const CPDF_Matrix& matrix, const CFX_ByteString& sContents,
208                 const CFX_ByteString& sAPState = "");
209
210 private:
211         FX_BOOL CreateFormFiller();
212 protected:
213         CPDF_Annot*                     m_pAnnot;
214 };
215
216 #endif  // FPDFSDK_INCLUDE_FSDK_BASEANNOT_H_