blob: 12b29aeb7e345044b5aaa2ec20dfca59b6eb7f74 [file] [log] [blame]
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001// 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.
Lei Zhanga6d9f0e2015-06-13 00:48:38 -07004
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07005// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
dan sinclair89e904b2016-03-23 19:29:15 -04007#ifndef FPDFSDK_PDFWINDOW_PWL_WND_H_
8#define FPDFSDK_PDFWINDOW_PWL_WND_H_
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07009
weili2d5b0202016-08-03 11:06:49 -070010#include <memory>
Tom Sepezab277682016-02-17 10:07:21 -080011#include <vector>
12
dsinclair1727aee2016-09-29 13:12:56 -070013#include "core/fpdfdoc/cpdf_formcontrol.h"
Dan Sinclairbc8dcc32017-01-19 13:53:02 -050014#include "core/fxcrt/cfx_observable.h"
dsinclaira52ab742016-09-29 13:59:29 -070015#include "core/fxcrt/fx_basic.h"
dsinclairb9590102016-04-27 06:38:59 -070016#include "fpdfsdk/cfx_systemhandler.h"
Dan Sinclairbc8dcc32017-01-19 13:53:02 -050017#include "fpdfsdk/cpdfsdk_widget.h"
18#include "fpdfsdk/pdfwindow/cpwl_color.h"
Tom Sepez870292c2015-04-07 16:12:46 -070019
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070020class CPWL_MsgControl;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070021class CPWL_ScrollBar;
22class CPWL_Timer;
23class CPWL_TimerHandler;
Tom Sepez870292c2015-04-07 16:12:46 -070024class CPWL_Wnd;
dsinclairb9590102016-04-27 06:38:59 -070025class CFX_SystemHandler;
dsinclairc7a73492016-04-05 12:01:42 -070026class IPVT_FontMap;
Tom Sepez870292c2015-04-07 16:12:46 -070027class IPWL_Provider;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070028
Nico Weber9d8ec5a2015-08-04 13:00:21 -070029// window styles
30#define PWS_CHILD 0x80000000L
31#define PWS_BORDER 0x40000000L
32#define PWS_BACKGROUND 0x20000000L
33#define PWS_HSCROLL 0x10000000L
34#define PWS_VSCROLL 0x08000000L
35#define PWS_VISIBLE 0x04000000L
36#define PWS_DISABLE 0x02000000L
37#define PWS_READONLY 0x01000000L
38#define PWS_AUTOFONTSIZE 0x00800000L
39#define PWS_AUTOTRANSPARENT 0x00400000L
40#define PWS_NOREFRESHCLIP 0x00200000L
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070041
Nico Weber9d8ec5a2015-08-04 13:00:21 -070042// edit and label styles
43#define PES_MULTILINE 0x0001L
44#define PES_PASSWORD 0x0002L
45#define PES_LEFT 0x0004L
46#define PES_RIGHT 0x0008L
47#define PES_MIDDLE 0x0010L
48#define PES_TOP 0x0020L
49#define PES_BOTTOM 0x0040L
50#define PES_CENTER 0x0080L
51#define PES_CHARARRAY 0x0100L
52#define PES_AUTOSCROLL 0x0200L
53#define PES_AUTORETURN 0x0400L
54#define PES_UNDO 0x0800L
55#define PES_RICH 0x1000L
56#define PES_SPELLCHECK 0x2000L
57#define PES_TEXTOVERFLOW 0x4000L
58#define PES_NOREAD 0x8000L
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070059
Nico Weber9d8ec5a2015-08-04 13:00:21 -070060// listbox styles
61#define PLBS_MULTIPLESEL 0x0001L
62#define PLBS_HOVERSEL 0x0008L
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070063
Nico Weber9d8ec5a2015-08-04 13:00:21 -070064// combobox styles
65#define PCBS_ALLOWCUSTOMTEXT 0x0001L
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070066
Nico Weber9d8ec5a2015-08-04 13:00:21 -070067// richedit styles
68#define PRES_MULTILINE 0x0001L
69#define PRES_AUTORETURN 0x0002L
70#define PRES_AUTOSCROLL 0x0004L
Nico Weber9d8ec5a2015-08-04 13:00:21 -070071#define PRES_UNDO 0x0100L
72#define PRES_MULTIPAGES 0x0200L
73#define PRES_TEXTOVERFLOW 0x0400L
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070074
Nico Weber9d8ec5a2015-08-04 13:00:21 -070075// notification messages
76#define PNM_ADDCHILD 0x00000000L
77#define PNM_REMOVECHILD 0x00000001L
78#define PNM_SETSCROLLINFO 0x00000002L
79#define PNM_SETSCROLLPOS 0x00000003L
80#define PNM_SCROLLWINDOW 0x00000004L
81#define PNM_LBUTTONDOWN 0x00000005L
82#define PNM_LBUTTONUP 0x00000006L
83#define PNM_MOUSEMOVE 0x00000007L
84#define PNM_NOTERESET 0x00000008L
85#define PNM_SETCARETINFO 0x00000009L
86#define PNM_SELCHANGED 0x0000000AL
87#define PNM_NOTEEDITCHANGED 0x0000000BL
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070088
Nico Weber9d8ec5a2015-08-04 13:00:21 -070089#define PWL_CLASSNAME_EDIT "CPWL_Edit"
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070090
Nico Weber9d8ec5a2015-08-04 13:00:21 -070091struct CPWL_Dash {
weili625ad662016-06-15 11:21:33 -070092 CPWL_Dash() : nDash(0), nGap(0), nPhase(0) {}
Nico Weber9d8ec5a2015-08-04 13:00:21 -070093 CPWL_Dash(int32_t dash, int32_t gap, int32_t phase)
94 : nDash(dash), nGap(gap), nPhase(phase) {}
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070095
Dan Sinclairbc8dcc32017-01-19 13:53:02 -050096 void Reset() {
97 nDash = 0;
98 nGap = 0;
99 nPhase = 0;
100 }
101
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700102 int32_t nDash;
103 int32_t nGap;
104 int32_t nPhase;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700105};
106
Tom Sepez007e6c02016-02-26 14:31:56 -0800107inline bool operator==(const CPWL_Color& c1, const CPWL_Color& c2) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700108 return c1.nColorType == c2.nColorType && c1.fColor1 - c2.fColor1 < 0.0001 &&
109 c1.fColor1 - c2.fColor1 > -0.0001 &&
110 c1.fColor2 - c2.fColor2 < 0.0001 &&
111 c1.fColor2 - c2.fColor2 > -0.0001 &&
112 c1.fColor3 - c2.fColor3 < 0.0001 &&
113 c1.fColor3 - c2.fColor3 > -0.0001 &&
114 c1.fColor4 - c2.fColor4 < 0.0001 && c1.fColor4 - c2.fColor4 > -0.0001;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700115}
116
Tom Sepez007e6c02016-02-26 14:31:56 -0800117inline bool operator!=(const CPWL_Color& c1, const CPWL_Color& c2) {
118 return !(c1 == c2);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700119}
120
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700121#define PWL_SCROLLBAR_WIDTH 12.0f
122#define PWL_SCROLLBAR_BUTTON_WIDTH 9.0f
123#define PWL_SCROLLBAR_POSBUTTON_MINWIDTH 2.0f
124#define PWL_SCROLLBAR_TRANSPARANCY 150
125#define PWL_SCROLLBAR_BKCOLOR \
126 CPWL_Color(COLORTYPE_RGB, 220.0f / 255.0f, 220.0f / 255.0f, 220.0f / 255.0f)
127#define PWL_DEFAULT_SELTEXTCOLOR CPWL_Color(COLORTYPE_RGB, 1, 1, 1)
128#define PWL_DEFAULT_SELBACKCOLOR \
129 CPWL_Color(COLORTYPE_RGB, 0, 51.0f / 255.0f, 113.0f / 255.0f)
130#define PWL_DEFAULT_BACKCOLOR PWL_DEFAULT_SELTEXTCOLOR
131#define PWL_DEFAULT_TEXTCOLOR CPWL_Color(COLORTYPE_RGB, 0, 0, 0)
132#define PWL_DEFAULT_FONTSIZE 9.0f
133#define PWL_DEFAULT_BLACKCOLOR CPWL_Color(COLORTYPE_GRAY, 0)
134#define PWL_DEFAULT_WHITECOLOR CPWL_Color(COLORTYPE_GRAY, 1)
135#define PWL_DEFAULT_HEAVYGRAYCOLOR CPWL_Color(COLORTYPE_GRAY, 0.50)
136#define PWL_DEFAULT_LIGHTGRAYCOLOR CPWL_Color(COLORTYPE_GRAY, 0.75)
137#define PWL_TRIANGLE_HALFLEN 2.0f
138#define PWL_CBBUTTON_TRIANGLE_HALFLEN 3.0f
139#define PWL_INVALIDATE_INFLATE 2
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700140
Dan Sinclairbc8dcc32017-01-19 13:53:02 -0500141class IPWL_Provider : public CFX_Observable<IPWL_Provider> {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700142 public:
143 virtual ~IPWL_Provider() {}
Tom Sepeze5b59ca2015-01-09 11:46:17 -0800144
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700145 // get a matrix which map user space to CWnd client space
Tom Sepez60d909e2015-12-10 15:34:55 -0800146 virtual CFX_Matrix GetWindowMatrix(void* pAttachedData) = 0;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700147
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700148 /*
149 0 L"&Undo\tCtrl+Z"
150 1 L"&Redo\tCtrl+Shift+Z"
151 2 L"Cu&t\tCtrl+X"
152 3 L"&Copy\tCtrl+C"
153 4 L"&Paste\tCtrl+V"
154 5 L"&Delete"
155 6 L"&Select All\tCtrl+A"
156 */
157 virtual CFX_WideString LoadPopupMenuString(int32_t nIndex) = 0;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700158};
159
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700160class IPWL_FocusHandler {
161 public:
162 virtual ~IPWL_FocusHandler() {}
163 virtual void OnSetFocus(CPWL_Wnd* pWnd) = 0;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700164};
165
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700166struct PWL_CREATEPARAM {
167 public:
weili625ad662016-06-15 11:21:33 -0700168 PWL_CREATEPARAM();
169 PWL_CREATEPARAM(const PWL_CREATEPARAM& other);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700170
Dan Sinclairbc8dcc32017-01-19 13:53:02 -0500171 void Reset() {
172 rcRectWnd.Reset();
173 pSystemHandler = nullptr;
174 pFontMap = nullptr;
175 pProvider.Reset();
176 pFocusHandler = nullptr;
177 dwFlags = 0;
178 sBackgroundColor.Reset();
179 pAttachedWidget.Reset();
180 nBorderStyle = BorderStyle::SOLID;
181 dwBorderWidth = 0;
182 sBorderColor.Reset();
183 sTextColor.Reset();
184 sTextStrokeColor.Reset();
185 nTransparency = 0;
186 fFontSize = 0.0f;
187 sDash.Reset();
188 pAttachedData = nullptr;
189 pParentWnd = nullptr;
190 pMsgControl = nullptr;
191 eCursorType = 0;
192 mtChild.SetIdentity();
193 }
194
Tom Sepez281a9ea2016-02-26 14:24:28 -0800195 CFX_FloatRect rcRectWnd; // required
dsinclairb9590102016-04-27 06:38:59 -0700196 CFX_SystemHandler* pSystemHandler; // required
Dan Sinclairbc8dcc32017-01-19 13:53:02 -0500197 IPVT_FontMap* pFontMap; // required
198 IPWL_Provider::ObservedPtr pProvider; // required
Nico Weber077f1a32015-08-06 15:08:57 -0700199 IPWL_FocusHandler* pFocusHandler; // optional
tsepezc3255f52016-03-25 14:52:27 -0700200 uint32_t dwFlags; // optional
Nico Weber077f1a32015-08-06 15:08:57 -0700201 CPWL_Color sBackgroundColor; // optional
Dan Sinclairbc8dcc32017-01-19 13:53:02 -0500202 CPDFSDK_Widget::ObservedPtr pAttachedWidget; // required
dsinclair92cb5e52016-05-16 11:38:28 -0700203 BorderStyle nBorderStyle; // optional
Nico Weber077f1a32015-08-06 15:08:57 -0700204 int32_t dwBorderWidth; // optional
205 CPWL_Color sBorderColor; // optional
206 CPWL_Color sTextColor; // optional
207 CPWL_Color sTextStrokeColor; // optional
208 int32_t nTransparency; // optional
209 FX_FLOAT fFontSize; // optional
210 CPWL_Dash sDash; // optional
211 void* pAttachedData; // optional
212 CPWL_Wnd* pParentWnd; // ignore
213 CPWL_MsgControl* pMsgControl; // ignore
214 int32_t eCursorType; // ignore
Tom Sepez60d909e2015-12-10 15:34:55 -0800215 CFX_Matrix mtChild; // ignore
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700216};
217
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700218class CPWL_Timer {
219 public:
dsinclairb9590102016-04-27 06:38:59 -0700220 CPWL_Timer(CPWL_TimerHandler* pAttached, CFX_SystemHandler* pSystemHandler);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700221 virtual ~CPWL_Timer();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700222
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700223 int32_t SetPWLTimer(int32_t nElapse);
224 void KillPWLTimer();
225 static void TimerProc(int32_t idEvent);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700226
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700227 private:
228 int32_t m_nTimerID;
229 CPWL_TimerHandler* m_pAttached;
dsinclairb9590102016-04-27 06:38:59 -0700230 CFX_SystemHandler* m_pSystemHandler;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700231};
232
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700233class CPWL_TimerHandler {
234 public:
235 CPWL_TimerHandler();
236 virtual ~CPWL_TimerHandler();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700237
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700238 void BeginTimer(int32_t nElapse);
239 void EndTimer();
240 virtual void TimerProc();
dsinclairb9590102016-04-27 06:38:59 -0700241 virtual CFX_SystemHandler* GetSystemHandler() const = 0;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700242
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700243 private:
weili2d5b0202016-08-03 11:06:49 -0700244 std::unique_ptr<CPWL_Timer> m_pTimer;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700245};
246
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700247class CPWL_Wnd : public CPWL_TimerHandler {
248 friend class CPWL_MsgControl;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700249
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700250 public:
251 CPWL_Wnd();
Lei Zhang2b1a2d52015-08-14 22:16:22 -0700252 ~CPWL_Wnd() override;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700253
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700254 void Create(const PWL_CREATEPARAM& cp);
255 virtual CFX_ByteString GetClassName() const;
Lei Zhangab5537d2016-01-06 14:58:14 -0800256 void InvalidateFocusHandler(IPWL_FocusHandler* handler);
257 void InvalidateProvider(IPWL_Provider* provider);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700258 void Destroy();
tsepez4cf55152016-11-02 14:37:54 -0700259 void Move(const CFX_FloatRect& rcNew, bool bReset, bool bRefresh);
thestig1cd352e2016-06-07 17:53:06 -0700260 virtual void InvalidateRect(CFX_FloatRect* pRect = nullptr);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700261
Tom Sepez60d909e2015-12-10 15:34:55 -0800262 void DrawAppearance(CFX_RenderDevice* pDevice, CFX_Matrix* pUser2Device);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700263
tsepez4cf55152016-11-02 14:37:54 -0700264 virtual bool OnKeyDown(uint16_t nChar, uint32_t nFlag);
265 virtual bool OnKeyUp(uint16_t nChar, uint32_t nFlag);
266 virtual bool OnChar(uint16_t nChar, uint32_t nFlag);
Dan Sinclairf528eee2017-02-14 11:52:07 -0500267 virtual bool OnLButtonDblClk(const CFX_PointF& point, uint32_t nFlag);
268 virtual bool OnLButtonDown(const CFX_PointF& point, uint32_t nFlag);
269 virtual bool OnLButtonUp(const CFX_PointF& point, uint32_t nFlag);
270 virtual bool OnMButtonDblClk(const CFX_PointF& point, uint32_t nFlag);
271 virtual bool OnMButtonDown(const CFX_PointF& point, uint32_t nFlag);
272 virtual bool OnMButtonUp(const CFX_PointF& point, uint32_t nFlag);
273 virtual bool OnRButtonDown(const CFX_PointF& point, uint32_t nFlag);
274 virtual bool OnRButtonUp(const CFX_PointF& point, uint32_t nFlag);
275 virtual bool OnMouseMove(const CFX_PointF& point, uint32_t nFlag);
tsepez4cf55152016-11-02 14:37:54 -0700276 virtual bool OnMouseWheel(short zDelta,
Dan Sinclairf528eee2017-02-14 11:52:07 -0500277 const CFX_PointF& point,
tsepez4cf55152016-11-02 14:37:54 -0700278 uint32_t nFlag);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700279
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700280 virtual void SetFocus();
281 virtual void KillFocus();
282 void SetCapture();
283 void ReleaseCapture();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700284
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700285 virtual void OnNotify(CPWL_Wnd* pWnd,
tsepezc3255f52016-03-25 14:52:27 -0700286 uint32_t msg,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700287 intptr_t wParam = 0,
288 intptr_t lParam = 0);
289 virtual void SetTextColor(const CPWL_Color& color);
290 virtual void SetTextStrokeColor(const CPWL_Color& color);
tsepez4cf55152016-11-02 14:37:54 -0700291 virtual void SetVisible(bool bVisible);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700292
Tom Sepez281a9ea2016-02-26 14:24:28 -0800293 virtual CFX_FloatRect GetFocusRect() const;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700294 virtual CPWL_Color GetBackgroundColor() const;
295 virtual CPWL_Color GetBorderColor() const;
296 virtual CPWL_Color GetTextColor() const;
297 virtual CPWL_Color GetTextStrokeColor() const;
298 virtual FX_FLOAT GetFontSize() const;
299 virtual int32_t GetInnerBorderWidth() const;
dsinclair92cb5e52016-05-16 11:38:28 -0700300 virtual CPWL_Color GetBorderLeftTopColor(BorderStyle nBorderStyle) const;
301 virtual CPWL_Color GetBorderRightBottomColor(BorderStyle nBorderStyle) const;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700302
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700303 virtual void SetFontSize(FX_FLOAT fFontSize);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700304
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700305 void SetBackgroundColor(const CPWL_Color& color);
Tom Sepez281a9ea2016-02-26 14:24:28 -0800306 void SetClipRect(const CFX_FloatRect& rect);
dsinclair92cb5e52016-05-16 11:38:28 -0700307 void SetBorderStyle(BorderStyle eBorderStyle);
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700308
Tom Sepez281a9ea2016-02-26 14:24:28 -0800309 virtual CFX_FloatRect GetWindowRect() const;
310 virtual CFX_FloatRect GetClientRect() const;
Dan Sinclairf528eee2017-02-14 11:52:07 -0500311 CFX_PointF GetCenterPoint() const;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700312 int32_t GetBorderWidth() const;
tsepez4cf55152016-11-02 14:37:54 -0700313 bool IsVisible() const { return m_bVisible; }
314 bool HasFlag(uint32_t dwFlags) const;
tsepezc3255f52016-03-25 14:52:27 -0700315 void AddFlag(uint32_t dwFlags);
316 void RemoveFlag(uint32_t dwFlags);
Tom Sepez281a9ea2016-02-26 14:24:28 -0800317 const CFX_FloatRect& GetClipRect() const;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700318 CPWL_Wnd* GetParentWindow() const;
dsinclair92cb5e52016-05-16 11:38:28 -0700319 BorderStyle GetBorderStyle() const;
Lei Zhang7457e382016-01-06 23:00:34 -0800320 const CPWL_Dash& GetBorderDash() const;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700321 void* GetAttachedData() const;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700322
Dan Sinclairf528eee2017-02-14 11:52:07 -0500323 bool WndHitTest(const CFX_PointF& point) const;
324 bool ClientHitTest(const CFX_PointF& point) const;
tsepez4cf55152016-11-02 14:37:54 -0700325 bool IsCaptureMouse() const;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700326
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700327 const CPWL_Wnd* GetFocused() const;
tsepez4cf55152016-11-02 14:37:54 -0700328 bool IsFocused() const;
329 bool IsReadOnly() const;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700330 CPWL_ScrollBar* GetVScrollBar() const;
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700331
dsinclairc7a73492016-04-05 12:01:42 -0700332 IPVT_FontMap* GetFontMap() const;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700333 IPWL_Provider* GetProvider() const;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700334 IPWL_FocusHandler* GetFocusHandler() const;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700335
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700336 int32_t GetTransparency();
337 void SetTransparency(int32_t nTransparency);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700338
Tom Sepez60d909e2015-12-10 15:34:55 -0800339 CFX_Matrix GetChildToRoot() const;
340 CFX_Matrix GetChildMatrix() const;
341 void SetChildMatrix(const CFX_Matrix& mt);
342 CFX_Matrix GetWindowMatrix() const;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700343
Dan Sinclairf528eee2017-02-14 11:52:07 -0500344 virtual CFX_PointF ChildToParent(const CFX_PointF& point) const;
Tom Sepez281a9ea2016-02-26 14:24:28 -0800345 virtual CFX_FloatRect ChildToParent(const CFX_FloatRect& rect) const;
Dan Sinclairf528eee2017-02-14 11:52:07 -0500346 virtual CFX_PointF ParentToChild(const CFX_PointF& point) const;
Tom Sepez281a9ea2016-02-26 14:24:28 -0800347 virtual CFX_FloatRect ParentToChild(const CFX_FloatRect& rect) const;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700348
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700349 // those methods only implemented by listctrl item
weili625ad662016-06-15 11:21:33 -0700350 virtual FX_FLOAT GetItemHeight(FX_FLOAT fLimitWidth);
351 virtual FX_FLOAT GetItemLeftMargin();
352 virtual FX_FLOAT GetItemRightMargin();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700353
tsepez4cf55152016-11-02 14:37:54 -0700354 void EnableWindow(bool bEnable);
355 bool IsEnabled();
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700356 virtual void SetCursor();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700357
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700358 protected:
Lei Zhang2b1a2d52015-08-14 22:16:22 -0700359 // CPWL_TimerHandler
dsinclairb9590102016-04-27 06:38:59 -0700360 CFX_SystemHandler* GetSystemHandler() const override;
Lei Zhang2b1a2d52015-08-14 22:16:22 -0700361
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700362 virtual void CreateChildWnd(const PWL_CREATEPARAM& cp);
363 virtual void RePosChildWnd();
364 void GetAppearanceStream(CFX_ByteTextBuf& sAppStream);
365 virtual void GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream);
366 virtual void GetChildAppearanceStream(CFX_ByteTextBuf& sAppStream);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700367
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700368 virtual void DrawThisAppearance(CFX_RenderDevice* pDevice,
Tom Sepez60d909e2015-12-10 15:34:55 -0800369 CFX_Matrix* pUser2Device);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700370 virtual void DrawChildAppearance(CFX_RenderDevice* pDevice,
Tom Sepez60d909e2015-12-10 15:34:55 -0800371 CFX_Matrix* pUser2Device);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700372
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700373 virtual void OnCreate(PWL_CREATEPARAM& cp);
374 virtual void OnCreated();
375 virtual void OnDestroy();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700376
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700377 virtual void OnSetFocus();
378 virtual void OnKillFocus();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700379
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700380 virtual void OnEnabled();
381 virtual void OnDisabled();
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700382
tsepez4cf55152016-11-02 14:37:54 -0700383 void SetNotifyFlag(bool bNotifying = true) { m_bNotifying = bNotifying; }
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700384
tsepez4cf55152016-11-02 14:37:54 -0700385 bool IsValid() const;
Lei Zhang7457e382016-01-06 23:00:34 -0800386 const PWL_CREATEPARAM& GetCreationParam() const;
tsepez4cf55152016-11-02 14:37:54 -0700387 bool IsNotifying() const { return m_bNotifying; }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700388
Tom Sepez281a9ea2016-02-26 14:24:28 -0800389 void InvalidateRectMove(const CFX_FloatRect& rcOld,
390 const CFX_FloatRect& rcNew);
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700391
Dan Sinclairf528eee2017-02-14 11:52:07 -0500392 void PWLtoWnd(const CFX_PointF& point, int32_t& x, int32_t& y) const;
Tom Sepez281a9ea2016-02-26 14:24:28 -0800393 FX_RECT PWLtoWnd(const CFX_FloatRect& rect) const;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700394
tsepez4cf55152016-11-02 14:37:54 -0700395 bool IsWndCaptureMouse(const CPWL_Wnd* pWnd) const;
396 bool IsWndCaptureKeyboard(const CPWL_Wnd* pWnd) const;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700397 const CPWL_Wnd* GetRootWnd() const;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700398
tsepez4cf55152016-11-02 14:37:54 -0700399 bool IsCTRLpressed(uint32_t nFlag) const;
400 bool IsSHIFTpressed(uint32_t nFlag) const;
401 bool IsALTpressed(uint32_t nFlag) const;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700402
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700403 private:
404 void AddChild(CPWL_Wnd* pWnd);
405 void RemoveChild(CPWL_Wnd* pWnd);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700406
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700407 void CreateScrollBar(const PWL_CREATEPARAM& cp);
408 void CreateVScrollBar(const PWL_CREATEPARAM& cp);
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700409
Lei Zhang62b2e912015-08-14 21:49:19 -0700410 void AdjustStyle();
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700411 void CreateMsgControl();
412 void DestroyMsgControl();
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700413
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700414 CPWL_MsgControl* GetMsgControl() const;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700415
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700416 protected:
tsepez6745f962017-01-04 10:09:45 -0800417 std::vector<CPWL_Wnd*> m_Children;
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700418
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700419 private:
420 PWL_CREATEPARAM m_sPrivateParam;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700421 CPWL_ScrollBar* m_pVScrollBar;
Tom Sepez281a9ea2016-02-26 14:24:28 -0800422 CFX_FloatRect m_rcWindow;
423 CFX_FloatRect m_rcClip;
tsepez4cf55152016-11-02 14:37:54 -0700424 bool m_bCreated;
425 bool m_bVisible;
426 bool m_bNotifying;
427 bool m_bEnabled;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700428};
429
dan sinclair89e904b2016-03-23 19:29:15 -0400430#endif // FPDFSDK_PDFWINDOW_PWL_WND_H_