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

Side by Side Diff: xfa/fwl/core/ifwl_widget.cpp

Issue 2488953003: Cleanup IFWL_Widget visibility and virtual parameters (Closed)
Patch Set: fixes Created 4 years, 1 month 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
« no previous file with comments | « xfa/fwl/core/ifwl_widget.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/fwl/core/ifwl_widget.h" 7 #include "xfa/fwl/core/ifwl_widget.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
11 #include "xfa/fde/tto/fde_textout.h" 11 #include "xfa/fde/tto/fde_textout.h"
12 #include "xfa/fwl/core/cfwl_message.h" 12 #include "xfa/fwl/core/cfwl_message.h"
13 #include "xfa/fwl/core/cfwl_themebackground.h" 13 #include "xfa/fwl/core/cfwl_themebackground.h"
14 #include "xfa/fwl/core/cfwl_themepart.h" 14 #include "xfa/fwl/core/cfwl_themepart.h"
15 #include "xfa/fwl/core/cfwl_themetext.h" 15 #include "xfa/fwl/core/cfwl_themetext.h"
16 #include "xfa/fwl/core/cfwl_widgetmgr.h" 16 #include "xfa/fwl/core/cfwl_widgetmgr.h"
17 #include "xfa/fwl/core/fwl_noteimp.h" 17 #include "xfa/fwl/core/fwl_noteimp.h"
18 #include "xfa/fwl/core/ifwl_app.h" 18 #include "xfa/fwl/core/ifwl_app.h"
19 #include "xfa/fwl/core/ifwl_combobox.h" 19 #include "xfa/fwl/core/ifwl_combobox.h"
20 #include "xfa/fwl/core/ifwl_form.h" 20 #include "xfa/fwl/core/ifwl_form.h"
21 #include "xfa/fwl/core/ifwl_themeprovider.h" 21 #include "xfa/fwl/core/ifwl_themeprovider.h"
22 #include "xfa/fwl/core/ifwl_widget.h" 22 #include "xfa/fwl/core/ifwl_widget.h"
23 #include "xfa/fxfa/xfa_ffapp.h" 23 #include "xfa/fxfa/xfa_ffapp.h"
24 24
25 #define FWL_STYLEEXT_MNU_Vert (1L << 0) 25 #define FWL_STYLEEXT_MNU_Vert (1L << 0)
26 #define FWL_WGT_CalcHeight 2048
27 #define FWL_WGT_CalcWidth 2048
28 #define FWL_WGT_CalcMultiLineDefWidth 120.0f
26 29
27 IFWL_Widget::IFWL_Widget(const IFWL_App* app, 30 IFWL_Widget::IFWL_Widget(const IFWL_App* app,
28 std::unique_ptr<CFWL_WidgetProperties> properties, 31 std::unique_ptr<CFWL_WidgetProperties> properties,
29 IFWL_Widget* pOuter) 32 IFWL_Widget* pOuter)
30 : m_pOwnerApp(app), 33 : m_pOwnerApp(app),
31 m_pWidgetMgr(app->GetWidgetMgr()), 34 m_pWidgetMgr(app->GetWidgetMgr()),
32 m_pProperties(std::move(properties)), 35 m_pProperties(std::move(properties)),
33 m_pOuter(pOuter), 36 m_pOuter(pOuter),
37 m_iLock(0),
34 m_pLayoutItem(nullptr), 38 m_pLayoutItem(nullptr),
35 m_pAssociate(nullptr), 39 m_pAssociate(nullptr),
36 m_iLock(0),
37 m_nEventKey(0), 40 m_nEventKey(0),
38 m_pDelegate(nullptr) { 41 m_pDelegate(nullptr) {
39 ASSERT(m_pWidgetMgr); 42 ASSERT(m_pWidgetMgr);
40 43
41 IFWL_Widget* pParent = m_pProperties->m_pParent; 44 IFWL_Widget* pParent = m_pProperties->m_pParent;
42 m_pWidgetMgr->InsertWidget(pParent, this); 45 m_pWidgetMgr->InsertWidget(pParent, this);
43 if (IsChild()) 46 if (IsChild())
44 return; 47 return;
45 48
46 IFWL_Widget* pOwner = m_pProperties->m_pOwner; 49 IFWL_Widget* pOwner = m_pProperties->m_pOwner;
47 if (pOwner) 50 if (pOwner)
48 m_pWidgetMgr->SetOwner(pOwner, this); 51 m_pWidgetMgr->SetOwner(pOwner, this);
49 } 52 }
50 53
51 IFWL_Widget::~IFWL_Widget() { 54 IFWL_Widget::~IFWL_Widget() {
52 NotifyDriver(); 55 NotifyDriver();
53 m_pWidgetMgr->RemoveWidget(this); 56 m_pWidgetMgr->RemoveWidget(this);
54 } 57 }
55 58
56 bool IFWL_Widget::IsInstance(const CFX_WideStringC& wsClass) const { 59 bool IFWL_Widget::IsInstance(const CFX_WideStringC& wsClass) const {
57 return false; 60 return false;
58 } 61 }
59 62
60 FWL_Error IFWL_Widget::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { 63 void IFWL_Widget::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) {
61 if (bAutoSize) { 64 if (bAutoSize) {
62 if (HasEdge()) { 65 if (HasEdge()) {
63 FX_FLOAT fEdge = GetEdgeWidth(); 66 FX_FLOAT fEdge = GetEdgeWidth();
64 rect.Inflate(fEdge, fEdge); 67 rect.Inflate(fEdge, fEdge);
65 } 68 }
66 if (HasBorder()) { 69 if (HasBorder()) {
67 FX_FLOAT fBorder = GetBorderSize(); 70 FX_FLOAT fBorder = GetBorderSize();
68 rect.Inflate(fBorder, fBorder); 71 rect.Inflate(fBorder, fBorder);
69 } 72 }
70 } else { 73 } else {
71 rect = m_pProperties->m_rtWidget; 74 rect = m_pProperties->m_rtWidget;
72 } 75 }
73 return FWL_Error::Succeeded;
74 } 76 }
75 77
76 FWL_Error IFWL_Widget::GetGlobalRect(CFX_RectF& rect) { 78 void IFWL_Widget::GetGlobalRect(CFX_RectF& rect) {
77 IFWL_Widget* pForm = m_pWidgetMgr->GetSystemFormWidget(this); 79 IFWL_Widget* pForm = m_pWidgetMgr->GetSystemFormWidget(this);
78 if (!pForm) 80 if (!pForm)
79 return FWL_Error::Indefinite; 81 return;
80 82
81 rect.Set(0, 0, m_pProperties->m_rtWidget.width, 83 rect.Set(0, 0, m_pProperties->m_rtWidget.width,
82 m_pProperties->m_rtWidget.height); 84 m_pProperties->m_rtWidget.height);
83 if (pForm == this) 85 if (pForm == this)
84 return FWL_Error::Succeeded; 86 return;
85 87
86 return TransformTo(pForm, rect); 88 TransformTo(pForm, rect.left, rect.top);
87 } 89 }
88 90
89 FWL_Error IFWL_Widget::SetWidgetRect(const CFX_RectF& rect) { 91 void IFWL_Widget::SetWidgetRect(const CFX_RectF& rect) {
90 CFX_RectF rtOld = m_pProperties->m_rtWidget; 92 CFX_RectF rtOld = m_pProperties->m_rtWidget;
91 m_pProperties->m_rtWidget = rect; 93 m_pProperties->m_rtWidget = rect;
92 if (IsChild()) { 94 if (IsChild()) {
93 if (FXSYS_fabs(rtOld.width - rect.width) > 0.5f || 95 if (FXSYS_fabs(rtOld.width - rect.width) > 0.5f ||
94 FXSYS_fabs(rtOld.height - rect.height) > 0.5f) { 96 FXSYS_fabs(rtOld.height - rect.height) > 0.5f) {
95 CFWL_EvtSizeChanged ev; 97 CFWL_EvtSizeChanged ev;
96 ev.m_pSrcTarget = this; 98 ev.m_pSrcTarget = this;
97 ev.m_rtOld = rtOld; 99 ev.m_rtOld = rtOld;
98 ev.m_rtNew = rect; 100 ev.m_rtNew = rect;
99 101
100 if (IFWL_WidgetDelegate* pDelegate = GetDelegate()) 102 if (IFWL_WidgetDelegate* pDelegate = GetDelegate())
101 pDelegate->OnProcessEvent(&ev); 103 pDelegate->OnProcessEvent(&ev);
102 } 104 }
103 return FWL_Error::Succeeded; 105 return;
104 } 106 }
105 m_pWidgetMgr->SetWidgetRect_Native(this, rect); 107 m_pWidgetMgr->SetWidgetRect_Native(this, rect);
106 return FWL_Error::Succeeded;
107 } 108 }
108 109
109 FWL_Error IFWL_Widget::GetClientRect(CFX_RectF& rect) { 110 void IFWL_Widget::GetClientRect(CFX_RectF& rect) {
110 GetEdgeRect(rect); 111 GetEdgeRect(rect);
111 if (HasEdge()) { 112 if (HasEdge()) {
112 FX_FLOAT fEdge = GetEdgeWidth(); 113 FX_FLOAT fEdge = GetEdgeWidth();
113 rect.Deflate(fEdge, fEdge); 114 rect.Deflate(fEdge, fEdge);
114 } 115 }
115 return FWL_Error::Succeeded;
116 } 116 }
117 117
118 IFWL_Widget* IFWL_Widget::GetParent() { 118 void IFWL_Widget::SetParent(IFWL_Widget* pParent) {
119 return m_pWidgetMgr->GetParentWidget(this); 119 m_pProperties->m_pParent = pParent;
120 m_pWidgetMgr->SetParent(pParent, this);
120 } 121 }
121 122
122 FWL_Error IFWL_Widget::SetParent(IFWL_Widget* pParent) { 123 void IFWL_Widget::ModifyStyles(uint32_t dwStylesAdded,
123 m_pProperties->m_pParent = pParent; 124 uint32_t dwStylesRemoved) {
124 m_pWidgetMgr->SetParent(pParent, this); 125 m_pProperties->m_dwStyles =
125 return FWL_Error::Succeeded; 126 (m_pProperties->m_dwStyles & ~dwStylesRemoved) | dwStylesAdded;
126 } 127 }
127 128
128 IFWL_Widget* IFWL_Widget::GetOwner() { 129 void IFWL_Widget::ModifyStylesEx(uint32_t dwStylesExAdded,
129 return m_pWidgetMgr->GetOwnerWidget(this); 130 uint32_t dwStylesExRemoved) {
130 }
131
132 FWL_Error IFWL_Widget::SetOwner(IFWL_Widget* pOwner) {
133 m_pProperties->m_pOwner = pOwner;
134 m_pWidgetMgr->SetOwner(pOwner, this);
135 return FWL_Error::Succeeded;
136 }
137
138 IFWL_Widget* IFWL_Widget::GetOuter() {
139 return m_pOuter;
140 }
141
142 uint32_t IFWL_Widget::GetStyles() {
143 return m_pProperties->m_dwStyles;
144 }
145
146 FWL_Error IFWL_Widget::ModifyStyles(uint32_t dwStylesAdded,
147 uint32_t dwStylesRemoved) {
148 m_pProperties->m_dwStyles =
149 (m_pProperties->m_dwStyles & ~dwStylesRemoved) | dwStylesAdded;
150 return FWL_Error::Succeeded;
151 }
152
153 uint32_t IFWL_Widget::GetStylesEx() {
154 return m_pProperties->m_dwStyleExes;
155 }
156
157 FWL_Error IFWL_Widget::ModifyStylesEx(uint32_t dwStylesExAdded,
158 uint32_t dwStylesExRemoved) {
159 m_pProperties->m_dwStyleExes = 131 m_pProperties->m_dwStyleExes =
160 (m_pProperties->m_dwStyleExes & ~dwStylesExRemoved) | dwStylesExAdded; 132 (m_pProperties->m_dwStyleExes & ~dwStylesExRemoved) | dwStylesExAdded;
161 return FWL_Error::Succeeded;
162 }
163
164 uint32_t IFWL_Widget::GetStates() {
165 return m_pProperties->m_dwStates;
166 } 133 }
167 134
168 static void NotifyHideChildWidget(CFWL_WidgetMgr* widgetMgr, 135 static void NotifyHideChildWidget(CFWL_WidgetMgr* widgetMgr,
169 IFWL_Widget* widget, 136 IFWL_Widget* widget,
170 CFWL_NoteDriver* noteDriver) { 137 CFWL_NoteDriver* noteDriver) {
171 IFWL_Widget* child = widgetMgr->GetFirstChildWidget(widget); 138 IFWL_Widget* child = widgetMgr->GetFirstChildWidget(widget);
172 while (child) { 139 while (child) {
173 noteDriver->NotifyTargetHide(child); 140 noteDriver->NotifyTargetHide(child);
174 NotifyHideChildWidget(widgetMgr, child, noteDriver); 141 NotifyHideChildWidget(widgetMgr, child, noteDriver);
175 child = widgetMgr->GetNextSiblingWidget(child); 142 child = widgetMgr->GetNextSiblingWidget(child);
(...skipping 12 matching lines...) Expand all
188 noteDriver->NotifyTargetHide(this); 155 noteDriver->NotifyTargetHide(this);
189 IFWL_Widget* child = widgetMgr->GetFirstChildWidget(this); 156 IFWL_Widget* child = widgetMgr->GetFirstChildWidget(this);
190 while (child) { 157 while (child) {
191 noteDriver->NotifyTargetHide(child); 158 noteDriver->NotifyTargetHide(child);
192 NotifyHideChildWidget(widgetMgr, child, noteDriver); 159 NotifyHideChildWidget(widgetMgr, child, noteDriver);
193 child = widgetMgr->GetNextSiblingWidget(child); 160 child = widgetMgr->GetNextSiblingWidget(child);
194 } 161 }
195 return; 162 return;
196 } 163 }
197 164
198 FWL_Error IFWL_Widget::Update() { 165 void IFWL_Widget::Update() {}
199 return FWL_Error::Succeeded;
200 }
201
202 FWL_Error IFWL_Widget::LockUpdate() {
203 m_iLock++;
204 return FWL_Error::Succeeded;
205 }
206
207 FWL_Error IFWL_Widget::UnlockUpdate() {
208 if (IsLocked()) {
209 m_iLock--;
210 }
211 return FWL_Error::Succeeded;
212 }
213 166
214 FWL_WidgetHit IFWL_Widget::HitTest(FX_FLOAT fx, FX_FLOAT fy) { 167 FWL_WidgetHit IFWL_Widget::HitTest(FX_FLOAT fx, FX_FLOAT fy) {
215 CFX_RectF rtClient; 168 CFX_RectF rtClient;
216 GetClientRect(rtClient); 169 GetClientRect(rtClient);
217 if (rtClient.Contains(fx, fy)) 170 if (rtClient.Contains(fx, fy))
218 return FWL_WidgetHit::Client; 171 return FWL_WidgetHit::Client;
219 if (HasEdge()) { 172 if (HasEdge()) {
220 CFX_RectF rtEdge; 173 CFX_RectF rtEdge;
221 GetEdgeRect(rtEdge); 174 GetEdgeRect(rtEdge);
222 if (rtEdge.Contains(fx, fy)) 175 if (rtEdge.Contains(fx, fy))
223 return FWL_WidgetHit::Edge; 176 return FWL_WidgetHit::Edge;
224 } 177 }
225 if (HasBorder()) { 178 if (HasBorder()) {
226 CFX_RectF rtRelative; 179 CFX_RectF rtRelative;
227 GetRelativeRect(rtRelative); 180 GetRelativeRect(rtRelative);
228 if (rtRelative.Contains(fx, fy)) 181 if (rtRelative.Contains(fx, fy))
229 return FWL_WidgetHit::Border; 182 return FWL_WidgetHit::Border;
230 } 183 }
231 return FWL_WidgetHit::Unknown; 184 return FWL_WidgetHit::Unknown;
232 } 185 }
233 186
234 FWL_Error IFWL_Widget::TransformTo(IFWL_Widget* pWidget, 187 void IFWL_Widget::TransformTo(IFWL_Widget* pWidget,
235 FX_FLOAT& fx, 188 FX_FLOAT& fx,
236 FX_FLOAT& fy) { 189 FX_FLOAT& fy) {
237 if (m_pWidgetMgr->IsFormDisabled()) { 190 if (m_pWidgetMgr->IsFormDisabled()) {
238 CFX_SizeF szOffset; 191 CFX_SizeF szOffset;
239 if (IsParent(pWidget)) { 192 if (IsParent(pWidget)) {
240 szOffset = GetOffsetFromParent(pWidget); 193 szOffset = GetOffsetFromParent(pWidget);
241 } else { 194 } else {
242 szOffset = pWidget->GetOffsetFromParent(this); 195 szOffset = pWidget->GetOffsetFromParent(this);
243 szOffset.x = -szOffset.x; 196 szOffset.x = -szOffset.x;
244 szOffset.y = -szOffset.y; 197 szOffset.y = -szOffset.y;
245 } 198 }
246 fx += szOffset.x; 199 fx += szOffset.x;
247 fy += szOffset.y; 200 fy += szOffset.y;
248 return FWL_Error::Succeeded; 201 return;
249 } 202 }
250 CFX_RectF r; 203 CFX_RectF r;
251 CFX_Matrix m; 204 CFX_Matrix m;
252 IFWL_Widget* parent = GetParent(); 205 IFWL_Widget* parent = GetParent();
253 if (parent) { 206 if (parent) {
254 GetWidgetRect(r); 207 GetWidgetRect(r);
255 fx += r.left; 208 fx += r.left;
256 fy += r.top; 209 fy += r.top;
257 GetMatrix(m, true); 210 GetMatrix(m, true);
258 m.TransformPoint(fx, fy); 211 m.TransformPoint(fx, fy);
259 } 212 }
260 IFWL_Widget* form1 = m_pWidgetMgr->GetSystemFormWidget(this); 213 IFWL_Widget* form1 = m_pWidgetMgr->GetSystemFormWidget(this);
261 if (!form1) 214 if (!form1)
262 return FWL_Error::Indefinite; 215 return;
263 if (!pWidget) { 216 if (!pWidget) {
264 form1->GetWidgetRect(r); 217 form1->GetWidgetRect(r);
265 fx += r.left; 218 fx += r.left;
266 fy += r.top; 219 fy += r.top;
267 return FWL_Error::Succeeded; 220 return;
268 } 221 }
269 IFWL_Widget* form2 = m_pWidgetMgr->GetSystemFormWidget(pWidget); 222 IFWL_Widget* form2 = m_pWidgetMgr->GetSystemFormWidget(pWidget);
270 if (!form2) 223 if (!form2)
271 return FWL_Error::Indefinite; 224 return;
272 if (form1 != form2) { 225 if (form1 != form2) {
273 form1->GetWidgetRect(r); 226 form1->GetWidgetRect(r);
274 fx += r.left; 227 fx += r.left;
275 fy += r.top; 228 fy += r.top;
276 form2->GetWidgetRect(r); 229 form2->GetWidgetRect(r);
277 fx -= r.left; 230 fx -= r.left;
278 fy -= r.top; 231 fy -= r.top;
279 } 232 }
280 parent = pWidget->GetParent(); 233 parent = pWidget->GetParent();
281 if (parent) { 234 if (parent) {
282 pWidget->GetMatrix(m, true); 235 pWidget->GetMatrix(m, true);
283 CFX_Matrix m1; 236 CFX_Matrix m1;
284 m1.SetIdentity(); 237 m1.SetIdentity();
285 m1.SetReverse(m); 238 m1.SetReverse(m);
286 m1.TransformPoint(fx, fy); 239 m1.TransformPoint(fx, fy);
287 pWidget->GetWidgetRect(r); 240 pWidget->GetWidgetRect(r);
288 fx -= r.left; 241 fx -= r.left;
289 fy -= r.top; 242 fy -= r.top;
290 } 243 }
291 return FWL_Error::Succeeded;
292 } 244 }
293 245
294 FWL_Error IFWL_Widget::TransformTo(IFWL_Widget* pWidget, CFX_RectF& rt) { 246 void IFWL_Widget::GetMatrix(CFX_Matrix& matrix, bool bGlobal) {
295 return TransformTo(pWidget, rt.left, rt.top);
296 }
297
298 FWL_Error IFWL_Widget::GetMatrix(CFX_Matrix& matrix, bool bGlobal) {
299 if (!m_pProperties) 247 if (!m_pProperties)
300 return FWL_Error::Indefinite; 248 return;
301 if (bGlobal) { 249 if (bGlobal) {
302 IFWL_Widget* parent = GetParent(); 250 IFWL_Widget* parent = GetParent();
303 CFX_ArrayTemplate<IFWL_Widget*> parents; 251 CFX_ArrayTemplate<IFWL_Widget*> parents;
304 while (parent) { 252 while (parent) {
305 parents.Add(parent); 253 parents.Add(parent);
306 parent = parent->GetParent(); 254 parent = parent->GetParent();
307 } 255 }
308 matrix.SetIdentity(); 256 matrix.SetIdentity();
309 CFX_Matrix ctmOnParent; 257 CFX_Matrix ctmOnParent;
310 CFX_RectF rect; 258 CFX_RectF rect;
311 int32_t count = parents.GetSize(); 259 int32_t count = parents.GetSize();
312 for (int32_t i = count - 2; i >= 0; i--) { 260 for (int32_t i = count - 2; i >= 0; i--) {
313 parent = parents.GetAt(i); 261 parent = parents.GetAt(i);
314 parent->GetMatrix(ctmOnParent, false); 262 parent->GetMatrix(ctmOnParent, false);
315 parent->GetWidgetRect(rect); 263 parent->GetWidgetRect(rect);
316 matrix.Concat(ctmOnParent, true); 264 matrix.Concat(ctmOnParent, true);
317 matrix.Translate(rect.left, rect.top, true); 265 matrix.Translate(rect.left, rect.top, true);
318 } 266 }
319 matrix.Concat(m_pProperties->m_ctmOnParent, true); 267 CFX_Matrix m;
268 m.SetIdentity();
269 matrix.Concat(m, true);
320 parents.RemoveAll(); 270 parents.RemoveAll();
321 } else { 271 } else {
322 matrix = m_pProperties->m_ctmOnParent; 272 matrix.SetIdentity();
323 } 273 }
324 return FWL_Error::Succeeded;
325 } 274 }
326 275
327 FWL_Error IFWL_Widget::SetMatrix(const CFX_Matrix& matrix) { 276 void IFWL_Widget::DrawWidget(CFX_Graphics* pGraphics,
328 if (!m_pProperties) 277 const CFX_Matrix* pMatrix) {}
329 return FWL_Error::Indefinite;
330 IFWL_Widget* parent = GetParent();
331 if (!parent) {
332 return FWL_Error::Indefinite;
333 }
334 m_pProperties->m_ctmOnParent = matrix;
335 return FWL_Error::Succeeded;
336 }
337 278
338 FWL_Error IFWL_Widget::DrawWidget(CFX_Graphics* pGraphics, 279 void IFWL_Widget::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) {
339 const CFX_Matrix* pMatrix) {
340 return FWL_Error::Indefinite;
341 }
342
343 IFWL_ThemeProvider* IFWL_Widget::GetThemeProvider() {
344 return m_pProperties->m_pThemeProvider;
345 }
346 FWL_Error IFWL_Widget::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) {
347 m_pProperties->m_pThemeProvider = pThemeProvider; 280 m_pProperties->m_pThemeProvider = pThemeProvider;
348 return FWL_Error::Succeeded;
349 }
350
351 const IFWL_App* IFWL_Widget::GetOwnerApp() const {
352 return m_pOwnerApp;
353 }
354
355 uint32_t IFWL_Widget::GetEventKey() const {
356 return m_nEventKey;
357 }
358
359 void IFWL_Widget::SetEventKey(uint32_t key) {
360 m_nEventKey = key;
361 }
362
363 void* IFWL_Widget::GetLayoutItem() const {
364 return m_pLayoutItem;
365 }
366
367 void IFWL_Widget::SetLayoutItem(void* pItem) {
368 m_pLayoutItem = pItem;
369 }
370
371 void IFWL_Widget::SetAssociateWidget(CFWL_Widget* pAssociate) {
372 m_pAssociate = pAssociate;
373 }
374 bool IFWL_Widget::IsEnabled() const {
375 return (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) == 0;
376 }
377
378 bool IFWL_Widget::IsVisible() const {
379 return (m_pProperties->m_dwStates & FWL_WGTSTATE_Invisible) == 0;
380 }
381
382 bool IFWL_Widget::IsActive() const {
383 return (m_pProperties->m_dwStates & FWL_WGTSTATE_Deactivated) == 0;
384 }
385
386 bool IFWL_Widget::IsOverLapper() const {
387 return (m_pProperties->m_dwStyles & FWL_WGTSTYLE_WindowTypeMask) ==
388 FWL_WGTSTYLE_OverLapper;
389 }
390
391 bool IFWL_Widget::IsPopup() const {
392 return !!(m_pProperties->m_dwStyles & FWL_WGTSTYLE_Popup);
393 }
394
395 bool IFWL_Widget::IsChild() const {
396 return !!(m_pProperties->m_dwStyles & FWL_WGTSTYLE_Child);
397 }
398
399 bool IFWL_Widget::IsLocked() const {
400 return m_iLock > 0;
401 }
402
403 bool IFWL_Widget::IsOffscreen() const {
404 return !!(m_pProperties->m_dwStyles & FWL_WGTSTYLE_Offscreen);
405 }
406
407 bool IFWL_Widget::HasBorder() const {
408 return !!(m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border);
409 }
410
411 bool IFWL_Widget::HasEdge() const {
412 return !!(m_pProperties->m_dwStyles & FWL_WGTSTYLE_EdgeMask);
413 } 281 }
414 282
415 void IFWL_Widget::GetEdgeRect(CFX_RectF& rtEdge) { 283 void IFWL_Widget::GetEdgeRect(CFX_RectF& rtEdge) {
416 rtEdge = m_pProperties->m_rtWidget; 284 rtEdge = m_pProperties->m_rtWidget;
417 rtEdge.left = rtEdge.top = 0; 285 rtEdge.left = rtEdge.top = 0;
418 if (HasBorder()) { 286 if (HasBorder()) {
419 FX_FLOAT fCX = GetBorderSize(); 287 FX_FLOAT fCX = GetBorderSize();
420 FX_FLOAT fCY = GetBorderSize(false); 288 FX_FLOAT fCY = GetBorderSize(false);
421 rtEdge.Deflate(fCX, fCY); 289 rtEdge.Deflate(fCX, fCY);
422 } 290 }
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 IFWL_Widget* IFWL_Widget::GetRootOuter() { 356 IFWL_Widget* IFWL_Widget::GetRootOuter() {
489 IFWL_Widget* pRet = m_pOuter; 357 IFWL_Widget* pRet = m_pOuter;
490 if (!pRet) 358 if (!pRet)
491 return nullptr; 359 return nullptr;
492 while (IFWL_Widget* pOuter = pRet->GetOuter()) { 360 while (IFWL_Widget* pOuter = pRet->GetOuter()) {
493 pRet = pOuter; 361 pRet = pOuter;
494 } 362 }
495 return pRet; 363 return pRet;
496 } 364 }
497 365
498 #define FWL_WGT_CalcHeight 2048
499 #define FWL_WGT_CalcWidth 2048
500 #define FWL_WGT_CalcMultiLineDefWidth 120.0f
501
502 CFX_SizeF IFWL_Widget::CalcTextSize(const CFX_WideString& wsText, 366 CFX_SizeF IFWL_Widget::CalcTextSize(const CFX_WideString& wsText,
503 IFWL_ThemeProvider* pTheme, 367 IFWL_ThemeProvider* pTheme,
504 bool bMultiLine, 368 bool bMultiLine,
505 int32_t iLineWidth) { 369 int32_t iLineWidth) {
506 if (!pTheme) 370 if (!pTheme)
507 return CFX_SizeF(); 371 return CFX_SizeF();
508 372
509 CFWL_ThemeText calPart; 373 CFWL_ThemeText calPart;
510 calPart.m_pWidget = this; 374 calPart.m_pWidget = this;
511 calPart.m_wsText = wsText; 375 calPart.m_wsText = wsText;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 } 447 }
584 return GetPopupPosGeneral(fMinHeight, fMaxHeight, rtAnchor, rtPopup); 448 return GetPopupPosGeneral(fMinHeight, fMaxHeight, rtAnchor, rtPopup);
585 } 449 }
586 450
587 bool IFWL_Widget::GetPopupPosMenu(FX_FLOAT fMinHeight, 451 bool IFWL_Widget::GetPopupPosMenu(FX_FLOAT fMinHeight,
588 FX_FLOAT fMaxHeight, 452 FX_FLOAT fMaxHeight,
589 const CFX_RectF& rtAnchor, 453 const CFX_RectF& rtAnchor,
590 CFX_RectF& rtPopup) { 454 CFX_RectF& rtPopup) {
591 FX_FLOAT fx = 0; 455 FX_FLOAT fx = 0;
592 FX_FLOAT fy = 0; 456 FX_FLOAT fy = 0;
593 FX_FLOAT fScreenWidth = 0; 457
594 FX_FLOAT fScreenHeight = 0;
595 GetScreenSize(fScreenWidth, fScreenHeight);
596 if (GetStylesEx() & FWL_STYLEEXT_MNU_Vert) { 458 if (GetStylesEx() & FWL_STYLEEXT_MNU_Vert) {
597 bool bLeft = m_pProperties->m_rtWidget.left < 0; 459 bool bLeft = m_pProperties->m_rtWidget.left < 0;
598 FX_FLOAT fRight = rtAnchor.right() + rtPopup.width; 460 FX_FLOAT fRight = rtAnchor.right() + rtPopup.width;
599 TransformTo(nullptr, fx, fy); 461 TransformTo(nullptr, fx, fy);
600 if (fRight + fx > fScreenWidth || bLeft) { 462 if (fRight + fx > 0.0f || bLeft) {
601 rtPopup.Set(rtAnchor.left - rtPopup.width, rtAnchor.top, rtPopup.width, 463 rtPopup.Set(rtAnchor.left - rtPopup.width, rtAnchor.top, rtPopup.width,
602 rtPopup.height); 464 rtPopup.height);
603 } else { 465 } else {
604 rtPopup.Set(rtAnchor.right(), rtAnchor.top, rtPopup.width, 466 rtPopup.Set(rtAnchor.right(), rtAnchor.top, rtPopup.width,
605 rtPopup.height); 467 rtPopup.height);
606 } 468 }
607 } else { 469 } else {
608 FX_FLOAT fBottom = rtAnchor.bottom() + rtPopup.height; 470 FX_FLOAT fBottom = rtAnchor.bottom() + rtPopup.height;
609 TransformTo(nullptr, fx, fy); 471 TransformTo(nullptr, fx, fy);
610 if (fBottom + fy > fScreenHeight) { 472 if (fBottom + fy > 0.0f) {
611 rtPopup.Set(rtAnchor.left, rtAnchor.top - rtPopup.height, rtPopup.width, 473 rtPopup.Set(rtAnchor.left, rtAnchor.top - rtPopup.height, rtPopup.width,
612 rtPopup.height); 474 rtPopup.height);
613 } else { 475 } else {
614 rtPopup.Set(rtAnchor.left, rtAnchor.bottom(), rtPopup.width, 476 rtPopup.Set(rtAnchor.left, rtAnchor.bottom(), rtPopup.width,
615 rtPopup.height); 477 rtPopup.height);
616 } 478 }
617 } 479 }
618 rtPopup.Offset(fx, fy); 480 rtPopup.Offset(fx, fy);
619 return true; 481 return true;
620 } 482 }
621 483
622 bool IFWL_Widget::GetPopupPosComboBox(FX_FLOAT fMinHeight, 484 bool IFWL_Widget::GetPopupPosComboBox(FX_FLOAT fMinHeight,
623 FX_FLOAT fMaxHeight, 485 FX_FLOAT fMaxHeight,
624 const CFX_RectF& rtAnchor, 486 const CFX_RectF& rtAnchor,
625 CFX_RectF& rtPopup) { 487 CFX_RectF& rtPopup) {
626 FX_FLOAT fx = 0; 488 FX_FLOAT fx = 0;
627 FX_FLOAT fy = 0; 489 FX_FLOAT fy = 0;
628 FX_FLOAT fScreenWidth = 0; 490
629 FX_FLOAT fScreenHeight = 0;
630 GetScreenSize(fScreenWidth, fScreenHeight);
631 FX_FLOAT fPopHeight = rtPopup.height; 491 FX_FLOAT fPopHeight = rtPopup.height;
632 if (rtPopup.height > fMaxHeight) { 492 if (rtPopup.height > fMaxHeight) {
633 fPopHeight = fMaxHeight; 493 fPopHeight = fMaxHeight;
634 } else if (rtPopup.height < fMinHeight) { 494 } else if (rtPopup.height < fMinHeight) {
635 fPopHeight = fMinHeight; 495 fPopHeight = fMinHeight;
636 } 496 }
637 FX_FLOAT fWidth = std::max(rtAnchor.width, rtPopup.width); 497 FX_FLOAT fWidth = std::max(rtAnchor.width, rtPopup.width);
638 FX_FLOAT fBottom = rtAnchor.bottom() + fPopHeight; 498 FX_FLOAT fBottom = rtAnchor.bottom() + fPopHeight;
639 TransformTo(nullptr, fx, fy); 499 TransformTo(nullptr, fx, fy);
640 if (fBottom + fy > fScreenHeight) { 500 if (fBottom + fy > 0.0f) {
641 rtPopup.Set(rtAnchor.left, rtAnchor.top - fPopHeight, fWidth, fPopHeight); 501 rtPopup.Set(rtAnchor.left, rtAnchor.top - fPopHeight, fWidth, fPopHeight);
642 } else { 502 } else {
643 rtPopup.Set(rtAnchor.left, rtAnchor.bottom(), fWidth, fPopHeight); 503 rtPopup.Set(rtAnchor.left, rtAnchor.bottom(), fWidth, fPopHeight);
644 } 504 }
645 rtPopup.Offset(fx, fy); 505 rtPopup.Offset(fx, fy);
646 return true; 506 return true;
647 } 507 }
648 508
649 bool IFWL_Widget::GetPopupPosGeneral(FX_FLOAT fMinHeight, 509 bool IFWL_Widget::GetPopupPosGeneral(FX_FLOAT fMinHeight,
650 FX_FLOAT fMaxHeight, 510 FX_FLOAT fMaxHeight,
651 const CFX_RectF& rtAnchor, 511 const CFX_RectF& rtAnchor,
652 CFX_RectF& rtPopup) { 512 CFX_RectF& rtPopup) {
653 FX_FLOAT fx = 0; 513 FX_FLOAT fx = 0;
654 FX_FLOAT fy = 0; 514 FX_FLOAT fy = 0;
655 FX_FLOAT fScreenWidth = 0; 515
656 FX_FLOAT fScreenHeight = 0;
657 GetScreenSize(fScreenWidth, fScreenHeight);
658 TransformTo(nullptr, fx, fy); 516 TransformTo(nullptr, fx, fy);
659 if (rtAnchor.bottom() + fy > fScreenHeight) { 517 if (rtAnchor.bottom() + fy > 0.0f) {
660 rtPopup.Set(rtAnchor.left, rtAnchor.top - rtPopup.height, rtPopup.width, 518 rtPopup.Set(rtAnchor.left, rtAnchor.top - rtPopup.height, rtPopup.width,
661 rtPopup.height); 519 rtPopup.height);
662 } else { 520 } else {
663 rtPopup.Set(rtAnchor.left, rtAnchor.bottom(), rtPopup.width, 521 rtPopup.Set(rtAnchor.left, rtAnchor.bottom(), rtPopup.width,
664 rtPopup.height); 522 rtPopup.height);
665 } 523 }
666 rtPopup.Offset(fx, fy); 524 rtPopup.Offset(fx, fy);
667 return true; 525 return true;
668 } 526 }
669 527
670 bool IFWL_Widget::GetScreenSize(FX_FLOAT& fx, FX_FLOAT& fy) {
671 return false;
672 }
673
674 void IFWL_Widget::RegisterEventTarget(IFWL_Widget* pEventSource, 528 void IFWL_Widget::RegisterEventTarget(IFWL_Widget* pEventSource,
675 uint32_t dwFilter) { 529 uint32_t dwFilter) {
676 const IFWL_App* pApp = GetOwnerApp(); 530 const IFWL_App* pApp = GetOwnerApp();
677 if (!pApp) 531 if (!pApp)
678 return; 532 return;
679 533
680 CFWL_NoteDriver* pNoteDriver = pApp->GetNoteDriver(); 534 CFWL_NoteDriver* pNoteDriver = pApp->GetNoteDriver();
681 if (!pNoteDriver) 535 if (!pNoteDriver)
682 return; 536 return;
683 537
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
893 } 747 }
894 default: 748 default:
895 break; 749 break;
896 } 750 }
897 } 751 }
898 752
899 void IFWL_Widget::OnProcessEvent(CFWL_Event* pEvent) {} 753 void IFWL_Widget::OnProcessEvent(CFWL_Event* pEvent) {}
900 754
901 void IFWL_Widget::OnDrawWidget(CFX_Graphics* pGraphics, 755 void IFWL_Widget::OnDrawWidget(CFX_Graphics* pGraphics,
902 const CFX_Matrix* pMatrix) {} 756 const CFX_Matrix* pMatrix) {}
OLDNEW
« no previous file with comments | « xfa/fwl/core/ifwl_widget.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698