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.

203 lines
7.2 KiB

  1. //---------------------------------------------------------------------------
  2. // ImageFile.h - implements the drawing API for bgtype = ImageFile
  3. //---------------------------------------------------------------------------
  4. #pragma once
  5. //---------------------------------------------------------------------------
  6. #include "DrawBase.h"
  7. //---------------------------------------------------------------------------
  8. #define MAX_IMAGEFILE_SIZES 5
  9. //---------------------------------------------------------------------------
  10. struct TMBITMAPHEADER; // forward
  11. //---------------------------------------------------------------------------
  12. struct DIBINFO // used for all dibs in an CImageFile object
  13. {
  14. //---- the bits ----
  15. int iDibOffset; // for DIB's in section
  16. HBITMAP hProcessBitmap; // for process-specific objects
  17. //---- size of a single, state image ----
  18. int iSingleWidth;
  19. int iSingleHeight;
  20. //---- custom region data ----
  21. int iRgnListOffset;
  22. //---- stretching/sizing ----
  23. SIZINGTYPE eSizingType;
  24. BOOL fBorderOnly;
  25. //---- transparency ----
  26. BOOL fTransparent;
  27. COLORREF crTransparent;
  28. //---- alpha ----
  29. BOOL fAlphaChannel;
  30. int iAlphaThreshold;
  31. //---- usage info ----
  32. int iMinDpi;
  33. SIZE szMinSize;
  34. };
  35. //---------------------------------------------------------------------------
  36. struct TRUESTRETCHINFO
  37. {
  38. BOOL fForceStretch; // forcing a TRUE SIZE image to be stretched
  39. BOOL fFullStretch; // stretch to fill entire dest RECT
  40. SIZE szDrawSize; // size to stretch image to
  41. };
  42. //---------------------------------------------------------------------------
  43. // Note: draw objects like CImageFile cannot have virtual methods
  44. // since they reside in the shared memory map file.
  45. //---------------------------------------------------------------------------
  46. class CImageFile : public CDrawBase
  47. {
  48. public:
  49. //---- load-time methods ----
  50. static BOOL KeyProperty(int iPropId);
  51. DIBINFO *EnumImageFiles(int iIndex);
  52. void DumpProperties(CSimpleFile *pFile, BYTE *pbThemeData, BOOL fFullInfo);
  53. BOOL HasRegionImageFile(DIBINFO *pdi, int *piMaxState);
  54. BOOL ImageUsesBrushes(DIBINFO *pdi, int *piBrushCount);
  55. void SetRgnListOffset(DIBINFO *pdi, int iOffset);
  56. HRESULT BuildRgnData(DIBINFO *pdi, CRenderObj *pRender, int iStateId,
  57. RGNDATA **ppRgnData, int *piDataLen);
  58. //---- draw-time methods ----
  59. HRESULT DrawBackground(CRenderObj *pRender, HDC hdc, int iStateId, const RECT *pRect,
  60. OPTIONAL const DTBGOPTS *pOptions);
  61. BOOL IsBackgroundPartiallyTransparent(int iStateId);
  62. HRESULT HitTestBackground(CRenderObj *pRender, OPTIONAL HDC hdc,
  63. int iStateId, DWORD dwHTFlags, const RECT *pRect, HRGN hrgn,
  64. POINT ptTest, OUT WORD *pwHitCode);
  65. HRESULT GetBackgroundRegion(CRenderObj *pRender, OPTIONAL HDC hdc, int iStateId,
  66. const RECT *pRect, HRGN *pRegion);
  67. HRESULT GetBackgroundContentRect(CRenderObj *pRender, OPTIONAL HDC hdc,
  68. const RECT *pBoundingRect, RECT *pContentRect);
  69. HRESULT GetBackgroundExtent(CRenderObj *pRender, OPTIONAL HDC hdc,
  70. const RECT *pContentRect, RECT *pExtentRect);
  71. HRESULT GetPartSize(CRenderObj *pRender, HDC hdc, const RECT *prc, THEMESIZE eSize, SIZE *psz);
  72. HRESULT GetBitmap(CRenderObj *pRender, HDC hdc, const RECT *prc, HBITMAP *phBitmap);
  73. HRESULT ScaleMargins(IN OUT MARGINS *pMargins, HDC hdcOrig, CRenderObj *pRender,
  74. DIBINFO *pdi, const SIZE *pszDraw, OPTIONAL float *pfx=NULL, OPTIONAL float *pfy=NULL);
  75. DIBINFO *SelectCorrectImageFile(CRenderObj *pRender, HDC hdc, const RECT *prc,
  76. BOOL fForGlyph, OPTIONAL TRUESTRETCHINFO *ptsInfo=NULL);
  77. void GetDrawnImageSize(DIBINFO *pdi, const RECT *pRect, TRUESTRETCHINFO *ptsInfo, SIZE *pszDraw);
  78. //---- multi dibs must be placed just after object ----
  79. inline DIBINFO *MultiDibPtr(int iIndex)
  80. {
  81. DIBINFO *pdi = NULL;
  82. if ((iIndex < 0) && (iIndex >= _iMultiImageCount))
  83. {
  84. ASSERT(0 && L"illegal index for MultiDibPtr()");
  85. }
  86. else
  87. {
  88. DIBINFO * pDibs = (DIBINFO *)(this+1);
  89. pdi = &pDibs[iIndex];
  90. }
  91. return pdi;
  92. }
  93. protected:
  94. //---- call this via CMaxImageFile::PackProperties() ----
  95. HRESULT PackProperties(CRenderObj *pRender, int iPartId, int iStateId);
  96. //---- helper methods ----
  97. HRESULT DrawImageInfo(DIBINFO *pdi, CRenderObj *pRender, HDC hdc, int iStateId,
  98. const RECT *pRect, const DTBGOPTS *pOptions, TRUESTRETCHINFO *ptsInfo);
  99. HRESULT DrawBackgroundDS(DIBINFO *pdi, TMBITMAPHEADER *pThemeBitmapHeader, BOOL fStock,
  100. CRenderObj *pRender, HDC hdc, int iStateId, const RECT *pRect, BOOL fForceStretch,
  101. MARGINS *pmarDest, float xMarginFactor, float yMarginFactor,
  102. OPTIONAL const DTBGOPTS *pOptions);
  103. HRESULT SetImageInfo(DIBINFO *pdi, CRenderObj *pRender, int iPartId, int iStateId);
  104. HRESULT GetScaledContentMargins(CRenderObj *pRender, OPTIONAL HDC hdc, OPTIONAL const RECT *prcDest,
  105. MARGINS *pMargins);
  106. void GetOffsets(int iStateId, DIBINFO *pdi, int *piXOffset, int *piYOffset);
  107. HRESULT DrawFontGlyph(CRenderObj *pRender, HDC hdc, RECT *prc,
  108. OPTIONAL const DTBGOPTS *pOptions);
  109. public:
  110. //---- primary image ----
  111. DIBINFO _ImageInfo;
  112. //---- multiple DPI scaling images ----
  113. int _iMultiImageCount; // number of DIBINFO's that immediately follow object
  114. IMAGESELECTTYPE _eImageSelectType;
  115. //---- properties common to all DIBINFO's in this object ----
  116. int _iImageCount;
  117. IMAGELAYOUT _eImageLayout;
  118. //---- mirroring ----
  119. BOOL _fMirrorImage;
  120. //---- TrueSize images ----
  121. TRUESIZESCALINGTYPE _eTrueSizeScalingType;
  122. HALIGN _eHAlign;
  123. VALIGN _eVAlign;
  124. BOOL _fBgFill;
  125. COLORREF _crFill;
  126. int _iTrueSizeStretchMark; // percent at which we stretch a truesize image
  127. BOOL _fUniformSizing; // both width & height must grow together
  128. BOOL _fIntegralSizing; // for TRUESIZE sizing and for Border sizing
  129. //---- margins ----
  130. MARGINS _SizingMargins;
  131. MARGINS _ContentMargins;
  132. BOOL _fSourceGrow;
  133. BOOL _fSourceShrink;
  134. SIZE _szNormalSize;
  135. //---- glyph ----
  136. BOOL _fGlyphOnly;
  137. GLYPHTYPE _eGlyphType;
  138. //---- font-based glyph ----
  139. COLORREF _crGlyphTextColor;
  140. LOGFONT _lfGlyphFont;
  141. int _iGlyphIndex;
  142. //---- image-based glyph ----
  143. DIBINFO _GlyphInfo;
  144. //---- id ----
  145. int _iSourcePartId;
  146. int _iSourceStateId;
  147. //---- multiple DIBINFO's may follow at end ----
  148. };
  149. //---------------------------------------------------------------------------
  150. class CMaxImageFile : public CImageFile
  151. {
  152. public:
  153. HRESULT PackMaxProperties(CRenderObj *pRender, int iPartId, int iStateId,
  154. OUT int *piMultiDibCount);
  155. DIBINFO MultiDibs[MAX_IMAGEFILE_SIZES]; // actual number of multi dibs varies with each obj
  156. };
  157. //---------------------------------------------------------------------------