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 extern void updateCanvasAndScrollbars(void);
20 void setImgXYRes(int x
, int y
)
22 if ((imgXRes
!=x
)||(imgYRes
!=y
))
26 updateCanvasAndScrollbars();
32 DeleteObject(hBms
[(currInd
+1)%4]);
33 hBms
[(currInd
+1)%4] = CopyImage( hBms
[currInd
], IMAGE_BITMAP
, 0, 0, LR_COPYRETURNORG
);
34 currInd
= (currInd
+1)%4;
35 if (undoSteps
<3) undoSteps
++;
37 SelectObject(hDrawingDC
, hBms
[currInd
]);
38 imgXRes
= GetDIBWidth(hBms
[currInd
]);
39 imgYRes
= GetDIBHeight(hBms
[currInd
]);
46 ShowWindow(hSelection
, SW_HIDE
);
47 currInd
= (currInd
+3)%4;
48 SelectObject(hDrawingDC
, hBms
[currInd
]);
50 if (redoSteps
<3) redoSteps
++;
51 setImgXYRes(GetDIBWidth(hBms
[currInd
]), GetDIBHeight(hBms
[currInd
]));
59 ShowWindow(hSelection
, SW_HIDE
);
60 currInd
= (currInd
+1)%4;
61 SelectObject(hDrawingDC
, hBms
[currInd
]);
63 if (undoSteps
<3) undoSteps
++;
64 setImgXYRes(GetDIBWidth(hBms
[currInd
]), GetDIBHeight(hBms
[currInd
]));
70 DeleteObject(hBms
[currInd
]);
71 hBms
[currInd
] = CopyImage( hBms
[(currInd
+3)%4], IMAGE_BITMAP
, 0, 0, LR_COPYRETURNORG
);
72 SelectObject(hDrawingDC
, hBms
[currInd
]);
73 imgXRes
= GetDIBWidth(hBms
[currInd
]);
74 imgYRes
= GetDIBHeight(hBms
[currInd
]);
83 void insertReversible(HBITMAP hbm
)
85 DeleteObject(hBms
[(currInd
+1)%4]);
86 hBms
[(currInd
+1)%4] = hbm
;
87 currInd
= (currInd
+1)%4;
88 if (undoSteps
<3) undoSteps
++;
90 SelectObject(hDrawingDC
, hBms
[currInd
]);
91 setImgXYRes(GetDIBWidth(hBms
[currInd
]), GetDIBHeight(hBms
[currInd
]));
94 void cropReversible(int width
, int height
, int xOffset
, int yOffset
)
100 SelectObject(hDrawingDC
, hBms
[currInd
]);
101 DeleteObject(hBms
[(currInd
+1)%4]);
102 hBms
[(currInd
+1)%4] = CreateDIBWithProperties(width
, height
);
103 currInd
= (currInd
+1)%4;
104 if (undoSteps
<3) undoSteps
++;
107 hdc
= CreateCompatibleDC(hDrawingDC
);
108 SelectObject(hdc
, hBms
[currInd
]);
110 oldPen
= SelectObject(hdc
, CreatePen(PS_SOLID
, 1, bgColor
));
111 oldBrush
= SelectObject(hdc
, CreateSolidBrush(bgColor
));
112 Rectangle(hdc
, 0, 0, width
, height
);
113 BitBlt(hdc
, -xOffset
, -yOffset
, imgXRes
, imgYRes
, hDrawingDC
, 0, 0, SRCCOPY
);
114 DeleteObject(SelectObject(hdc
, oldBrush
));
115 DeleteObject(SelectObject(hdc
, oldPen
));
117 SelectObject(hDrawingDC
, hBms
[currInd
]);
119 setImgXYRes(width
, height
);