1 // TortoiseSVN - a Windows shell extension for easy version control
\r
3 // Copyright (C) 2003-2008 - Stefan Kueng
\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
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
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
20 #include "TortoiseProc.h"
\r
21 #include "MessageBox.h"
\r
22 #include "SVNProperties.h"
\r
23 #include "UnicodeUtils.h"
\r
24 #include "Propdlg.h"
\r
25 #include "Registry.h"
\r
28 IMPLEMENT_DYNAMIC(CPropDlg, CResizableStandAloneDialog)
\r
29 CPropDlg::CPropDlg(CWnd* pParent /*=NULL*/)
\r
30 : CResizableStandAloneDialog(CPropDlg::IDD, pParent)
\r
31 , m_rev(SVNRev::REV_WC)
\r
35 CPropDlg::~CPropDlg()
\r
39 void CPropDlg::DoDataExchange(CDataExchange* pDX)
\r
41 CResizableStandAloneDialog::DoDataExchange(pDX);
\r
42 DDX_Control(pDX, IDC_PROPERTYLIST, m_proplist);
\r
46 BEGIN_MESSAGE_MAP(CPropDlg, CResizableStandAloneDialog)
\r
50 BOOL CPropDlg::OnInitDialog()
\r
52 CResizableStandAloneDialog::OnInitDialog();
\r
54 m_proplist.SetExtendedStyle ( LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER );
\r
56 m_proplist.DeleteAllItems();
\r
57 int c = ((CHeaderCtrl*)(m_proplist.GetDlgItem(0)))->GetItemCount()-1;
\r
59 m_proplist.DeleteColumn(c--);
\r
61 temp.LoadString(IDS_PROPPROPERTY);
\r
62 m_proplist.InsertColumn(0, temp);
\r
63 temp.LoadString(IDS_PROPVALUE);
\r
64 m_proplist.InsertColumn(1, temp);
\r
65 m_proplist.SetRedraw(false);
\r
67 int maxcol = ((CHeaderCtrl*)(m_proplist.GetDlgItem(0)))->GetItemCount()-1;
\r
69 for (col = mincol; col <= maxcol; col++)
\r
71 m_proplist.SetColumnWidth(col,LVSCW_AUTOSIZE_USEHEADER);
\r
73 m_proplist.SetRedraw(false);
\r
75 DialogEnableWindow(IDOK, FALSE);
\r
76 if (AfxBeginThread(PropThreadEntry, this)==NULL)
\r
78 CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);
\r
81 AddAnchor(IDC_PROPERTYLIST, TOP_LEFT, BOTTOM_RIGHT);
\r
82 AddAnchor(IDOK, BOTTOM_CENTER);
\r
83 EnableSaveRestore(_T("PropDlg"));
\r
87 void CPropDlg::OnCancel()
\r
89 if (GetDlgItem(IDOK)->IsWindowEnabled())
\r
90 CResizableStandAloneDialog::OnCancel();
\r
93 void CPropDlg::OnOK()
\r
95 if (GetDlgItem(IDOK)->IsWindowEnabled())
\r
96 CResizableStandAloneDialog::OnOK();
\r
99 UINT CPropDlg::PropThreadEntry(LPVOID pVoid)
\r
101 return ((CPropDlg*)pVoid)->PropThread();
\r
104 UINT CPropDlg::PropThread()
\r
106 SVNProperties props(m_Path, m_rev, false);
\r
108 m_proplist.SetRedraw(false);
\r
110 for (int i=0; i<props.GetCount(); ++i)
\r
112 CString name = props.GetItemName(i).c_str();
\r
114 val = props.GetItemValue(i).c_str();
\r
119 nFound = val.FindOneOf(_T("\r\n"));
\r
120 m_proplist.InsertItem(row, name);
\r
122 m_proplist.SetItemText(row++, 1, val.Left(nFound));
\r
124 m_proplist.SetItemText(row++, 1, val);
\r
125 val = val.Mid(nFound);
\r
128 } while (!val.IsEmpty()&&(nFound>=0));
\r
131 int maxcol = ((CHeaderCtrl*)(m_proplist.GetDlgItem(0)))->GetItemCount()-1;
\r
133 for (col = mincol; col <= maxcol; col++)
\r
135 m_proplist.SetColumnWidth(col,LVSCW_AUTOSIZE_USEHEADER);
\r
138 m_proplist.SetRedraw(true);
\r
139 DialogEnableWindow(IDOK, TRUE);
\r
143 BOOL CPropDlg::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
\r
145 if ((GetDlgItem(IDOK)->IsWindowEnabled())||(pWnd != GetDlgItem(IDC_PROPERTYLIST)))
\r
147 HCURSOR hCur = LoadCursor(NULL, MAKEINTRESOURCE(IDC_ARROW));
\r
149 return CResizableStandAloneDialog::OnSetCursor(pWnd, nHitTest, message);
\r
151 HCURSOR hCur = LoadCursor(NULL, MAKEINTRESOURCE(IDC_WAIT));
\r