Perform a stable sort in order to preserve the order
[TortoiseGit.git] / src / TortoiseProc / PatchViewDlg.cpp
blob05ced42fbe9f3a8df404dbd96cd65974c9d3f80f
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);
63 m_ctrlPatchView.SetUDiffStyle();
65 return TRUE; // return TRUE unless you set the focus to a control
66 // EXCEPTION: OCX Property Pages should return FALSE
69 void CPatchViewDlg::SetText(const CString& text)
71 m_ctrlPatchView.Call(SCI_SETREADONLY, FALSE);
72 m_ctrlPatchView.SetText(text);
73 m_ctrlPatchView.Call(SCI_SETREADONLY, TRUE);
74 if (!text.IsEmpty())
76 m_ctrlPatchView.Call(SCI_GOTOPOS, 0);
77 CRect rect;
78 m_ctrlPatchView.GetClientRect(rect);
79 m_ctrlPatchView.Call(SCI_SETSCROLLWIDTH, rect.Width() - 4);
83 void CPatchViewDlg::ClearView()
85 SetText(CString());
88 void CPatchViewDlg::OnSize(UINT nType, int cx, int cy)
90 CDialog::OnSize(nType, cx, cy);
92 if (this->IsWindowVisible())
94 CRect rect;
95 GetClientRect(rect);
96 GetDlgItem(IDC_PATCH)->MoveWindow(0, 0, cx, cy);
97 CRect rect2;
98 m_ctrlPatchView.GetClientRect(rect);
99 m_ctrlPatchView.Call(SCI_SETSCROLLWIDTH, rect.Width() - 4);
103 void CPatchViewDlg::OnMoving(UINT fwSide, LPRECT pRect)
105 #define STICKYSIZE 5
106 RECT parentRect;
107 m_ParentDlg->GetPatchViewParentWnd()->GetWindowRect(&parentRect);
108 if (abs(parentRect.right - pRect->left) < STICKYSIZE)
110 int width = pRect->right - pRect->left;
111 pRect->left = parentRect.right;
112 pRect->right = pRect->left + width;
114 CDialog::OnMoving(fwSide, pRect);
117 void CPatchViewDlg::OnClose()
119 CDialog::OnClose();
120 m_ParentDlg->TogglePatchView();