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

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

Issue 2464703006: Fold IFWL*::{Initialize|Finalize} into constructor/destructor (Closed)
Patch Set: Rebase to master 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_combolist.h ('k') | xfa/fwl/core/ifwl_datetimecalendar.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 PDFium Authors. All rights reserved. 1 // Copyright 2016 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_combolist.h" 7 #include "xfa/fwl/core/ifwl_combolist.h"
8 8
9 #include "third_party/base/ptr_util.h"
9 #include "xfa/fwl/core/ifwl_combobox.h" 10 #include "xfa/fwl/core/ifwl_combobox.h"
10 #include "xfa/fwl/core/ifwl_comboedit.h" 11 #include "xfa/fwl/core/ifwl_comboedit.h"
11 12
12 IFWL_ComboList::IFWL_ComboList(const IFWL_App* app, 13 IFWL_ComboList::IFWL_ComboList(const IFWL_App* app,
13 const CFWL_WidgetImpProperties& properties, 14 const CFWL_WidgetImpProperties& properties,
14 IFWL_Widget* pOuter) 15 IFWL_Widget* pOuter)
15 : IFWL_ListBox(app, properties, pOuter), m_bNotifyOwner(TRUE) { 16 : IFWL_ListBox(app, properties, pOuter), m_bNotifyOwner(TRUE) {
16 ASSERT(pOuter); 17 ASSERT(pOuter);
17 } 18 SetDelegate(pdfium::MakeUnique<CFWL_ComboListImpDelegate>(this));
18
19 void IFWL_ComboList::Initialize() {
20 IFWL_ListBox::Initialize();
21
22 // Delete the delegate that was created by IFWL_ListBox::Initialize ...
23 delete m_pDelegate;
24 m_pDelegate = new CFWL_ComboListImpDelegate(this);
25 }
26
27 void IFWL_ComboList::Finalize() {
28 delete m_pDelegate;
29 m_pDelegate = nullptr;
30 IFWL_ListBox::Finalize();
31 } 19 }
32 20
33 int32_t IFWL_ComboList::MatchItem(const CFX_WideString& wsMatch) { 21 int32_t IFWL_ComboList::MatchItem(const CFX_WideString& wsMatch) {
34 if (wsMatch.IsEmpty()) { 22 if (wsMatch.IsEmpty()) {
35 return -1; 23 return -1;
36 } 24 }
37 if (!m_pProperties->m_pDataProvider) 25 if (!m_pProperties->m_pDataProvider)
38 return -1; 26 return -1;
39 IFWL_ListBoxDP* pData = 27 IFWL_ListBoxDP* pData =
40 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 28 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 int32_t iSel = pData->GetItemIndex(m_pOwner, hItem); 176 int32_t iSel = pData->GetItemIndex(m_pOwner, hItem);
189 CFWL_EvtCmbHoverChanged event; 177 CFWL_EvtCmbHoverChanged event;
190 event.m_pSrcTarget = m_pOwner->m_pOuter; 178 event.m_pSrcTarget = m_pOwner->m_pOuter;
191 event.m_iCurHover = iSel; 179 event.m_iCurHover = iSel;
192 m_pOwner->DispatchEvent(&event); 180 m_pOwner->DispatchEvent(&event);
193 m_pOwner->ChangeSelected(iSel); 181 m_pOwner->ChangeSelected(iSel);
194 } 182 }
195 } else if (m_pOwner->m_bNotifyOwner) { 183 } else if (m_pOwner->m_bNotifyOwner) {
196 m_pOwner->ClientToOuter(pMsg->m_fx, pMsg->m_fy); 184 m_pOwner->ClientToOuter(pMsg->m_fx, pMsg->m_fy);
197 IFWL_ComboBox* pOuter = static_cast<IFWL_ComboBox*>(m_pOwner->m_pOuter); 185 IFWL_ComboBox* pOuter = static_cast<IFWL_ComboBox*>(m_pOwner->m_pOuter);
198 pOuter->m_pDelegate->OnProcessMessage(pMsg); 186 pOuter->GetDelegate()->OnProcessMessage(pMsg);
199 } 187 }
200 return 1; 188 return 1;
201 } 189 }
202 190
203 int32_t CFWL_ComboListImpDelegate::OnDropListLButtonDown(CFWL_MsgMouse* pMsg) { 191 int32_t CFWL_ComboListImpDelegate::OnDropListLButtonDown(CFWL_MsgMouse* pMsg) {
204 if (m_pOwner->m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) { 192 if (m_pOwner->m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) {
205 return 0; 193 return 0;
206 } 194 }
207 IFWL_ComboBox* pOuter = static_cast<IFWL_ComboBox*>(m_pOwner->m_pOuter); 195 IFWL_ComboBox* pOuter = static_cast<IFWL_ComboBox*>(m_pOwner->m_pOuter);
208 pOuter->ShowDropList(FALSE); 196 pOuter->ShowDropList(FALSE);
209 return 1; 197 return 1;
210 } 198 }
211 199
212 int32_t CFWL_ComboListImpDelegate::OnDropListLButtonUp(CFWL_MsgMouse* pMsg) { 200 int32_t CFWL_ComboListImpDelegate::OnDropListLButtonUp(CFWL_MsgMouse* pMsg) {
213 IFWL_ComboBox* pOuter = static_cast<IFWL_ComboBox*>(m_pOwner->m_pOuter); 201 IFWL_ComboBox* pOuter = static_cast<IFWL_ComboBox*>(m_pOwner->m_pOuter);
214 if (m_pOwner->m_bNotifyOwner) { 202 if (m_pOwner->m_bNotifyOwner) {
215 m_pOwner->ClientToOuter(pMsg->m_fx, pMsg->m_fy); 203 m_pOwner->ClientToOuter(pMsg->m_fx, pMsg->m_fy);
216 pOuter->m_pDelegate->OnProcessMessage(pMsg); 204 pOuter->GetDelegate()->OnProcessMessage(pMsg);
217 } else { 205 } else {
218 if (m_pOwner->IsShowScrollBar(TRUE) && m_pOwner->m_pVertScrollBar) { 206 if (m_pOwner->IsShowScrollBar(TRUE) && m_pOwner->m_pVertScrollBar) {
219 CFX_RectF rect; 207 CFX_RectF rect;
220 m_pOwner->m_pVertScrollBar->GetWidgetRect(rect); 208 m_pOwner->m_pVertScrollBar->GetWidgetRect(rect);
221 if (rect.Contains(pMsg->m_fx, pMsg->m_fy)) { 209 if (rect.Contains(pMsg->m_fx, pMsg->m_fy)) {
222 return 1; 210 return 1;
223 } 211 }
224 } 212 }
225 pOuter->ShowDropList(FALSE); 213 pOuter->ShowDropList(FALSE);
226 IFWL_ListItem* hItem = m_pOwner->GetItemAtPoint(pMsg->m_fx, pMsg->m_fy); 214 IFWL_ListItem* hItem = m_pOwner->GetItemAtPoint(pMsg->m_fx, pMsg->m_fy);
(...skipping 21 matching lines...) Expand all
248 pOuter->ProcessSelChanged(FALSE); 236 pOuter->ProcessSelChanged(FALSE);
249 return 1; 237 return 1;
250 } 238 }
251 default: { bPropagate = TRUE; } 239 default: { bPropagate = TRUE; }
252 } 240 }
253 } else if (pKey->m_dwCmd == FWL_KeyCommand::Char) { 241 } else if (pKey->m_dwCmd == FWL_KeyCommand::Char) {
254 bPropagate = TRUE; 242 bPropagate = TRUE;
255 } 243 }
256 if (bPropagate) { 244 if (bPropagate) {
257 pKey->m_pDstTarget = m_pOwner->m_pOuter; 245 pKey->m_pDstTarget = m_pOwner->m_pOuter;
258 pOuter->m_pDelegate->OnProcessMessage(pKey); 246 pOuter->GetDelegate()->OnProcessMessage(pKey);
259 return 1; 247 return 1;
260 } 248 }
261 return 0; 249 return 0;
262 } 250 }
263 251
264 void CFWL_ComboListImpDelegate::OnDropListKeyDown(CFWL_MsgKey* pKey) { 252 void CFWL_ComboListImpDelegate::OnDropListKeyDown(CFWL_MsgKey* pKey) {
265 uint32_t dwKeyCode = pKey->m_dwKeyCode; 253 uint32_t dwKeyCode = pKey->m_dwKeyCode;
266 switch (dwKeyCode) { 254 switch (dwKeyCode) {
267 case FWL_VKEY_Up: 255 case FWL_VKEY_Up:
268 case FWL_VKEY_Down: 256 case FWL_VKEY_Down:
(...skipping 12 matching lines...) Expand all
281 CFX_RectF rtInvalidate; 269 CFX_RectF rtInvalidate;
282 rtInvalidate.Set(0, 0, m_pOwner->m_pProperties->m_rtWidget.width, 270 rtInvalidate.Set(0, 0, m_pOwner->m_pProperties->m_rtWidget.width,
283 m_pOwner->m_pProperties->m_rtWidget.height); 271 m_pOwner->m_pProperties->m_rtWidget.height);
284 m_pOwner->Repaint(&rtInvalidate); 272 m_pOwner->Repaint(&rtInvalidate);
285 break; 273 break;
286 } 274 }
287 default: 275 default:
288 break; 276 break;
289 } 277 }
290 } 278 }
OLDNEW
« no previous file with comments | « xfa/fwl/core/ifwl_combolist.h ('k') | xfa/fwl/core/ifwl_datetimecalendar.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698