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

Side by Side Diff: fpdfsdk/src/pdfwindow/PWL_ListBox.cpp

Issue 1252613002: FX_BOOL considered harmful. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Manual edits. Created 5 years, 5 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
« no previous file with comments | « fpdfsdk/src/pdfwindow/PWL_Label.cpp ('k') | fpdfsdk/src/pdfwindow/PWL_ListCtrl.cpp » ('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 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 "../../include/pdfwindow/PDFWindow.h" 7 #include "../../include/pdfwindow/PDFWindow.h"
8 #include "../../include/pdfwindow/PWL_Wnd.h" 8 #include "../../include/pdfwindow/PWL_Wnd.h"
9 #include "../../include/pdfwindow/PWL_ListBox.h" 9 #include "../../include/pdfwindow/PWL_ListBox.h"
10 #include "../../include/pdfwindow/PWL_Utils.h" 10 #include "../../include/pdfwindow/PWL_Utils.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 42
43 m_pList->OnNotify(m_pList,PNM_SETSCROLLINFO,SBT_VSCROLL,(intptr_t)&Info) ; 43 m_pList->OnNotify(m_pList,PNM_SETSCROLLINFO,SBT_VSCROLL,(intptr_t)&Info) ;
44 44
45 if (CPWL_ScrollBar * pScroll = m_pList->GetVScrollBar()) 45 if (CPWL_ScrollBar * pScroll = m_pList->GetVScrollBar())
46 { 46 {
47 if (IsFloatBigger(Info.fPlateWidth,Info.fContentMax-Info.fConten tMin) 47 if (IsFloatBigger(Info.fPlateWidth,Info.fContentMax-Info.fConten tMin)
48 || IsFloatEqual(Info.fPlateWidth,Info.fContentMax-Info.f ContentMin)) 48 || IsFloatEqual(Info.fPlateWidth,Info.fContentMax-Info.f ContentMin))
49 { 49 {
50 if (pScroll->IsVisible()) 50 if (pScroll->IsVisible())
51 { 51 {
52 » » » » pScroll->SetVisible(FALSE); 52 » » » » pScroll->SetVisible(false);
53 m_pList->RePosChildWnd(); 53 m_pList->RePosChildWnd();
54 } 54 }
55 } 55 }
56 else 56 else
57 { 57 {
58 if (!pScroll->IsVisible()) 58 if (!pScroll->IsVisible())
59 { 59 {
60 » » » » pScroll->SetVisible(TRUE); 60 » » » » pScroll->SetVisible(true);
61 m_pList->RePosChildWnd(); 61 m_pList->RePosChildWnd();
62 } 62 }
63 } 63 }
64 } 64 }
65 } 65 }
66 66
67 void CPWL_List_Notify::IOnSetScrollPosY(FX_FLOAT fy) 67 void CPWL_List_Notify::IOnSetScrollPosY(FX_FLOAT fy)
68 { 68 {
69 m_pList->OnNotify(m_pList,PNM_SETSCROLLPOS,SBT_VSCROLL,(intptr_t)&fy); 69 m_pList->OnNotify(m_pList,PNM_SETSCROLLPOS,SBT_VSCROLL,(intptr_t)&fy);
70 } 70 }
71 71
72 void CPWL_List_Notify::IOnInvalidateRect(CPDF_Rect * pRect) 72 void CPWL_List_Notify::IOnInvalidateRect(CPDF_Rect * pRect)
73 { 73 {
74 m_pList->InvalidateRect(pRect); 74 m_pList->InvalidateRect(pRect);
75 } 75 }
76 76
77 /* --------------------------- CPWL_ListBox ---------------------------- */ 77 /* --------------------------- CPWL_ListBox ---------------------------- */
78 78
79 CPWL_ListBox::CPWL_ListBox() : 79 CPWL_ListBox::CPWL_ListBox() :
80 m_pList(NULL), 80 m_pList(NULL),
81 m_pListNotify(NULL), 81 m_pListNotify(NULL),
82 » m_bMouseDown(FALSE), 82 » m_bMouseDown(false),
83 » m_bHoverSel(FALSE), 83 » m_bHoverSel(false),
84 m_pFillerNotify(NULL) 84 m_pFillerNotify(NULL)
85 { 85 {
86 m_pList = IFX_List::NewList(); 86 m_pList = IFX_List::NewList();
87 87
88 ASSERT(m_pList != NULL); 88 ASSERT(m_pList != NULL);
89 } 89 }
90 90
91 CPWL_ListBox::~CPWL_ListBox() 91 CPWL_ListBox::~CPWL_ListBox()
92 { 92 {
93 IFX_List::DelList(m_pList); 93 IFX_List::DelList(m_pList);
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 IFX_Edit::DrawEdit(pDevice, pUser2Device, m_pLis t->GetItemEdit(i), 222 IFX_Edit::DrawEdit(pDevice, pUser2Device, m_pLis t->GetItemEdit(i),
223 CPWL_Utils::PWLColorToFXColor(Ge tTextColor()), 223 CPWL_Utils::PWLColorToFXColor(Ge tTextColor()),
224 CPWL_Utils::PWLColorToFXColor(Ge tTextStrokeColor()), 224 CPWL_Utils::PWLColorToFXColor(Ge tTextStrokeColor()),
225 rcList, ptOffset, NULL,pSysHandl er, NULL); 225 rcList, ptOffset, NULL,pSysHandl er, NULL);
226 226
227 } 227 }
228 } 228 }
229 } 229 }
230 } 230 }
231 231
232 FX_BOOL CPWL_ListBox::OnKeyDown(FX_WORD nChar, FX_DWORD nFlag) 232 bool CPWL_ListBox::OnKeyDown(FX_WORD nChar, FX_DWORD nFlag)
233 { 233 {
234 CPWL_Wnd::OnKeyDown(nChar, nFlag); 234 CPWL_Wnd::OnKeyDown(nChar, nFlag);
235 235
236 » if (!m_pList) return FALSE; 236 » if (!m_pList) return false;
237 237
238 switch (nChar) 238 switch (nChar)
239 { 239 {
240 default: 240 default:
241 » » return FALSE; 241 » » return false;
242 case FWL_VKEY_Up: 242 case FWL_VKEY_Up:
243 case FWL_VKEY_Down: 243 case FWL_VKEY_Down:
244 case FWL_VKEY_Home: 244 case FWL_VKEY_Home:
245 case FWL_VKEY_Left: 245 case FWL_VKEY_Left:
246 case FWL_VKEY_End: 246 case FWL_VKEY_End:
247 case FWL_VKEY_Right: 247 case FWL_VKEY_Right:
248 break; 248 break;
249 } 249 }
250 250
251 switch (nChar) 251 switch (nChar)
(...skipping 13 matching lines...) Expand all
265 case FWL_VKEY_End: 265 case FWL_VKEY_End:
266 m_pList->OnVK_END(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag)); 266 m_pList->OnVK_END(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag));
267 break; 267 break;
268 case FWL_VKEY_Right: 268 case FWL_VKEY_Right:
269 m_pList->OnVK_RIGHT(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag)); 269 m_pList->OnVK_RIGHT(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag));
270 break; 270 break;
271 case FWL_VKEY_Delete: 271 case FWL_VKEY_Delete:
272 break; 272 break;
273 } 273 }
274 274
275 » FX_BOOL bExit = FALSE; 275 » bool bExit = false;
276 » OnNotifySelChanged(TRUE,bExit,nFlag); 276 » OnNotifySelChanged(true,bExit,nFlag);
277 277
278 » return TRUE; 278 » return true;
279 } 279 }
280 280
281 FX_BOOL CPWL_ListBox::OnChar(FX_WORD nChar, FX_DWORD nFlag) 281 bool CPWL_ListBox::OnChar(FX_WORD nChar, FX_DWORD nFlag)
282 { 282 {
283 CPWL_Wnd::OnChar(nChar,nFlag); 283 CPWL_Wnd::OnChar(nChar,nFlag);
284 284
285 » if (!m_pList) return FALSE; 285 » if (!m_pList) return false;
286 286
287 » if (!m_pList->OnChar(nChar,IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag))) return FALSE; 287 » if (!m_pList->OnChar(nChar,IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag))) return false;
288 288
289 » FX_BOOL bExit = FALSE; 289 » bool bExit = false;
290 » OnNotifySelChanged(TRUE,bExit, nFlag); 290 » OnNotifySelChanged(true,bExit, nFlag);
291 291
292 » return TRUE; 292 » return true;
293 } 293 }
294 294
295 FX_BOOL CPWL_ListBox::OnLButtonDown(const CPDF_Point & point, FX_DWORD nFlag) 295 bool CPWL_ListBox::OnLButtonDown(const CPDF_Point & point, FX_DWORD nFlag)
296 { 296 {
297 CPWL_Wnd::OnLButtonDown(point,nFlag); 297 CPWL_Wnd::OnLButtonDown(point,nFlag);
298 298
299 if (ClientHitTest(point)) 299 if (ClientHitTest(point))
300 { 300 {
301 » » m_bMouseDown = TRUE; 301 » » m_bMouseDown = true;
302 SetFocus(); 302 SetFocus();
303 SetCapture(); 303 SetCapture();
304 304
305 if (m_pList) 305 if (m_pList)
306 m_pList->OnMouseDown(point,IsSHIFTpressed(nFlag),IsCTRLp ressed(nFlag)); 306 m_pList->OnMouseDown(point,IsSHIFTpressed(nFlag),IsCTRLp ressed(nFlag));
307 } 307 }
308 308
309 » return TRUE; 309 » return true;
310 } 310 }
311 311
312 FX_BOOL CPWL_ListBox::OnLButtonUp(const CPDF_Point & point, FX_DWORD nFlag) 312 bool CPWL_ListBox::OnLButtonUp(const CPDF_Point & point, FX_DWORD nFlag)
313 { 313 {
314 CPWL_Wnd::OnLButtonUp(point,nFlag); 314 CPWL_Wnd::OnLButtonUp(point,nFlag);
315 315
316 if (m_bMouseDown) 316 if (m_bMouseDown)
317 { 317 {
318 ReleaseCapture(); 318 ReleaseCapture();
319 » » m_bMouseDown = FALSE; 319 » » m_bMouseDown = false;
320 } 320 }
321 321
322 » FX_BOOL bExit = FALSE; 322 » bool bExit = false;
323 » OnNotifySelChanged(FALSE,bExit,nFlag); 323 » OnNotifySelChanged(false,bExit,nFlag);
324 324
325 » return TRUE; 325 » return true;
326 } 326 }
327 327
328 void CPWL_ListBox::SetHoverSel(FX_BOOL bHoverSel) 328 void CPWL_ListBox::SetHoverSel(bool bHoverSel)
329 { 329 {
330 m_bHoverSel = bHoverSel; 330 m_bHoverSel = bHoverSel;
331 } 331 }
332 332
333 FX_BOOL CPWL_ListBox::OnMouseMove(const CPDF_Point & point, FX_DWORD nFlag) 333 bool CPWL_ListBox::OnMouseMove(const CPDF_Point & point, FX_DWORD nFlag)
334 { 334 {
335 CPWL_Wnd::OnMouseMove(point, nFlag); 335 CPWL_Wnd::OnMouseMove(point, nFlag);
336 336
337 if (m_bHoverSel && !IsCaptureMouse() && ClientHitTest(point)) 337 if (m_bHoverSel && !IsCaptureMouse() && ClientHitTest(point))
338 { 338 {
339 if (m_pList) 339 if (m_pList)
340 m_pList->Select(m_pList->GetItemIndex(point)); 340 m_pList->Select(m_pList->GetItemIndex(point));
341 } 341 }
342 342
343 if (m_bMouseDown) 343 if (m_bMouseDown)
344 { 344 {
345 if (m_pList) 345 if (m_pList)
346 m_pList->OnMouseMove(point,IsSHIFTpressed(nFlag),IsCTRLp ressed(nFlag)); 346 m_pList->OnMouseMove(point,IsSHIFTpressed(nFlag),IsCTRLp ressed(nFlag));
347 } 347 }
348 348
349 » return TRUE; 349 » return true;
350 } 350 }
351 351
352 void CPWL_ListBox::OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, intptr_t wParam, intpt r_t lParam) 352 void CPWL_ListBox::OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, intptr_t wParam, intpt r_t lParam)
353 { 353 {
354 CPWL_Wnd::OnNotify(pWnd,msg,wParam,lParam); 354 CPWL_Wnd::OnNotify(pWnd,msg,wParam,lParam);
355 355
356 FX_FLOAT fPos; 356 FX_FLOAT fPos;
357 357
358 switch (msg) 358 switch (msg)
359 { 359 {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 } 398 }
399 399
400 void CPWL_ListBox::RePosChildWnd() 400 void CPWL_ListBox::RePosChildWnd()
401 { 401 {
402 CPWL_Wnd::RePosChildWnd(); 402 CPWL_Wnd::RePosChildWnd();
403 403
404 if (m_pList) 404 if (m_pList)
405 m_pList->SetPlateRect(GetListRect()); 405 m_pList->SetPlateRect(GetListRect());
406 } 406 }
407 407
408 void CPWL_ListBox::OnNotifySelChanged(FX_BOOL bKeyDown, FX_BOOL & bExit, FX_DWO RD nFlag) 408 void CPWL_ListBox::OnNotifySelChanged(bool bKeyDown, bool & bExit, FX_DWORD nFl ag)
409 { 409 {
410 if (m_pFillerNotify) 410 if (m_pFillerNotify)
411 { 411 {
412 » » FX_BOOL bRC = TRUE; 412 » » bool bRC = true;
413 CFX_WideString swChange = GetText(); 413 CFX_WideString swChange = GetText();
414 CFX_WideString strChangeEx; 414 CFX_WideString strChangeEx;
415 int nSelStart = 0; 415 int nSelStart = 0;
416 int nSelEnd = swChange.GetLength(); 416 int nSelEnd = swChange.GetLength();
417 » » m_pFillerNotify->OnBeforeKeyStroke(FALSE, GetAttachedData(), 0, swChange, strChangeEx, nSelStart, nSelEnd, bKeyDown, bRC, bExit, nFlag); 417 » » m_pFillerNotify->OnBeforeKeyStroke(false, GetAttachedData(), 0, swChange, strChangeEx, nSelStart, nSelEnd, bKeyDown, bRC, bExit, nFlag);
418 if (bExit) return; 418 if (bExit) return;
419 419
420 » » m_pFillerNotify->OnAfterKeyStroke(FALSE, GetAttachedData(), bExi t,nFlag); 420 » » m_pFillerNotify->OnAfterKeyStroke(false, GetAttachedData(), bExi t,nFlag);
421 } 421 }
422 } 422 }
423 423
424 CPDF_Rect CPWL_ListBox::GetFocusRect() const 424 CPDF_Rect CPWL_ListBox::GetFocusRect() const
425 { 425 {
426 if (m_pList && m_pList->IsMultipleSel()) 426 if (m_pList && m_pList->IsMultipleSel())
427 { 427 {
428 CPDF_Rect rcCaret = m_pList->GetItemRect(m_pList->GetCaret()); 428 CPDF_Rect rcCaret = m_pList->GetItemRect(m_pList->GetCaret());
429 rcCaret.Intersect(GetClientRect()); 429 rcCaret.Intersect(GetClientRect());
430 return rcCaret; 430 return rcCaret;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 if (m_pList) 491 if (m_pList)
492 m_pList->Empty(); 492 m_pList->Empty();
493 } 493 }
494 494
495 void CPWL_ListBox::Reset() 495 void CPWL_ListBox::Reset()
496 { 496 {
497 if (m_pList) 497 if (m_pList)
498 m_pList->Cancel(); 498 m_pList->Cancel();
499 } 499 }
500 500
501 FX_BOOL CPWL_ListBox::IsMultipleSel() const 501 bool CPWL_ListBox::IsMultipleSel() const
502 { 502 {
503 if (m_pList) 503 if (m_pList)
504 return m_pList->IsMultipleSel(); 504 return m_pList->IsMultipleSel();
505 505
506 » return FALSE; 506 » return false;
507 } 507 }
508 508
509 int32_t CPWL_ListBox::GetCaretIndex() const 509 int32_t CPWL_ListBox::GetCaretIndex() const
510 { 510 {
511 if (m_pList) 511 if (m_pList)
512 return m_pList->GetCaret(); 512 return m_pList->GetCaret();
513 513
514 return -1; 514 return -1;
515 } 515 }
516 516
517 int32_t CPWL_ListBox::GetCurSel() const 517 int32_t CPWL_ListBox::GetCurSel() const
518 { 518 {
519 if (m_pList) 519 if (m_pList)
520 return m_pList->GetSelect(); 520 return m_pList->GetSelect();
521 521
522 return -1; 522 return -1;
523 } 523 }
524 524
525 FX_BOOL CPWL_ListBox::IsItemSelected(int32_t nItemIndex) const 525 bool CPWL_ListBox::IsItemSelected(int32_t nItemIndex) const
526 { 526 {
527 if (m_pList) 527 if (m_pList)
528 return m_pList->IsItemSelected(nItemIndex); 528 return m_pList->IsItemSelected(nItemIndex);
529 529
530 » return FALSE; 530 » return false;
531 } 531 }
532 532
533 int32_t CPWL_ListBox::GetTopVisibleIndex() const 533 int32_t CPWL_ListBox::GetTopVisibleIndex() const
534 { 534 {
535 if (m_pList) 535 if (m_pList)
536 { 536 {
537 m_pList->ScrollToListItem(m_pList->GetFirstSelected()); 537 m_pList->ScrollToListItem(m_pList->GetFirstSelected());
538 return m_pList->GetTopItem(); 538 return m_pList->GetTopItem();
539 } 539 }
540 540
(...skipping 30 matching lines...) Expand all
571 return m_pList->GetFirstHeight(); 571 return m_pList->GetFirstHeight();
572 572
573 return 0.0f; 573 return 0.0f;
574 } 574 }
575 575
576 CPDF_Rect CPWL_ListBox::GetListRect() const 576 CPDF_Rect CPWL_ListBox::GetListRect() const
577 { 577 {
578 return CPWL_Utils::DeflateRect(GetWindowRect(),(FX_FLOAT)(GetBorderWidth ()+GetInnerBorderWidth())); 578 return CPWL_Utils::DeflateRect(GetWindowRect(),(FX_FLOAT)(GetBorderWidth ()+GetInnerBorderWidth()));
579 } 579 }
580 580
581 FX_BOOL»CPWL_ListBox::OnMouseWheel(short zDelta, const CPDF_Point & point, FX_DW ORD nFlag) 581 bool» CPWL_ListBox::OnMouseWheel(short zDelta, const CPDF_Point & point, FX_DW ORD nFlag)
582 { 582 {
583 » if (!m_pList) return FALSE; 583 » if (!m_pList) return false;
584 584
585 if (zDelta < 0) 585 if (zDelta < 0)
586 { 586 {
587 m_pList->OnVK_DOWN(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag)); 587 m_pList->OnVK_DOWN(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag));
588 } 588 }
589 else 589 else
590 { 590 {
591 m_pList->OnVK_UP(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag)); 591 m_pList->OnVK_UP(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag));
592 } 592 }
593 593
594 » FX_BOOL bExit = FALSE; 594 » bool bExit = false;
595 » OnNotifySelChanged(FALSE,bExit, nFlag); 595 » OnNotifySelChanged(false,bExit, nFlag);
596 » return TRUE; 596 » return true;
597 } 597 }
598 598
OLDNEW
« no previous file with comments | « fpdfsdk/src/pdfwindow/PWL_Label.cpp ('k') | fpdfsdk/src/pdfwindow/PWL_ListCtrl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698