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