aboutsummaryrefslogtreecommitdiff
path: root/Src/Plugins/General/gen_ml/ml_cloud.cpp
blob: e8aee869ac46cf57240b9cee38e573bc77b24587 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include "./ml_cloud.h"
#include <commctrl.h>

BOOL MLCloudI_Draw( HDC hdc, INT value, HMLIMGLST hmlil, INT index, RECT *prc )
{
	if ( !hdc || !hmlil || !prc )
		return FALSE;

	INT ilIndex = MLImageListI_GetRealIndex(hmlil, index, GetBkColor(hdc), GetTextColor(hdc));

	if ( -1 != ilIndex )
	{
		INT val = ( value < 0 ) ? 0 : value;
		static IMAGELISTDRAWPARAMS ildp = { 56/*sizeof(IMAGELISTDRAWPARAMS)*/, 0, };

		ildp.hdcDst = hdc;
		ildp.himl   = MLImageListI_GetRealList( hmlil );
		ildp.i      = ilIndex;
		ildp.x      = prc->left;
		ildp.y      = prc->top;
		ildp.rgbBk  = CLR_DEFAULT;
		ildp.rgbFg  = CLR_DEFAULT;
		ildp.fStyle = ILD_NORMAL;
		ildp.dwRop  = SRCCOPY;

		MLImageListI_GetImageSize( hmlil, &ildp.cx, &ildp.cy );

		ildp.xBitmap = 0;

		if ( ildp.y < prc->top )
		{
			ildp.yBitmap = prc->top - ildp.y;
			ildp.y       = prc->top;
		}
		else
			ildp.yBitmap = 0;

		if ( ildp.cy > ( prc->bottom - ildp.y ) )
			ildp.cy = prc->bottom - ildp.y;

		if ( !val )
			ildp.xBitmap -= ildp.cx;

		if ( !( ildp.x < ( prc->left - ildp.cx ) ) )
		{
			if ( prc->right < ( ildp.x + ildp.cx ) )
				ildp.cx = prc->right - ildp.x;

			ImageList_DrawIndirect( &ildp );
		}
	}

	return TRUE;
}

BOOL MLCloudI_CalcMinRect( HMLIMGLST hmlil, RECT *prc )
{
	INT imageCX, imageCY;

	if ( !hmlil || !prc || !MLImageListI_GetImageSize( hmlil, &imageCX, &imageCY ) )
		return FALSE;

	SetRect( prc, 0, 0, imageCX + 2, imageCY );

	return TRUE;
}