CommitDlg: Update empty file list message
[TortoiseGit.git] / src / TortoiseProc / PatchViewDlg.cpp
blobbced52785585ad7b1f3b6e02f762dee9cbf5ad2f
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2015 - 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"
26 // CPatchViewDlg dialog
28 IMPLEMENT_DYNAMIC(CPatchViewDlg, CDialog)
30 CPatchViewDlg::CPatchViewDlg(CWnd* pParent /*=NULL*/)
31 : CDialog(CPatchViewDlg::IDD, pParent)
32 , m_ParentDlg(nullptr)
37 CPatchViewDlg::~CPatchViewDlg()
41 void CPatchViewDlg::DoDataExchange(CDataExchange* pDX)
43 CDialog::DoDataExchange(pDX);
44 DDX_Control(pDX, IDC_PATCH, m_ctrlPatchView);
47 BEGIN_MESSAGE_MAP(CPatchViewDlg, CDialog)
48 ON_WM_SIZE()
49 ON_WM_MOVING()
50 ON_WM_CLOSE()
51 END_MESSAGE_MAP()
53 // CPatchViewDlg message handlers
55 BOOL CPatchViewDlg::OnInitDialog()
57 CDialog::OnInitDialog();
59 m_ctrlPatchView.Init(-1);
61 m_ctrlPatchView.SetUDiffStyle();
63 return TRUE; // return TRUE unless you set the focus to a control
64 // EXCEPTION: OCX Property Pages should return FALSE
67 void CPatchViewDlg::SetText(const CString& text)
69 m_ctrlPatchView.Call(SCI_SETREADONLY, FALSE);
70 m_ctrlPatchView.SetText(text);
71 m_ctrlPatchView.Call(SCI_SETREADONLY, TRUE);
72 if (!text.IsEmpty())
74 m_ctrlPatchView.Call(SCI_GOTOPOS, 0);
75 CRect rect;
76 m_ctrlPatchView.GetClientRect(rect);
77 m_ctrlPatchView.Call(SCI_SETSCROLLWIDTH, rect.Width() - 4);
81 void CPatchViewDlg::ClearView()
83 SetText(CString());
86 void CPatchViewDlg::OnSize(UINT nType, int cx, int cy)
88 CDialog::OnSize(nType, cx, cy);
90 if (this->IsWindowVisible())
92 CRect rect;
93 GetClientRect(rect);
94 GetDlgItem(IDC_PATCH)->MoveWindow(0, 0, cx, cy);
95 CRect rect2;
96 m_ctrlPatchView.GetClientRect(rect);
97 m_ctrlPatchView.Call(SCI_SETSCROLLWIDTH, rect.Width() - 4);
101 void CPatchViewDlg::OnMoving(UINT fwSide, LPRECT pRect)
103 #define STICKYSIZE 5
104 RECT parentRect;
105 m_ParentDlg->GetPatchViewParentWnd()->GetWindowRect(&parentRect);
106 if (abs(parentRect.right - pRect->left) < STICKYSIZE)
108 int width = pRect->right - pRect->left;
109 pRect->left = parentRect.right;
110 pRect->right = pRect->left + width;
112 CDialog::OnMoving(fwSide, pRect);
115 void CPatchViewDlg::OnClose()
117 CDialog::OnClose();
118 m_ParentDlg->TogglePatchView();