OSDN Git Service

PATCH: [ 1158456 ] Fix setting font for headerbar editcontrols
authorKimmo Varis <kimmov@gmail.com>
Tue, 8 Mar 2005 16:29:52 +0000 (16:29 +0000)
committerKimmo Varis <kimmov@gmail.com>
Tue, 8 Mar 2005 16:29:52 +0000 (16:29 +0000)
Src/EditorFilepathBar.cpp
Src/EditorFilepathBar.h
Src/readme.txt

index 00863f6..87591a7 100644 (file)
@@ -35,6 +35,17 @@ static char THIS_FILE[] = __FILE__;
 /////////////////////////////////////////////////////////////////////////////
 // CEditorFilePathBar construction destruction
 
+CEditorFilePathBar::CEditorFilePathBar()
+: m_pFont(NULL)
+{
+}
+
+CEditorFilePathBar::~CEditorFilePathBar()
+{
+       delete m_pFont;
+}
+
+
 BOOL CEditorFilePathBar::Create(CWnd* pParentWnd)
 {
        if (! CDialogBar::Create(pParentWnd, CEditorFilePathBar::IDD, 
@@ -53,16 +64,37 @@ BOOL CEditorFilePathBar::Create(CWnd* pParentWnd)
 
 /////////////////////////////////////////////////////////////////////////////
 
-
-
-// return TRUE if parent must recompute layout
-BOOL CEditorFilePathBar::LookLikeThisWnd(CWnd * pWnd)
+/**
+ * @brief Set look of headerbars similar to other window.
+ *
+ * @param [in] pWnd Pointer to window we want to imitate
+ * @return TRUE if parent must recompute layout
+ */
+BOOL CEditorFilePathBar::LookLikeThisWnd(const CWnd * pWnd)
 {
-       // same font
+       // Update font. Note that we must delete previous font
+       // before creating a new one.
        CFont * pFont = pWnd->GetFont();
-       m_EditLeft.SetFont(pFont);
-       m_EditRight.SetFont(pFont);
-       // and same dimensions
+       if (pFont)
+       {
+               if (m_pFont != NULL)
+                       delete m_pFont;
+
+               m_pFont = new CFont();
+
+               if (m_pFont != NULL)
+               {
+                       LOGFONT lfFont = {0};
+                       if (pFont->GetLogFont(&lfFont))
+                       {
+                               m_pFont->CreateFontIndirect(&lfFont);
+                               m_EditLeft.SetFont(m_pFont);
+                               m_EditRight.SetFont(m_pFont);
+                       }
+               }
+       }
+
+       // Set same dimensions (than window we imitate)
        CRect rectNew;
        pWnd->GetWindowRect(rectNew);
        CRect rectCurrent;
index 87275c2..d642832 100644 (file)
@@ -48,12 +48,15 @@ public:
 class CEditorFilePathBar : public CDialogBar, public IHeaderBar
 {
 public : 
+       CEditorFilePathBar();
+       ~CEditorFilePathBar();
+
        BOOL Create( CWnd* pParentWnd);
 
 // Dialog Data
        enum { IDD = IDD_EDITOR_HEADERBAR };
 
-       BOOL LookLikeThisWnd(CWnd * pWnd);
+       BOOL LookLikeThisWnd(const CWnd * pWnd);
        void Resize();
        void Resize(int leftWidth, int rightWidth);
 
@@ -68,6 +71,7 @@ protected:
 private:
        // this dialog uses custom edit boxes
        CFilepathEdit m_EditLeft, m_EditRight;
+       CFont * m_pFont; /**< Font for editcontrols */
 };
 
 
index 1832118..6413538 100644 (file)
@@ -1,3 +1,7 @@
+2005-03-08 Kimmo
+ PATCH: [ 1158456 ] Fix setting font for headerbar editcontrols
+  Src: EditorFilepathBar.cpp EditorFilepathBar.h
+
 2005-03-07 Perry
  PATCH: [ 1157859 ] Add LVS_SHOWSELALWAYS style to dirview
  Postlude: Alter WindowStyle_Add to call CWnd::ModifyStyle.