BrowseRefs: Context menu enhancements
[TortoiseGit.git] / src / TortoiseProc / MergeWizard.cpp
blobc133dd9a89558386e698ff0fad1c31616e503477
1 // TortoiseSVN - a Windows shell extension for easy version control
3 // Copyright (C) 2007-2008 - TortoiseSVN
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 #include "stdafx.h"
20 #include "TortoiseProc.h"
21 #include "MergeWizard.h"
24 // CMergeWizard
26 IMPLEMENT_DYNAMIC(CMergeWizard, CPropertySheet)
28 CMergeWizard::CMergeWizard(UINT nIDCaption, CWnd* pParentWnd, UINT iSelectPage)
29 :CPropertySheet(nIDCaption, pParentWnd, iSelectPage)
30 , bReverseMerge(FALSE)
31 , nRevRangeMerge(MERGEWIZARD_REVRANGE)
32 , m_bIgnoreAncestry(FALSE)
33 , m_bIgnoreEOL(FALSE)
34 , m_depth(svn_depth_unknown)
35 , m_bRecordOnly(FALSE)
36 , m_FirstPageActivation(true)
38 SetWizardMode();
39 AddPage(&page1);
40 AddPage(&tree);
41 AddPage(&revrange);
42 AddPage(&options);
43 AddPage(&reintegrate);
45 m_psh.dwFlags |= PSH_WIZARD97|PSP_HASHELP|PSH_HEADER;
46 m_psh.pszbmHeader = MAKEINTRESOURCE(IDB_MERGEWIZARDTITLE);
48 m_psh.hInstance = AfxGetResourceHandle();
49 m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
53 CMergeWizard::~CMergeWizard()
58 BEGIN_MESSAGE_MAP(CMergeWizard, CPropertySheet)
59 ON_WM_PAINT()
60 ON_WM_QUERYDRAGICON()
61 END_MESSAGE_MAP()
64 // CMergeWizard message handlers
66 BOOL CMergeWizard::OnInitDialog()
68 BOOL bResult = CPropertySheet::OnInitDialog();
70 SetIcon(m_hIcon, TRUE); // Set big icon
71 SetIcon(m_hIcon, FALSE); // Set small icon
73 SVN svn;
74 url = svn.GetURLFromPath(wcPath);
75 sUUID = svn.GetUUIDFromPath(wcPath);
77 return bResult;
81 void CMergeWizard::SaveMode()
83 CRegDWORD regMergeWizardMode(_T("Software\\TortoiseGit\\MergeWizardMode"), 0);
84 if (DWORD(regMergeWizardMode))
86 switch (nRevRangeMerge)
88 case IDD_MERGEWIZARD_REVRANGE:
89 regMergeWizardMode = 2;
90 break;
91 case IDD_MERGEWIZARD_REINTEGRATE:
92 regMergeWizardMode = 3;
93 break;
94 case IDD_MERGEWIZARD_TREE:
95 regMergeWizardMode = 1;
96 break;
97 default:
98 regMergeWizardMode = 0;
99 break;
104 LRESULT CMergeWizard::GetSecondPage()
106 switch (nRevRangeMerge)
108 case MERGEWIZARD_REVRANGE:
109 return IDD_MERGEWIZARD_REVRANGE;
110 case MERGEWIZARD_TREE:
111 return IDD_MERGEWIZARD_TREE;
112 case MERGEWIZARD_REINTEGRATE:
113 return IDD_MERGEWIZARD_REINTEGRATE;
115 return IDD_MERGEWIZARD_REVRANGE;
118 void CMergeWizard::OnPaint()
120 if (IsIconic())
122 CPaintDC dc(this); // device context for painting
124 SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
126 // Center icon in client rectangle
127 int cxIcon = GetSystemMetrics(SM_CXICON);
128 int cyIcon = GetSystemMetrics(SM_CYICON);
129 CRect rect;
130 GetClientRect(&rect);
131 int x = (rect.Width() - cxIcon + 1) / 2;
132 int y = (rect.Height() - cyIcon + 1) / 2;
134 // Draw the icon
135 dc.DrawIcon(x, y, m_hIcon);
137 else
139 CPropertySheet::OnPaint();
143 HCURSOR CMergeWizard::OnQueryDragIcon()
145 return static_cast<HCURSOR>(m_hIcon);