Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(273)

Side by Side Diff: xfa/fwl/lightwidget/cfwl_widget.cpp

Issue 1834323003: Move xfa/include/fwl/{theme,lightwidget} to xfa/fwl (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/include/fwl/lightwidget/widget.h" 7 #include "xfa/fwl/lightwidget/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/fwl_noteimp.h" 11 #include "xfa/fwl/core/fwl_noteimp.h"
12 #include "xfa/fwl/core/fwl_noteimp.h" 12 #include "xfa/fwl/core/fwl_noteimp.h"
13 #include "xfa/fwl/core/fwl_targetimp.h" 13 #include "xfa/fwl/core/fwl_targetimp.h"
14 #include "xfa/fwl/core/fwl_widgetimp.h" 14 #include "xfa/fwl/core/fwl_widgetimp.h"
15 #include "xfa/fwl/core/fwl_widgetmgrimp.h" 15 #include "xfa/fwl/core/fwl_widgetmgrimp.h"
16 #include "xfa/fwl/core/ifwl_notethread.h" 16 #include "xfa/fwl/core/ifwl_notethread.h"
17 #include "xfa/fwl/core/ifwl_themeprovider.h" 17 #include "xfa/fwl/core/ifwl_themeprovider.h"
18 18
19 CFWL_WidgetImpProperties CFWL_WidgetProperties::MakeWidgetImpProperties(
20 IFWL_DataProvider* pDataProvider) const {
21 CFWL_WidgetImpProperties result;
22 result.m_ctmOnParent = m_ctmOnParent;
23 result.m_rtWidget = m_rtWidget;
24 result.m_dwStyles = m_dwStyles;
25 result.m_dwStyleExes = m_dwStyleExes;
26 result.m_dwStates = m_dwStates;
27 if (m_pParent)
28 result.m_pParent = m_pParent->GetWidget();
29 if (m_pOwner)
30 result.m_pOwner = m_pOwner->GetWidget();
31 result.m_pDataProvider = pDataProvider;
32 return result;
33 }
34 IFWL_Widget* CFWL_Widget::GetWidget() { 19 IFWL_Widget* CFWL_Widget::GetWidget() {
35 return m_pIface; 20 return m_pIface;
36 } 21 }
22
37 FWL_ERR CFWL_Widget::GetClassName(CFX_WideString& wsClass) const { 23 FWL_ERR CFWL_Widget::GetClassName(CFX_WideString& wsClass) const {
38 if (!m_pIface) 24 if (!m_pIface)
39 return FWL_ERR_Indefinite; 25 return FWL_ERR_Indefinite;
40 return m_pIface->GetClassName(wsClass); 26 return m_pIface->GetClassName(wsClass);
41 } 27 }
28
42 uint32_t CFWL_Widget::GetClassID() const { 29 uint32_t CFWL_Widget::GetClassID() const {
43 if (!m_pIface) 30 if (!m_pIface)
44 return 0; 31 return 0;
45 return m_pIface->GetClassID(); 32 return m_pIface->GetClassID();
46 } 33 }
34
47 FX_BOOL CFWL_Widget::IsInstance(const CFX_WideStringC& wsClass) const { 35 FX_BOOL CFWL_Widget::IsInstance(const CFX_WideStringC& wsClass) const {
48 if (!m_pIface) 36 if (!m_pIface)
49 return FALSE; 37 return FALSE;
50 return m_pIface->IsInstance(wsClass); 38 return m_pIface->IsInstance(wsClass);
51 } 39 }
40
52 static void* gs_pFWLWidget = (void*)FXBSTR_ID('l', 'i', 'g', 't'); 41 static void* gs_pFWLWidget = (void*)FXBSTR_ID('l', 'i', 'g', 't');
42
53 FWL_ERR CFWL_Widget::Initialize(const CFWL_WidgetProperties* pProperties) { 43 FWL_ERR CFWL_Widget::Initialize(const CFWL_WidgetProperties* pProperties) {
54 if (!m_pIface) 44 if (!m_pIface)
55 return FWL_ERR_Indefinite; 45 return FWL_ERR_Indefinite;
56 return m_pIface->SetPrivateData(gs_pFWLWidget, this, NULL); 46 return m_pIface->SetPrivateData(gs_pFWLWidget, this, NULL);
57 } 47 }
48
58 FWL_ERR CFWL_Widget::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { 49 FWL_ERR CFWL_Widget::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
59 if (!m_pIface) 50 if (!m_pIface)
60 return FWL_ERR_Indefinite; 51 return FWL_ERR_Indefinite;
61 return m_pIface->GetWidgetRect(rect, bAutoSize); 52 return m_pIface->GetWidgetRect(rect, bAutoSize);
62 } 53 }
54
63 FWL_ERR CFWL_Widget::GetGlobalRect(CFX_RectF& rect) { 55 FWL_ERR CFWL_Widget::GetGlobalRect(CFX_RectF& rect) {
64 if (!m_pIface) 56 if (!m_pIface)
65 return FWL_ERR_Indefinite; 57 return FWL_ERR_Indefinite;
66 return m_pIface->GetGlobalRect(rect); 58 return m_pIface->GetGlobalRect(rect);
67 } 59 }
60
68 FWL_ERR CFWL_Widget::SetWidgetRect(const CFX_RectF& rect) { 61 FWL_ERR CFWL_Widget::SetWidgetRect(const CFX_RectF& rect) {
69 if (!m_pIface) 62 if (!m_pIface)
70 return FWL_ERR_Indefinite; 63 return FWL_ERR_Indefinite;
71 return m_pIface->SetWidgetRect(rect); 64 return m_pIface->SetWidgetRect(rect);
72 } 65 }
66
73 FWL_ERR CFWL_Widget::GetClientRect(CFX_RectF& rect) { 67 FWL_ERR CFWL_Widget::GetClientRect(CFX_RectF& rect) {
74 if (!m_pIface) 68 if (!m_pIface)
75 return FWL_ERR_Indefinite; 69 return FWL_ERR_Indefinite;
76 return m_pIface->GetClientRect(rect); 70 return m_pIface->GetClientRect(rect);
77 } 71 }
72
78 CFWL_Widget* CFWL_Widget::GetParent() { 73 CFWL_Widget* CFWL_Widget::GetParent() {
79 if (!m_pIface) 74 if (!m_pIface)
80 return NULL; 75 return NULL;
81 IFWL_Widget* parent = m_pIface->GetParent(); 76 IFWL_Widget* parent = m_pIface->GetParent();
82 if (parent) { 77 if (parent) {
83 return static_cast<CFWL_Widget*>(parent->GetPrivateData(gs_pFWLWidget)); 78 return static_cast<CFWL_Widget*>(parent->GetPrivateData(gs_pFWLWidget));
84 } 79 }
85 return NULL; 80 return NULL;
86 } 81 }
82
87 FWL_ERR CFWL_Widget::SetParent(CFWL_Widget* pParent) { 83 FWL_ERR CFWL_Widget::SetParent(CFWL_Widget* pParent) {
88 if (!m_pIface) 84 if (!m_pIface)
89 return FWL_ERR_Indefinite; 85 return FWL_ERR_Indefinite;
90 return m_pIface->SetParent(pParent ? pParent->GetWidget() : NULL); 86 return m_pIface->SetParent(pParent ? pParent->GetWidget() : NULL);
91 } 87 }
88
92 CFWL_Widget* CFWL_Widget::GetOwner() { 89 CFWL_Widget* CFWL_Widget::GetOwner() {
93 if (!m_pIface) 90 if (!m_pIface)
94 return NULL; 91 return NULL;
95 return NULL; 92 return NULL;
96 } 93 }
94
97 FWL_ERR CFWL_Widget::SetOwner(CFWL_Widget* pOwner) { 95 FWL_ERR CFWL_Widget::SetOwner(CFWL_Widget* pOwner) {
98 if (!m_pIface) 96 if (!m_pIface)
99 return FWL_ERR_Indefinite; 97 return FWL_ERR_Indefinite;
100 return FWL_ERR_Succeeded; 98 return FWL_ERR_Succeeded;
101 } 99 }
100
102 uint32_t CFWL_Widget::GetStyles() { 101 uint32_t CFWL_Widget::GetStyles() {
103 if (!m_pIface) 102 if (!m_pIface)
104 return 0; 103 return 0;
105 return m_pIface->GetStyles(); 104 return m_pIface->GetStyles();
106 } 105 }
106
107 FWL_ERR CFWL_Widget::ModifyStyles(uint32_t dwStylesAdded, 107 FWL_ERR CFWL_Widget::ModifyStyles(uint32_t dwStylesAdded,
108 uint32_t dwStylesRemoved) { 108 uint32_t dwStylesRemoved) {
109 if (!m_pIface) 109 if (!m_pIface)
110 return FWL_ERR_Indefinite; 110 return FWL_ERR_Indefinite;
111 return m_pIface->ModifyStyles(dwStylesAdded, dwStylesRemoved); 111 return m_pIface->ModifyStyles(dwStylesAdded, dwStylesRemoved);
112 } 112 }
113 uint32_t CFWL_Widget::GetStylesEx() { 113 uint32_t CFWL_Widget::GetStylesEx() {
114 if (!m_pIface) 114 if (!m_pIface)
115 return 0; 115 return 0;
116 return m_pIface->GetStylesEx(); 116 return m_pIface->GetStylesEx();
117 } 117 }
118
118 FWL_ERR CFWL_Widget::ModifyStylesEx(uint32_t dwStylesExAdded, 119 FWL_ERR CFWL_Widget::ModifyStylesEx(uint32_t dwStylesExAdded,
119 uint32_t dwStylesExRemoved) { 120 uint32_t dwStylesExRemoved) {
120 return m_pIface->ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); 121 return m_pIface->ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved);
121 } 122 }
123
122 uint32_t CFWL_Widget::GetStates() { 124 uint32_t CFWL_Widget::GetStates() {
123 if (!m_pIface) 125 if (!m_pIface)
124 return FWL_ERR_Indefinite; 126 return FWL_ERR_Indefinite;
125 return m_pIface->GetStates(); 127 return m_pIface->GetStates();
126 } 128 }
129
127 FWL_ERR CFWL_Widget::SetStates(uint32_t dwStates, FX_BOOL bSet) { 130 FWL_ERR CFWL_Widget::SetStates(uint32_t dwStates, FX_BOOL bSet) {
128 if (!m_pIface) 131 if (!m_pIface)
129 return FWL_ERR_Indefinite; 132 return FWL_ERR_Indefinite;
130 return m_pIface->SetStates(dwStates, bSet); 133 return m_pIface->SetStates(dwStates, bSet);
131 } 134 }
135
132 FWL_ERR CFWL_Widget::SetPrivateData(void* module_id, 136 FWL_ERR CFWL_Widget::SetPrivateData(void* module_id,
133 void* pData, 137 void* pData,
134 PD_CALLBACK_FREEDATA callback) { 138 PD_CALLBACK_FREEDATA callback) {
135 if (!m_pIface) 139 if (!m_pIface)
136 return FWL_ERR_Indefinite; 140 return FWL_ERR_Indefinite;
137 return m_pIface->SetPrivateData(module_id, pData, callback); 141 return m_pIface->SetPrivateData(module_id, pData, callback);
138 } 142 }
143
139 void* CFWL_Widget::GetPrivateData(void* module_id) { 144 void* CFWL_Widget::GetPrivateData(void* module_id) {
140 if (!m_pIface) 145 if (!m_pIface)
141 return NULL; 146 return NULL;
142 return m_pIface->GetPrivateData(module_id); 147 return m_pIface->GetPrivateData(module_id);
143 } 148 }
149
144 FWL_ERR CFWL_Widget::Update() { 150 FWL_ERR CFWL_Widget::Update() {
145 if (!m_pIface) 151 if (!m_pIface)
146 return FWL_ERR_Indefinite; 152 return FWL_ERR_Indefinite;
147 return m_pIface->Update(); 153 return m_pIface->Update();
148 } 154 }
155
149 FWL_ERR CFWL_Widget::LockUpdate() { 156 FWL_ERR CFWL_Widget::LockUpdate() {
150 if (!m_pIface) 157 if (!m_pIface)
151 return FWL_ERR_Indefinite; 158 return FWL_ERR_Indefinite;
152 return m_pIface->LockUpdate(); 159 return m_pIface->LockUpdate();
153 } 160 }
161
154 FWL_ERR CFWL_Widget::UnlockUpdate() { 162 FWL_ERR CFWL_Widget::UnlockUpdate() {
155 if (!m_pIface) 163 if (!m_pIface)
156 return FWL_ERR_Indefinite; 164 return FWL_ERR_Indefinite;
157 return m_pIface->UnlockUpdate(); 165 return m_pIface->UnlockUpdate();
158 } 166 }
167
159 uint32_t CFWL_Widget::HitTest(FX_FLOAT fx, FX_FLOAT fy) { 168 uint32_t CFWL_Widget::HitTest(FX_FLOAT fx, FX_FLOAT fy) {
160 if (!m_pIface) 169 if (!m_pIface)
161 return 0; 170 return 0;
162 return m_pIface->HitTest(fx, fy); 171 return m_pIface->HitTest(fx, fy);
163 } 172 }
173
164 FWL_ERR CFWL_Widget::TransformTo(CFWL_Widget* pWidget, 174 FWL_ERR CFWL_Widget::TransformTo(CFWL_Widget* pWidget,
165 FX_FLOAT& fx, 175 FX_FLOAT& fx,
166 FX_FLOAT& fy) { 176 FX_FLOAT& fy) {
167 if (!m_pIface) 177 if (!m_pIface)
168 return FWL_ERR_Indefinite; 178 return FWL_ERR_Indefinite;
169 return m_pIface->TransformTo(pWidget ? pWidget->GetWidget() : NULL, fx, fy); 179 return m_pIface->TransformTo(pWidget ? pWidget->GetWidget() : NULL, fx, fy);
170 } 180 }
181
171 FWL_ERR CFWL_Widget::TransformTo(CFWL_Widget* pWidget, CFX_RectF& rt) { 182 FWL_ERR CFWL_Widget::TransformTo(CFWL_Widget* pWidget, CFX_RectF& rt) {
172 if (!m_pIface) 183 if (!m_pIface)
173 return FWL_ERR_Indefinite; 184 return FWL_ERR_Indefinite;
174 return m_pIface->TransformTo(pWidget ? pWidget->GetWidget() : NULL, rt); 185 return m_pIface->TransformTo(pWidget ? pWidget->GetWidget() : NULL, rt);
175 } 186 }
187
176 FWL_ERR CFWL_Widget::GetMatrix(CFX_Matrix& matrix, FX_BOOL bGlobal) { 188 FWL_ERR CFWL_Widget::GetMatrix(CFX_Matrix& matrix, FX_BOOL bGlobal) {
177 if (!m_pIface) 189 if (!m_pIface)
178 return FWL_ERR_Indefinite; 190 return FWL_ERR_Indefinite;
179 return m_pIface->GetMatrix(matrix, bGlobal); 191 return m_pIface->GetMatrix(matrix, bGlobal);
180 } 192 }
193
181 FWL_ERR CFWL_Widget::SetMatrix(const CFX_Matrix& matrix) { 194 FWL_ERR CFWL_Widget::SetMatrix(const CFX_Matrix& matrix) {
182 if (!m_pIface) 195 if (!m_pIface)
183 return FWL_ERR_Indefinite; 196 return FWL_ERR_Indefinite;
184 return m_pIface->SetMatrix(matrix); 197 return m_pIface->SetMatrix(matrix);
185 } 198 }
199
186 FWL_ERR CFWL_Widget::DrawWidget(CFX_Graphics* pGraphics, 200 FWL_ERR CFWL_Widget::DrawWidget(CFX_Graphics* pGraphics,
187 const CFX_Matrix* pMatrix) { 201 const CFX_Matrix* pMatrix) {
188 if (!m_pIface) 202 if (!m_pIface)
189 return FWL_ERR_Indefinite; 203 return FWL_ERR_Indefinite;
190 return m_pIface->DrawWidget(pGraphics, pMatrix); 204 return m_pIface->DrawWidget(pGraphics, pMatrix);
191 } 205 }
206
192 IFWL_WidgetDelegate* CFWL_Widget::SetDelegate(IFWL_WidgetDelegate* pDelegate) { 207 IFWL_WidgetDelegate* CFWL_Widget::SetDelegate(IFWL_WidgetDelegate* pDelegate) {
193 if (!m_pIface) 208 if (!m_pIface)
194 return NULL; 209 return NULL;
195 m_pDelegate = m_pIface->SetDelegate(pDelegate); 210 m_pDelegate = m_pIface->SetDelegate(pDelegate);
196 return m_pDelegate; 211 return m_pDelegate;
197 } 212 }
213
198 CFWL_Widget::CFWL_Widget() 214 CFWL_Widget::CFWL_Widget()
199 : m_pIface(NULL), m_pDelegate(NULL), m_pProperties(NULL) { 215 : m_pIface(NULL), m_pDelegate(NULL), m_pProperties(NULL) {
200 m_pProperties = new CFWL_WidgetProperties; 216 m_pProperties = new CFWL_WidgetProperties;
201 m_pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); 217 m_pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr());
202 FXSYS_assert(m_pWidgetMgr != NULL); 218 FXSYS_assert(m_pWidgetMgr != NULL);
203 } 219 }
220
204 CFWL_Widget::~CFWL_Widget() { 221 CFWL_Widget::~CFWL_Widget() {
205 delete m_pProperties; 222 delete m_pProperties;
206 if (m_pIface) { 223 if (m_pIface) {
207 m_pIface->Finalize(); 224 m_pIface->Finalize();
208 delete m_pIface; 225 delete m_pIface;
209 } 226 }
210 } 227 }
228
211 FWL_ERR CFWL_Widget::Repaint(const CFX_RectF* pRect) { 229 FWL_ERR CFWL_Widget::Repaint(const CFX_RectF* pRect) {
212 if (!m_pIface) 230 if (!m_pIface)
213 return FWL_ERR_Indefinite; 231 return FWL_ERR_Indefinite;
214 CFX_RectF rect; 232 CFX_RectF rect;
215 if (pRect) { 233 if (pRect) {
216 rect = *pRect; 234 rect = *pRect;
217 } else { 235 } else {
218 m_pIface->GetWidgetRect(rect); 236 m_pIface->GetWidgetRect(rect);
219 rect.left = rect.top = 0; 237 rect.left = rect.top = 0;
220 } 238 }
221 return m_pWidgetMgr->RepaintWidget(m_pIface, &rect); 239 return m_pWidgetMgr->RepaintWidget(m_pIface, &rect);
222 } 240 }
241
223 FWL_ERR CFWL_Widget::SetFocus(FX_BOOL bFocus) { 242 FWL_ERR CFWL_Widget::SetFocus(FX_BOOL bFocus) {
224 if (!m_pIface) 243 if (!m_pIface)
225 return FWL_ERR_Indefinite; 244 return FWL_ERR_Indefinite;
226 IFWL_NoteThread* pThread = m_pIface->GetOwnerThread(); 245 IFWL_NoteThread* pThread = m_pIface->GetOwnerThread();
227 if (!pThread) 246 if (!pThread)
228 return FWL_ERR_Indefinite; 247 return FWL_ERR_Indefinite;
229 IFWL_NoteDriver* pDriver = pThread->GetNoteDriver(); 248 IFWL_NoteDriver* pDriver = pThread->GetNoteDriver();
230 if (!pDriver) 249 if (!pDriver)
231 return FWL_ERR_Indefinite; 250 return FWL_ERR_Indefinite;
232 if (bFocus) { 251 if (bFocus) {
233 pDriver->SetFocus(m_pIface); 252 pDriver->SetFocus(m_pIface);
234 } else { 253 } else {
235 if (pDriver->GetFocus() == m_pIface) { 254 if (pDriver->GetFocus() == m_pIface) {
236 pDriver->SetFocus(NULL); 255 pDriver->SetFocus(NULL);
237 } 256 }
238 } 257 }
239 return FWL_ERR_Succeeded; 258 return FWL_ERR_Succeeded;
240 } 259 }
260
241 FWL_ERR CFWL_Widget::SetGrab(FX_BOOL bSet) { 261 FWL_ERR CFWL_Widget::SetGrab(FX_BOOL bSet) {
242 if (!m_pIface) 262 if (!m_pIface)
243 return FWL_ERR_Indefinite; 263 return FWL_ERR_Indefinite;
244 IFWL_NoteThread* pThread = m_pIface->GetOwnerThread(); 264 IFWL_NoteThread* pThread = m_pIface->GetOwnerThread();
245 if (!pThread) 265 if (!pThread)
246 return FWL_ERR_Indefinite; 266 return FWL_ERR_Indefinite;
247 IFWL_NoteDriver* pDriver = pThread->GetNoteDriver(); 267 IFWL_NoteDriver* pDriver = pThread->GetNoteDriver();
248 if (!pDriver) 268 if (!pDriver)
249 return FWL_ERR_Indefinite; 269 return FWL_ERR_Indefinite;
250 pDriver->SetGrab(m_pIface, bSet); 270 pDriver->SetGrab(m_pIface, bSet);
251 return FWL_ERR_Succeeded; 271 return FWL_ERR_Succeeded;
252 } 272 }
273
253 void CFWL_Widget::RegisterEventTarget(CFWL_Widget* pEventSource, 274 void CFWL_Widget::RegisterEventTarget(CFWL_Widget* pEventSource,
254 uint32_t dwFilter) { 275 uint32_t dwFilter) {
255 if (!m_pIface) 276 if (!m_pIface)
256 return; 277 return;
257 IFWL_NoteThread* pThread = m_pIface->GetOwnerThread(); 278 IFWL_NoteThread* pThread = m_pIface->GetOwnerThread();
258 if (!pThread) 279 if (!pThread)
259 return; 280 return;
260 IFWL_NoteDriver* pNoteDriver = pThread->GetNoteDriver(); 281 IFWL_NoteDriver* pNoteDriver = pThread->GetNoteDriver();
261 if (!pNoteDriver) 282 if (!pNoteDriver)
262 return; 283 return;
263 IFWL_Widget* pEventSourceImp = 284 IFWL_Widget* pEventSourceImp =
264 !pEventSource ? NULL : pEventSource->GetWidget(); 285 !pEventSource ? NULL : pEventSource->GetWidget();
265 pNoteDriver->RegisterEventTarget(GetWidget(), pEventSourceImp, dwFilter); 286 pNoteDriver->RegisterEventTarget(GetWidget(), pEventSourceImp, dwFilter);
266 } 287 }
288
267 void CFWL_Widget::DispatchEvent(CFWL_Event* pEvent) { 289 void CFWL_Widget::DispatchEvent(CFWL_Event* pEvent) {
268 if (!m_pIface) 290 if (!m_pIface)
269 return; 291 return;
270 if (m_pIface->GetOuter()) { 292 if (m_pIface->GetOuter()) {
271 return; 293 return;
272 } 294 }
273 IFWL_NoteThread* pThread = m_pIface->GetOwnerThread(); 295 IFWL_NoteThread* pThread = m_pIface->GetOwnerThread();
274 if (!pThread) 296 if (!pThread)
275 return; 297 return;
276 IFWL_NoteDriver* pNoteDriver = pThread->GetNoteDriver(); 298 IFWL_NoteDriver* pNoteDriver = pThread->GetNoteDriver();
277 if (!pNoteDriver) 299 if (!pNoteDriver)
278 return; 300 return;
279 pNoteDriver->SendNote(pEvent); 301 pNoteDriver->SendNote(pEvent);
280 } 302 }
303
281 #define FWL_WGT_CalcHeight 2048 304 #define FWL_WGT_CalcHeight 2048
282 #define FWL_WGT_CalcWidth 2048 305 #define FWL_WGT_CalcWidth 2048
283 #define FWL_WGT_CalcMultiLineDefWidth 120.0f 306 #define FWL_WGT_CalcMultiLineDefWidth 120.0f
307
284 CFX_SizeF CFWL_Widget::CalcTextSize(const CFX_WideString& wsText, 308 CFX_SizeF CFWL_Widget::CalcTextSize(const CFX_WideString& wsText,
285 FX_BOOL bMultiLine, 309 FX_BOOL bMultiLine,
286 int32_t iLineWidth) { 310 int32_t iLineWidth) {
287 if (!m_pIface) 311 if (!m_pIface)
288 return CFX_SizeF(); 312 return CFX_SizeF();
289 IFWL_ThemeProvider* pTheme = m_pIface->GetThemeProvider(); 313 IFWL_ThemeProvider* pTheme = m_pIface->GetThemeProvider();
290 if (!pTheme) 314 if (!pTheme)
291 return CFX_SizeF(); 315 return CFX_SizeF();
292 316
293 CFWL_ThemeText calPart; 317 CFWL_ThemeText calPart;
294 calPart.m_pWidget = m_pIface; 318 calPart.m_pWidget = m_pIface;
295 calPart.m_wsText = wsText; 319 calPart.m_wsText = wsText;
296 calPart.m_dwTTOStyles = 320 calPart.m_dwTTOStyles =
297 bMultiLine ? FDE_TTOSTYLE_LineWrap : FDE_TTOSTYLE_SingleLine; 321 bMultiLine ? FDE_TTOSTYLE_LineWrap : FDE_TTOSTYLE_SingleLine;
298 calPart.m_iTTOAlign = FDE_TTOALIGNMENT_TopLeft; 322 calPart.m_iTTOAlign = FDE_TTOALIGNMENT_TopLeft;
299 CFX_RectF rect; 323 CFX_RectF rect;
300 FX_FLOAT fWidth = bMultiLine 324 FX_FLOAT fWidth = bMultiLine
301 ? (iLineWidth > 0 ? (FX_FLOAT)iLineWidth 325 ? (iLineWidth > 0 ? (FX_FLOAT)iLineWidth
302 : FWL_WGT_CalcMultiLineDefWidth) 326 : FWL_WGT_CalcMultiLineDefWidth)
303 : FWL_WGT_CalcWidth; 327 : FWL_WGT_CalcWidth;
304 rect.Set(0, 0, fWidth, FWL_WGT_CalcHeight); 328 rect.Set(0, 0, fWidth, FWL_WGT_CalcHeight);
305 pTheme->CalcTextRect(&calPart, rect); 329 pTheme->CalcTextRect(&calPart, rect);
306 return CFX_SizeF(rect.width, rect.height); 330 return CFX_SizeF(rect.width, rect.height);
307 } 331 }
308 CFWL_WidgetDelegate::CFWL_WidgetDelegate() {}
309 CFWL_WidgetDelegate::~CFWL_WidgetDelegate() {}
310 int32_t CFWL_WidgetDelegate::OnProcessMessage(CFWL_Message* pMessage) {
311 return 1;
312 }
313 FWL_ERR CFWL_WidgetDelegate::OnProcessEvent(CFWL_Event* pEvent) {
314 return FWL_ERR_Succeeded;
315 }
316 FWL_ERR CFWL_WidgetDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
317 const CFX_Matrix* pMatrix) {
318 return FWL_ERR_Succeeded;
319 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698