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 POINT *m_ptStack; 17 int m_iPtSP; 18 19 public: 20 COLORREF m_rgbBack; 21 BOOL m_bShow; 22 BOOL m_bContentChanged; 23 CRect m_rc; // in image pixel coordinates 24 POINT m_ptHit; // in image pixel coordinates 25 CRect m_rcOld; // in image pixel coordinates 26 INT m_nSelectionBrush = 0; 27 28 SelectionModel(); 29 ~SelectionModel(); 30 31 void ResetPtStack(); 32 void PushToPtStack(POINT pt); 33 int PtStackSize() const; 34 void SetRectFromPoints(const POINT& ptFrom, const POINT& ptTo); 35 void BuildMaskFromPtStack(); 36 37 BOOL TakeOff(); 38 void Landing(); 39 BOOL IsLanded() const; 40 void HideSelection(); 41 void DeleteSelection(); 42 43 HBITMAP CopyBitmap(); 44 HBITMAP LockBitmap(); 45 void UnlockBitmap(HBITMAP hbmLocked); 46 void GetSelectionContents(HDC hDCImage); 47 void DrawFramePoly(HDC hDCImage); 48 void DrawBackground(HDC hDCImage); 49 void DrawBackgroundPoly(HDC hDCImage, COLORREF crBg); 50 void DrawBackgroundRect(HDC hDCImage, COLORREF crBg); 51 void DrawSelection(HDC hDCImage, COLORREF crBg = 0, BOOL bBgTransparent = FALSE); 52 void InsertFromHBITMAP(HBITMAP hbmColor, INT x = 0, INT y = 0, HBITMAP hbmMask = NULL); 53 54 // operation 55 void FlipHorizontally(); 56 void FlipVertically(); 57 void RotateNTimes90Degrees(int iN); 58 void StretchSkew(int nStretchPercentX, int nStretchPercentY, int nSkewDegX, int nSkewDegY); 59 void InvertSelection(); 60 61 void Dragging(HITTEST hit, POINT pt); 62 void ClearMaskImage(); 63 void ClearColorImage(); 64 void NotifyContentChanged(); 65 66 void StretchSelection(BOOL bShrink); 67 68 private: 69 SelectionModel(const SelectionModel&); 70 SelectionModel& operator=(const SelectionModel&); 71 72 void ShiftPtStack(INT dx, INT dy); 73 void SwapWidthAndHeight(); 74 }; 75