source: dev/trunk/ab5.0/abdev/abdev/src/ProjectManager/ProjectManager.cpp@ 620

Last change on this file since 620 was 620, checked in by dai_9181, 16 years ago

Projectクラスをリファクタリング中。

File size: 11.8 KB
Line 
1#include "stdafx.h"
2
3using namespace ActiveBasic::IDE;
4
5void OpenWorkfile( const std::string &path );
6
7void Project::Open( char *path )
8{
9 extern HANDLE hHeap;
10 int i,i2;
11 char *buffer,temporary[MAX_PATH],temp2[MAX_PATH];
12
13 //既にプロジェクトが開かれている場合は閉じる
14 if( this->IsOpened() ){
15 if(!this->Close()) return;
16 }
17 //memset(&projectInfo,0,sizeof(PROJECTINFO));
18
19 //プロジェクトの作業ディレクトリを取得
20 _splitpath(path,temporary,temp2,0,0);
21 lstrcat( temporary, temp2 );
22 this->workDir = Jenga::Common::Directory( temporary );
23
24 //ファイルを開く、保存の初期ディレクトリをセット
25 lstrcpy(pobj_nv->DefSaveDir,this->GetWorkDir().GetPath().c_str());
26
27
28 //////////////////////////////////////////
29 // リソースデータ用領域を確保
30 this->res.pCursorResInfo=(RESITEMINFO *)HeapAlloc(hHeap,0,1);
31 this->res.NumberOfCursorRes=0;
32 this->res.pBitmapResInfo=(RESITEMINFO *)HeapAlloc(hHeap,0,1);
33 this->res.NumberOfBitmapRes=0;
34 this->res.pIconResInfo=(RESITEMINFO *)HeapAlloc(hHeap,0,1);
35 this->res.NumberOfIconRes=0;
36
37
38 //////////////////////////////////////////
39 //プロジェクトファイル(*.pj)をオープン
40 buffer=ReadBuffer(path);
41 if(!buffer) return;
42
43 //解析
44 this->pobj_DBFileInfo=new CDBFileInfo();
45 bool isUseWindow = false;
46 for(i=0;;i++){
47 if(buffer[i]=='\0') break;
48 if(buffer[i]=='\r'&&buffer[i+1]=='\n'&&buffer[i+2]=='#'){
49 for(i+=3,i2=0;;i++,i2++){
50 if(!IsVariableChar(buffer[i])){
51 temporary[i2]=0;
52 break;
53 }
54 temporary[i2]=buffer[i];
55 }
56 if(lstrcmpi(temporary,"VERSION")==0&&buffer[i]=='='){
57 for(i++,i2=0;;i++,i2++){
58 if((buffer[i]=='\r'&&buffer[i+1]=='\n')||buffer[i]=='\0'){
59 temporary[i2]=0;
60 if(buffer[i]=='\r'&&buffer[i+1]=='\n') i-=2;
61 break;
62 }
63 temporary[i2]=buffer[i];
64 }
65 this->dwVersion=GetValue(temporary);
66 }
67 else if(lstrcmpi(temporary,"MODULETYPE")==0&&buffer[i]=='='){
68 for(i++,i2=0;;i++,i2++){
69 if((buffer[i]=='\r'&&buffer[i+1]=='\n')||buffer[i]=='\0'){
70 temporary[i2]=0;
71 if(buffer[i]=='\r'&&buffer[i+1]=='\n') i-=2;
72 break;
73 }
74 temporary[i2]=buffer[i];
75 }
76 this->moduleType = (ActiveBasic::Common::TargetModuleType::EnumType)atoi(temporary);
77 }
78 else if(lstrcmpi(temporary,"NAME")==0&&buffer[i]=='='){
79 for(i++,i2=0;;i++,i2++){
80 if((buffer[i]=='\r'&&buffer[i+1]=='\n')||buffer[i]=='\0'){
81 temporary[i2]=0;
82 break;
83 }
84 temporary[i2]=buffer[i];
85 }
86 this->name = temporary;
87 }
88 else if(lstrcmpi(temporary,"PLATFORM")==0&&buffer[i]=='='){
89 for(i++,i2=0;;i++,i2++){
90 if((buffer[i]=='\r'&&buffer[i+1]=='\n')||buffer[i]=='\0'){
91 temporary[i2]=0;
92 if(buffer[i]=='\r'&&buffer[i+1]=='\n') i-=2;
93 break;
94 }
95 temporary[i2]=buffer[i];
96 }
97 i2=atoi(temporary);
98 extern HWND hSelectCompilerCombo;
99 if(i2==32){
100 //プラットフォームにWin32を選択
101 SendMessage(hSelectCompilerCombo,CB_SETCURSEL,0,0);
102 }
103 else if(i2==64){
104 //プラットフォームにWin64を選択
105 SendMessage(hSelectCompilerCombo,CB_SETCURSEL,1,0);
106 }
107 SendMessage(hSelectCompilerCombo,WM_COMMAND,MAKELONG(0,CBN_SELCHANGE),0);
108 }
109 else if(lstrcmpi(temporary,"USEWINDOW")==0&&buffer[i]=='='){
110 for(i++,i2=0;;i++,i2++){
111 if((buffer[i]=='\r'&&buffer[i+1]=='\n')||buffer[i]=='\0'){
112 temporary[i2]=0;
113 if(buffer[i]=='\r'&&buffer[i+1]=='\n') i-=2;
114 break;
115 }
116 temporary[i2]=buffer[i];
117 }
118 if( atoi(temporary) > 0 )
119 {
120 isUseWindow = true;
121 }
122 }
123 else if(lstrcmpi(temporary,"OPTION")==0&&buffer[i]=='='){
124 for(i++,i2=0;;i++,i2++){
125 if((buffer[i]=='\r'&&buffer[i+1]=='\n')||buffer[i]=='\0'){
126 temporary[i2]=0;
127 if(buffer[i]=='\r'&&buffer[i+1]=='\n') i-=2;
128 break;
129 }
130 temporary[i2]=buffer[i];
131 }
132 this->dwOption=GetValue(temporary);
133 }
134 else if(lstrcmpi(temporary,"OUTPUT_RELEASE")==0&&buffer[i]=='='){
135 for(i++,i2=0;;i++,i2++){
136 if((buffer[i]=='\r'&&buffer[i+1]=='\n')||buffer[i]=='\0'){
137 temporary[i2]=0;
138 if(buffer[i]=='\r'&&buffer[i+1]=='\n') i-=2;
139 break;
140 }
141 temporary[i2]=buffer[i];
142 }
143 lstrcpy(this->lpszOutput_Release,temporary);
144 }
145 else if(lstrcmpi(temporary,"OUTPUT_DEBUG")==0&&buffer[i]=='='){
146 for(i++,i2=0;;i++,i2++){
147 if((buffer[i]=='\r'&&buffer[i+1]=='\n')||buffer[i]=='\0'){
148 temporary[i2]=0;
149 if(buffer[i]=='\r'&&buffer[i+1]=='\n') i-=2;
150 break;
151 }
152 temporary[i2]=buffer[i];
153 }
154 lstrcpy(this->lpszOutput_Debug,temporary);
155 }
156 else if(lstrcmpi(temporary,"MANIFEST")==0&&buffer[i]=='='){
157 for(i++,i2=0;;i++,i2++){
158 if((buffer[i]=='\r'&&buffer[i+1]=='\n')||buffer[i]=='\0'){
159 temporary[i2]=0;
160 if(buffer[i]=='\r'&&buffer[i+1]=='\n') i-=2;
161 break;
162 }
163 temporary[i2]=buffer[i];
164 }
165 lstrcpy(this->szManifestPath,temporary);
166 }
167 else if(lstrcmpi(temporary,"DEBUG_CMD_LINE")==0&&buffer[i]=='='){
168 for(i++,i2=0;;i++,i2++){
169 if((buffer[i]=='\r'&&buffer[i+1]=='\n')||buffer[i]=='\0'){
170 temporary[i2]=0;
171 if(buffer[i]=='\r'&&buffer[i+1]=='\n') i-=2;
172 break;
173 }
174 temporary[i2]=buffer[i];
175 }
176 lstrcpy(this->szCmdLine,temporary);
177 }
178 else if(lstrcmpi(temporary,"DEBUG_EXE_PATH")==0&&buffer[i]=='='){
179 for(i++,i2=0;;i++,i2++){
180 if((buffer[i]=='\r'&&buffer[i+1]=='\n')||buffer[i]=='\0'){
181 temporary[i2]=0;
182 if(buffer[i]=='\r'&&buffer[i+1]=='\n') i-=2;
183 break;
184 }
185 temporary[i2]=buffer[i];
186 }
187 lstrcpy(this->szExePath,temporary);
188 }
189 else if(lstrcmpi(temporary,"RESOURCE")==0&&buffer[i]=='='){
190 for(i++,i2=0;;i++,i2++){
191 if((buffer[i]=='\r'&&buffer[i+1]=='\n')||buffer[i]=='\0'){
192 temporary[i2]=0;
193 if(buffer[i]=='\r'&&buffer[i+1]=='\n') i-=2;
194 break;
195 }
196 temporary[i2]=buffer[i];
197 }
198 if(temporary[0]!='\0'&&(!(temporary[0]=='0'&&temporary[1]=='\0'))){
199 lstrcpy(this->ResourceFileName,temporary);
200 GetResourceData();
201 }
202 else{
203 sprintf(this->ResourceFileName,"%s.rc",this->GetName().c_str());
204 }
205 }
206 else if(lstrcmpi(temporary,"SOURCE")==0&&buffer[i]=='\r'&&buffer[i+1]=='\n'){
207 while(1){
208 for(i+=2,i2=0;;i++,i2++){
209 if((buffer[i]=='\r'&&buffer[i+1]=='\n')||buffer[i]=='\0'){
210 temporary[i2]=0;
211 break;
212 }
213 temporary[i2]=buffer[i];
214 }
215 if(temporary[0]=='\0') break;
216 this->pobj_DBFileInfo->add(temporary,0);
217
218 if(buffer[i]=='\0') break;
219 }
220 }
221 else{
222 //不明なパラメータは無視
223 for(i++;;i++){
224 if((buffer[i]=='\r'&&buffer[i+1]=='\n')||buffer[i]=='\0'){
225 if(buffer[i]=='\r'&&buffer[i+1]=='\n') i-=2;
226 break;
227 }
228 }
229 }
230 if(buffer[i]=='\0') break;
231 }
232 }
233 HeapDefaultFree(buffer);
234
235 //古いバージョンファイルを考慮
236 if(this->dwVersion<=4){
237 if( this->GetModuleType() == ActiveBasic::Common::TargetModuleType::Dll )
238 {
239 sprintf(this->lpszOutput_Release,".\\%s.dll",this->GetName().c_str());
240 }
241 else
242 {
243 sprintf(this->lpszOutput_Release,".\\%s.exe",this->GetName().c_str());
244 }
245 sprintf(this->lpszOutput_Debug,".\\%s_debug.exe",this->GetName().c_str());
246 }
247
248 //ブレークポイントを初期化
249 this->pobj_DBBreakPoint=new CDBBreakPoint();
250
251
252 if( isUseWindow )
253 {
254 /////////////////////////////////////////////
255 //ウィンドウ定義ファイル(*.wnd)をオープン
256 sprintf(temp2,"%s%s.wnd",this->GetWorkDir().GetPath().c_str(),this->GetName().c_str());
257 if(!OpenWindowFile(temp2)) return;
258 }
259 else{
260 this->windowInfos.Clear();
261
262 this->NumberOfMenu=0;
263 this->pMenuInfo=(MENU_INFO *)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,1);
264 }
265
266 OpenWorkfile( this->GetWorkDir().GetPath() + this->GetName() + ".wrk" );
267
268 this->modify=0;
269 this->ModifyOfMaterial=0;
270 this->ModifuOfResource=0;
271}
272
273bool Project::Close()
274{
275 extern HANDLE hHeap;
276 extern MDIINFO MdiInfo[MAX_WNDNUM];
277 int i,i2,WndNum;
278 HWND hChild,hCloseChild;
279 char temporary[MAX_PATH];
280
281
282 //保存確認
283 i=ProjectModifyCheck(0);
284 if(i==0) return false;
285 else if(i==2) MakeWorkFile();
286
287 //プロジェクトに関するMDIウィンドウをすべて閉じる
288 hChild=GetWindow(hClient,GW_CHILD);
289 while(hChild){
290 hCloseChild=hChild;
291 hChild=GetNextWindow(hChild,GW_HWNDNEXT);
292 WndNum=GetWndNum(hCloseChild);
293 if(IS_DOCUMENT_TEXT(MdiInfo[WndNum].DocType)){
294 for(i=0;i<this->pobj_DBFileInfo->iNum;i++){
295 this->pobj_DBFileInfo->ppobj_FileInfo[i]->GetFullPath(temporary);
296 if(lstrcmpi(MdiInfo[WndNum].path,temporary)==0){
297
298 //変更フラグをオフにする
299 MdiInfo[WndNum].pMdiTextEdit->UnModify();
300
301 SendMessage(hCloseChild,WM_CLOSE,0,0);
302 break;
303 }
304 }
305 }
306 else if(MdiInfo[WndNum].DocType==WNDTYPE_RAD)
307 {
308 BOOST_FOREACH( const WindowInfo *pWindowInfo, windowInfos )
309 {
310 if( pWindowInfo->GetName() == MdiInfo[WndNum].path ){
311 SendMessage(hCloseChild,WM_CLOSE,0,0);
312 break;
313 }
314 }
315 }
316 else if(MdiInfo[WndNum].DocType==WNDTYPE_MENU){
317 for(i=0;i<this->NumberOfMenu;i++){
318 if(lstrcmp(MdiInfo[WndNum].path,this->pMenuInfo[i].IdName)==0){
319 SendMessage(hCloseChild,WM_CLOSE,0,0);
320 break;
321 }
322 }
323 }
324 else if(MdiInfo[WndNum].DocType==WNDTYPE_ICONEDIT){
325 for(i=0;this->res.NumberOfIconRes;i++){
326 lstrcpy(temporary,this->res.pIconResInfo[i].path);
327 lstrcpy( temporary, this->GetWorkDir().GetFullPath( temporary ).c_str() );
328 if(lstrcmpi(MdiInfo[WndNum].path,temporary)==0){
329 SendMessage(hCloseChild,WM_CLOSE,0,0);
330 break;
331 }
332 }
333 }
334 }
335
336 //ファイル情報のメモリを解放
337 delete this->pobj_DBFileInfo;
338
339 //ブレークポイントのオブジェクトを解放
340 delete this->pobj_DBBreakPoint;
341
342 //ウィンドウ情報のメモリを解放
343 BOOST_FOREACH( WindowInfo *pWindowInfo, windowInfos )
344 {
345 HeapDefaultFree(pWindowInfo->caption);
346 HeapDefaultFree(pWindowInfo->ClassName);
347 HeapDefaultFree(pWindowInfo->CallBackName);
348 HeapDefaultFree(pWindowInfo->filepath);
349 if(pWindowInfo->MenuID)
350 HeapDefaultFree(pWindowInfo->MenuID);
351 if(pWindowInfo->IconResName)
352 HeapDefaultFree(pWindowInfo->IconResName);
353
354 //子ウィンドウのメモリを解放
355 for(i2=0;i2<pWindowInfo->childWindowInfos.size();i2++){
356 HeapDefaultFree(pWindowInfo->childWindowInfos[i2]->IdName);
357 HeapDefaultFree(pWindowInfo->childWindowInfos[i2]->caption);
358 if(pWindowInfo->childWindowInfos[i2]->Control==CT_IMAGEBOX){
359 //イメージ ボックスの場合
360 HeapDefaultFree(pWindowInfo->childWindowInfos[i2]->ImageCtrlInfo.path);
361 }
362
363 delete pWindowInfo->childWindowInfos[i2];
364 }
365 pWindowInfo->childWindowInfos.clear();
366 }
367 this->windowInfos.Clear();
368
369 //メニュー情報のメモリを解放
370 HeapMenuDataFree(this->pMenuInfo,this->NumberOfMenu,0);
371 HeapDefaultFree(this->pMenuInfo);
372
373 //リソースのメモリを解放
374 for(i=0;i<this->res.NumberOfCursorRes;i++){
375 HeapDefaultFree(this->res.pCursorResInfo[i].IdName);
376 HeapDefaultFree(this->res.pCursorResInfo[i].path);
377 }
378 HeapDefaultFree(this->res.pCursorResInfo);
379 for(i=0;i<this->res.NumberOfBitmapRes;i++){
380 HeapDefaultFree(this->res.pBitmapResInfo[i].IdName);
381 HeapDefaultFree(this->res.pBitmapResInfo[i].path);
382 }
383 HeapDefaultFree(this->res.pBitmapResInfo);
384 for(i=0;i<this->res.NumberOfIconRes;i++){
385 HeapDefaultFree(this->res.pIconResInfo[i].IdName);
386 HeapDefaultFree(this->res.pIconResInfo[i].path);
387 }
388 HeapDefaultFree(this->res.pIconResInfo);
389
390 //プロジェクト ビューを非表示にする
391 extern HWND hProjectView;
392 if(IsWindowVisible(hProjectView)) SendMessage(hOwner,WM_COMMAND,IDM_PROJECTVIEW,0);
393 SetWindowText(hProjectView,"Project View");
394
395 extern HWND hProcedureTreeView;
396 extern HWND hMaterialTreeView;
397 TreeView_DeleteAllItems(pobj_FileTree->hTree);
398 TreeView_DeleteAllItems(hProcedureTreeView);
399 TreeView_DeleteAllItems(hMaterialTreeView);
400
401 //ウィンドウ タイトルを変更
402 SetWindowText(hOwner,APPLICATION_NAME);
403
404 this->name = "";
405
406 //メニュー状態を設定
407 ResetState_DocMenu();
408
409 return true;
410}
Note: See TracBrowser for help on using the repository browser.