OSDN Git Service

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