Add Command Line Argument to select blame version.
[TortoiseGit.git] / src / TortoiseGitBlame / TortoiseGitBlame.cpp
blob79adf9802c91075906aea4a0d40b1b90858921ef
2 // TortoiseGitBlame.cpp : Defines the class behaviors for the application.
3 //
5 #include "stdafx.h"
6 #include "afxwinappex.h"
7 #include "TortoiseGitBlame.h"
8 #include "MainFrm.h"
10 #include "TortoiseGitBlameDoc.h"
11 #include "TortoiseGitBlameView.h"
12 #include "CmdLineParser.h"
14 #ifdef _DEBUG
15 #define new DEBUG_NEW
16 #endif
19 // CTortoiseGitBlameApp
21 BEGIN_MESSAGE_MAP(CTortoiseGitBlameApp, CWinAppEx)
22 ON_COMMAND(ID_APP_ABOUT, &CTortoiseGitBlameApp::OnAppAbout)
23 // Standard file based document commands
24 ON_COMMAND(ID_FILE_NEW, &CWinAppEx::OnFileNew)
25 ON_COMMAND(ID_FILE_OPEN, &CWinAppEx::OnFileOpen)
26 // Standard print setup command
27 ON_COMMAND(ID_FILE_PRINT_SETUP, &CWinAppEx::OnFilePrintSetup)
28 END_MESSAGE_MAP()
31 // CTortoiseGitBlameApp construction
33 CTortoiseGitBlameApp::CTortoiseGitBlameApp()
35 EnableHtmlHelp();
38 m_bHiColorIcons = TRUE;
40 // TODO: add construction code here,
41 // Place all significant initialization in InitInstance
44 // The one and only CTortoiseGitBlameApp object
46 CTortoiseGitBlameApp theApp;
49 // CTortoiseGitBlameApp initialization
51 BOOL CTortoiseGitBlameApp::InitInstance()
53 // InitCommonControlsEx() is required on Windows XP if an application
54 // manifest specifies use of ComCtl32.dll version 6 or later to enable
55 // visual styles. Otherwise, any window creation will fail.
56 INITCOMMONCONTROLSEX InitCtrls;
57 InitCtrls.dwSize = sizeof(InitCtrls);
58 // Set this to include all the common control classes you want to use
59 // in your application.
60 InitCtrls.dwICC = ICC_WIN95_CLASSES;
61 InitCommonControlsEx(&InitCtrls);
63 CWinAppEx::InitInstance();
65 // Initialize OLE libraries
66 if (!AfxOleInit())
68 AfxMessageBox(IDP_OLE_INIT_FAILED);
69 return FALSE;
71 AfxEnableControlContainer();
72 // Standard initialization
73 // If you are not using these features and wish to reduce the size
74 // of your final executable, you should remove from the following
75 // the specific initialization routines you do not need
76 // Change the registry key under which our settings are stored
77 // TODO: You should modify this string to be something appropriate
78 // such as the name of your company or organization
79 SetRegistryKey(_T("Local AppWizard-Generated Applications"));
80 LoadStdProfileSettings(4); // Load standard INI file options (including MRU)
82 InitContextMenuManager();
84 InitKeyboardManager();
86 InitTooltipManager();
87 CMFCToolTipInfo ttParams;
88 ttParams.m_bVislManagerTheme = TRUE;
89 theApp.GetTooltipManager()->SetTooltipParams(AFX_TOOLTIP_TYPE_ALL,
90 RUNTIME_CLASS(CMFCToolTipCtrl), &ttParams);
92 // Register the application's document templates. Document templates
93 // serve as the connection between documents, frame windows and views
94 CSingleDocTemplate* pDocTemplate;
95 pDocTemplate = new CSingleDocTemplate(
96 IDR_TORTOISE_GIT_BLAME_MAINFRAME,
97 RUNTIME_CLASS(CTortoiseGitBlameDoc),
98 RUNTIME_CLASS(CMainFrame), // main SDI frame window
99 RUNTIME_CLASS(CTortoiseGitBlameView));
100 if (!pDocTemplate)
101 return FALSE;
102 AddDocTemplate(pDocTemplate);
106 // Parse command line for standard shell commands, DDE, file open
107 CCommandLineInfo cmdInfo;
108 ParseCommandLine(cmdInfo);
110 // Dispatch commands specified on the command line. Will return FALSE if
111 // app was launched with /RegServer, /Register, /Unregserver or /Unregister.
112 if (!ProcessShellCommand(cmdInfo))
113 return FALSE;
115 // The one and only window has been initialized, so show and update it
116 m_pMainWnd->ShowWindow(SW_SHOW);
117 m_pMainWnd->UpdateWindow();
118 // call DragAcceptFiles only if there's a suffix
119 // In an SDI app, this should occur after ProcessShellCommand
120 return TRUE;
125 // CAboutDlg dialog used for App About
127 class CAboutDlg : public CDialog
129 public:
130 CAboutDlg();
132 // Dialog Data
133 enum { IDD = IDD_ABOUTBOX };
135 protected:
136 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
138 // Implementation
139 protected:
140 DECLARE_MESSAGE_MAP()
143 CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
147 void CAboutDlg::DoDataExchange(CDataExchange* pDX)
149 CDialog::DoDataExchange(pDX);
152 BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
153 END_MESSAGE_MAP()
155 // App command to run the dialog
156 void CTortoiseGitBlameApp::OnAppAbout()
158 CAboutDlg aboutDlg;
159 aboutDlg.DoModal();
162 // CTortoiseGitBlameApp customization load/save methods
164 void CTortoiseGitBlameApp::PreLoadState()
166 BOOL bNameValid;
167 CString strName;
168 bNameValid = strName.LoadString(IDS_EDIT_MENU);
169 ASSERT(bNameValid);
170 GetContextMenuManager()->AddMenu(strName, IDR_POPUP_EDIT);
173 void CTortoiseGitBlameApp::LoadCustomState()
177 void CTortoiseGitBlameApp::SaveCustomState()
181 // CTortoiseGitBlameApp message handlers