ReactOS 0.4.15-dev-8093-g3285f69
SelectionModel Class Reference

#include <selectionmodel.h>

Collaboration diagram for SelectionModel:

Public Member Functions

 SelectionModel ()
 
 ~SelectionModel ()
 
void SetRectFromPoints (const POINT &ptFrom, const POINT &ptTo)
 
void setMask (const CRect &rc, HBITMAP hbmMask)
 
BOOL TakeOff ()
 
void Landing ()
 
BOOL IsLanded () const
 
void HideSelection ()
 
void DeleteSelection ()
 
HITTEST hitTest (POINT ptCanvas)
 
void drawFrameOnCanvas (HDC hCanvasDC)
 
void moveSelection (INT xDelta, INT yDelta)
 
HBITMAP GetSelectionContents ()
 
void DrawBackground (HDC hDCImage, COLORREF crBg)
 
void DrawBackgroundPoly (HDC hDCImage, COLORREF crBg)
 
void DrawBackgroundRect (HDC hDCImage, COLORREF crBg)
 
void DrawSelection (HDC hDCImage, COLORREF crBg, BOOL bBgTransparent, const CRect &rc, HBITMAP hbm)
 
void DrawSelection (HDC hDCImage, COLORREF crBg, BOOL bBgTransparent)
 
void DrawSelection (HDC hDCImage, COLORREF crBg, BOOL bBgTransparent, const CRect &rc)
 
void InsertFromHBITMAP (HBITMAP hbmColor, INT x=0, INT y=0, HBITMAP hbmMask=NULL)
 
void FlipHorizontally ()
 
void FlipVertically ()
 
void RotateNTimes90Degrees (int iN)
 
void StretchSkew (int nStretchPercentX, int nStretchPercentY, int nSkewDegX, int nSkewDegY)
 
void InvertSelection ()
 
void Dragging (HITTEST hit, POINT pt)
 
void ClearMaskImage ()
 
void ClearColorImage ()
 
void NotifyContentChanged ()
 
void StretchSelection (BOOL bShrink)
 

Public Attributes

COLORREF m_rgbBack
 
BOOL m_bShow
 
BOOL m_bContentChanged
 
CRect m_rc
 
POINT m_ptHit
 
CRect m_rcOld
 

Private Member Functions

 SelectionModel (const SelectionModel &)
 
SelectionModeloperator= (const SelectionModel &)
 
void ShiftPtStack (INT dx, INT dy)
 
void SwapWidthAndHeight ()
 

Private Attributes

HBITMAP m_hbmColor
 
HBITMAP m_hbmMask
 

Detailed Description

Definition at line 11 of file selectionmodel.h.

Constructor & Destructor Documentation

◆ SelectionModel() [1/2]

SelectionModel::SelectionModel ( )

Definition at line 15 of file selectionmodel.cpp.

18 , m_rgbBack(RGB(255, 255, 255))
19 , m_bShow(FALSE)
21{
24 m_ptHit = { -1, -1 };
25}
void SetRectEmpty() noexcept
Definition: atltypes.h:431
HBITMAP m_hbmColor
COLORREF m_rgbBack
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define RGB(r, g, b)
Definition: precomp.h:71

◆ ~SelectionModel()

SelectionModel::~SelectionModel ( )

Definition at line 27 of file selectionmodel.cpp.

28{
31}

◆ SelectionModel() [2/2]

SelectionModel::SelectionModel ( const SelectionModel )
private

Member Function Documentation

◆ ClearColorImage()

void SelectionModel::ClearColorImage ( )

Definition at line 401 of file selectionmodel.cpp.

402{
403 if (m_hbmColor)
404 {
407 }
408}
pKey DeleteObject()

Referenced by HideSelection(), TakeOff(), and ~SelectionModel().

◆ ClearMaskImage()

void SelectionModel::ClearMaskImage ( )

Definition at line 392 of file selectionmodel.cpp.

393{
394 if (m_hbmMask)
395 {
397 m_hbmMask = NULL;
398 }
399}

