1 /* 2 * PROJECT: PAINT for ReactOS 3 * LICENSE: LGPL-2.0-or-later (https://spdx.org/licenses/LGPL-2.0-or-later) 4 * PURPOSE: Keep track of selection parameters, notify listeners 5 * COPYRIGHT: Copyright 2015 Benedikt Freisen <b.freisen@gmx.net> 6 * Copyright 2019-2023 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com> 7 */ 8 9 #pragma once 10 11 class SelectionModel 12 { 13 private: 14 HBITMAP m_hbmColor; 15 HBITMAP m_hbmMask; 16 17 public: 18 COLORREF m_rgbBack; 19 BOOL m_bShow; 20 BOOL m_bContentChanged; 21 CRect m_rc; // in image pixel coordinates 22 POINT m_ptHit; // in image pixel coordinates 23 CRect m_rcOld; // in image pixel coordinates 24 25 SelectionModel(); 26 ~SelectionModel(); 27 28 void SetRectFromPoints(const POINT& ptFrom, const POINT& ptTo); 29 void setMask(const CRect& rc, HBITMAP hbmMask); 30 31 BOOL TakeOff(); 32 void Landing(); 33 BOOL IsLanded() const; 34 void HideSelection(); 35 void DeleteSelection(); 36 HITTEST hitTest(POINT ptCanvas); 37 void drawFrameOnCanvas(HDC hCanvasDC); 38 void moveSelection(INT xDelta, INT yDelta); 39 40 HBITMAP GetSelectionContents(); 41 void DrawBackground(HDC hDCImage, COLORREF crBg); 42 void DrawBackgroundPoly(HDC hDCImage, COLORREF crBg); 43 void DrawBackgroundRect(HDC hDCImage, COLORREF crBg); 44 45 void DrawSelection(HDC hDCImage, COLORREF crBg, BOOL bBgTransparent, const CRect& rc, HBITMAP hbm); 46 47 void DrawSelection(HDC hDCImage, COLORREF crBg, BOOL bBgTransparent) 48 { 49 return DrawSelection(hDCImage, crBg, bBgTransparent, m_rc); 50 } 51 52 void DrawSelection(HDC hDCImage, COLORREF crBg, BOOL bBgTransparent, const CRect& rc) 53 { 54 return DrawSelection(hDCImage, crBg, bBgTransparent, rc, m_hbmColor); 55 } 56 57 void InsertFromHBITMAP(HBITMAP hbmColor, INT x = 0, INT y = 0, HBITMAP hbmMask = NULL); 58 59 // operation 60 void FlipHorizontally(); 61 void FlipVertically(); 62 void RotateNTimes90Degrees(int iN); 63 void StretchSkew(int nStretchPercentX, int nStretchPercentY, int nSkewDegX, int nSkewDegY); 64 void InvertSelection(); 65 66 void Dragging(HITTEST hit, POINT pt); 67 void ClearMaskImage(); 68 void ClearColorImage(); 69 void NotifyContentChanged(); 70 71 void StretchSelection(BOOL bShrink); 72 73 private: 74 SelectionModel(const SelectionModel&); 75 SelectionModel& operator=(const SelectionModel&); 76 77 void ShiftPtStack(INT dx, INT dy); 78 void SwapWidthAndHeight(); 79 }; 80