Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

186 lines
4.6 KiB

  1. // formatba.h : header file
  2. //
  3. // This is a part of the Microsoft Foundation Classes C++ library.
  4. // Copyright (C) 1992-1995 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. #ifndef __FORMATBA_H__
  13. #define __FORMATBA_H__
  14. class CWordPadView;
  15. /*
  16. typedef struct tagNMHDR
  17. {
  18. HWND hwndFrom;
  19. UINT idFrom;
  20. UINT code; // NM_ code
  21. } NMHDR;
  22. */
  23. struct CHARHDR : public tagNMHDR
  24. {
  25. CHARFORMAT cf;
  26. CHARHDR() {cf.cbSize = sizeof(CHARFORMAT);}
  27. };
  28. #define FN_SETFORMAT 0x1000
  29. #define FN_GETFORMAT 0x1001
  30. /////////////////////////////////////////////////////////////////////////////
  31. // CLocalComboBox
  32. class CLocalComboBox : public CComboBox
  33. {
  34. public:
  35. //Attributes
  36. CPtrArray m_arrayFontDesc;
  37. static int m_nFontHeight;
  38. int m_nLimitText;
  39. BOOL HasFocus()
  40. {
  41. HWND hWnd = ::GetFocus();
  42. return (NULL != hWnd) && (hWnd == m_hWnd || ::IsChild(m_hWnd, hWnd));
  43. }
  44. void GetTheText(CString& str);
  45. void SetTheText(LPCTSTR lpszText,BOOL bMatchExact = FALSE);
  46. //Operations
  47. BOOL LimitText(int nMaxChars);
  48. // Implementation
  49. public:
  50. virtual BOOL PreTranslateMessage(MSG* pMsg);
  51. // Generated message map functions
  52. //{{AFX_MSG(CLocalComboBox)
  53. afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  54. //}}AFX_MSG
  55. DECLARE_MESSAGE_MAP()
  56. };
  57. class CFontComboBox : public CLocalComboBox
  58. {
  59. public:
  60. CFontComboBox();
  61. //Attributes
  62. CBitmap m_bmFontType;
  63. //Operations
  64. void EnumFontFamiliesEx(CDC& dc, BYTE nCharSet = DEFAULT_CHARSET);
  65. void AddFont(ENUMLOGFONT* pelf, DWORD dwType, LPCTSTR lpszScript = NULL);
  66. void EmptyContents();
  67. static BOOL CALLBACK AFX_EXPORT EnumFamScreenCallBackEx(
  68. ENUMLOGFONTEX* pelf, NEWTEXTMETRICEX* /*lpntm*/, int FontType,
  69. LPVOID pThis);
  70. static BOOL CALLBACK AFX_EXPORT EnumFamPrinterCallBackEx(
  71. ENUMLOGFONTEX* pelf, NEWTEXTMETRICEX* /*lpntm*/, int FontType,
  72. LPVOID pThis);
  73. //Overridables
  74. virtual void DrawItem(LPDRAWITEMSTRUCT lpDIS);
  75. virtual void MeasureItem(LPMEASUREITEMSTRUCT lpMIS);
  76. virtual int CompareItem(LPCOMPAREITEMSTRUCT lpCIS);
  77. // Generated message map functions
  78. //{{AFX_MSG(CFontComboBox)
  79. afx_msg void OnDestroy();
  80. //}}AFX_MSG
  81. DECLARE_MESSAGE_MAP()
  82. };
  83. class CSizeComboBox : public CLocalComboBox
  84. {
  85. public:
  86. CSizeComboBox();
  87. //Attributes
  88. int m_nLogVert;
  89. int m_nTwipsLast;
  90. public:
  91. void EnumFontSizes(CDC& dc, LPCTSTR pFontName);
  92. static BOOL FAR PASCAL EnumSizeCallBack(LOGFONT FAR* lplf,
  93. LPNEWTEXTMETRIC lpntm,int FontType, LPVOID lpv);
  94. void TwipsToPointString(LPTSTR lpszBuf, int cchBuf, int nTwips);
  95. void SetTwipSize(int nSize);
  96. int GetTwipSize();
  97. void InsertSize(int nSize);
  98. };
  99. class CScriptComboBox : public CLocalComboBox
  100. {
  101. enum {HistorySize = 4};
  102. public:
  103. CScriptComboBox() {m_history_index = 0;}
  104. BYTE PickScript();
  105. private:
  106. //
  107. // HACKHACK: All this history stuff is to help make choosing a script for
  108. // a font easier. There doesn't seem to be anyway to get a "good" script
  109. // for a given font/locale so what we do is save the last serveral scripts
  110. // and hope that the font the user just switched to supports one of them.
  111. //
  112. CString m_script_history[HistorySize];
  113. int m_history_index;
  114. };
  115. /////////////////////////////////////////////////////////////////////////////
  116. // CFormatBar dialog
  117. class CFormatBar : public CToolBar
  118. {
  119. // Construction
  120. public:
  121. CFormatBar();
  122. // Operations
  123. public:
  124. void PositionCombos();
  125. void SyncToView();
  126. // Attributes
  127. public:
  128. CDC m_dcPrinter;
  129. CSize m_szBaseUnits;
  130. CFontComboBox m_comboFontName;
  131. CSizeComboBox m_comboFontSize;
  132. CScriptComboBox m_comboScript;
  133. // Implementation
  134. public:
  135. void NotifyOwner(UINT nCode);
  136. protected:
  137. virtual void OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler);
  138. void SetCharFormat(CCharFormat& cf);
  139. // Generated message map functions
  140. //{{AFX_MSG(CFormatBar)
  141. afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  142. afx_msg void OnDestroy();
  143. //}}AFX_MSG
  144. afx_msg void OnFontNameKillFocus();
  145. afx_msg void OnFontSizeKillFocus();
  146. afx_msg void OnScriptKillFocus();
  147. afx_msg void OnFontSizeDropDown();
  148. afx_msg void OnScriptDropDown();
  149. afx_msg void OnComboCloseUp();
  150. afx_msg void OnComboSetFocus();
  151. afx_msg LONG OnPrinterChanged(UINT, LONG); //handles registered message
  152. DECLARE_MESSAGE_MAP()
  153. };
  154. #endif