Referenced by HideSelection(), InsertFromHBITMAP(), TakeOff(), and ~SelectionModel().

◆ DeleteSelection()

void SelectionModel::DeleteSelection ( )

Definition at line 420 of file selectionmodel.cpp.

421{
422 if (!m_bShow)
423 return;
424
425 TakeOff();
428
430}
void PushImageForUndo()
Definition: history.cpp:127
HDC GetDC()
Definition: history.cpp:271
COLORREF GetBgColor() const
void DrawBackground(HDC hDCImage, COLORREF crBg)
ImageModel imageModel
Definition: history.cpp:11
PaletteModel paletteModel

Referenced by CMainWindow::OnCommand().

◆ Dragging()

void SelectionModel::Dragging ( HITTEST  hit,
POINT  pt 
)

Definition at line 350 of file selectionmodel.cpp.

351{
352 switch (hit)
353 {
354 case HIT_NONE:
355 break;
356 case HIT_UPPER_LEFT:
357 m_rc.left += pt.x - m_ptHit.x;
358 m_rc.top += pt.y - m_ptHit.y;
359 break;
360 case HIT_UPPER_CENTER:
361 m_rc.top += pt.y - m_ptHit.y;
362 break;
363 case HIT_UPPER_RIGHT:
364 m_rc.right += pt.x - m_ptHit.x;
365 m_rc.top += pt.y - m_ptHit.y;
366 break;
367 case HIT_MIDDLE_LEFT:
368 m_rc.left += pt.x - m_ptHit.x;
369 break;
370 case HIT_MIDDLE_RIGHT:
371 m_rc.right += pt.x - m_ptHit.x;
372 break;
373 case HIT_LOWER_LEFT:
374 m_rc.left += pt.x - m_ptHit.x;
375 m_rc.bottom += pt.y - m_ptHit.y;
376 break;
377 case HIT_LOWER_CENTER:
378 m_rc.bottom += pt.y - m_ptHit.y;
379 break;
380 case HIT_LOWER_RIGHT:
381 m_rc.right += pt.x - m_ptHit.x;
382 m_rc.bottom += pt.y - m_ptHit.y;
383 break;
384 case HIT_BORDER:
385 case HIT_INNER:
386 m_rc.OffsetRect(pt.x - m_ptHit.x, pt.y - m_ptHit.y);
387 break;
388 }
389 m_ptHit = pt;
390}
@ HIT_NONE
Definition: precomp.h:56
@ HIT_BORDER
Definition: precomp.h:65
@ HIT_LOWER_RIGHT
Definition: precomp.h:64
@ HIT_LOWER_CENTER
Definition: precomp.h:63
@ HIT_UPPER_LEFT
Definition: precomp.h:57
@ HIT_INNER
Definition: precomp.h:66
@ HIT_LOWER_LEFT
Definition: precomp.h:62
@ HIT_UPPER_CENTER
Definition: precomp.h:58
@ HIT_UPPER_RIGHT
Definition: precomp.h:59
@ HIT_MIDDLE_RIGHT
Definition: precomp.h:61
@ HIT_MIDDLE_LEFT
Definition: precomp.h:60
void OffsetRect(int x, int y) noexcept
Definition: atltypes.h:403
#define pt(x, y)
Definition: drawing.c:79
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306

Referenced by SelectionBaseTool::OnButtonUp(), and SelectionBaseTool::OnMouseMove().

◆ DrawBackground()

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

Definition at line 53 of file selectionmodel.cpp.

54{
56 DrawBackgroundPoly(hDCImage, crBg);
57 else
58 DrawBackgroundRect(hDCImage, crBg);
59}
ToolsModel toolsModel
Definition: toolsmodel.cpp:10
void DrawBackgroundPoly(HDC hDCImage, COLORREF crBg)
void DrawBackgroundRect(HDC hDCImage, COLORREF crBg)
TOOLTYPE GetActiveTool() const
Definition: toolsmodel.cpp:134
@ TOOL_FREESEL
Definition: toolsmodel.h:12

