OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "xfa/fwl/core/ifwl_form.h" | 7 #include "xfa/fwl/core/cfwl_form.h" |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
11 #include "third_party/base/ptr_util.h" | 11 #include "third_party/base/ptr_util.h" |
12 #include "xfa/fde/tto/fde_textout.h" | 12 #include "xfa/fde/tto/fde_textout.h" |
13 #include "xfa/fwl/core/cfwl_app.h" | 13 #include "xfa/fwl/core/cfwl_app.h" |
14 #include "xfa/fwl/core/cfwl_evtclose.h" | 14 #include "xfa/fwl/core/cfwl_evtclose.h" |
| 15 #include "xfa/fwl/core/cfwl_formproxy.h" |
15 #include "xfa/fwl/core/cfwl_msgmouse.h" | 16 #include "xfa/fwl/core/cfwl_msgmouse.h" |
16 #include "xfa/fwl/core/cfwl_notedriver.h" | 17 #include "xfa/fwl/core/cfwl_notedriver.h" |
17 #include "xfa/fwl/core/cfwl_noteloop.h" | 18 #include "xfa/fwl/core/cfwl_noteloop.h" |
18 #include "xfa/fwl/core/cfwl_sysbtn.h" | 19 #include "xfa/fwl/core/cfwl_sysbtn.h" |
19 #include "xfa/fwl/core/cfwl_themebackground.h" | 20 #include "xfa/fwl/core/cfwl_themebackground.h" |
20 #include "xfa/fwl/core/cfwl_themepart.h" | 21 #include "xfa/fwl/core/cfwl_themepart.h" |
21 #include "xfa/fwl/core/cfwl_themetext.h" | 22 #include "xfa/fwl/core/cfwl_themetext.h" |
22 #include "xfa/fwl/core/cfwl_widgetmgr.h" | 23 #include "xfa/fwl/core/cfwl_widgetmgr.h" |
23 #include "xfa/fwl/core/ifwl_formproxy.h" | |
24 #include "xfa/fwl/core/ifwl_themeprovider.h" | 24 #include "xfa/fwl/core/ifwl_themeprovider.h" |
25 #include "xfa/fwl/theme/cfwl_widgettp.h" | 25 #include "xfa/fwl/theme/cfwl_widgettp.h" |
26 | 26 |
27 namespace { | 27 namespace { |
28 | 28 |
29 const int kSystemButtonSize = 21; | 29 const int kSystemButtonSize = 21; |
30 const int kSystemButtonMargin = 5; | 30 const int kSystemButtonMargin = 5; |
31 const int kSystemButtonSpan = 2; | 31 const int kSystemButtonSpan = 2; |
32 | 32 |
33 } // namespace | 33 } // namespace |
34 | 34 |
35 namespace { | 35 namespace { |
36 | 36 |
37 const uint8_t kCornerEnlarge = 10; | 37 const uint8_t kCornerEnlarge = 10; |
38 | 38 |
39 } // namespace | 39 } // namespace |
40 | 40 |
41 IFWL_Form::IFWL_Form(const CFWL_App* app, | 41 CFWL_Form::CFWL_Form(const CFWL_App* app, |
42 std::unique_ptr<CFWL_WidgetProperties> properties, | 42 std::unique_ptr<CFWL_WidgetProperties> properties, |
43 IFWL_Widget* pOuter) | 43 IFWL_Widget* pOuter) |
44 : IFWL_Widget(app, std::move(properties), pOuter), | 44 : IFWL_Widget(app, std::move(properties), pOuter), |
45 #if (_FX_OS_ == _FX_MACOSX_) | 45 #if (_FX_OS_ == _FX_MACOSX_) |
46 m_bMouseIn(false), | 46 m_bMouseIn(false), |
47 #endif | 47 #endif |
48 m_pCloseBox(nullptr), | 48 m_pCloseBox(nullptr), |
49 m_pMinBox(nullptr), | 49 m_pMinBox(nullptr), |
50 m_pMaxBox(nullptr), | 50 m_pMaxBox(nullptr), |
51 m_pSubFocus(nullptr), | 51 m_pSubFocus(nullptr), |
52 m_fCXBorder(0), | 52 m_fCXBorder(0), |
53 m_fCYBorder(0), | 53 m_fCYBorder(0), |
54 m_iCaptureBtn(-1), | 54 m_iCaptureBtn(-1), |
55 m_iSysBox(0), | 55 m_iSysBox(0), |
56 m_bLButtonDown(false), | 56 m_bLButtonDown(false), |
57 m_bMaximized(false), | 57 m_bMaximized(false), |
58 m_bSetMaximize(false), | 58 m_bSetMaximize(false), |
59 m_bDoModalFlag(false) { | 59 m_bDoModalFlag(false) { |
60 m_rtRelative.Reset(); | 60 m_rtRelative.Reset(); |
61 m_rtRestore.Reset(); | 61 m_rtRestore.Reset(); |
62 | 62 |
63 RegisterForm(); | 63 RegisterForm(); |
64 RegisterEventTarget(nullptr); | 64 RegisterEventTarget(nullptr); |
65 } | 65 } |
66 | 66 |
67 IFWL_Form::~IFWL_Form() { | 67 CFWL_Form::~CFWL_Form() { |
68 UnregisterEventTarget(); | 68 UnregisterEventTarget(); |
69 UnRegisterForm(); | 69 UnRegisterForm(); |
70 RemoveSysButtons(); | 70 RemoveSysButtons(); |
71 } | 71 } |
72 | 72 |
73 FWL_Type IFWL_Form::GetClassID() const { | 73 FWL_Type CFWL_Form::GetClassID() const { |
74 return FWL_Type::Form; | 74 return FWL_Type::Form; |
75 } | 75 } |
76 | 76 |
77 bool IFWL_Form::IsInstance(const CFX_WideStringC& wsClass) const { | 77 bool CFWL_Form::IsInstance(const CFX_WideStringC& wsClass) const { |
78 if (wsClass == CFX_WideStringC(FWL_CLASS_Form)) | 78 if (wsClass == CFX_WideStringC(FWL_CLASS_Form)) |
79 return true; | 79 return true; |
80 return IFWL_Widget::IsInstance(wsClass); | 80 return IFWL_Widget::IsInstance(wsClass); |
81 } | 81 } |
82 | 82 |
83 void IFWL_Form::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { | 83 void CFWL_Form::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { |
84 if (!bAutoSize) { | 84 if (!bAutoSize) { |
85 rect = m_pProperties->m_rtWidget; | 85 rect = m_pProperties->m_rtWidget; |
86 return; | 86 return; |
87 } | 87 } |
88 | 88 |
89 rect.Reset(); | 89 rect.Reset(); |
90 FX_FLOAT fCXBorder = GetBorderSize(true); | 90 FX_FLOAT fCXBorder = GetBorderSize(true); |
91 FX_FLOAT fCYBorder = GetBorderSize(false); | 91 FX_FLOAT fCYBorder = GetBorderSize(false); |
92 FX_FLOAT fEdge = GetEdgeWidth(); | 92 FX_FLOAT fEdge = GetEdgeWidth(); |
93 rect.height += fCYBorder + fEdge + fEdge; | 93 rect.height += fCYBorder + fEdge + fEdge; |
94 rect.width += fCXBorder + fCXBorder + fEdge + fEdge; | 94 rect.width += fCXBorder + fCXBorder + fEdge + fEdge; |
95 } | 95 } |
96 | 96 |
97 void IFWL_Form::GetClientRect(CFX_RectF& rect) { | 97 void CFWL_Form::GetClientRect(CFX_RectF& rect) { |
98 rect = m_pProperties->m_rtWidget; | 98 rect = m_pProperties->m_rtWidget; |
99 rect.Offset(-rect.left, -rect.top); | 99 rect.Offset(-rect.left, -rect.top); |
100 } | 100 } |
101 | 101 |
102 void IFWL_Form::Update() { | 102 void CFWL_Form::Update() { |
103 if (m_iLock > 0) | 103 if (m_iLock > 0) |
104 return; | 104 return; |
105 if (!m_pProperties->m_pThemeProvider) | 105 if (!m_pProperties->m_pThemeProvider) |
106 m_pProperties->m_pThemeProvider = GetAvailableTheme(); | 106 m_pProperties->m_pThemeProvider = GetAvailableTheme(); |
107 | 107 |
108 Layout(); | 108 Layout(); |
109 } | 109 } |
110 | 110 |
111 FWL_WidgetHit IFWL_Form::HitTest(FX_FLOAT fx, FX_FLOAT fy) { | 111 FWL_WidgetHit CFWL_Form::HitTest(FX_FLOAT fx, FX_FLOAT fy) { |
112 GetAvailableTheme(); | 112 GetAvailableTheme(); |
113 | 113 |
114 if (m_pCloseBox && m_pCloseBox->m_rtBtn.Contains(fx, fy)) | 114 if (m_pCloseBox && m_pCloseBox->m_rtBtn.Contains(fx, fy)) |
115 return FWL_WidgetHit::CloseBox; | 115 return FWL_WidgetHit::CloseBox; |
116 if (m_pMaxBox && m_pMaxBox->m_rtBtn.Contains(fx, fy)) | 116 if (m_pMaxBox && m_pMaxBox->m_rtBtn.Contains(fx, fy)) |
117 return FWL_WidgetHit::MaxBox; | 117 return FWL_WidgetHit::MaxBox; |
118 if (m_pMinBox && m_pMinBox->m_rtBtn.Contains(fx, fy)) | 118 if (m_pMinBox && m_pMinBox->m_rtBtn.Contains(fx, fy)) |
119 return FWL_WidgetHit::MinBox; | 119 return FWL_WidgetHit::MinBox; |
120 | 120 |
121 CFX_RectF rtCap; | 121 CFX_RectF rtCap; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 | 164 |
165 rt.Set(m_rtRelative.width - m_fCYBorder - kCornerEnlarge, | 165 rt.Set(m_rtRelative.width - m_fCYBorder - kCornerEnlarge, |
166 m_rtRelative.height - m_fCXBorder - kCornerEnlarge, | 166 m_rtRelative.height - m_fCXBorder - kCornerEnlarge, |
167 m_fCYBorder + kCornerEnlarge, m_fCXBorder + kCornerEnlarge); | 167 m_fCYBorder + kCornerEnlarge, m_fCXBorder + kCornerEnlarge); |
168 if (rt.Contains(fx, fy)) | 168 if (rt.Contains(fx, fy)) |
169 return FWL_WidgetHit::RightBottom; | 169 return FWL_WidgetHit::RightBottom; |
170 } | 170 } |
171 return FWL_WidgetHit::Client; | 171 return FWL_WidgetHit::Client; |
172 } | 172 } |
173 | 173 |
174 void IFWL_Form::DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) { | 174 void CFWL_Form::DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) { |
175 if (!pGraphics) | 175 if (!pGraphics) |
176 return; | 176 return; |
177 if (!m_pProperties->m_pThemeProvider) | 177 if (!m_pProperties->m_pThemeProvider) |
178 return; | 178 return; |
179 | 179 |
180 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; | 180 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; |
181 bool bInactive = !IsActive(); | 181 bool bInactive = !IsActive(); |
182 int32_t iState = bInactive ? CFWL_PartState_Inactive : CFWL_PartState_Normal; | 182 int32_t iState = bInactive ? CFWL_PartState_Inactive : CFWL_PartState_Normal; |
183 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_FRM_NoDrawClient) == 0) | 183 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_FRM_NoDrawClient) == 0) |
184 DrawBackground(pGraphics, pTheme); | 184 DrawBackground(pGraphics, pTheme); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 if (m_pMinBox) { | 260 if (m_pMinBox) { |
261 param.m_iPart = CFWL_Part::MinimizeBox; | 261 param.m_iPart = CFWL_Part::MinimizeBox; |
262 param.m_dwStates = m_pMinBox->GetPartState(); | 262 param.m_dwStates = m_pMinBox->GetPartState(); |
263 param.m_rtPart = m_pMinBox->m_rtBtn; | 263 param.m_rtPart = m_pMinBox->m_rtBtn; |
264 pTheme->DrawBackground(¶m); | 264 pTheme->DrawBackground(¶m); |
265 } | 265 } |
266 } | 266 } |
267 #endif | 267 #endif |
268 } | 268 } |
269 | 269 |
270 IFWL_Widget* IFWL_Form::DoModal() { | 270 IFWL_Widget* CFWL_Form::DoModal() { |
271 const CFWL_App* pApp = GetOwnerApp(); | 271 const CFWL_App* pApp = GetOwnerApp(); |
272 if (!pApp) | 272 if (!pApp) |
273 return nullptr; | 273 return nullptr; |
274 | 274 |
275 CFWL_NoteDriver* pDriver = pApp->GetNoteDriver(); | 275 CFWL_NoteDriver* pDriver = pApp->GetNoteDriver(); |
276 if (!pDriver) | 276 if (!pDriver) |
277 return nullptr; | 277 return nullptr; |
278 | 278 |
279 m_pNoteLoop = pdfium::MakeUnique<CFWL_NoteLoop>(); | 279 m_pNoteLoop = pdfium::MakeUnique<CFWL_NoteLoop>(); |
280 m_pNoteLoop->SetMainForm(this); | 280 m_pNoteLoop->SetMainForm(this); |
281 | 281 |
282 pDriver->PushNoteLoop(m_pNoteLoop.get()); | 282 pDriver->PushNoteLoop(m_pNoteLoop.get()); |
283 m_bDoModalFlag = true; | 283 m_bDoModalFlag = true; |
284 SetStates(FWL_WGTSTATE_Invisible, false); | 284 SetStates(FWL_WGTSTATE_Invisible, false); |
285 pDriver->Run(); | 285 pDriver->Run(); |
286 | 286 |
287 #if _FX_OS_ != _FX_MACOSX_ | 287 #if _FX_OS_ != _FX_MACOSX_ |
288 pDriver->PopNoteLoop(); | 288 pDriver->PopNoteLoop(); |
289 #endif | 289 #endif |
290 | 290 |
291 m_pNoteLoop.reset(); | 291 m_pNoteLoop.reset(); |
292 return nullptr; | 292 return nullptr; |
293 } | 293 } |
294 | 294 |
295 void IFWL_Form::EndDoModal() { | 295 void CFWL_Form::EndDoModal() { |
296 if (!m_pNoteLoop) | 296 if (!m_pNoteLoop) |
297 return; | 297 return; |
298 | 298 |
299 m_bDoModalFlag = false; | 299 m_bDoModalFlag = false; |
300 | 300 |
301 #if (_FX_OS_ == _FX_MACOSX_) | 301 #if (_FX_OS_ == _FX_MACOSX_) |
302 m_pNoteLoop->EndModalLoop(); | 302 m_pNoteLoop->EndModalLoop(); |
303 const CFWL_App* pApp = GetOwnerApp(); | 303 const CFWL_App* pApp = GetOwnerApp(); |
304 if (!pApp) | 304 if (!pApp) |
305 return; | 305 return; |
306 | 306 |
307 CFWL_NoteDriver* pDriver = | 307 CFWL_NoteDriver* pDriver = |
308 static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver()); | 308 static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver()); |
309 if (!pDriver) | 309 if (!pDriver) |
310 return; | 310 return; |
311 | 311 |
312 pDriver->PopNoteLoop(); | 312 pDriver->PopNoteLoop(); |
313 SetStates(FWL_WGTSTATE_Invisible, true); | 313 SetStates(FWL_WGTSTATE_Invisible, true); |
314 #else | 314 #else |
315 SetStates(FWL_WGTSTATE_Invisible, true); | 315 SetStates(FWL_WGTSTATE_Invisible, true); |
316 m_pNoteLoop->EndModalLoop(); | 316 m_pNoteLoop->EndModalLoop(); |
317 #endif | 317 #endif |
318 } | 318 } |
319 | 319 |
320 void IFWL_Form::DrawBackground(CFX_Graphics* pGraphics, | 320 void CFWL_Form::DrawBackground(CFX_Graphics* pGraphics, |
321 IFWL_ThemeProvider* pTheme) { | 321 IFWL_ThemeProvider* pTheme) { |
322 CFWL_ThemeBackground param; | 322 CFWL_ThemeBackground param; |
323 param.m_pWidget = this; | 323 param.m_pWidget = this; |
324 param.m_iPart = CFWL_Part::Background; | 324 param.m_iPart = CFWL_Part::Background; |
325 param.m_pGraphics = pGraphics; | 325 param.m_pGraphics = pGraphics; |
326 param.m_rtPart = m_rtRelative; | 326 param.m_rtPart = m_rtRelative; |
327 param.m_rtPart.Deflate(m_fCYBorder, m_fCXBorder, m_fCYBorder, m_fCXBorder); | 327 param.m_rtPart.Deflate(m_fCYBorder, m_fCXBorder, m_fCYBorder, m_fCXBorder); |
328 pTheme->DrawBackground(¶m); | 328 pTheme->DrawBackground(¶m); |
329 } | 329 } |
330 | 330 |
331 void IFWL_Form::RemoveSysButtons() { | 331 void CFWL_Form::RemoveSysButtons() { |
332 delete m_pCloseBox; | 332 delete m_pCloseBox; |
333 m_pCloseBox = nullptr; | 333 m_pCloseBox = nullptr; |
334 delete m_pMinBox; | 334 delete m_pMinBox; |
335 m_pMinBox = nullptr; | 335 m_pMinBox = nullptr; |
336 delete m_pMaxBox; | 336 delete m_pMaxBox; |
337 m_pMaxBox = nullptr; | 337 m_pMaxBox = nullptr; |
338 } | 338 } |
339 | 339 |
340 CFWL_SysBtn* IFWL_Form::GetSysBtnAtPoint(FX_FLOAT fx, FX_FLOAT fy) { | 340 CFWL_SysBtn* CFWL_Form::GetSysBtnAtPoint(FX_FLOAT fx, FX_FLOAT fy) { |
341 if (m_pCloseBox && m_pCloseBox->m_rtBtn.Contains(fx, fy)) | 341 if (m_pCloseBox && m_pCloseBox->m_rtBtn.Contains(fx, fy)) |
342 return m_pCloseBox; | 342 return m_pCloseBox; |
343 if (m_pMaxBox && m_pMaxBox->m_rtBtn.Contains(fx, fy)) | 343 if (m_pMaxBox && m_pMaxBox->m_rtBtn.Contains(fx, fy)) |
344 return m_pMaxBox; | 344 return m_pMaxBox; |
345 if (m_pMinBox && m_pMinBox->m_rtBtn.Contains(fx, fy)) | 345 if (m_pMinBox && m_pMinBox->m_rtBtn.Contains(fx, fy)) |
346 return m_pMinBox; | 346 return m_pMinBox; |
347 return nullptr; | 347 return nullptr; |
348 } | 348 } |
349 | 349 |
350 CFWL_SysBtn* IFWL_Form::GetSysBtnByState(uint32_t dwState) { | 350 CFWL_SysBtn* CFWL_Form::GetSysBtnByState(uint32_t dwState) { |
351 if (m_pCloseBox && (m_pCloseBox->m_dwState & dwState)) | 351 if (m_pCloseBox && (m_pCloseBox->m_dwState & dwState)) |
352 return m_pCloseBox; | 352 return m_pCloseBox; |
353 if (m_pMaxBox && (m_pMaxBox->m_dwState & dwState)) | 353 if (m_pMaxBox && (m_pMaxBox->m_dwState & dwState)) |
354 return m_pMaxBox; | 354 return m_pMaxBox; |
355 if (m_pMinBox && (m_pMinBox->m_dwState & dwState)) | 355 if (m_pMinBox && (m_pMinBox->m_dwState & dwState)) |
356 return m_pMinBox; | 356 return m_pMinBox; |
357 return nullptr; | 357 return nullptr; |
358 } | 358 } |
359 | 359 |
360 CFWL_SysBtn* IFWL_Form::GetSysBtnByIndex(int32_t nIndex) { | 360 CFWL_SysBtn* CFWL_Form::GetSysBtnByIndex(int32_t nIndex) { |
361 if (nIndex < 0) | 361 if (nIndex < 0) |
362 return nullptr; | 362 return nullptr; |
363 | 363 |
364 CFX_ArrayTemplate<CFWL_SysBtn*> arrBtn; | 364 CFX_ArrayTemplate<CFWL_SysBtn*> arrBtn; |
365 if (m_pMinBox) | 365 if (m_pMinBox) |
366 arrBtn.Add(m_pMinBox); | 366 arrBtn.Add(m_pMinBox); |
367 if (m_pMaxBox) | 367 if (m_pMaxBox) |
368 arrBtn.Add(m_pMaxBox); | 368 arrBtn.Add(m_pMaxBox); |
369 if (m_pCloseBox) | 369 if (m_pCloseBox) |
370 arrBtn.Add(m_pCloseBox); | 370 arrBtn.Add(m_pCloseBox); |
371 return arrBtn[nIndex]; | 371 return arrBtn[nIndex]; |
372 } | 372 } |
373 | 373 |
374 int32_t IFWL_Form::GetSysBtnIndex(CFWL_SysBtn* pBtn) { | 374 int32_t CFWL_Form::GetSysBtnIndex(CFWL_SysBtn* pBtn) { |
375 CFX_ArrayTemplate<CFWL_SysBtn*> arrBtn; | 375 CFX_ArrayTemplate<CFWL_SysBtn*> arrBtn; |
376 if (m_pMinBox) | 376 if (m_pMinBox) |
377 arrBtn.Add(m_pMinBox); | 377 arrBtn.Add(m_pMinBox); |
378 if (m_pMaxBox) | 378 if (m_pMaxBox) |
379 arrBtn.Add(m_pMaxBox); | 379 arrBtn.Add(m_pMaxBox); |
380 if (m_pCloseBox) | 380 if (m_pCloseBox) |
381 arrBtn.Add(m_pCloseBox); | 381 arrBtn.Add(m_pCloseBox); |
382 return arrBtn.Find(pBtn); | 382 return arrBtn.Find(pBtn); |
383 } | 383 } |
384 | 384 |
385 void IFWL_Form::GetEdgeRect(CFX_RectF& rtEdge) { | 385 void CFWL_Form::GetEdgeRect(CFX_RectF& rtEdge) { |
386 rtEdge = m_rtRelative; | 386 rtEdge = m_rtRelative; |
387 if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border) { | 387 if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border) { |
388 FX_FLOAT fCX = GetBorderSize(); | 388 FX_FLOAT fCX = GetBorderSize(); |
389 FX_FLOAT fCY = GetBorderSize(false); | 389 FX_FLOAT fCY = GetBorderSize(false); |
390 rtEdge.Deflate(fCX, fCY, fCX, fCY); | 390 rtEdge.Deflate(fCX, fCY, fCX, fCY); |
391 } | 391 } |
392 } | 392 } |
393 | 393 |
394 void IFWL_Form::SetWorkAreaRect() { | 394 void CFWL_Form::SetWorkAreaRect() { |
395 m_rtRestore = m_pProperties->m_rtWidget; | 395 m_rtRestore = m_pProperties->m_rtWidget; |
396 CFWL_WidgetMgr* pWidgetMgr = GetOwnerApp()->GetWidgetMgr(); | 396 CFWL_WidgetMgr* pWidgetMgr = GetOwnerApp()->GetWidgetMgr(); |
397 if (!pWidgetMgr) | 397 if (!pWidgetMgr) |
398 return; | 398 return; |
399 | 399 |
400 m_bSetMaximize = true; | 400 m_bSetMaximize = true; |
401 Repaint(&m_rtRelative); | 401 Repaint(&m_rtRelative); |
402 } | 402 } |
403 | 403 |
404 void IFWL_Form::Layout() { | 404 void CFWL_Form::Layout() { |
405 GetRelativeRect(m_rtRelative); | 405 GetRelativeRect(m_rtRelative); |
406 | 406 |
407 #ifndef FWL_UseMacSystemBorder | 407 #ifndef FWL_UseMacSystemBorder |
408 ResetSysBtn(); | 408 ResetSysBtn(); |
409 #endif | 409 #endif |
410 } | 410 } |
411 | 411 |
412 void IFWL_Form::ResetSysBtn() { | 412 void CFWL_Form::ResetSysBtn() { |
413 m_fCXBorder = | 413 m_fCXBorder = |
414 *static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::CXBorder)); | 414 *static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::CXBorder)); |
415 m_fCYBorder = | 415 m_fCYBorder = |
416 *static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::CYBorder)); | 416 *static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::CYBorder)); |
417 RemoveSysButtons(); | 417 RemoveSysButtons(); |
418 | 418 |
419 m_iSysBox = 0; | 419 m_iSysBox = 0; |
420 if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_CloseBox) { | 420 if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_CloseBox) { |
421 m_pCloseBox = new CFWL_SysBtn; | 421 m_pCloseBox = new CFWL_SysBtn; |
422 m_pCloseBox->m_rtBtn.Set( | 422 m_pCloseBox->m_rtBtn.Set( |
(...skipping 26 matching lines...) Expand all Loading... |
449 m_pCloseBox->m_rtBtn.top, kSystemButtonSize, kSystemButtonSize); | 449 m_pCloseBox->m_rtBtn.top, kSystemButtonSize, kSystemButtonSize); |
450 } else { | 450 } else { |
451 m_pMinBox->m_rtBtn.Set( | 451 m_pMinBox->m_rtBtn.Set( |
452 m_rtRelative.right() - kSystemButtonMargin - kSystemButtonSize, | 452 m_rtRelative.right() - kSystemButtonMargin - kSystemButtonSize, |
453 kSystemButtonMargin, kSystemButtonSize, kSystemButtonSize); | 453 kSystemButtonMargin, kSystemButtonSize, kSystemButtonSize); |
454 } | 454 } |
455 m_iSysBox++; | 455 m_iSysBox++; |
456 } | 456 } |
457 } | 457 } |
458 | 458 |
459 void IFWL_Form::RegisterForm() { | 459 void CFWL_Form::RegisterForm() { |
460 const CFWL_App* pApp = GetOwnerApp(); | 460 const CFWL_App* pApp = GetOwnerApp(); |
461 if (!pApp) | 461 if (!pApp) |
462 return; | 462 return; |
463 | 463 |
464 CFWL_NoteDriver* pDriver = | 464 CFWL_NoteDriver* pDriver = |
465 static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver()); | 465 static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver()); |
466 if (!pDriver) | 466 if (!pDriver) |
467 return; | 467 return; |
468 | 468 |
469 pDriver->RegisterForm(this); | 469 pDriver->RegisterForm(this); |
470 } | 470 } |
471 | 471 |
472 void IFWL_Form::UnRegisterForm() { | 472 void CFWL_Form::UnRegisterForm() { |
473 const CFWL_App* pApp = GetOwnerApp(); | 473 const CFWL_App* pApp = GetOwnerApp(); |
474 if (!pApp) | 474 if (!pApp) |
475 return; | 475 return; |
476 | 476 |
477 CFWL_NoteDriver* pDriver = | 477 CFWL_NoteDriver* pDriver = |
478 static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver()); | 478 static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver()); |
479 if (!pDriver) | 479 if (!pDriver) |
480 return; | 480 return; |
481 | 481 |
482 pDriver->UnRegisterForm(this); | 482 pDriver->UnRegisterForm(this); |
483 } | 483 } |
484 | 484 |
485 void IFWL_Form::OnProcessMessage(CFWL_Message* pMessage) { | 485 void CFWL_Form::OnProcessMessage(CFWL_Message* pMessage) { |
486 #ifndef FWL_UseMacSystemBorder | 486 #ifndef FWL_UseMacSystemBorder |
487 if (!pMessage) | 487 if (!pMessage) |
488 return; | 488 return; |
489 | 489 |
490 switch (pMessage->GetClassID()) { | 490 switch (pMessage->GetClassID()) { |
491 case CFWL_MessageType::Mouse: { | 491 case CFWL_MessageType::Mouse: { |
492 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); | 492 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); |
493 switch (pMsg->m_dwCmd) { | 493 switch (pMsg->m_dwCmd) { |
494 case FWL_MouseCommand::LeftButtonDown: | 494 case FWL_MouseCommand::LeftButtonDown: |
495 OnLButtonDown(pMsg); | 495 OnLButtonDown(pMsg); |
(...skipping 14 matching lines...) Expand all Loading... |
510 break; | 510 break; |
511 } | 511 } |
512 break; | 512 break; |
513 } | 513 } |
514 default: | 514 default: |
515 break; | 515 break; |
516 } | 516 } |
517 #endif // FWL_UseMacSystemBorder | 517 #endif // FWL_UseMacSystemBorder |
518 } | 518 } |
519 | 519 |
520 void IFWL_Form::OnDrawWidget(CFX_Graphics* pGraphics, | 520 void CFWL_Form::OnDrawWidget(CFX_Graphics* pGraphics, |
521 const CFX_Matrix* pMatrix) { | 521 const CFX_Matrix* pMatrix) { |
522 DrawWidget(pGraphics, pMatrix); | 522 DrawWidget(pGraphics, pMatrix); |
523 } | 523 } |
524 | 524 |
525 void IFWL_Form::OnLButtonDown(CFWL_MsgMouse* pMsg) { | 525 void CFWL_Form::OnLButtonDown(CFWL_MsgMouse* pMsg) { |
526 SetGrab(true); | 526 SetGrab(true); |
527 m_bLButtonDown = true; | 527 m_bLButtonDown = true; |
528 | 528 |
529 CFWL_SysBtn* pPressBtn = GetSysBtnAtPoint(pMsg->m_fx, pMsg->m_fy); | 529 CFWL_SysBtn* pPressBtn = GetSysBtnAtPoint(pMsg->m_fx, pMsg->m_fy); |
530 m_iCaptureBtn = GetSysBtnIndex(pPressBtn); | 530 m_iCaptureBtn = GetSysBtnIndex(pPressBtn); |
531 | 531 |
532 if (!pPressBtn) | 532 if (!pPressBtn) |
533 return; | 533 return; |
534 | 534 |
535 pPressBtn->SetPressed(); | 535 pPressBtn->SetPressed(); |
536 Repaint(&pPressBtn->m_rtBtn); | 536 Repaint(&pPressBtn->m_rtBtn); |
537 } | 537 } |
538 | 538 |
539 void IFWL_Form::OnLButtonUp(CFWL_MsgMouse* pMsg) { | 539 void CFWL_Form::OnLButtonUp(CFWL_MsgMouse* pMsg) { |
540 SetGrab(false); | 540 SetGrab(false); |
541 m_bLButtonDown = false; | 541 m_bLButtonDown = false; |
542 CFWL_SysBtn* pPointBtn = GetSysBtnAtPoint(pMsg->m_fx, pMsg->m_fy); | 542 CFWL_SysBtn* pPointBtn = GetSysBtnAtPoint(pMsg->m_fx, pMsg->m_fy); |
543 CFWL_SysBtn* pPressedBtn = GetSysBtnByIndex(m_iCaptureBtn); | 543 CFWL_SysBtn* pPressedBtn = GetSysBtnByIndex(m_iCaptureBtn); |
544 if (!pPressedBtn || pPointBtn != pPressedBtn) | 544 if (!pPressedBtn || pPointBtn != pPressedBtn) |
545 return; | 545 return; |
546 if (pPressedBtn == GetSysBtnByState(FWL_SYSBUTTONSTATE_Pressed)) | 546 if (pPressedBtn == GetSysBtnByState(FWL_SYSBUTTONSTATE_Pressed)) |
547 pPressedBtn->SetNormal(); | 547 pPressedBtn->SetNormal(); |
548 if (pPressedBtn == m_pMaxBox) { | 548 if (pPressedBtn == m_pMaxBox) { |
549 if (m_bMaximized) { | 549 if (m_bMaximized) { |
550 SetWidgetRect(m_rtRestore); | 550 SetWidgetRect(m_rtRestore); |
551 Update(); | 551 Update(); |
552 Repaint(); | 552 Repaint(); |
553 } else { | 553 } else { |
554 SetWorkAreaRect(); | 554 SetWorkAreaRect(); |
555 Update(); | 555 Update(); |
556 } | 556 } |
557 m_bMaximized = !m_bMaximized; | 557 m_bMaximized = !m_bMaximized; |
558 } else if (pPressedBtn != m_pMinBox) { | 558 } else if (pPressedBtn != m_pMinBox) { |
559 CFWL_EvtClose eClose; | 559 CFWL_EvtClose eClose; |
560 eClose.m_pSrcTarget = this; | 560 eClose.m_pSrcTarget = this; |
561 DispatchEvent(&eClose); | 561 DispatchEvent(&eClose); |
562 } | 562 } |
563 } | 563 } |
564 | 564 |
565 void IFWL_Form::OnMouseMove(CFWL_MsgMouse* pMsg) { | 565 void CFWL_Form::OnMouseMove(CFWL_MsgMouse* pMsg) { |
566 if (m_bLButtonDown) | 566 if (m_bLButtonDown) |
567 return; | 567 return; |
568 | 568 |
569 CFX_RectF rtInvalidate; | 569 CFX_RectF rtInvalidate; |
570 rtInvalidate.Reset(); | 570 rtInvalidate.Reset(); |
571 CFWL_SysBtn* pPointBtn = GetSysBtnAtPoint(pMsg->m_fx, pMsg->m_fy); | 571 CFWL_SysBtn* pPointBtn = GetSysBtnAtPoint(pMsg->m_fx, pMsg->m_fy); |
572 CFWL_SysBtn* pOldHover = GetSysBtnByState(FWL_SYSBUTTONSTATE_Hover); | 572 CFWL_SysBtn* pOldHover = GetSysBtnByState(FWL_SYSBUTTONSTATE_Hover); |
573 | 573 |
574 #if _FX_OS_ == _FX_MACOSX_ | 574 #if _FX_OS_ == _FX_MACOSX_ |
575 { | 575 { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
609 else | 609 else |
610 rtInvalidate.Union(pPointBtn->m_rtBtn); | 610 rtInvalidate.Union(pPointBtn->m_rtBtn); |
611 } | 611 } |
612 } | 612 } |
613 #endif | 613 #endif |
614 | 614 |
615 if (!rtInvalidate.IsEmpty()) | 615 if (!rtInvalidate.IsEmpty()) |
616 Repaint(&rtInvalidate); | 616 Repaint(&rtInvalidate); |
617 } | 617 } |
618 | 618 |
619 void IFWL_Form::OnMouseLeave(CFWL_MsgMouse* pMsg) { | 619 void CFWL_Form::OnMouseLeave(CFWL_MsgMouse* pMsg) { |
620 CFWL_SysBtn* pHover = GetSysBtnByState(FWL_SYSBUTTONSTATE_Hover); | 620 CFWL_SysBtn* pHover = GetSysBtnByState(FWL_SYSBUTTONSTATE_Hover); |
621 if (!pHover) | 621 if (!pHover) |
622 return; | 622 return; |
623 | 623 |
624 pHover->SetNormal(); | 624 pHover->SetNormal(); |
625 Repaint(&pHover->m_rtBtn); | 625 Repaint(&pHover->m_rtBtn); |
626 } | 626 } |
627 | 627 |
628 void IFWL_Form::OnLButtonDblClk(CFWL_MsgMouse* pMsg) { | 628 void CFWL_Form::OnLButtonDblClk(CFWL_MsgMouse* pMsg) { |
629 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_FRM_Resize) && | 629 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_FRM_Resize) && |
630 HitTest(pMsg->m_fx, pMsg->m_fy) == FWL_WidgetHit::Titlebar) { | 630 HitTest(pMsg->m_fx, pMsg->m_fy) == FWL_WidgetHit::Titlebar) { |
631 if (m_bMaximized) | 631 if (m_bMaximized) |
632 SetWidgetRect(m_rtRestore); | 632 SetWidgetRect(m_rtRestore); |
633 else | 633 else |
634 SetWorkAreaRect(); | 634 SetWorkAreaRect(); |
635 | 635 |
636 Update(); | 636 Update(); |
637 m_bMaximized = !m_bMaximized; | 637 m_bMaximized = !m_bMaximized; |
638 } | 638 } |
639 } | 639 } |
OLD | NEW |