/** * @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