Referenced by DeleteSelection(), and SelectionBaseTool::OnDrawOverlayOnImage().

◆ DrawBackgroundPoly()

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

Definition at line 33 of file selectionmodel.cpp.

34{
35 if (m_rcOld.IsRectEmpty())
36 return;
37
38 HGDIOBJ hbrOld = ::SelectObject(hDCImage, ::GetStockObject(DC_BRUSH));
39 ::SetDCBrushColor(hDCImage, crBg);
42 ::SelectObject(hDCImage, hbrOld);
43}
int Width() const noexcept
Definition: atltypes.h:461
int Height() const noexcept
Definition: atltypes.h:318
BOOL IsRectEmpty() const noexcept
Definition: atltypes.h:351
COLORREF WINAPI SetDCBrushColor(_In_ HDC hdc, _In_ COLORREF crColor)
Definition: dc.c:905
HGDIOBJ WINAPI GetStockObject(_In_ int)
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
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
#define PATCOPY
Definition: wingdi.h:335
#define MAKEROP4(f, b)
Definition: wingdi.h:2946

Referenced by DrawBackground().

◆ DrawBackgroundRect()

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

Definition at line 45 of file selectionmodel.cpp.

46{
47 if (m_rcOld.IsRectEmpty())
48 return;
49
50 Rect(hDCImage, m_rcOld.left, m_rcOld.top, m_rcOld.right, m_rcOld.bottom, crBg, crBg, 0, 1);
51}

Referenced by DrawBackground().

◆ drawFrameOnCanvas()

void SelectionModel::drawFrameOnCanvas ( HDC  hCanvasDC)

Definition at line 473 of file selectionmodel.cpp.

474{
475 if (!m_bShow)
476 return;
477
478 CRect rcSelection = m_rc;
479 canvasWindow.ImageToCanvas(rcSelection);
480 rcSelection.InflateRect(GRIP_SIZE, GRIP_SIZE);
481 drawSizeBoxes(hCanvasDC, &rcSelection, TRUE);
482}
#define GRIP_SIZE
Definition: precomp.h:43
CCanvasWindow canvasWindow
Definition: canvas.cpp:10
VOID ImageToCanvas(POINT &pt)
Definition: canvas.cpp:40
void InflateRect(int x, int y) noexcept
Definition: atltypes.h:323
#define TRUE
Definition: types.h:120
VOID drawSizeBoxes(HDC hdc, LPCRECT prcBase, BOOL bDrawFrame, LPCRECT prcPaint)
Definition: sizebox.cpp:103

Referenced by SelectionBaseTool::OnDrawOverlayOnCanvas().

◆ DrawSelection() [1/3]

void SelectionModel::DrawSelection ( HDC  hDCImage,
COLORREF  crBg,
BOOL  bBgTransparent 
)
inline

Definition at line 47 of file selectionmodel.h.

48 {
49 return DrawSelection(hDCImage, crBg, bBgTransparent, m_rc);
50 }
void DrawSelection(HDC hDCImage, COLORREF crBg, BOOL bBgTransparent, const CRect &rc, HBITMAP hbm)

◆ DrawSelection() [2/3]

void SelectionModel::DrawSelection ( HDC  hDCImage,
COLORREF  crBg,
BOOL  bBgTransparent,
const CRect rc 
)
inline

Definition at line 52 of file selectionmodel.h.

53 {
54 return DrawSelection(hDCImage, crBg, bBgTransparent, rc, m_hbmColor);
55 }

◆ DrawSelection() [3/3]

void SelectionModel::DrawSelection ( HDC  hDCImage,
COLORREF  crBg,
BOOL  bBgTransparent,
const CRect rc,
HBITMAP  hbm 
)

Definition at line 62 of file selectionmodel.cpp.

