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.

142 lines
3.3 KiB

  1. #ifndef __RESCACHE_H__
  2. #define __RESCACHE_H__
  3. //////////////////////////////////////////////////////////////////////////
  4. //
  5. //
  6. // rescache.h --- Header file for CResourceCache
  7. //
  8. //
  9. /*
  10. CResourceCache is a class which contains functions for all the globally cached resources
  11. such as fonts, accelerators etc.
  12. All of these functions initialize on demand.
  13. */
  14. //////////////////////////////////////////////////////////////////////////
  15. //
  16. // Constants
  17. //
  18. // Number of global accelerators. Is the number of tabs, plus 1 for the options button.
  19. const int c_NumTabCtrlKeys = (HH_MAX_TABS+1) + 1 ;
  20. enum {
  21. ACCEL_KEY_OPTIONS = HH_MAX_TABS+1 // The index into the TabCtrlKeys arrary for the options btn.
  22. };
  23. //////////////////////////////////////////////////////////////////////////
  24. //
  25. // CResourceCache
  26. //
  27. class CResourceCache
  28. {
  29. public:
  30. // Constuctor
  31. CResourceCache() ;
  32. // Destruct
  33. ~CResourceCache() ;
  34. public:
  35. //--- Access Functions
  36. char* MsgBoxTitle() ; // title for author message boxes
  37. HFONT GetUIFont() ; // default font to use for listbox, buttons, etc.
  38. HFONT GetAccessableUIFont() ; // A UI font that respects current accessability settings.
  39. HFONT DefaultPrinterFont(HDC hDC);
  40. HACCEL AcceleratorTable();
  41. char TabCtrlKeys(int TabIndex) ; // tab ctrl accelerator keys.
  42. //--- Other functions.
  43. void TabCtrlKeys(int TabIndex, char) ; //Sets an accelerator key. Only used for custom tabs.
  44. void InitRichEdit(); // Loads Riched20.dll, needed for multilingual (wide edit controls).
  45. private:
  46. //--- Initialization functions
  47. void InitMsgBoxTitle() ;
  48. void InitDefaultUIFont(HDC hDC = NULL, HFONT* hFont = NULL) ;
  49. void InitAcceleratorTable();
  50. void InitTabCtrlKeys() ;
  51. private:
  52. //--- Member variables.
  53. char* m_pszMsgBoxTitle ;
  54. HFONT m_hUIFontDefault ;
  55. HFONT m_hUIAccessableFontDefault;
  56. HACCEL m_hAccel;
  57. HINSTANCE m_hInstRichEdit;
  58. bool m_bInitTabCtrlKeys ; // Controls initializing the tab ctrl keys.
  59. char m_TabCtrlKeys[c_NumTabCtrlKeys]; // Will IsDialogMessage fix this?
  60. };
  61. //////////////////////////////////////////////////////////////////////////
  62. //
  63. // globals.
  64. //
  65. extern CResourceCache _Resource ;
  66. //////////////////////////////////////////////////////////////////////////
  67. //
  68. // Inline Functions
  69. //
  70. //////////////////////////////////////////////////////////////////////////
  71. //
  72. // MsgBoxTitle
  73. //
  74. inline char*
  75. CResourceCache::MsgBoxTitle()
  76. {
  77. if (!m_pszMsgBoxTitle)
  78. InitMsgBoxTitle() ;
  79. return m_pszMsgBoxTitle ;
  80. }
  81. inline HFONT
  82. CResourceCache::GetUIFont()
  83. {
  84. if (!m_hUIFontDefault)
  85. InitDefaultUIFont() ;
  86. return m_hUIFontDefault;
  87. }
  88. inline HFONT
  89. CResourceCache::GetAccessableUIFont()
  90. {
  91. if (!m_hUIAccessableFontDefault)
  92. InitDefaultUIFont() ;
  93. return m_hUIAccessableFontDefault;
  94. }
  95. inline HFONT
  96. CResourceCache::DefaultPrinterFont(HDC hDC)
  97. {
  98. HFONT hFont;
  99. InitDefaultUIFont(hDC, &hFont);
  100. return hFont;
  101. }
  102. inline HACCEL
  103. CResourceCache::AcceleratorTable()
  104. {
  105. if (!m_hAccel)
  106. InitAcceleratorTable();
  107. return m_hAccel ;
  108. }
  109. inline char
  110. CResourceCache::TabCtrlKeys(int TabIndex)
  111. {
  112. if (TabIndex < 0 || TabIndex > c_NumTabCtrlKeys)
  113. {
  114. return 0 ;
  115. }
  116. if (!m_bInitTabCtrlKeys)
  117. InitTabCtrlKeys() ;
  118. return m_TabCtrlKeys[TabIndex] ;
  119. }
  120. #endif //__RESCACHE_H__