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.

162 lines
5.1 KiB

  1. /*
  2. * NineGrid bitmap rendering (ported from UxTheme)
  3. */
  4. #ifndef DUI_UTIL_NINEGRID_H_INCLUDED
  5. #define DUI_UTIL_NINEGRID_H_INCLUDED
  6. #pragma once
  7. namespace DirectUI
  8. {
  9. //---------------------------------------------------------------------------
  10. //#include "uxtheme.h" // need MARGINS struct from here
  11. typedef struct _MARGINS
  12. {
  13. int cxLeftWidth; // width of left border that retains its size
  14. int cxRightWidth; // width of right border that retains its size
  15. int cyTopHeight; // height of top border that retains its size
  16. int cyBottomHeight; // height of bottom border that retains its size
  17. } MARGINS, *PMARGINS;
  18. //#include "tmschema.h" // need SIZINGTYPE, VALIGN, HALIGN enums from here
  19. enum SIZINGTYPE
  20. {
  21. ST_TRUESIZE,
  22. ST_STRETCH,
  23. ST_TILE,
  24. ST_TILEHORZ,
  25. ST_TILEVERT,
  26. ST_TILECENTER
  27. };
  28. enum HALIGN
  29. {
  30. HA_LEFT,
  31. HA_CENTER,
  32. HA_RIGHT
  33. };
  34. enum VALIGN
  35. {
  36. VA_TOP,
  37. VA_CENTER,
  38. VA_BOTTOM
  39. };
  40. //---------------------------------------------------------------------------
  41. #ifndef HEIGHT
  42. #define HEIGHT(rc) ((rc).bottom - (rc).top)
  43. #endif
  44. //---------------------------------------------------------------------------
  45. #ifndef WIDTH
  46. #define WIDTH(rc) ((rc).right - (rc).left)
  47. #endif
  48. //---------------------------------------------------------------------------
  49. enum MBSIZING
  50. {
  51. MB_COPY,
  52. MB_STRETCH,
  53. MB_TILE
  54. };
  55. //------------------------------------------------------------------------------------
  56. struct BRUSHBUFF
  57. {
  58. int iBuffLen;
  59. BYTE *pBuff;
  60. };
  61. //---------------------------------------------------------------------------
  62. struct MBINFO
  63. {
  64. DWORD dwSize; // size of this struct (versioning support)
  65. HDC hdcDest;
  66. HDC hdcSrc;
  67. RECT rcClip; // don't draw outside this rect
  68. HBITMAP hBitmap;
  69. //---- for quick tiling ----
  70. BRUSHBUFF *pBrushBuff;
  71. //---- options ----
  72. DWORD dwOptions; // subset DrawNineGrid() option flags
  73. POINT ptTileOrigin; // for MBO_TILEORIGIN
  74. BITMAPINFOHEADER *pbmHdr; // for MBO_DIRECTBITS
  75. BYTE *pBits; // for MBO_DIRECTBITS
  76. COLORREF crTransparent; // for MBO_TRANSPARENT
  77. _BLENDFUNCTION AlphaBlendInfo; // for MBO_ALPHABLEND
  78. HBRUSH *pCachedBrushes; // for DNG_CACHEBRUSHES
  79. int iCacheIndex; // which brush to use
  80. };
  81. //---------------------------------------------------------------------------
  82. //---- DrawNineGrid() "dwOptions" bits ----
  83. //---- shared with MultiBlt() ----
  84. #define DNG_ALPHABLEND (1 << 0) // use AlphaBlendInfo
  85. #define DNG_TRANSPARENT (1 << 1) // transparancy defined by crTransparent
  86. #define DNG_TILEORIGIN (1 << 2) // use ptTileOrigin
  87. #define DNG_DIRECTBITS (1 << 3) // use pbmHdr & pBits
  88. #define DNG_CACHEBRUSHES (1 << 4) // use/set pCachedBrushes
  89. #define DNG_MANUALTILING (1 << 5) // loop thru BitBlt's
  90. #define DNG_DIRECTBRUSH (1 << 6) // create brushes from temp. extracted DIB's
  91. #define DNG_FLIPGRIDS (1 << 7) // all grid images should be flipped
  92. //---- used only by DrawNineGrid() ----
  93. #define DNG_OMITBORDER (1 << 16) // don't draw border
  94. #define DNG_OMITCONTENT (1 << 17) // don't draw middle
  95. #define DNG_SOLIDBORDER (1 << 18) // sample borders and draw as solid colors
  96. #define DNG_SOLIDCONTENT (1 << 19) // sample content as draw as solid color
  97. #define DNG_BGFILL (1 << 20) // use crFill for ST_TRUESIZE
  98. //------------------------------------------------------------------------------------
  99. struct NGINFO
  100. {
  101. DWORD dwSize; // size of this struct (versioning support)
  102. HDC hdcDest;
  103. RECT rcClip; // don't draw outside this rect
  104. SIZINGTYPE eImageSizing;
  105. HBITMAP hBitmap;
  106. RECT rcSrc; // where to get bits from
  107. RECT rcDest; // where to draw bits to
  108. int iDestMargins[4];
  109. int iSrcMargins[4];
  110. //---- for quick tiling ----
  111. BRUSHBUFF *pBrushBuff;
  112. //---- options ----
  113. DWORD dwOptions;
  114. POINT ptTileOrigin; // for DNG_TILEORIGIN
  115. BITMAPINFOHEADER *pbmHdr; // for DNG_DIRECTBITS
  116. BYTE *pBits; // for DNG_DIRECTBITS
  117. COLORREF crTransparent; // for DNG_TRANSPARENT
  118. _BLENDFUNCTION AlphaBlendInfo; // for DNG_ALPHABLEND
  119. HBRUSH *pCachedBrushes; // for DNG_CACHEBRUSHES
  120. COLORREF *pcrBorders; // for DNG_SOLIDBORDERS, DNG_SOLIDCONTENT
  121. //---- for ST_TRUESIZE images smaller than rcDest ----
  122. COLORREF crFill;
  123. VALIGN eVAlign;
  124. HALIGN eHAlign;
  125. };
  126. //---------------------------------------------------------------------------
  127. HRESULT MultiBlt(MBINFO *pmb, MBSIZING eSizing, int iDestX, int iDestY, int iDestW, int iDestH,
  128. int iSrcX, int iSrcY, int iSrcW, int iSrcH);
  129. HRESULT DrawNineGrid(NGINFO *png);
  130. //---------------------------------------------------------------------------
  131. } // namespace DirectUI
  132. #endif // DUI_UTIL_NINEGRID_H_INCLUDED