Merge branch 'restructure-tree'
[TortoiseGit.git] / src / TortoiseProc / RepositoryBar.h
blob5984023c38d8974d5180959870d6460089aaf569
1 // TortoiseSVN - a Windows shell extension for easy version control
3 // Copyright (C) 2003-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 #pragma once
21 #include "GitRev.h"
22 #include "HistoryCombo.h"
23 #include "Tooltip.h"
24 #include "XPImageButton.h"
26 class CRepositoryTree;
28 /**
29 * \ingroup TortoiseProc
30 * Interface definition
32 class IRepo
34 public:
35 virtual bool ChangeToUrl(CString& url, GitRev& rev, bool bAlreadyChecked) = 0;
36 virtual CString GetRepoRoot() = 0;
39 /**
40 * \ingroup TortoiseProc
41 * Provides a CReBarCtrl which can be used as a "control center" for the
42 * repository browser. To associate the repository bar with any repository
43 * tree control, call AssocTree() once after both objects are created. As
44 * long as they are associated, the bar and the tree form a "team" of
45 * controls that work together.
47 class CRepositoryBar : public CReBarCtrl
49 DECLARE_DYNAMIC(CRepositoryBar)
51 public:
52 CRepositoryBar();
53 virtual ~CRepositoryBar();
55 public:
56 /**
57 * Creates the repository bar. Set \a in_dialog to TRUE when the bar
58 * is placed inside of a dialog. Otherwise it is assumed that the
59 * bar is placed in a frame window.
61 bool Create(CWnd* parent, UINT id, bool in_dialog = true);
63 /**
64 * Show the given \a svn_url in the URL combo and the revision button.
66 void ShowUrl(const CString& url, GitRev rev);
68 /**
69 * Show the given \a svn_url in the URL combo and the revision button,
70 * and select it in the associated repository tree. If no \a svn_url
71 * is given, the current values are used (which effectively refreshes
72 * the tree).
74 void GotoUrl(const CString& url = CString(), GitRev rev = GitRev(), bool bAlreadyChecked = false);
76 /**
77 * Returns the current URL.
79 CString GetCurrentUrl() const;
81 /**
82 * Returns the current revision
84 GitRev GetCurrentRev() const;
86 /**
87 * Saves the URL history of the HistoryCombo.
89 void SaveHistory();
91 /**
92 * Set the revision
94 void SetRevision(GitRev rev);
96 void SetFocusToURL();
98 void SetIRepo(IRepo * pRepo) {m_pRepo = pRepo;}
100 void SetHeadRevision(const GitRev& rev) {m_headRev = rev;}
101 afx_msg void OnGoUp();
102 protected:
103 virtual BOOL PreTranslateMessage(MSG* pMsg);
104 afx_msg void OnCbnSelChange();
105 afx_msg void OnBnClicked();
106 afx_msg void OnDestroy();
108 DECLARE_MESSAGE_MAP()
110 private:
111 CString m_url;
112 GitRev m_rev;
114 IRepo * m_pRepo;
116 class CRepositoryCombo : public CHistoryCombo
118 CRepositoryBar *m_bar;
119 public:
120 CRepositoryCombo(CRepositoryBar *bar) : m_bar(bar) {}
121 virtual bool OnReturnKeyPressed();
122 } m_cbxUrl;
124 CButton m_btnRevision;
125 CXPImageButton m_btnUp;
127 GitRev m_headRev;
128 CToolTips m_tooltips;
129 HICON m_UpIcon;
134 * \ingroup TortoiseProc
135 * Implements a visual container for a CRepositoryBar which may be added to a
136 * dialog. A CRepositoryBarCnr is not needed if the CRepositoryBar is attached
137 * to a frame window.
139 class CRepositoryBarCnr : public CStatic
141 DECLARE_DYNAMIC(CRepositoryBarCnr)
143 public:
144 CRepositoryBarCnr(CRepositoryBar *repository_bar);
145 ~CRepositoryBarCnr();
147 // Generated message map functions
148 protected:
149 afx_msg BOOL OnEraseBkgnd(CDC* pDC);
150 afx_msg void OnSize(UINT nType, int cx, int cy);
151 afx_msg UINT OnGetDlgCode();
152 afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
154 virtual void DrawItem(LPDRAWITEMSTRUCT);
156 DECLARE_MESSAGE_MAP()
158 private:
159 CRepositoryBar *m_pbarRepository;