ReactOS  0.4.15-dev-4872-g8a3db97
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, INT x=0, INT y=0)
 
void FlipHorizontally ()
 
void FlipVertically ()
 
void RotateNTimes90Degrees (int iN)
 
void StretchSkew (int nStretchPercentX, int nStretchPercentY, int nSkewDegX=0, int nSkewDegY=0)
 
HBITMAP GetBitmap () const
 
int PtStackSize () const
 
void DrawFramePoly (HDC hDCImage)
 
void SetSrcAndDestRectFromPoints (const POINT &ptFrom, const POINT &ptTo)
 
void SetSrcRectSizeToZero ()
 
BOOL IsSrcRectSizeNonzero () const
 
void ModifyDestRect (POINT &ptDelta, int iAction)
 
LONG GetDestRectWidth () const
 
LONG GetDestRectHeight () const
 
LONG GetDestRectLeft () const
 
LONG GetDestRectTop () const
 
void GetRect (LPRECT prc) const
 

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
LONG top
Definition: windef.h:307
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
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 RECT_HEIGHT(a)
Definition: common.h:21
#define RECT_WIDTH(a)
Definition: common.h:18
#define FALSE
Definition: types.h:117
HBITMAP CreateDIBWithProperties(int width, int height)
Definition: dib.cpp:17
#define MAKEROP4(f, b)
Definition: wingdi.h:2946
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:337
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:100
#define HeapFree(x, y, z)
Definition: compat.h:594
#define SRCCOPY
Definition: wingdi.h:333
HBITMAP WINAPI CreateBitmap(_In_ INT cx, _In_ INT cy, _In_ UINT cPlanes, _In_ UINT cBitsPerPel, _In_opt_ const VOID *pvBits)

Referenced by FreeSelTool::OnButtonUp().

◆ 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 }
LONG top
Definition: windef.h:307
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
LONG left
Definition: windef.h:306
#define RECT_HEIGHT(a)
Definition: common.h:21
#define RECT_WIDTH(a)
Definition: common.h:18
HBITMAP CreateDIBWithProperties(int width, int height)
Definition: dib.cpp:17
#define NULL
Definition: types.h:112
#define SRCCOPY
Definition: wingdi.h:333
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 RectSelTool::OnButtonUp().

◆ 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 ImageModel::DrawSelectionBackground().

◆ 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 ImageModel::DrawSelectionBackground().

◆ DrawFramePoly()

void SelectionModel::DrawFramePoly ( HDC  hDCImage)

Definition at line 292 of file selectionmodel.cpp.

293 {
294  Poly(hDCImage, m_ptStack, m_iPtSP, 0, 0, 2, 0, FALSE, TRUE); /* draw the freehand selection inverted/xored */
295 }
#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 FreeSelTool::OnMouseMove().

◆ DrawSelection()

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

Definition at line 127 of file selectionmodel.cpp.

128 {
129  if (!bBgTransparent)
131  m_hDC, 0, 0, m_hMask, 0, 0, MAKEROP4(SRCCOPY, SRCAND));
132  else
134  m_hDC, 0, 0, m_hMask, 0, 0, MAKEROP4(SRCCOPY, SRCAND), crBg);
135 }
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
#define RECT_HEIGHT(a)
Definition: common.h:21
#define RECT_WIDTH(a)
Definition: common.h:18
#define MAKEROP4(f, b)
Definition: wingdi.h:2946
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: drawing.cpp:312
#define SRCAND
Definition: wingdi.h:330
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:333

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

◆ DrawSelectionStretched()

void SelectionModel::DrawSelectionStretched ( HDC  hDCImage)

Definition at line 137 of file selectionmodel.cpp.

138 {
140 }
LONG top
Definition: windef.h:307
int GetDIBHeight(HBITMAP hBitmap)
Definition: dib.cpp:62
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)
#define RECT_HEIGHT(a)
Definition: common.h:21
int GetDIBWidth(HBITMAP hBitmap)
Definition: dib.cpp:54
#define RECT_WIDTH(a)
Definition: common.h:18
#define SRCCOPY
Definition: wingdi.h:333

Referenced by CSelectionWindow::OnMouseMove().

