ReactOS  0.4.13-dev-563-g0561610
CSizeboxWindow Class Reference

#include <sizebox.h>

Inheritance diagram for CSizeboxWindow:
Collaboration diagram for CSizeboxWindow:

Public Member Functions

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 OnCaptureChanged (UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnKeyDown (UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 

Detailed Description

Definition at line 12 of file sizebox.h.

Member Function Documentation

◆ OnCaptureChanged()

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

Definition at line 107 of file sizebox.cpp.

108 {
109  resizing = FALSE;
110  return 0;
111 }
static BOOL resizing
Definition: sizebox.cpp:16

◆ OnKeyDown()

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

Definition at line 113 of file sizebox.cpp.

114 {
115  if (wParam == VK_ESCAPE)
116  {
117  if (GetCapture() == m_hWnd)
118  {
119  ReleaseCapture();
120  }
121  }
122  return 0;
123 }
#define VK_ESCAPE
Definition: winuser.h:2168
WPARAM wParam
Definition: combotst.c:138
HWND WINAPI GetCapture(void)
Definition: message.c:2879
BOOL WINAPI ReleaseCapture(void)
Definition: message.c:2888

◆ OnLButtonDown()

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

Definition at line 33 of file sizebox.cpp.

34 {
35  resizing = TRUE;
38  SetCapture();
39  return 0;
40 }
#define TRUE
Definition: types.h:120
#define GET_X_LPARAM(lp)
Definition: windowsx.h:274
static BOOL resizing
Definition: sizebox.cpp:16
static short yOrig
Definition: sizebox.cpp:18
static short xOrig
Definition: sizebox.cpp:17
HWND WINAPI SetCapture(_In_ HWND hWnd)
#define GET_Y_LPARAM(lp)
Definition: windowsx.h:275
LPARAM lParam
Definition: combotst.c:139

◆ OnLButtonUp()

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

Definition at line 74 of file sizebox.cpp.

75 {
76  if (resizing)
77  {
78  short xRel;
79  short yRel;
80  int imgXRes = imageModel.GetWidth();
81  int imgYRes = imageModel.GetHeight();
82  xRel = (GET_X_LPARAM(lParam) - xOrig) * 1000 / toolsModel.GetZoom();
83  yRel = (GET_Y_LPARAM(lParam) - yOrig) * 1000 / toolsModel.GetZoom();
84  if (m_hWnd == sizeboxLeftTop)
85  imageModel.Crop(imgXRes - xRel, imgYRes - yRel, xRel, yRel);
86  if (m_hWnd == sizeboxCenterTop.m_hWnd)
87  imageModel.Crop(imgXRes, imgYRes - yRel, 0, yRel);
88  if (m_hWnd == sizeboxRightTop.m_hWnd)
89  imageModel.Crop(imgXRes + xRel, imgYRes - yRel, 0, yRel);
90  if (m_hWnd == sizeboxLeftCenter.m_hWnd)
91  imageModel.Crop(imgXRes - xRel, imgYRes, xRel, 0);
92  if (m_hWnd == sizeboxRightCenter.m_hWnd)
93  imageModel.Crop(imgXRes + xRel, imgYRes, 0, 0);
94  if (m_hWnd == sizeboxLeftBottom.m_hWnd)
95  imageModel.Crop(imgXRes - xRel, imgYRes + yRel, xRel, 0);
96  if (m_hWnd == sizeboxCenterBottom.m_hWnd)
97  imageModel.Crop(imgXRes, imgYRes + yRel, 0, 0);
98  if (m_hWnd == sizeboxRightBottom.m_hWnd)
99  imageModel.Crop(imgXRes + xRel, imgYRes + yRel, 0, 0);
101  }
102  resizing = FALSE;
103  ReleaseCapture();
104  return 0;
105 }
ToolsModel toolsModel
Definition: main.cpp:18
#define GET_X_LPARAM(lp)
Definition: windowsx.h:274
CSizeboxWindow sizeboxRightCenter
Definition: main.cpp:76
int GetZoom()
Definition: toolsmodel.cpp:104
void Crop(int nWidth, int nHeight, int nOffsetX=0, int nOffsetY=0)
Definition: history.cpp:124
static BOOL resizing
Definition: sizebox.cpp:16
CSizeboxWindow sizeboxCenterTop
Definition: main.cpp:73
CSizeboxWindow sizeboxRightTop
Definition: main.cpp:74
CSizeboxWindow sizeboxCenterBottom
Definition: main.cpp:78
LONG_PTR LPARAM
Definition: windef.h:208
CSizeboxWindow sizeboxRightBottom
Definition: main.cpp:79
static short yOrig
Definition: sizebox.cpp:18
#define _T(x)
Definition: vfdio.h:22
HWND hStatusBar
Definition: main.cpp:35
int GetWidth()
Definition: history.cpp:195
int GetHeight()
Definition: history.cpp:200
#define SB_SETTEXT
Definition: commctrl.h:1921
CSizeboxWindow sizeboxLeftCenter
Definition: main.cpp:75
ImageModel imageModel
Definition: main.cpp:32
static short xOrig
Definition: sizebox.cpp:17
CSizeboxWindow sizeboxLeftBottom
Definition: main.cpp:77
#define GET_Y_LPARAM(lp)
Definition: windowsx.h:275
BOOL WINAPI ReleaseCapture(void)
Definition: message.c:2888
CSizeboxWindow sizeboxLeftTop
Definition: main.cpp:72
#define SendMessage
Definition: winuser.h:5709
LPARAM lParam
Definition: combotst.c:139

◆ OnMouseMove()

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

Definition at line 42 of file sizebox.cpp.

43 {
44  if (resizing)
45  {
46  CString strSize;
47  short xRel;
48  short yRel;
49  int imgXRes = imageModel.GetWidth();
50  int imgYRes = imageModel.GetHeight();
51  xRel = (GET_X_LPARAM(lParam) - xOrig) * 1000 / toolsModel.GetZoom();
52  yRel = (GET_Y_LPARAM(lParam) - yOrig) * 1000 / toolsModel.GetZoom();
53  if (m_hWnd == sizeboxLeftTop.m_hWnd)
54  strSize.Format(_T("%d x %d"), imgXRes - xRel, imgYRes - yRel);
55  if (m_hWnd == sizeboxCenterTop.m_hWnd)
56  strSize.Format(_T("%d x %d"), imgXRes, imgYRes - yRel);
57  if (m_hWnd == sizeboxRightTop.m_hWnd)
58  strSize.Format(_T("%d x %d"), imgXRes + xRel, imgYRes - yRel);
59  if (m_hWnd == sizeboxLeftCenter.m_hWnd)
60  strSize.Format(_T("%d x %d"), imgXRes - xRel, imgYRes);
61  if (m_hWnd == sizeboxRightCenter.m_hWnd)
62  strSize.Format(_T("%d x %d"), imgXRes + xRel, imgYRes);
63  if (m_hWnd == sizeboxLeftBottom.m_hWnd)
64  strSize.Format(_T("%d x %d"), imgXRes - xRel, imgYRes + yRel);
65  if (m_hWnd == sizeboxCenterBottom.m_hWnd)
66  strSize.Format(_T("%d x %d"), imgXRes, imgYRes + yRel);
67  if (m_hWnd == sizeboxRightBottom.m_hWnd)
68  strSize.Format(_T("%d x %d"), imgXRes + xRel, imgYRes + yRel);
70  }
71  return 0;
72 }
ToolsModel toolsModel
Definition: main.cpp:18
const CHAR * LPCTSTR
Definition: xmlstorage.h:193
#define GET_X_LPARAM(lp)
Definition: windowsx.h:274
CSizeboxWindow sizeboxRightCenter
Definition: main.cpp:76
void __cdecl Format(UINT nFormatID,...)
Definition: cstringt.h:668
int GetZoom()
Definition: toolsmodel.cpp:104
static BOOL resizing
Definition: sizebox.cpp:16
CSizeboxWindow sizeboxCenterTop
Definition: main.cpp:73
CSizeboxWindow sizeboxRightTop
Definition: main.cpp:74
CSizeboxWindow sizeboxCenterBottom
Definition: main.cpp:78
LONG_PTR LPARAM
Definition: windef.h:208
CSizeboxWindow sizeboxRightBottom
Definition: main.cpp:79
static short yOrig
Definition: sizebox.cpp:18
#define _T(x)
Definition: vfdio.h:22
HWND hStatusBar
Definition: main.cpp:35
int GetWidth()
Definition: history.cpp:195
int GetHeight()
Definition: history.cpp:200
#define SB_SETTEXT
Definition: commctrl.h:1921
CSizeboxWindow sizeboxLeftCenter
Definition: main.cpp:75
ImageModel imageModel
Definition: main.cpp:32
static short xOrig
Definition: sizebox.cpp:17
CSizeboxWindow sizeboxLeftBottom
Definition: main.cpp:77
#define GET_Y_LPARAM(lp)
Definition: windowsx.h:275
CSizeboxWindow sizeboxLeftTop
Definition: main.cpp:72
#define SendMessage
Definition: winuser.h:5709
LPARAM lParam
Definition: combotst.c:139

◆ OnSetCursor()

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

Definition at line 20 of file sizebox.cpp.

21 {
22  if ((m_hWnd == sizeboxLeftTop.m_hWnd) || (m_hWnd == sizeboxRightBottom.m_hWnd))
24  if ((m_hWnd == sizeboxLeftBottom.m_hWnd) || (m_hWnd == sizeboxRightTop.m_hWnd))
26  if ((m_hWnd == sizeboxLeftCenter.m_hWnd) || (m_hWnd == sizeboxRightCenter.m_hWnd))
28  if ((m_hWnd == sizeboxCenterTop.m_hWnd) || (m_hWnd == sizeboxCenterBottom.m_hWnd))
30  return 0;
31 }
#define IDC_SIZEWE
Definition: winuser.h:689
CSizeboxWindow sizeboxRightCenter
Definition: main.cpp:76
#define IDC_SIZENESW
Definition: winuser.h:688
#define IDC_SIZENS
Definition: winuser.h:690
CSizeboxWindow sizeboxCenterTop
Definition: main.cpp:73
CSizeboxWindow sizeboxRightTop
Definition: main.cpp:74
#define IDC_SIZENWSE
Definition: winuser.h:687
CSizeboxWindow sizeboxCenterBottom
Definition: main.cpp:78
smooth NULL
Definition: ftsmooth.c:416
CSizeboxWindow sizeboxRightBottom
Definition: main.cpp:79
CSizeboxWindow sizeboxLeftCenter
Definition: main.cpp:75
#define LoadCursor
Definition: winuser.h:5678
CSizeboxWindow sizeboxLeftBottom
Definition: main.cpp:77
HCURSOR WINAPI SetCursor(_In_opt_ HCURSOR)
CSizeboxWindow sizeboxLeftTop
Definition: main.cpp:72

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