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.

212 lines
9.2 KiB

  1. /*****************************************************************************\
  2. FILE: AdvAppearPg.h
  3. DESCRIPTION:
  4. This code will display a "Advanced Appearances" tab in the
  5. "Advanced Display Properties" dialog.
  6. ??????? ?/??/1993 Created
  7. BryanSt 3/23/2000 Updated and Converted to C++
  8. Copyright (C) Microsoft Corp 1993-2000. All rights reserved.
  9. \*****************************************************************************/
  10. #ifndef _ADVAPPEAR_H
  11. #define _ADVAPPEAR_H
  12. // Public
  13. HRESULT CAdvAppearancePage_CreateInstance(OUT IAdvancedDialog ** ppAdvDialog, IN const SYSTEMMETRICSALL * pState);
  14. class CAdvAppearancePage;
  15. typedef struct {
  16. HWND hwndFontName;
  17. HDC hdc;
  18. CAdvAppearancePage * pThis;
  19. } ENUMFONTPARAM;
  20. #define MAX_CHARSETS 4
  21. //============================================================================================================
  22. // Class
  23. //============================================================================================================
  24. class CAdvAppearancePage : public CObjectWithSite
  25. , public CObjectWindow
  26. , public CObjectCLSID
  27. , public IAdvancedDialog
  28. {
  29. public:
  30. //////////////////////////////////////////////////////
  31. // Public Interfaces
  32. //////////////////////////////////////////////////////
  33. // *** IUnknown ***
  34. virtual STDMETHODIMP QueryInterface(REFIID riid, LPVOID * ppvObj);
  35. virtual STDMETHODIMP_(ULONG) AddRef(void);
  36. virtual STDMETHODIMP_(ULONG) Release(void);
  37. // *** IAdvancedDialog ***
  38. virtual STDMETHODIMP DisplayAdvancedDialog(IN HWND hwndParent, IN IPropertyBag * pBasePage, IN BOOL * pfEnableApply);
  39. HRESULT Draw(HDC hdc, LPRECT prc, BOOL fOnlyShowActiveWindow, BOOL fRTL);
  40. int _EnumSizes(LPENUMLOGFONT lpelf, LPNEWTEXTMETRIC lpntm, int Type);
  41. CAdvAppearancePage(IN const SYSTEMMETRICSALL * pState);
  42. virtual ~CAdvAppearancePage(void);
  43. private:
  44. // Private Member Variables
  45. long m_cRef;
  46. // Members for State
  47. BOOL m_fDirty;
  48. DWORD m_dwChanged; // These are the categories of state that are dirty. (SCHEME_CHANGE, DPI_CHANGE, COLOR_CHANGE, METRIC_CHANGE)
  49. // Members for UI Controls
  50. int m_iCurElement; // start off as not even "not set"
  51. LOOK_SIZE m_elCurrentSize; // this one kept separately for range purposes
  52. int m_iPrevSize;
  53. BOOL m_bPalette; // is this a palette device?
  54. BOOL m_fInUserEditMode; // Are refreshes coming from the user edits?
  55. BOOL m_fProprtySheetExiting; // See _PropagateMessage for description
  56. int m_nCachedNewDPI; // Cached DPI for scaling
  57. int m_i3DShadowAdj;
  58. int m_i3DHilightAdj;
  59. int m_iWatermarkAdj;
  60. BOOL m_fScale3DShadowAdj;
  61. BOOL m_fScale3DHilightAdj;
  62. BOOL m_fScaleWatermarkAdj;
  63. BOOL m_fModifiedScheme;
  64. int m_cyBorderSM; // Cached SystemMetrics
  65. int m_cxBorderSM; // Cached SystemMetrics
  66. int m_cxEdgeSM; // Cached SystemMetrics
  67. int m_cyEdgeSM; // Cached SystemMetrics
  68. float m_fCaptionRatio; // Save the ratio
  69. LOOK_SIZE m_sizes[NUM_SIZES]; // These are the sizes
  70. LOOK_FONT m_fonts[NUM_FONTS]; // These are the fonts installed that the user can choose from.
  71. COLORREF m_rgb[COLOR_MAX]; // These are the colors the user can choose from.
  72. HBRUSH m_brushes[COLOR_MAX]; // These are created from m_rgb and used when painting the UI.
  73. HPALETTE m_hpal3D; // only exist if palette device
  74. HPALETTE m_hpalVGA; // only exist if palette device
  75. HBRUSH m_hbrMainColor;
  76. HBRUSH m_hbrTextColor;
  77. HBRUSH m_hbrGradientColor;
  78. HTHEME m_hTheme; // theme the ownerdrawn color picker button
  79. // The following array will hold the "unique" Charsets corresponding to System Locale,
  80. // User Locale, System UI lang and User UI Lang. Note: Only unique charsets are kept
  81. // here. So, the variable g_iCountCharsets contains the number of valid items in this array.
  82. UINT m_uiUniqueCharsets[MAX_CHARSETS];
  83. int m_iCountCharsets; // number of charsets stored in m_uiUniqueCharsets. Minimum value is 1; Maximum is 4
  84. // Private Member Functions
  85. // Init/Destroy/State functions
  86. INT_PTR _AdvAppearDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
  87. INT_PTR _OnCommand(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
  88. HRESULT _OnDestroy(HWND hDlg);
  89. HRESULT _OnSetActive(HWND hDlg);
  90. HRESULT _OnApply(HWND hDlg, LPARAM lParam);
  91. HRESULT _OnInitAdvAppearanceDlg(HWND hDlg);
  92. HRESULT _InitSysStuff(void);
  93. HRESULT _InitColorAndPalette(void);
  94. HRESULT _LoadState(IN const SYSTEMMETRICSALL * pState);
  95. HRESULT _IsDirty(IN BOOL * pIsDirty);
  96. // On User Action
  97. HRESULT _OnFontNameChanged(HWND hDlg);
  98. HRESULT _OnSizeChange(HWND hDlg, WORD wEvent);
  99. void _SelectName(HWND hDlg, int iSel);
  100. HRESULT _InitFonts(void);
  101. HRESULT _FreeFonts(void);
  102. // Classic Look_ functions
  103. HRESULT _SelectElement(HWND hDlg, int iElement, DWORD dwFlags);
  104. COLORREF _NearestColor(int iColor, COLORREF rgb);
  105. int _EnumFontNames(LPENUMLOGFONTEX lpelf, LPNEWTEXTMETRIC lpntm, DWORD Type, ENUMFONTPARAM * pEnumFontParam);
  106. BOOL _ChangeColor(HWND hDlg, int iColor, COLORREF rgb);
  107. void _Recalc(LPRECT prc);
  108. void _Repaint(HWND hDlg, BOOL bRecalc);
  109. void _RebuildCurFont(HWND hDlg);
  110. void _ChangeFontSize(HWND hDlg, int Points);
  111. void _ChangeFontBI(HWND hDlg, int id, BOOL bCheck);
  112. void _ChangeFontName(HWND hDlg, LPCTSTR szBuf, INT iCharSet);
  113. void _ChangeSize(HWND hDlg, int NewSize, BOOL bRepaint);
  114. void _PickAColor(HWND hDlg, int CtlID);
  115. void _DrawPreview(HDC hdc, LPRECT prc, BOOL fOnlyShowActiveWindow, BOOL fShowBack);
  116. void _DrawButton(HWND hDlg, LPDRAWITEMSTRUCT lpdis);
  117. void _RebuildSysStuff(BOOL fInit);
  118. void _Set3DPaletteColor(COLORREF rgb, int iColor);
  119. void _InitUniqueCharsetArray(void);
  120. void _DestroySysStuff(void);
  121. void _InitFontList(HWND hDlg);
  122. void _NewFont(HWND hDlg, int iFont);
  123. void _SetColor(HWND hDlg, int id, HBRUSH hbrColor);
  124. void _DrawDownArrow(HDC hdc, LPRECT lprc, BOOL bDisabled);
  125. void _SetCurSizeAndRange(HWND hDlg);
  126. void _DoSizeStuff(HWND hDlg, BOOL fCanSuggest);
  127. void _UpdateSizeBasedOnFont(HWND hDlg, BOOL fComputeIdeal);
  128. void _SyncSize(HWND hDlg);
  129. void _Changed(HWND hDlg, DWORD dwChange);
  130. void _SetSysStuff(UINT nChanged);
  131. void _GetMyNonClientMetrics(LPNONCLIENTMETRICS lpncm);
  132. void _SetMyNonClientMetrics(const LPNONCLIENTMETRICS lpncm);
  133. void _UpdateGradientButton(HWND hDlg);
  134. void _PropagateMessage(HWND hwnd, UINT uMessage, WPARAM wParam, LPARAM lParam);
  135. int _PointToHeight(int Points);
  136. int _HeightToPoint(int Height);
  137. static INT_PTR CALLBACK AdvAppearDlgProc(HWND hDlg, UINT uMessage, WPARAM wParam, LPARAM lParam);
  138. friend int CALLBACK Font_EnumNames(LPENUMLOGFONTEX lpelf, LPNEWTEXTMETRIC lpntm, DWORD dwType, LPARAM lData);
  139. // Preview Methods
  140. // Classic LookPrev_ functions
  141. void _RepaintPreview(HWND hwnd);
  142. void _MyDrawBorderBelow(HDC hdc, LPRECT prc);
  143. void _ShowBitmap(HWND hWnd, HDC hdc);
  144. HRESULT _OnReCreateBitmap(HWND hWnd);
  145. HRESULT _OnButtonDownOrDblClick(HWND hWnd, int nCoordX, int nCoordY);
  146. HRESULT _OnCreatePreviewSMDlg(LPRECT prc, BOOL fRTL);
  147. HRESULT _OnNCCreate(HWND hWnd);
  148. HRESULT _OnDestroyPreview(HWND hWnd);
  149. HRESULT _OnPaintPreview(HWND hWnd);
  150. void _InitPreview(LPRECT prc, BOOL fRTL);
  151. LRESULT _PreviewSystemMetricsWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
  152. static LRESULT CALLBACK PreviewSystemMetricsWndProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam);
  153. friend BOOL RegisterPreviewSystemMetricClass(HINSTANCE hInst);
  154. };
  155. extern CAdvAppearancePage * g_pAdvAppearancePage;
  156. // Shared between AdvAppearPg & BaseAppearPage
  157. extern BOOL g_fProprtySheetExiting;
  158. // a new element has been chosen.
  159. //
  160. // iElement - index into g_elements of the chosen one
  161. // bSetCur - if TRUE, need to find element in elements combobox, too
  162. #define LSE_NONE 0x0000
  163. #define LSE_SETCUR 0x0001
  164. #define LSE_ALWAYS 0x0002
  165. #define EnableApplyButton(hdlg) PropSheet_Changed(GetParent(hdlg), hdlg)
  166. #endif // _ADVAPPEAR_H