◆ FlipHorizontally()

void SelectionModel::FlipHorizontally ( )

Definition at line 188 of file selectionmodel.cpp.

189 {
197 }
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
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: common.h:21
#define RECT_WIDTH(a)
Definition: common.h:18
void NotifyRefreshNeeded()
#define SRCCOPY
Definition: wingdi.h:333

Referenced by CMainWindow::OnCommand().

◆ FlipVertically()

void SelectionModel::FlipVertically ( )

Definition at line 199 of file selectionmodel.cpp.

200 {
208 }
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
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: common.h:21
#define RECT_WIDTH(a)
Definition: common.h:18
void NotifyRefreshNeeded()
#define SRCCOPY
Definition: wingdi.h:333

Referenced by CMainWindow::OnCommand().

◆ GetBitmap()

HBITMAP SelectionModel::GetBitmap ( ) const

Definition at line 282 of file selectionmodel.cpp.

283 {
284  return m_hBm;
285 }

Referenced by CMainWindow::OnCommand().

◆ GetDestRectHeight()

LONG SelectionModel::GetDestRectHeight ( ) const

Definition at line 381 of file selectionmodel.cpp.

382 {
383  return m_rcDest.bottom - m_rcDest.top;
384 }
LONG top
Definition: windef.h:307
LONG bottom
Definition: windef.h:309

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

◆ GetDestRectLeft()

LONG SelectionModel::GetDestRectLeft ( ) const

Definition at line 386 of file selectionmodel.cpp.

387 {
388  return m_rcDest.left;
389 }
LONG left
Definition: windef.h:306

Referenced by placeSelWin().

◆ GetDestRectTop()

LONG SelectionModel::GetDestRectTop ( ) const

Definition at line 391 of file selectionmodel.cpp.

392 {
393  return m_rcDest.top;
394 }
LONG top
Definition: windef.h:307

Referenced by placeSelWin().

◆ GetDestRectWidth()

LONG SelectionModel::GetDestRectWidth ( ) const

Definition at line 376 of file selectionmodel.cpp.

377 {
378  return m_rcDest.right - m_rcDest.left;
379 }
LONG left
Definition: windef.h:306
LONG right
Definition: windef.h:308

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

◆ GetRect()

void SelectionModel::GetRect ( LPRECT  prc) const

Definition at line 401 of file selectionmodel.cpp.

402 {
403  *prc = m_rcDest;
404 }
_Out_ LPRECT prc
Definition: ntgdi.h:1658

Referenced by TextTool::OnButtonUp().

◆ InsertFromHBITMAP()

void SelectionModel::InsertFromHBITMAP ( HBITMAP  hBm,
INT  x = 0,
INT  y = 0 
)

Definition at line 165 of file selectionmodel.cpp.

166 {
167  HDC hTempDC;
168  HBITMAP hTempMask;
169 
170  m_hBm = CopyDIBImage(hBm);
172 
174  m_rcDest.left = x;
175  m_rcDest.top = y;
178 
179  hTempDC = CreateCompatibleDC(m_hDC);
180  hTempMask = CreateBitmap(RECT_WIDTH(m_rcDest), RECT_HEIGHT(m_rcDest), 1, 1, NULL);
181  SelectObject(hTempDC, hTempMask);
182  Rect(hTempDC, 0, 0, RECT_WIDTH(m_rcDest), RECT_HEIGHT(m_rcDest), 0x00ffffff, 0x00ffffff, 1, 1);
184  m_hMask = hTempMask;
185  DeleteDC(hTempDC);
186 }
static HBITMAP CopyDIBImage(HBITMAP hbm, INT cx=0, INT cy=0)
Definition: dib.h:14
static HDC
Definition: imagelist.c:92
LONG top
Definition: windef.h:307
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
int GetDIBHeight(HBITMAP hBitmap)
Definition: dib.cpp:62
LONG left
Definition: windef.h:306
LONG right
Definition: windef.h:308
#define RECT_HEIGHT(a)
Definition: common.h:21
int GetDIBWidth(HBITMAP hBitmap)
Definition: dib.cpp:54
#define RECT_WIDTH(a)
Definition: common.h:18
BOOL WINAPI SetRectEmpty(_Out_ LPRECT)
BOOL WINAPI DeleteDC(_In_ HDC)
#define NULL
Definition: types.h:112
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
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(), RotateNTimes90Degrees(), and StretchSkew().

