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