Add support for "project" config level
[TortoiseGit.git] / src / TortoiseProc / ProgressDlg.h
blob23cdb7727f425bf13776e378237afa603954b8e0
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2012 - 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"
25 #define MSG_PROGRESSDLG_UPDATE_UI (WM_USER+121)
27 // CProgressDlg dialog
28 #define MSG_PROGRESSDLG_START 0
29 #define MSG_PROGRESSDLG_RUN 50
30 #define MSG_PROGRESSDLG_END 110
31 #define MSG_PROGRESSDLG_FAILED 111
33 class CProgressDlg : public CResizableStandAloneDialog
35 DECLARE_DYNAMIC(CProgressDlg)
36 public:
37 typedef void (*PostCmdCallback)(CProgressDlg *dlg, void *caller, int result);
39 CProgressDlg(CWnd* pParent = NULL); // standard constructor
40 virtual ~CProgressDlg();
42 private:
43 virtual BOOL OnInitDialog();
45 // Dialog Data
46 enum { IDD = IDD_GITPROGRESS };
48 public:
49 CString m_Title;
50 CString m_GitCmd;
51 CStringArray m_PostCmdList;
52 CStringArray m_PostFailCmdList;
53 PostCmdCallback m_PostCmdCallback;
54 void * m_caller;
55 std::vector<CString> m_GitCmdList;
56 CString m_PreText; // optional text to show in log window before running command
57 bool m_bShowCommand; // whether to display the command in the log window (default true)
58 CString m_LogFile;
59 bool m_bBufferAll; // Buffer All to improve speed when there are many file add at commit
60 bool m_bAutoCloseOnSuccess;
62 DWORD m_GitStatus;
63 CString m_LogText;
65 CString GetLogText() { CString text; m_Log.GetWindowText(text); return text; }
67 private:
68 CMenuButton m_ctrlPostCmd;
70 CProgressCtrl m_Progress;
72 CRichEditCtrl m_Log;
73 CAnimateCtrl m_Animate;
74 CStatic m_CurrentWork;
75 CWinThread* m_pThread;
76 volatile LONG m_bThreadRunning;
78 bool m_bAbort;
79 bool m_bDone;
80 bool m_bAltAbortPress;
81 DWORD m_startTick;
83 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
84 static UINT ProgressThreadEntry(LPVOID pVoid);
85 UINT ProgressThread();
87 CStringA m_LogTextA;
89 void ParserCmdOutput(char ch);
90 void RemoveLastLine(CString &str);
92 LRESULT OnProgressUpdateUI(WPARAM wParam,LPARAM lParam);
94 afx_msg LRESULT OnTaskbarBtnCreated(WPARAM wParam, LPARAM lParam);
95 CComPtr<ITaskbarList3> m_pTaskbarList;
97 void OnCancel();
98 afx_msg void OnClose();
100 CGitByteArray m_Databuf;
101 virtual CString Convert2UnionCode(char *buff, int size=-1)
103 CString str;
104 g_Git.StringAppend(&str, (BYTE*)buff, CP_UTF8, size);
105 return str;
108 int m_BufStart;
110 DECLARE_MESSAGE_MAP()
112 //Share with Sync Dailog
113 static int FindPercentage(CString &log);
115 static void ClearESC(CString &str);
117 public:
118 static void ParserCmdOutput(CRichEditCtrl &log,CProgressCtrl &progressctrl,HWND m_hWnd,CComPtr<ITaskbarList3> m_pTaskbarList,
119 CStringA &oneline, char ch,CWnd *CurrentWork=NULL);
121 static UINT RunCmdList(CWnd *pWnd,std::vector<CString> &cmdlist,bool bShowCommand,CString *pfilename,bool *bAbort,CGitByteArray *pdata=NULL);
123 static void KillProcessTree(DWORD dwProcessId, unsigned int depth = 0);
125 static void InsertColorText(CRichEditCtrl &edit,CString text,COLORREF rgb);
127 private:
128 afx_msg void OnBnClickedOk();
129 afx_msg void OnBnClickedButton1();
131 virtual BOOL PreTranslateMessage(MSG* pMsg);
134 class CCommitProgressDlg:public CProgressDlg
136 public:
137 CCommitProgressDlg(CWnd* pParent = NULL):CProgressDlg(pParent)
141 virtual CString Convert2UnionCode(char *buff, int size=-1);