29b73eef67610e34baf6068615b2b1425ef460e5
2 * PROJECT: PAINT for ReactOS
4 * FILE: base/applications/mspaint/sizebox.cpp
5 * PURPOSE: Window procedure of the size boxes
6 * PROGRAMMERS: Benedikt Freisen
9 /* INCLUDES *********************************************************/
13 /* FUNCTIONS ********************************************************/
15 BOOL resizing
= FALSE
;
19 LRESULT
CSizeboxWindow::OnSetCursor(UINT nMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
)
21 if ((m_hWnd
== sizeboxLeftTop
.m_hWnd
) || (m_hWnd
== sizeboxRightBottom
.m_hWnd
))
22 SetCursor(LoadCursor(NULL
, IDC_SIZENWSE
));
23 if ((m_hWnd
== sizeboxLeftBottom
.m_hWnd
) || (m_hWnd
== sizeboxRightTop
.m_hWnd
))
24 SetCursor(LoadCursor(NULL
, IDC_SIZENESW
));
25 if ((m_hWnd
== sizeboxLeftCenter
.m_hWnd
) || (m_hWnd
== sizeboxRightCenter
.m_hWnd
))
26 SetCursor(LoadCursor(NULL
, IDC_SIZEWE
));
27 if ((m_hWnd
== sizeboxCenterTop
.m_hWnd
) || (m_hWnd
== sizeboxCenterBottom
.m_hWnd
))
28 SetCursor(LoadCursor(NULL
, IDC_SIZENS
));
32 LRESULT
CSizeboxWindow::OnLButtonDown(UINT nMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
)
35 xOrig
= GET_X_LPARAM(lParam
);
36 yOrig
= GET_Y_LPARAM(lParam
);
41 LRESULT
CSizeboxWindow::OnMouseMove(UINT nMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
)
48 int imgXRes
= imageModel
.GetWidth();
49 int imgYRes
= imageModel
.GetHeight();
50 xRel
= (GET_X_LPARAM(lParam
) - xOrig
) * 1000 / toolsModel
.GetZoom();
51 yRel
= (GET_Y_LPARAM(lParam
) - yOrig
) * 1000 / toolsModel
.GetZoom();
52 if (m_hWnd
== sizeboxLeftTop
.m_hWnd
)
53 _stprintf(sizeStr
, _T("%d x %d"), imgXRes
- xRel
, imgYRes
- yRel
);
54 if (m_hWnd
== sizeboxCenterTop
.m_hWnd
)
55 _stprintf(sizeStr
, _T("%d x %d"), imgXRes
, imgYRes
- yRel
);
56 if (m_hWnd
== sizeboxRightTop
.m_hWnd
)
57 _stprintf(sizeStr
, _T("%d x %d"), imgXRes
+ xRel
, imgYRes
- yRel
);
58 if (m_hWnd
== sizeboxLeftCenter
.m_hWnd
)
59 _stprintf(sizeStr
, _T("%d x %d"), imgXRes
- xRel
, imgYRes
);
60 if (m_hWnd
== sizeboxRightCenter
.m_hWnd
)
61 _stprintf(sizeStr
, _T("%d x %d"), imgXRes
+ xRel
, imgYRes
);
62 if (m_hWnd
== sizeboxLeftBottom
.m_hWnd
)
63 _stprintf(sizeStr
, _T("%d x %d"), imgXRes
- xRel
, imgYRes
+ yRel
);
64 if (m_hWnd
== sizeboxCenterBottom
.m_hWnd
)
65 _stprintf(sizeStr
, _T("%d x %d"), imgXRes
, imgYRes
+ yRel
);
66 if (m_hWnd
== sizeboxRightBottom
.m_hWnd
)
67 _stprintf(sizeStr
, _T("%d x %d"), imgXRes
+ xRel
, imgYRes
+ yRel
);
68 SendMessage(hStatusBar
, SB_SETTEXT
, 2, (LPARAM
) sizeStr
);
73 LRESULT
CSizeboxWindow::OnLButtonUp(UINT nMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
)
81 int imgXRes
= imageModel
.GetWidth();
82 int imgYRes
= imageModel
.GetHeight();
83 xRel
= (GET_X_LPARAM(lParam
) - xOrig
) * 1000 / toolsModel
.GetZoom();
84 yRel
= (GET_Y_LPARAM(lParam
) - yOrig
) * 1000 / toolsModel
.GetZoom();
85 if (m_hWnd
== sizeboxLeftTop
)
86 imageModel
.Crop(imgXRes
- xRel
, imgYRes
- yRel
, xRel
, yRel
);
87 if (m_hWnd
== sizeboxCenterTop
.m_hWnd
)
88 imageModel
.Crop(imgXRes
, imgYRes
- yRel
, 0, yRel
);
89 if (m_hWnd
== sizeboxRightTop
.m_hWnd
)
90 imageModel
.Crop(imgXRes
+ xRel
, imgYRes
- yRel
, 0, yRel
);
91 if (m_hWnd
== sizeboxLeftCenter
.m_hWnd
)
92 imageModel
.Crop(imgXRes
- xRel
, imgYRes
, xRel
, 0);
93 if (m_hWnd
== sizeboxRightCenter
.m_hWnd
)
94 imageModel
.Crop(imgXRes
+ xRel
, imgYRes
, 0, 0);
95 if (m_hWnd
== sizeboxLeftBottom
.m_hWnd
)
96 imageModel
.Crop(imgXRes
- xRel
, imgYRes
+ yRel
, xRel
, 0);
97 if (m_hWnd
== sizeboxCenterBottom
.m_hWnd
)
98 imageModel
.Crop(imgXRes
, imgYRes
+ yRel
, 0, 0);
99 if (m_hWnd
== sizeboxRightBottom
.m_hWnd
)
100 imageModel
.Crop(imgXRes
+ xRel
, imgYRes
+ yRel
, 0, 0);
101 SendMessage(hStatusBar
, SB_SETTEXT
, 2, (LPARAM
) _T(""));