Add Daemon Shell Context Menu
[TortoiseGit.git] / src / TortoiseProc / RepositoryBrowser.h
blob13f31a8c6bb06fb375641089925b2c52f38f816b
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2009-2012 - TortoiseGit
4 // Copyright (C) 2012 - Sven Strickroth <email@cs-ware.de>
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software Foundation,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #pragma once
22 #include <map>
23 #include "StandAloneDlg.h"
25 #define REPOBROWSER_CTRL_MIN_WIDTH 20
27 class CShadowFilesTree;
29 typedef std::map<CString, CShadowFilesTree> TShadowFilesTreeMap;
31 class CShadowFilesTree
33 public:
34 CShadowFilesTree()
35 : m_hTree(NULL)
36 , m_pParent(NULL)
37 , m_bFolder(false)
38 , m_iSize(0)
41 CString m_sName;
42 size_t m_iSize;
43 bool m_bFolder;
45 HTREEITEM m_hTree;
47 TShadowFilesTreeMap m_ShadowTree;
48 CShadowFilesTree* m_pParent;
50 CString GetFullName() const
52 if (m_pParent == NULL)
53 return m_sName;
55 CString parentPath = m_pParent->GetFullName();
56 if (parentPath.IsEmpty())
57 return m_sName;
58 else
59 return m_pParent->GetFullName() + _T("/") + m_sName;
62 typedef std::vector<CShadowFilesTree *> TShadowFilesTreeList;
64 class CRepositoryBrowser : public CResizableStandAloneDialog
66 DECLARE_DYNAMIC(CRepositoryBrowser)
68 public:
69 CRepositoryBrowser(CString rev, CWnd* pParent = NULL); // standard constructor
70 virtual ~CRepositoryBrowser();
72 // Dialog Data
73 enum { IDD = IDD_REPOSITORY_BROWSER };
75 static bool s_bSortLogical;
77 enum eCmd
79 eCmd_Open = WM_APP,
80 eCmd_OpenWith,
81 eCmd_OpenWithAlternativeEditor,
82 eCmd_ViewLog,
83 eCmd_Blame,
84 eCmd_CompareWC,
85 eCmd_Revert,
86 eCmd_SaveAs,
87 eCmd_CopyPath,
90 enum eCol
92 eCol_Name,
93 eCol_Extension,
94 eCol_FileSize,
97 enum eOpenType
99 ALTERNATIVEEDITOR,
100 OPEN,
101 OPEN_WITH,
104 enum eSelectionType
106 ONLY_FILES,
107 ONLY_FOLDERS,
108 MIXED,
111 private:
112 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
114 DECLARE_MESSAGE_MAP()
116 afx_msg void OnOK();
117 afx_msg void OnCancel();
118 virtual BOOL OnInitDialog();
120 CTreeCtrl m_RepoTree;
121 CListCtrl m_RepoList;
123 afx_msg void OnLvnColumnclickRepoList(NMHDR *pNMHDR, LRESULT *pResult);
124 int m_currSortCol;
125 bool m_currSortDesc;
127 CShadowFilesTree m_TreeRoot;
128 int ReadTreeRecursive(git_repository &repo, git_tree * tree, CShadowFilesTree * treeroot);
129 int ReadTree(CShadowFilesTree * treeroot);
130 int m_nIconFolder;
131 int m_nOpenIconFolder;
133 bool m_bHasWC;
135 void Refresh();
136 CString m_sRevision;
137 void FillListCtrlForTreeNode(HTREEITEM treeNode);
138 void FillListCtrlForShadowTree(CShadowFilesTree* pTree);
139 afx_msg void OnTvnSelchangedRepoTree(NMHDR *pNMHDR, LRESULT *pResult);
141 afx_msg void OnNMDblclk_RepoList(NMHDR *pNMHDR, LRESULT *pResult);
142 afx_msg void OnContextMenu(CWnd* pWndFrom, CPoint point);
143 void OnContextMenu_RepoList(CPoint point);
144 void OnContextMenu_RepoTree(CPoint point);
145 void ShowContextMenu(CPoint point, TShadowFilesTreeList &selectedLeafs, eSelectionType selType);
147 void FileSaveAs(const CString path);
148 void OpenFile(const CString path, eOpenType mode);
149 bool RevertItemToVersion(const CString &path);
151 afx_msg void OnBnClickedButtonRevision();
153 virtual BOOL PreTranslateMessage(MSG* pMsg);
155 /// resizes the control so that the divider is at position 'point'
156 void HandleDividerMove(CPoint point, bool bDraw);
157 bool bDragMode;
158 void SaveDividerPosition();
159 int oldy, oldx;
160 /// draws the bar when the tree and list control are resized
161 void DrawXorBar(CDC * pDC, int x1, int y1, int width, int height);
162 afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
163 afx_msg void OnMouseMove(UINT nFlags, CPoint point);
164 afx_msg void OnCaptureChanged(CWnd *pWnd);
165 afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
166 afx_msg void OnLButtonUp(UINT nFlags, CPoint point);