/** * @file XTPControlComboBoxExt.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(__XTPCONTROLCOMBOBOXEXT_H__) # define __XTPCONTROLCOMBOBOXEXT_H__ /** @endcond */ # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" /** * @brief * The XTP_FN_SETFORMAT notification sent by CXTPControlFontComboBox to set the * current RichEdit selection format. * * Example: * Here is an example of how an application would process the XTP_FN_SETFORMAT * message. *
 * BEGIN_MESSAGE_MAP(CApplicationView, CRichEditView)
 *     //{{AFX_MSG_MAP(CApplicationView)
 *     ON_NOTIFY(XTP_FN_SETFORMAT, ID_EDIT_SIZE, OnSetCharFormat)
 *     //}}AFX_MSG_MAP
 * END_MESSAGE_MAP()
 *
 * void CApplicationView::OnSetCharFormat(NMHDR* pNMHDR, LRESULT* pResult)
 * {
 *    CHARFORMAT& cf = ((NMXTPCHARHDR*)pNMHDR)->cf;
 *    SetCharFormat(cf);
 *    *pResult = 1;
 * }
 * 
* @see * XTP_FN_GETFORMAT, CXTPControlFontComboBox */ const UINT XTP_FN_SETFORMAT = 0x1000; /** * @brief * The XTP_FN_GETFORMAT notification sent by CXTPControlFontComboBox to get the * current RichEdit selection format * * Example: * Here is an example of how an application would process the XTP_FN_GETFORMAT * message. *
 * BEGIN_MESSAGE_MAP(CApplicationView, CRichEditView)
 *     //{{AFX_MSG_MAP(CApplicationView)
 *     ON_NOTIFY(XTP_FN_GETFORMAT, ID_EDIT_SIZE, OnGetCharFormat)
 *     //}}AFX_MSG_MAP
 * END_MESSAGE_MAP()
 *
 * void CApplicationView::OnGetCharFormat(NMHDR* pNMHDR, LRESULT* pResult)
 * {
 *    CHARFORMAT& cf = ((NMXTPCHARHDR*)pNMHDR)->cf;
 *    cf = GetCharFormatSelection();
 *    *pResult = 1;
 * }
 * 
* @see * XTP_FN_SETFORMAT, CXTPControlFontComboBox */ const UINT XTP_FN_GETFORMAT = 0x1001; /** * @brief * Structure used as a parameter for XTP_FN_SETFORMAT and XTP_FN_GETFORMAT messages. * * Example: * See Example of XTP_FN_SETFORMAT. * @see * XTP_FN_SETFORMAT, XTP_FN_GETFORMAT, CXTPControlFontComboBox */ struct NMXTPCHARHDR : public NMXTPCONTROL { /** @cond */ /** * @brief * Constructs a NMXTPCHARHDR object */ NMXTPCHARHDR() { cf.cbSize = sizeof(CHARFORMAT); } /** @endcond */ CHARFORMAT cf; /**< Character formatting in a rich edit control. */ }; /** * @brief * CXTPControlSizeComboBox is a CXTPControlComboBox derived class. It * represents the size picker. */ class _XTP_EXT_CLASS CXTPControlSizeComboBox : public CXTPControlComboBox { /** @cond */ DECLARE_XTP_CONTROL(CXTPControlSizeComboBox) /** @endcond */ public: /** * @brief * Constructs a CXTPControlSizeComboBox object. */ CXTPControlSizeComboBox(); /** * @brief * Destroys a CXTPControlSizeComboBox object, handles cleanup * and deallocation. */ virtual ~CXTPControlSizeComboBox(); public: /** * @brief * Call this method to set the current size. * @param nTwips Size, in twips, to be set */ void SetTwipSize(int nTwips); /** * @brief * This method is called to convert string to twip size. * @param lpszText String contains twips number. * @return Converts string to twip size */ static int AFX_CDECL GetTwipSize(LPCTSTR lpszText); /** * @brief * This method is called to convert twips to string. * @param nTwips twips number to convert. * @return Returns converted twips to string */ static CString AFX_CDECL TwipsToPointString(int nTwips); protected: /** * @brief * This method is called to pop-up the control. * @param bPopup TRUE to set pop-up. * @return * TRUE if successful; otherwise FALSE. */ virtual BOOL OnSetPopup(BOOL bPopup); /** * @brief * Call this method to retrieve the current user selected size. * @return * The current size. */ int GetTwipSize() const; /** * @brief * This method is called when the control is executed. */ virtual void OnExecute(); private: void EnumFontSizes(CDC& dc, LPCTSTR pFontName); static BOOL CALLBACK AFX_EXPORT EnumSizeCallBack(LOGFONT FAR* /*lplf*/, LPNEWTEXTMETRIC lpntm, int FontType, LPVOID lpv); void InsertSize(int nSize); private: int m_nLogVert; int m_nTwipsLast; }; /** * @brief * CXTPControlFontComboBoxList is a CXTPControlComboBoxList derived * class. It represents the font picker pop-up. */ class _XTP_EXT_CLASS CXTPControlFontComboBoxList : public CXTPControlComboBoxList { /** @cond */ DECLARE_XTP_COMMANDBAR(CXTPControlFontComboBoxList) /** @endcond */ public: /** @cond */ class _XTP_EXT_CLASS CFontDesc { public: CFontDesc(LPCTSTR lpszName, LPCTSTR lpszScript, BYTE nCharSet, BYTE nPitchAndFamily, DWORD dwFlags); CString m_strName; CString m_strScript; BYTE m_nCharSet; BYTE m_nPitchAndFamily; DWORD m_dwFlags; }; class _XTP_EXT_CLASS CFontDescHolder { public: static BOOL CALLBACK AFX_EXPORT EnumFamScreenCallBack(ENUMLOGFONT* pelf, NEWTEXTMETRICEX* /*lpntm*/, int FontType, LPVOID pThis); static BOOL CALLBACK AFX_EXPORT EnumFamScreenCallBackEx(ENUMLOGFONTEX* pelf, NEWTEXTMETRICEX* /*lpntm*/, int FontType, LPVOID pThis); void AddFont(ENUMLOGFONT* pelf, DWORD dwType, LPCTSTR lpszScript = NULL); void EnumFontFamilies(); ~CFontDescHolder() { for (int i = 0; i < m_arrayFontDesc.GetSize(); i++) delete m_arrayFontDesc[i]; } public: CArray m_arrayFontDesc; }; /** @endcond */ protected: /** * @brief * Either reads this object from or writes this object to an archive. * @param pPX A CXTPPropExchange object to serialize to or from. */ virtual void DoPropExchange(CXTPPropExchange* pPX); /** * @brief * Call this method to make a copy of the command bar. * @param pCommandBar Command bar to be copied. * @param bRecursive TRUE to copy recursively. */ void Copy(CXTPCommandBar* pCommandBar, BOOL bRecursive = FALSE); /** * @brief * Creates a list box. */ void CreateListBox(); public: /** * @brief * This method is called to add all fonts to the list. * @param dwStyleListBox Flags to be used in EnumFontFamiliesEx. Currently not supported. */ void EnumFontFamiliesEx(BOOL dwStyleListBox = 1); protected: DWORD m_dwStyleListBox; /**< Style of the control. */ private: friend class CXTPControlFontComboBox; }; /** * @brief * CXTPControlFontComboBox is a CXTPControlComboBox derived class. It * represents the font picker control. */ class _XTP_EXT_CLASS CXTPControlFontComboBox : public CXTPControlComboBox { /** @cond */ DECLARE_XTP_CONTROL(CXTPControlFontComboBox) /** @endcond */ public: /** * @brief * Constructs a CXTPControlFontComboBox object. * @param dwStyleListBox Flags to be used in list box. Currently not supported, * must be default. */ CXTPControlFontComboBox(DWORD dwStyleListBox = 1); /** * @brief * Destroys a CXTPControl object, handles cleanup and deallocation. */ virtual ~CXTPControlFontComboBox(); public: /** * @brief * Call this method to set the current font of the picker. * @param cf CHARFORMAT structure contains information about character * formatting in a rich edit control. */ void SetCharFormat(CHARFORMAT& cf); protected: /** * @brief * This method is called when the control is executed. */ virtual void OnExecute(); }; /** @cond */ # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" #endif //#if !defined(__XTPCONTROLCOMBOBOXEXT_H__) /** @endcond */