Initial commit.
[pdfium.git] / fpdfsdk / include / pdfwindow / PWL_Note.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 _PWL_NOTE_H_\r
8 #define _PWL_NOTE_H_\r
9 \r
10 class IPWL_NoteNotify;\r
11 class IPWL_NoteHandler;\r
12 class IPWL_NoteItem;\r
13 class CPWL_NoteItem;\r
14 class CPWL_Note;\r
15 class CPWL_Label;\r
16 class CPWL_Edit;\r
17 class CPWL_Note_Icon;\r
18 class CPWL_Note_CloseBox;\r
19 class CPWL_Note_LBBox;\r
20 class CPWL_Note_RBBox;\r
21 class CPWL_Note_Edit;\r
22 class CPWL_Note_Options;\r
23 class CPWL_Note_Contents;\r
24 class IPopup_Note;\r
25 \r
26 \r
27 class IPWL_NoteNotify\r
28 {\r
29 public:\r
30         virtual void                                            OnNoteMove(const FX_RECT& rtWin) = 0;\r
31         virtual void                                            OnNoteShow(FX_BOOL bShow) = 0;\r
32         virtual void                                            OnNoteActivate(FX_BOOL bActive) = 0;\r
33         virtual void                                            OnNoteClose() = 0;\r
34         virtual void                                            OnItemCreate(IPWL_NoteItem* pItem) = 0;\r
35         virtual void                                            OnItemDelete(IPWL_NoteItem* pItem) = 0;\r
36         virtual void                                            OnSetAuthorName(IPWL_NoteItem* pItem) = 0;\r
37         virtual void                                            OnSetBkColor(IPWL_NoteItem* pItem) = 0;\r
38         virtual void                                            OnSetContents(IPWL_NoteItem* pItem) = 0;\r
39         virtual void                                            OnSetDateTime(IPWL_NoteItem* pItem) = 0;\r
40         virtual void                                            OnSetSubjectName(IPWL_NoteItem* pItem) = 0;\r
41         virtual void                                            OnPopupMenu(FX_INT32 x, FX_INT32 y) = 0;\r
42         virtual void                                            OnPopupMenu(IPWL_NoteItem* pItem, FX_INT32 x, FX_INT32 y) = 0;\r
43 };\r
44 \r
45 class IPWL_NoteHandler\r
46 {\r
47 public:\r
48         virtual void                                            OnNoteColorChanged(const CPWL_Color& color) = 0;\r
49 };\r
50 \r
51 class IPWL_NoteItem\r
52 {\r
53 public:\r
54         virtual void                                            SetPrivateData(void* pData) = 0;\r
55         virtual void                                            SetBkColor(const CPWL_Color& color) = 0;\r
56         virtual void                                            SetSubjectName(const CFX_WideString& sName) = 0;\r
57         virtual void                                            SetAuthorName(const CFX_WideString& sName) = 0;\r
58         virtual void                                            SetDateTime(FX_SYSTEMTIME time) = 0;\r
59         virtual void                                            SetContents(const CFX_WideString& sContents) = 0;\r
60 \r
61         virtual IPWL_NoteItem*                          CreateSubItem() = 0;\r
62         virtual FX_INT32                                        CountSubItems() const = 0;\r
63         virtual IPWL_NoteItem*                          GetSubItems(FX_INT32 index) const = 0;\r
64         virtual void                                            DeleteSubItem(IPWL_NoteItem* pNoteItem) = 0;\r
65         virtual void                                            SetFocus() = 0;\r
66         \r
67         virtual IPWL_NoteItem*                          GetParentItem() const = 0;\r
68         virtual void*                                           GetPrivateData() const = 0;\r
69         virtual CFX_WideString                          GetAuthorName() const = 0;\r
70         virtual CPWL_Color                                      GetBkColor() const = 0;\r
71         virtual CFX_WideString                          GetContents() const = 0;\r
72         virtual FX_SYSTEMTIME                           GetDateTime() const = 0;\r
73         virtual CFX_WideString                          GetSubjectName() const = 0;\r
74 \r
75         virtual CPWL_Edit*                                      GetEdit() const = 0;\r
76 };\r
77 \r
78 class PWL_CLASS CPWL_Note_Icon : public CPWL_Wnd\r
79 {\r
80 public:\r
81         CPWL_Note_Icon();\r
82         virtual ~CPWL_Note_Icon();\r
83 \r
84         void                                                            SetIconType(FX_INT32 nType);\r
85 \r
86 public:\r
87 \r
88 protected:\r
89         virtual void                                            DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device);\r
90 \r
91 private:\r
92         FX_INT32                                                        m_nType;\r
93 };\r
94 \r
95 class CPWL_Note_CloseBox : public CPWL_Button\r
96 {\r
97 public:\r
98         CPWL_Note_CloseBox();\r
99         virtual ~CPWL_Note_CloseBox();\r
100 \r
101 protected:\r
102         virtual void                                            DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device);\r
103         virtual FX_BOOL                                         OnLButtonDown(const CPDF_Point & point, FX_DWORD nFlag);\r
104         virtual FX_BOOL                                         OnLButtonUp(const CPDF_Point & point, FX_DWORD nFlag);\r
105 \r
106 private:\r
107         FX_BOOL                                                         m_bMouseDown;\r
108 };\r
109 \r
110 class CPWL_Note_LBBox : public CPWL_Wnd\r
111 {\r
112 public:\r
113         CPWL_Note_LBBox();\r
114         virtual ~CPWL_Note_LBBox();\r
115 \r
116 protected:\r
117         virtual void                                            DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device);\r
118 };\r
119 \r
120 class CPWL_Note_RBBox : public CPWL_Wnd\r
121 {\r
122 public:\r
123         CPWL_Note_RBBox();\r
124         virtual ~CPWL_Note_RBBox();\r
125 \r
126 protected:\r
127         virtual void                                            DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device);\r
128 };\r
129 \r
130 class CPWL_Note_Edit : public CPWL_Edit\r
131 {\r
132 public:\r
133         CPWL_Note_Edit();\r
134         virtual ~CPWL_Note_Edit();\r
135 \r
136         void                                                            EnableNotify(FX_BOOL bEnable) {m_bEnableNotify = bEnable;}\r
137         virtual FX_FLOAT                                        GetItemHeight(FX_FLOAT fLimitWidth);\r
138         FX_FLOAT                                                        GetItemLeftMargin();\r
139         FX_FLOAT                                                        GetItemRightMargin();\r
140 \r
141         virtual void                                            SetText(FX_LPCWSTR csText);\r
142 \r
143 protected:\r
144         virtual void                                            OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, FX_INTPTR wParam = 0, FX_INTPTR lParam = 0);\r
145         virtual void                                            RePosChildWnd();\r
146         virtual void                                            OnSetFocus();\r
147         virtual void                                            OnKillFocus();  \r
148 \r
149 private:\r
150         FX_BOOL                                                         m_bEnableNotify;\r
151         FX_FLOAT                                                        m_fOldItemHeight;\r
152         FX_BOOL                                                         m_bSizeChanged;\r
153         FX_FLOAT                                                        m_fOldMin;\r
154         FX_FLOAT                                                        m_fOldMax;\r
155 };\r
156 \r
157 class CPWL_Note_Options : public CPWL_Wnd\r
158 {\r
159 public:\r
160         CPWL_Note_Options();\r
161         virtual ~CPWL_Note_Options();\r
162 \r
163         CPDF_Rect                                                       GetContentRect() const;\r
164         virtual void                                            SetTextColor(const CPWL_Color & color);\r
165         void                                                            SetText(const CFX_WideString& sText);\r
166 \r
167 protected:\r
168         virtual void                                            RePosChildWnd();\r
169         virtual void                                            CreateChildWnd(const PWL_CREATEPARAM & cp);\r
170         virtual void                                            DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device);\r
171 \r
172 private:\r
173         CPWL_Label*                                                     m_pText;\r
174 };\r
175 \r
176 class CPWL_Note_Contents : public CPWL_ListCtrl\r
177 {\r
178 public:\r
179         CPWL_Note_Contents();\r
180         virtual ~CPWL_Note_Contents();\r
181 \r
182         virtual CFX_ByteString                          GetClassName() const;\r
183         virtual void                                            OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, FX_INTPTR wParam = 0, FX_INTPTR lParam = 0);\r
184         virtual FX_BOOL                                         OnLButtonDown(const CPDF_Point& point, FX_DWORD nFlag);\r
185 \r
186         void                                                            SetEditFocus(FX_BOOL bLast);\r
187         CPWL_Edit*                                                      GetEdit() const;\r
188 \r
189 public:\r
190         void                                                            SetText(const CFX_WideString& sText);\r
191         CFX_WideString                                          GetText() const;\r
192 \r
193         CPWL_NoteItem*                                          CreateSubItem();\r
194         void                                                            DeleteSubItem(IPWL_NoteItem* pNoteItem);\r
195         FX_INT32                                                        CountSubItems() const;\r
196         IPWL_NoteItem*                                          GetSubItems(FX_INT32 index) const;\r
197 \r
198         virtual IPWL_NoteItem*                          GetHitNoteItem(const CPDF_Point& point);\r
199         void                                                            EnableRead(FX_BOOL bEnabled);\r
200         void                                                            EnableModify(FX_BOOL bEnabled);\r
201 \r
202 protected:\r
203         virtual void                                            CreateChildWnd(const PWL_CREATEPARAM & cp);\r
204 \r
205 private:\r
206         CPWL_Note_Edit*                                         m_pEdit;\r
207 };\r
208 \r
209 class PWL_CLASS CPWL_NoteItem : public CPWL_Wnd, public IPWL_NoteItem \r
210 {\r
211 public:\r
212         CPWL_NoteItem();\r
213         virtual ~CPWL_NoteItem();\r
214 \r
215 public:\r
216         virtual void                                            SetPrivateData(void* pData);\r
217         virtual void                                            SetBkColor(const CPWL_Color& color);\r
218         virtual void                                            SetSubjectName(const CFX_WideString& sName);\r
219         virtual void                                            SetAuthorName(const CFX_WideString& sName);\r
220         virtual void                                            SetDateTime(FX_SYSTEMTIME time);\r
221         virtual void                                            SetContents(const CFX_WideString& sContents);\r
222 \r
223         virtual IPWL_NoteItem*                          CreateSubItem();\r
224         virtual FX_INT32                                        CountSubItems() const;\r
225         virtual IPWL_NoteItem*                          GetSubItems(FX_INT32 index) const;\r
226         virtual void                                            DeleteSubItem(IPWL_NoteItem* pNoteItem);\r
227         virtual void                                            SetFocus(){SetNoteFocus(FALSE);}\r
228 \r
229         virtual IPWL_NoteItem*                          GetParentItem() const;\r
230         virtual void*                                           GetPrivateData() const;\r
231         virtual CFX_WideString                          GetAuthorName() const;\r
232         virtual CPWL_Color                                      GetBkColor() const;\r
233         virtual CFX_WideString                          GetContents() const;\r
234         virtual FX_SYSTEMTIME                           GetDateTime() const;\r
235         virtual CFX_WideString                          GetSubjectName() const;\r
236         virtual FX_BOOL                                         IsTopItem() const { return FALSE;}\r
237         virtual CPWL_Edit*                                      GetEdit() const;\r
238 \r
239 public:\r
240         virtual FX_BOOL                                         OnLButtonDown(const CPDF_Point& point, FX_DWORD nFlag);\r
241         virtual FX_BOOL                                         OnRButtonUp(const CPDF_Point & point, FX_DWORD nFlag);\r
242         virtual CFX_ByteString                          GetClassName() const;\r
243         virtual IPWL_NoteItem*                          GetHitNoteItem(const CPDF_Point& point);\r
244         virtual IPWL_NoteItem*                          GetFocusedNoteItem() const;\r
245 \r
246         virtual void                                            ResetSubjectName(FX_INT32 nItemIndex);\r
247         void                                                            EnableRead(FX_BOOL bEnabled);\r
248         void                                                            EnableModify(FX_BOOL bEnabled);\r
249 \r
250 protected:\r
251         virtual void                                            RePosChildWnd();\r
252         virtual void                                            CreateChildWnd(const PWL_CREATEPARAM & cp);\r
253 \r
254         virtual void                                            OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, FX_INTPTR wParam = 0, FX_INTPTR lParam = 0);\r
255 \r
256 public:\r
257         virtual FX_FLOAT                                        GetItemHeight(FX_FLOAT fLimitWidth);\r
258         virtual FX_FLOAT                                        GetItemLeftMargin();\r
259         virtual FX_FLOAT                                        GetItemRightMargin();\r
260         CPWL_NoteItem*                                          CreateNoteItem();\r
261         CPWL_NoteItem*                                          GetParentNoteItem() const;\r
262 \r
263         void                                                            SetNoteFocus(FX_BOOL bLast);\r
264         void                                                            OnContentsValidate();\r
265         \r
266         void                                                            OnCreateNoteItem();\r
267 \r
268 protected:\r
269         void                                                            PopupNoteItemMenu(const CPDF_Point& point);\r
270 \r
271         virtual const CPWL_Note*                        GetNote() const;\r
272         virtual IPWL_NoteNotify*                        GetNoteNotify() const;\r
273 \r
274 protected:\r
275         CPWL_Label*                                                     m_pSubject;\r
276         CPWL_Label*                                                     m_pDateTime;\r
277         CPWL_Note_Contents*                                     m_pContents;\r
278 \r
279 private:\r
280         void*                                                           m_pPrivateData;\r
281         FX_SYSTEMTIME                                           m_dtNote;\r
282         CFX_WideString                                          m_sAuthor;\r
283 \r
284         FX_FLOAT                                                        m_fOldItemHeight;\r
285         FX_BOOL                                                         m_bSizeChanged;\r
286         FX_BOOL                                                         m_bAllowModify;\r
287 };\r
288 \r
289 class PWL_CLASS CPWL_Note : public CPWL_NoteItem\r
290 {\r
291 public:\r
292         CPWL_Note(IPopup_Note* pPopupNote, IPWL_NoteNotify* pNoteNotify, IPWL_NoteHandler* pNoteHandler);\r
293         virtual ~CPWL_Note();\r
294 \r
295 public:\r
296         virtual void                                            SetSubjectName(const CFX_WideString& sName);\r
297         virtual void                                            SetAuthorName(const CFX_WideString& sName);\r
298         virtual CFX_WideString                          GetAuthorName() const;\r
299         virtual void                                            SetBkColor(const CPWL_Color& color);\r
300         virtual void                                            ResetSubjectName(FX_INT32 nItemIndex){}\r
301         virtual FX_BOOL                                         IsTopItem() const {return TRUE;}\r
302         virtual const CPWL_Note*                        GetNote() const;\r
303         virtual IPWL_NoteNotify*                        GetNoteNotify() const;\r
304 \r
305 public:\r
306         IPWL_NoteItem*                                          Reply();\r
307         void                                                            EnableNotify(FX_BOOL bEnabled);\r
308         void                                                            SetIconType(FX_INT32 nType);\r
309         void                                                            SetOptionsText(const CFX_WideString& sText);\r
310         void                                                            EnableRead(FX_BOOL bEnabled);\r
311         void                                                            EnableModify(FX_BOOL bEnabled);\r
312 \r
313         CFX_WideString                                          GetReplyString() const;\r
314         void                                                            SetReplyString(const CFX_WideString& string);\r
315 \r
316         //0-normal / 1-caption / 2-leftbottom corner / 3-rightbottom corner / 4-close / 5-options \r
317         FX_INT32                                                        NoteHitTest(const CPDF_Point& point) const;\r
318         CPDF_Rect                                                       GetCaptionRect() const {return m_rcCaption;}\r
319         IPopup_Note*                                            GetPopupNote() const {return m_pPopupNote;}\r
320 \r
321 public:\r
322         virtual FX_BOOL                                         OnLButtonDown(const CPDF_Point & point, FX_DWORD nFlag);\r
323         virtual FX_BOOL                                         OnRButtonUp(const CPDF_Point & point, FX_DWORD nFlag);\r
324         virtual FX_BOOL                                         OnMouseWheel(short zDelta, const CPDF_Point & point, FX_DWORD nFlag);\r
325 \r
326 protected:\r
327         virtual void                                            RePosChildWnd();\r
328         virtual void                                            CreateChildWnd(const PWL_CREATEPARAM & cp);\r
329 \r
330         virtual void                                            OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, FX_INTPTR wParam = 0, FX_INTPTR lParam = 0);\r
331 \r
332         FX_BOOL                                                         ResetScrollBar();\r
333         void                                                            RePosNoteChildren();\r
334         FX_BOOL                                                         ScrollBarShouldVisible();\r
335 \r
336 private:\r
337         CPWL_Label*                                                     m_pAuthor;\r
338         CPWL_Note_Icon*                                         m_pIcon;\r
339         CPWL_Note_CloseBox*                                     m_pCloseBox;\r
340         CPWL_Note_LBBox*                                        m_pLBBox;\r
341         CPWL_Note_RBBox*                                        m_pRBBox;\r
342         CPWL_ScrollBar*                                         m_pContentsBar; \r
343         CPWL_Note_Options*                                      m_pOptions;\r
344         IPWL_NoteNotify*                                        m_pNoteNotify;\r
345         FX_BOOL                                                         m_bResizing;\r
346         PWL_SCROLL_INFO                                         m_OldScrollInfo;\r
347         CPDF_Rect                                                       m_rcCaption;\r
348         FX_BOOL                                                         m_bEnalbleNotify;\r
349         IPopup_Note*                                            m_pPopupNote;\r
350         IPWL_NoteHandler*                                       m_pNoteHandler;\r
351         CFX_WideString                                          m_sReplyString;\r
352 };\r
353 \r
354 #endif\r
355 \r