OSDN Git Service

Fix last line problem
[tortoisegit/TortoiseGitJp.git] / src / TortoiseProc / MergeWizardBasePage.h
1 // TortoiseSVN - a Windows shell extension for easy version control\r
2 \r
3 // Copyright (C) 2007-2008 - TortoiseSVN\r
4 \r
5 // This program is free software; you can redistribute it and/or\r
6 // modify it under the terms of the GNU General Public License\r
7 // as published by the Free Software Foundation; either version 2\r
8 // of the License, or (at your option) any later version.\r
9 \r
10 // This program is distributed in the hope that it will be useful,\r
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of\r
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
13 // GNU General Public License for more details.\r
14 \r
15 // You should have received a copy of the GNU General Public License\r
16 // along with this program; if not, write to the Free Software Foundation,\r
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\r
18 //\r
19 #pragma once\r
20 \r
21 \r
22 /**\r
23  * base class for the merge wizard property pages\r
24  */\r
25 class CMergeWizardBasePage : public CPropertyPage\r
26 {\r
27 public:\r
28         CMergeWizardBasePage() : CPropertyPage() {;}\r
29         explicit CMergeWizardBasePage(UINT nIDTemplate, UINT nIDCaption = 0, DWORD dwSize = sizeof(PROPSHEETPAGE)) \r
30                 : CPropertyPage(nIDTemplate, nIDCaption, dwSize) {;}\r
31         explicit CMergeWizardBasePage(LPCTSTR lpszTemplateName, UINT nIDCaption = 0, DWORD dwSize = sizeof(PROPSHEETPAGE))\r
32                 : CPropertyPage(lpszTemplateName, nIDCaption, dwSize) {;}\r
33 \r
34         virtual ~CMergeWizardBasePage() {;}\r
35 \r
36 \r
37 \r
38 protected:\r
39         virtual void                    SetButtonTexts()\r
40         {\r
41                 CPropertySheet* psheet = (CPropertySheet*) GetParent();\r
42                 if (psheet)\r
43                 {\r
44                         psheet->GetDlgItem(ID_WIZFINISH)->SetWindowText(CString(MAKEINTRESOURCE(IDS_MERGE_MERGE)));\r
45                         psheet->GetDlgItem(ID_WIZBACK)->SetWindowText(CString(MAKEINTRESOURCE(IDS_PROPPAGE_BACK)));\r
46                         psheet->GetDlgItem(ID_WIZNEXT)->SetWindowText(CString(MAKEINTRESOURCE(IDS_PROPPAGE_NEXT)));\r
47                         psheet->GetDlgItem(IDHELP)->SetWindowText(CString(MAKEINTRESOURCE(IDS_PROPPAGE_HELP)));\r
48                         psheet->GetDlgItem(IDCANCEL)->SetWindowText(CString(MAKEINTRESOURCE(IDS_PROPPAGE_CANCEL)));\r
49                 }\r
50         }\r
51 \r
52         void AdjustControlSize(UINT nID)\r
53         {\r
54                 CWnd * pwndDlgItem = GetDlgItem(nID);\r
55                 // adjust the size of the control to fit its content\r
56                 CString sControlText;\r
57                 pwndDlgItem->GetWindowText(sControlText);\r
58                 // next step: find the rectangle the control text needs to\r
59                 // be displayed\r
60 \r
61                 CDC * pDC = pwndDlgItem->GetWindowDC();\r
62                 RECT controlrect;\r
63                 RECT controlrectorig;\r
64                 pwndDlgItem->GetWindowRect(&controlrect);\r
65                 ::MapWindowPoints(NULL, GetSafeHwnd(), (LPPOINT)&controlrect, 2);\r
66                 controlrectorig = controlrect;\r
67                 if (pDC)\r
68                 {\r
69                         CFont * font = pwndDlgItem->GetFont();\r
70                         CFont * pOldFont = pDC->SelectObject(font);\r
71                         if (pDC->DrawText(sControlText, -1, &controlrect, DT_WORDBREAK | DT_EDITCONTROL | DT_EXPANDTABS | DT_LEFT | DT_CALCRECT))\r
72                         {\r
73                                 // now we have the rectangle the control really needs\r
74                                 if ((controlrectorig.right - controlrectorig.left) > (controlrect.right - controlrect.left))\r
75                                 {\r
76                                         // we're dealing with radio buttons and check boxes,\r
77                                         // which means we have to add a little space for the checkbox\r
78                                         controlrectorig.right = controlrectorig.left + (controlrect.right - controlrect.left) + 20;\r
79                                         pwndDlgItem->MoveWindow(&controlrectorig);\r
80                                 }\r
81                         }\r
82                         pDC->SelectObject(pOldFont);\r
83                         ReleaseDC(pDC);\r
84                 }\r
85         }\r
86 };\r