◆ IsSrcRectSizeNonzero()

BOOL SelectionModel::IsSrcRectSizeNonzero ( ) const

Definition at line 311 of file selectionmodel.cpp.

312 {
313  return (RECT_WIDTH(m_rcSrc) != 0) && (RECT_HEIGHT(m_rcSrc) != 0);
314 }
#define RECT_HEIGHT(a)
Definition: common.h:21
#define RECT_WIDTH(a)
Definition: common.h:18

Referenced by RectSelTool::OnButtonUp(), and TextTool::OnButtonUp().

◆ ModifyDestRect()

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

Definition at line 316 of file selectionmodel.cpp.

317 {
318  POINT ptDeltaUsed;
319 
320  switch (iAction)
321  {
322  case ACTION_MOVE: /* move selection */
323  ptDeltaUsed.x = ptDelta.x;
324  ptDeltaUsed.y = ptDelta.y;
325  OffsetRect(&m_rcDest, ptDeltaUsed.x, ptDeltaUsed.y);
326  break;
327  case ACTION_RESIZE_TOP_LEFT: /* resize at upper left corner */
328  ptDeltaUsed.x = min(ptDelta.x, RECT_WIDTH(m_rcDest) - 1);
329  ptDeltaUsed.y = min(ptDelta.y, RECT_HEIGHT(m_rcDest) - 1);
330  m_rcDest.left += ptDeltaUsed.x;
331  m_rcDest.top += ptDeltaUsed.y;
332  break;
333  case ACTION_RESIZE_TOP: /* resize at top edge */
334  ptDeltaUsed.x = ptDelta.x;
335  ptDeltaUsed.y = min(ptDelta.y, RECT_HEIGHT(m_rcDest) - 1);
336  m_rcDest.top += ptDeltaUsed.y;
337  break;
338  case ACTION_RESIZE_TOP_RIGHT: /* resize at upper right corner */
339  ptDeltaUsed.x = max(ptDelta.x, -(RECT_WIDTH(m_rcDest) - 1));
340  ptDeltaUsed.y = min(ptDelta.y, RECT_HEIGHT(m_rcDest) - 1);
341  m_rcDest.top += ptDeltaUsed.y;
342  m_rcDest.right += ptDeltaUsed.x;
343  break;
344  case ACTION_RESIZE_LEFT: /* resize at left edge */
345  ptDeltaUsed.x = min(ptDelta.x, RECT_WIDTH(m_rcDest) - 1);
346  ptDeltaUsed.y = ptDelta.y;
347  m_rcDest.left += ptDeltaUsed.x;
348  break;
349  case ACTION_RESIZE_RIGHT: /* resize at right edge */
350  ptDeltaUsed.x = max(ptDelta.x, -(RECT_WIDTH(m_rcDest) - 1));
351  ptDeltaUsed.y = ptDelta.y;
352  m_rcDest.right += ptDeltaUsed.x;
353  break;
354  case ACTION_RESIZE_BOTTOM_LEFT: /* resize at lower left corner */
355  ptDeltaUsed.x = min(ptDelta.x, RECT_WIDTH(m_rcDest) - 1);
356  ptDeltaUsed.y = max(ptDelta.y, -(RECT_HEIGHT(m_rcDest) - 1));
357  m_rcDest.left += ptDeltaUsed.x;
358  m_rcDest.bottom += ptDeltaUsed.y;
359  break;
360  case ACTION_RESIZE_BOTTOM: /* resize at bottom edge */
361  ptDeltaUsed.x = ptDelta.x;
362  ptDeltaUsed.y = max(ptDelta.y, -(RECT_HEIGHT(m_rcDest) - 1));
363  m_rcDest.bottom += ptDeltaUsed.y;
364  break;
365  case ACTION_RESIZE_BOTTOM_RIGHT: /* resize at lower right corner */
366  ptDeltaUsed.x = max(ptDelta.x, -(RECT_WIDTH(m_rcDest) - 1));
367  ptDeltaUsed.y = max(ptDelta.y, -(RECT_HEIGHT(m_rcDest) - 1));
368  m_rcDest.right += ptDeltaUsed.x;
369  m_rcDest.bottom += ptDeltaUsed.y;
370  break;
371  }
372  ptDelta.x -= ptDeltaUsed.x;
373  ptDelta.y -= ptDeltaUsed.y;
374 }
#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
LONG top
Definition: windef.h:307
#define ACTION_RESIZE_RIGHT
LONG left
Definition: windef.h:306
LONG right
Definition: windef.h:308
#define RECT_HEIGHT(a)
Definition: common.h:21
#define RECT_WIDTH(a)
Definition: common.h:18
#define ACTION_RESIZE_BOTTOM_LEFT
#define ACTION_RESIZE_TOP_RIGHT
#define ACTION_MOVE
#define ACTION_RESIZE_TOP
#define ACTION_RESIZE_LEFT
#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 396 of file selectionmodel.cpp.

