f64d34f3af25795188ce5699bbbfa46ae8005a0e
2 * PROJECT: PAINT for ReactOS
5 * PURPOSE: Undo and redo functionality
6 * PROGRAMMERS: Benedikt Freisen
9 /* INCLUDES *********************************************************/
12 #include "globalvar.h"
14 #include "definitions.h"
16 /* FUNCTIONS ********************************************************/
18 void setImgXYRes(int x
, int y
)
20 if ((imgXRes
!=x
)||(imgYRes
!=y
))
24 updateCanvasAndScrollbars();
30 DeleteObject(hBms
[(currInd
+1)%4]);
31 hBms
[(currInd
+1)%4] = CopyImage( hBms
[currInd
], IMAGE_BITMAP
, 0, 0, LR_COPYRETURNORG
);
32 currInd
= (currInd
+1)%4;
33 if (undoSteps
<3) undoSteps
++;
35 SelectObject(hDrawingDC
, hBms
[currInd
]);
36 imgXRes
= GetDIBWidth(hBms
[currInd
]);
37 imgYRes
= GetDIBHeight(hBms
[currInd
]);
44 ShowWindow(hSelection
, SW_HIDE
);
45 currInd
= (currInd
+3)%4;
46 SelectObject(hDrawingDC
, hBms
[currInd
]);
48 if (redoSteps
<3) redoSteps
++;
49 setImgXYRes(GetDIBWidth(hBms
[currInd
]), GetDIBHeight(hBms
[currInd
]));
57 ShowWindow(hSelection
, SW_HIDE
);
58 currInd
= (currInd
+1)%4;
59 SelectObject(hDrawingDC
, hBms
[currInd
]);
61 if (undoSteps
<3) undoSteps
++;
62 setImgXYRes(GetDIBWidth(hBms
[currInd
]), GetDIBHeight(hBms
[currInd
]));
68 DeleteObject(hBms
[currInd
]);
69 hBms
[currInd
] = CopyImage( hBms
[(currInd
+3)%4], IMAGE_BITMAP
, 0, 0, LR_COPYRETURNORG
);
70 SelectObject(hDrawingDC
, hBms
[currInd
]);
71 imgXRes
= GetDIBWidth(hBms
[currInd
]);
72 imgYRes
= GetDIBHeight(hBms
[currInd
]);
81 void insertReversible(HBITMAP hbm
)
83 DeleteObject(hBms
[(currInd
+1)%4]);
84 hBms
[(currInd
+1)%4] = hbm
;
85 currInd
= (currInd
+1)%4;
86 if (undoSteps
<3) undoSteps
++;
88 SelectObject(hDrawingDC
, hBms
[currInd
]);
89 setImgXYRes(GetDIBWidth(hBms
[currInd
]), GetDIBHeight(hBms
[currInd
]));
92 void cropReversible(int x
, int y
)
94 SelectObject(hDrawingDC
, hBms
[currInd
]);
95 DeleteObject(hBms
[(currInd
+1)%4]);
96 hBms
[(currInd
+1)%4] = CreateDIBWithProperties(x
, y
);
97 currInd
= (currInd
+1)%4;
98 if (undoSteps
<3) undoSteps
++;
101 HBITMAP oldBitmap
= SelectObject(hSelDC
, hBms
[currInd
]);
102 HPEN oldPen
= SelectObject(hSelDC
, CreatePen(PS_SOLID
, 1, bgColor
));
103 HBRUSH oldBrush
= SelectObject(hSelDC
, CreateSolidBrush(bgColor
));
104 Rectangle(hSelDC
, 0, 0, x
, y
);
105 DeleteObject(SelectObject(hSelDC
, oldBrush
));
106 DeleteObject(SelectObject(hSelDC
, oldPen
));
107 BitBlt(hDrawingDC
, 0, 0, imgXRes
, imgYRes
, hSelDC
, 0, 0, SRCCOPY
);
108 SelectObject(hDrawingDC
, SelectObject(hSelDC
, oldBitmap
));