From 21a6da201a6bbf8f7e67a4934063db17f6ba255b Mon Sep 17 00:00:00 2001 From: Takashi Sawanaka Date: Sat, 25 Jun 2016 20:16:56 +0900 Subject: [PATCH] EditorFilepathBar.*: Refactor --- Src/EditorFilepathBar.cpp | 13 ++++--------- Src/EditorFilepathBar.h | 3 +-- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/Src/EditorFilepathBar.cpp b/Src/EditorFilepathBar.cpp index 8db56e8dc..11ccc07dc 100644 --- a/Src/EditorFilepathBar.cpp +++ b/Src/EditorFilepathBar.cpp @@ -41,7 +41,7 @@ END_MESSAGE_MAP() * @brief Constructor. */ CEditorFilePathBar::CEditorFilePathBar() -: m_pFont(nullptr), m_nPanes(2) +: m_nPanes(2) { } @@ -66,18 +66,13 @@ BOOL CEditorFilePathBar::Create(CWnd* pParentWnd) NONCLIENTMETRICS ncm = { sizeof NONCLIENTMETRICS }; if (SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof NONCLIENTMETRICS, &ncm, 0)) - { - m_pFont.reset(new CFont()); - if (m_pFont) - m_pFont->CreateFontIndirect(&ncm.lfStatusFont); - } + m_font.CreateFontIndirect(&ncm.lfStatusFont); // subclass the two custom edit boxes for (int pane = 0; pane < countof(m_Edit); pane++) { m_Edit[pane].SubClassEdit(IDC_STATIC_TITLE_PANE0 + pane, this); - if (m_pFont) - m_Edit[pane].SetFont(m_pFont.get()); + m_Edit[pane].SetFont(&m_font); m_Edit[pane].SetMargins(4, 4); } return TRUE; @@ -87,7 +82,7 @@ CSize CEditorFilePathBar::CalcFixedLayout(BOOL bStretch, BOOL bHorz) { TEXTMETRIC tm; CClientDC dc(this); - CFont *pOldFont = dc.SelectObject(m_pFont.get()); + CFont *pOldFont = dc.SelectObject(&m_font); dc.GetTextMetrics(&tm); dc.SelectObject(pOldFont); return CSize(SHRT_MAX, tm.tmHeight + 6); diff --git a/Src/EditorFilepathBar.h b/Src/EditorFilepathBar.h index 5f2642516..cff1d1a97 100644 --- a/Src/EditorFilepathBar.h +++ b/Src/EditorFilepathBar.h @@ -25,7 +25,6 @@ */ #pragma once -#include #include "FilepathEdit.h" /** @@ -74,6 +73,6 @@ protected: private: // this dialog uses custom edit boxes CFilepathEdit m_Edit[3]; /**< Edit controls. */ - std::unique_ptr m_pFont; /**< Font for editcontrols */ + CFont m_font; /**< Font for editcontrols */ int m_nPanes; }; -- 2.11.0