64{
65 if (rc.IsRectEmpty())
66 return;
67
68 BITMAP bm;
69 if (!GetObjectW(hbm, sizeof(BITMAP), &bm))
70 return;
71
72 COLORREF keyColor = (bBgTransparent ? crBg : CLR_INVALID);
73
74 HDC hMemDC = CreateCompatibleDC(hDCImage);
75 HGDIOBJ hbmOld = SelectObject(hMemDC, hbm);
76 ColorKeyedMaskBlt(hDCImage, rc.left, rc.top, rc.Width(), rc.Height(),
77 hMemDC, 0, 0, bm.bmWidth, bm.bmHeight, m_hbmMask, keyColor);
78 SelectObject(hMemDC, hbmOld);
79 DeleteDC(hMemDC);
80}
BOOL ColorKeyedMaskBlt(HDC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HDC hdcSrc, int nXSrc, int nYSrc, int nSrcWidth, int nSrcHeight, HBITMAP hbmMask, COLORREF keyColor)
Definition: drawing.cpp:287
static HDC
Definition: imagelist.c:92
_In_ HBITMAP hbm
Definition: ntgdi.h:2776
Definition: bl.h:1331
DWORD COLORREF
Definition: windef.h:300
int WINAPI GetObjectW(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
#define CLR_INVALID
Definition: wingdi.h:883
BOOL WINAPI DeleteDC(_In_ HDC)

Referenced by DrawSelection(), GetSelectionContents(), and SelectionBaseTool::OnDrawOverlayOnImage().

◆ FlipHorizontally()

void SelectionModel::FlipHorizontally ( )

Definition at line 185 of file selectionmodel.cpp.

186{
187 TakeOff();
188
190 if (m_hbmMask)
191 {
194 hdcMem, 0, 0, m_rc.Width(), m_rc.Height(), SRCCOPY);
195 }
196 if (m_hbmColor)
197 {
200 hdcMem, 0, 0, m_rc.Width(), m_rc.Height(), SRCCOPY);
201 }
203
205}
void NotifyContentChanged()
HDC hdcMem
Definition: welcome.c:104
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)

Referenced by CMainWindow::OnCommand().

◆ FlipVertically()

void SelectionModel::FlipVertically ( )

Definition at line 207 of file selectionmodel.cpp.

208{
209 TakeOff();
210
212 if (m_hbmMask)
213 {
216 hdcMem, 0, 0, m_rc.Width(), m_rc.Height(), SRCCOPY);
217 }
218 if (m_hbmColor)
219 {
222 hdcMem, 0, 0, m_rc.Width(), m_rc.Height(), SRCCOPY);
223 }
225
227}

Referenced by CMainWindow::OnCommand().

◆ GetSelectionContents()

HBITMAP SelectionModel::GetSelectionContents ( )

Definition at line 91 of file selectionmodel.cpp.

92{
93 HBITMAP hbmWhole = imageModel.LockBitmap();
94 HBITMAP hbmPart = getSubImage(hbmWhole, (IsLanded() ? m_rc : m_rcOld));
95 imageModel.UnlockBitmap(hbmWhole);
96 if (!hbmPart)
97 return NULL;
98
99 CRect rc = { 0, 0, m_rc.Width(), m_rc.Height() };
100
103 HGDIOBJ hbmOld = ::SelectObject(hdcMem, hbmNew);
105 ::SelectObject(hdcMem, hbmOld);
107
108 ::DeleteObject(hbmPart);
109 return hbmNew;
110}
SelectionModel selectionModel
HBITMAP LockBitmap()
Definition: history.cpp:345
void UnlockBitmap(HBITMAP hbmLocked)
Definition: history.cpp:354
BOOL IsLanded() const
HBITMAP getSubImage(HBITMAP hbmWhole, const RECT &rcPartial)
Definition: dib.cpp:409
HBITMAP CreateColorDIB(int width, int height, COLORREF rgb)
Definition: dib.cpp:65
static HBITMAP
Definition: button.c:44

Referenced by CMainWindow::OnCommand(), and TakeOff().

◆ HideSelection()

◆ hitTest()

HITTEST SelectionModel::hitTest ( POINT  ptCanvas)

Definition at line 462 of file selectionmodel.cpp.

