summaryrefslogtreecommitdiff
path: root/plugins/StartPosition/src/startposition.cpp
blob: 7e2dce02af3b2c254fc8793b4fea13df7b7e2815 (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
54
55
56
57
58
#include "stdafx.h"

CMPlugin::CMPlugin() :
	PLUGIN<CMPlugin>(MODULENAME, pluginInfoEx)
{}

void CMPlugin::Init()
{
	HookPluginEvent(ME_OPT_INITIALISE, &CMPlugin::OnOptionsInit);
}

void CMPlugin::positionClist()
{
	ClistOptions clOptions;

	if (spOptions.setClistStartState)
		clOptions.state = static_cast<uint8_t>(spOptions.clistState);

	if (spOptions.setClistWidth && spOptions.clistWidth > 0)
		clOptions.width = static_cast<uint32_t>(spOptions.clistWidth);
	else
		spOptions.clistWidth = static_cast<uint32_t>(clOptions.width);

	if (spOptions.setTopPosition || spOptions.setBottomPosition || spOptions.setSidePosition)
		clOptions.isDocked = false;

	if (spOptions.setTopPosition)
		clOptions.y = static_cast<uint32_t>(spOptions.pixelsFromTop);

	RECT WorkArea;
	SystemParametersInfo(SPI_GETWORKAREA, 0, &WorkArea, 0);

	if (spOptions.setBottomPosition) {
		if (spOptions.setTopPosition)
			clOptions.height = WorkArea.bottom - WorkArea.top - spOptions.pixelsFromTop - spOptions.pixelsFromBottom;
		else
			clOptions.y = WorkArea.bottom - spOptions.pixelsFromBottom - clOptions.height;
	}

	if (spOptions.setSidePosition) {
		if (spOptions.clistAlign == ClistAlign::right)
			clOptions.x = WorkArea.right - spOptions.clistWidth - spOptions.pixelsFromSide;
		else
			clOptions.x = WorkArea.left + spOptions.pixelsFromSide;
	}
}

int CMPlugin::OnOptionsInit(WPARAM wParam, LPARAM)
{
	OPTIONSDIALOGPAGE odp = {};
	odp.szGroup.a = LPGEN("Contact list");
	odp.szTitle.a = LPGEN("Start position");
	odp.pDialog = new COptionsDlg();
	odp.flags = ODPF_BOLDGROUPS;
	g_plugin.addOptions(wParam, &odp);

	return 0;
}