John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 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. |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 4 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 5 | // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | |
Dan Sinclair | c411eb9 | 2017-07-25 09:39:30 -0400 | [diff] [blame] | 7 | #ifndef FPDFSDK_PWL_CPWL_WND_H_ |
| 8 | #define FPDFSDK_PWL_CPWL_WND_H_ |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 9 | |
Tom Sepez | 6fe32f8 | 2018-10-25 23:25:58 +0000 | [diff] [blame] | 10 | #include <memory> |
Tom Sepez | ab27768 | 2016-02-17 10:07:21 -0800 | [diff] [blame] | 11 | #include <vector> |
| 12 | |
Tom Sepez | b813c16 | 2019-08-09 19:23:10 +0000 | [diff] [blame] | 13 | #include "core/fxcrt/cfx_timer.h" |
Tom Sepez | 27c350f | 2019-06-11 23:52:35 +0000 | [diff] [blame] | 14 | #include "core/fxcrt/observed_ptr.h" |
Dan Sinclair | aee0db0 | 2017-09-21 16:53:58 -0400 | [diff] [blame] | 15 | #include "core/fxcrt/unowned_ptr.h" |
Dan Sinclair | 7f55a54 | 2017-07-13 14:17:10 -0400 | [diff] [blame] | 16 | #include "core/fxge/cfx_color.h" |
Lei Zhang | 8a5d97c | 2019-05-28 18:51:45 +0000 | [diff] [blame] | 17 | #include "core/fxge/cfx_renderdevice.h" |
Tom Sepez | ea9130d | 2019-08-06 21:55:57 +0000 | [diff] [blame] | 18 | #include "fpdfsdk/pwl/ipwl_systemhandler.h" |
Tom Sepez | 870292c | 2015-04-07 16:12:46 -0700 | [diff] [blame] | 19 | |
Lei Zhang | 4183f20 | 2017-07-07 16:10:06 -0700 | [diff] [blame] | 20 | class CPWL_Edit; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 21 | class CPWL_MsgControl; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 22 | class CPWL_ScrollBar; |
dsinclair | c7a7349 | 2016-04-05 12:01:42 -0700 | [diff] [blame] | 23 | class IPVT_FontMap; |
Dan Sinclair | fb00ec2 | 2017-07-05 09:28:15 -0400 | [diff] [blame] | 24 | struct PWL_SCROLL_INFO; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 25 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 26 | // window styles |
| 27 | #define PWS_CHILD 0x80000000L |
| 28 | #define PWS_BORDER 0x40000000L |
| 29 | #define PWS_BACKGROUND 0x20000000L |
| 30 | #define PWS_HSCROLL 0x10000000L |
| 31 | #define PWS_VSCROLL 0x08000000L |
| 32 | #define PWS_VISIBLE 0x04000000L |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 33 | #define PWS_READONLY 0x01000000L |
| 34 | #define PWS_AUTOFONTSIZE 0x00800000L |
| 35 | #define PWS_AUTOTRANSPARENT 0x00400000L |
| 36 | #define PWS_NOREFRESHCLIP 0x00200000L |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 37 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 38 | // edit and label styles |
| 39 | #define PES_MULTILINE 0x0001L |
| 40 | #define PES_PASSWORD 0x0002L |
| 41 | #define PES_LEFT 0x0004L |
| 42 | #define PES_RIGHT 0x0008L |
| 43 | #define PES_MIDDLE 0x0010L |
| 44 | #define PES_TOP 0x0020L |
| 45 | #define PES_BOTTOM 0x0040L |
| 46 | #define PES_CENTER 0x0080L |
| 47 | #define PES_CHARARRAY 0x0100L |
| 48 | #define PES_AUTOSCROLL 0x0200L |
| 49 | #define PES_AUTORETURN 0x0400L |
| 50 | #define PES_UNDO 0x0800L |
| 51 | #define PES_RICH 0x1000L |
| 52 | #define PES_SPELLCHECK 0x2000L |
| 53 | #define PES_TEXTOVERFLOW 0x4000L |
| 54 | #define PES_NOREAD 0x8000L |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 55 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 56 | // listbox styles |
| 57 | #define PLBS_MULTIPLESEL 0x0001L |
| 58 | #define PLBS_HOVERSEL 0x0008L |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 59 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 60 | // combobox styles |
| 61 | #define PCBS_ALLOWCUSTOMTEXT 0x0001L |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 62 | |
Lei Zhang | 7fdc211 | 2018-12-13 22:30:17 +0000 | [diff] [blame] | 63 | // Cursor style. These must match the values in public/fpdf_formfill.h |
| 64 | #define FXCT_ARROW 0 |
| 65 | #define FXCT_NESW 1 |
| 66 | #define FXCT_NWSE 2 |
| 67 | #define FXCT_VBEAM 3 |
| 68 | #define FXCT_HBEAM 4 |
| 69 | #define FXCT_HAND 5 |
| 70 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 71 | struct CPWL_Dash { |
weili | 625ad66 | 2016-06-15 11:21:33 -0700 | [diff] [blame] | 72 | CPWL_Dash() : nDash(0), nGap(0), nPhase(0) {} |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 73 | CPWL_Dash(int32_t dash, int32_t gap, int32_t phase) |
| 74 | : nDash(dash), nGap(gap), nPhase(phase) {} |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 75 | |
Dan Sinclair | bc8dcc3 | 2017-01-19 13:53:02 -0500 | [diff] [blame] | 76 | void Reset() { |
| 77 | nDash = 0; |
| 78 | nGap = 0; |
| 79 | nPhase = 0; |
| 80 | } |
| 81 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 82 | int32_t nDash; |
| 83 | int32_t nGap; |
| 84 | int32_t nPhase; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 85 | }; |
| 86 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 87 | #define PWL_SCROLLBAR_WIDTH 12.0f |
Dan Sinclair | fc54e05 | 2017-02-23 09:59:05 -0500 | [diff] [blame] | 88 | #define PWL_SCROLLBAR_TRANSPARENCY 150 |
Dan Sinclair | 8e7f932 | 2017-10-16 11:35:42 -0400 | [diff] [blame] | 89 | #define PWL_DEFAULT_BLACKCOLOR CFX_Color(CFX_Color::kGray, 0) |
| 90 | #define PWL_DEFAULT_WHITECOLOR CFX_Color(CFX_Color::kGray, 1) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 91 | |
Tom Sepez | 9fb0595 | 2019-08-06 22:33:54 +0000 | [diff] [blame] | 92 | class CPWL_Wnd : public Observable { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 93 | public: |
Tom Sepez | d8ae8f8 | 2019-06-12 17:58:33 +0000 | [diff] [blame] | 94 | class ProviderIface : public Observable { |
Tom Sepez | 134ac91 | 2017-09-15 15:32:01 -0700 | [diff] [blame] | 95 | public: |
Tom Sepez | 39cf6a7 | 2018-10-04 23:33:30 +0000 | [diff] [blame] | 96 | virtual ~ProviderIface() = default; |
Tom Sepez | 134ac91 | 2017-09-15 15:32:01 -0700 | [diff] [blame] | 97 | |
| 98 | // get a matrix which map user space to CWnd client space |
Tom Sepez | ea9130d | 2019-08-06 21:55:57 +0000 | [diff] [blame] | 99 | virtual CFX_Matrix GetWindowMatrix( |
| 100 | const IPWL_SystemHandler::PerWindowData* pAttached) = 0; |
Tom Sepez | 134ac91 | 2017-09-15 15:32:01 -0700 | [diff] [blame] | 101 | }; |
| 102 | |
| 103 | class FocusHandlerIface { |
| 104 | public: |
Tom Sepez | 39cf6a7 | 2018-10-04 23:33:30 +0000 | [diff] [blame] | 105 | virtual ~FocusHandlerIface() = default; |
Tom Sepez | 134ac91 | 2017-09-15 15:32:01 -0700 | [diff] [blame] | 106 | virtual void OnSetFocus(CPWL_Edit* pEdit) = 0; |
| 107 | }; |
| 108 | |
| 109 | class CreateParams { |
Tom Sepez | bf15730 | 2017-09-15 13:26:32 -0700 | [diff] [blame] | 110 | public: |
| 111 | CreateParams(); |
| 112 | CreateParams(const CreateParams& other); |
Tom Sepez | 134ac91 | 2017-09-15 15:32:01 -0700 | [diff] [blame] | 113 | ~CreateParams(); |
Tom Sepez | bf15730 | 2017-09-15 13:26:32 -0700 | [diff] [blame] | 114 | |
Lei Zhang | 99f44ba | 2020-06-18 17:41:38 +0000 | [diff] [blame] | 115 | // Required: |
| 116 | CFX_FloatRect rcRectWnd; |
Tom Sepez | 8a5699d | 2020-10-13 21:23:53 +0000 | [diff] [blame] | 117 | ObservedPtr<CFX_Timer::HandlerIface> pTimerHandler; |
Lei Zhang | 99f44ba | 2020-06-18 17:41:38 +0000 | [diff] [blame] | 118 | UnownedPtr<IPWL_SystemHandler> pSystemHandler; |
| 119 | UnownedPtr<IPVT_FontMap> pFontMap; |
| 120 | ObservedPtr<ProviderIface> pProvider; |
| 121 | // Optional: |
| 122 | UnownedPtr<FocusHandlerIface> pFocusHandler; |
| 123 | uint32_t dwFlags = 0; |
| 124 | CFX_Color sBackgroundColor; |
| 125 | BorderStyle nBorderStyle = BorderStyle::kSolid; |
| 126 | int32_t dwBorderWidth = 1; |
| 127 | CFX_Color sBorderColor; |
| 128 | CFX_Color sTextColor; |
| 129 | int32_t nTransparency = 255; |
| 130 | float fFontSize; |
| 131 | CPWL_Dash sDash; |
| 132 | // Ignore: |
| 133 | CPWL_MsgControl* pMsgControl = nullptr; |
| 134 | int32_t eCursorType = FXCT_ARROW; |
| 135 | CFX_Matrix mtChild; |
Tom Sepez | bf15730 | 2017-09-15 13:26:32 -0700 | [diff] [blame] | 136 | }; |
| 137 | |
Tom Sepez | 43f012f | 2019-08-02 16:16:46 +0000 | [diff] [blame] | 138 | static bool IsSHIFTKeyDown(uint32_t nFlag); |
| 139 | static bool IsCTRLKeyDown(uint32_t nFlag); |
| 140 | static bool IsALTKeyDown(uint32_t nFlag); |
| 141 | |
Tom Sepez | ea9130d | 2019-08-06 21:55:57 +0000 | [diff] [blame] | 142 | CPWL_Wnd(const CreateParams& cp, |
| 143 | std::unique_ptr<IPWL_SystemHandler::PerWindowData> pAttachedData); |
Tom Sepez | 9fb0595 | 2019-08-06 22:33:54 +0000 | [diff] [blame] | 144 | virtual ~CPWL_Wnd(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 145 | |
Henrique Nakashima | 55469ae | 2017-10-04 11:08:45 -0400 | [diff] [blame] | 146 | // Returns |true| iff this instance is still allocated. |
Tom Sepez | 3034615 | 2020-10-15 17:47:53 +0000 | [diff] [blame] | 147 | virtual bool InvalidateRect(const CFX_FloatRect* pRect); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 148 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 149 | virtual bool OnKeyDown(uint16_t nChar, uint32_t nFlag); |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 150 | virtual bool OnChar(uint16_t nChar, uint32_t nFlag); |
Lei Zhang | be91209 | 2020-04-17 18:03:33 +0000 | [diff] [blame] | 151 | virtual bool OnLButtonDblClk(uint32_t nFlag, const CFX_PointF& point); |
| 152 | virtual bool OnLButtonDown(uint32_t nFlag, const CFX_PointF& point); |
| 153 | virtual bool OnLButtonUp(uint32_t nFlag, const CFX_PointF& point); |
| 154 | virtual bool OnRButtonDown(uint32_t nFlag, const CFX_PointF& point); |
| 155 | virtual bool OnRButtonUp(uint32_t nFlag, const CFX_PointF& point); |
| 156 | virtual bool OnMouseMove(uint32_t nFlag, const CFX_PointF& point); |
| 157 | virtual bool OnMouseWheel(uint32_t nFlag, |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame] | 158 | const CFX_PointF& point, |
Lei Zhang | be91209 | 2020-04-17 18:03:33 +0000 | [diff] [blame] | 159 | const CFX_Vector& delta); |
Dan Sinclair | fb00ec2 | 2017-07-05 09:28:15 -0400 | [diff] [blame] | 160 | virtual void SetScrollInfo(const PWL_SCROLL_INFO& info); |
Dan Sinclair | 7e0336e | 2017-07-05 09:39:50 -0400 | [diff] [blame] | 161 | virtual void SetScrollPosition(float pos); |
Dan Sinclair | 63fbd8d | 2017-07-05 14:10:36 -0400 | [diff] [blame] | 162 | virtual void ScrollWindowVertically(float pos); |
Dan Sinclair | 7f6bec9 | 2017-07-05 14:13:16 -0400 | [diff] [blame] | 163 | virtual void NotifyLButtonDown(CPWL_Wnd* child, const CFX_PointF& pos); |
| 164 | virtual void NotifyLButtonUp(CPWL_Wnd* child, const CFX_PointF& pos); |
| 165 | virtual void NotifyMouseMove(CPWL_Wnd* child, const CFX_PointF& pos); |
Dan Sinclair | 90b7326 | 2017-02-23 14:38:48 -0500 | [diff] [blame] | 166 | virtual void SetFocus(); |
| 167 | virtual void KillFocus(); |
| 168 | virtual void SetCursor(); |
Henrique Nakashima | 55469ae | 2017-10-04 11:08:45 -0400 | [diff] [blame] | 169 | |
| 170 | // Returns |true| iff this instance is still allocated. |
| 171 | virtual bool SetVisible(bool bVisible); |
Dan Sinclair | 05df075 | 2017-03-14 14:43:42 -0400 | [diff] [blame] | 172 | virtual void SetFontSize(float fFontSize); |
| 173 | virtual float GetFontSize() const; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 174 | |
Lei Zhang | 3900ddb | 2018-04-17 14:54:40 +0000 | [diff] [blame] | 175 | virtual WideString GetText(); |
Ryan Harrison | 275e260 | 2017-09-18 14:23:18 -0400 | [diff] [blame] | 176 | virtual WideString GetSelectedText(); |
| 177 | virtual void ReplaceSelection(const WideString& text); |
Lei Zhang | a610536 | 2020-06-22 20:09:56 +0000 | [diff] [blame] | 178 | virtual bool SelectAllText(); |
Lei Zhang | ee96772 | 2018-04-19 20:55:54 +0000 | [diff] [blame] | 179 | |
| 180 | virtual bool CanUndo(); |
| 181 | virtual bool CanRedo(); |
| 182 | virtual bool Undo(); |
| 183 | virtual bool Redo(); |
| 184 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 185 | virtual CFX_FloatRect GetFocusRect() const; |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 186 | virtual CFX_FloatRect GetClientRect() const; |
Dan Sinclair | 90b7326 | 2017-02-23 14:38:48 -0500 | [diff] [blame] | 187 | |
Tom Sepez | 9590dee | 2018-10-26 22:08:43 +0000 | [diff] [blame] | 188 | void AddChild(std::unique_ptr<CPWL_Wnd> pWnd); |
Tom Sepez | 7df950a | 2018-10-26 19:42:40 +0000 | [diff] [blame] | 189 | void RemoveChild(CPWL_Wnd* pWnd); |
Tom Sepez | b7c4a02 | 2018-10-26 23:56:27 +0000 | [diff] [blame] | 190 | void Realize(); |
Dan Sinclair | 90b7326 | 2017-02-23 14:38:48 -0500 | [diff] [blame] | 191 | void Destroy(); |
Henrique Nakashima | 55469ae | 2017-10-04 11:08:45 -0400 | [diff] [blame] | 192 | bool Move(const CFX_FloatRect& rcNew, bool bReset, bool bRefresh); |
Dan Sinclair | 90b7326 | 2017-02-23 14:38:48 -0500 | [diff] [blame] | 193 | |
Tom Sepez | 7df950a | 2018-10-26 19:42:40 +0000 | [diff] [blame] | 194 | void InvalidateFocusHandler(FocusHandlerIface* handler); |
| 195 | void InvalidateProvider(ProviderIface* provider); |
Dan Sinclair | 90b7326 | 2017-02-23 14:38:48 -0500 | [diff] [blame] | 196 | void SetCapture(); |
| 197 | void ReleaseCapture(); |
Lei Zhang | eb14e04 | 2017-08-15 13:56:43 -0700 | [diff] [blame] | 198 | void DrawAppearance(CFX_RenderDevice* pDevice, |
| 199 | const CFX_Matrix& mtUser2Device); |
Dan Sinclair | 90b7326 | 2017-02-23 14:38:48 -0500 | [diff] [blame] | 200 | |
Dan Sinclair | 7f55a54 | 2017-07-13 14:17:10 -0400 | [diff] [blame] | 201 | CFX_Color GetBackgroundColor() const; |
| 202 | void SetBackgroundColor(const CFX_Color& color); |
| 203 | CFX_Color GetBorderColor() const; |
| 204 | CFX_Color GetTextColor() const; |
| 205 | void SetTextColor(const CFX_Color& color); |
| 206 | CFX_Color GetBorderLeftTopColor(BorderStyle nBorderStyle) const; |
| 207 | CFX_Color GetBorderRightBottomColor(BorderStyle nBorderStyle) const; |
Dan Sinclair | 90b7326 | 2017-02-23 14:38:48 -0500 | [diff] [blame] | 208 | |
Andrew Weintraub | ce4e27f | 2019-06-13 18:49:18 +0000 | [diff] [blame] | 209 | void SetBorderStyle(BorderStyle nBorderStyle); |
Dan Sinclair | 90b7326 | 2017-02-23 14:38:48 -0500 | [diff] [blame] | 210 | BorderStyle GetBorderStyle() const; |
| 211 | const CPWL_Dash& GetBorderDash() const; |
| 212 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 213 | int32_t GetBorderWidth() const; |
Dan Sinclair | 90b7326 | 2017-02-23 14:38:48 -0500 | [diff] [blame] | 214 | int32_t GetInnerBorderWidth() const; |
| 215 | CFX_FloatRect GetWindowRect() const; |
| 216 | CFX_PointF GetCenterPoint() const; |
| 217 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 218 | bool IsVisible() const { return m_bVisible; } |
| 219 | bool HasFlag(uint32_t dwFlags) const; |
tsepez | c3255f5 | 2016-03-25 14:52:27 -0700 | [diff] [blame] | 220 | void AddFlag(uint32_t dwFlags); |
| 221 | void RemoveFlag(uint32_t dwFlags); |
Dan Sinclair | 90b7326 | 2017-02-23 14:38:48 -0500 | [diff] [blame] | 222 | |
| 223 | void SetClipRect(const CFX_FloatRect& rect); |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 224 | const CFX_FloatRect& GetClipRect() const; |
Dan Sinclair | 90b7326 | 2017-02-23 14:38:48 -0500 | [diff] [blame] | 225 | |
Tom Sepez | 8fba261 | 2018-10-26 21:27:41 +0000 | [diff] [blame] | 226 | CPWL_Wnd* GetParentWindow() const { return m_pParent.Get(); } |
Tom Sepez | ea9130d | 2019-08-06 21:55:57 +0000 | [diff] [blame] | 227 | const IPWL_SystemHandler::PerWindowData* GetAttachedData() const { |
| 228 | return m_pAttachedData.get(); |
| 229 | } |
| 230 | std::unique_ptr<IPWL_SystemHandler::PerWindowData> CloneAttachedData() const; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 231 | |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame] | 232 | bool WndHitTest(const CFX_PointF& point) const; |
| 233 | bool ClientHitTest(const CFX_PointF& point) const; |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 234 | bool IsCaptureMouse() const; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 235 | |
Dan Sinclair | 90b7326 | 2017-02-23 14:38:48 -0500 | [diff] [blame] | 236 | void EnableWindow(bool bEnable); |
| 237 | bool IsEnabled() const { return m_bEnabled; } |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 238 | const CPWL_Wnd* GetFocused() const; |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 239 | bool IsFocused() const; |
| 240 | bool IsReadOnly() const; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 241 | CPWL_ScrollBar* GetVScrollBar() const; |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 242 | |
Tom Sepez | 5b63fd9 | 2018-08-20 20:27:01 +0000 | [diff] [blame] | 243 | IPVT_FontMap* GetFontMap() const { return m_CreationParams.pFontMap.Get(); } |
| 244 | ProviderIface* GetProvider() const { |
| 245 | return m_CreationParams.pProvider.Get(); |
| 246 | } |
| 247 | FocusHandlerIface* GetFocusHandler() const { |
| 248 | return m_CreationParams.pFocusHandler.Get(); |
| 249 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 250 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 251 | int32_t GetTransparency(); |
| 252 | void SetTransparency(int32_t nTransparency); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 253 | |
Tom Sepez | 60d909e | 2015-12-10 15:34:55 -0800 | [diff] [blame] | 254 | CFX_Matrix GetChildToRoot() const; |
| 255 | CFX_Matrix GetChildMatrix() const; |
| 256 | void SetChildMatrix(const CFX_Matrix& mt); |
| 257 | CFX_Matrix GetWindowMatrix() const; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 258 | |
Dan Sinclair | 6dc4fb8 | 2017-10-17 09:08:26 -0400 | [diff] [blame] | 259 | virtual void OnSetFocus(); |
| 260 | virtual void OnKillFocus(); |
Dan Sinclair | 90b7326 | 2017-02-23 14:38:48 -0500 | [diff] [blame] | 261 | |
Dan Sinclair | 6dc4fb8 | 2017-10-17 09:08:26 -0400 | [diff] [blame] | 262 | protected: |
Tom Sepez | bf15730 | 2017-09-15 13:26:32 -0700 | [diff] [blame] | 263 | virtual void CreateChildWnd(const CreateParams& cp); |
Henrique Nakashima | 55469ae | 2017-10-04 11:08:45 -0400 | [diff] [blame] | 264 | |
| 265 | // Returns |true| iff this instance is still allocated. |
| 266 | virtual bool RePosChildWnd(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 267 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 268 | virtual void DrawThisAppearance(CFX_RenderDevice* pDevice, |
Lei Zhang | eb14e04 | 2017-08-15 13:56:43 -0700 | [diff] [blame] | 269 | const CFX_Matrix& mtUser2Device); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 270 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 271 | virtual void OnCreated(); |
| 272 | virtual void OnDestroy(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 273 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 274 | bool IsNotifying() const { return m_bNotifying; } |
Tom Sepez | bf15730 | 2017-09-15 13:26:32 -0700 | [diff] [blame] | 275 | bool IsValid() const { return m_bCreated; } |
Tom Sepez | ea08d17 | 2018-10-29 17:29:06 +0000 | [diff] [blame] | 276 | CreateParams* GetCreationParams() { return &m_CreationParams; } |
Tom Sepez | 8a5699d | 2020-10-13 21:23:53 +0000 | [diff] [blame] | 277 | CFX_Timer::HandlerIface* GetTimerHandler() const { |
Tom Sepez | 7c2d110 | 2019-08-07 22:25:50 +0000 | [diff] [blame] | 278 | return m_CreationParams.pTimerHandler.Get(); |
| 279 | } |
Tom Sepez | 9fb0595 | 2019-08-06 22:33:54 +0000 | [diff] [blame] | 280 | IPWL_SystemHandler* GetSystemHandler() const { |
| 281 | return m_CreationParams.pSystemHandler.Get(); |
| 282 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 283 | |
Henrique Nakashima | 55469ae | 2017-10-04 11:08:45 -0400 | [diff] [blame] | 284 | // Returns |true| iff this instance is still allocated. |
| 285 | bool InvalidateRectMove(const CFX_FloatRect& rcOld, |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 286 | const CFX_FloatRect& rcNew); |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 287 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 288 | bool IsWndCaptureMouse(const CPWL_Wnd* pWnd) const; |
| 289 | bool IsWndCaptureKeyboard(const CPWL_Wnd* pWnd) const; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 290 | |
Lei Zhang | 60fa2fc | 2017-07-21 17:42:19 -0700 | [diff] [blame] | 291 | static bool IsCTRLpressed(uint32_t nFlag) { |
Tom Sepez | 43f012f | 2019-08-02 16:16:46 +0000 | [diff] [blame] | 292 | return CPWL_Wnd::IsCTRLKeyDown(nFlag); |
Lei Zhang | 60fa2fc | 2017-07-21 17:42:19 -0700 | [diff] [blame] | 293 | } |
| 294 | static bool IsSHIFTpressed(uint32_t nFlag) { |
Tom Sepez | 43f012f | 2019-08-02 16:16:46 +0000 | [diff] [blame] | 295 | return CPWL_Wnd::IsSHIFTKeyDown(nFlag); |
Lei Zhang | 60fa2fc | 2017-07-21 17:42:19 -0700 | [diff] [blame] | 296 | } |
| 297 | static bool IsALTpressed(uint32_t nFlag) { |
Tom Sepez | 43f012f | 2019-08-02 16:16:46 +0000 | [diff] [blame] | 298 | return CPWL_Wnd::IsALTKeyDown(nFlag); |
Lei Zhang | 60fa2fc | 2017-07-21 17:42:19 -0700 | [diff] [blame] | 299 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 300 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 301 | private: |
Dan Sinclair | 90b7326 | 2017-02-23 14:38:48 -0500 | [diff] [blame] | 302 | CFX_PointF ParentToChild(const CFX_PointF& point) const; |
| 303 | CFX_FloatRect ParentToChild(const CFX_FloatRect& rect) const; |
| 304 | |
Lei Zhang | eb14e04 | 2017-08-15 13:56:43 -0700 | [diff] [blame] | 305 | void DrawChildAppearance(CFX_RenderDevice* pDevice, |
| 306 | const CFX_Matrix& mtUser2Device); |
Dan Sinclair | 90b7326 | 2017-02-23 14:38:48 -0500 | [diff] [blame] | 307 | |
Lei Zhang | 77f9bff | 2017-08-29 11:34:12 -0700 | [diff] [blame] | 308 | CFX_FloatRect PWLtoWnd(const CFX_FloatRect& rect) const; |
Dan Sinclair | 1f403ce | 2017-02-21 12:56:24 -0500 | [diff] [blame] | 309 | |
Tom Sepez | bf15730 | 2017-09-15 13:26:32 -0700 | [diff] [blame] | 310 | void CreateScrollBar(const CreateParams& cp); |
| 311 | void CreateVScrollBar(const CreateParams& cp); |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 312 | |
Lei Zhang | 62b2e91 | 2015-08-14 21:49:19 -0700 | [diff] [blame] | 313 | void AdjustStyle(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 314 | void CreateMsgControl(); |
| 315 | void DestroyMsgControl(); |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 316 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 317 | CPWL_MsgControl* GetMsgControl() const; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 318 | |
Tom Sepez | bf15730 | 2017-09-15 13:26:32 -0700 | [diff] [blame] | 319 | CreateParams m_CreationParams; |
Tom Sepez | ea9130d | 2019-08-06 21:55:57 +0000 | [diff] [blame] | 320 | std::unique_ptr<IPWL_SystemHandler::PerWindowData> m_pAttachedData; |
Tom Sepez | 8fba261 | 2018-10-26 21:27:41 +0000 | [diff] [blame] | 321 | UnownedPtr<CPWL_Wnd> m_pParent; |
Tom Sepez | a9a582b | 2018-10-26 23:04:45 +0000 | [diff] [blame] | 322 | std::vector<std::unique_ptr<CPWL_Wnd>> m_Children; |
Dan Sinclair | aee0db0 | 2017-09-21 16:53:58 -0400 | [diff] [blame] | 323 | UnownedPtr<CPWL_ScrollBar> m_pVScrollBar; |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 324 | CFX_FloatRect m_rcWindow; |
| 325 | CFX_FloatRect m_rcClip; |
Tom Sepez | 6fe32f8 | 2018-10-25 23:25:58 +0000 | [diff] [blame] | 326 | bool m_bCreated = false; |
| 327 | bool m_bVisible = false; |
| 328 | bool m_bNotifying = false; |
| 329 | bool m_bEnabled = true; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 330 | }; |
| 331 | |
Dan Sinclair | c411eb9 | 2017-07-25 09:39:30 -0400 | [diff] [blame] | 332 | #endif // FPDFSDK_PWL_CPWL_WND_H_ |