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.

250 lines
11 KiB

  1. #ifndef _INC_IMAGE
  2. #define _INC_IMAGE
  3. // internal image stuff
  4. EXTERN_C void InitDitherBrush(void);
  5. EXTERN_C void TerminateDitherBrush(void);
  6. EXTERN_C HBITMAP CreateMonoBitmap(int cx, int cy);
  7. EXTERN_C HBITMAP CreateColorBitmap(int cx, int cy);
  8. EXTERN_C void WINAPI ImageList_CopyDitherImage(HIMAGELIST pimlDest, WORD iDst,
  9. int xDst, int yDst, HIMAGELIST pimlSrc, int iSrc, UINT fStyle);
  10. // function to create a imagelist using the params of a given image list
  11. EXTERN_C HIMAGELIST WINAPI ImageList_Clone(HIMAGELIST himl, int cx, int cy,
  12. UINT flags, int cInitial, int cGrow);
  13. EXTERN_C DWORD WINAPI ImageList_GetItemFlags(HIMAGELIST himl, int i);
  14. EXTERN_C HBITMAP CreateDIB(HDC h, int cx, int cy, RGBQUAD** pprgb);
  15. EXTERN_C BOOL DIBHasAlpha(int cx, int cy, RGBQUAD* prgb);
  16. EXTERN_C void PreProcessDIB(int cx, int cy, RGBQUAD* pargb);
  17. #define GLOW_RADIUS 10
  18. #define DROP_SHADOW 3
  19. #ifndef ILC_COLORMASK
  20. #define ILC_COLORMASK 0x00FE
  21. #define ILD_BLENDMASK 0x000E
  22. #endif
  23. #undef ILC_COLOR
  24. #undef ILC_BLEND
  25. #define CLR_WHITE 0x00FFFFFFL
  26. #define CLR_BLACK 0x00000000L
  27. #define IsImageListIndex(i) ((i) >= 0 && (i) < _cImage)
  28. #define IMAGELIST_SIG mmioFOURCC('H','I','M','L') // in memory magic
  29. #define IMAGELIST_MAGIC ('I' + ('L' * 256)) // file format magic
  30. // Version has to stay 0x0101 if we want both back ward and forward compatibility for
  31. // our imagelist_read code
  32. #define IMAGELIST_VER0 0x0101 // file format ver
  33. #define IMAGELIST_VER6 0x0600 // Comctl32 version 6 imagelist
  34. #define BFTYPE_BITMAP 0x4D42 // "BM"
  35. #define CBDIBBUF 4096
  36. #ifdef __cplusplus
  37. // Define this structure such that it will read and write the same
  38. // format for both 16 and 32 bit applications...
  39. #pragma pack(2)
  40. typedef struct _ILFILEHEADER
  41. {
  42. WORD magic;
  43. WORD version;
  44. SHORT cImage;
  45. SHORT cAlloc;
  46. SHORT cGrow;
  47. SHORT cx;
  48. SHORT cy;
  49. COLORREF clrBk;
  50. SHORT flags;
  51. SHORT aOverlayIndexes[NUM_OVERLAY_IMAGES]; // array of special images
  52. } ILFILEHEADER;
  53. // This is the old size which has only 4 overlay slots
  54. #define ILFILEHEADER_SIZE0 (SIZEOF(ILFILEHEADER) - SIZEOF(SHORT) * (NUM_OVERLAY_IMAGES - NUM_OVERLAY_IMAGES_0))
  55. #pragma pack()
  56. #include "../CommonImageList.h"
  57. class CImageList : public CImageListBase,
  58. public IImageList,
  59. public IImageListPriv,
  60. public IPersistStream,
  61. public IImageListPersistStream
  62. {
  63. long _cRef;
  64. ~CImageList();
  65. void _Destroy();
  66. public:
  67. CImageList();
  68. static HRESULT InitGlobals();
  69. HRESULT Initialize(int cx, int cy, UINT flags, int cInitial, int cGrow);
  70. void _RemoveItemBitmap(int i);
  71. BOOL _IsSameObject(IUnknown* punk);
  72. HRESULT _SetIconSize(int cxImage, int cyImage);
  73. HBITMAP _CreateMirroredBitmap(HBITMAP hbmOrig, BOOL fMirrorEach, int cx);
  74. HRESULT _ReAllocBitmaps(int cAlloc);
  75. HRESULT _Add(HBITMAP hbmImage, HBITMAP hbmMask, int cImage, int xStart, int yStart, int* pi);
  76. HRESULT _AddMasked(HBITMAP hbmImage, COLORREF crMask, int* pi);
  77. HRESULT _AddValidated(HBITMAP hbmImage, HBITMAP hbmMask, int* pi);
  78. HRESULT _ReplaceValidated(int i, HBITMAP hbmImage, HBITMAP hbmMask);
  79. HRESULT _Replace(int i, int cImage, HBITMAP hbmImage, HBITMAP hbmMask, int xStart, int yStart);
  80. HRESULT _Remove(int i);
  81. HRESULT _SetOverlayImage(int iImage, int iOverlay);
  82. HRESULT _ReplaceIcon(int i, HICON hIcon, int* pi);
  83. HBITMAP _CopyBitmap(HBITMAP hbm, HDC hdc);
  84. HBITMAP _CopyDIBBitmap(HBITMAP hbm, HDC hdc, RGBQUAD** ppargb);
  85. HRESULT LoadNormal(IStream* pstm);
  86. HRESULT SaveNormal(IStream* pstm);
  87. void _Merge(IImageList* pux, int i, int dx, int dy);
  88. HRESULT _Merge(int i1, IUnknown* punk, int i2, int dx, int dy, CImageList** ppiml);
  89. HRESULT _Read(ILFILEHEADER *pilfh, HBITMAP hbmImage, PVOID pvBits, HBITMAP hbmMask);
  90. BOOL _MoreOverlaysUsed();
  91. BOOL GetSpareImageRect(RECT * prcImage);
  92. BOOL GetSpareImageRectInverted(RECT * prcImage);
  93. void _CopyOneImage(int iDst, int x, int y, CImageList* piml, int iSrc);
  94. BOOL CreateDragBitmaps();
  95. COLORREF _SetBkColor(COLORREF clrBk);
  96. HBITMAP _CreateBitmap(int cx, int cy, RGBQUAD** ppargb);
  97. void _ResetBkColor(int iFirst, int iLast, COLORREF clr);
  98. BOOL _HasAlpha(int i);
  99. void _ScanForAlpha();
  100. BOOL _PreProcessImage(int i);
  101. inline DWORD _GetItemFlags(int i);
  102. BOOL _MaskStretchBlt(BOOL fStretch, int i, HDC hdcDest, int xDst, int yDst, int cxDst, int cyDst,
  103. HDC hdcImage, int xSrc, int ySrc, int cxSrc, int cySrc,
  104. int xMask, int yMask,
  105. DWORD dwRop);
  106. BOOL _StretchBlt(BOOL fStretch, HDC hdc, int x, int y, int cx, int cy, HDC hdcSrc, int xs, int ys, int cxs, int cys, DWORD dwRop);
  107. inline void SetItemFlags(int i, DWORD dwFlag);
  108. void _GenerateAlphaForImageUsingMask(int iImage, BOOL fSpare);
  109. void BlendCTHelper(DWORD *pdw, DWORD rgb, UINT n, UINT count);
  110. void BlendCT(HDC hdcDst, int xDst, int yDst, int x, int y, int cx, int cy, COLORREF rgb, UINT fStyle);
  111. void BlendDither(HDC hdcDst, int xDst, int yDst, int x, int y, int cx, int cy, COLORREF rgb, UINT fStyle);
  112. void Blend16Helper(int xSrc, int ySrc, int xDst, int yDst, int cx, int cy, COLORREF rgb, int a);
  113. void Blend16(HDC hdcDst, int xDst, int yDst, int iImage, int cx, int cy, COLORREF rgb, UINT fStyle);
  114. BOOL Blend32(HDC hdcDst, int xDst, int yDst, int iImage, int cx, int cy, COLORREF rgb, UINT fStyle);
  115. BOOL Blend(HDC hdcDst, int xDst, int yDst, int iImage, int cx, int cy, COLORREF rgb, UINT fStyle);
  116. HRESULT GetImageRectInverted(int i, RECT * prcImage);
  117. static BOOL GlobalInit(void);
  118. static void GlobalUninit(void);
  119. static void SelectDstBitmap(HBITMAP hbmDst);
  120. static void SelectSrcBitmap(HBITMAP hbmSrc);
  121. static CImageList* Create(int cx, int cy, UINT flags, int cInitial, int cGrow);
  122. static void _DeleteBitmap(HBITMAP hbmp);
  123. BOOL _fInitialized;
  124. BOOL _fSolidBk; // is the bkcolor a solid color (in hbmImage)
  125. BOOL _fColorsSet; // The DIB colors have been set with SetColorTable()
  126. int _cImage; // count of images in image list
  127. int _cAlloc; // # of images we have space for
  128. int _cGrow; // # of images to grow bitmaps by
  129. int _cx; // width of each image
  130. int _cy; // height
  131. int _cStrip; // # images in horizontal strip
  132. UINT _flags; // ILC_* flags
  133. COLORREF _clrBlend; // last blend color
  134. COLORREF _clrBk; // bk color or CLR_NONE for transparent.
  135. HBRUSH _hbrBk; // bk brush or black
  136. HBITMAP _hbmImage; // all images are in here
  137. HBITMAP _hbmMask; // all image masks are in here.
  138. HDSA _dsaFlags; // Flags for the images
  139. RGBQUAD* _pargbImage; // The alpha values of the imagelist.
  140. HDC _hdcImage;
  141. HDC _hdcMask;
  142. int _aOverlayIndexes[NUM_OVERLAY_IMAGES]; // array of special images
  143. int _aOverlayX[NUM_OVERLAY_IMAGES]; // x offset of image
  144. int _aOverlayY[NUM_OVERLAY_IMAGES]; // y offset of image
  145. int _aOverlayDX[NUM_OVERLAY_IMAGES]; // cx offset of image
  146. int _aOverlayDY[NUM_OVERLAY_IMAGES]; // cy offset of image
  147. int _aOverlayF[NUM_OVERLAY_IMAGES]; // ILD_ flags for image
  148. CImageList* _pimlMirror; // Set only when another mirrored imagelist is needed (ILC_MIRROR)
  149. //
  150. // used for "blending" effects on a HiColor display.
  151. // assumes layout of a DIBSECTION.
  152. //
  153. struct
  154. {
  155. BITMAP bm;
  156. BITMAPINFOHEADER bi;
  157. DWORD ct[256];
  158. } dib;
  159. // *** IUnknown ***
  160. STDMETHODIMP QueryInterface(REFIID riid, void **ppv);
  161. STDMETHODIMP_(ULONG)AddRef();
  162. STDMETHODIMP_(ULONG)Release();
  163. // *** IImageList ***
  164. STDMETHODIMP Add(HBITMAP hbmImage, HBITMAP hbmMask, int* pi);
  165. STDMETHODIMP ReplaceIcon(int i, HICON hIcon, int* pi);
  166. STDMETHODIMP SetOverlayImage(int iImage, int iOverlay);
  167. STDMETHODIMP Replace(int i, HBITMAP hbmImage, HBITMAP hbmMask);
  168. STDMETHODIMP AddMasked(HBITMAP hbmImage, COLORREF crMask, int* pi);
  169. STDMETHODIMP Draw(IMAGELISTDRAWPARAMS* pimldp);
  170. STDMETHODIMP Remove(int i);
  171. STDMETHODIMP GetIcon(int i, UINT flags, HICON* phicon);
  172. STDMETHODIMP GetImageInfo(int i, IMAGEINFO * pImageInfo);
  173. STDMETHODIMP Copy(int iDst, IUnknown* punkSrc, int iSrc, UINT uFlags);
  174. STDMETHODIMP Merge(int i1, IUnknown* punk, int i2, int dx, int dy, REFIID riid, void** ppv);
  175. STDMETHODIMP Clone(REFIID riid, void** ppv);
  176. STDMETHODIMP GetImageRect(int i, RECT * prcImage);
  177. STDMETHODIMP SetIconSize(int cxImage, int cyImage);
  178. STDMETHODIMP GetIconSize(int* pcx, int* pcy);
  179. STDMETHODIMP SetImageCount(UINT uAlloc);
  180. STDMETHODIMP GetImageCount(int* pi);
  181. STDMETHODIMP SetBkColor(COLORREF clrBk, COLORREF* pclr);
  182. STDMETHODIMP GetBkColor(COLORREF* pclr);
  183. STDMETHODIMP BeginDrag(int iTrack, int dxHotspot, int dyHotspot);
  184. STDMETHODIMP DragEnter(HWND hwndLock, int x, int y);
  185. STDMETHODIMP DragMove(int x, int y);
  186. STDMETHODIMP DragLeave(HWND hwndLock);
  187. STDMETHODIMP EndDrag();
  188. STDMETHODIMP SetDragCursorImage(IUnknown* punk, int i, int dxHotspot, int dyHotspot);
  189. STDMETHODIMP DragShowNolock(BOOL fShow);
  190. STDMETHODIMP GetDragImage(POINT * ppt, POINT * pptHotspot, REFIID riid, void** ppv);
  191. STDMETHODIMP GetItemFlags(int i, DWORD *dwFlags);
  192. STDMETHODIMP GetOverlayImage(int iOverlay, int *piIndex);
  193. // *** IImageListPriv ***
  194. STDMETHODIMP SetFlags(UINT uFlags);
  195. STDMETHODIMP GetFlags(UINT* puFlags);
  196. STDMETHODIMP SetColorTable(int start, int len, RGBQUAD *prgb, int* pi);
  197. STDMETHODIMP GetPrivateGoo(HBITMAP* hbmp, HDC* hdc, HBITMAP* hbmpMask, HDC* hdcMask);
  198. STDMETHODIMP GetMirror(REFIID riid, void** ppv);
  199. STDMETHODIMP CopyDitherImage(WORD iDst, int xDst, int yDst, IUnknown* punkSrc, int iSrc, UINT fStyle);
  200. // *** IPersist ***
  201. STDMETHODIMP GetClassID(CLSID *pClassID) { *pClassID = CLSID_ImageList; return S_OK; }
  202. STDMETHODIMP IsDirty() { return E_NOTIMPL; }
  203. // *** IPersistStream ***
  204. STDMETHODIMP Load(IStream *pStm);
  205. STDMETHODIMP Save(IStream *pStm, int fClearDirty);
  206. STDMETHODIMP GetSizeMax(ULARGE_INTEGER * pcbSize) { return E_NOTIMPL; }
  207. // *** IImageListPersistStream ***
  208. STDMETHODIMP LoadEx(DWORD dwFlags, IStream* pstm);
  209. STDMETHODIMP SaveEx(DWORD dwFlags, IStream* pstm);
  210. };
  211. #endif // __cplusplus
  212. #endif // _INC_IMAGE