Fixed issue #2219: "add cherry picked from" is not applied when squashing/editing...
[TortoiseGit.git] / src / TortoiseProc / PatchViewDlg.cpp
blobeb0778ef2848ee941c17956647ba21da7d08415f
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2014 - TortoiseGit
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 // PatchViewDlg.cpp : implementation file
22 #include "stdafx.h"
23 #include "TortoiseProc.h"
24 #include "PatchViewDlg.h"
25 #include "registry.h"
26 #include "UnicodeUtils.h"
27 // CPatchViewDlg dialog
29 IMPLEMENT_DYNAMIC(CPatchViewDlg, CDialog)
31 CPatchViewDlg::CPatchViewDlg(CWnd* pParent /*=NULL*/)
32 : CDialog(CPatchViewDlg::IDD, pParent)
33 , m_ParentDlg(nullptr)
34 , m_pProjectProperties(nullptr)
39 CPatchViewDlg::~CPatchViewDlg()
43 void CPatchViewDlg::DoDataExchange(CDataExchange* pDX)
45 CDialog::DoDataExchange(pDX);
46 DDX_Control(pDX, IDC_PATCH, m_ctrlPatchView);
49 BEGIN_MESSAGE_MAP(CPatchViewDlg, CDialog)
50 ON_WM_SIZE()
51 ON_WM_MOVING()
52 ON_WM_CLOSE()
53 END_MESSAGE_MAP()
55 // CPatchViewDlg message handlers
57 BOOL CPatchViewDlg::OnInitDialog()
59 CDialog::OnInitDialog();
61 m_ctrlPatchView.Init(*m_pProjectProperties);
62 m_ctrlPatchView.SetFont((CString)CRegString(_T("Software\\TortoiseGit\\LogFontName"), _T("Courier New")), (DWORD)CRegDWORD(_T("Software\\TortoiseGit\\LogFontSize"), 8));
64 m_ctrlPatchView.SetUDiffStyle();
66 return TRUE; // return TRUE unless you set the focus to a control
67 // EXCEPTION: OCX Property Pages should return FALSE
70 void CPatchViewDlg::SetText(const CString& text)
72 m_ctrlPatchView.Call(SCI_SETREADONLY, FALSE);
73 m_ctrlPatchView.SetText(text);
74 m_ctrlPatchView.Call(SCI_SETREADONLY, TRUE);
75 if (!text.IsEmpty())
77 m_ctrlPatchView.Call(SCI_GOTOPOS, 0);
78 CRect rect;
79 m_ctrlPatchView.GetClientRect(rect);
80 m_ctrlPatchView.Call(SCI_SETSCROLLWIDTH, rect.Width() - 4);
84 void CPatchViewDlg::ClearView()
86 SetText(CString());
89 void CPatchViewDlg::OnSize(UINT nType, int cx, int cy)
91 CDialog::OnSize(nType, cx, cy);
93 if (this->IsWindowVisible())
95 CRect rect;
96 GetClientRect(rect);
97 GetDlgItem(IDC_PATCH)->MoveWindow(0, 0, cx, cy);
98 CRect rect2;
99 m_ctrlPatchView.GetClientRect(rect);
100 m_ctrlPatchView.Call(SCI_SETSCROLLWIDTH, rect.Width() - 4);
104 void CPatchViewDlg::OnMoving(UINT fwSide, LPRECT pRect)
106 #define STICKYSIZE 5
107 RECT parentRect;
108 m_ParentDlg->GetPatchViewParentWnd()->GetWindowRect(&parentRect);
109 if (abs(parentRect.right - pRect->left) < STICKYSIZE)
111 int width = pRect->right - pRect->left;
112 pRect->left = parentRect.right;
113 pRect->right = pRect->left + width;
115 CDialog::OnMoving(fwSide, pRect);
118 void CPatchViewDlg::OnClose()
120 CDialog::OnClose();
121 m_ParentDlg->TogglePatchView();