2015-07-09 09:48:01 +00:00
|
|
|
/*
|
2023-06-23 11:04:32 +00:00
|
|
|
* PROJECT: PAINT for ReactOS
|
|
|
|
* LICENSE: LGPL-2.0-or-later (https://spdx.org/licenses/LGPL-2.0-or-later)
|
|
|
|
* PURPOSE: Keep track of selection parameters, notify listeners
|
2023-06-27 18:22:21 +00:00
|
|
|
* COPYRIGHT: Copyright 2015 Benedikt Freisen <b.freisen@gmx.net>
|
2023-06-23 11:04:32 +00:00
|
|
|
* Copyright 2019-2023 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
|
2015-07-09 09:48:01 +00:00
|
|
|
*/
|
|
|
|
|
2017-12-09 12:36:45 +00:00
|
|
|
#pragma once
|
|
|
|
|
2015-07-09 09:48:01 +00:00
|
|
|
class SelectionModel
|
|
|
|
{
|
|
|
|
private:
|
2023-04-01 13:01:04 +00:00
|
|
|
HBITMAP m_hbmColor;
|
|
|
|
HBITMAP m_hbmMask;
|
2015-07-09 09:48:01 +00:00
|
|
|
|
|
|
|
public:
|
2023-06-18 23:24:17 +00:00
|
|
|
COLORREF m_rgbBack;
|
2023-04-01 13:01:04 +00:00
|
|
|
BOOL m_bShow;
|
2023-06-18 22:51:19 +00:00
|
|
|
BOOL m_bContentChanged;
|
2023-04-01 13:01:04 +00:00
|
|
|
CRect m_rc; // in image pixel coordinates
|
|
|
|
POINT m_ptHit; // in image pixel coordinates
|
2023-06-17 12:15:35 +00:00
|
|
|
CRect m_rcOld; // in image pixel coordinates
|
2023-04-01 13:01:04 +00:00
|
|
|
|
2015-07-09 09:48:01 +00:00
|
|
|
SelectionModel();
|
2019-12-25 06:46:29 +00:00
|
|
|
~SelectionModel();
|
2023-04-01 13:01:04 +00:00
|
|
|
|
|
|
|
void SetRectFromPoints(const POINT& ptFrom, const POINT& ptTo);
|
2023-11-25 04:44:31 +00:00
|
|
|
void setMask(const CRect& rc, HBITMAP hbmMask);
|
2023-04-01 13:01:04 +00:00
|
|
|
|
|
|
|
BOOL TakeOff();
|
|
|
|
void Landing();
|
2023-06-17 12:15:35 +00:00
|
|
|
BOOL IsLanded() const;
|
|
|
|
void HideSelection();
|
|
|
|
void DeleteSelection();
|
2023-11-23 01:31:24 +00:00
|
|
|
HITTEST hitTest(POINT ptCanvas);
|
2023-11-23 02:03:10 +00:00
|
|
|
void drawFrameOnCanvas(HDC hCanvasDC);
|
2023-11-23 05:44:27 +00:00
|
|
|
void moveSelection(INT xDelta, INT yDelta);
|
2023-04-01 13:01:04 +00:00
|
|
|
|
2023-11-03 20:56:10 +00:00
|
|
|
HBITMAP GetSelectionContents();
|
2023-11-25 04:44:31 +00:00
|
|
|
void DrawBackground(HDC hDCImage, COLORREF crBg);
|
2015-07-09 09:48:01 +00:00
|
|
|
void DrawBackgroundPoly(HDC hDCImage, COLORREF crBg);
|
|
|
|
void DrawBackgroundRect(HDC hDCImage, COLORREF crBg);
|
2024-02-28 13:01:08 +00:00
|
|
|
|
|
|
|
void DrawSelection(HDC hDCImage, COLORREF crBg, BOOL bBgTransparent, const CRect& rc, HBITMAP hbm);
|
|
|
|
|
|
|
|
void DrawSelection(HDC hDCImage, COLORREF crBg, BOOL bBgTransparent)
|
|
|
|
{
|
|
|
|
return DrawSelection(hDCImage, crBg, bBgTransparent, m_rc);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DrawSelection(HDC hDCImage, COLORREF crBg, BOOL bBgTransparent, const CRect& rc)
|
|
|
|
{
|
|
|
|
return DrawSelection(hDCImage, crBg, bBgTransparent, rc, m_hbmColor);
|
|
|
|
}
|
|
|
|
|
2023-06-19 00:56:02 +00:00
|
|
|
void InsertFromHBITMAP(HBITMAP hbmColor, INT x = 0, INT y = 0, HBITMAP hbmMask = NULL);
|
2023-04-01 13:01:04 +00:00
|
|
|
|
|
|
|
// operation
|
2015-07-09 09:48:01 +00:00
|
|
|
void FlipHorizontally();
|
|
|
|
void FlipVertically();
|
|
|
|
void RotateNTimes90Degrees(int iN);
|
2023-04-01 13:01:04 +00:00
|
|
|
void StretchSkew(int nStretchPercentX, int nStretchPercentY, int nSkewDegX, int nSkewDegY);
|
2023-06-18 22:51:19 +00:00
|
|
|
void InvertSelection();
|
2023-04-01 13:01:04 +00:00
|
|
|
|
2023-06-24 10:39:07 +00:00
|
|
|
void Dragging(HITTEST hit, POINT pt);
|
2023-09-23 00:26:11 +00:00
|
|
|
void ClearMaskImage();
|
|
|
|
void ClearColorImage();
|
2023-06-18 22:51:19 +00:00
|
|
|
void NotifyContentChanged();
|
2019-12-25 06:46:29 +00:00
|
|
|
|
2023-09-23 00:26:11 +00:00
|
|
|
void StretchSelection(BOOL bShrink);
|
|
|
|
|
2019-12-25 06:46:29 +00:00
|
|
|
private:
|
|
|
|
SelectionModel(const SelectionModel&);
|
|
|
|
SelectionModel& operator=(const SelectionModel&);
|
2023-04-01 13:01:04 +00:00
|
|
|
|
2023-06-17 12:15:35 +00:00
|
|
|
void ShiftPtStack(INT dx, INT dy);
|
2023-06-18 22:51:19 +00:00
|
|
|
void SwapWidthAndHeight();
|
2015-07-09 09:48:01 +00:00
|
|
|
};
|