ReactOS  0.4.15-dev-4616-g17e0e44
selection.cpp
Go to the documentation of this file.
1 /*
2  * PROJECT: PAINT for ReactOS
3  * LICENSE: LGPL
4  * FILE: base/applications/mspaint/selection.cpp
5  * PURPOSE: Window procedure of the selection window
6  * PROGRAMMERS: Benedikt Freisen
7  * Katayama Hirofumi MZ
8  */
9 
10 /* INCLUDES *********************************************************/
11 
12 #include "precomp.h"
13 
14 /* FUNCTIONS ********************************************************/
15 
16 const LPCTSTR CSelectionWindow::m_lpszCursorLUT[9] = { /* action to mouse cursor lookup table */
18 
22 };
23 
25 {
27  {
31  }
32 }
33 
34 int CSelectionWindow::IdentifyCorner(int iXPos, int iYPos, int iWidth, int iHeight)
35 {
36  POINT pt = { iXPos, iYPos };
38  if (hwndChild == sizeboxLeftTop)
40  if (hwndChild == sizeboxCenterTop)
41  return ACTION_RESIZE_TOP;
42  if (hwndChild == sizeboxRightTop)
44  if (hwndChild == sizeboxRightCenter)
45  return ACTION_RESIZE_RIGHT;
46  if (hwndChild == sizeboxLeftCenter)
47  return ACTION_RESIZE_LEFT;
48  if (hwndChild == sizeboxCenterBottom)
49  return ACTION_RESIZE_BOTTOM;
50  if (hwndChild == sizeboxRightBottom)
52  if (hwndChild == sizeboxLeftBottom)
54  return 0;
55 }
56 
58 {
59  PAINTSTRUCT ps;
60  HDC hDC = BeginPaint(&ps);
61  if (!m_bMoving)
62  {
63  SelectionFrame(hDC, 1, 1,
67  }
68  EndPaint(&ps);
69  return 0;
70 }
71 
73 {
74  // do nothing => transparent background
75  return TRUE;
76 }
77 
79 {
80  m_bMoving = FALSE;
82  /* update the system selection color */
83  Invalidate();
84  return 0;
85 }
86 
88 {
89  /* update the system selection color */
90  Invalidate();
91  return 0;
92 }
93 
95 {
97  return 0;
98 }
99 
101 {
104  m_ptDelta.x = 0;
105  m_ptDelta.y = 0;
106  SetCapture();
107  if (m_iAction != ACTION_MOVE)
109  m_bMoving = TRUE;
110  scrlClientWindow.InvalidateRect(NULL, TRUE);
111  scrlClientWindow.SendMessage(WM_PAINT, 0, 0);
115  return 0;
116 }
117 
119 {
120  if (m_bMoving)
121  {
128  if (toolsModel.GetZoom() < 1000)
129  {
130  m_ptFrac.x = 0;
131  m_ptFrac.y = 0;
132  }
133  else
134  {
137  }
139 
140  CString strSize;
142  SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) (LPCTSTR) strSize);
143 
144  if (m_iAction != ACTION_MOVE)
146  else
152  }
153  else
154  {
161  if (m_iAction != ACTION_MOVE)
163  }
164  return 0;
165 }
166 
168 {
169  m_bMoved = TRUE;
170  return 0;
171 }
172 
174 {
175  if (m_bMoving)
176  {
177  m_bMoving = FALSE;
178  ReleaseCapture();
180  {
181  imageModel.Undo();
185  }
186  placeSelWin();
187  }
188  return 0;
189 }
190 
192 {
193  if (m_bMoving)
194  {
195  m_bMoving = FALSE;
196  if (m_iAction == ACTION_MOVE)
197  {
200  else
201  placeSelWin();
202  }
203  else
204  {
206  }
208  }
209  return 0;
210 }
211 
213 {
214  if (wParam == VK_ESCAPE)
215  {
216  if (GetCapture() == m_hWnd)
217  {
218  ReleaseCapture();
219  }
220  }
221  return 0;
222 }
223 
225 {
226  return 0;
227 }
228 
230 {
231  return 0;
232 }
233 
235 {
237  return 0;
238 }
239 
241 {
243 }
244 
246 {
247  placeSelWin();
248  return 0;
249 }
#define IDC_SIZEWE
Definition: winuser.h:689
void DrawSelectionStretched(HDC hDCImage)
LRESULT OnLButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: selection.cpp:100
static int Zoomed(int xy)
Definition: common.h:37
ToolsModel toolsModel
Definition: main.cpp:18
void CopyPrevious(void)
Definition: history.cpp:47
const CHAR * LPCTSTR
Definition: xmlstorage.h:193
#define COLOR_HIGHLIGHT
Definition: winuser.h:920
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
long y
Definition: polytest.cpp:48
void placeSelWin(void)
Definition: mouse.cpp:20
long x
Definition: polytest.cpp:48
LRESULT OnToolsModelSettingsChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: selection.cpp:229
#define ACTION_RESIZE_TOP_LEFT
#define TRUE
Definition: types.h:120
#define pt(x, y)
Definition: drawing.c:79
#define SW_HIDE
Definition: winuser.h:762
COLORREF m_rgbBack
Definition: selection.h:70
LRESULT OnMouseWheel(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: selection.cpp:240
static HDC
Definition: imagelist.c:92
LRESULT OnSelectionModelRefreshNeeded(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: selection.cpp:234
#define GET_X_LPARAM(lp)
Definition: windowsx.h:274
LRESULT OnCaptureChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: selection.cpp:191
LRESULT OnMove(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: selection.cpp:167
CSizeboxWindow sizeboxRightCenter
Definition: main.cpp:77
void __cdecl Format(UINT nFormatID,...)
Definition: cstringt.h:753
#define ACTION_RESIZE_RIGHT
UINT_PTR WPARAM
Definition: windef.h:207
SelectionModel selectionModel
Definition: main.cpp:20
LRESULT OnToolsModelZoomChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: selection.cpp:245
LONG GetDestRectWidth() const
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
LRESULT OnLButtonUp(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: selection.cpp:173
#define VK_ESCAPE
Definition: winuser.h:2194
#define IDC_SIZENESW
Definition: winuser.h:688
DWORD WINAPI GetSysColor(_In_ int)
WPARAM wParam
Definition: combotst.c:138
COLORREF GetBgColor() const
#define IDC_SIZENS
Definition: winuser.h:690
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
BOOL InvalidateRect(LPCRECT lpRect, BOOL bErase=TRUE)
Definition: atlwin.h:868
CImgAreaWindow imageArea
Definition: main.cpp:72
LRESULT OnPaint(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: selection.cpp:57
#define ACTION_RESIZE_BOTTOM_LEFT
CSizeboxWindow sizeboxCenterTop
Definition: main.cpp:74
CSizeboxWindow sizeboxRightTop
Definition: main.cpp:75
#define IDC_SIZENWSE
Definition: winuser.h:687
CSizeboxWindow sizeboxCenterBottom
Definition: main.cpp:79
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
HDC GetDC()
Definition: history.cpp:239
#define CWP_SKIPINVISIBLE
Definition: winuser.h:208
HWND WINAPI GetCapture(void)
Definition: message.c:2881
#define CWP_SKIPDISABLED
Definition: winuser.h:209
LONG_PTR LPARAM
Definition: windef.h:208
CSizeboxWindow sizeboxRightBottom
Definition: main.cpp:80
#define ACTION_RESIZE_TOP_RIGHT
CScrollboxWindow scrlClientWindow
Definition: main.cpp:70
void ModifyDestRect(POINT &ptDelta, int iAction)
#define _T(x)
Definition: vfdio.h:22
#define ACTION_MOVE
void SelectionFrame(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF system_selection_color)
Definition: drawing.cpp:249
HWND hStatusBar
Definition: main.cpp:35
#define ACTION_RESIZE_TOP
LRESULT OnPaletteModelColorChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: selection.cpp:224
int GetZoom() const
Definition: toolsmodel.cpp:148
#define WM_PAINT
Definition: winuser.h:1607
HWND WINAPI ChildWindowFromPointEx(_In_ HWND, _In_ POINT, _In_ UINT)
#define ACTION_RESIZE_LEFT
TOOLTYPE GetActiveTool() const
Definition: toolsmodel.cpp:76
#define GRIP_SIZE
Definition: common.h:13
#define SB_SETTEXT
Definition: commctrl.h:1949
CSizeboxWindow sizeboxLeftCenter
Definition: main.cpp:76
ImageModel imageModel
Definition: main.cpp:32
#define LoadCursor
Definition: winuser.h:5792
void ForceRefreshSelectionContents()
Definition: selection.cpp:24
LONG GetDestRectHeight() const
static HDC hDC
Definition: 3dtext.c:33
LRESULT OnSysColorChange(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: selection.cpp:87
HWND WINAPI GetParent(_In_ HWND)
LRESULT OnKeyDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: selection.cpp:212
HWND WINAPI SetCapture(_In_ HWND hWnd)
CSizeboxWindow sizeboxLeftBottom
Definition: main.cpp:78
PaletteModel paletteModel
Definition: main.cpp:28
HCURSOR WINAPI SetCursor(_In_opt_ HCURSOR)
LRESULT OnEraseBkgnd(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: selection.cpp:72
#define IDC_SIZEALL
Definition: winuser.h:691
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
LRESULT OnCreate(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: selection.cpp:78
void DrawSelection(HDC hDCImage, COLORREF crBg=0, BOOL bBgTransparent=FALSE)
#define GET_Y_LPARAM(lp)
Definition: windowsx.h:275
void cancelDrawing()
Definition: imgarea.cpp:238
static const LPCTSTR m_lpszCursorLUT[9]
Definition: selection.h:63
int IdentifyCorner(int iXPos, int iYPos, int iWidth, int iHeight)
Definition: selection.cpp:34
void DrawSelectionBackground(COLORREF rgbBG)
Definition: history.cpp:285
BOOL WINAPI ReleaseCapture(void)
Definition: message.c:2890
CSizeboxWindow sizeboxLeftTop
Definition: main.cpp:73
#define SendMessage
Definition: winuser.h:5823
LRESULT SendMessage(UINT message, WPARAM wParam=0, LPARAM lParam=0)
Definition: atlwin.h:1082
BOOL WINAPI IsWindowVisible(_In_ HWND)
#define ACTION_RESIZE_BOTTOM
LONG_PTR LRESULT
Definition: windef.h:209
#define ACTION_RESIZE_BOTTOM_RIGHT
void Undo(BOOL bClearRedo=FALSE)
Definition: history.cpp:60
LRESULT OnMouseMove(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: selection.cpp:118
void ResetToPrevious(void)
Definition: history.cpp:100
LPARAM lParam
Definition: combotst.c:139
LRESULT OnSetCursor(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: selection.cpp:94
CSelectionWindow selectionWindow
Definition: main.cpp:71
BOOL IsBackgroundTransparent() const
Definition: toolsmodel.cpp:135
static int UnZoomed(int xy)
Definition: common.h:42