extern BOOL showMiniature;
extern HWND hwndMiniature;
+
+extern HWND hSizeboxLeftTop;
+extern HWND hSizeboxCenterTop;
+extern HWND hSizeboxRightTop;
+extern HWND hSizeboxLeftCenter;
+extern HWND hSizeboxRightCenter;
+extern HWND hSizeboxLeftBottom;
+extern HWND hSizeboxCenterBottom;
+extern HWND hSizeboxRightBottom;
setImgXYRes(GetDIBWidth(hBms[currInd]), GetDIBHeight(hBms[currInd]));
}
-void cropReversible(int x, int y)//FIXME: This function is broken
+void cropReversible(int width, int height, int xOffset, int yOffset)
{
- HBITMAP oldBitmap;
+ HDC hdc;
HPEN oldPen;
HBRUSH oldBrush;
SelectObject(hDrawingDC, hBms[currInd]);
DeleteObject(hBms[(currInd+1)%4]);
- hBms[(currInd+1)%4] = CreateDIBWithProperties(x, y);
+ hBms[(currInd+1)%4] = CreateDIBWithProperties(width, height);
currInd = (currInd+1)%4;
if (undoSteps<3) undoSteps++;
redoSteps = 0;
- oldBitmap = SelectObject(hSelDC, hBms[currInd]);
- oldPen = SelectObject(hSelDC, CreatePen(PS_SOLID, 1, bgColor));
- oldBrush = SelectObject(hSelDC, CreateSolidBrush(bgColor));
- Rectangle(hSelDC, 0, 0, x, y);
- DeleteObject(SelectObject(hSelDC, oldBrush));
- DeleteObject(SelectObject(hSelDC, oldPen));
- BitBlt(hDrawingDC, 0, 0, imgXRes, imgYRes, hSelDC, 0, 0, SRCCOPY);
- SelectObject(hDrawingDC, SelectObject(hSelDC, oldBitmap));
+ hdc = CreateCompatibleDC(hDrawingDC);
+ SelectObject(hdc, hBms[currInd]);
- setImgXYRes(x, y);
+ oldPen = SelectObject(hdc, CreatePen(PS_SOLID, 1, bgColor));
+ oldBrush = SelectObject(hdc, CreateSolidBrush(bgColor));
+ Rectangle(hdc, 0, 0, width, height);
+ BitBlt(hdc, -xOffset, -yOffset, imgXRes, imgYRes, hDrawingDC, 0, 0, SRCCOPY);
+ DeleteObject(SelectObject(hdc, oldBrush));
+ DeleteObject(SelectObject(hdc, oldPen));
+ DeleteDC(hdc);
+ SelectObject(hDrawingDC, hBms[currInd]);
+
+ setImgXYRes(width, height);
}
void insertReversible();
-void cropReversible(int x, int y);
+void cropReversible(int width, int height, int xOffset, int yOffset);
#include "palette.h"
#include "toolsettings.h"
#include "selection.h"
+#include "sizebox.h"
/* FUNCTIONS ********************************************************/
HWND hwndMiniature;
+HWND hSizeboxLeftTop;
+HWND hSizeboxCenterTop;
+HWND hSizeboxRightTop;
+HWND hSizeboxLeftCenter;
+HWND hSizeboxRightCenter;
+HWND hSizeboxLeftBottom;
+HWND hSizeboxCenterBottom;
+HWND hSizeboxRightBottom;
+
int WINAPI _tWinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPTSTR lpszArgument, int nFunsterStil)
{
HWND hwnd; /* This is the handle for our window */
wclSelection.hbrBackground = NULL;//GetSysColorBrush(COLOR_BTNFACE);
RegisterClassEx (&wclSelection);
+ /* initializing and registering the window class for the size boxes */
+ wclSettings.hInstance = hThisInstance;
+ wclSettings.lpszClassName = _T("Sizebox");
+ wclSettings.lpfnWndProc = SizeboxWinProc;
+ wclSettings.style = CS_DBLCLKS;
+ wclSettings.cbSize = sizeof (WNDCLASSEX);
+ wclSettings.hIcon = NULL;
+ wclSettings.hIconSm = NULL;
+ wclSettings.hCursor = LoadCursor (NULL, IDC_ARROW);
+ wclSettings.lpszMenuName = NULL;
+ wclSettings.cbClsExtra = 0;
+ wclSettings.cbWndExtra = 0;
+ wclSettings.hbrBackground = GetSysColorBrush(COLOR_HIGHLIGHT);
+ RegisterClassEx (&wclSettings);
+
LoadString(hThisInstance, IDS_DEFAULTFILENAME, filename, SIZEOF(filename));
LoadString(hThisInstance, IDS_WINDOWTITLE, resstr, SIZEOF(resstr));
_stprintf(progtitle, resstr, filename);
sfn.nMaxFileTitle = SIZEOF(sfnFiletitle);
sfn.Flags = OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY;
+ hSizeboxLeftTop = CreateWindowEx(0, _T("Sizebox"), _T(""), WS_CHILD | WS_VISIBLE, 0, 0, 3, 3, hScrlClient, NULL, hThisInstance, NULL);
+ hSizeboxCenterTop = CreateWindowEx(0, _T("Sizebox"), _T(""), WS_CHILD | WS_VISIBLE, 0, 0, 3, 3, hScrlClient, NULL, hThisInstance, NULL);
+ hSizeboxRightTop = CreateWindowEx(0, _T("Sizebox"), _T(""), WS_CHILD | WS_VISIBLE, 0, 0, 3, 3, hScrlClient, NULL, hThisInstance, NULL);
+ hSizeboxLeftCenter = CreateWindowEx(0, _T("Sizebox"), _T(""), WS_CHILD | WS_VISIBLE, 0, 0, 3, 3, hScrlClient, NULL, hThisInstance, NULL);
+ hSizeboxRightCenter = CreateWindowEx(0, _T("Sizebox"), _T(""), WS_CHILD | WS_VISIBLE, 0, 0, 3, 3, hScrlClient, NULL, hThisInstance, NULL);
+ hSizeboxLeftBottom = CreateWindowEx(0, _T("Sizebox"), _T(""), WS_CHILD | WS_VISIBLE, 0, 0, 3, 3, hScrlClient, NULL, hThisInstance, NULL);
+ hSizeboxCenterBottom= CreateWindowEx(0, _T("Sizebox"), _T(""), WS_CHILD | WS_VISIBLE, 0, 0, 3, 3, hScrlClient, NULL, hThisInstance, NULL);
+ hSizeboxRightBottom = CreateWindowEx(0, _T("Sizebox"), _T(""), WS_CHILD | WS_VISIBLE, 0, 0, 3, 3, hScrlClient, NULL, hThisInstance, NULL);
+ SendMessage(hImageArea, WM_SIZE, 0, 0);
/* by moving the window, the things in WM_SIZE are done */
MoveWindow(hwnd, 100, 100, 600, 450, TRUE);
<file>palette.c</file>
<file>registry.c</file>
<file>selection.c</file>
+ <file>sizebox.c</file>
<file>toolsettings.c</file>
<file>winproc.c</file>
<file>rsrc.rc</file>
--- /dev/null
+/*
+ * PROJECT: PAINT for ReactOS
+ * LICENSE: LGPL
+ * FILE: sizebox.c
+ * PURPOSE: Window procedure of the size boxes
+ * PROGRAMMERS: Benedikt Freisen
+ */
+
+/* INCLUDES *********************************************************/
+
+#include <windows.h>
+#include "globalvar.h"
+#include "drawing.h"
+#include "history.h"
+#include "mouse.h"
+
+/* FUNCTIONS ********************************************************/
+
+BOOL resizing = FALSE;
+short xOrig;
+short yOrig;
+
+LRESULT CALLBACK SizeboxWinProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ switch (message)
+ {
+ case WM_SETCURSOR:
+ {
+ if ((hwnd==hSizeboxLeftTop)||(hwnd==hSizeboxRightBottom))
+ SetCursor(LoadCursor(NULL, IDC_SIZENWSE));
+ if ((hwnd==hSizeboxLeftBottom)||(hwnd==hSizeboxRightTop))
+ SetCursor(LoadCursor(NULL, IDC_SIZENESW));
+ if ((hwnd==hSizeboxLeftCenter)||(hwnd==hSizeboxRightCenter))
+ SetCursor(LoadCursor(NULL, IDC_SIZEWE));
+ if ((hwnd==hSizeboxCenterTop)||(hwnd==hSizeboxCenterBottom))
+ SetCursor(LoadCursor(NULL, IDC_SIZENS));
+ }
+ break;
+ case WM_LBUTTONDOWN:
+ resizing = TRUE;
+ xOrig = LOWORD(lParam);
+ yOrig = HIWORD(lParam);
+ SetCapture(hwnd);
+ break;
+ case WM_MOUSEMOVE:
+ // TODO: print things in the status bar
+ break;
+ case WM_LBUTTONUP:
+ if (resizing)
+ {
+ short xRel;
+ short yRel;
+ ReleaseCapture();
+ resizing = FALSE;
+ xRel = ((short)LOWORD(lParam)-xOrig)*1000/zoom;
+ yRel = ((short)HIWORD(lParam)-yOrig)*1000/zoom;
+ if (hwnd==hSizeboxLeftTop)
+ cropReversible(imgXRes-xRel, imgYRes-yRel, xRel, yRel);
+ if (hwnd==hSizeboxCenterTop)
+ cropReversible(imgXRes, imgYRes-yRel, 0, yRel);
+ if (hwnd==hSizeboxRightTop)
+ cropReversible(imgXRes+xRel, imgYRes-yRel, 0, yRel);
+ if (hwnd==hSizeboxLeftCenter)
+ cropReversible(imgXRes-xRel, imgYRes, xRel, 0);
+ if (hwnd==hSizeboxRightCenter)
+ cropReversible(imgXRes+xRel, imgYRes, 0, 0);
+ if (hwnd==hSizeboxLeftBottom)
+ cropReversible(imgXRes-xRel, imgYRes+yRel, xRel, 0);
+ if (hwnd==hSizeboxCenterBottom)
+ cropReversible(imgXRes, imgYRes+yRel, 0, 0);
+ if (hwnd==hSizeboxRightBottom)
+ cropReversible(imgXRes+xRel, imgYRes+yRel, 0, 0);
+ }
+ break;
+
+ default:
+ return DefWindowProc (hwnd, message, wParam, lParam);
+ }
+
+ return 0;
+}
--- /dev/null
+/*
+ * PROJECT: PAINT for ReactOS
+ * LICENSE: LGPL
+ * FILE: sizebox.h
+ * PURPOSE: Window procedure of the size boxes
+ * PROGRAMMERS: Benedikt Freisen
+ */
+
+LRESULT CALLBACK SizeboxWinProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
MoveWindow(hScrollbox, 56, 49,LOWORD(lParam)-56, HIWORD(lParam)-72, TRUE);
//InvalidateRect(hwnd, NULL, TRUE);
}
+ if (hwnd==hImageArea)
+ {
+ MoveWindow(hSizeboxLeftTop,
+ 0,
+ 0, 3, 3, TRUE);
+ MoveWindow(hSizeboxCenterTop,
+ imgXRes*zoom/2000+3*3/4,
+ 0, 3, 3, TRUE);
+ MoveWindow(hSizeboxRightTop,
+ imgXRes*zoom/1000+3,
+ 0, 3, 3, TRUE);
+ MoveWindow(hSizeboxLeftCenter,
+ 0,
+ imgYRes*zoom/2000+3*3/4, 3, 3, TRUE);
+ MoveWindow(hSizeboxRightCenter,
+ imgXRes*zoom/1000+3,
+ imgYRes*zoom/2000+3*3/4, 3, 3, TRUE);
+ MoveWindow(hSizeboxLeftBottom,
+ 0,
+ imgYRes*zoom/1000+3, 3, 3, TRUE);
+ MoveWindow(hSizeboxCenterBottom,
+ imgXRes*zoom/2000+3*3/4,
+ imgYRes*zoom/1000+3, 3, 3, TRUE);
+ MoveWindow(hSizeboxRightBottom,
+ imgXRes*zoom/1000+3,
+ imgYRes*zoom/1000+3, 3, 3, TRUE);
+ }
if ((hwnd==hImageArea)||(hwnd==hScrollbox))
{
long clientRectScrollbox[4];
long mclient[4];
GetClientRect(hwndMiniature, (LPRECT)&mclient);
HDC hdc = GetDC(hwndMiniature);
- BitBlt(hdc, 0, 0, imgXRes, imgYRes, hDrawingDC, min(imgXRes*GetScrollPos(hScrollbox, SB_HORZ)/10000, imgXRes-mclient[2]),
- min(imgYRes*GetScrollPos(hScrollbox, SB_VERT)/10000, imgYRes-mclient[3]), SRCCOPY);
+ BitBlt(hdc, -min(imgXRes*GetScrollPos(hScrollbox, SB_HORZ)/10000, imgXRes-mclient[2]),
+ -min(imgYRes*GetScrollPos(hScrollbox, SB_VERT)/10000, imgYRes-mclient[3]), imgXRes, imgYRes, hDrawingDC, 0, 0, SRCCOPY);
ReleaseDC(hwndMiniature, hdc);
}
break;
int retVal = attributesDlg();
if ((LOWORD(retVal)!=0)&&(HIWORD(retVal)!=0))
{
- // cropReversible broken, dirty hack:
- // insertReversible(CopyImage(hBms[currInd], IMAGE_BITMAP, LOWORD(retVal), HIWORD(retVal), 0));
- cropReversible(LOWORD(retVal), HIWORD(retVal));
+ cropReversible(LOWORD(retVal), HIWORD(retVal), 0, 0);
updateCanvasAndScrollbars();
}
}