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

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

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

File size: 11.7 KB
Line 
1#include "stdafx.h"
2
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;
17 int i3;
18 char temporary[MAX_PATH];
19
20 //"カーソル ファイルを指定してください"
21 if(!GetFilePathDialog(hOwner,temporary,CursorFileFilter,STRING_FILEOPENTITLE_CURSOR,TRUE)) return;
22
23 ActiveBasic::Common::ResourceItem item;
24 item.filepath = projectInfo.GetWorkDir().GetRelationalPath( temporary );
25
26 for(i3=1;;i3++){
27 sprintf(temporary,"IDC_CURSOR%d",i3);
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 }
36 }
37
38 if( !isDuplicate )
39 {
40 break;
41 }
42 }
43 item.idName = temporary;
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;
52 tv.hParent = hCursorTreeItemForProjectView;
53 tv.item.pszText=temporary;
54
55 item.hTreeItem = TreeView_InsertItem(hMaterialTreeView,&tv);
56
57 TreeView_SelectItem( hMaterialTreeView, item.hTreeItem );
58
59 projectInfo.resourceManager.cursorResources.push_back( item );
60
61 projectInfo.ModifuOfResource=1;
62}
63void Project_Cursor_Delete(int CursorInfoNum){
64 //ツリービューから削除
65 extern HWND hMaterialTreeView;
66 TreeView_DeleteItem(hMaterialTreeView,projectInfo.resourceManager.cursorResources[CursorInfoNum].hTreeItem);
67
68 //projectInfo.pCursorInfo構造体から削除
69 Jenga::Common::EraseVectorItem<ActiveBasic::Common::ResourceItems>( projectInfo.resourceManager.cursorResources, CursorInfoNum );
70
71 projectInfo.ModifuOfResource=1;
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
81 if(!DialogBoxParam(hResInst,MAKEINTRESOURCE(IDD_INPUTID),hOwner,(DLGPROC)DlgProject_ResourceID_Input,(long)projectInfo.resourceManager.cursorResources[CursorInfoNum].idName.c_str())) return;
82
83 //重複チェック
84 for(i2=0;i2<static_cast<int>(projectInfo.resourceManager.cursorResources.size());i2++){
85 if(i2==CursorInfoNum) continue;
86 if( projectInfo.resourceManager.cursorResources[i2].idName == NewIdName )
87 {
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
95 projectInfo.resourceManager.cursorResources[CursorInfoNum].idName = NewIdName;
96
97 tvItem.hItem=projectInfo.resourceManager.cursorResources[CursorInfoNum].hTreeItem;
98 tvItem.mask=TVIF_TEXT;
99 lstrcpy( temporary, projectInfo.resourceManager.cursorResources[CursorInfoNum].idName.c_str() );
100 tvItem.pszText=temporary;
101 tvItem.cchTextMax=lstrlen(temporary)+1;
102 TreeView_SetItem(hMaterialTreeView,&tvItem);
103
104 projectInfo.ModifuOfResource=1;
105
106 TreeView_SortChildren(hMaterialTreeView,
107 TreeView_GetParent(hMaterialTreeView,projectInfo.resourceManager.cursorResources[CursorInfoNum].hTreeItem),
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
120 ActiveBasic::Common::ResourceItem item;
121 item.filepath = projectInfo.GetWorkDir().GetRelationalPath( temporary );
122
123 for(i3=1;;i3++){
124 sprintf(temporary,"IDB_BITMAP%d",i3);
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 }
133 }
134
135 if( !isDuplicate )
136 {
137 break;
138 }
139 }
140 item.idName = temporary;
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;
149 tv.hParent = hBitmapTreeItemForProjectView;
150 tv.item.pszText=temporary;
151
152 item.hTreeItem = TreeView_InsertItem(hMaterialTreeView,&tv);
153
154 TreeView_SelectItem(hMaterialTreeView,item.hTreeItem);
155
156 projectInfo.resourceManager.bitmapResources.push_back( item );
157
158 projectInfo.ModifuOfResource=1;
159
160
161 ////////////////////////////////
162 // ウィンドウ プロパティを更新
163 for(i2=0;i2<MdiInfo.size();i2++){
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));
167 }
168 }
169}
170void Project_Bitmap_Delete(int BitmapInfoNum){
171 //ツリービューから削除
172 extern HWND hMaterialTreeView;
173 TreeView_DeleteItem(hMaterialTreeView,projectInfo.resourceManager.bitmapResources[BitmapInfoNum].hTreeItem);
174
175 //projectInfo.pBitmapInfo構造体から削除
176 Jenga::Common::EraseVectorItem<ActiveBasic::Common::ResourceItems>( projectInfo.resourceManager.bitmapResources, BitmapInfoNum );
177
178 projectInfo.ModifuOfResource=1;
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
188 if(!DialogBoxParam(hResInst,MAKEINTRESOURCE(IDD_INPUTID),hOwner,(DLGPROC)DlgProject_ResourceID_Input,(long)projectInfo.resourceManager.bitmapResources[BitmapInfoNum].idName.c_str())) return;
189
190 //重複チェック
191 for(i2=0;i2<static_cast<int>(projectInfo.resourceManager.bitmapResources.size());i2++){
192 if(i2==BitmapInfoNum) continue;
193 if( projectInfo.resourceManager.bitmapResources[i2].idName == NewIdName )
194 {
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
202 projectInfo.resourceManager.bitmapResources[BitmapInfoNum].idName = NewIdName;
203
204 tvItem.hItem=projectInfo.resourceManager.bitmapResources[BitmapInfoNum].hTreeItem;
205 tvItem.mask=TVIF_TEXT;
206 lstrcpy( temporary, projectInfo.resourceManager.bitmapResources[BitmapInfoNum].idName.c_str() );
207 tvItem.pszText = temporary;
208 tvItem.cchTextMax=lstrlen(temporary)+1;
209 TreeView_SetItem(hMaterialTreeView,&tvItem);
210
211 projectInfo.ModifuOfResource=1;
212
213 TreeView_SortChildren(hMaterialTreeView,
214 TreeView_GetParent(hMaterialTreeView,projectInfo.resourceManager.bitmapResources[BitmapInfoNum].hTreeItem),
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
226 ActiveBasic::Common::ResourceItem item;
227 item.filepath = projectInfo.GetWorkDir().GetRelationalPath( temporary );
228
229 for(i3=1;;i3++){
230 sprintf(temporary,"IDI_ICON%d",i3);
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 }
239 }
240
241 if( !isDuplicate )
242 {
243 break;
244 }
245 }
246 item.idName = temporary;
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;
255 tv.hParent = hIconTreeItemForProjectView;
256 if(projectInfo.resourceManager.iconResources.size()==0) lstrcat(temporary," (Main)");
257 tv.item.pszText=temporary;
258
259 item.hTreeItem=
260 TreeView_InsertItem(hMaterialTreeView,&tv);
261
262 TreeView_SelectItem(hMaterialTreeView,item.hTreeItem);
263
264 projectInfo.resourceManager.iconResources.push_back( item );
265
266 projectInfo.ModifuOfResource=1;
267
268 ////////////////////////////////
269 // ウィンドウ プロパティを更新
270 for(i2=0;i2<MdiInfo.size();i2++){
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));
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;
285 TreeView_DeleteItem(hMaterialTreeView,projectInfo.resourceManager.iconResources[IconInfoNum].hTreeItem);
286
287 //projectInfo.pIconInfo構造体から削除
288 Jenga::Common::EraseVectorItem<ActiveBasic::Common::ResourceItems>( projectInfo.resourceManager.iconResources, IconInfoNum );
289
290 if(IconInfoNum==0&&projectInfo.resourceManager.iconResources.size()){
291 tv.mask=TVIF_TEXT|TVIF_HANDLE;
292 tv.pszText=temporary;
293 tv.cchTextMax=MAX_PATH;
294 tv.hItem=projectInfo.resourceManager.iconResources[0].hTreeItem;
295 TreeView_GetItem(hMaterialTreeView,&tv);
296 lstrcat(tv.pszText," (Main)");
297 TreeView_SetItem(hMaterialTreeView,&tv);
298 }
299
300 projectInfo.ModifuOfResource=1;
301
302 ////////////////////////////////
303 // ウィンドウ プロパティを更新
304 for(i2=0;i2<MdiInfo.size();i2++){
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));
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
319 if(!DialogBoxParam(hResInst,MAKEINTRESOURCE(IDD_INPUTID),hOwner,(DLGPROC)DlgProject_ResourceID_Input,(long)projectInfo.resourceManager.iconResources[IconInfoNum].idName.c_str())) return;
320
321 //重複チェック
322 for(i2=0;i2<static_cast<int>(projectInfo.resourceManager.iconResources.size());i2++){
323 if(i2==IconInfoNum) continue;
324 if( projectInfo.resourceManager.iconResources[i2].idName == NewIdName )
325 {
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
333 projectInfo.resourceManager.iconResources[IconInfoNum].idName = NewIdName;
334
335 tvItem.hItem=projectInfo.resourceManager.iconResources[IconInfoNum].hTreeItem;
336 tvItem.mask=TVIF_TEXT;
337 if(IconInfoNum==0){
338 sprintf(temporary,"%s (Main)",projectInfo.resourceManager.iconResources[IconInfoNum].idName.c_str());
339 }
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;
346 TreeView_SetItem(hMaterialTreeView,&tvItem);
347
348 projectInfo.ModifuOfResource=1;
349
350 TreeView_SortChildren(hMaterialTreeView,
351 TreeView_GetParent(hMaterialTreeView,projectInfo.resourceManager.iconResources[IconInfoNum].hTreeItem),
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.