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 | 89e904b | 2016-03-23 19:29:15 -0400 | [diff] [blame] | 7 | #ifndef FPDFSDK_PDFWINDOW_PWL_WND_H_ |
| 8 | #define FPDFSDK_PDFWINDOW_PWL_WND_H_ |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 9 | |
weili | 2d5b020 | 2016-08-03 11:06:49 -0700 | [diff] [blame] | 10 | #include <memory> |
Tom Sepez | ab27768 | 2016-02-17 10:07:21 -0800 | [diff] [blame] | 11 | #include <vector> |
| 12 | |
dsinclair | 1727aee | 2016-09-29 13:12:56 -0700 | [diff] [blame] | 13 | #include "core/fpdfdoc/cpdf_formcontrol.h" |
Dan Sinclair | bc8dcc3 | 2017-01-19 13:53:02 -0500 | [diff] [blame] | 14 | #include "core/fxcrt/cfx_observable.h" |
dsinclair | a52ab74 | 2016-09-29 13:59:29 -0700 | [diff] [blame] | 15 | #include "core/fxcrt/fx_basic.h" |
dsinclair | b959010 | 2016-04-27 06:38:59 -0700 | [diff] [blame] | 16 | #include "fpdfsdk/cfx_systemhandler.h" |
Dan Sinclair | bc8dcc3 | 2017-01-19 13:53:02 -0500 | [diff] [blame] | 17 | #include "fpdfsdk/cpdfsdk_widget.h" |
| 18 | #include "fpdfsdk/pdfwindow/cpwl_color.h" |
Tom Sepez | 870292c | 2015-04-07 16:12:46 -0700 | [diff] [blame] | 19 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 20 | class CPWL_MsgControl; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 21 | class CPWL_ScrollBar; |
| 22 | class CPWL_Timer; |
| 23 | class CPWL_TimerHandler; |
Tom Sepez | 870292c | 2015-04-07 16:12:46 -0700 | [diff] [blame] | 24 | class CPWL_Wnd; |
dsinclair | b959010 | 2016-04-27 06:38:59 -0700 | [diff] [blame] | 25 | class CFX_SystemHandler; |
dsinclair | c7a7349 | 2016-04-05 12:01:42 -0700 | [diff] [blame] | 26 | class IPVT_FontMap; |
Tom Sepez | 870292c | 2015-04-07 16:12:46 -0700 | [diff] [blame] | 27 | class IPWL_Provider; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 28 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 29 | // 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 41 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 42 | // 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-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 | // listbox styles |
| 61 | #define PLBS_MULTIPLESEL 0x0001L |
| 62 | #define PLBS_HOVERSEL 0x0008L |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 63 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 64 | // combobox styles |
| 65 | #define PCBS_ALLOWCUSTOMTEXT 0x0001L |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 66 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 67 | // richedit styles |
| 68 | #define PRES_MULTILINE 0x0001L |
| 69 | #define PRES_AUTORETURN 0x0002L |
| 70 | #define PRES_AUTOSCROLL 0x0004L |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 71 | #define PRES_UNDO 0x0100L |
| 72 | #define PRES_MULTIPAGES 0x0200L |
| 73 | #define PRES_TEXTOVERFLOW 0x0400L |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 74 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 75 | // 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 88 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 89 | #define PWL_CLASSNAME_EDIT "CPWL_Edit" |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 90 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 91 | struct CPWL_Dash { |
weili | 625ad66 | 2016-06-15 11:21:33 -0700 | [diff] [blame] | 92 | CPWL_Dash() : nDash(0), nGap(0), nPhase(0) {} |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 93 | CPWL_Dash(int32_t dash, int32_t gap, int32_t phase) |
| 94 | : nDash(dash), nGap(gap), nPhase(phase) {} |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 95 | |
Dan Sinclair | bc8dcc3 | 2017-01-19 13:53:02 -0500 | [diff] [blame] | 96 | void Reset() { |
| 97 | nDash = 0; |
| 98 | nGap = 0; |
| 99 | nPhase = 0; |
| 100 | } |
| 101 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 102 | int32_t nDash; |
| 103 | int32_t nGap; |
| 104 | int32_t nPhase; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 105 | }; |
| 106 | |
Tom Sepez | 007e6c0 | 2016-02-26 14:31:56 -0800 | [diff] [blame] | 107 | inline bool operator==(const CPWL_Color& c1, const CPWL_Color& c2) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 108 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 115 | } |
| 116 | |
Tom Sepez | 007e6c0 | 2016-02-26 14:31:56 -0800 | [diff] [blame] | 117 | inline bool operator!=(const CPWL_Color& c1, const CPWL_Color& c2) { |
| 118 | return !(c1 == c2); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 119 | } |
| 120 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 121 | #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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 140 | |
Dan Sinclair | bc8dcc3 | 2017-01-19 13:53:02 -0500 | [diff] [blame] | 141 | class IPWL_Provider : public CFX_Observable<IPWL_Provider> { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 142 | public: |
| 143 | virtual ~IPWL_Provider() {} |
Tom Sepez | e5b59ca | 2015-01-09 11:46:17 -0800 | [diff] [blame] | 144 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 145 | // get a matrix which map user space to CWnd client space |
Tom Sepez | 60d909e | 2015-12-10 15:34:55 -0800 | [diff] [blame] | 146 | virtual CFX_Matrix GetWindowMatrix(void* pAttachedData) = 0; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 147 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 148 | /* |
| 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 158 | }; |
| 159 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 160 | class IPWL_FocusHandler { |
| 161 | public: |
| 162 | virtual ~IPWL_FocusHandler() {} |
| 163 | virtual void OnSetFocus(CPWL_Wnd* pWnd) = 0; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 164 | }; |
| 165 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 166 | struct PWL_CREATEPARAM { |
| 167 | public: |
weili | 625ad66 | 2016-06-15 11:21:33 -0700 | [diff] [blame] | 168 | PWL_CREATEPARAM(); |
| 169 | PWL_CREATEPARAM(const PWL_CREATEPARAM& other); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 170 | |
Dan Sinclair | bc8dcc3 | 2017-01-19 13:53:02 -0500 | [diff] [blame] | 171 | 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 Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 195 | CFX_FloatRect rcRectWnd; // required |
dsinclair | b959010 | 2016-04-27 06:38:59 -0700 | [diff] [blame] | 196 | CFX_SystemHandler* pSystemHandler; // required |
Dan Sinclair | bc8dcc3 | 2017-01-19 13:53:02 -0500 | [diff] [blame] | 197 | IPVT_FontMap* pFontMap; // required |
| 198 | IPWL_Provider::ObservedPtr pProvider; // required |
Nico Weber | 077f1a3 | 2015-08-06 15:08:57 -0700 | [diff] [blame] | 199 | IPWL_FocusHandler* pFocusHandler; // optional |
tsepez | c3255f5 | 2016-03-25 14:52:27 -0700 | [diff] [blame] | 200 | uint32_t dwFlags; // optional |
Nico Weber | 077f1a3 | 2015-08-06 15:08:57 -0700 | [diff] [blame] | 201 | CPWL_Color sBackgroundColor; // optional |
Dan Sinclair | bc8dcc3 | 2017-01-19 13:53:02 -0500 | [diff] [blame] | 202 | CPDFSDK_Widget::ObservedPtr pAttachedWidget; // required |
dsinclair | 92cb5e5 | 2016-05-16 11:38:28 -0700 | [diff] [blame] | 203 | BorderStyle nBorderStyle; // optional |
Nico Weber | 077f1a3 | 2015-08-06 15:08:57 -0700 | [diff] [blame] | 204 | 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 Sepez | 60d909e | 2015-12-10 15:34:55 -0800 | [diff] [blame] | 215 | CFX_Matrix mtChild; // ignore |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 216 | }; |
| 217 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 218 | class CPWL_Timer { |
| 219 | public: |
dsinclair | b959010 | 2016-04-27 06:38:59 -0700 | [diff] [blame] | 220 | CPWL_Timer(CPWL_TimerHandler* pAttached, CFX_SystemHandler* pSystemHandler); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 221 | virtual ~CPWL_Timer(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 222 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 223 | int32_t SetPWLTimer(int32_t nElapse); |
| 224 | void KillPWLTimer(); |
| 225 | static void TimerProc(int32_t idEvent); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 226 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 227 | private: |
| 228 | int32_t m_nTimerID; |
| 229 | CPWL_TimerHandler* m_pAttached; |
dsinclair | b959010 | 2016-04-27 06:38:59 -0700 | [diff] [blame] | 230 | CFX_SystemHandler* m_pSystemHandler; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 231 | }; |
| 232 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 233 | class CPWL_TimerHandler { |
| 234 | public: |
| 235 | CPWL_TimerHandler(); |
| 236 | virtual ~CPWL_TimerHandler(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 237 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 238 | void BeginTimer(int32_t nElapse); |
| 239 | void EndTimer(); |
| 240 | virtual void TimerProc(); |
dsinclair | b959010 | 2016-04-27 06:38:59 -0700 | [diff] [blame] | 241 | virtual CFX_SystemHandler* GetSystemHandler() const = 0; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 242 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 243 | private: |
weili | 2d5b020 | 2016-08-03 11:06:49 -0700 | [diff] [blame] | 244 | std::unique_ptr<CPWL_Timer> m_pTimer; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 245 | }; |
| 246 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 247 | class CPWL_Wnd : public CPWL_TimerHandler { |
| 248 | friend class CPWL_MsgControl; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 249 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 250 | public: |
| 251 | CPWL_Wnd(); |
Lei Zhang | 2b1a2d5 | 2015-08-14 22:16:22 -0700 | [diff] [blame] | 252 | ~CPWL_Wnd() override; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 253 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 254 | void Create(const PWL_CREATEPARAM& cp); |
| 255 | virtual CFX_ByteString GetClassName() const; |
Lei Zhang | ab5537d | 2016-01-06 14:58:14 -0800 | [diff] [blame] | 256 | void InvalidateFocusHandler(IPWL_FocusHandler* handler); |
| 257 | void InvalidateProvider(IPWL_Provider* provider); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 258 | void Destroy(); |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 259 | void Move(const CFX_FloatRect& rcNew, bool bReset, bool bRefresh); |
thestig | 1cd352e | 2016-06-07 17:53:06 -0700 | [diff] [blame] | 260 | virtual void InvalidateRect(CFX_FloatRect* pRect = nullptr); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 261 | |
Tom Sepez | 60d909e | 2015-12-10 15:34:55 -0800 | [diff] [blame] | 262 | void DrawAppearance(CFX_RenderDevice* pDevice, CFX_Matrix* pUser2Device); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 263 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 264 | 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 Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame^] | 267 | 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); |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 276 | virtual bool OnMouseWheel(short zDelta, |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame^] | 277 | const CFX_PointF& point, |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 278 | uint32_t nFlag); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 279 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 280 | virtual void SetFocus(); |
| 281 | virtual void KillFocus(); |
| 282 | void SetCapture(); |
| 283 | void ReleaseCapture(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 284 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 285 | virtual void OnNotify(CPWL_Wnd* pWnd, |
tsepez | c3255f5 | 2016-03-25 14:52:27 -0700 | [diff] [blame] | 286 | uint32_t msg, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 287 | 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); |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 291 | virtual void SetVisible(bool bVisible); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 292 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 293 | virtual CFX_FloatRect GetFocusRect() const; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 294 | 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; |
dsinclair | 92cb5e5 | 2016-05-16 11:38:28 -0700 | [diff] [blame] | 300 | virtual CPWL_Color GetBorderLeftTopColor(BorderStyle nBorderStyle) const; |
| 301 | virtual CPWL_Color GetBorderRightBottomColor(BorderStyle nBorderStyle) const; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 302 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 303 | virtual void SetFontSize(FX_FLOAT fFontSize); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 304 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 305 | void SetBackgroundColor(const CPWL_Color& color); |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 306 | void SetClipRect(const CFX_FloatRect& rect); |
dsinclair | 92cb5e5 | 2016-05-16 11:38:28 -0700 | [diff] [blame] | 307 | void SetBorderStyle(BorderStyle eBorderStyle); |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 308 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 309 | virtual CFX_FloatRect GetWindowRect() const; |
| 310 | virtual CFX_FloatRect GetClientRect() const; |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame^] | 311 | CFX_PointF GetCenterPoint() const; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 312 | int32_t GetBorderWidth() const; |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 313 | bool IsVisible() const { return m_bVisible; } |
| 314 | bool HasFlag(uint32_t dwFlags) const; |
tsepez | c3255f5 | 2016-03-25 14:52:27 -0700 | [diff] [blame] | 315 | void AddFlag(uint32_t dwFlags); |
| 316 | void RemoveFlag(uint32_t dwFlags); |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 317 | const CFX_FloatRect& GetClipRect() const; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 318 | CPWL_Wnd* GetParentWindow() const; |
dsinclair | 92cb5e5 | 2016-05-16 11:38:28 -0700 | [diff] [blame] | 319 | BorderStyle GetBorderStyle() const; |
Lei Zhang | 7457e38 | 2016-01-06 23:00:34 -0800 | [diff] [blame] | 320 | const CPWL_Dash& GetBorderDash() const; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 321 | void* GetAttachedData() const; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 322 | |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame^] | 323 | bool WndHitTest(const CFX_PointF& point) const; |
| 324 | bool ClientHitTest(const CFX_PointF& point) const; |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 325 | bool IsCaptureMouse() const; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 326 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 327 | const CPWL_Wnd* GetFocused() const; |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 328 | bool IsFocused() const; |
| 329 | bool IsReadOnly() const; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 330 | CPWL_ScrollBar* GetVScrollBar() const; |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 331 | |
dsinclair | c7a7349 | 2016-04-05 12:01:42 -0700 | [diff] [blame] | 332 | IPVT_FontMap* GetFontMap() const; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 333 | IPWL_Provider* GetProvider() const; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 334 | IPWL_FocusHandler* GetFocusHandler() const; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 335 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 336 | int32_t GetTransparency(); |
| 337 | void SetTransparency(int32_t nTransparency); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 338 | |
Tom Sepez | 60d909e | 2015-12-10 15:34:55 -0800 | [diff] [blame] | 339 | CFX_Matrix GetChildToRoot() const; |
| 340 | CFX_Matrix GetChildMatrix() const; |
| 341 | void SetChildMatrix(const CFX_Matrix& mt); |
| 342 | CFX_Matrix GetWindowMatrix() const; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 343 | |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame^] | 344 | virtual CFX_PointF ChildToParent(const CFX_PointF& point) const; |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 345 | virtual CFX_FloatRect ChildToParent(const CFX_FloatRect& rect) const; |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame^] | 346 | virtual CFX_PointF ParentToChild(const CFX_PointF& point) const; |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 347 | virtual CFX_FloatRect ParentToChild(const CFX_FloatRect& rect) const; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 348 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 349 | // those methods only implemented by listctrl item |
weili | 625ad66 | 2016-06-15 11:21:33 -0700 | [diff] [blame] | 350 | virtual FX_FLOAT GetItemHeight(FX_FLOAT fLimitWidth); |
| 351 | virtual FX_FLOAT GetItemLeftMargin(); |
| 352 | virtual FX_FLOAT GetItemRightMargin(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 353 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 354 | void EnableWindow(bool bEnable); |
| 355 | bool IsEnabled(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 356 | virtual void SetCursor(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 357 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 358 | protected: |
Lei Zhang | 2b1a2d5 | 2015-08-14 22:16:22 -0700 | [diff] [blame] | 359 | // CPWL_TimerHandler |
dsinclair | b959010 | 2016-04-27 06:38:59 -0700 | [diff] [blame] | 360 | CFX_SystemHandler* GetSystemHandler() const override; |
Lei Zhang | 2b1a2d5 | 2015-08-14 22:16:22 -0700 | [diff] [blame] | 361 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 362 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 367 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 368 | virtual void DrawThisAppearance(CFX_RenderDevice* pDevice, |
Tom Sepez | 60d909e | 2015-12-10 15:34:55 -0800 | [diff] [blame] | 369 | CFX_Matrix* pUser2Device); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 370 | virtual void DrawChildAppearance(CFX_RenderDevice* pDevice, |
Tom Sepez | 60d909e | 2015-12-10 15:34:55 -0800 | [diff] [blame] | 371 | CFX_Matrix* pUser2Device); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 372 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 373 | virtual void OnCreate(PWL_CREATEPARAM& cp); |
| 374 | virtual void OnCreated(); |
| 375 | virtual void OnDestroy(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 376 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 377 | virtual void OnSetFocus(); |
| 378 | virtual void OnKillFocus(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 379 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 380 | virtual void OnEnabled(); |
| 381 | virtual void OnDisabled(); |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 382 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 383 | void SetNotifyFlag(bool bNotifying = true) { m_bNotifying = bNotifying; } |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 384 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 385 | bool IsValid() const; |
Lei Zhang | 7457e38 | 2016-01-06 23:00:34 -0800 | [diff] [blame] | 386 | const PWL_CREATEPARAM& GetCreationParam() const; |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 387 | bool IsNotifying() const { return m_bNotifying; } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 388 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 389 | void InvalidateRectMove(const CFX_FloatRect& rcOld, |
| 390 | const CFX_FloatRect& rcNew); |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 391 | |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame^] | 392 | void PWLtoWnd(const CFX_PointF& point, int32_t& x, int32_t& y) const; |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 393 | FX_RECT PWLtoWnd(const CFX_FloatRect& rect) const; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 394 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 395 | bool IsWndCaptureMouse(const CPWL_Wnd* pWnd) const; |
| 396 | bool IsWndCaptureKeyboard(const CPWL_Wnd* pWnd) const; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 397 | const CPWL_Wnd* GetRootWnd() const; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 398 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 399 | bool IsCTRLpressed(uint32_t nFlag) const; |
| 400 | bool IsSHIFTpressed(uint32_t nFlag) const; |
| 401 | bool IsALTpressed(uint32_t nFlag) const; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 402 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 403 | private: |
| 404 | void AddChild(CPWL_Wnd* pWnd); |
| 405 | void RemoveChild(CPWL_Wnd* pWnd); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 406 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 407 | void CreateScrollBar(const PWL_CREATEPARAM& cp); |
| 408 | void CreateVScrollBar(const PWL_CREATEPARAM& cp); |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 409 | |
Lei Zhang | 62b2e91 | 2015-08-14 21:49:19 -0700 | [diff] [blame] | 410 | void AdjustStyle(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 411 | void CreateMsgControl(); |
| 412 | void DestroyMsgControl(); |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 413 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 414 | CPWL_MsgControl* GetMsgControl() const; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 415 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 416 | protected: |
tsepez | 6745f96 | 2017-01-04 10:09:45 -0800 | [diff] [blame] | 417 | std::vector<CPWL_Wnd*> m_Children; |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 418 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 419 | private: |
| 420 | PWL_CREATEPARAM m_sPrivateParam; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 421 | CPWL_ScrollBar* m_pVScrollBar; |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 422 | CFX_FloatRect m_rcWindow; |
| 423 | CFX_FloatRect m_rcClip; |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 424 | bool m_bCreated; |
| 425 | bool m_bVisible; |
| 426 | bool m_bNotifying; |
| 427 | bool m_bEnabled; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 428 | }; |
| 429 | |
dan sinclair | 89e904b | 2016-03-23 19:29:15 -0400 | [diff] [blame] | 430 | #endif // FPDFSDK_PDFWINDOW_PWL_WND_H_ |