1
0

ml_cloudcolumn.cpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #include "main.h"
  2. #include "./ml_cloudcolumn.h"
  3. #include "./ml_cloud.h"
  4. #include "api__gen_ml.h"
  5. #include "./ml.h"
  6. #include "./ml_IPC_0313.h"
  7. #include "./resource.h"
  8. #include "../winamp/gen.h"
  9. #include "./stockobjects.h"
  10. #include <commctrl.h>
  11. #include <strsafe.h>
  12. extern HMLIMGLST hmlilCloud;
  13. #define CLOUD_IMAGELIST hmlilCloud
  14. #define CLOUD_LEFTPADDING 5
  15. #define CLOUD_RIGHTPADDING 4
  16. static INT cloudMinWidth = 27;
  17. BOOL MLCloudColumnI_Initialize(void)
  18. {
  19. RECT rc;
  20. cloudMinWidth = ((MLCloudI_CalcMinRect(CLOUD_IMAGELIST, &rc)) ? (rc.right - rc.left) : 0);
  21. return TRUE;
  22. }
  23. INT MLCloudColumnI_GetMinWidth(void)
  24. {
  25. return cloudMinWidth + CLOUD_LEFTPADDING + CLOUD_RIGHTPADDING;
  26. }
  27. BOOL MLCloudColumnI_Paint(CLOUDCOLUMNPAINT_I *pRCPaint)
  28. {
  29. RECT rc;
  30. rc.left = LVIR_BOUNDS;
  31. rc.top = pRCPaint->iSubItem;
  32. if (SendMessageW(pRCPaint->hwndList, LVM_GETSUBITEMRECT, pRCPaint->iItem, (LPARAM)&rc))
  33. {
  34. if ((rc.right - rc.left - CLOUD_LEFTPADDING - CLOUD_RIGHTPADDING) >= cloudMinWidth &&
  35. (rc.left + CLOUD_LEFTPADDING) < (rc.right - CLOUD_RIGHTPADDING) && rc.top < rc.bottom)
  36. {
  37. INT left;
  38. COLORREF rgbBkOld;
  39. if (rc.right <= pRCPaint->prcView->left || rc.left >= pRCPaint->prcView->right) return TRUE;
  40. rgbBkOld = SetBkColor(pRCPaint->hdc, pRCPaint->rgbBk);
  41. left = rc.left;
  42. if (0 == rc.left) rc.left = 3;
  43. ExtTextOutW(pRCPaint->hdc, 0, 0, ETO_OPAQUE, &rc, L"", 0, 0);
  44. INT value = pRCPaint->value;
  45. if (value)
  46. {
  47. COLORREF rgbFgOld = SetTextColor(pRCPaint->hdc, pRCPaint->rgbFg);
  48. rc.left = left + CLOUD_LEFTPADDING;
  49. rc.right -= CLOUD_RIGHTPADDING;
  50. MLCloudI_Draw(pRCPaint->hdc, value, CLOUD_IMAGELIST, (value - 1), &rc);
  51. if (pRCPaint->rgbFg != rgbFgOld) SetTextColor(pRCPaint->hdc, rgbFgOld);
  52. }
  53. if (pRCPaint->rgbBk != rgbBkOld) SetBkColor(pRCPaint->hdc, rgbBkOld);
  54. return TRUE;
  55. }
  56. }
  57. return FALSE;
  58. }
  59. INT MLCloudColumnI_GetWidth(INT width)
  60. {
  61. INT minWidth = MLCloudColumnI_GetMinWidth();
  62. if (width < minWidth) width = minWidth;
  63. if (width > minWidth) width = minWidth;
  64. return width;
  65. }