463{
464 if (!m_bShow)
465 return HIT_NONE;
466
467 CRect rcSelection = m_rc;
468 canvasWindow.ImageToCanvas(rcSelection);
469 rcSelection.InflateRect(GRIP_SIZE, GRIP_SIZE);
470 return getSizeBoxHitTest(ptCanvas, &rcSelection);
471}
HITTEST getSizeBoxHitTest(POINT pt, LPCRECT prcBase)
Definition: sizebox.cpp:80

Referenced by SelectionBaseTool::OnButtonDown(), CCanvasWindow::OnButtonDown(), and CCanvasWindow::OnSetCursor().

◆ InsertFromHBITMAP()

void SelectionModel::InsertFromHBITMAP ( HBITMAP  hbmColor,
INT  x = 0,
INT  y = 0,
HBITMAP  hbmMask = NULL 
)

Definition at line 162 of file selectionmodel.cpp.

163{
165 m_hbmColor = hbmColor;
166
167 m_rc.left = x;
168 m_rc.top = y;
169 m_rc.right = x + GetDIBWidth(hbmColor);
170 m_rc.bottom = y + GetDIBHeight(hbmColor);
171
172 if (hbmMask)
173 {
175 m_hbmMask = hbmMask;
176 }
177 else
178 {
180 }
181
183}
int GetDIBHeight(HBITMAP hBitmap)
Definition: dib.cpp:144
int GetDIBWidth(HBITMAP hBitmap)
Definition: dib.cpp:136
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548

Referenced by CMainWindow::InsertSelectionFromHBITMAP(), and StretchSkew().

◆ InvertSelection()

void SelectionModel::InvertSelection ( )

Definition at line 432 of file selectionmodel.cpp.

433{
434 TakeOff();
435
436 BITMAP bm;
437 ::GetObjectW(m_hbmColor, sizeof(bm), &bm);
438
441 RECT rc = { 0, 0, bm.bmWidth, bm.bmHeight };
442 ::InvertRect(hdc, &rc);
443 ::SelectObject(hdc, hbmOld);
445
447}
HDC hdc
Definition: main.c:9
BOOL WINAPI InvertRect(_In_ HDC, _In_ LPCRECT)

Referenced by CMainWindow::OnCommand().

◆ IsLanded()

BOOL SelectionModel::IsLanded ( ) const

Definition at line 112 of file selectionmodel.cpp.

113{
114 return !m_hbmColor;
115}

Referenced by GetSelectionContents(), Landing(), SelectionBaseTool::OnDrawOverlayOnImage(), and TakeOff().

◆ Landing()

void SelectionModel::Landing ( )

Definition at line 140 of file selectionmodel.cpp.

141{
142 if (IsLanded() && !m_bShow)
143 {
145 return;
146 }
147
148 if (m_bContentChanged ||
150 {
151 CRect rc;
154
157 }
158
160}
BOOL m_drawing
Definition: canvas.h:43
BOOL UnionRect(LPCRECT lpRect1, LPCRECT lpRect2) noexcept
Definition: atltypes.h:456
BOOL EqualRect(LPCRECT lpRect) const noexcept
Definition: atltypes.h:312
void OnDrawOverlayOnImage(HDC hdc)
Definition: mouse.cpp:1186

Referenced by SelectionBaseTool::OnButtonDown(), SelectionBaseTool::OnEndDraw(), ToolBase::reset(), and ToolsModel::SetActiveTool().

◆ moveSelection()

void SelectionModel::moveSelection ( INT  xDelta,
INT  yDelta 
)

Definition at line 484 of file selectionmodel.cpp.

485{
486 if (!m_bShow)
487 return;
488
489 TakeOff();
490 m_rc.OffsetRect(xDelta, yDelta);
491 canvasWindow.Invalidate();
492}

Referenced by CMainWindow::OnKeyDown().

◆ NotifyContentChanged()

void SelectionModel::NotifyContentChanged ( )

◆ operator=()

SelectionModel & SelectionModel::operator= ( const SelectionModel )
private

◆ RotateNTimes90Degrees()

void SelectionModel::RotateNTimes90Degrees ( int  iN)

Definition at line 229 of file selectionmodel.cpp.

230{
231 HBITMAP hbm;
232 HGDIOBJ hbmOld;
234
235 switch (iN)
236 {
237 case 1: /* rotate 90 degrees */
238 case 3: /* rotate 270 degrees */
239 TakeOff();
240
241 if (m_hbmColor)
242 {
245 ::SelectObject(hdcMem, hbmOld);
247 m_hbmColor = hbm;
248 }
249 if (m_hbmMask)
250 {
253 ::SelectObject(hdcMem, hbmOld);
255 m_hbmMask = hbm;
256 }
257
259 break;
260
261 case 2: /* rotate 180 degrees */
262 TakeOff();
263
264 if (m_hbmColor)
265 {
268 hdcMem, 0, 0, m_rc.Width(), m_rc.Height(), SRCCOPY);
269 ::SelectObject(hdcMem, hbmOld);
270 }
271 if (m_hbmMask)
272 {
275 hdcMem, 0, 0, m_rc.Width(), m_rc.Height(), SRCCOPY);
276 ::SelectObject(hdcMem, hbmOld);
277 }
278 break;
279 }
280
283}
HBITMAP Rotate90DegreeBlt(HDC hDC1, INT cx, INT cy, BOOL bRight, BOOL bMono)
Definition: dib.cpp:312

