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