397 {
399 }
#define WM_SELECTIONMODELREFRESHNEEDED
Definition: precomp.h:43
CSelectionWindow selectionWindow
Definition: main.cpp:71

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

◆ operator=()

◆ PtStackSize()

int SelectionModel::PtStackSize ( ) const

Definition at line 287 of file selectionmodel.cpp.

288 {
289  return m_iPtSP;
290 }

Referenced by FreeSelTool::OnButtonUp().

◆ 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 FreeSelTool::OnButtonDown(), and FreeSelTool::OnMouseMove().

◆ 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 FreeSelTool::OnButtonDown(), FreeSelTool::OnButtonUp(), ToolBase::reset(), and ~SelectionModel().

◆ RotateNTimes90Degrees()

void SelectionModel::RotateNTimes90Degrees ( int  iN)

Definition at line 210 of file selectionmodel.cpp.

211 {
212  HBITMAP hbm;
213  switch (iN)
214  {
215  case 1:
216  case 3:
222  DeleteObject(hbm);
225  placeSelWin();
226  break;
227  case 2:
234  break;
235  }
237 }
void CopyPrevious(void)
Definition: history.cpp:47
#define SW_SHOWNOACTIVATE
Definition: winuser.h:768
void placeSelWin(void)
Definition: mouse.cpp:20
void InsertFromHBITMAP(HBITMAP hBm, INT x=0, INT y=0)
LONG top
Definition: windef.h:307
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
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)
#define RECT_HEIGHT(a)
Definition: common.h:21
#define RECT_WIDTH(a)
Definition: common.h:18
HBITMAP Rotate90DegreeBlt(HDC hDC1, INT cx, INT cy, BOOL bRight)
Definition: dib.cpp:213
ImageModel imageModel
Definition: main.cpp:32
void ForceRefreshSelectionContents()
Definition: selection.cpp:24
_In_ HBITMAP hbm
Definition: ntgdi.h:2776
void NotifyRefreshNeeded()
static HBITMAP
Definition: button.c:44
void DeleteSelection()
Definition: history.cpp:293
#define SRCCOPY
Definition: wingdi.h:333
CSelectionWindow selectionWindow
Definition: main.cpp:71

Referenced by CMainWindow::OnCommand().

◆ ScaleContentsToFit()

void SelectionModel::ScaleContentsToFit ( )

Definition at line 142 of file selectionmodel.cpp.

