source: dev/trunk/ab5.0/abdev/ProjectEditor/IconEditor_UndoRedo.cpp@ 479

Last change on this file since 479 was 475, checked in by dai_9181, 17 years ago

構成管理を変更中・・・(いったんコミット)

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