source: dev/trunk/ab5.0/abdev/abdev/Resource.cpp@ 655

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

MDIINFO構造体をリファクタリング。

File size: 11.7 KB
RevLine 
[475]1#include "stdafx.h"
2
[3]3#include "common.h"
4
5#if defined(JPN)
6//日本語
7#include "pj_msg_jpn.h"
8#else
9//英語
10#include "pj_msg_eng.h"
11#endif
12
13
14void Project_CursorResInsert(void){
15 extern HANDLE hHeap;
16 extern LPSTR CursorFileFilter;
[623]17 int i3;
[3]18 char temporary[MAX_PATH];
19
20 //"カーソル ファイルを指定してください"
21 if(!GetFilePathDialog(hOwner,temporary,CursorFileFilter,STRING_FILEOPENTITLE_CURSOR,TRUE)) return;
22
[623]23 ActiveBasic::Common::ResourceItem item;
24 item.filepath = projectInfo.GetWorkDir().GetRelationalPath( temporary );
[3]25
26 for(i3=1;;i3++){
27 sprintf(temporary,"IDC_CURSOR%d",i3);
[623]28 bool isDuplicate = false;
29 BOOST_FOREACH( const ActiveBasic::Common::ResourceItem &resourceItem, projectInfo.resourceManager.cursorResources )
30 {
31 if( resourceItem.idName == temporary )
32 {
33 isDuplicate = true;
34 break;
35 }
[3]36 }
[623]37
38 if( !isDuplicate )
39 {
40 break;
41 }
[3]42 }
[623]43 item.idName = temporary;
[3]44
45 //ツリービューに追加
46 extern HWND hMaterialTreeView;
47 TV_INSERTSTRUCT tv;
48 tv.hInsertAfter=TVI_SORT;
49 tv.item.mask=TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE;
50 tv.item.iImage=6;
51 tv.item.iSelectedImage=6;
[623]52 tv.hParent = hCursorTreeItemForProjectView;
[3]53 tv.item.pszText=temporary;
54
[623]55 item.hTreeItem = TreeView_InsertItem(hMaterialTreeView,&tv);
[3]56
[623]57 TreeView_SelectItem( hMaterialTreeView, item.hTreeItem );
[3]58
[623]59 projectInfo.resourceManager.cursorResources.push_back( item );
60
[618]61 projectInfo.ModifuOfResource=1;
[3]62}
63void Project_Cursor_Delete(int CursorInfoNum){
64 //ツリービューから削除
65 extern HWND hMaterialTreeView;
[623]66 TreeView_DeleteItem(hMaterialTreeView,projectInfo.resourceManager.cursorResources[CursorInfoNum].hTreeItem);
[3]67
[618]68 //projectInfo.pCursorInfo構造体から削除
[623]69 Jenga::Common::EraseVectorItem<ActiveBasic::Common::ResourceItems>( projectInfo.resourceManager.cursorResources, CursorInfoNum );
[3]70
[618]71 projectInfo.ModifuOfResource=1;
[3]72}
73void Project_Cursor_RenameID(int CursorInfoNum){
74 extern HANDLE hHeap;
75 extern char NewIdName[MAX_PATH];
76 extern HWND hMaterialTreeView;
77 int i2;
78 char temporary[MAX_PATH];
79 TVITEM tvItem;
80
[623]81 if(!DialogBoxParam(hResInst,MAKEINTRESOURCE(IDD_INPUTID),hOwner,(DLGPROC)DlgProject_ResourceID_Input,(long)projectInfo.resourceManager.cursorResources[CursorInfoNum].idName.c_str())) return;
[3]82
83 //重複チェック
[624]84 for(i2=0;i2<static_cast<int>(projectInfo.resourceManager.cursorResources.size());i2++){
[3]85 if(i2==CursorInfoNum) continue;
[623]86 if( projectInfo.resourceManager.cursorResources[i2].idName == NewIdName )
87 {
[3]88 //"ID \"%s\" は既にプロジェクト内に存在します。"
89 sprintf(temporary,STRING_DUPLICATIONERROR_ID_IN_PROJECT,NewIdName);
90 MessageBox(hOwner,temporary,STRING_ERROR,MB_OK|MB_ICONEXCLAMATION);
91 return;
92 }
93 }
94
[623]95 projectInfo.resourceManager.cursorResources[CursorInfoNum].idName = NewIdName;
[3]96
[623]97 tvItem.hItem=projectInfo.resourceManager.cursorResources[CursorInfoNum].hTreeItem;
[3]98 tvItem.mask=TVIF_TEXT;
[623]99 lstrcpy( temporary, projectInfo.resourceManager.cursorResources[CursorInfoNum].idName.c_str() );
100 tvItem.pszText=temporary;
101 tvItem.cchTextMax=lstrlen(temporary)+1;
[3]102 TreeView_SetItem(hMaterialTreeView,&tvItem);
103
[618]104 projectInfo.ModifuOfResource=1;
[3]105
106 TreeView_SortChildren(hMaterialTreeView,
[623]107 TreeView_GetParent(hMaterialTreeView,projectInfo.resourceManager.cursorResources[CursorInfoNum].hTreeItem),
[3]108 0);
109}
110
111void Project_BitmapResInsert(void){
112 extern HANDLE hHeap;
113 extern LPSTR BitmapFileFilter;
114 int i2,i3;
115 char temporary[MAX_PATH];
116
117 //"ビットマップ ファイルを指定してください"
118 if(!GetFilePathDialog(hOwner,temporary,BitmapFileFilter,STRING_FILEOPENTITLE_BITMAP,TRUE)) return;
119
[623]120 ActiveBasic::Common::ResourceItem item;
121 item.filepath = projectInfo.GetWorkDir().GetRelationalPath( temporary );
[3]122
123 for(i3=1;;i3++){
124 sprintf(temporary,"IDB_BITMAP%d",i3);
[623]125 bool isDuplicate = false;
126 BOOST_FOREACH( const ActiveBasic::Common::ResourceItem &resourceItem, projectInfo.resourceManager.bitmapResources )
127 {
128 if( resourceItem.idName == temporary )
129 {
130 isDuplicate = true;
131 break;
132 }
[3]133 }
[623]134
135 if( !isDuplicate )
136 {
137 break;
138 }
[3]139 }
[623]140 item.idName = temporary;
[3]141
142 //ツリービューに追加
143 extern HWND hMaterialTreeView;
144 TV_INSERTSTRUCT tv;
145 tv.hInsertAfter=TVI_SORT;
146 tv.item.mask=TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE;
147 tv.item.iImage=5;
148 tv.item.iSelectedImage=5;
[623]149 tv.hParent = hBitmapTreeItemForProjectView;
[3]150 tv.item.pszText=temporary;
151
[623]152 item.hTreeItem = TreeView_InsertItem(hMaterialTreeView,&tv);
[3]153
[623]154 TreeView_SelectItem(hMaterialTreeView,item.hTreeItem);
[3]155
[623]156 projectInfo.resourceManager.bitmapResources.push_back( item );
157
[618]158 projectInfo.ModifuOfResource=1;
[3]159
160
161 ////////////////////////////////
162 // ウィンドウ プロパティを更新
[625]163 for(i2=0;i2<MdiInfo.size();i2++){
[629]164 if(MdiInfo[i2]->hwnd&&MdiInfo[i2]->DocType==WNDTYPE_RAD){
165 if(MdiInfo[i2]->MdiRadInfo->SelectingItem[0]==SELECT_WINDOW)
166 ChangePropertyWindow(i2,GetWndInfoNum(MdiInfo[i2]->path));
[3]167 }
168 }
169}
170void Project_Bitmap_Delete(int BitmapInfoNum){
171 //ツリービューから削除
172 extern HWND hMaterialTreeView;
[623]173 TreeView_DeleteItem(hMaterialTreeView,projectInfo.resourceManager.bitmapResources[BitmapInfoNum].hTreeItem);
[3]174
[618]175 //projectInfo.pBitmapInfo構造体から削除
[623]176 Jenga::Common::EraseVectorItem<ActiveBasic::Common::ResourceItems>( projectInfo.resourceManager.bitmapResources, BitmapInfoNum );
[3]177
[618]178 projectInfo.ModifuOfResource=1;
[3]179}
180void Project_Bitmap_RenameID(int BitmapInfoNum){
181 extern HANDLE hHeap;
182 extern char NewIdName[MAX_PATH];
183 extern HWND hMaterialTreeView;
184 int i2;
185 char temporary[MAX_PATH];
186 TVITEM tvItem;
187
[623]188 if(!DialogBoxParam(hResInst,MAKEINTRESOURCE(IDD_INPUTID),hOwner,(DLGPROC)DlgProject_ResourceID_Input,(long)projectInfo.resourceManager.bitmapResources[BitmapInfoNum].idName.c_str())) return;
[3]189
190 //重複チェック
[624]191 for(i2=0;i2<static_cast<int>(projectInfo.resourceManager.bitmapResources.size());i2++){
[3]192 if(i2==BitmapInfoNum) continue;
[623]193 if( projectInfo.resourceManager.bitmapResources[i2].idName == NewIdName )
194 {
[3]195 //"ID \"%s\" は既にプロジェクト内に存在します。"
196 sprintf(temporary,STRING_DUPLICATIONERROR_ID_IN_PROJECT,NewIdName);
197 MessageBox(hOwner,temporary,STRING_ERROR,MB_OK|MB_ICONEXCLAMATION);
198 return;
199 }
200 }
201
[623]202 projectInfo.resourceManager.bitmapResources[BitmapInfoNum].idName = NewIdName;
[3]203
[623]204 tvItem.hItem=projectInfo.resourceManager.bitmapResources[BitmapInfoNum].hTreeItem;
[3]205 tvItem.mask=TVIF_TEXT;
[623]206 lstrcpy( temporary, projectInfo.resourceManager.bitmapResources[BitmapInfoNum].idName.c_str() );
207 tvItem.pszText = temporary;
208 tvItem.cchTextMax=lstrlen(temporary)+1;
[3]209 TreeView_SetItem(hMaterialTreeView,&tvItem);
210
[618]211 projectInfo.ModifuOfResource=1;
[3]212
213 TreeView_SortChildren(hMaterialTreeView,
[623]214 TreeView_GetParent(hMaterialTreeView,projectInfo.resourceManager.bitmapResources[BitmapInfoNum].hTreeItem),
[3]215 0);
216}
217void Project_IconResInsert(void){
218 extern HANDLE hHeap;
219 extern LPSTR IconFileFilter;
220 int i2,i3;
221 char temporary[MAX_PATH];
222
223 //"アイコン ファイルを指定してください"
224 if(!GetFilePathDialog(hOwner,temporary,IconFileFilter,STRING_FILEOPENTITLE_ICON,TRUE)) return;
225
[623]226 ActiveBasic::Common::ResourceItem item;
227 item.filepath = projectInfo.GetWorkDir().GetRelationalPath( temporary );
[3]228
229 for(i3=1;;i3++){
230 sprintf(temporary,"IDI_ICON%d",i3);
[623]231 bool isDuplicate = false;
232 BOOST_FOREACH( const ActiveBasic::Common::ResourceItem &resourceItem, projectInfo.resourceManager.iconResources )
233 {
234 if( resourceItem.idName == temporary )
235 {
236 isDuplicate = true;
237 break;
238 }
[3]239 }
[623]240
241 if( !isDuplicate )
242 {
243 break;
244 }
[3]245 }
[623]246 item.idName = temporary;
[3]247
248 //ツリービューに追加
249 extern HWND hMaterialTreeView;
250 TV_INSERTSTRUCT tv;
251 tv.hInsertAfter=TVI_SORT;
252 tv.item.mask=TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE;
253 tv.item.iImage=4;
254 tv.item.iSelectedImage=4;
[623]255 tv.hParent = hIconTreeItemForProjectView;
256 if(projectInfo.resourceManager.iconResources.size()==0) lstrcat(temporary," (Main)");
[3]257 tv.item.pszText=temporary;
258
[623]259 item.hTreeItem=
[3]260 TreeView_InsertItem(hMaterialTreeView,&tv);
261
[623]262 TreeView_SelectItem(hMaterialTreeView,item.hTreeItem);
[3]263
[623]264 projectInfo.resourceManager.iconResources.push_back( item );
265
[618]266 projectInfo.ModifuOfResource=1;
[3]267
268 ////////////////////////////////
269 // ウィンドウ プロパティを更新
[625]270 for(i2=0;i2<MdiInfo.size();i2++){
[629]271 if(MdiInfo[i2]->hwnd&&MdiInfo[i2]->DocType==WNDTYPE_RAD){
272 if(MdiInfo[i2]->MdiRadInfo->SelectingItem[0]==SELECT_WINDOW)
273 ChangePropertyWindow(i2,GetWndInfoNum(MdiInfo[i2]->path));
[3]274 }
275 }
276}
277void Project_Icon_Delete(int IconInfoNum){
278 extern HANDLE hHeap;
279 int i2;
280 char temporary[MAX_PATH];
281 TVITEM tv;
282
283 //ツリービューから削除
284 extern HWND hMaterialTreeView;
[623]285 TreeView_DeleteItem(hMaterialTreeView,projectInfo.resourceManager.iconResources[IconInfoNum].hTreeItem);
[3]286
[618]287 //projectInfo.pIconInfo構造体から削除
[623]288 Jenga::Common::EraseVectorItem<ActiveBasic::Common::ResourceItems>( projectInfo.resourceManager.iconResources, IconInfoNum );
[3]289
[623]290 if(IconInfoNum==0&&projectInfo.resourceManager.iconResources.size()){
[3]291 tv.mask=TVIF_TEXT|TVIF_HANDLE;
292 tv.pszText=temporary;
293 tv.cchTextMax=MAX_PATH;
[623]294 tv.hItem=projectInfo.resourceManager.iconResources[0].hTreeItem;
[3]295 TreeView_GetItem(hMaterialTreeView,&tv);
296 lstrcat(tv.pszText," (Main)");
297 TreeView_SetItem(hMaterialTreeView,&tv);
298 }
299
[618]300 projectInfo.ModifuOfResource=1;
[3]301
302 ////////////////////////////////
303 // ウィンドウ プロパティを更新
[625]304 for(i2=0;i2<MdiInfo.size();i2++){
[629]305 if(MdiInfo[i2]->hwnd&&MdiInfo[i2]->DocType==WNDTYPE_RAD){
306 if(MdiInfo[i2]->MdiRadInfo->SelectingItem[0]==SELECT_WINDOW)
307 ChangePropertyWindow(i2,GetWndInfoNum(MdiInfo[i2]->path));
[3]308 }
309 }
310}
311void Project_Icon_RenameID(int IconInfoNum){
312 extern HANDLE hHeap;
313 extern char NewIdName[MAX_PATH];
314 extern HWND hMaterialTreeView;
315 int i2;
316 char temporary[MAX_PATH];
317 TVITEM tvItem;
318
[623]319 if(!DialogBoxParam(hResInst,MAKEINTRESOURCE(IDD_INPUTID),hOwner,(DLGPROC)DlgProject_ResourceID_Input,(long)projectInfo.resourceManager.iconResources[IconInfoNum].idName.c_str())) return;
[3]320
321 //重複チェック
[624]322 for(i2=0;i2<static_cast<int>(projectInfo.resourceManager.iconResources.size());i2++){
[3]323 if(i2==IconInfoNum) continue;
[623]324 if( projectInfo.resourceManager.iconResources[i2].idName == NewIdName )
325 {
[3]326 //"ID \"%s\" は既にプロジェクト内に存在します。"
327 sprintf(temporary,STRING_DUPLICATIONERROR_ID_IN_PROJECT,NewIdName);
328 MessageBox(hOwner,temporary,STRING_ERROR,MB_OK|MB_ICONEXCLAMATION);
329 return;
330 }
331 }
332
[623]333 projectInfo.resourceManager.iconResources[IconInfoNum].idName = NewIdName;
[3]334
[623]335 tvItem.hItem=projectInfo.resourceManager.iconResources[IconInfoNum].hTreeItem;
[3]336 tvItem.mask=TVIF_TEXT;
337 if(IconInfoNum==0){
[623]338 sprintf(temporary,"%s (Main)",projectInfo.resourceManager.iconResources[IconInfoNum].idName.c_str());
[3]339 }
[623]340 else
341 {
342 sprintf(temporary,"%s",projectInfo.resourceManager.iconResources[IconInfoNum].idName.c_str());
343 }
344 tvItem.pszText=temporary;
345 tvItem.cchTextMax=lstrlen(temporary)+1;
[3]346 TreeView_SetItem(hMaterialTreeView,&tvItem);
347
[618]348 projectInfo.ModifuOfResource=1;
[3]349
350 TreeView_SortChildren(hMaterialTreeView,
[623]351 TreeView_GetParent(hMaterialTreeView,projectInfo.resourceManager.iconResources[IconInfoNum].hTreeItem),
[3]352 0);
353}
354
355BOOL CALLBACK DlgProject_ResourceID_Input(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
356 extern char NewIdName[MAX_PATH];
357 switch(message){
358 case WM_INITDIALOG:
359 //"IDの変更"
360 SetWindowText(hwnd,STRING_RENAME_ID);
361
362 SetDlgItemText(hwnd,IDC_IDNAME,(char *)lParam);
363 SetPosCenter(hwnd);
364 break;
365 case WM_COMMAND:
366 switch(LOWORD(wParam)){
367 case IDOK:
368 GetDlgItemText(hwnd,IDC_IDNAME,NewIdName,MAX_PATH);
369 if(!NewIdName[0]){
370 //"ID名を入力して下さい。"
371 MessageBox(hwnd,STRING_ERROR_MUST_IDNAME,APPLICATION_NAME,MB_OK);
372 return 1;
373 }
374 EndDialog(hwnd,1);
375 return 1;
376 case IDCANCEL:
377 EndDialog(hwnd,0);
378 return 1;
379 }
380 break;
381 }
382 return 0;
383}
Note: See TracBrowser for help on using the repository browser.