Source code of Windows XP (NT5)
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.

271 lines
8.2 KiB

  1. // Tfont.h : interface of the CTfont class
  2. // This class takes text entry from the user.
  3. // It is derived from the CEdit class
  4. /***************************************************************************/
  5. #ifndef __Tfont_H__
  6. #define __Tfont_H__
  7. // TOOLBAAR CONSTANTS -- Bitmap Positions and Toolbar Positions
  8. #define MAX_TBAR_ITEMS 12 // positions 0 through 11
  9. #define BOLD_BMP_POS 0
  10. #define ITALIC_BMP_POS 1
  11. #define UNDERLINE_BMP_POS 2
  12. #define VERTEDIT_BMP_POS 3
  13. #define PEN_BMP_POS 4
  14. #define EDITTEXT_BMP_POS 5
  15. #define KEYBOARD_BMP_POS 6 // still wasting space in image
  16. #define INS_SPACE_BMP_POS 7
  17. #define BACKSPACE_BMP_POS 8
  18. #define NEWLINE_BMP_POS 9
  19. #define SHADOW_BMP_POS -1 // don't exist currently
  20. #define BOLD_TBAR_POS 0
  21. #define ITALIC_TBAR_POS 1
  22. #define UNDERLINE_TBAR_POS 2
  23. #define VERTEDIT_TBAR_POS 3
  24. #define SPACE_ONE 4
  25. #define PEN_TBAR_TEXT_POS 5
  26. #define INS_SPACE_TBAR_POS 5
  27. #define BACKSPACE_TBAR_POS 6
  28. #define NEWLINE_TBAR_POS 7
  29. #define SPACE_TWO 8
  30. #define EDITTEXT_TBAR_POS 9
  31. #define SPACE_THREE 10
  32. #define PEN_TBAR_PEN_POS 11
  33. #define SHADOW_TBAR_POS -1 // don't exist currently
  34. #define KEYBOARD_TBAR_POS -1 // don't exist currently
  35. #define FONT_BMP_TXT_BORDER 2 // # pixels between font bmp (prn/tt) and text
  36. #define UM_DELAYED_TOOLBAR WM_USER + 900
  37. // definde font types used by m_iFontType in CTfont class
  38. #define TT_FONT 0x0001
  39. #define TT_OPENTYPE_FONT 0x0002
  40. #define PS_OPENTYPE_FONT 0x0004
  41. #define TYPE1_FONT 0x0008
  42. #define DEVICE_FONT 0x0010
  43. #define RASTER_FONT 0x0020
  44. #define NumCPic 5
  45. class CTedit; // forward reference for change/undo notification
  46. //class CAttrEdit; // forward reference for setfont,...notification
  47. /******************************************************************************/
  48. class CTfontTbar : public CToolBar
  49. {
  50. private:
  51. protected: // create from serialization only
  52. DECLARE_DYNCREATE(CTfontTbar)
  53. protected:
  54. //{{AFX_MSG(CTfontTbar)
  55. // NOTE - the ClassWizard will add and remove member functions here.
  56. // DO NOT EDIT what you see in these blocks of generated code !
  57. // afx_msg void OnInsertObject(); // OLE support
  58. //}}AFX_MSG
  59. DECLARE_MESSAGE_MAP()
  60. public:
  61. CTfontTbar(void);
  62. virtual ~CTfontTbar(void);
  63. BOOL Create(CWnd* pcParentWnd, BOOL bShowPen = FALSE);
  64. };
  65. /******************************************************************************/
  66. class CTfontDlg : public CDialogBar
  67. {
  68. private:
  69. CPic m_cPictures[NumCPic];
  70. int m_Max_cx_FontType_BMP;
  71. void SetColorsInDC(HDC hdc, BOOL bInverted);
  72. protected: // create from serialization only
  73. DECLARE_DYNCREATE(CTfontDlg)
  74. protected:
  75. //{{AFX_MSG(CTfontDlg)
  76. afx_msg void OnRButtonDown ( UINT nFlags, CPoint point );
  77. //
  78. // MFC 4 - had to put the WM_DRAWITEM and WM_MEASUREITEM handlers here instead
  79. // of CTfont. This dialog is the real parent of the owner-draw combobox, don't
  80. // know how the old version worked with these handlers in CTfont.
  81. //
  82. afx_msg void OnDrawItem (int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct);
  83. afx_msg void OnMeasureItem (int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct);
  84. afx_msg DWORD OnGetDefId ( void );
  85. //}}AFX_MSG
  86. DECLARE_MESSAGE_MAP()
  87. public:
  88. CTfontDlg(void);
  89. void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct, CString *pcStringText);
  90. virtual ~CTfontDlg(void);
  91. BOOL Create(CWnd* pcParentWnd);
  92. };
  93. /******************************************************************************/
  94. class CCharSetDesc;
  95. class CFontDesc;
  96. /******************************************************************************/
  97. class CTfont : public CMiniFrmWnd
  98. {
  99. private:
  100. int m_iControlIDLastChange;
  101. int m_iWeight;
  102. CFont m_cCurrentFont;
  103. CString m_cStrTypeFaceName;
  104. CString m_cStrTypeFaceNamePrev;
  105. int m_iPointSize;
  106. int m_iPointSizePrev;
  107. CString m_strFontName;
  108. int m_iFontType;
  109. BYTE m_nCharSet;
  110. BYTE m_nCharSetPrev;
  111. BOOL m_bBoldOn;
  112. BOOL m_bItalicOn;
  113. BOOL m_bUnderlineOn;
  114. BOOL m_bVertEditOn;
  115. BOOL m_bShadowOn;
  116. BOOL m_bPenOn;
  117. CRect m_cRectWindow;
  118. BOOL m_bDisplayCText;
  119. BOOL m_bInUpdate;
  120. class CTedit* m_pcTedit;
  121. CTfontDlg m_cTfontDlg;
  122. CTfontTbar *m_pcTfontTbar; // must be dynamic for changing buttons (delete/new)
  123. BYTE PickCharSet(CCharSetDesc *pCharSetDescList, int iCharSetSelection);
  124. void ResizeWindow(void);
  125. void ProcessNewTypeface(void);
  126. void UpdateEditControlFont(void);
  127. void FreeMemoryFromCBox(void);
  128. void OnTypeFaceComboBoxUpdate(void);
  129. void OnPointSizeComboBoxUpdate(void);
  130. void SaveToIniFile(void);
  131. void ReadFromIniFile(void);
  132. // was used for spin control to save point sizes,...
  133. // CMapWordToPtr PointSizeMap;
  134. // void EmptyMap(void);
  135. void RefreshFontList(void);
  136. int EnumFontFace( ENUMLOGFONTEX* lpEnumLogFont,
  137. NEWTEXTMETRICEX* lpNewTextMetric,
  138. int iFontType );
  139. int EnumFontSizes( LPENUMLOGFONT lpEnumLogFont,
  140. LPNEWTEXTMETRIC lpNewTextMetric,
  141. int iFontType );
  142. protected: // create from serialization only
  143. DECLARE_DYNCREATE(CTfont)
  144. //{{AFX_MSG(CTfont)
  145. afx_msg void OnTypefaceChange();
  146. afx_msg void OnPointSizeChange();
  147. afx_msg BOOL OnEraseBkgnd(CDC* pDC);
  148. afx_msg void OnSetFocus(CWnd* pOldWnd);
  149. afx_msg void OnDestroy();
  150. afx_msg void OnMove(int x, int y);
  151. afx_msg void OnClose();
  152. afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
  153. afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  154. afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
  155. //}}AFX_MSG
  156. DECLARE_MESSAGE_MAP()
  157. public:
  158. CTfont();
  159. CTfont( CTedit *pcTedit );
  160. ~CTfont(void);
  161. CWnd* GetFontSizeControl() { return ((m_cTfontDlg.GetSafeHwnd() == NULL)? NULL:
  162. m_cTfontDlg.GetDlgItem( IDC_POINTSIZE ) ); }
  163. CWnd* GetFontFaceControl() { return ((m_cTfontDlg.GetSafeHwnd() == NULL)? NULL:
  164. m_cTfontDlg.GetDlgItem( IDC_TYPEFACE ) ); }
  165. //MY AFX_MSG(CTfont)
  166. afx_msg void OnBold ( void );
  167. afx_msg void OnItalic ( void );
  168. afx_msg void OnUnderline ( void );
  169. afx_msg void OnVertEdit ( void );
  170. afx_msg void OnVertEditUpdate ( CCmdUI* pCmdUI );
  171. afx_msg void OnShadow ( void );
  172. afx_msg void OnPen ( void );
  173. afx_msg long OnDelayedPen( WPARAM wParam, LPARAM lParam );
  174. afx_msg void OnEditText ( void );
  175. afx_msg void OnKeyboard ( void );
  176. afx_msg void OnInsSpace ( void );
  177. afx_msg void OnBackSpace ( void );
  178. afx_msg void OnNewLine ( void );
  179. //MY AFX_MSG
  180. BOOL IsBoldOn ( void ) { return m_bBoldOn; }
  181. BOOL IsItalicOn ( void ) { return m_bItalicOn; }
  182. BOOL IsUnderlineOn ( void ) { return m_bUnderlineOn; }
  183. BOOL IsVertEditOn ( void ) { return m_bVertEditOn; }
  184. BOOL IsShadowOn ( void ) { return m_bShadowOn; }
  185. BOOL Create ( CRect rectEditArea );
  186. void Undo ( void );
  187. void RefreshToolBar( void );
  188. void GetFontInfo ( int iFontSelection, BYTE nCharSetSelection);
  189. static int CALLBACK EnumFontFaceProc(ENUMLOGFONTEX* lpEnumLogFont,
  190. NEWTEXTMETRICEX* lpNewTextMetric,
  191. int iFontType, LPARAM lParam);
  192. static int CALLBACK EnumFontOneFaceProc(LPENUMLOGFONT lpEnumLogFont,
  193. LPNEWTEXTMETRIC lpNewTextMetric,
  194. int iFontType, LPARAM lParam);
  195. virtual WORD GetHelpOffset() {return 0;} // for now just return 0
  196. virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
  197. virtual void RecalcLayout(BOOL bNotify = TRUE);
  198. };
  199. /***************************************************************************/
  200. #endif // __Tfont_H__