summaryrefslogtreecommitdiff
path: root/plugins/HistoryStats/src/themeapi.cpp
blob: a15067bc66d17b01d165b1ace31a46eb9d69b35e (plain)
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
#include "_globals.h"
#include "themeapi.h"

/*
 * ThemeAPI
 */

const mu_text* ThemeAPI::m_szThemesDll = muT("uxtheme.dll");
HMODULE ThemeAPI::m_hThemesDll = NULL;
bool ThemeAPI::m_bUseTheme = false;

ThemeAPI::fnCloseThemeData           ThemeAPI::CloseThemeData           = NULL;
ThemeAPI::fnDrawThemeBackground      ThemeAPI::DrawThemeBackground      = NULL;
ThemeAPI::fnIsAppThemed              ThemeAPI::IsAppThemed              = NULL;
ThemeAPI::fnIsThemeActive            ThemeAPI::IsThemeActive            = NULL;
ThemeAPI::fnOpenThemeData            ThemeAPI::OpenThemeData            = NULL;
#if !defined(HISTORYSTATS_THEMEAPI_MINIMAL)
ThemeAPI::fnDrawThemeIcon            ThemeAPI::DrawThemeIcon            = NULL;
ThemeAPI::fnEnableThemeDialogTexture ThemeAPI::EnableThemeDialogTexture = NULL;
ThemeAPI::fnGetThemePartSize         ThemeAPI::GetThemePartSize         = NULL;
#endif

void ThemeAPI::init()
{
	m_hThemesDll = LoadLibrary(m_szThemesDll);

	if (m_hThemesDll)
	{
		CloseThemeData           = reinterpret_cast<fnCloseThemeData          >(GetProcAddress(m_hThemesDll, muA("CloseThemeData")          ));
		DrawThemeBackground      = reinterpret_cast<fnDrawThemeBackground     >(GetProcAddress(m_hThemesDll, muA("DrawThemeBackground")     ));
		IsAppThemed              = reinterpret_cast<fnIsAppThemed             >(GetProcAddress(m_hThemesDll, muA("IsAppThemed")             ));
		IsThemeActive            = reinterpret_cast<fnIsThemeActive           >(GetProcAddress(m_hThemesDll, muA("IsThemeActive")           ));
		OpenThemeData            = reinterpret_cast<fnOpenThemeData           >(GetProcAddress(m_hThemesDll, muA("OpenThemeData")           ));
#if !defined(HISTORYSTATS_THEMEAPI_MINIMAL)
		DrawThemeIcon            = reinterpret_cast<fnDrawThemeIcon           >(GetProcAddress(m_hThemesDll, muA("DrawThemeIcon")           ));
		EnableThemeDialogTexture = reinterpret_cast<fnEnableThemeDialogTexture>(GetProcAddress(m_hThemesDll, muA("EnableThemeDialogTexture")));
		GetThemePartSize         = reinterpret_cast<fnGetThemePartSize        >(GetProcAddress(m_hThemesDll, muA("GetThemePartSize")        ));
#endif

		m_bUseTheme = IsThemeActive && IsAppThemed;
	}
}

void ThemeAPI::uninit()
{
	if (m_hThemesDll)
	{
		FreeLibrary(m_hThemesDll);

		m_hThemesDll = NULL;
		m_bUseTheme = false;
	}
}