Referenced by CMainWindow::OnCommand().

◆ setMask()

void SelectionModel::setMask ( const CRect rc,
HBITMAP  hbmMask 
)

Definition at line 82 of file selectionmodel.cpp.

83{
84 if (m_hbmMask)
86
87 m_hbmMask = hbmMask;
88 m_rc = m_rcOld = rc;
89}

Referenced by BuildMaskFromPoints().

◆ SetRectFromPoints()

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

◆ ShiftPtStack()

void SelectionModel::ShiftPtStack ( INT  dx,
INT  dy 
)
private

◆ StretchSelection()

void SelectionModel::StretchSelection ( BOOL  bShrink)

Definition at line 494 of file selectionmodel.cpp.

495{
496 if (!m_bShow)
497 return;
498
499 TakeOff();
500
501 INT cx = m_rc.Width(), cy = m_rc.Height();
502
503 if (bShrink)
504 m_rc.InflateRect(-cx / 4, -cy / 4);
505 else
506 m_rc.InflateRect(+cx / 2, +cy / 2);
507
508 // The selection area must exist there
509 if (m_rc.Width() <= 0)
510 m_rc.right = m_rc.left + 1;
511 if (m_rc.Height() <= 0)
512 m_rc.bottom = m_rc.top + 1;
513
515}
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:586
_Out_opt_ int * cx
Definition: commctrl.h:585
int32_t INT
Definition: typedefs.h:58

Referenced by SelectionBaseTool::OnSpecialTweak().

◆ StretchSkew()

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

Definition at line 293 of file selectionmodel.cpp.

