/** * @file XTPSyntaxEditColorComboBox.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(__XTPSYNTAXEDITCOLORCOMBOBOX_H__) # define __XTPSYNTAXEDITCOLORCOMBOBOX_H__ /** @endcond */ # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" /** * @brief * This class allows for colors to be edited by using a combobox control. * It displays the color name and draws a rectangle for each item using the item color. */ class _XTP_EXT_CLASS CXTPSyntaxEditColorComboBox : public CComboBox { /** @cond */ DECLARE_DYNAMIC(CXTPSyntaxEditColorComboBox) /** @endcond */ public: /** * @brief * Standard object constructor. */ CXTPSyntaxEditColorComboBox(); /** * @brief * Standard object destructor. */ virtual ~CXTPSyntaxEditColorComboBox(); public: /** * @brief * Gets the selected color. * @return * The selected color, or COLORREF_NULL if no color is selected. */ COLORREF GetSelColor(); /** * @brief * Sets the selected color. * @param crColor Color to be set. * @return * The index of the newly selected color. */ int SetSelColor(COLORREF crColor); /** * @brief * Removes a specified color. * @param crColor Color to be removed. * @return * The index of the deleted color if successful, otherwise CB_ERR. */ int DeleteColor(COLORREF crColor); /** * @brief * Retrieves the index of a specified color. * @param crColor Color to retrieve the index of. * @return * The index of the specified color if successful, otherwise CB_ERR. */ int FindColor(COLORREF crColor); /** * @brief * Sets the user color value and user color name. * @param crColor User color value to be set. * @param lpszUserText User color name to be set or NULL to use the default. * @return * The index of the user color value if successful, otherwise CB_ERR. */ int SetUserColor(COLORREF crColor, LPCTSTR lpszUserText = NULL); /** * @brief * Gets the user color value. * @return * The user color value. */ COLORREF GetUserColor() const; /** * @brief * Sets the auto color value and auto color name. * @param crColor Auto color value to be set. * @param lpszAutoText Auto color name to be set or NULL to use the default. * @return * The index of the auto color value if successful, otherwise CB_ERR. */ int SetAutoColor(COLORREF crColor, LPCTSTR lpszAutoText = NULL); /** * @brief * Gets the auto color value. * @return * The auto color value. */ COLORREF GetAutoColor() const; /** * @brief * Selects the user color. * @return * The index of the selected user color if successful, otherwise CB_ERR. */ int SelectUserColor(); /** * @brief * Adds the default set of colors. * @return * true if successful, otherwise false. */ virtual bool Init(); /** @cond */ public: virtual void DrawItem(LPDRAWITEMSTRUCT lpDIS); virtual void MeasureItem(LPMEASUREITEMSTRUCT lpMIS); virtual int CompareItem(LPCOMPAREITEMSTRUCT lpCIS); virtual BOOL PreTranslateMessage(MSG* pMsg); protected: virtual void PreSubclassWindow(); virtual BOOL PreCreateWindow(CREATESTRUCT& cs); /** @endcond */ protected: /** * @brief * Adds a new color. * @param crColor Color to be added. * @param nID Resource ID of the color name string. * @return * The index of the newly added color if successful, otherwise CB_ERR. */ virtual int AddColor(COLORREF crColor, UINT nID); /** * @brief * Sends a WM_COMMAND message to the owner window. * @details * Default implementation sends the following notifications: * CBN_SELENDCANCEL, CBN_SELENDOK * @param nCode Notification code. */ virtual void NotifyOwner(UINT nCode); /** * @brief * Gets the index of the currently selected listbox item * (works for dropped state only). * @return * The index of the currently selected listbox item if successful, otherwise LB_ERR. */ virtual int GetLBCurSel() const; /** @cond */ afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt); afx_msg void OnCloseUp(); DECLARE_MESSAGE_MAP() /** @endcond */ private: int m_iPrevSel; bool m_bPreInit; COLORREF m_crAuto; COLORREF m_crUser; }; ///////////////////////////////////////////////////////////////////////////// AFX_INLINE COLORREF CXTPSyntaxEditColorComboBox::GetUserColor() const { return m_crUser; } AFX_INLINE COLORREF CXTPSyntaxEditColorComboBox::GetAutoColor() const { return m_crAuto; } /** * @brief * Exchanges the currently selected color for a CXTPSyntaxEditColorComboBox control. * @param pDX Pointer to a CDataExchange object. * @param nIDC Control ID. * @param value Reference to the color value. */ _XTP_EXT_CLASS void AFXAPI DDX_CBSyntaxColor(CDataExchange* pDX, int nIDC, COLORREF& value); ///////////////////////////////////////////////////////////////////////////// //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" /** @cond */ #endif // !defined(__XTPSYNTAXEDITCOLORCOMBOBOX_H__) /** @endcond */