home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / mfc / ole / wordpad / formatba.h < prev    next >
C/C++ Source or Header  |  1998-03-26  |  4KB  |  168 lines

  1. // formatba.h : header file
  2. //
  3. // This is a part of the Microsoft Foundation Classes C++ library.
  4. // Copyright (C) 1992-1998 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // This source code is only intended as a supplement to the
  8. // Microsoft Foundation Classes Reference and related
  9. // electronic documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // Microsoft Foundation Classes product.
  12.  
  13. #ifndef __FORMATBA_H__
  14. #define __FORMATBA_H__
  15.  
  16. class CWordPadView;
  17.  
  18. /*
  19. typedef struct tagNMHDR
  20. {
  21.     HWND  hwndFrom;
  22.     UINT  idFrom;
  23.     UINT  code;         // NM_ code
  24. }   NMHDR;
  25. */
  26.  
  27. struct CHARHDR : public tagNMHDR
  28. {
  29.     CHARFORMAT cf;
  30.     CHARHDR() {cf.cbSize = sizeof(CHARFORMAT);}
  31. };
  32.  
  33. #define FN_SETFORMAT    0x1000
  34. #define FN_GETFORMAT    0x1001
  35.  
  36. /////////////////////////////////////////////////////////////////////////////
  37. // CLocalComboBox
  38.  
  39. class CLocalComboBox : public CComboBox
  40. {
  41. public:
  42.  
  43. //Attributes
  44.     CPtrArray m_arrayFontDesc;
  45.     static int m_nFontHeight;
  46.     int m_nLimitText;
  47.     BOOL HasFocus()
  48.     {
  49.         HWND hWnd = ::GetFocus();
  50.         return (hWnd == m_hWnd || ::IsChild(m_hWnd, hWnd));
  51.     }
  52.     void GetTheText(CString& str);
  53.     void SetTheText(LPCTSTR lpszText,BOOL bMatchExact = FALSE);
  54.  
  55. //Operations
  56.     BOOL LimitText(int nMaxChars);
  57.  
  58. // Implementation
  59. public:
  60.     virtual BOOL PreTranslateMessage(MSG* pMsg);
  61.  
  62.     // Generated message map functions
  63.     //{{AFX_MSG(CLocalComboBox)
  64.     afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  65.     //}}AFX_MSG
  66.     DECLARE_MESSAGE_MAP()
  67. };
  68.  
  69. class CFontComboBox : public CLocalComboBox
  70. {
  71. public:
  72.     CFontComboBox();
  73.  
  74. //Attributes
  75.     CBitmap m_bmFontType;
  76.  
  77. //Operations
  78.     void EnumFontFamiliesEx(CDC& dc, BYTE nCharSet = DEFAULT_CHARSET);
  79.     void AddFont(ENUMLOGFONT* pelf, DWORD dwType, LPCTSTR lpszScript = NULL);
  80.     void MatchFont(LPCTSTR lpszName, BYTE nCharSet);
  81.     void EmptyContents();
  82.  
  83.     static BOOL CALLBACK AFX_EXPORT EnumFamScreenCallBack(
  84.         ENUMLOGFONT* pelf, NEWTEXTMETRICEX* /*lpntm*/, int FontType,
  85.         LPVOID pThis);
  86.     static BOOL CALLBACK AFX_EXPORT EnumFamPrinterCallBack(
  87.         ENUMLOGFONT* pelf, NEWTEXTMETRICEX* /*lpntm*/, int FontType,
  88.         LPVOID pThis);
  89.     static BOOL CALLBACK AFX_EXPORT EnumFamScreenCallBackEx(
  90.         ENUMLOGFONTEX* pelf, NEWTEXTMETRICEX* /*lpntm*/, int FontType,
  91.         LPVOID pThis);
  92.     static BOOL CALLBACK AFX_EXPORT EnumFamPrinterCallBackEx(
  93.         ENUMLOGFONTEX* pelf, NEWTEXTMETRICEX* /*lpntm*/, int FontType,
  94.         LPVOID pThis);
  95.  
  96. //Overridables
  97.     virtual void DrawItem(LPDRAWITEMSTRUCT lpDIS);
  98.     virtual void MeasureItem(LPMEASUREITEMSTRUCT lpMIS);
  99.     virtual int CompareItem(LPCOMPAREITEMSTRUCT lpCIS);
  100.     // Generated message map functions
  101.     //{{AFX_MSG(CFontComboBox)
  102.     afx_msg void OnDestroy();
  103.     //}}AFX_MSG
  104.     DECLARE_MESSAGE_MAP()
  105. };
  106.  
  107. class CSizeComboBox : public CLocalComboBox
  108. {
  109. public:
  110.     CSizeComboBox();
  111.  
  112. //Attributes
  113.     int m_nLogVert;
  114.     int m_nTwipsLast;
  115. public:
  116.     void EnumFontSizes(CDC& dc, LPCTSTR pFontName);
  117.     static BOOL FAR PASCAL EnumSizeCallBack(LOGFONT FAR* lplf,
  118.         LPNEWTEXTMETRIC lpntm,int FontType, LPVOID lpv);
  119.     void TwipsToPointString(LPTSTR lpszBuf, int nTwips);
  120.     void SetTwipSize(int nSize);
  121.     int GetTwipSize();
  122.     void InsertSize(int nSize);
  123. };
  124.  
  125. /////////////////////////////////////////////////////////////////////////////
  126. // CFormatBar dialog
  127. class CFormatBar : public CToolBar
  128. {
  129. // Construction
  130. public:
  131.     CFormatBar();
  132.  
  133. // Operations
  134. public:
  135.     void PositionCombos();
  136.     void SyncToView();
  137.  
  138. // Attributes
  139. public:
  140.     CDC m_dcPrinter;
  141.     CSize m_szBaseUnits;
  142.     CFontComboBox m_comboFontName;
  143.     CSizeComboBox m_comboFontSize;
  144.  
  145. // Implementation
  146. public:
  147.     void NotifyOwner(UINT nCode);
  148.  
  149. protected:
  150.     virtual void OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler);
  151.     void SetCharFormat(CCharFormat& cf);
  152.  
  153.     // Generated message map functions
  154.     //{{AFX_MSG(CFormatBar)
  155.     afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  156.     afx_msg void OnDestroy();
  157.     //}}AFX_MSG
  158.     afx_msg void OnFontNameKillFocus();
  159.     afx_msg void OnFontSizeKillFocus();
  160.     afx_msg void OnFontSizeDropDown();
  161.     afx_msg void OnComboCloseUp();
  162.     afx_msg void OnComboSetFocus();
  163.     afx_msg LONG OnPrinterChanged(UINT, LONG); //handles registered message
  164.     DECLARE_MESSAGE_MAP()
  165. };
  166.  
  167. #endif
  168.