source: dev/ProjectEditor/IconEditor_UndoRedo.cpp@ 7

Last change on this file since 7 was 3, checked in by dai_9181, 18 years ago
File size: 3.1 KB
Line 
1#include "common.h"
2
3void IconEdit_UndoCommand(int WndNum){
4 extern MDIINFO MdiInfo[MAX_WNDNUM];
5 int i;
6 BYTE *pByte;
7 ICONEDIT_UNDOSTATE *pUndoState;
8
9 pUndoState=&MdiInfo[WndNum].MdiIconEditInfo->undo[MdiInfo[WndNum].MdiIconEditInfo->SelectIconNum];
10
11 i=pUndoState->NowPos-1;
12 if(i==-1) i=MAX_ICONEDIT_UNDONUM-1;
13 if(!pUndoState->lpData[i]){
14 MessageBeep(0);
15 return;
16 }
17 pUndoState->NowPos=i;
18
19 pByte=MdiInfo[WndNum].MdiIconEditInfo->pIconImage[MdiInfo[WndNum].MdiIconEditInfo->SelectIconNum];
20 MdiInfo[WndNum].MdiIconEditInfo->pIconImage[MdiInfo[WndNum].MdiIconEditInfo->SelectIconNum]=
21 pUndoState->lpData[i];
22 pUndoState->lpData[i]=pByte;
23
24 //選択フレームを消去
25 if(MdiInfo[WndNum].MdiIconEditInfo->SelectLevel==2){
26 DeleteObject(MdiInfo[WndNum].MdiIconEditInfo->hSelectingBmp);
27 MdiInfo[WndNum].MdiIconEditInfo->SelectLevel=0;
28 }
29
30 //再描画
31 DrawIconToMemBmp(WndNum,0);
32 InvalidateRect(MdiInfo[WndNum].MdiIconEditInfo->hMain,NULL,0);
33
34 MdiInfo[WndNum].MdiIconEditInfo->bModify=1;
35
36 //メニューを有効化
37 ResetState_UndoMenu();
38}
39void IconEdit_RedoCommand(int WndNum){
40 extern MDIINFO MdiInfo[MAX_WNDNUM];
41 BYTE *pByte;
42 ICONEDIT_UNDOSTATE *pUndoState;
43
44 pUndoState=&MdiInfo[WndNum].MdiIconEditInfo->undo[MdiInfo[WndNum].MdiIconEditInfo->SelectIconNum];
45
46 if(!pUndoState->lpData[pUndoState->NowPos]){
47 MessageBeep(0);
48 return;
49 }
50
51 pByte=MdiInfo[WndNum].MdiIconEditInfo->pIconImage[MdiInfo[WndNum].MdiIconEditInfo->SelectIconNum];
52 MdiInfo[WndNum].MdiIconEditInfo->pIconImage[MdiInfo[WndNum].MdiIconEditInfo->SelectIconNum]=
53 pUndoState->lpData[pUndoState->NowPos];
54 pUndoState->lpData[pUndoState->NowPos]=pByte;
55
56 DrawIconToMemBmp(WndNum,0);
57 InvalidateRect(MdiInfo[WndNum].MdiIconEditInfo->hMain,NULL,0);
58
59 pUndoState->NowPos++;
60 if(pUndoState->NowPos==MAX_ICONEDIT_UNDONUM) pUndoState->NowPos=0;
61
62 MdiInfo[WndNum].MdiIconEditInfo->bModify=1;
63
64 ResetState_UndoMenu();
65}
66void IconEdit_NoticeChanging(int WndNum){
67 extern HANDLE hHeap;
68 extern MDIINFO MdiInfo[MAX_WNDNUM];
69 int i;
70 ICONEDIT_UNDOSTATE *pUndoState;
71
72 pUndoState=&MdiInfo[WndNum].MdiIconEditInfo->undo[MdiInfo[WndNum].MdiIconEditInfo->SelectIconNum];
73
74 //Redoされた場合の不要なデータを削除する
75 for(i=pUndoState->NowPos;;i++){
76 if(i==MAX_ICONEDIT_UNDONUM) i=0;
77 if(pUndoState->lpData[i]==0) break;
78 HeapDefaultFree(pUndoState->lpData[i]);
79 pUndoState->lpData[i]=0;
80 }
81
82 pUndoState->lpData[pUndoState->NowPos]=(BYTE *)
83 HeapAlloc(hHeap,0,MdiInfo[WndNum].MdiIconEditInfo->dwBytesInRes[MdiInfo[WndNum].MdiIconEditInfo->SelectIconNum]);
84
85 memcpy(pUndoState->lpData[pUndoState->NowPos],
86 MdiInfo[WndNum].MdiIconEditInfo->pIconImage[MdiInfo[WndNum].MdiIconEditInfo->SelectIconNum],
87 MdiInfo[WndNum].MdiIconEditInfo->dwBytesInRes[MdiInfo[WndNum].MdiIconEditInfo->SelectIconNum]);
88
89 pUndoState->NowPos++;
90 if(pUndoState->NowPos==MAX_ICONEDIT_UNDONUM) pUndoState->NowPos=0;
91 if(pUndoState->lpData[pUndoState->NowPos]){
92 //一番古い情報を切り捨てる
93 HeapDefaultFree(pUndoState->lpData[pUndoState->NowPos]);
94 pUndoState->lpData[pUndoState->NowPos]=0;
95 }
96
97 MdiInfo[WndNum].MdiIconEditInfo->bModify=1;
98
99 ResetState_UndoMenu();
100}
Note: See TracBrowser for help on using the repository browser.