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

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

Issue 1928963004: Cleanup IFWL_Adapter interfaces. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase to master Created 4 years, 7 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/fwl/core/fwl_widgetimp.h" 7 #include "xfa/fwl/core/fwl_widgetimp.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/basewidget/ifwl_combobox.h" 12 #include "xfa/fwl/basewidget/ifwl_combobox.h"
13 #include "xfa/fwl/basewidget/ifwl_datetimepicker.h" 13 #include "xfa/fwl/basewidget/ifwl_datetimepicker.h"
14 #include "xfa/fwl/core/cfwl_message.h" 14 #include "xfa/fwl/core/cfwl_message.h"
15 #include "xfa/fwl/core/cfwl_themebackground.h" 15 #include "xfa/fwl/core/cfwl_themebackground.h"
16 #include "xfa/fwl/core/cfwl_themepart.h" 16 #include "xfa/fwl/core/cfwl_themepart.h"
17 #include "xfa/fwl/core/cfwl_themetext.h" 17 #include "xfa/fwl/core/cfwl_themetext.h"
18 #include "xfa/fwl/core/fwl_appimp.h" 18 #include "xfa/fwl/core/fwl_appimp.h"
19 #include "xfa/fwl/core/fwl_noteimp.h" 19 #include "xfa/fwl/core/fwl_noteimp.h"
20 #include "xfa/fwl/core/fwl_widgetmgrimp.h" 20 #include "xfa/fwl/core/fwl_widgetmgrimp.h"
21 #include "xfa/fwl/core/ifwl_adapternative.h"
22 #include "xfa/fwl/core/ifwl_adapterthreadmgr.h"
23 #include "xfa/fwl/core/ifwl_adapterwidgetmgr.h"
24 #include "xfa/fwl/core/ifwl_app.h" 21 #include "xfa/fwl/core/ifwl_app.h"
25 #include "xfa/fwl/core/ifwl_form.h" 22 #include "xfa/fwl/core/ifwl_form.h"
26 #include "xfa/fwl/core/ifwl_themeprovider.h" 23 #include "xfa/fwl/core/ifwl_themeprovider.h"
24 #include "xfa/fxfa/include/xfa_ffapp.h"
27 25
28 #define FWL_CLASSHASH_Menu 3957949655 26 #define FWL_CLASSHASH_Menu 3957949655
29 #define FWL_STYLEEXT_MNU_Vert (1L << 0) 27 #define FWL_STYLEEXT_MNU_Vert (1L << 0)
30 28
31 IFWL_Widget::~IFWL_Widget() {} 29 IFWL_Widget::~IFWL_Widget() {}
32 30
33 FWL_ERR IFWL_Widget::GetClassName(CFX_WideString& wsClass) const { 31 FWL_ERR IFWL_Widget::GetClassName(CFX_WideString& wsClass) const {
34 return m_pImpl->GetClassName(wsClass); 32 return m_pImpl->GetClassName(wsClass);
35 } 33 }
36 34
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 return static_cast<CFWL_WidgetImp*>(GetImpl())->GetStylesEx(); 88 return static_cast<CFWL_WidgetImp*>(GetImpl())->GetStylesEx();
91 } 89 }
92 FWL_ERR IFWL_Widget::ModifyStylesEx(uint32_t dwStylesExAdded, 90 FWL_ERR IFWL_Widget::ModifyStylesEx(uint32_t dwStylesExAdded,
93 uint32_t dwStylesExRemoved) { 91 uint32_t dwStylesExRemoved) {
94 return static_cast<CFWL_WidgetImp*>(GetImpl()) 92 return static_cast<CFWL_WidgetImp*>(GetImpl())
95 ->ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); 93 ->ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved);
96 } 94 }
97 uint32_t IFWL_Widget::GetStates() { 95 uint32_t IFWL_Widget::GetStates() {
98 return static_cast<CFWL_WidgetImp*>(GetImpl())->GetStates(); 96 return static_cast<CFWL_WidgetImp*>(GetImpl())->GetStates();
99 } 97 }
100 FWL_ERR IFWL_Widget::SetStates(uint32_t dwStates, FX_BOOL bSet) { 98 void IFWL_Widget::SetStates(uint32_t dwStates, FX_BOOL bSet) {
101 return static_cast<CFWL_WidgetImp*>(GetImpl())->SetStates(dwStates, bSet); 99 static_cast<CFWL_WidgetImp*>(GetImpl())->SetStates(dwStates, bSet);
102 } 100 }
103 FWL_ERR IFWL_Widget::SetPrivateData(void* module_id, 101 FWL_ERR IFWL_Widget::SetPrivateData(void* module_id,
104 void* pData, 102 void* pData,
105 PD_CALLBACK_FREEDATA callback) { 103 PD_CALLBACK_FREEDATA callback) {
106 return static_cast<CFWL_WidgetImp*>(GetImpl()) 104 return static_cast<CFWL_WidgetImp*>(GetImpl())
107 ->SetPrivateData(module_id, pData, callback); 105 ->SetPrivateData(module_id, pData, callback);
108 } 106 }
109 void* IFWL_Widget::GetPrivateData(void* module_id) { 107 void* IFWL_Widget::GetPrivateData(void* module_id) {
110 return static_cast<CFWL_WidgetImp*>(GetImpl())->GetPrivateData(module_id); 108 return static_cast<CFWL_WidgetImp*>(GetImpl())->GetPrivateData(module_id);
111 } 109 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 return static_cast<CFWL_WidgetImp*>(GetImpl())->GetOwnerApp(); 156 return static_cast<CFWL_WidgetImp*>(GetImpl())->GetOwnerApp();
159 } 157 }
160 CFX_SizeF IFWL_Widget::GetOffsetFromParent(IFWL_Widget* pParent) { 158 CFX_SizeF IFWL_Widget::GetOffsetFromParent(IFWL_Widget* pParent) {
161 return static_cast<CFWL_WidgetImp*>(GetImpl())->GetOffsetFromParent(pParent); 159 return static_cast<CFWL_WidgetImp*>(GetImpl())->GetOffsetFromParent(pParent);
162 } 160 }
163 161
164 FWL_ERR CFWL_WidgetImp::Initialize() { 162 FWL_ERR CFWL_WidgetImp::Initialize() {
165 IFWL_App* pApp = FWL_GetApp(); 163 IFWL_App* pApp = FWL_GetApp();
166 if (!pApp) 164 if (!pApp)
167 return FWL_ERR_Indefinite; 165 return FWL_ERR_Indefinite;
168 IFWL_AdapterNative* pAdapter = pApp->GetAdapterNative(); 166 CXFA_FFApp* pAdapter = pApp->GetAdapterNative();
169 if (!pAdapter) 167 if (!pAdapter)
170 return FWL_ERR_Indefinite; 168 return FWL_ERR_Indefinite;
171 IFWL_AdapterThreadMgr* pAdapterThread = pAdapter->GetThreadMgr(); 169
172 if (!pAdapterThread) 170 SetOwnerApp(static_cast<CFWL_AppImp*>(FWL_GetApp()->GetImpl()));
173 return FWL_ERR_Indefinite;
174 SetOwnerApp(
175 static_cast<CFWL_AppImp*>(pAdapterThread->GetCurrentThread()->GetImpl()));
176 IFWL_Widget* pParent = m_pProperties->m_pParent; 171 IFWL_Widget* pParent = m_pProperties->m_pParent;
177 m_pWidgetMgr->InsertWidget(pParent, m_pInterface); 172 m_pWidgetMgr->InsertWidget(pParent, m_pInterface);
178 if (!IsChild()) { 173 if (!IsChild()) {
179 { 174 IFWL_Widget* pOwner = m_pProperties->m_pOwner;
180 IFWL_Widget* pOwner = m_pProperties->m_pOwner; 175 if (pOwner)
181 if (pOwner) { 176 m_pWidgetMgr->SetOwner(pOwner, m_pInterface);
182 m_pWidgetMgr->SetOwner(pOwner, m_pInterface);
183 }
184 }
185 m_pWidgetMgr->CreateWidget_Native(m_pInterface);
186 } 177 }
187 return FWL_ERR_Succeeded; 178 return FWL_ERR_Succeeded;
188 } 179 }
189 180
190 FWL_ERR CFWL_WidgetImp::Finalize() { 181 FWL_ERR CFWL_WidgetImp::Finalize() {
191 NotifyDriver(); 182 NotifyDriver();
192 if (!IsChild())
193 m_pWidgetMgr->DestroyWidget_Native(m_pInterface);
194
195 m_pWidgetMgr->RemoveWidget(m_pInterface); 183 m_pWidgetMgr->RemoveWidget(m_pInterface);
196 return FWL_ERR_Succeeded; 184 return FWL_ERR_Succeeded;
197 } 185 }
198 186
199 FWL_ERR CFWL_WidgetImp::GetClassName(CFX_WideString& wsClass) const { 187 FWL_ERR CFWL_WidgetImp::GetClassName(CFX_WideString& wsClass) const {
200 wsClass.clear(); 188 wsClass.clear();
201 return FWL_ERR_Succeeded; 189 return FWL_ERR_Succeeded;
202 } 190 }
203 191
204 uint32_t CFWL_WidgetImp::GetClassID() const { 192 uint32_t CFWL_WidgetImp::GetClassID() const {
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 static void NotifyHideChildWidget(IFWL_WidgetMgr* widgetMgr, 295 static void NotifyHideChildWidget(IFWL_WidgetMgr* widgetMgr,
308 IFWL_Widget* widget, 296 IFWL_Widget* widget,
309 CFWL_NoteDriver* noteDriver) { 297 CFWL_NoteDriver* noteDriver) {
310 IFWL_Widget* child = widgetMgr->GetWidget(widget, FWL_WGTRELATION_FirstChild); 298 IFWL_Widget* child = widgetMgr->GetWidget(widget, FWL_WGTRELATION_FirstChild);
311 while (child) { 299 while (child) {
312 noteDriver->NotifyTargetHide(child); 300 noteDriver->NotifyTargetHide(child);
313 NotifyHideChildWidget(widgetMgr, child, noteDriver); 301 NotifyHideChildWidget(widgetMgr, child, noteDriver);
314 child = widgetMgr->GetWidget(child, FWL_WGTRELATION_NextSibling); 302 child = widgetMgr->GetWidget(child, FWL_WGTRELATION_NextSibling);
315 } 303 }
316 } 304 }
317 FWL_ERR CFWL_WidgetImp::SetStates(uint32_t dwStates, FX_BOOL bSet) { 305 void CFWL_WidgetImp::SetStates(uint32_t dwStates, FX_BOOL bSet) {
318 bSet ? (m_pProperties->m_dwStates |= dwStates) 306 bSet ? (m_pProperties->m_dwStates |= dwStates)
319 : (m_pProperties->m_dwStates &= ~dwStates); 307 : (m_pProperties->m_dwStates &= ~dwStates);
320 FWL_ERR ret = FWL_ERR_Succeeded; 308 if (!(dwStates & FWL_WGTSTATE_Invisible) || !bSet)
321 if (dwStates & FWL_WGTSTATE_Invisible) { 309 return;
322 if (bSet) { 310
323 ret = m_pWidgetMgr->HideWidget_Native(m_pInterface); 311 CFWL_NoteDriver* noteDriver =
324 CFWL_NoteDriver* noteDriver = 312 static_cast<CFWL_NoteDriver*>(GetOwnerApp()->GetNoteDriver());
325 static_cast<CFWL_NoteDriver*>(GetOwnerApp()->GetNoteDriver()); 313 IFWL_WidgetMgr* widgetMgr = FWL_GetWidgetMgr();
326 IFWL_WidgetMgr* widgetMgr = FWL_GetWidgetMgr(); 314 noteDriver->NotifyTargetHide(m_pInterface);
327 noteDriver->NotifyTargetHide(m_pInterface); 315 IFWL_Widget* child =
328 IFWL_Widget* child = 316 widgetMgr->GetWidget(m_pInterface, FWL_WGTRELATION_FirstChild);
329 widgetMgr->GetWidget(m_pInterface, FWL_WGTRELATION_FirstChild); 317 while (child) {
330 while (child) { 318 noteDriver->NotifyTargetHide(child);
331 noteDriver->NotifyTargetHide(child); 319 NotifyHideChildWidget(widgetMgr, child, noteDriver);
332 NotifyHideChildWidget(widgetMgr, child, noteDriver); 320 child = widgetMgr->GetWidget(child, FWL_WGTRELATION_NextSibling);
333 child = widgetMgr->GetWidget(child, FWL_WGTRELATION_NextSibling);
334 }
335 } else {
336 ret = m_pWidgetMgr->ShowWidget_Native(m_pInterface);
337 }
338 } 321 }
339 return ret; 322 return;
340 } 323 }
341 FWL_ERR CFWL_WidgetImp::SetPrivateData(void* module_id, 324 FWL_ERR CFWL_WidgetImp::SetPrivateData(void* module_id,
342 void* pData, 325 void* pData,
343 PD_CALLBACK_FREEDATA callback) { 326 PD_CALLBACK_FREEDATA callback) {
344 if (!m_pPrivateData) { 327 if (!m_pPrivateData) {
345 m_pPrivateData = new CFX_PrivateData; 328 m_pPrivateData = new CFX_PrivateData;
346 } 329 }
347 m_pPrivateData->SetPrivateData(module_id, pData, callback); 330 m_pPrivateData->SetPrivateData(module_id, pData, callback);
348 return FWL_ERR_Succeeded; 331 return FWL_ERR_Succeeded;
349 } 332 }
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after
1073 FWL_ERR CFWL_WidgetImpDelegate::OnProcessEvent(CFWL_Event* pEvent) { 1056 FWL_ERR CFWL_WidgetImpDelegate::OnProcessEvent(CFWL_Event* pEvent) {
1074 return FWL_ERR_Succeeded; 1057 return FWL_ERR_Succeeded;
1075 } 1058 }
1076 1059
1077 FWL_ERR CFWL_WidgetImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, 1060 FWL_ERR CFWL_WidgetImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
1078 const CFX_Matrix* pMatrix) { 1061 const CFX_Matrix* pMatrix) {
1079 CFWL_EvtDraw evt; 1062 CFWL_EvtDraw evt;
1080 evt.m_pGraphics = pGraphics; 1063 evt.m_pGraphics = pGraphics;
1081 return FWL_ERR_Succeeded; 1064 return FWL_ERR_Succeeded;
1082 } 1065 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698