1
0

ml_cloud.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #include "./ml_cloud.h"
  2. #include <commctrl.h>
  3. BOOL MLCloudI_Draw( HDC hdc, INT value, HMLIMGLST hmlil, INT index, RECT *prc )
  4. {
  5. if ( !hdc || !hmlil || !prc )
  6. return FALSE;
  7. INT ilIndex = MLImageListI_GetRealIndex(hmlil, index, GetBkColor(hdc), GetTextColor(hdc));
  8. if ( -1 != ilIndex )
  9. {
  10. INT val = ( value < 0 ) ? 0 : value;
  11. static IMAGELISTDRAWPARAMS ildp = { 56/*sizeof(IMAGELISTDRAWPARAMS)*/, 0, };
  12. ildp.hdcDst = hdc;
  13. ildp.himl = MLImageListI_GetRealList( hmlil );
  14. ildp.i = ilIndex;
  15. ildp.x = prc->left;
  16. ildp.y = prc->top;
  17. ildp.rgbBk = CLR_DEFAULT;
  18. ildp.rgbFg = CLR_DEFAULT;
  19. ildp.fStyle = ILD_NORMAL;
  20. ildp.dwRop = SRCCOPY;
  21. MLImageListI_GetImageSize( hmlil, &ildp.cx, &ildp.cy );
  22. ildp.xBitmap = 0;
  23. if ( ildp.y < prc->top )
  24. {
  25. ildp.yBitmap = prc->top - ildp.y;
  26. ildp.y = prc->top;
  27. }
  28. else
  29. ildp.yBitmap = 0;
  30. if ( ildp.cy > ( prc->bottom - ildp.y ) )
  31. ildp.cy = prc->bottom - ildp.y;
  32. if ( !val )
  33. ildp.xBitmap -= ildp.cx;
  34. if ( !( ildp.x < ( prc->left - ildp.cx ) ) )
  35. {
  36. if ( prc->right < ( ildp.x + ildp.cx ) )
  37. ildp.cx = prc->right - ildp.x;
  38. ImageList_DrawIndirect( &ildp );
  39. }
  40. }
  41. return TRUE;
  42. }
  43. BOOL MLCloudI_CalcMinRect( HMLIMGLST hmlil, RECT *prc )
  44. {
  45. INT imageCX, imageCY;
  46. if ( !hmlil || !prc || !MLImageListI_GetImageSize( hmlil, &imageCX, &imageCY ) )
  47. return FALSE;
  48. SetRect( prc, 0, 0, imageCX + 2, imageCY );
  49. return TRUE;
  50. }