ReactOS  0.4.15-dev-1397-g19779b3
CSelectionWindow Class Reference

#include <selection.h>

Inheritance diagram for CSelectionWindow:
Collaboration diagram for CSelectionWindow:

Public Member Functions

LRESULT OnPaint (UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnEraseBkgnd (UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnCreate (UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnSysColorChange (UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnSetCursor (UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnLButtonDown (UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnMouseMove (UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnLButtonUp (UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnPaletteModelColorChanged (UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnToolsModelSettingsChanged (UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnSelectionModelRefreshNeeded (UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnCaptureChanged (UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnKeyDown (UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 

Private Member Functions

int IdentifyCorner (int iXPos, int iYPos, int iWidth, int iHeight)
 

Private Attributes

BOOL m_bMoving
 
int m_iAction
 
POINT m_ptPos
 
POINT m_ptFrac
 
POINT m_ptDelta
 
DWORD m_dwSystemSelectionColor
 

Static Private Attributes

static const LPCTSTR m_lpszCursorLUT [9]
 

Detailed Description

Definition at line 12 of file selection.h.

Member Function Documentation

◆ IdentifyCorner()

int CSelectionWindow::IdentifyCorner ( int  iXPos,
int  iYPos,
int  iWidth,
int  iHeight 
)
private

Definition at line 66 of file selection.cpp.

67 {
68  if (iYPos < 3)
69  {
70  if (iXPos < 3)
72  if ((iXPos < iWidth / 2 + 2) && (iXPos >= iWidth / 2 - 1))
73  return ACTION_RESIZE_TOP;
74  if (iXPos >= iWidth - 3)
76  }
77  if ((iYPos < iHeight / 2 + 2) && (iYPos >= iHeight / 2 - 1))
78  {
79  if (iXPos < 3)
80  return ACTION_RESIZE_LEFT;
81  if (iXPos >= iWidth - 3)
82  return ACTION_RESIZE_RIGHT;
83  }
84  if (iYPos >= iHeight - 3)
85  {
86  if (iXPos < 3)
88  if ((iXPos < iWidth / 2 + 2) && (iXPos >= iWidth / 2 - 1))
89  return ACTION_RESIZE_BOTTOM;
90  if (iXPos >= iWidth - 3)
92  }
93  return 0;
94 }
#define ACTION_RESIZE_TOP_LEFT
#define ACTION_RESIZE_RIGHT
#define ACTION_RESIZE_BOTTOM_LEFT
#define ACTION_RESIZE_TOP_RIGHT
#define ACTION_RESIZE_TOP
#define ACTION_RESIZE_LEFT
#define ACTION_RESIZE_BOTTOM
#define ACTION_RESIZE_BOTTOM_RIGHT

Referenced by OnMouseMove().

◆ OnCaptureChanged()

LRESULT CSelectionWindow::OnCaptureChanged ( UINT  nMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)

Definition at line 236 of file selection.cpp.

237 {
238  if (m_bMoving)
239  {
240  m_bMoving = FALSE;
241  if (m_iAction == ACTION_MOVE)
242  {
243  // FIXME: dirty hack
244  placeSelWin();
245  imageModel.Undo();
246  imageModel.Undo();
247  }
248  else
249  {
251  }
253  }
254  return 0;
255 }
#define SW_HIDE
Definition: winuser.h:762
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define FALSE
Definition: types.h:117
#define ACTION_MOVE
void placeSelWin()
Definition: mouse.cpp:16
ImageModel imageModel
Definition: main.cpp:32
void Undo(void)
Definition: history.cpp:57

◆ OnCreate()

LRESULT CSelectionWindow::OnCreate ( UINT  nMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)

Definition at line 116 of file selection.cpp.

117 {
118  m_bMoving = FALSE;
120  /* update the system selection color */
122  SendMessage(WM_PAINT, 0, MAKELPARAM(0, 0));
123  return 0;
124 }
#define COLOR_HIGHLIGHT
Definition: winuser.h:916
#define MAKELPARAM(l, h)
Definition: winuser.h:3983
DWORD m_dwSystemSelectionColor
Definition: selection.h:54
DWORD WINAPI GetSysColor(_In_ int)
#define FALSE
Definition: types.h:117
#define ACTION_MOVE
#define WM_PAINT
Definition: winuser.h:1602
#define SendMessage
Definition: winuser.h:5818

◆ OnEraseBkgnd()

LRESULT CSelectionWindow::OnEraseBkgnd ( UINT  nMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)

Definition at line 110 of file selection.cpp.

111 {
112  // do nothing => transparent background
113  return 0;
114 }

◆ OnKeyDown()

LRESULT CSelectionWindow::OnKeyDown ( UINT  nMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)

Definition at line 257 of file selection.cpp.

258 {
259  if (wParam == VK_ESCAPE)
260  {
261  if (GetCapture() == m_hWnd)
262  {
263  ReleaseCapture();
264  }
265  }
266  return 0;
267 }
#define VK_ESCAPE
Definition: winuser.h:2189
WPARAM wParam
Definition: combotst.c:138
HWND WINAPI GetCapture(void)
Definition: message.c:2880
BOOL WINAPI ReleaseCapture(void)
Definition: message.c:2889

◆ OnLButtonDown()

LRESULT CSelectionWindow::OnLButtonDown ( UINT  nMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)

Definition at line 140 of file selection.cpp.

141 {
144  m_ptDelta.x = 0;
145  m_ptDelta.y = 0;
146  SetCapture();
147  if (m_iAction != ACTION_MOVE)
149  m_bMoving = TRUE;
150  scrlClientWindow.InvalidateRect(NULL, TRUE);
151  scrlClientWindow.SendMessage(WM_PAINT, 0, 0);
154  return 0;
155 }
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
#define TRUE
Definition: types.h:120
#define GET_X_LPARAM(lp)
Definition: windowsx.h:274
BOOL InvalidateRect(LPCRECT lpRect, BOOL bErase=TRUE)
Definition: atlwin.h:834
CImgAreaWindow imageArea
Definition: main.cpp:72
#define FALSE
Definition: types.h:117
CScrollboxWindow scrlClientWindow
Definition: main.cpp:70
#define ACTION_MOVE
#define WM_PAINT
Definition: winuser.h:1602
#define LoadCursor
Definition: winuser.h:5787
HWND WINAPI SetCapture(_In_ HWND hWnd)
HCURSOR WINAPI SetCursor(_In_opt_ HCURSOR)
#define NULL
Definition: types.h:112
#define GET_Y_LPARAM(lp)
Definition: windowsx.h:275
static const LPCTSTR m_lpszCursorLUT[9]
Definition: selection.h:48
LRESULT SendMessage(UINT message, WPARAM wParam=0, LPARAM lParam=0)
Definition: atlwin.h:1048
LPARAM lParam
Definition: combotst.c:139

◆ OnLButtonUp()

LRESULT CSelectionWindow::OnLButtonUp ( UINT  nMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)

Definition at line 212 of file selection.cpp.

213 {
214  if (m_bMoving)
215  {
216  m_bMoving = FALSE;
217  ReleaseCapture();
218  if (m_iAction != ACTION_MOVE)
219  {
221  {
222  // FIXME: What to do?
223  }
224  else
225  {
227  }
228  }
229  placeSelWin();
232  }
233  return 0;
234 }
ToolsModel toolsModel
Definition: main.cpp:18
#define TOOL_TEXT
Definition: definitions.h:144
#define SW_HIDE
Definition: winuser.h:762
SelectionModel selectionModel
Definition: main.cpp:20
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define FALSE
Definition: types.h:117
#define SW_SHOW
Definition: winuser.h:769
#define ACTION_MOVE
void placeSelWin()
Definition: mouse.cpp:16
int GetActiveTool()
Definition: toolsmodel.cpp:60
BOOL WINAPI ReleaseCapture(void)
Definition: message.c:2889

◆ OnMouseMove()

LRESULT CSelectionWindow::OnMouseMove ( UINT  nMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)

Definition at line 157 of file selection.cpp.

158 {
159  if (m_bMoving)
160  {
164  m_ptDelta.x += m_ptFrac.x * 1000 / toolsModel.GetZoom();
165  m_ptDelta.y += m_ptFrac.y * 1000 / toolsModel.GetZoom();
166  if (toolsModel.GetZoom() < 1000)
167  {
168  m_ptFrac.x = 0;
169  m_ptFrac.y = 0;
170  }
171  else
172  {
173  m_ptFrac.x -= (m_ptFrac.x * 1000 / toolsModel.GetZoom()) * toolsModel.GetZoom() / 1000;
174  m_ptFrac.y -= (m_ptFrac.y * 1000 / toolsModel.GetZoom()) * toolsModel.GetZoom() / 1000;
175  }
177 
178  CString strSize;
180  SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) (LPCTSTR) strSize);
181 
183  {
185  }
186  else
187  {
188  if (m_iAction != ACTION_MOVE)
190  else
192  }
197  }
198  else
199  {
200  int w = selectionModel.GetDestRectWidth() * toolsModel.GetZoom() / 1000 + 6;
201  int h = selectionModel.GetDestRectHeight() * toolsModel.GetZoom() / 1000 + 6;
206  if (m_iAction != ACTION_MOVE)
208  }
209  return 0;
210 }
void DrawSelectionStretched(HDC hDCImage)
ToolsModel toolsModel
Definition: main.cpp:18
const CHAR * LPCTSTR
Definition: xmlstorage.h:193
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
long y
Definition: polytest.cpp:48
#define TOOL_TEXT
Definition: definitions.h:144
long x
Definition: polytest.cpp:48
#define GET_X_LPARAM(lp)
Definition: windowsx.h:274
void __cdecl Format(UINT nFormatID,...)
Definition: cstringt.h:716
SelectionModel selectionModel
Definition: main.cpp:20
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
int GetZoom()
Definition: toolsmodel.cpp:104
BOOL InvalidateRect(LPCRECT lpRect, BOOL bErase=TRUE)
Definition: atlwin.h:834
CImgAreaWindow imageArea
Definition: main.cpp:72
#define FALSE
Definition: types.h:117
HDC GetDC()
Definition: history.cpp:218
LONG_PTR LPARAM
Definition: windef.h:208
BOOL IsBackgroundTransparent()
Definition: toolsmodel.cpp:93
void ModifyDestRect(POINT &ptDelta, int iAction)
#define _T(x)
Definition: vfdio.h:22
#define ACTION_MOVE
HWND hStatusBar
Definition: main.cpp:35
#define WM_PAINT
Definition: winuser.h:1602
#define SB_SETTEXT
Definition: commctrl.h:1945
ImageModel imageModel
Definition: main.cpp:32
#define LoadCursor
Definition: winuser.h:5787
PaletteModel paletteModel
Definition: main.cpp:28
HCURSOR WINAPI SetCursor(_In_opt_ HCURSOR)
int GetActiveTool()
Definition: toolsmodel.cpp:60
#define NULL
Definition: types.h:112
void DrawSelection(HDC hDCImage, COLORREF crBg=0, BOOL bBgTransparent=FALSE)
#define GET_Y_LPARAM(lp)
Definition: windowsx.h:275
static const LPCTSTR m_lpszCursorLUT[9]
Definition: selection.h:48
int IdentifyCorner(int iXPos, int iYPos, int iWidth, int iHeight)
Definition: selection.cpp:66
#define SendMessage
Definition: winuser.h:5818
LRESULT SendMessage(UINT message, WPARAM wParam=0, LPARAM lParam=0)
Definition: atlwin.h:1048
void DrawTextToolText(HDC hDCImage, COLORREF crFg, COLORREF crBg, BOOL bBgTransparent=FALSE)
void ResetToPrevious(void)
Definition: history.cpp:93
LPARAM lParam
Definition: combotst.c:139

◆ OnPaint()

LRESULT CSelectionWindow::OnPaint ( UINT  nMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)

Definition at line 96 of file selection.cpp.

97 {
98  if (!m_bMoving)
99  {
100  HDC hDC = GetDC();
105  ReleaseDC(hDC);
106  }
107  return 0;
108 }
ToolsModel toolsModel
Definition: main.cpp:18
HDC WINAPI GetDC(_In_opt_ HWND)
static HDC
Definition: imagelist.c:92
SelectionModel selectionModel
Definition: main.cpp:20
DWORD m_dwSystemSelectionColor
Definition: selection.h:54
WPARAM wParam
Definition: combotst.c:138
int GetZoom()
Definition: toolsmodel.cpp:104
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define DefWindowProc
Definition: ros2win.h:31
#define WM_PAINT
Definition: winuser.h:1602
static HDC hDC
Definition: 3dtext.c:33
LPARAM lParam
Definition: combotst.c:139
void SelectionFrame(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, DWORD system_selection_color)
Definition: drawing.cpp:249

◆ OnPaletteModelColorChanged()

LRESULT CSelectionWindow::OnPaletteModelColorChanged ( UINT  nMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)

Definition at line 269 of file selection.cpp.

270 {
273  return 0;
274 }
ToolsModel toolsModel
Definition: main.cpp:18
#define TOOL_TEXT
Definition: definitions.h:144
void ForceRefreshSelectionContents()
Definition: selection.cpp:56
int GetActiveTool()
Definition: toolsmodel.cpp:60

◆ OnSelectionModelRefreshNeeded()

LRESULT CSelectionWindow::OnSelectionModelRefreshNeeded ( UINT  nMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)

Definition at line 285 of file selection.cpp.

286 {
288  return 0;
289 }
void ForceRefreshSelectionContents()
Definition: selection.cpp:56

◆ OnSetCursor()

LRESULT CSelectionWindow::OnSetCursor ( UINT  nMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)

Definition at line 134 of file selection.cpp.

135 {
137  return 0;
138 }
#define LoadCursor
Definition: winuser.h:5787
HCURSOR WINAPI SetCursor(_In_opt_ HCURSOR)
#define IDC_SIZEALL
Definition: winuser.h:691
#define NULL
Definition: types.h:112

◆ OnSysColorChange()

LRESULT CSelectionWindow::OnSysColorChange ( UINT  nMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)

Definition at line 126 of file selection.cpp.

127 {
128  /* update the system selection color */
130  SendMessage(WM_PAINT, 0, MAKELPARAM(0, 0));
131  return 0;
132 }
#define COLOR_HIGHLIGHT
Definition: winuser.h:916
#define MAKELPARAM(l, h)
Definition: winuser.h:3983
DWORD m_dwSystemSelectionColor
Definition: selection.h:54
DWORD WINAPI GetSysColor(_In_ int)
#define WM_PAINT
Definition: winuser.h:1602
#define SendMessage
Definition: winuser.h:5818

◆ OnToolsModelSettingsChanged()

LRESULT CSelectionWindow::OnToolsModelSettingsChanged ( UINT  nMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)

Definition at line 276 of file selection.cpp.

277 {
282  return 0;
283 }
ToolsModel toolsModel
Definition: main.cpp:18
#define TOOL_TEXT
Definition: definitions.h:144
#define TOOL_FREESEL
Definition: definitions.h:135
#define TOOL_RECTSEL
Definition: definitions.h:136
void ForceRefreshSelectionContents()
Definition: selection.cpp:56
int GetActiveTool()
Definition: toolsmodel.cpp:60

Member Data Documentation

◆ m_bMoving

BOOL CSelectionWindow::m_bMoving
private

Definition at line 49 of file selection.h.

Referenced by OnCaptureChanged(), OnCreate(), OnLButtonDown(), OnLButtonUp(), OnMouseMove(), and OnPaint().

◆ m_dwSystemSelectionColor

DWORD CSelectionWindow::m_dwSystemSelectionColor
private

Definition at line 54 of file selection.h.

Referenced by OnCreate(), OnPaint(), and OnSysColorChange().

◆ m_iAction

int CSelectionWindow::m_iAction
private

Definition at line 50 of file selection.h.

Referenced by OnCaptureChanged(), OnCreate(), OnLButtonDown(), OnLButtonUp(), and OnMouseMove().

◆ m_lpszCursorLUT

const LPCTSTR CSelectionWindow::m_lpszCursorLUT
staticprivate

◆ m_ptDelta

POINT CSelectionWindow::m_ptDelta
private

Definition at line 53 of file selection.h.

Referenced by OnLButtonDown(), and OnMouseMove().

◆ m_ptFrac

POINT CSelectionWindow::m_ptFrac
private

Definition at line 52 of file selection.h.

Referenced by OnMouseMove().

◆ m_ptPos

POINT CSelectionWindow::m_ptPos
private

Definition at line 51 of file selection.h.

Referenced by OnLButtonDown(), and OnMouseMove().


The documentation for this class was generated from the following files: