ReactOS  0.4.15-dev-1638-gc0caa5c
SelectionModel Class Reference

#include <selectionmodel.h>

Collaboration diagram for SelectionModel:

Public Member Functions

 SelectionModel ()
 
 ~SelectionModel ()
 
void ResetPtStack ()
 
void PushToPtStack (LONG x, LONG y)
 
void CalculateBoundingBoxAndContents (HDC hDCImage)
 
void CalculateContents (HDC hDCImage)
 
void DrawBackgroundPoly (HDC hDCImage, COLORREF crBg)
 
void DrawBackgroundRect (HDC hDCImage, COLORREF crBg)
 
void DrawSelection (HDC hDCImage, COLORREF crBg=0, BOOL bBgTransparent=FALSE)
 
void DrawSelectionStretched (HDC hDCImage)
 
void ScaleContentsToFit ()
 
void InsertFromHBITMAP (HBITMAP hBm)
 
void FlipHorizontally ()
 
void FlipVertically ()
 
void RotateNTimes90Degrees (int iN)
 
HBITMAP GetBitmap ()
 
int PtStackSize ()
 
void DrawFramePoly (HDC hDCImage)
 
void SetSrcAndDestRectFromPoints (const POINT &ptFrom, const POINT &ptTo)
 
void SetSrcRectSizeToZero ()
 
BOOL IsSrcRectSizeNonzero ()
 
void ModifyDestRect (POINT &ptDelta, int iAction)
 
LONG GetDestRectWidth ()
 
LONG GetDestRectHeight ()
 
LONG GetDestRectLeft ()
 
LONG GetDestRectTop ()
 
void DrawTextToolText (HDC hDCImage, COLORREF crFg, COLORREF crBg, BOOL bBgTransparent=FALSE)
 

Private Member Functions

void NotifyRefreshNeeded ()
 
 SelectionModel (const SelectionModel &)
 
SelectionModeloperator= (const SelectionModel &)
 

Private Attributes

HDC m_hDC
 
RECT m_rcSrc
 
RECT m_rcDest
 
HBITMAP m_hBm
 
HBITMAP m_hMask
 
POINTm_ptStack
 
int m_iPtSP
 

Detailed Description

Definition at line 26 of file selectionmodel.h.

Constructor & Destructor Documentation

◆ SelectionModel() [1/2]

SelectionModel::SelectionModel ( )

Definition at line 16 of file selectionmodel.cpp.

18  , m_hBm(NULL)
19  , m_hMask(NULL)
20  , m_ptStack(NULL)
21  , m_iPtSP(0)
22 {
25 }
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
BOOL WINAPI SetRectEmpty(_Out_ LPRECT)
#define NULL
Definition: types.h:112

◆ ~SelectionModel()

SelectionModel::~SelectionModel ( )

Definition at line 27 of file selectionmodel.cpp.

28 {
29  DeleteDC(m_hDC);
30  ResetPtStack();
31  if (m_hBm)
32  {
34  }
35  if (m_hMask)
36  {
38  }
39 }
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
BOOL WINAPI DeleteDC(_In_ HDC)

◆ SelectionModel() [2/2]

SelectionModel::SelectionModel ( const SelectionModel )
private

Member Function Documentation

◆ CalculateBoundingBoxAndContents()

void SelectionModel::CalculateBoundingBoxAndContents ( HDC  hDCImage)

Definition at line 63 of file selectionmodel.cpp.

64 {
65  int i;
68  for (i = 0; i < m_iPtSP; i++)
69  {
70  if (m_ptStack[i].x < m_rcSrc.left)
72  if (m_ptStack[i].y < m_rcSrc.top)
73  m_rcSrc.top = m_ptStack[i].y;
74  if (m_ptStack[i].x > m_rcSrc.right)
76  if (m_ptStack[i].y > m_rcSrc.bottom)
78  }
79  m_rcSrc.right += 1;
80  m_rcSrc.bottom += 1;
85 
86  if (m_iPtSP > 1)
87  {
91  POINT *m_ptStackCopy = (POINT*) HeapAlloc(GetProcessHeap(), HEAP_GENERATE_EXCEPTIONS, sizeof(POINT) * m_iPtSP);
92  for (i = 0; i < m_iPtSP; i++)
93  {
94  m_ptStackCopy[i].x = m_ptStack[i].x - m_rcSrc.left;
95  m_ptStackCopy[i].y = m_ptStack[i].y - m_rcSrc.top;
96  }
97  Poly(m_hDC, m_ptStackCopy, m_iPtSP, 0x00ffffff, 0x00ffffff, 1, 2, TRUE, FALSE);
98  HeapFree(GetProcessHeap(), 0, m_ptStackCopy);
103  }
104 }
long y
Definition: polytest.cpp:48
#define MAXLONG
Definition: umtypes.h:116
long x
Definition: polytest.cpp:48
#define TRUE
Definition: types.h:120
#define RECT_WIDTH(a)
Definition: definitions.h:19
LONG top
Definition: windef.h:307
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1499
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
LONG left
Definition: windef.h:306
LONG right
Definition: windef.h:308
#define FALSE
Definition: types.h:117
HBITMAP CreateDIBWithProperties(int width, int height)
Definition: dib.cpp:16
#define MAKEROP4(f, b)
Definition: wingdi.h:2945
void Poly(HDC hdc, POINT *lpPoints, int nCount, COLORREF fg, COLORREF bg, int thickness, int style, BOOL closed, BOOL inverted)
Definition: drawing.cpp:70
#define POINT
Definition: precomp.h:30
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
ImageModel imageModel
Definition: main.cpp:32
#define WHITENESS
Definition: wingdi.h:336
#define RECT_HEIGHT(a)
Definition: definitions.h:22
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define NULL
Definition: types.h:112
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
LONG bottom
Definition: windef.h:309
BOOL WINAPI MaskBlt(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ HDC, _In_ int, _In_ int, _In_ HBITMAP, _In_ int, _In_ int, _In_ DWORD)
#define HEAP_GENERATE_EXCEPTIONS
Definition: nt_native.h:1694
void ResetToPrevious(void)
Definition: history.cpp:93
#define HeapFree(x, y, z)
Definition: compat.h:594
#define SRCCOPY
Definition: wingdi.h:332
HBITMAP WINAPI CreateBitmap(_In_ INT cx, _In_ INT cy, _In_ UINT cPlanes, _In_ UINT cBitsPerPel, _In_opt_ const VOID *pvBits)

Referenced by endPaintingL().

◆ CalculateContents()

void SelectionModel::CalculateContents ( HDC  hDCImage)

Definition at line 106 of file selectionmodel.cpp.

107 {
111  Rect(m_hDC, 0, 0, RECT_WIDTH(m_rcSrc), RECT_HEIGHT(m_rcSrc), 0x00ffffff, 0x00ffffff, 1, 2);
114  m_rcSrc.top, SRCCOPY);
115 }
#define RECT_WIDTH(a)
Definition: definitions.h:19
LONG top
Definition: windef.h:307
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1499
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
LONG left
Definition: windef.h:306
HBITMAP CreateDIBWithProperties(int width, int height)
Definition: dib.cpp:16
#define RECT_HEIGHT(a)
Definition: definitions.h:22
#define NULL
Definition: types.h:112
#define SRCCOPY
Definition: wingdi.h:332
static VOID NTAPI BitBlt(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Width, _In_ ULONG Height, _In_reads_bytes_(Delta *Height) PUCHAR Buffer, _In_ ULONG BitsPerPixel, _In_ ULONG Delta)
Definition: common.c:49
struct Rect Rect
HBITMAP WINAPI CreateBitmap(_In_ INT cx, _In_ INT cy, _In_ UINT cPlanes, _In_ UINT cBitsPerPel, _In_opt_ const VOID *pvBits)

Referenced by endPaintingL().

◆ DrawBackgroundPoly()

void SelectionModel::DrawBackgroundPoly ( HDC  hDCImage,
COLORREF  crBg 
)

Definition at line 117 of file selectionmodel.cpp.

118 {
119  Poly(hDCImage, m_ptStack, m_iPtSP, crBg, crBg, 1, 2, TRUE, FALSE);
120 }
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
void Poly(HDC hdc, POINT *lpPoints, int nCount, COLORREF fg, COLORREF bg, int thickness, int style, BOOL closed, BOOL inverted)
Definition: drawing.cpp:70

Referenced by endPaintingL().

◆ DrawBackgroundRect()

void SelectionModel::DrawBackgroundRect ( HDC  hDCImage,
COLORREF  crBg 
)

Definition at line 122 of file selectionmodel.cpp.

123 {
124  Rect(hDCImage, m_rcSrc.left, m_rcSrc.top, m_rcSrc.right, m_rcSrc.bottom, crBg, crBg, 0, 1);
125 }
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
struct Rect Rect

Referenced by endPaintingL().

◆ DrawFramePoly()

void SelectionModel::DrawFramePoly ( HDC  hDCImage)

Definition at line 237 of file selectionmodel.cpp.

238 {
239  Poly(hDCImage, m_ptStack, m_iPtSP, 0, 0, 2, 0, FALSE, TRUE); /* draw the freehand selection inverted/xored */
240 }
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
void Poly(HDC hdc, POINT *lpPoints, int nCount, COLORREF fg, COLORREF bg, int thickness, int style, BOOL closed, BOOL inverted)
Definition: drawing.cpp:70

Referenced by whilePaintingL().

◆ DrawSelection()

void SelectionModel::DrawSelection ( HDC  hDCImage,
COLORREF  crBg = 0,
BOOL  bBgTransparent = FALSE 
)

Definition at line 130 of file selectionmodel.cpp.

131 {
132  if (!bBgTransparent)
134  m_hDC, 0, 0, m_hMask, 0, 0, MAKEROP4(SRCCOPY, SRCAND));
135  else
137  m_hDC, 0, 0, m_hMask, 0, 0, MAKEROP4(SRCCOPY, SRCAND), crBg);
138 }
#define RECT_WIDTH(a)
Definition: definitions.h:19
LONG top
Definition: windef.h:307
BOOL ColorKeyedMaskBlt(HDC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HDC hdcSrc, int nXSrc, int nYSrc, HBITMAP hbmMask, int xMask, int yMask, DWORD dwRop, COLORREF keyColor)
Definition: selection.cpp:25
LONG left
Definition: windef.h:306
#define MAKEROP4(f, b)
Definition: wingdi.h:2945
#define RECT_HEIGHT(a)
Definition: definitions.h:22
#define SRCAND
Definition: wingdi.h:329
BOOL WINAPI MaskBlt(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ HDC, _In_ int, _In_ int, _In_ HBITMAP, _In_ int, _In_ int, _In_ DWORD)
#define SRCCOPY
Definition: wingdi.h:332

Referenced by endPaintingL(), and CSelectionWindow::OnMouseMove().

◆ DrawSelectionStretched()

void SelectionModel::DrawSelectionStretched ( HDC  hDCImage)

Definition at line 140 of file selectionmodel.cpp.

141 {
143 }
#define RECT_WIDTH(a)
Definition: definitions.h:19
LONG top
Definition: windef.h:307
int GetDIBHeight(HBITMAP hBitmap)
Definition: dib.cpp:61
LONG left
Definition: windef.h:306
BOOL WINAPI StretchBlt(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_opt_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD)
int GetDIBWidth(HBITMAP hBitmap)
Definition: dib.cpp:53
#define RECT_HEIGHT(a)
Definition: definitions.h:22
#define SRCCOPY
Definition: wingdi.h:332

Referenced by CSelectionWindow::OnMouseMove().

◆ DrawTextToolText()

void SelectionModel::DrawTextToolText ( HDC  hDCImage,
COLORREF  crFg,
COLORREF  crBg,
BOOL  bBgTransparent = FALSE 
)

Definition at line 341 of file selectionmodel.cpp.

342 {
343  Text(hDCImage, m_rcDest.left, m_rcDest.top, m_rcDest.right, m_rcDest.bottom, crFg, crBg, textToolText, hfontTextFont, bBgTransparent);
344 }
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
LONG right
Definition: windef.h:308
HFONT hfontTextFont
Definition: main.cpp:23
LPTSTR textToolText
Definition: main.cpp:25
LONG bottom
Definition: windef.h:309
char * Text
Definition: combotst.c:136

Referenced by CSelectionWindow::OnMouseMove().

◆ FlipHorizontally()

void SelectionModel::FlipHorizontally ( )

Definition at line 191 of file selectionmodel.cpp.

192 {
200 }
#define RECT_WIDTH(a)
Definition: definitions.h:19
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1499
BOOL WINAPI StretchBlt(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_opt_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD)
#define RECT_HEIGHT(a)
Definition: definitions.h:22
void NotifyRefreshNeeded()
#define SRCCOPY
Definition: wingdi.h:332

Referenced by CMainWindow::OnCommand().

◆ FlipVertically()

void SelectionModel::FlipVertically ( )

Definition at line 202 of file selectionmodel.cpp.

203 {
211 }
#define RECT_WIDTH(a)
Definition: definitions.h:19
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1499
BOOL WINAPI StretchBlt(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_opt_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD)
#define RECT_HEIGHT(a)
Definition: definitions.h:22
void NotifyRefreshNeeded()
#define SRCCOPY
Definition: wingdi.h:332

Referenced by CMainWindow::OnCommand().

◆ GetBitmap()

HBITMAP SelectionModel::GetBitmap ( )

Definition at line 227 of file selectionmodel.cpp.

228 {
229  return m_hBm;
230 }

Referenced by CMainWindow::OnCommand().

◆ GetDestRectHeight()

LONG SelectionModel::GetDestRectHeight ( )

Definition at line 326 of file selectionmodel.cpp.

327 {
328  return m_rcDest.bottom - m_rcDest.top;
329 }
LONG top
Definition: windef.h:307
LONG bottom
Definition: windef.h:309

Referenced by CSelectionWindow::OnMouseMove(), CSelectionWindow::OnPaint(), and placeSelWin().

◆ GetDestRectLeft()

LONG SelectionModel::GetDestRectLeft ( )

Definition at line 331 of file selectionmodel.cpp.

332 {
333  return m_rcDest.left;
334 }
LONG left
Definition: windef.h:306

Referenced by placeSelWin().

◆ GetDestRectTop()

LONG SelectionModel::GetDestRectTop ( )

Definition at line 336 of file selectionmodel.cpp.

337 {
338  return m_rcDest.top;
339 }
LONG top
Definition: windef.h:307

Referenced by placeSelWin().

◆ GetDestRectWidth()

LONG SelectionModel::GetDestRectWidth ( )

Definition at line 321 of file selectionmodel.cpp.

322 {
323  return m_rcDest.right - m_rcDest.left;
324 }
LONG left
Definition: windef.h:306
LONG right
Definition: windef.h:308

Referenced by CSelectionWindow::OnMouseMove(), CSelectionWindow::OnPaint(), and placeSelWin().

◆ InsertFromHBITMAP()

void SelectionModel::InsertFromHBITMAP ( HBITMAP  hBm)

Definition at line 168 of file selectionmodel.cpp.

169 {
170  HDC hTempDC;
171  HBITMAP hTempMask;
172 
174  IMAGE_BITMAP, 0, 0,
175  LR_COPYRETURNORG)));
176 
178  m_rcDest.left = m_rcDest.top = 0;
181 
182  hTempDC = CreateCompatibleDC(m_hDC);
183  hTempMask = CreateBitmap(RECT_WIDTH(m_rcDest), RECT_HEIGHT(m_rcDest), 1, 1, NULL);
184  SelectObject(hTempDC, hTempMask);
185  Rect(hTempDC, m_rcDest.left, m_rcDest.top, m_rcDest.right, m_rcDest.bottom, 0x00ffffff, 0x00ffffff, 1, 1);
187  m_hMask = hTempMask;
188  DeleteDC(hTempDC);
189 }
#define RECT_WIDTH(a)
Definition: definitions.h:19
static HDC
Definition: imagelist.c:92
LONG top
Definition: windef.h:307
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1499
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
int GetDIBHeight(HBITMAP hBitmap)
Definition: dib.cpp:61
LONG left
Definition: windef.h:306
LONG right
Definition: windef.h:308
int GetDIBWidth(HBITMAP hBitmap)
Definition: dib.cpp:53
#define LR_COPYRETURNORG
Definition: winuser.h:1080
HANDLE WINAPI CopyImage(_In_ HANDLE, _In_ UINT, _In_ int, _In_ int, _In_ UINT)
Definition: cursoricon.c:1956
BOOL WINAPI SetRectEmpty(_Out_ LPRECT)
#define RECT_HEIGHT(a)
Definition: definitions.h:22
BOOL WINAPI DeleteDC(_In_ HDC)
#define NULL
Definition: types.h:112
#define IMAGE_BITMAP
Definition: winuser.h:211
LONG bottom
Definition: windef.h:309
static HBITMAP
Definition: button.c:44
struct Rect Rect
HBITMAP WINAPI CreateBitmap(_In_ INT cx, _In_ INT cy, _In_ UINT cPlanes, _In_ UINT cBitsPerPel, _In_opt_ const VOID *pvBits)

Referenced by CMainWindow::InsertSelectionFromHBITMAP().

◆ IsSrcRectSizeNonzero()

BOOL SelectionModel::IsSrcRectSizeNonzero ( )

Definition at line 256 of file selectionmodel.cpp.

257 {
258  return (RECT_WIDTH(m_rcSrc) != 0) && (RECT_HEIGHT(m_rcSrc) != 0);
259 }
#define RECT_WIDTH(a)
Definition: definitions.h:19
#define RECT_HEIGHT(a)
Definition: definitions.h:22

Referenced by endPaintingL().

◆ ModifyDestRect()

void SelectionModel::ModifyDestRect ( POINT ptDelta,
int  iAction 
)

Definition at line 261 of file selectionmodel.cpp.

262 {
263  POINT ptDeltaUsed;
264 
265  switch (iAction)
266  {
267  case ACTION_MOVE: /* move selection */
268  ptDeltaUsed.x = ptDelta.x;
269  ptDeltaUsed.y = ptDelta.y;
270  OffsetRect(&m_rcDest, ptDeltaUsed.x, ptDeltaUsed.y);
271  break;
272  case ACTION_RESIZE_TOP_LEFT: /* resize at upper left corner */
273  ptDeltaUsed.x = min(ptDelta.x, RECT_WIDTH(m_rcDest) - 1);
274  ptDeltaUsed.y = min(ptDelta.y, RECT_HEIGHT(m_rcDest) - 1);
275  m_rcDest.left += ptDeltaUsed.x;
276  m_rcDest.top += ptDeltaUsed.y;
277  break;
278  case ACTION_RESIZE_TOP: /* resize at top edge */
279  ptDeltaUsed.x = ptDelta.x;
280  ptDeltaUsed.y = min(ptDelta.y, RECT_HEIGHT(m_rcDest) - 1);
281  m_rcDest.top += ptDeltaUsed.y;
282  break;
283  case ACTION_RESIZE_TOP_RIGHT: /* resize at upper right corner */
284  ptDeltaUsed.x = max(ptDelta.x, -(RECT_WIDTH(m_rcDest) - 1));
285  ptDeltaUsed.y = min(ptDelta.y, RECT_HEIGHT(m_rcDest) - 1);
286  m_rcDest.top += ptDeltaUsed.y;
287  m_rcDest.right += ptDeltaUsed.x;
288  break;
289  case ACTION_RESIZE_LEFT: /* resize at left edge */
290  ptDeltaUsed.x = min(ptDelta.x, RECT_WIDTH(m_rcDest) - 1);
291  ptDeltaUsed.y = ptDelta.y;
292  m_rcDest.left += ptDeltaUsed.x;
293  break;
294  case ACTION_RESIZE_RIGHT: /* resize at right edge */
295  ptDeltaUsed.x = max(ptDelta.x, -(RECT_WIDTH(m_rcDest) - 1));
296  ptDeltaUsed.y = ptDelta.y;
297  m_rcDest.right += ptDeltaUsed.x;
298  break;
299  case ACTION_RESIZE_BOTTOM_LEFT: /* resize at lower left corner */
300  ptDeltaUsed.x = min(ptDelta.x, RECT_WIDTH(m_rcDest) - 1);
301  ptDeltaUsed.y = max(ptDelta.y, -(RECT_HEIGHT(m_rcDest) - 1));
302  m_rcDest.left += ptDeltaUsed.x;
303  m_rcDest.bottom += ptDeltaUsed.y;
304  break;
305  case ACTION_RESIZE_BOTTOM: /* resize at bottom edge */
306  ptDeltaUsed.x = ptDelta.x;
307  ptDeltaUsed.y = max(ptDelta.y, -(RECT_HEIGHT(m_rcDest) - 1));
308  m_rcDest.bottom += ptDeltaUsed.y;
309  break;
310  case ACTION_RESIZE_BOTTOM_RIGHT: /* resize at lower right corner */
311  ptDeltaUsed.x = max(ptDelta.x, -(RECT_WIDTH(m_rcDest) - 1));
312  ptDeltaUsed.y = max(ptDelta.y, -(RECT_HEIGHT(m_rcDest) - 1));
313  m_rcDest.right += ptDeltaUsed.x;
314  m_rcDest.bottom += ptDeltaUsed.y;
315  break;
316  }
317  ptDelta.x -= ptDeltaUsed.x;
318  ptDelta.y -= ptDeltaUsed.y;
319 }
#define max(a, b)
Definition: svc.c:63
long y
Definition: polytest.cpp:48
BOOL WINAPI OffsetRect(_Inout_ LPRECT, _In_ int, _In_ int)
long x
Definition: polytest.cpp:48
#define ACTION_RESIZE_TOP_LEFT
#define RECT_WIDTH(a)
Definition: definitions.h:19
LONG top
Definition: windef.h:307
#define ACTION_RESIZE_RIGHT
LONG left
Definition: windef.h:306
LONG right
Definition: windef.h:308
#define ACTION_RESIZE_BOTTOM_LEFT
#define ACTION_RESIZE_TOP_RIGHT
#define ACTION_MOVE
#define ACTION_RESIZE_TOP
#define ACTION_RESIZE_LEFT
#define RECT_HEIGHT(a)
Definition: definitions.h:22
#define min(a, b)
Definition: monoChain.cc:55
LONG bottom
Definition: windef.h:309
#define ACTION_RESIZE_BOTTOM
#define ACTION_RESIZE_BOTTOM_RIGHT

Referenced by CSelectionWindow::OnMouseMove().

◆ NotifyRefreshNeeded()

void SelectionModel::NotifyRefreshNeeded ( )
private

Definition at line 346 of file selectionmodel.cpp.

347 {
349 }
#define WM_SELECTIONMODELREFRESHNEEDED
Definition: definitions.h:248
CSelectionWindow selectionWindow
Definition: main.cpp:71

Referenced by FlipHorizontally(), FlipVertically(), and RotateNTimes90Degrees().

◆ operator=()

◆ PtStackSize()

int SelectionModel::PtStackSize ( )

Definition at line 232 of file selectionmodel.cpp.

233 {
234  return m_iPtSP;
235 }

Referenced by endPaintingL(), and whilePaintingL().

◆ PushToPtStack()

void SelectionModel::PushToPtStack ( LONG  x,
LONG  y 
)

Definition at line 49 of file selectionmodel.cpp.

50 {
51  if (m_iPtSP % 1024 == 0)
52  {
53  if (m_ptStack)
55  else
57  }
58  m_ptStack[m_iPtSP].x = x;
59  m_ptStack[m_iPtSP].y = y;
60  m_iPtSP++;
61 }
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
#define POINT
Definition: precomp.h:30
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define HeapReAlloc
Definition: compat.h:593
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define HEAP_GENERATE_EXCEPTIONS
Definition: nt_native.h:1694

Referenced by startPaintingL(), and whilePaintingL().

◆ ResetPtStack()

void SelectionModel::ResetPtStack ( )

Definition at line 41 of file selectionmodel.cpp.

42 {
43  if (m_ptStack != NULL)
45  m_ptStack = NULL;
46  m_iPtSP = 0;
47 }
#define GetProcessHeap()
Definition: compat.h:595
#define NULL
Definition: types.h:112
#define HeapFree(x, y, z)
Definition: compat.h:594

Referenced by CImgAreaWindow::cancelDrawing(), endPaintingL(), startPaintingL(), and ~SelectionModel().

◆ RotateNTimes90Degrees()

void SelectionModel::RotateNTimes90Degrees ( int  iN)

Definition at line 213 of file selectionmodel.cpp.

214 {
215  if (iN == 2)
216  {
223  }
225 }
#define RECT_WIDTH(a)
Definition: definitions.h:19
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1499
BOOL WINAPI StretchBlt(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_opt_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD)
#define RECT_HEIGHT(a)
Definition: definitions.h:22
void NotifyRefreshNeeded()
#define SRCCOPY
Definition: wingdi.h:332

Referenced by CMainWindow::OnCommand().

◆ ScaleContentsToFit()

void SelectionModel::ScaleContentsToFit ( )

Definition at line 145 of file selectionmodel.cpp.

146 {
147  HDC hTempDC;
148  HBITMAP hTempBm;
149  hTempDC = CreateCompatibleDC(m_hDC);
151  SelectObject(hTempDC, hTempBm);
153  StretchBlt(hTempDC, 0, 0, RECT_WIDTH(m_rcDest), RECT_HEIGHT(m_rcDest), m_hDC, 0, 0,
156  m_hBm = hTempBm;
158  SelectObject(hTempDC, hTempBm);
160  StretchBlt(hTempDC, 0, 0, RECT_WIDTH(m_rcDest), RECT_HEIGHT(m_rcDest), m_hDC, 0, 0,
163  m_hMask = hTempBm;
165  DeleteDC(hTempDC);
166 }
#define RECT_WIDTH(a)
Definition: definitions.h:19
static HDC
Definition: imagelist.c:92
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1499
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
int GetDIBHeight(HBITMAP hBitmap)
Definition: dib.cpp:61
BOOL WINAPI StretchBlt(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_opt_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD)
int GetDIBWidth(HBITMAP hBitmap)
Definition: dib.cpp:53
HBITMAP CreateDIBWithProperties(int width, int height)
Definition: dib.cpp:16
#define RECT_HEIGHT(a)
Definition: definitions.h:22
BOOL WINAPI DeleteDC(_In_ HDC)
#define NULL
Definition: types.h:112
static HBITMAP
Definition: button.c:44
#define SRCCOPY
Definition: wingdi.h:332
HBITMAP WINAPI CreateBitmap(_In_ INT cx, _In_ INT cy, _In_ UINT cPlanes, _In_ UINT cBitsPerPel, _In_opt_ const VOID *pvBits)

Referenced by CSelectionWindow::OnLButtonUp().

◆ SetSrcAndDestRectFromPoints()

void SelectionModel::SetSrcAndDestRectFromPoints ( const POINT ptFrom,
const POINT ptTo 
)

Definition at line 242 of file selectionmodel.cpp.

243 {
244  m_rcDest.left = m_rcSrc.left = min(ptFrom.x, ptTo.x);
245  m_rcDest.top = m_rcSrc.top = min(ptFrom.y, ptTo.y);
246  m_rcDest.right = m_rcSrc.right = max(ptFrom.x, ptTo.x);
247  m_rcDest.bottom = m_rcSrc.bottom = max(ptFrom.y, ptTo.y);
248 }
#define max(a, b)
Definition: svc.c:63
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
LONG right
Definition: windef.h:308
#define min(a, b)
Definition: monoChain.cc:55
LONG bottom
Definition: windef.h:309

Referenced by whilePaintingL().

◆ SetSrcRectSizeToZero()

void SelectionModel::SetSrcRectSizeToZero ( )

Definition at line 250 of file selectionmodel.cpp.

251 {
254 }
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309

Referenced by startPaintingL().

Member Data Documentation

◆ m_hBm

◆ m_hDC

◆ m_hMask

◆ m_iPtSP

int SelectionModel::m_iPtSP
private

◆ m_ptStack

POINT* SelectionModel::m_ptStack
private

◆ m_rcDest

◆ m_rcSrc


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