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/cfwl_widget.h" | 7 #include "xfa/fwl/core/cfwl_widget.h" |
8 | 8 |
9 #include "xfa/fde/tto/fde_textout.h" | 9 #include "xfa/fde/tto/fde_textout.h" |
10 #include "xfa/fwl/core/cfwl_themetext.h" | 10 #include "xfa/fwl/core/cfwl_themetext.h" |
11 #include "xfa/fwl/core/cfwl_widgetmgr.h" | 11 #include "xfa/fwl/core/cfwl_widgetmgr.h" |
12 #include "xfa/fwl/core/fwl_noteimp.h" | 12 #include "xfa/fwl/core/fwl_noteimp.h" |
13 #include "xfa/fwl/core/fwl_noteimp.h" | 13 #include "xfa/fwl/core/fwl_noteimp.h" |
14 #include "xfa/fwl/core/ifwl_app.h" | 14 #include "xfa/fwl/core/ifwl_app.h" |
15 #include "xfa/fwl/core/ifwl_themeprovider.h" | 15 #include "xfa/fwl/core/ifwl_themeprovider.h" |
16 | 16 |
17 #define FWL_WGT_CalcHeight 2048 | 17 #define FWL_WGT_CalcHeight 2048 |
18 #define FWL_WGT_CalcWidth 2048 | 18 #define FWL_WGT_CalcWidth 2048 |
19 #define FWL_WGT_CalcMultiLineDefWidth 120.0f | 19 #define FWL_WGT_CalcMultiLineDefWidth 120.0f |
20 | 20 |
21 CFWL_Widget::CFWL_Widget(const IFWL_App* app) : m_pApp(app) {} | 21 CFWL_Widget::CFWL_Widget(const IFWL_App* app) : m_pApp(app) {} |
22 | 22 |
23 CFWL_Widget::~CFWL_Widget() {} | 23 CFWL_Widget::~CFWL_Widget() {} |
24 | 24 |
25 void CFWL_Widget::Initialize() { | 25 void CFWL_Widget::Initialize() { |
26 ASSERT(m_pIface); | 26 ASSERT(m_pIface); |
27 m_pIface->SetAssociateWidget(this); | 27 m_pIface->SetAssociateWidget(this); |
28 } | 28 } |
29 | 29 |
30 IFWL_Widget* CFWL_Widget::GetWidget() { | |
31 return m_pIface.get(); | |
32 } | |
33 | |
34 const IFWL_Widget* CFWL_Widget::GetWidget() const { | |
35 return m_pIface.get(); | |
36 } | |
37 | |
38 void CFWL_Widget::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { | 30 void CFWL_Widget::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { |
39 if (m_pIface) | 31 if (m_pIface) |
40 m_pIface->GetWidgetRect(rect, bAutoSize); | 32 m_pIface->GetWidgetRect(rect, bAutoSize); |
41 } | 33 } |
42 | 34 |
43 void CFWL_Widget::SetWidgetRect(const CFX_RectF& rect) { | 35 void CFWL_Widget::SetWidgetRect(const CFX_RectF& rect) { |
44 if (m_pIface) | 36 if (m_pIface) |
45 m_pIface->SetWidgetRect(rect); | 37 m_pIface->SetWidgetRect(rect); |
46 } | 38 } |
47 | 39 |
48 void CFWL_Widget::ModifyStyles(uint32_t dwStylesAdded, | 40 void CFWL_Widget::ModifyStyles(uint32_t dwStylesAdded, |
49 uint32_t dwStylesRemoved) { | 41 uint32_t dwStylesRemoved) { |
50 if (m_pIface) | 42 if (m_pIface) |
51 m_pIface->ModifyStyles(dwStylesAdded, dwStylesRemoved); | 43 m_pIface->ModifyStyles(dwStylesAdded, dwStylesRemoved); |
52 } | 44 } |
53 | 45 |
54 uint32_t CFWL_Widget::GetStylesEx() { | 46 uint32_t CFWL_Widget::GetStylesEx() { |
55 if (!m_pIface) | 47 return m_pIface ? m_pIface->GetStylesEx() : 0; |
56 return 0; | |
57 return m_pIface->GetStylesEx(); | |
58 } | 48 } |
59 | 49 |
60 void CFWL_Widget::ModifyStylesEx(uint32_t dwStylesExAdded, | 50 void CFWL_Widget::ModifyStylesEx(uint32_t dwStylesExAdded, |
61 uint32_t dwStylesExRemoved) { | 51 uint32_t dwStylesExRemoved) { |
62 m_pIface->ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); | 52 m_pIface->ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); |
63 } | 53 } |
64 | 54 |
65 uint32_t CFWL_Widget::GetStates() { | 55 uint32_t CFWL_Widget::GetStates() { |
66 return m_pIface ? m_pIface->GetStates() : 0; | 56 return m_pIface ? m_pIface->GetStates() : 0; |
67 } | 57 } |
68 | 58 |
69 void CFWL_Widget::SetStates(uint32_t dwStates, bool bSet) { | 59 void CFWL_Widget::SetStates(uint32_t dwStates, bool bSet) { |
70 if (m_pIface) | 60 if (m_pIface) |
71 m_pIface->SetStates(dwStates, bSet); | 61 m_pIface->SetStates(dwStates, bSet); |
72 } | 62 } |
73 | 63 |
74 void CFWL_Widget::SetLayoutItem(void* pItem) { | 64 void CFWL_Widget::SetLayoutItem(void* pItem) { |
75 if (m_pIface) | 65 if (m_pIface) |
76 m_pIface->SetLayoutItem(pItem); | 66 m_pIface->SetLayoutItem(pItem); |
77 } | 67 } |
78 | 68 |
79 void CFWL_Widget::Update() { | 69 void CFWL_Widget::Update() { |
80 if (!m_pIface) | 70 if (m_pIface) |
81 return; | 71 m_pIface->Update(); |
82 m_pIface->Update(); | |
83 } | 72 } |
84 | 73 |
85 void CFWL_Widget::LockUpdate() { | 74 void CFWL_Widget::LockUpdate() { |
86 if (!m_pIface) | 75 if (m_pIface) |
87 return; | 76 m_pIface->LockUpdate(); |
88 m_pIface->LockUpdate(); | |
89 } | 77 } |
90 | 78 |
91 void CFWL_Widget::UnlockUpdate() { | 79 void CFWL_Widget::UnlockUpdate() { |
92 if (!m_pIface) | 80 if (m_pIface) |
93 return; | 81 m_pIface->UnlockUpdate(); |
94 m_pIface->UnlockUpdate(); | |
95 } | 82 } |
96 | 83 |
97 FWL_WidgetHit CFWL_Widget::HitTest(FX_FLOAT fx, FX_FLOAT fy) { | 84 FWL_WidgetHit CFWL_Widget::HitTest(FX_FLOAT fx, FX_FLOAT fy) { |
98 if (!m_pIface) | 85 if (!m_pIface) |
99 return FWL_WidgetHit::Unknown; | 86 return FWL_WidgetHit::Unknown; |
100 return m_pIface->HitTest(fx, fy); | 87 return m_pIface->HitTest(fx, fy); |
101 } | 88 } |
102 | 89 |
103 void CFWL_Widget::DrawWidget(CFX_Graphics* pGraphics, | 90 void CFWL_Widget::DrawWidget(CFX_Graphics* pGraphics, |
104 const CFX_Matrix* pMatrix) { | 91 const CFX_Matrix* pMatrix) { |
105 if (m_pIface) | 92 if (m_pIface) |
106 m_pIface->DrawWidget(pGraphics, pMatrix); | 93 m_pIface->DrawWidget(pGraphics, pMatrix); |
107 } | 94 } |
108 | 95 |
109 IFWL_WidgetDelegate* CFWL_Widget::GetDelegate() const { | 96 IFWL_WidgetDelegate* CFWL_Widget::GetDelegate() const { |
110 return m_pIface ? m_pIface->GetDelegate() : nullptr; | 97 return m_pIface ? m_pIface->GetDelegate() : nullptr; |
111 } | 98 } |
112 | 99 |
113 void CFWL_Widget::SetDelegate(IFWL_WidgetDelegate* pDelegate) { | 100 void CFWL_Widget::SetDelegate(IFWL_WidgetDelegate* pDelegate) { |
114 if (m_pIface) | 101 if (m_pIface) |
115 m_pIface->SetDelegate(pDelegate); | 102 m_pIface->SetDelegate(pDelegate); |
116 } | 103 } |
OLD | NEW |