/** * @file XTPImageEditor.h * * @copyright * (c) 1998-2025 Codejock Software, All Rights Reserved. * * This source file is the property of Codejock Software and must not be * redistributed by any means without the explicit written permission of * Codejock Software. * * The use of this source code is governed by the terms and conditions specified * in the Toolkit Pro license agreement. Codejock Software grants you, as a * single software developer, the limited right to use this software on one * computer only. * * Contact Information: * support@codejock.com * http://www.codejock.com * */ /** @cond */ #if !defined(__XTP_IMAGEEDITORDLG_H__) # define __XTP_IMAGEEDITORDLG_H__ /** @endcond */ # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" class CXTPImageManagerIconHandle; class CXTPImageEditorDlg; /** @cond */ enum XTPImageEditorTools { xtpToolPencil, xtpToolFill, xtpToolGetColor, xtpToolLine, xtpToolRectangle, xtpToolCircle }; # define XTPCOLOR_ERASE (0xFFFEFF) /** * @brief * Internal class used int CXTPImageEditorDlg */ class _XTP_EXT_CLASS CXTPImageEditorPicker : public CStatic { DECLARE_DYNAMIC(CXTPImageEditorPicker) public: CXTPImageEditorPicker(); public: void SetColor(COLORREF clr); COLORREF GetColor(); void SetSelected(BOOL bSelected = TRUE); protected: DECLARE_MESSAGE_MAP() afx_msg void OnPaint(); afx_msg void OnLButtonDown(UINT nFlags, CPoint point); private: COLORREF m_clr; BOOL m_bSelected; }; /** * @brief * Internal class used int CXTPImageEditorDlg */ class _XTP_EXT_CLASS CXTPImageEditorPicture : public CStatic { public: class CAlphaBitmap : public CBitmap { public: CAlphaBitmap(BOOL bAlpha = FALSE) { m_bAlpha = bAlpha; } public: void CreateEditorBitmap(int nWidth, int nHeight); public: BOOL m_bAlpha; }; public: CXTPImageEditorPicture(); ~CXTPImageEditorPicture(); public: void Apply(); void Init(UINT nID, CXTPImageEditorDlg* pParentWnd); XTPImageEditorTools GetSelectedTool(); COLORREF GetSelectedColor(); CPoint ClientToPicture(CPoint pt); static void AFX_CDECL CopyBitmap(CAlphaBitmap* pBitmapCopyTo, CAlphaBitmap* pBitmapCopyFrom, CSize sz, CPoint ptOffset = 0, COLORREF clrTransparentFrom = XTPCOLOR_ERASE, COLORREF clrTransparentTo = XTPCOLOR_ERASE, CDC* pDC = 0); COLORREF GetPicturePixel(CPoint point); void FixAlphaLayer(CAlphaBitmap* pBitmap, CAlphaBitmap* pPictureBitmap); void Undo(); void Redo(); void Clear(); void Copy(); void Paste(); void Load(); void MovePicture(CPoint ptOffset); void OnPictureChanged(); protected: DECLARE_MESSAGE_MAP() afx_msg void OnPaint(); afx_msg void OnLButtonDown(UINT nFlags, CPoint point); afx_msg void OnMouseMove(UINT nFlags, CPoint point); afx_msg void OnCaptureChanged(CWnd* pWnd); afx_msg void OnLButtonUp(UINT nFlags, CPoint point); afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message); public: CSize m_szPicture; CSize m_szItem; CXTPImageEditorDlg* m_pParentWnd; CDC m_dcPicture; CAlphaBitmap* m_pCurrentBitmap; CAlphaBitmap* m_pPictureBitmap; CList m_lstUndo; CList m_lstRedo; CPoint m_ptTracked; BOOL m_bTracked; COLORREF m_clrDraw; HCURSOR m_hCursorLine; HCURSOR m_hCursorFillColor; HCURSOR m_hCursorPencil; HCURSOR m_hCursorPickColor; }; /** * @brief * Internal class used int CXTPImageEditorDlg */ class _XTP_EXT_CLASS CXTPImageEditorPreview : public CStatic { public: CXTPImageEditorPreview(); public: void Init(UINT nID, CXTPImageEditorDlg* pParentWnd); protected: DECLARE_MESSAGE_MAP() afx_msg void OnPaint(); protected: CXTPImageEditorDlg* m_pParentWnd; CSize m_szPicture; }; /** @endcond */ /** * @brief * CXTPImageEditorDlg is a CDialog derived class. * It represents the dialog for icons edition. */ class _XTP_EXT_CLASS CXTPImageEditorDlg : public CDialog { private: /** * @brief * Child Tools bar. */ class CDlgToolBar : public CXTPToolBar { public: CDlgToolBar(); }; public: /** * @brief * Constructs a CXTPImageEditorDlg object. * @param pParent Pointer to the object's parent window. * @param bCommandBarsEditor TRUE if Dialog used in Customize mode. */ CXTPImageEditorDlg(CWnd* pParent = NULL, BOOL bCommandBarsEditor = FALSE); public: /** * @brief * Sets the icon to edit. * @param pHandle Reference to a CXTPImageManagerIconHandle object that * represents the handle of the icon. */ void SetIcon(CXTPImageManagerIconHandle& pHandle); /** * @brief * Sets the icon size to edit. * @param szIcon Icon size. */ void SetIconSize(CSize szIcon); /** * @brief * Retrieves the edited icon. * @param pHandle Handle of the icon. */ void GetIcon(CXTPImageManagerIconHandle* pHandle); protected: /** @cond */ DECLARE_MESSAGE_MAP() //{{AFX_VIRTUAL(CXTPImageEditorDlg) protected: virtual void DoDataExchange(CDataExchange* pDX); /**< DDX/DDV support */ virtual BOOL OnInitDialog(); //}}AFX_VIRTUAL //{{AFX_MSG(CXTPImageEditorDlg) afx_msg void OnUpdateButtonTool(CCmdUI* pCmdUI); afx_msg void OnButtonTool(UINT nID); afx_msg LRESULT OnKickIdle(WPARAM wp, LPARAM lCount); afx_msg void OnUpdateButtonUndo(CCmdUI* pCmdUI); afx_msg void OnButtonUndo(); afx_msg void OnUpdateButtonRedo(CCmdUI* pCmdUI); afx_msg void OnButtonRedo(); afx_msg void OnButtonClear(); afx_msg void OnButtonCopy(); afx_msg void OnButtonPaste(); afx_msg void OnButtonOpen(); afx_msg void OnMoveButton(UINT nID); afx_msg BOOL OnToolTipText(UINT, NMHDR* pNMHDR, LRESULT* pResult); afx_msg void OnDestroy(); //}}AFX_MSG /** @endcond */ private: void OnPictureChanged(); void OnPickerClick(NMHDR* pNMHDR, LRESULT* pResult); void OnSelectorClick(UINT id, NMHDR* pNMHDR, LRESULT* pResult); void OnEraseClick(NMHDR* pNMHDR, LRESULT* pResult); void SetSelected(CXTPImageEditorPicker* pPicker); void FixAlphaLayer(LPBYTE pBits, UINT nCount); public: enum { IDD = XTP_IDD_IMAGEEDITOR_DIALOG /**< Dialog resource identifier. */ }; private: CButton m_gboxTools; CButton m_gboxMove; CDlgToolBar m_wndToolbarTools; CDlgToolBar m_wndToolbarMove; CXTPImageEditorPicker m_wndSelector[16]; CXTPImageEditorPicker m_wndPicker; CXTPImageEditorPicker m_wndSelectorErase; CXTPImageEditorPicture m_wndPicture; CXTPImageEditorPreview m_wndPreview; CXTPImageEditorPicker* m_pSelected; XTPImageEditorTools m_toolSelected; XTPImageEditorTools m_toolPrevious; CSize m_szPicture; BOOL m_bCommandBarsEditor; private: friend class CXTPImageEditorPicture; friend class CXTPImageEditorPreview; }; /** @cond */ # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" #endif // !defined(__XTP_IMAGEEDITORDLG_H__) /** @endcond */