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 | 60f507b | 2015-06-13 00:41:00 -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 | |
Lei Zhang | 606346f | 2015-06-19 18:11:07 -0700 | [diff] [blame] | 7 | #include <map> |
| 8 | |
Lei Zhang | bde53d2 | 2015-11-12 22:21:30 -0800 | [diff] [blame] | 9 | #include "fpdfsdk/include/pdfwindow/PWL_ScrollBar.h" |
| 10 | #include "fpdfsdk/include/pdfwindow/PWL_Utils.h" |
| 11 | #include "fpdfsdk/include/pdfwindow/PWL_Wnd.h" |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 12 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 13 | static std::map<int32_t, CPWL_Timer*>& GetPWLTimeMap() { |
Bruce Dawson | 26d96ff | 2015-01-05 15:31:49 -0800 | [diff] [blame] | 14 | // Leak the object at shutdown. |
Lei Zhang | 606346f | 2015-06-19 18:11:07 -0700 | [diff] [blame] | 15 | static auto timeMap = new std::map<int32_t, CPWL_Timer*>; |
Bruce Dawson | 26d96ff | 2015-01-05 15:31:49 -0800 | [diff] [blame] | 16 | return *timeMap; |
| 17 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 18 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 19 | CPWL_Timer::CPWL_Timer(CPWL_TimerHandler* pAttached, |
| 20 | IFX_SystemHandler* pSystemHandler) |
| 21 | : m_nTimerID(0), m_pAttached(pAttached), m_pSystemHandler(pSystemHandler) { |
Lei Zhang | 96660d6 | 2015-12-14 18:27:25 -0800 | [diff] [blame] | 22 | ASSERT(m_pAttached); |
| 23 | ASSERT(m_pSystemHandler); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 24 | } |
| 25 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 26 | CPWL_Timer::~CPWL_Timer() { |
| 27 | KillPWLTimer(); |
| 28 | } |
| 29 | |
| 30 | int32_t CPWL_Timer::SetPWLTimer(int32_t nElapse) { |
| 31 | if (m_nTimerID != 0) |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 32 | KillPWLTimer(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 33 | m_nTimerID = m_pSystemHandler->SetTimer(nElapse, TimerProc); |
| 34 | |
| 35 | GetPWLTimeMap()[m_nTimerID] = this; |
| 36 | return m_nTimerID; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 37 | } |
| 38 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 39 | void CPWL_Timer::KillPWLTimer() { |
| 40 | if (m_nTimerID == 0) |
| 41 | return; |
Lei Zhang | 606346f | 2015-06-19 18:11:07 -0700 | [diff] [blame] | 42 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 43 | m_pSystemHandler->KillTimer(m_nTimerID); |
| 44 | GetPWLTimeMap().erase(m_nTimerID); |
| 45 | m_nTimerID = 0; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 46 | } |
| 47 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 48 | void CPWL_Timer::TimerProc(int32_t idEvent) { |
| 49 | auto it = GetPWLTimeMap().find(idEvent); |
| 50 | if (it == GetPWLTimeMap().end()) |
| 51 | return; |
Lei Zhang | 606346f | 2015-06-19 18:11:07 -0700 | [diff] [blame] | 52 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 53 | CPWL_Timer* pTimer = it->second; |
| 54 | if (pTimer->m_pAttached) |
| 55 | pTimer->m_pAttached->TimerProc(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 56 | } |
| 57 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 58 | CPWL_TimerHandler::CPWL_TimerHandler() : m_pTimer(NULL) {} |
| 59 | |
| 60 | CPWL_TimerHandler::~CPWL_TimerHandler() { |
| 61 | delete m_pTimer; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 62 | } |
| 63 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 64 | void CPWL_TimerHandler::BeginTimer(int32_t nElapse) { |
| 65 | if (!m_pTimer) |
| 66 | m_pTimer = new CPWL_Timer(this, GetSystemHandler()); |
| 67 | |
| 68 | if (m_pTimer) |
| 69 | m_pTimer->SetPWLTimer(nElapse); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 70 | } |
| 71 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 72 | void CPWL_TimerHandler::EndTimer() { |
| 73 | if (m_pTimer) |
| 74 | m_pTimer->KillPWLTimer(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 75 | } |
| 76 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 77 | void CPWL_TimerHandler::TimerProc() {} |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 78 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 79 | class CPWL_MsgControl { |
| 80 | friend class CPWL_Wnd; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 81 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 82 | public: |
Lei Zhang | c2fb35f | 2016-01-05 16:46:58 -0800 | [diff] [blame] | 83 | explicit CPWL_MsgControl(CPWL_Wnd* pWnd) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 84 | m_pCreatedWnd = pWnd; |
| 85 | Default(); |
| 86 | } |
| 87 | |
| 88 | ~CPWL_MsgControl() { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 89 | Default(); |
| 90 | } |
| 91 | |
| 92 | void Default() { |
| 93 | m_aMousePath.RemoveAll(); |
| 94 | m_aKeyboardPath.RemoveAll(); |
| 95 | m_pMainMouseWnd = NULL; |
| 96 | m_pMainKeyboardWnd = NULL; |
| 97 | } |
| 98 | |
| 99 | FX_BOOL IsWndCreated(const CPWL_Wnd* pWnd) const { |
| 100 | return m_pCreatedWnd == pWnd; |
| 101 | } |
| 102 | |
| 103 | FX_BOOL IsMainCaptureMouse(const CPWL_Wnd* pWnd) const { |
| 104 | return pWnd == m_pMainMouseWnd; |
| 105 | } |
| 106 | |
| 107 | FX_BOOL IsWndCaptureMouse(const CPWL_Wnd* pWnd) const { |
Lei Zhang | c2fb35f | 2016-01-05 16:46:58 -0800 | [diff] [blame] | 108 | if (pWnd) { |
| 109 | for (int32_t i = 0, sz = m_aMousePath.GetSize(); i < sz; i++) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 110 | if (m_aMousePath.GetAt(i) == pWnd) |
| 111 | return TRUE; |
Lei Zhang | c2fb35f | 2016-01-05 16:46:58 -0800 | [diff] [blame] | 112 | } |
| 113 | } |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 114 | |
| 115 | return FALSE; |
| 116 | } |
| 117 | |
| 118 | FX_BOOL IsMainCaptureKeyboard(const CPWL_Wnd* pWnd) const { |
| 119 | return pWnd == m_pMainKeyboardWnd; |
| 120 | } |
| 121 | |
| 122 | FX_BOOL IsWndCaptureKeyboard(const CPWL_Wnd* pWnd) const { |
Lei Zhang | c2fb35f | 2016-01-05 16:46:58 -0800 | [diff] [blame] | 123 | if (pWnd) { |
| 124 | for (int32_t i = 0, sz = m_aKeyboardPath.GetSize(); i < sz; i++) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 125 | if (m_aKeyboardPath.GetAt(i) == pWnd) |
| 126 | return TRUE; |
Lei Zhang | c2fb35f | 2016-01-05 16:46:58 -0800 | [diff] [blame] | 127 | } |
| 128 | } |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 129 | |
| 130 | return FALSE; |
| 131 | } |
| 132 | |
| 133 | void SetFocus(CPWL_Wnd* pWnd) { |
| 134 | m_aKeyboardPath.RemoveAll(); |
| 135 | |
| 136 | if (pWnd) { |
| 137 | m_pMainKeyboardWnd = pWnd; |
| 138 | |
| 139 | CPWL_Wnd* pParent = pWnd; |
| 140 | while (pParent) { |
| 141 | m_aKeyboardPath.Add(pParent); |
| 142 | pParent = pParent->GetParentWindow(); |
| 143 | } |
| 144 | |
| 145 | pWnd->OnSetFocus(); |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 146 | } |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 147 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 148 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 149 | void KillFocus() { |
| 150 | if (m_aKeyboardPath.GetSize() > 0) |
| 151 | if (CPWL_Wnd* pWnd = m_aKeyboardPath.GetAt(0)) |
| 152 | pWnd->OnKillFocus(); |
| 153 | |
| 154 | m_pMainKeyboardWnd = NULL; |
| 155 | m_aKeyboardPath.RemoveAll(); |
| 156 | } |
| 157 | |
| 158 | void SetCapture(CPWL_Wnd* pWnd) { |
| 159 | m_aMousePath.RemoveAll(); |
| 160 | |
| 161 | if (pWnd) { |
| 162 | m_pMainMouseWnd = pWnd; |
| 163 | |
| 164 | CPWL_Wnd* pParent = pWnd; |
| 165 | while (pParent) { |
| 166 | m_aMousePath.Add(pParent); |
| 167 | pParent = pParent->GetParentWindow(); |
| 168 | } |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 169 | } |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 170 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 171 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 172 | void ReleaseCapture() { |
| 173 | m_pMainMouseWnd = NULL; |
| 174 | m_aMousePath.RemoveAll(); |
| 175 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 176 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 177 | private: |
| 178 | CFX_ArrayTemplate<CPWL_Wnd*> m_aMousePath; |
| 179 | CFX_ArrayTemplate<CPWL_Wnd*> m_aKeyboardPath; |
| 180 | CPWL_Wnd* m_pCreatedWnd; |
| 181 | CPWL_Wnd* m_pMainMouseWnd; |
| 182 | CPWL_Wnd* m_pMainKeyboardWnd; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 183 | }; |
| 184 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 185 | CPWL_Wnd::CPWL_Wnd() |
| 186 | : m_pVScrollBar(NULL), |
| 187 | m_rcWindow(), |
| 188 | m_rcClip(), |
| 189 | m_bCreated(FALSE), |
| 190 | m_bVisible(FALSE), |
| 191 | m_bNotifying(FALSE), |
| 192 | m_bEnabled(TRUE) {} |
| 193 | |
| 194 | CPWL_Wnd::~CPWL_Wnd() { |
| 195 | ASSERT(m_bCreated == FALSE); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 196 | } |
| 197 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 198 | CFX_ByteString CPWL_Wnd::GetClassName() const { |
| 199 | return "CPWL_Wnd"; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 200 | } |
| 201 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 202 | void CPWL_Wnd::Create(const PWL_CREATEPARAM& cp) { |
| 203 | if (!IsValid()) { |
| 204 | m_sPrivateParam = cp; |
| 205 | |
| 206 | OnCreate(m_sPrivateParam); |
| 207 | |
| 208 | m_sPrivateParam.rcRectWnd.Normalize(); |
| 209 | m_rcWindow = m_sPrivateParam.rcRectWnd; |
| 210 | m_rcClip = CPWL_Utils::InflateRect(m_rcWindow, 1.0f); |
| 211 | |
| 212 | CreateMsgControl(); |
| 213 | |
| 214 | if (m_sPrivateParam.pParentWnd) |
| 215 | m_sPrivateParam.pParentWnd->OnNotify(this, PNM_ADDCHILD); |
| 216 | |
| 217 | PWL_CREATEPARAM ccp = m_sPrivateParam; |
| 218 | |
| 219 | ccp.dwFlags &= 0xFFFF0000L; // remove sub styles |
Tom Sepez | 60d909e | 2015-12-10 15:34:55 -0800 | [diff] [blame] | 220 | ccp.mtChild = CFX_Matrix(1, 0, 0, 1, 0, 0); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 221 | |
| 222 | CreateScrollBar(ccp); |
| 223 | CreateChildWnd(ccp); |
| 224 | |
| 225 | m_bVisible = HasFlag(PWS_VISIBLE); |
| 226 | |
| 227 | OnCreated(); |
| 228 | |
| 229 | RePosChildWnd(); |
| 230 | m_bCreated = TRUE; |
| 231 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 232 | } |
| 233 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 234 | void CPWL_Wnd::OnCreate(PWL_CREATEPARAM& cp) {} |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 235 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 236 | void CPWL_Wnd::OnCreated() {} |
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 CPWL_Wnd::OnDestroy() {} |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 239 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 240 | void CPWL_Wnd::Destroy() { |
| 241 | KillFocus(); |
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 | OnDestroy(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 244 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 245 | if (m_bCreated) { |
| 246 | for (int32_t i = m_aChildren.GetSize() - 1; i >= 0; i--) { |
| 247 | if (CPWL_Wnd* pChild = m_aChildren[i]) { |
| 248 | pChild->Destroy(); |
| 249 | delete pChild; |
| 250 | pChild = NULL; |
| 251 | } |
| 252 | } |
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 | if (m_sPrivateParam.pParentWnd) |
| 255 | m_sPrivateParam.pParentWnd->OnNotify(this, PNM_REMOVECHILD); |
| 256 | m_bCreated = FALSE; |
| 257 | } |
Lei Zhang | 60f507b | 2015-06-13 00:41:00 -0700 | [diff] [blame] | 258 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 259 | DestroyMsgControl(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 260 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 261 | FXSYS_memset(&m_sPrivateParam, 0, sizeof(PWL_CREATEPARAM)); |
| 262 | m_aChildren.RemoveAll(); |
| 263 | m_pVScrollBar = NULL; |
| 264 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 265 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 266 | void CPWL_Wnd::Move(const CPDF_Rect& rcNew, FX_BOOL bReset, FX_BOOL bRefresh) { |
| 267 | if (IsValid()) { |
| 268 | CPDF_Rect rcOld = GetWindowRect(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 269 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 270 | m_rcWindow = rcNew; |
| 271 | m_rcWindow.Normalize(); |
| 272 | |
| 273 | if (rcOld.left != rcNew.left || rcOld.right != rcNew.right || |
| 274 | rcOld.top != rcNew.top || rcOld.bottom != rcNew.bottom) { |
| 275 | if (bReset) { |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 276 | RePosChildWnd(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 277 | } |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 278 | } |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 279 | if (bRefresh) { |
| 280 | InvalidateRectMove(rcOld, rcNew); |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 281 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 282 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 283 | m_sPrivateParam.rcRectWnd = m_rcWindow; |
| 284 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 285 | } |
| 286 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 287 | void CPWL_Wnd::InvalidateRectMove(const CPDF_Rect& rcOld, |
| 288 | const CPDF_Rect& rcNew) { |
| 289 | CPDF_Rect rcUnion = rcOld; |
| 290 | rcUnion.Union(rcNew); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 291 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 292 | InvalidateRect(&rcUnion); |
| 293 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 294 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 295 | void CPWL_Wnd::GetAppearanceStream(CFX_ByteString& sAppStream) { |
| 296 | if (IsValid()) { |
| 297 | CFX_ByteTextBuf sTextBuf; |
| 298 | GetAppearanceStream(sTextBuf); |
| 299 | sAppStream += sTextBuf.GetByteString(); |
| 300 | } |
| 301 | } |
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 | void CPWL_Wnd::GetAppearanceStream(CFX_ByteTextBuf& sAppStream) { |
| 304 | if (IsValid() && IsVisible()) { |
| 305 | GetThisAppearanceStream(sAppStream); |
| 306 | GetChildAppearanceStream(sAppStream); |
| 307 | } |
| 308 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 309 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 310 | // if don't set,Get default apperance stream |
| 311 | void CPWL_Wnd::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) { |
| 312 | CPDF_Rect rectWnd = GetWindowRect(); |
| 313 | if (!rectWnd.IsEmpty()) { |
| 314 | CFX_ByteTextBuf sThis; |
| 315 | |
| 316 | if (HasFlag(PWS_BACKGROUND)) |
| 317 | sThis << CPWL_Utils::GetRectFillAppStream(rectWnd, GetBackgroundColor()); |
| 318 | |
| 319 | if (HasFlag(PWS_BORDER)) { |
| 320 | sThis << CPWL_Utils::GetBorderAppStream( |
| 321 | rectWnd, (FX_FLOAT)GetBorderWidth(), GetBorderColor(), |
| 322 | GetBorderLeftTopColor(GetBorderStyle()), |
| 323 | GetBorderRightBottomColor(GetBorderStyle()), GetBorderStyle(), |
| 324 | GetBorderDash()); |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 325 | } |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 326 | |
| 327 | sAppStream << sThis; |
| 328 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 329 | } |
| 330 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 331 | void CPWL_Wnd::GetChildAppearanceStream(CFX_ByteTextBuf& sAppStream) { |
| 332 | for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) { |
| 333 | if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) { |
| 334 | pChild->GetAppearanceStream(sAppStream); |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 335 | } |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 336 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 337 | } |
| 338 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 339 | void CPWL_Wnd::DrawAppearance(CFX_RenderDevice* pDevice, |
Tom Sepez | 60d909e | 2015-12-10 15:34:55 -0800 | [diff] [blame] | 340 | CFX_Matrix* pUser2Device) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 341 | if (IsValid() && IsVisible()) { |
| 342 | DrawThisAppearance(pDevice, pUser2Device); |
| 343 | DrawChildAppearance(pDevice, pUser2Device); |
| 344 | } |
| 345 | } |
| 346 | |
| 347 | void CPWL_Wnd::DrawThisAppearance(CFX_RenderDevice* pDevice, |
Tom Sepez | 60d909e | 2015-12-10 15:34:55 -0800 | [diff] [blame] | 348 | CFX_Matrix* pUser2Device) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 349 | CPDF_Rect rectWnd = GetWindowRect(); |
| 350 | if (!rectWnd.IsEmpty()) { |
| 351 | if (HasFlag(PWS_BACKGROUND)) { |
| 352 | CPDF_Rect rcClient = CPWL_Utils::DeflateRect( |
| 353 | rectWnd, (FX_FLOAT)(GetBorderWidth() + GetInnerBorderWidth())); |
| 354 | CPWL_Utils::DrawFillRect(pDevice, pUser2Device, rcClient, |
| 355 | GetBackgroundColor(), GetTransparency()); |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 356 | } |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 357 | |
| 358 | if (HasFlag(PWS_BORDER)) |
| 359 | CPWL_Utils::DrawBorder( |
| 360 | pDevice, pUser2Device, rectWnd, (FX_FLOAT)GetBorderWidth(), |
| 361 | GetBorderColor(), GetBorderLeftTopColor(GetBorderStyle()), |
| 362 | GetBorderRightBottomColor(GetBorderStyle()), GetBorderStyle(), |
| 363 | GetBorderDash(), GetTransparency()); |
| 364 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 365 | } |
| 366 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 367 | void CPWL_Wnd::DrawChildAppearance(CFX_RenderDevice* pDevice, |
Tom Sepez | 60d909e | 2015-12-10 15:34:55 -0800 | [diff] [blame] | 368 | CFX_Matrix* pUser2Device) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 369 | for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) { |
| 370 | if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) { |
Tom Sepez | 60d909e | 2015-12-10 15:34:55 -0800 | [diff] [blame] | 371 | CFX_Matrix mt = pChild->GetChildMatrix(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 372 | if (mt.IsIdentity()) { |
| 373 | pChild->DrawAppearance(pDevice, pUser2Device); |
| 374 | } else { |
| 375 | mt.Concat(*pUser2Device); |
| 376 | pChild->DrawAppearance(pDevice, &mt); |
| 377 | } |
Lei Zhang | 60f507b | 2015-06-13 00:41:00 -0700 | [diff] [blame] | 378 | } |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 379 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 380 | } |
| 381 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 382 | void CPWL_Wnd::InvalidateRect(CPDF_Rect* pRect) { |
| 383 | if (IsValid()) { |
| 384 | CPDF_Rect rcRefresh = pRect ? *pRect : GetWindowRect(); |
| 385 | |
| 386 | if (!HasFlag(PWS_NOREFRESHCLIP)) { |
| 387 | CPDF_Rect rcClip = GetClipRect(); |
| 388 | if (!rcClip.IsEmpty()) { |
| 389 | rcRefresh.Intersect(rcClip); |
| 390 | } |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 391 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 392 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 393 | FX_RECT rcWin = PWLtoWnd(rcRefresh); |
| 394 | rcWin.left -= PWL_INVALIDATE_INFLATE; |
| 395 | rcWin.top -= PWL_INVALIDATE_INFLATE; |
| 396 | rcWin.right += PWL_INVALIDATE_INFLATE; |
| 397 | rcWin.bottom += PWL_INVALIDATE_INFLATE; |
| 398 | |
| 399 | if (IFX_SystemHandler* pSH = GetSystemHandler()) { |
| 400 | if (FX_HWND hWnd = GetAttachedHWnd()) { |
| 401 | pSH->InvalidateRect(hWnd, rcWin); |
| 402 | } |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 403 | } |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 404 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 405 | } |
| 406 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 407 | #define PWL_IMPLEMENT_KEY_METHOD(key_method_name) \ |
| 408 | FX_BOOL CPWL_Wnd::key_method_name(FX_WORD nChar, FX_DWORD nFlag) { \ |
| 409 | if (IsValid() && IsVisible() && IsEnabled()) { \ |
| 410 | if (IsWndCaptureKeyboard(this)) { \ |
| 411 | for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) { \ |
| 412 | if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) { \ |
| 413 | if (IsWndCaptureKeyboard(pChild)) { \ |
| 414 | return pChild->key_method_name(nChar, nFlag); \ |
| 415 | } \ |
| 416 | } \ |
| 417 | } \ |
| 418 | } \ |
| 419 | } \ |
| 420 | return FALSE; \ |
| 421 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 422 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 423 | #define PWL_IMPLEMENT_MOUSE_METHOD(mouse_method_name) \ |
| 424 | FX_BOOL CPWL_Wnd::mouse_method_name(const CPDF_Point& point, \ |
| 425 | FX_DWORD nFlag) { \ |
| 426 | if (IsValid() && IsVisible() && IsEnabled()) { \ |
| 427 | if (IsWndCaptureMouse(this)) { \ |
| 428 | for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) { \ |
| 429 | if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) { \ |
| 430 | if (IsWndCaptureMouse(pChild)) { \ |
| 431 | return pChild->mouse_method_name(pChild->ParentToChild(point), \ |
| 432 | nFlag); \ |
| 433 | } \ |
| 434 | } \ |
| 435 | } \ |
| 436 | SetCursor(); \ |
| 437 | } else { \ |
| 438 | for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) { \ |
| 439 | if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) { \ |
| 440 | if (pChild->WndHitTest(pChild->ParentToChild(point))) { \ |
| 441 | return pChild->mouse_method_name(pChild->ParentToChild(point), \ |
| 442 | nFlag); \ |
| 443 | } \ |
| 444 | } \ |
| 445 | } \ |
| 446 | if (WndHitTest(point)) \ |
| 447 | SetCursor(); \ |
| 448 | } \ |
| 449 | } \ |
| 450 | return FALSE; \ |
| 451 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 452 | |
| 453 | PWL_IMPLEMENT_KEY_METHOD(OnKeyDown) |
| 454 | PWL_IMPLEMENT_KEY_METHOD(OnKeyUp) |
| 455 | PWL_IMPLEMENT_KEY_METHOD(OnChar) |
| 456 | |
| 457 | PWL_IMPLEMENT_MOUSE_METHOD(OnLButtonDblClk) |
| 458 | PWL_IMPLEMENT_MOUSE_METHOD(OnLButtonDown) |
| 459 | PWL_IMPLEMENT_MOUSE_METHOD(OnLButtonUp) |
| 460 | PWL_IMPLEMENT_MOUSE_METHOD(OnMButtonDblClk) |
| 461 | PWL_IMPLEMENT_MOUSE_METHOD(OnMButtonDown) |
| 462 | PWL_IMPLEMENT_MOUSE_METHOD(OnMButtonUp) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 463 | PWL_IMPLEMENT_MOUSE_METHOD(OnRButtonDown) |
| 464 | PWL_IMPLEMENT_MOUSE_METHOD(OnRButtonUp) |
| 465 | PWL_IMPLEMENT_MOUSE_METHOD(OnMouseMove) |
| 466 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 467 | FX_BOOL CPWL_Wnd::OnMouseWheel(short zDelta, |
| 468 | const CPDF_Point& point, |
| 469 | FX_DWORD nFlag) { |
| 470 | if (IsValid() && IsVisible() && IsEnabled()) { |
| 471 | SetCursor(); |
| 472 | if (IsWndCaptureKeyboard(this)) { |
| 473 | for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) { |
| 474 | if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) { |
| 475 | if (IsWndCaptureKeyboard(pChild)) { |
| 476 | return pChild->OnMouseWheel(zDelta, pChild->ParentToChild(point), |
| 477 | nFlag); |
| 478 | } |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 479 | } |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 480 | } |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 481 | } |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 482 | } |
| 483 | return FALSE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 484 | } |
| 485 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 486 | void CPWL_Wnd::AddChild(CPWL_Wnd* pWnd) { |
| 487 | m_aChildren.Add(pWnd); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 488 | } |
| 489 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 490 | void CPWL_Wnd::RemoveChild(CPWL_Wnd* pWnd) { |
| 491 | for (int32_t i = m_aChildren.GetSize() - 1; i >= 0; i--) { |
| 492 | if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) { |
| 493 | if (pChild == pWnd) { |
| 494 | m_aChildren.RemoveAt(i); |
| 495 | break; |
| 496 | } |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 497 | } |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 498 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 499 | } |
| 500 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 501 | void CPWL_Wnd::OnNotify(CPWL_Wnd* pWnd, |
| 502 | FX_DWORD msg, |
| 503 | intptr_t wParam, |
| 504 | intptr_t lParam) { |
| 505 | switch (msg) { |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 506 | case PNM_ADDCHILD: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 507 | AddChild(pWnd); |
| 508 | break; |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 509 | case PNM_REMOVECHILD: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 510 | RemoveChild(pWnd); |
| 511 | break; |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 512 | default: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 513 | break; |
| 514 | } |
| 515 | } |
| 516 | |
| 517 | FX_BOOL CPWL_Wnd::IsValid() const { |
| 518 | return m_bCreated; |
| 519 | } |
| 520 | |
| 521 | PWL_CREATEPARAM CPWL_Wnd::GetCreationParam() const { |
| 522 | return m_sPrivateParam; |
| 523 | } |
| 524 | |
| 525 | CPWL_Wnd* CPWL_Wnd::GetParentWindow() const { |
| 526 | return m_sPrivateParam.pParentWnd; |
| 527 | } |
| 528 | |
| 529 | CPDF_Rect CPWL_Wnd::GetOriginWindowRect() const { |
| 530 | return m_sPrivateParam.rcRectWnd; |
| 531 | } |
| 532 | |
| 533 | CPDF_Rect CPWL_Wnd::GetWindowRect() const { |
| 534 | return m_rcWindow; |
| 535 | } |
| 536 | |
| 537 | CPDF_Rect CPWL_Wnd::GetClientRect() const { |
| 538 | CPDF_Rect rcWindow = GetWindowRect(); |
| 539 | CPDF_Rect rcClient = CPWL_Utils::DeflateRect( |
| 540 | rcWindow, (FX_FLOAT)(GetBorderWidth() + GetInnerBorderWidth())); |
| 541 | if (CPWL_ScrollBar* pVSB = GetVScrollBar()) |
| 542 | rcClient.right -= pVSB->GetScrollBarWidth(); |
| 543 | |
| 544 | rcClient.Normalize(); |
| 545 | return rcWindow.Contains(rcClient) ? rcClient : CPDF_Rect(); |
| 546 | } |
| 547 | |
| 548 | CPDF_Point CPWL_Wnd::GetCenterPoint() const { |
| 549 | CPDF_Rect rcClient = GetClientRect(); |
| 550 | return CPDF_Point((rcClient.left + rcClient.right) * 0.5f, |
| 551 | (rcClient.top + rcClient.bottom) * 0.5f); |
| 552 | } |
| 553 | |
| 554 | CPDF_Rect CPWL_Wnd::GetClientCenterSquare() const { |
| 555 | return CPWL_Utils::GetCenterSquare(GetClientRect()); |
| 556 | } |
| 557 | |
| 558 | CPDF_Rect CPWL_Wnd::GetWindowCenterSquare() const { |
| 559 | return CPWL_Utils::GetCenterSquare( |
| 560 | CPWL_Utils::DeflateRect(GetWindowRect(), 0.1f)); |
| 561 | } |
| 562 | |
| 563 | FX_BOOL CPWL_Wnd::HasFlag(FX_DWORD dwFlags) const { |
| 564 | return (m_sPrivateParam.dwFlags & dwFlags) != 0; |
| 565 | } |
| 566 | |
| 567 | void CPWL_Wnd::RemoveFlag(FX_DWORD dwFlags) { |
| 568 | m_sPrivateParam.dwFlags &= ~dwFlags; |
| 569 | } |
| 570 | |
| 571 | void CPWL_Wnd::AddFlag(FX_DWORD dwFlags) { |
| 572 | m_sPrivateParam.dwFlags |= dwFlags; |
| 573 | } |
| 574 | |
| 575 | CPWL_Color CPWL_Wnd::GetBackgroundColor() const { |
| 576 | return m_sPrivateParam.sBackgroundColor; |
| 577 | } |
| 578 | |
| 579 | void CPWL_Wnd::SetBackgroundColor(const CPWL_Color& color) { |
| 580 | m_sPrivateParam.sBackgroundColor = color; |
| 581 | } |
| 582 | |
| 583 | void CPWL_Wnd::SetTextColor(const CPWL_Color& color) { |
| 584 | m_sPrivateParam.sTextColor = color; |
| 585 | } |
| 586 | |
| 587 | void CPWL_Wnd::SetTextStrokeColor(const CPWL_Color& color) { |
| 588 | m_sPrivateParam.sTextStrokeColor = color; |
| 589 | } |
| 590 | |
| 591 | CPWL_Color CPWL_Wnd::GetTextColor() const { |
| 592 | return m_sPrivateParam.sTextColor; |
| 593 | } |
| 594 | |
| 595 | CPWL_Color CPWL_Wnd::GetTextStrokeColor() const { |
| 596 | return m_sPrivateParam.sTextStrokeColor; |
| 597 | } |
| 598 | |
| 599 | int32_t CPWL_Wnd::GetBorderStyle() const { |
| 600 | return m_sPrivateParam.nBorderStyle; |
| 601 | } |
| 602 | |
| 603 | void CPWL_Wnd::SetBorderStyle(int32_t nBorderStyle) { |
| 604 | if (HasFlag(PWS_BORDER)) |
| 605 | m_sPrivateParam.nBorderStyle = nBorderStyle; |
| 606 | } |
| 607 | |
| 608 | int32_t CPWL_Wnd::GetBorderWidth() const { |
| 609 | if (HasFlag(PWS_BORDER)) |
| 610 | return m_sPrivateParam.dwBorderWidth; |
| 611 | |
| 612 | return 0; |
| 613 | } |
| 614 | |
| 615 | int32_t CPWL_Wnd::GetInnerBorderWidth() const { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 616 | return 0; |
| 617 | } |
| 618 | |
| 619 | void CPWL_Wnd::SetBorderWidth(int32_t nBorderWidth) { |
| 620 | if (HasFlag(PWS_BORDER)) |
| 621 | m_sPrivateParam.dwBorderWidth = nBorderWidth; |
| 622 | } |
| 623 | |
| 624 | CPWL_Color CPWL_Wnd::GetBorderColor() const { |
| 625 | if (HasFlag(PWS_BORDER)) |
| 626 | return m_sPrivateParam.sBorderColor; |
| 627 | |
| 628 | return CPWL_Color(); |
| 629 | } |
| 630 | |
| 631 | void CPWL_Wnd::SetBorderColor(const CPWL_Color& color) { |
| 632 | if (HasFlag(PWS_BORDER)) |
| 633 | m_sPrivateParam.sBorderColor = color; |
| 634 | } |
| 635 | |
| 636 | CPWL_Dash CPWL_Wnd::GetBorderDash() const { |
| 637 | return m_sPrivateParam.sDash; |
| 638 | } |
| 639 | |
| 640 | void* CPWL_Wnd::GetAttachedData() const { |
| 641 | return m_sPrivateParam.pAttachedData; |
| 642 | } |
| 643 | |
| 644 | void CPWL_Wnd::SetBorderDash(const CPWL_Dash& sDash) { |
| 645 | if (HasFlag(PWS_BORDER)) |
| 646 | m_sPrivateParam.sDash = sDash; |
| 647 | } |
| 648 | |
| 649 | CPWL_ScrollBar* CPWL_Wnd::GetVScrollBar() const { |
| 650 | if (HasFlag(PWS_VSCROLL)) |
| 651 | return m_pVScrollBar; |
| 652 | |
| 653 | return NULL; |
| 654 | } |
| 655 | |
| 656 | void CPWL_Wnd::CreateScrollBar(const PWL_CREATEPARAM& cp) { |
| 657 | CreateVScrollBar(cp); |
| 658 | } |
| 659 | |
| 660 | void CPWL_Wnd::CreateVScrollBar(const PWL_CREATEPARAM& cp) { |
| 661 | if (!m_pVScrollBar && HasFlag(PWS_VSCROLL)) { |
| 662 | PWL_CREATEPARAM scp = cp; |
| 663 | |
| 664 | // flags |
| 665 | scp.dwFlags = |
| 666 | PWS_CHILD | PWS_BACKGROUND | PWS_AUTOTRANSPARENT | PWS_NOREFRESHCLIP; |
| 667 | |
| 668 | scp.pParentWnd = this; |
| 669 | scp.sBackgroundColor = PWL_DEFAULT_WHITECOLOR; |
| 670 | scp.eCursorType = FXCT_ARROW; |
| 671 | scp.nTransparency = PWL_SCROLLBAR_TRANSPARANCY; |
| 672 | |
Lei Zhang | e00660b | 2015-08-13 15:40:18 -0700 | [diff] [blame] | 673 | m_pVScrollBar = new CPWL_ScrollBar(SBT_VSCROLL); |
| 674 | m_pVScrollBar->Create(scp); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 675 | } |
| 676 | } |
| 677 | |
| 678 | void CPWL_Wnd::SetCapture() { |
| 679 | if (CPWL_MsgControl* pMsgCtrl = GetMsgControl()) |
| 680 | pMsgCtrl->SetCapture(this); |
| 681 | } |
| 682 | |
| 683 | void CPWL_Wnd::ReleaseCapture() { |
| 684 | for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) |
| 685 | if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) |
| 686 | pChild->ReleaseCapture(); |
| 687 | |
| 688 | if (CPWL_MsgControl* pMsgCtrl = GetMsgControl()) |
| 689 | pMsgCtrl->ReleaseCapture(); |
| 690 | } |
| 691 | |
| 692 | void CPWL_Wnd::SetFocus() { |
| 693 | if (CPWL_MsgControl* pMsgCtrl = GetMsgControl()) { |
| 694 | if (!pMsgCtrl->IsMainCaptureKeyboard(this)) |
| 695 | pMsgCtrl->KillFocus(); |
| 696 | pMsgCtrl->SetFocus(this); |
| 697 | } |
| 698 | } |
| 699 | |
| 700 | void CPWL_Wnd::KillFocus() { |
| 701 | if (CPWL_MsgControl* pMsgCtrl = GetMsgControl()) { |
| 702 | if (pMsgCtrl->IsWndCaptureKeyboard(this)) |
| 703 | pMsgCtrl->KillFocus(); |
| 704 | } |
| 705 | } |
| 706 | |
| 707 | void CPWL_Wnd::OnSetFocus() {} |
| 708 | |
| 709 | void CPWL_Wnd::OnKillFocus() {} |
| 710 | |
| 711 | FX_BOOL CPWL_Wnd::WndHitTest(const CPDF_Point& point) const { |
| 712 | return IsValid() && IsVisible() && GetWindowRect().Contains(point.x, point.y); |
| 713 | } |
| 714 | |
| 715 | FX_BOOL CPWL_Wnd::ClientHitTest(const CPDF_Point& point) const { |
| 716 | return IsValid() && IsVisible() && GetClientRect().Contains(point.x, point.y); |
| 717 | } |
| 718 | |
| 719 | const CPWL_Wnd* CPWL_Wnd::GetRootWnd() const { |
| 720 | if (m_sPrivateParam.pParentWnd) |
| 721 | return m_sPrivateParam.pParentWnd->GetRootWnd(); |
| 722 | |
| 723 | return this; |
| 724 | } |
| 725 | |
| 726 | void CPWL_Wnd::SetVisible(FX_BOOL bVisible) { |
| 727 | if (IsValid()) { |
| 728 | for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) { |
| 729 | if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) { |
| 730 | pChild->SetVisible(bVisible); |
| 731 | } |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 732 | } |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 733 | |
| 734 | if (bVisible != m_bVisible) { |
| 735 | m_bVisible = bVisible; |
| 736 | RePosChildWnd(); |
| 737 | InvalidateRect(); |
| 738 | } |
| 739 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 740 | } |
| 741 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 742 | void CPWL_Wnd::SetClipRect(const CPDF_Rect& rect) { |
| 743 | m_rcClip = rect; |
| 744 | m_rcClip.Normalize(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 745 | } |
| 746 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 747 | CPDF_Rect CPWL_Wnd::GetClipRect() const { |
| 748 | return m_rcClip; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 749 | } |
| 750 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 751 | FX_BOOL CPWL_Wnd::IsReadOnly() const { |
| 752 | return HasFlag(PWS_READONLY); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 753 | } |
| 754 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 755 | void CPWL_Wnd::RePosChildWnd() { |
| 756 | CPDF_Rect rcContent = CPWL_Utils::DeflateRect( |
| 757 | GetWindowRect(), (FX_FLOAT)(GetBorderWidth() + GetInnerBorderWidth())); |
| 758 | |
| 759 | CPWL_ScrollBar* pVSB = GetVScrollBar(); |
| 760 | |
| 761 | CPDF_Rect rcVScroll = |
| 762 | CPDF_Rect(rcContent.right - PWL_SCROLLBAR_WIDTH, rcContent.bottom, |
| 763 | rcContent.right - 1.0f, rcContent.top); |
| 764 | |
| 765 | if (pVSB) |
| 766 | pVSB->Move(rcVScroll, TRUE, FALSE); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 767 | } |
| 768 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 769 | void CPWL_Wnd::CreateChildWnd(const PWL_CREATEPARAM& cp) {} |
| 770 | |
| 771 | void CPWL_Wnd::SetCursor() { |
| 772 | if (IsValid()) { |
| 773 | if (IFX_SystemHandler* pSH = GetSystemHandler()) { |
| 774 | int32_t nCursorType = GetCreationParam().eCursorType; |
| 775 | pSH->SetCursor(nCursorType); |
| 776 | } |
| 777 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 778 | } |
| 779 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 780 | void CPWL_Wnd::CreateMsgControl() { |
| 781 | if (!m_sPrivateParam.pMsgControl) |
| 782 | m_sPrivateParam.pMsgControl = new CPWL_MsgControl(this); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 783 | } |
| 784 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 785 | void CPWL_Wnd::DestroyMsgControl() { |
| 786 | if (CPWL_MsgControl* pMsgControl = GetMsgControl()) |
| 787 | if (pMsgControl->IsWndCreated(this)) |
| 788 | delete pMsgControl; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 789 | } |
| 790 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 791 | CPWL_MsgControl* CPWL_Wnd::GetMsgControl() const { |
| 792 | return m_sPrivateParam.pMsgControl; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 793 | } |
| 794 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 795 | FX_BOOL CPWL_Wnd::IsCaptureMouse() const { |
| 796 | return IsWndCaptureMouse(this); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 797 | } |
| 798 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 799 | FX_BOOL CPWL_Wnd::IsWndCaptureMouse(const CPWL_Wnd* pWnd) const { |
| 800 | if (CPWL_MsgControl* pCtrl = GetMsgControl()) |
| 801 | return pCtrl->IsWndCaptureMouse(pWnd); |
| 802 | |
| 803 | return FALSE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 804 | } |
| 805 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 806 | FX_BOOL CPWL_Wnd::IsWndCaptureKeyboard(const CPWL_Wnd* pWnd) const { |
| 807 | if (CPWL_MsgControl* pCtrl = GetMsgControl()) |
| 808 | return pCtrl->IsWndCaptureKeyboard(pWnd); |
| 809 | |
| 810 | return FALSE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 811 | } |
| 812 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 813 | FX_BOOL CPWL_Wnd::IsFocused() const { |
| 814 | if (CPWL_MsgControl* pCtrl = GetMsgControl()) |
| 815 | return pCtrl->IsMainCaptureKeyboard(this); |
| 816 | |
| 817 | return FALSE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 818 | } |
| 819 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 820 | CPDF_Rect CPWL_Wnd::GetFocusRect() const { |
| 821 | return CPWL_Utils::InflateRect(GetWindowRect(), 1); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 822 | } |
| 823 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 824 | FX_FLOAT CPWL_Wnd::GetFontSize() const { |
| 825 | return m_sPrivateParam.fFontSize; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 826 | } |
| 827 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 828 | void CPWL_Wnd::SetFontSize(FX_FLOAT fFontSize) { |
| 829 | m_sPrivateParam.fFontSize = fFontSize; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 830 | } |
| 831 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 832 | IFX_SystemHandler* CPWL_Wnd::GetSystemHandler() const { |
| 833 | return m_sPrivateParam.pSystemHandler; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 834 | } |
| 835 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 836 | IPWL_FocusHandler* CPWL_Wnd::GetFocusHandler() const { |
| 837 | return m_sPrivateParam.pFocusHandler; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 838 | } |
| 839 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 840 | IPWL_Provider* CPWL_Wnd::GetProvider() const { |
| 841 | return m_sPrivateParam.pProvider; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 842 | } |
| 843 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 844 | IFX_Edit_FontMap* CPWL_Wnd::GetFontMap() const { |
| 845 | return m_sPrivateParam.pFontMap; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 846 | } |
| 847 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 848 | CPWL_Color CPWL_Wnd::GetBorderLeftTopColor(int32_t nBorderStyle) const { |
| 849 | CPWL_Color color; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 850 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 851 | switch (nBorderStyle) { |
| 852 | case PBS_SOLID: |
| 853 | break; |
| 854 | case PBS_DASH: |
| 855 | break; |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 856 | case PBS_BEVELED: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 857 | color = CPWL_Color(COLORTYPE_GRAY, 1); |
| 858 | break; |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 859 | case PBS_INSET: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 860 | color = CPWL_Color(COLORTYPE_GRAY, 0.5f); |
| 861 | break; |
| 862 | case PBS_UNDERLINED: |
| 863 | break; |
| 864 | } |
| 865 | |
| 866 | return color; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 867 | } |
| 868 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 869 | CPWL_Color CPWL_Wnd::GetBorderRightBottomColor(int32_t nBorderStyle) const { |
| 870 | CPWL_Color color; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 871 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 872 | switch (nBorderStyle) { |
| 873 | case PBS_SOLID: |
| 874 | break; |
| 875 | case PBS_DASH: |
| 876 | break; |
| 877 | case PBS_BEVELED: |
| 878 | color = CPWL_Utils::DevideColor(GetBackgroundColor(), 2); |
| 879 | break; |
| 880 | case PBS_INSET: |
| 881 | color = CPWL_Color(COLORTYPE_GRAY, 0.75f); |
| 882 | break; |
| 883 | case PBS_UNDERLINED: |
| 884 | break; |
| 885 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 886 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 887 | return color; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 888 | } |
| 889 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 890 | int32_t CPWL_Wnd::GetTransparency() { |
| 891 | return m_sPrivateParam.nTransparency; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 892 | } |
| 893 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 894 | void CPWL_Wnd::SetTransparency(int32_t nTransparency) { |
| 895 | for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) { |
| 896 | if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) { |
| 897 | pChild->SetTransparency(nTransparency); |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 898 | } |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 899 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 900 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 901 | m_sPrivateParam.nTransparency = nTransparency; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 902 | } |
| 903 | |
Tom Sepez | 60d909e | 2015-12-10 15:34:55 -0800 | [diff] [blame] | 904 | CFX_Matrix CPWL_Wnd::GetWindowMatrix() const { |
| 905 | CFX_Matrix mt = GetChildToRoot(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 906 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 907 | if (IPWL_Provider* pProvider = GetProvider()) { |
| 908 | mt.Concat(pProvider->GetWindowMatrix(GetAttachedData())); |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 909 | return mt; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 910 | } |
| 911 | |
| 912 | return mt; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 913 | } |
| 914 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 915 | void CPWL_Wnd::PWLtoWnd(const CPDF_Point& point, int32_t& x, int32_t& y) const { |
Tom Sepez | 60d909e | 2015-12-10 15:34:55 -0800 | [diff] [blame] | 916 | CFX_Matrix mt = GetWindowMatrix(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 917 | CPDF_Point pt = point; |
| 918 | mt.Transform(pt.x, pt.y); |
| 919 | x = (int32_t)(pt.x + 0.5); |
| 920 | y = (int32_t)(pt.y + 0.5); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 921 | } |
| 922 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 923 | FX_RECT CPWL_Wnd::PWLtoWnd(const CPDF_Rect& rect) const { |
| 924 | CPDF_Rect rcTemp = rect; |
Tom Sepez | 60d909e | 2015-12-10 15:34:55 -0800 | [diff] [blame] | 925 | CFX_Matrix mt = GetWindowMatrix(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 926 | mt.TransformRect(rcTemp); |
| 927 | return FX_RECT((int32_t)(rcTemp.left + 0.5), (int32_t)(rcTemp.bottom + 0.5), |
| 928 | (int32_t)(rcTemp.right + 0.5), (int32_t)(rcTemp.top + 0.5)); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 929 | } |
| 930 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 931 | FX_HWND CPWL_Wnd::GetAttachedHWnd() const { |
| 932 | return m_sPrivateParam.hAttachedWnd; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 933 | } |
| 934 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 935 | CPDF_Point CPWL_Wnd::ChildToParent(const CPDF_Point& point) const { |
Tom Sepez | 60d909e | 2015-12-10 15:34:55 -0800 | [diff] [blame] | 936 | CFX_Matrix mt = GetChildMatrix(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 937 | if (mt.IsIdentity()) |
| 938 | return point; |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 939 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 940 | CPDF_Point pt = point; |
| 941 | mt.Transform(pt.x, pt.y); |
| 942 | return pt; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 943 | } |
| 944 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 945 | CPDF_Rect CPWL_Wnd::ChildToParent(const CPDF_Rect& rect) const { |
Tom Sepez | 60d909e | 2015-12-10 15:34:55 -0800 | [diff] [blame] | 946 | CFX_Matrix mt = GetChildMatrix(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 947 | if (mt.IsIdentity()) |
| 948 | return rect; |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 949 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 950 | CPDF_Rect rc = rect; |
| 951 | mt.TransformRect(rc); |
| 952 | return rc; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 953 | } |
| 954 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 955 | CPDF_Point CPWL_Wnd::ParentToChild(const CPDF_Point& point) const { |
Tom Sepez | 60d909e | 2015-12-10 15:34:55 -0800 | [diff] [blame] | 956 | CFX_Matrix mt = GetChildMatrix(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 957 | if (mt.IsIdentity()) |
| 958 | return point; |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 959 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 960 | mt.SetReverse(mt); |
| 961 | CPDF_Point pt = point; |
| 962 | mt.Transform(pt.x, pt.y); |
| 963 | return pt; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 964 | } |
| 965 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 966 | CPDF_Rect CPWL_Wnd::ParentToChild(const CPDF_Rect& rect) const { |
Tom Sepez | 60d909e | 2015-12-10 15:34:55 -0800 | [diff] [blame] | 967 | CFX_Matrix mt = GetChildMatrix(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 968 | if (mt.IsIdentity()) |
| 969 | return rect; |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 970 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 971 | mt.SetReverse(mt); |
| 972 | CPDF_Rect rc = rect; |
| 973 | mt.TransformRect(rc); |
| 974 | return rc; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 975 | } |
| 976 | |
Tom Sepez | 60d909e | 2015-12-10 15:34:55 -0800 | [diff] [blame] | 977 | CFX_Matrix CPWL_Wnd::GetChildToRoot() const { |
| 978 | CFX_Matrix mt(1, 0, 0, 1, 0, 0); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 979 | if (HasFlag(PWS_CHILD)) { |
| 980 | const CPWL_Wnd* pParent = this; |
| 981 | while (pParent) { |
| 982 | mt.Concat(pParent->GetChildMatrix()); |
| 983 | pParent = pParent->GetParentWindow(); |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 984 | } |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 985 | } |
| 986 | return mt; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 987 | } |
| 988 | |
Tom Sepez | 60d909e | 2015-12-10 15:34:55 -0800 | [diff] [blame] | 989 | CFX_Matrix CPWL_Wnd::GetChildMatrix() const { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 990 | if (HasFlag(PWS_CHILD)) |
| 991 | return m_sPrivateParam.mtChild; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 992 | |
Tom Sepez | 60d909e | 2015-12-10 15:34:55 -0800 | [diff] [blame] | 993 | return CFX_Matrix(1, 0, 0, 1, 0, 0); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 994 | } |
| 995 | |
Tom Sepez | 60d909e | 2015-12-10 15:34:55 -0800 | [diff] [blame] | 996 | void CPWL_Wnd::SetChildMatrix(const CFX_Matrix& mt) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 997 | m_sPrivateParam.mtChild = mt; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 998 | } |
| 999 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1000 | const CPWL_Wnd* CPWL_Wnd::GetFocused() const { |
| 1001 | if (CPWL_MsgControl* pMsgCtrl = GetMsgControl()) { |
| 1002 | return pMsgCtrl->m_pMainKeyboardWnd; |
| 1003 | } |
| 1004 | |
| 1005 | return NULL; |
| 1006 | } |
| 1007 | |
| 1008 | void CPWL_Wnd::EnableWindow(FX_BOOL bEnable) { |
| 1009 | if (m_bEnabled != bEnable) { |
| 1010 | for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) { |
| 1011 | if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) { |
| 1012 | pChild->EnableWindow(bEnable); |
| 1013 | } |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 1014 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1015 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1016 | m_bEnabled = bEnable; |
| 1017 | |
| 1018 | if (bEnable) |
| 1019 | OnEnabled(); |
| 1020 | else |
| 1021 | OnDisabled(); |
| 1022 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1023 | } |
| 1024 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1025 | FX_BOOL CPWL_Wnd::IsEnabled() { |
| 1026 | return m_bEnabled; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1027 | } |
| 1028 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1029 | void CPWL_Wnd::OnEnabled() {} |
| 1030 | |
| 1031 | void CPWL_Wnd::OnDisabled() {} |
| 1032 | |
| 1033 | FX_BOOL CPWL_Wnd::IsCTRLpressed(FX_DWORD nFlag) const { |
| 1034 | if (IFX_SystemHandler* pSystemHandler = GetSystemHandler()) { |
| 1035 | return pSystemHandler->IsCTRLKeyDown(nFlag); |
| 1036 | } |
| 1037 | |
| 1038 | return FALSE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1039 | } |
| 1040 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1041 | FX_BOOL CPWL_Wnd::IsSHIFTpressed(FX_DWORD nFlag) const { |
| 1042 | if (IFX_SystemHandler* pSystemHandler = GetSystemHandler()) { |
| 1043 | return pSystemHandler->IsSHIFTKeyDown(nFlag); |
| 1044 | } |
| 1045 | |
| 1046 | return FALSE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1047 | } |
| 1048 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1049 | FX_BOOL CPWL_Wnd::IsALTpressed(FX_DWORD nFlag) const { |
| 1050 | if (IFX_SystemHandler* pSystemHandler = GetSystemHandler()) { |
| 1051 | return pSystemHandler->IsALTKeyDown(nFlag); |
| 1052 | } |
| 1053 | |
| 1054 | return FALSE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1055 | } |
| 1056 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1057 | FX_BOOL CPWL_Wnd::IsINSERTpressed(FX_DWORD nFlag) const { |
| 1058 | if (IFX_SystemHandler* pSystemHandler = GetSystemHandler()) { |
| 1059 | return pSystemHandler->IsINSERTKeyDown(nFlag); |
| 1060 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1061 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1062 | return FALSE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1063 | } |