143 {
144  HDC hTempDC;
145  HBITMAP hTempBm;
146  hTempDC = CreateCompatibleDC(m_hDC);
148  SelectObject(hTempDC, hTempBm);
150  StretchBlt(hTempDC, 0, 0, RECT_WIDTH(m_rcDest), RECT_HEIGHT(m_rcDest), m_hDC, 0, 0,
153  m_hBm = hTempBm;
155  SelectObject(hTempDC, hTempBm);
157  StretchBlt(hTempDC, 0, 0, RECT_WIDTH(m_rcDest), RECT_HEIGHT(m_rcDest), m_hDC, 0, 0,
160  m_hMask = hTempBm;
162  DeleteDC(hTempDC);
163 }
static HDC
Definition: imagelist.c:92
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
int GetDIBHeight(HBITMAP hBitmap)
Definition: dib.cpp:62
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: common.h:21
int GetDIBWidth(HBITMAP hBitmap)
Definition: dib.cpp:54
#define RECT_WIDTH(a)
Definition: common.h:18
HBITMAP CreateDIBWithProperties(int width, int height)
Definition: dib.cpp:17
BOOL WINAPI DeleteDC(_In_ HDC)
#define NULL
Definition: types.h:112
static HBITMAP
Definition: button.c:44
#define SRCCOPY
Definition: wingdi.h:333
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 297 of file selectionmodel.cpp.

298 {
299  m_rcDest.left = m_rcSrc.left = min(ptFrom.x, ptTo.x);
300  m_rcDest.top = m_rcSrc.top = min(ptFrom.y, ptTo.y);
301  m_rcDest.right = m_rcSrc.right = max(ptFrom.x, ptTo.x);
302  m_rcDest.bottom = m_rcSrc.bottom = max(ptFrom.y, ptTo.y);
303 }
#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 RectSelTool::OnMouseMove(), and TextTool::UpdatePoint().

◆ SetSrcRectSizeToZero()

void SelectionModel::SetSrcRectSizeToZero ( )

Definition at line 305 of file selectionmodel.cpp.

306 {
309 }
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 RectSelTool::OnButtonDown().

◆ StretchSkew()

void SelectionModel::StretchSkew ( int  nStretchPercentX,
int  nStretchPercentY,
int  nSkewDegX = 0,
int  nSkewDegY = 0 
)

Definition at line 239 of file selectionmodel.cpp.

240 {
241  if (nStretchPercentX == 100 && nStretchPercentY == 100 && nSkewDegX == 0 && nSkewDegY == 0)
242  return;
243 
246 
247  INT oldWidth = RECT_WIDTH(m_rcDest);
248  INT oldHeight = RECT_HEIGHT(m_rcDest);
249  INT newWidth = oldWidth * nStretchPercentX / 100;
250  INT newHeight = oldHeight * nStretchPercentY / 100;
251 
252  if (oldWidth != newWidth || oldHeight != newHeight)
253  {
255  HBITMAP hbm0 = CopyDIBImage(m_hBm, newWidth, newHeight);
257  DeleteObject(hbm0);
258  }
259 
260  if (nSkewDegX)
261  {
263  HBITMAP hbm1 = SkewDIB(m_hDC, m_hBm, nSkewDegX, FALSE);
265  DeleteObject(hbm1);
266  }
267 
268  if (nSkewDegY)
269  {
271  HBITMAP hbm2 = SkewDIB(m_hDC, m_hBm, nSkewDegY, TRUE);
273  DeleteObject(hbm2);
274  }
275 
278  placeSelWin();
280 }
void CopyPrevious(void)
Definition: history.cpp:47
#define SW_SHOWNOACTIVATE
Definition: winuser.h:768
void placeSelWin(void)
Definition: mouse.cpp:20
static HBITMAP CopyDIBImage(HBITMAP hbm, INT cx=0, INT cy=0)
Definition: dib.h:14
#define TRUE
Definition: types.h:120
void InsertFromHBITMAP(HBITMAP hBm, INT x=0, INT y=0)
LONG top
Definition: windef.h:307
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
LONG left
Definition: windef.h:306
int32_t INT
Definition: typedefs.h:58
#define RECT_HEIGHT(a)
Definition: common.h:21
HBITMAP SkewDIB(HDC hDC1, HBITMAP hbm, INT nDegree, BOOL bVertical)
Definition: dib.cpp:252
#define RECT_WIDTH(a)
Definition: common.h:18
#define FALSE
Definition: types.h:117
ImageModel imageModel
Definition: main.cpp:32
void ForceRefreshSelectionContents()
Definition: selection.cpp:24
void NotifyRefreshNeeded()
static HBITMAP
Definition: button.c:44
void DeleteSelection()
Definition: history.cpp:293
CSelectionWindow selectionWindow
Definition: main.cpp:71

Referenced by CMainWindow::OnCommand().

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: