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

Side by Side Diff: xfa/fxfa/app/xfa_fwltheme.cpp

Issue 2227883002: Use smart pointers for class owned pointers in xfa/fxfa (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: address comments Created 4 years, 4 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 | « xfa/fxfa/app/xfa_fwltheme.h ('k') | xfa/fxfa/include/xfa_ffapp.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 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/fxfa/app/xfa_fwltheme.h" 7 #include "xfa/fxfa/app/xfa_fwltheme.h"
8 8
9 #include "xfa/fde/tto/fde_textout.h" 9 #include "xfa/fde/tto/fde_textout.h"
10 #include "xfa/fgas/crt/fgas_codepage.h" 10 #include "xfa/fgas/crt/fgas_codepage.h"
(...skipping 25 matching lines...) Expand all
36 36
37 CXFA_FFWidget* XFA_ThemeGetOuterWidget(IFWL_Widget* pWidget) { 37 CXFA_FFWidget* XFA_ThemeGetOuterWidget(IFWL_Widget* pWidget) {
38 IFWL_Widget* pOuter = pWidget; 38 IFWL_Widget* pOuter = pWidget;
39 while (pOuter && pOuter->GetOuter()) 39 while (pOuter && pOuter->GetOuter())
40 pOuter = pOuter->GetOuter(); 40 pOuter = pOuter->GetOuter();
41 41
42 return pOuter ? static_cast<CXFA_FFWidget*>(pOuter->GetLayoutItem()) 42 return pOuter ? static_cast<CXFA_FFWidget*>(pOuter->GetLayoutItem())
43 : nullptr; 43 : nullptr;
44 } 44 }
45 45
46 CXFA_FWLTheme::CXFA_FWLTheme(CXFA_FFApp* pApp) : m_pApp(pApp) { 46 CXFA_FWLTheme::CXFA_FWLTheme(CXFA_FFApp* pApp)
47 m_dwCapacity = 0; 47 : m_pCheckBoxTP(new CXFA_FWLCheckBoxTP),
48 m_fCapacity = 0; 48 m_pListBoxTP(new CFWL_ListBoxTP),
49 m_pCalendarFont = nullptr; 49 m_pPictureBoxTP(new CFWL_PictureBoxTP),
50 m_Rect.Set(0, 0, 0, 0); 50 m_pSrollBarTP(new CFWL_ScrollBarTP),
51 m_pCheckBoxTP = new CXFA_FWLCheckBoxTP; 51 m_pEditTP(new CXFA_FWLEditTP),
52 m_pListBoxTP = new CFWL_ListBoxTP; 52 m_pComboBoxTP(new CFWL_ComboBoxTP),
53 m_pPictureBoxTP = new CFWL_PictureBoxTP; 53 m_pMonthCalendarTP(new CFWL_MonthCalendarTP),
54 m_pSrollBarTP = new CFWL_ScrollBarTP; 54 m_pDateTimePickerTP(new CFWL_DateTimePickerTP),
55 m_pEditTP = new CXFA_FWLEditTP; 55 m_pPushButtonTP(new CFWL_PushButtonTP),
56 m_pComboBoxTP = new CFWL_ComboBoxTP; 56 m_pCaretTP(new CFWL_CaretTP),
57 m_pMonthCalendarTP = new CFWL_MonthCalendarTP; 57 m_pBarcodeTP(new CFWL_BarcodeTP),
58 m_pDateTimePickerTP = new CFWL_DateTimePickerTP; 58 m_fCapacity(0.0f),
59 m_pPushButtonTP = new CFWL_PushButtonTP; 59 m_dwCapacity(0),
60 m_pCaretTP = new CFWL_CaretTP; 60 m_pCalendarFont(nullptr),
61 m_pBarcodeTP = new CFWL_BarcodeTP; 61 m_pApp(pApp) {
62 m_Rect.Reset();
62 Initialize(); 63 Initialize();
63 } 64 }
65
64 CXFA_FWLTheme::~CXFA_FWLTheme() { 66 CXFA_FWLTheme::~CXFA_FWLTheme() {
65 Finalize(); 67 Finalize();
66 delete m_pCheckBoxTP;
67 delete m_pListBoxTP;
68 delete m_pPictureBoxTP;
69 delete m_pSrollBarTP;
70 delete m_pEditTP;
71 delete m_pComboBoxTP;
72 delete m_pMonthCalendarTP;
73 delete m_pDateTimePickerTP;
74 delete m_pPushButtonTP;
75 delete m_pCaretTP;
76 delete m_pBarcodeTP;
77 } 68 }
69
78 FWL_Error CXFA_FWLTheme::Initialize() { 70 FWL_Error CXFA_FWLTheme::Initialize() {
79 m_pTextOut.reset(new CFDE_TextOut); 71 m_pTextOut.reset(new CFDE_TextOut);
80 for (size_t i = 0; !m_pCalendarFont && i < FX_ArraySize(g_FWLTheme_CalFonts); 72 for (size_t i = 0; !m_pCalendarFont && i < FX_ArraySize(g_FWLTheme_CalFonts);
81 ++i) { 73 ++i) {
82 m_pCalendarFont = CFGAS_GEFont::LoadFont(g_FWLTheme_CalFonts[i], 0, 0, 74 m_pCalendarFont = CFGAS_GEFont::LoadFont(g_FWLTheme_CalFonts[i], 0, 0,
83 m_pApp->GetFDEFontMgr()); 75 m_pApp->GetFDEFontMgr());
84 } 76 }
85 if (!m_pCalendarFont) { 77 if (!m_pCalendarFont) {
86 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ 78 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
87 m_pCalendarFont = m_pApp->GetFDEFontMgr()->GetDefFontByCodePage( 79 m_pCalendarFont = m_pApp->GetFDEFontMgr()->GetDefFontByCodePage(
88 FX_CODEPAGE_MSWin_WesternEuropean, 0, nullptr); 80 FX_CODEPAGE_MSWin_WesternEuropean, 0, nullptr);
89 #else 81 #else
90 m_pCalendarFont = m_pApp->GetFDEFontMgr()->GetFontByCodePage( 82 m_pCalendarFont = m_pApp->GetFDEFontMgr()->GetFontByCodePage(
91 FX_CODEPAGE_MSWin_WesternEuropean, 0, nullptr); 83 FX_CODEPAGE_MSWin_WesternEuropean, 0, nullptr);
92 #endif 84 #endif
93 } 85 }
94 86
95 ASSERT(m_pCalendarFont); 87 ASSERT(m_pCalendarFont);
96 FWLTHEME_Init(); 88 FWLTHEME_Init();
97 return FWL_Error::Succeeded; 89 return FWL_Error::Succeeded;
98 } 90 }
91
99 FWL_Error CXFA_FWLTheme::Finalize() { 92 FWL_Error CXFA_FWLTheme::Finalize() {
100 m_pTextOut.reset(); 93 m_pTextOut.reset();
101 if (m_pCalendarFont) { 94 if (m_pCalendarFont) {
102 m_pCalendarFont->Release(); 95 m_pCalendarFont->Release();
103 m_pCalendarFont = nullptr; 96 m_pCalendarFont = nullptr;
104 } 97 }
105 FWLTHEME_Release(); 98 FWLTHEME_Release();
106 return FWL_Error::Succeeded; 99 return FWL_Error::Succeeded;
107 } 100 }
108 101
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 return FALSE; 392 return FALSE;
400 m_pTextOut->SetAlignment(pParams->m_iTTOAlign); 393 m_pTextOut->SetAlignment(pParams->m_iTTOAlign);
401 m_pTextOut->SetStyles(pParams->m_dwTTOStyles); 394 m_pTextOut->SetStyles(pParams->m_dwTTOStyles);
402 m_pTextOut->CalcLogicSize(pParams->m_wsText.c_str(), 395 m_pTextOut->CalcLogicSize(pParams->m_wsText.c_str(),
403 pParams->m_wsText.GetLength(), rect); 396 pParams->m_wsText.GetLength(), rect);
404 return TRUE; 397 return TRUE;
405 } 398 }
406 CFWL_WidgetTP* CXFA_FWLTheme::GetTheme(IFWL_Widget* pWidget) { 399 CFWL_WidgetTP* CXFA_FWLTheme::GetTheme(IFWL_Widget* pWidget) {
407 switch (pWidget->GetClassID()) { 400 switch (pWidget->GetClassID()) {
408 case FWL_Type::CheckBox: 401 case FWL_Type::CheckBox:
409 return m_pCheckBoxTP; 402 return m_pCheckBoxTP.get();
410 case FWL_Type::ListBox: 403 case FWL_Type::ListBox:
411 return m_pListBoxTP; 404 return m_pListBoxTP.get();
412 case FWL_Type::PictureBox: 405 case FWL_Type::PictureBox:
413 return m_pPictureBoxTP; 406 return m_pPictureBoxTP.get();
414 case FWL_Type::ScrollBar: 407 case FWL_Type::ScrollBar:
415 return m_pSrollBarTP; 408 return m_pSrollBarTP.get();
416 case FWL_Type::Edit: 409 case FWL_Type::Edit:
417 return m_pEditTP; 410 return m_pEditTP.get();
418 case FWL_Type::ComboBox: 411 case FWL_Type::ComboBox:
419 return m_pComboBoxTP; 412 return m_pComboBoxTP.get();
420 case FWL_Type::MonthCalendar: 413 case FWL_Type::MonthCalendar:
421 return m_pMonthCalendarTP; 414 return m_pMonthCalendarTP.get();
422 case FWL_Type::DateTimePicker: 415 case FWL_Type::DateTimePicker:
423 return m_pDateTimePickerTP; 416 return m_pDateTimePickerTP.get();
424 case FWL_Type::PushButton: 417 case FWL_Type::PushButton:
425 return m_pPushButtonTP; 418 return m_pPushButtonTP.get();
426 case FWL_Type::Caret: 419 case FWL_Type::Caret:
427 return m_pCaretTP; 420 return m_pCaretTP.get();
428 case FWL_Type::Barcode: 421 case FWL_Type::Barcode:
429 return m_pBarcodeTP; 422 return m_pBarcodeTP.get();
430 default: 423 default:
431 return nullptr; 424 return nullptr;
432 } 425 }
433 } 426 }
434 CXFA_FWLCheckBoxTP::CXFA_FWLCheckBoxTP() {} 427 CXFA_FWLCheckBoxTP::CXFA_FWLCheckBoxTP() {}
435 FX_BOOL CXFA_FWLCheckBoxTP::DrawBackground(CFWL_ThemeBackground* pParams) { 428 FX_BOOL CXFA_FWLCheckBoxTP::DrawBackground(CFWL_ThemeBackground* pParams) {
436 if (pParams->m_iPart != CFWL_Part::CheckBox) { 429 if (pParams->m_iPart != CFWL_Part::CheckBox) {
437 return TRUE; 430 return TRUE;
438 } 431 }
439 if ((pParams->m_dwStates & CFWL_PartState_Checked) || 432 if ((pParams->m_dwStates & CFWL_PartState_Checked) ||
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 } 488 }
496 } 489 }
497 CFX_Color crLine(cr); 490 CFX_Color crLine(cr);
498 pParams->m_pGraphics->SetStrokeColor(&crLine); 491 pParams->m_pGraphics->SetStrokeColor(&crLine);
499 pParams->m_pGraphics->SetLineWidth(fWidth); 492 pParams->m_pGraphics->SetLineWidth(fWidth);
500 pParams->m_pGraphics->StrokePath(pParams->m_pPath, &pParams->m_matrix); 493 pParams->m_pGraphics->StrokePath(pParams->m_pPath, &pParams->m_matrix);
501 return TRUE; 494 return TRUE;
502 } 495 }
503 return CFWL_EditTP::DrawBackground(pParams); 496 return CFWL_EditTP::DrawBackground(pParams);
504 } 497 }
OLDNEW
« no previous file with comments | « xfa/fxfa/app/xfa_fwltheme.h ('k') | xfa/fxfa/include/xfa_ffapp.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698