Fix broken build by moving implementations to cpp files
[TortoiseGit.git] / src / TortoiseProc / ProgressDlg.h
blob369d634c141503310297e7476a27a5d8ba10fc3e
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2014 - TortoiseGit
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 "StandAloneDlg.h"
22 #include "Git.h"
23 #include "MenuButton.h"
24 #include <functional>
26 #define MSG_PROGRESSDLG_UPDATE_UI (WM_USER+121)
28 // CProgressDlg dialog
29 #define MSG_PROGRESSDLG_START 0
30 #define MSG_PROGRESSDLG_RUN 50
31 #define MSG_PROGRESSDLG_END 110
32 #define MSG_PROGRESSDLG_FAILED 111
34 typedef enum {
35 AUTOCLOSE_NO,
36 AUTOCLOSE_IF_NO_OPTIONS,
37 AUTOCLOSE_IF_NO_ERRORS,
38 } GitProgressAutoClose;
40 class CProgressDlg : public CResizableStandAloneDialog
42 DECLARE_DYNAMIC(CProgressDlg)
43 public:
44 typedef std::function<void()> PostCmdCallback;
46 CProgressDlg(CWnd* pParent = NULL); // standard constructor
47 virtual ~CProgressDlg();
49 private:
50 virtual BOOL OnInitDialog();
52 // Dialog Data
53 enum { IDD = IDD_GITPROGRESS };
55 public:
56 CString m_GitCmd;
57 CStringArray m_PostCmdList;
58 CStringArray m_PostFailCmdList;
59 PostCmdCallback m_PostCmdCallback;
60 std::vector<CString> m_GitCmdList;
61 STRING_VECTOR m_GitDirList;
62 CString m_PreText; // optional text to show in log window before running command
63 bool m_bShowCommand; // whether to display the command in the log window (default true)
64 CString m_LogFile;
65 bool m_bBufferAll; // Buffer All to improve speed when there are many file add at commit
66 GitProgressAutoClose m_AutoClose;
67 CGit * m_Git;
69 DWORD m_GitStatus;
70 CString m_LogText;
72 CString GetLogText() const { CString text; m_Log.GetWindowText(text); return text; }
74 private:
75 void WriteLog() const;
76 CMenuButton m_ctrlPostCmd;
78 CProgressCtrl m_Progress;
80 CRichEditCtrl m_Log;
81 CAnimateCtrl m_Animate;
82 CStatic m_CurrentWork;
83 CWinThread* m_pThread;
85 bool m_bAbort;
86 bool m_bDone;
87 DWORD m_startTick;
89 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
90 static UINT ProgressThreadEntry(LPVOID pVoid);
91 UINT ProgressThread();
93 CStringA m_LogTextA;
95 void ParserCmdOutput(char ch);
96 void RemoveLastLine(CString &str);
98 LRESULT OnProgressUpdateUI(WPARAM wParam,LPARAM lParam);
100 afx_msg LRESULT OnTaskbarBtnCreated(WPARAM wParam, LPARAM lParam);
101 CComPtr<ITaskbarList3> m_pTaskbarList;
103 void OnCancel();
104 afx_msg void OnClose();
106 CGitByteArray m_Databuf;
107 virtual CString Convert2UnionCode(char *buff, int size=-1)
109 CString str;
110 g_Git.StringAppend(&str, (BYTE*)buff, CP_UTF8, size);
111 return str;
114 int m_BufStart;
116 DECLARE_MESSAGE_MAP()
118 //Share with Sync Dailog
119 static int FindPercentage(CString &log);
121 static void ClearESC(CString &str);
123 public:
124 static void ParserCmdOutput(CRichEditCtrl &log,CProgressCtrl &progressctrl,HWND m_hWnd,CComPtr<ITaskbarList3> m_pTaskbarList,
125 CStringA &oneline, char ch,CWnd *CurrentWork=NULL);
128 *@param dirlist if empty, the current directory of param git is used; otherwise each entry in param cmdlist uses the corresponding entry in param dirlist
130 static UINT RunCmdList(CWnd *pWnd, STRING_VECTOR &cmdlist, STRING_VECTOR &dirlist, bool bShowCommand, CString *pfilename, bool *bAbort, CGitByteArray *pdata, CGit *git = &g_Git);
132 static void KillProcessTree(DWORD dwProcessId, unsigned int depth = 0);
134 static void InsertColorText(CRichEditCtrl &edit,CString text,COLORREF rgb);
136 private:
137 afx_msg void OnBnClickedOk();
138 afx_msg void OnBnClickedButton1();
140 virtual BOOL PreTranslateMessage(MSG* pMsg);
143 class CCommitProgressDlg:public CProgressDlg
145 public:
146 CCommitProgressDlg(CWnd* pParent = NULL):CProgressDlg(pParent)
150 virtual CString Convert2UnionCode(char *buff, int size=-1);