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

Last change on this file since 828 was 828, checked in by イグトランス (egtra), 12 years ago

egtraブランチの内容をマージ。

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