294{
295 if (nStretchPercentX == 100 && nStretchPercentY == 100 && nSkewDegX == 0 && nSkewDegY == 0)
296 return;
297
298 TakeOff();
299
300 INT oldWidth = m_rc.Width(), oldHeight = m_rc.Height();
301 INT newWidth = oldWidth * nStretchPercentX / 100;
302 INT newHeight = oldHeight * nStretchPercentY / 100;
303
304 HBITMAP hbmColor = m_hbmColor, hbmMask = m_hbmMask;
305
306 if (hbmMask == NULL)
307 hbmMask = CreateMonoBitmap(oldWidth, oldHeight, TRUE);
308
309 if (oldWidth != newWidth || oldHeight != newHeight)
310 {
311 AttachHBITMAP(&hbmColor, CopyDIBImage(hbmColor, newWidth, newHeight));
312 AttachHBITMAP(&hbmMask, CopyMonoImage(hbmMask, newWidth, newHeight));
313 }
314
315 HGDIOBJ hbmOld;
317
318 if (nSkewDegX)
319 {
320 hbmOld = ::SelectObject(hDC, hbmColor);
321 AttachHBITMAP(&hbmColor, SkewDIB(hDC, hbmColor, nSkewDegX, FALSE));
322 ::SelectObject(hDC, hbmMask);
323 AttachHBITMAP(&hbmMask, SkewDIB(hDC, hbmMask, nSkewDegX, FALSE, TRUE));
324 ::SelectObject(hDC, hbmOld);
325 }
326
327 if (nSkewDegY)
328 {
329 hbmOld = ::SelectObject(hDC, hbmColor);
330 AttachHBITMAP(&hbmColor, SkewDIB(hDC, hbmColor, nSkewDegY, TRUE));
331 ::SelectObject(hDC, hbmMask);
332 AttachHBITMAP(&hbmMask, SkewDIB(hDC, hbmMask, nSkewDegY, TRUE, TRUE));
333 ::SelectObject(hDC, hbmOld);
334 }
335
337
338 InsertFromHBITMAP(hbmColor, m_rc.left, m_rc.top, hbmMask);
339
340 m_bShow = TRUE;
342}
static HDC hDC
Definition: 3dtext.c:33
static HBITMAP CopyDIBImage(HBITMAP hbm, INT cx=0, INT cy=0)
Definition: dib.h:19
void InsertFromHBITMAP(HBITMAP hbmColor, INT x=0, INT y=0, HBITMAP hbmMask=NULL)
HBITMAP SkewDIB(HDC hDC1, HBITMAP hbm, INT nDegree, BOOL bVertical, BOOL bMono)
Definition: dib.cpp:351
HBITMAP CopyMonoImage(HBITMAP hbm, INT cx, INT cy)
Definition: dib.cpp:87
HBITMAP CreateMonoBitmap(int width, int height, BOOL bWhite)
Definition: dib.cpp:45
static void AttachHBITMAP(HBITMAP *phbm, HBITMAP hbmNew)

Referenced by CMainWindow::OnCommand().

◆ SwapWidthAndHeight()

void SelectionModel::SwapWidthAndHeight ( )
private

Definition at line 455 of file selectionmodel.cpp.

456{
457 INT cx = m_rc.Width(), cy = m_rc.Height();
458 m_rc.right = m_rc.left + cy;
459 m_rc.bottom = m_rc.top + cx;
460}

Referenced by RotateNTimes90Degrees().

◆ TakeOff()

BOOL SelectionModel::TakeOff ( )

Definition at line 117 of file selectionmodel.cpp.

118{
119 if (!IsLanded() || m_rc.IsRectEmpty())
120 return FALSE;
121
122 // The background color is needed for transparency of selection
124
125 // Get the contents of the selection area
128
129 // RectSel doesn't need the mask image
132
133 // Save the selection area
134 m_rcOld = m_rc;
135
137 return TRUE;
138}
HBITMAP GetSelectionContents()
@ TOOL_RECTSEL
Definition: toolsmodel.h:13

Referenced by DeleteSelection(), FlipHorizontally(), FlipVertically(), InvertSelection(), moveSelection(), SelectionBaseTool::OnButtonDown(), CMainWindow::OnCommand(), RotateNTimes90Degrees(), StretchSelection(), and StretchSkew().

Member Data Documentation

◆ m_bContentChanged

BOOL SelectionModel::m_bContentChanged

Definition at line 20 of file selectionmodel.h.

Referenced by HideSelection(), Landing(), and NotifyContentChanged().

◆ m_bShow

◆ m_hbmColor

◆ m_hbmMask

◆ m_ptHit

POINT SelectionModel::m_ptHit

Definition at line 22 of file selectionmodel.h.

Referenced by Dragging(), SelectionBaseTool::OnButtonDown(), and SelectionModel().

◆ m_rc

◆ m_rcOld

◆ m_rgbBack

COLORREF SelectionModel::m_rgbBack

Definition at line 18 of file selectionmodel.h.

Referenced by SelectionBaseTool::OnDrawOverlayOnImage(), and TakeOff().


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