153 lines
5.2 KiB
C++
153 lines
5.2 KiB
C++
// XMonoFontDialog.h Version 1.1
|
|
//
|
|
// Author: Hans Dietrich
|
|
// hdietrich@gmail.com
|
|
//
|
|
// License:
|
|
// This software is released into the public domain. You are free to use
|
|
// it in any way you like, except that you may not sell this source code.
|
|
//
|
|
// This software is provided "as is" with no expressed or implied warranty.
|
|
// I accept no liability for any damage or loss of business that this
|
|
// software may cause.
|
|
//
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
#ifndef XMONOFONTDIALOG_H
|
|
#define XMONOFONTDIALOG_H
|
|
|
|
#include "XMonoFontListCombo.h"
|
|
|
|
//=============================================================================
|
|
// font filters
|
|
//=============================================================================
|
|
#define XFONT_SHOW_SYMBOL 0x01 // show symbol fonts
|
|
#define XFONT_SHOW_MONOSPACED 0x02 // show monospaced fonts
|
|
#define XFONT_SHOW_BOLD 0x04 // show bold fonts
|
|
#define XFONT_SHOW_ITALIC 0x08 // show italic fonts
|
|
#define XFONT_SHOW_NORMAL 0x10 // show normal fonts
|
|
#define XFONT_SHOW_ALL 0xFF // show all
|
|
|
|
//=============================================================================
|
|
// bit definitions for m_dwXFontFlags
|
|
//=============================================================================
|
|
#define XFONT_TRUETYPE 0x00000001
|
|
#define XFONT_OPENTYPE 0x00000002
|
|
#define XFONT_RASTER 0x00000004
|
|
#define XFONT_VECTOR 0x00000008
|
|
#define XFONT_FAMILY_MASK 0x000000F0
|
|
#define XFONT_BOLD 0x00000100
|
|
#define XFONT_ITALIC 0x00000200
|
|
#define XFONT_SYMBOL 0x00000400
|
|
#define XFONT_MONOSPACED 0x00000800
|
|
#define XFONT_OEM 0x00001000
|
|
#define XFONT_WEIGHT_MASK 0x0FFF0000
|
|
|
|
//=============================================================================
|
|
class CXMonoFontDialog : public CDialog
|
|
//=============================================================================
|
|
{
|
|
DECLARE_DYNAMIC(CXMonoFontDialog)
|
|
|
|
// Construction
|
|
public:
|
|
CXMonoFontDialog(LPLOGFONT lplfInitial = NULL,
|
|
DWORD dwFlags = 0,
|
|
CDC *pdcPrinter = NULL,
|
|
CWnd *pParentWnd = NULL);
|
|
virtual ~CXMonoFontDialog();
|
|
|
|
// Dialog Data
|
|
//{{AFX_DATA(CXMonoFontDialog)
|
|
CXMonoFontListCombo m_FontList;
|
|
CComboBox m_FontSizes;
|
|
CStatic m_Sample;
|
|
CStatic m_MonospacedLabel;
|
|
//}}AFX_DATA
|
|
|
|
// Attributes
|
|
public:
|
|
|
|
// CFontDialog
|
|
COLORREF GetColor() const { return RGB(0,0,0); }
|
|
void GetCurrentFont(LPLOGFONT lplf);
|
|
CString GetFaceName() const { return m_strFaceName; }
|
|
int GetSize() const { return 10*m_nPointSize; }
|
|
CString GetStyleName() const { return _T(""); }
|
|
int GetWeight() const
|
|
{ return (m_dwXFontFlags & XFONT_WEIGHT_MASK) >> 16; }
|
|
// the following 4 functions report the selection in the style combo,
|
|
// which we do not use
|
|
BOOL IsBold() const { return FALSE; }
|
|
BOOL IsItalic() const { return FALSE; }
|
|
BOOL IsStrikeOut() const { return FALSE; }
|
|
BOOL IsUnderline() const { return FALSE; }
|
|
|
|
// CXMonoFontDialog
|
|
CString GetCaption() { return m_strCaption; }
|
|
DWORD GetFontData() { return m_dwXFontFlags; }
|
|
DWORD GetFontFilter() { return m_dwFontFilter; }
|
|
CString GetSampleText() { return m_strSampleText; }
|
|
LONG GetTmHeight() { return m_Height; }
|
|
BOOL IsMonospaced() { return (m_dwXFontFlags & XFONT_MONOSPACED); }
|
|
BOOL IsOpenType() { return (m_dwXFontFlags & XFONT_OPENTYPE); }
|
|
BOOL IsSymbol() { return (m_dwXFontFlags & XFONT_SYMBOL); }
|
|
BOOL IsTrueType() { return (m_dwXFontFlags & XFONT_TRUETYPE); }
|
|
BOOL IsVector() { return (m_dwXFontFlags & XFONT_VECTOR); }
|
|
CXMonoFontDialog& SetCaption(LPCTSTR strCaption)
|
|
{ m_strCaption = strCaption; return *this; }
|
|
CXMonoFontDialog& SetFontFilter(DWORD dwFontFilter)
|
|
{ m_dwFontFilter = dwFontFilter; return *this; }
|
|
CXMonoFontDialog& SetMonospacedLabel(LPCTSTR lpszLabel)
|
|
{ m_strMonospacedLabel = lpszLabel; return *this; }
|
|
CXMonoFontDialog& SetSampleText(LPCTSTR lpszSampleText)
|
|
{ m_strSampleText = lpszSampleText; return *this; }
|
|
CXMonoFontDialog& ShowMonospacedLabel(BOOL bShow)
|
|
{ m_bShowMonospacedLabel = bShow; return *this; }
|
|
CXMonoFontDialog& ShowMonospacedAsBold(BOOL bShow)
|
|
{ m_bShowMonospacedAsBold = bShow; return *this; }
|
|
|
|
// ClassWizard generated virtual function overrides
|
|
//{{AFX_VIRTUAL(CXMonoFontDialog)
|
|
protected:
|
|
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
|
//}}AFX_VIRTUAL
|
|
|
|
// Implementation
|
|
protected:
|
|
LOGFONT m_lfInitial;
|
|
CFont m_SampleFont;
|
|
CString m_strCaption;
|
|
CString m_strSampleText;
|
|
CString m_strMonospacedLabel;
|
|
DWORD m_dwFontFilter;
|
|
BOOL m_bShowMonospacedLabel;
|
|
BOOL m_bShowMonospacedAsBold;
|
|
CImageList m_FontType;
|
|
|
|
// current font
|
|
CString m_strFaceName;
|
|
LONG m_Height;
|
|
int m_nPointSize;
|
|
LOGFONT m_lfCurrent;
|
|
DWORD m_dwXFontFlags;
|
|
|
|
void SetCurFont();
|
|
|
|
//{{AFX_MSG(CXMonoFontDialog)
|
|
afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
|
|
virtual BOOL OnInitDialog();
|
|
afx_msg void OnSelchangeFontList();
|
|
afx_msg void OnSelchangeFontSize();
|
|
afx_msg void OnEditchangeFontSize();
|
|
afx_msg void OnTimer(UINT nIDEvent);
|
|
virtual void OnOK();
|
|
//}}AFX_MSG
|
|
DECLARE_MESSAGE_MAP()
|
|
};
|
|
|
|
//{{AFX_INSERT_LOCATION}}
|
|
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
|
|
|
#endif //XMONOFONTDIALOG_H
|