aboutsummaryrefslogtreecommitdiff
path: root/Src/Wasabi/api/wndmgr/appcmds.cpp
blob: 93b6ab6d9a46466214e663a2b225d3d7c5faae5c (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
#include <precomp.h>
#include "appcmds.h"

#define CBCLASS AppCmdsI
START_DISPATCH;
CB(APPCMDS_GETNUMCMDS, appcmds_getNumCmds);
CB(APPCMDS_ENUMCMD, appcmds_enumCmd);
VCB(APPCMDS_ONCOMMAND, appcmds_onCommand);
END_DISPATCH;
#undef CBCLASS

AppCmdsI::~AppCmdsI()
{
	foreach(cmds)
	if (cmds.getfor()->autodelete)
		delete cmds.getfor();
	endfor
}

void AppCmdsI::appcmds_addCmd(CmdRec *cmdrec)
{
	cmds.addItem(cmdrec);
}

void AppCmdsI::appcmds_addCmd(const wchar_t *name, int id, int side)
{
	cmds.addItem(new CmdRec(name, id, side, TRUE));
}

void AppCmdsI::appcmds_deleteAll()
{
	foreach(cmds)
	if (cmds.getfor()->autodelete) delete cmds.getfor();
	endfor
	cmds.removeAll();
}

int AppCmdsI::appcmds_getNumCmds()
{
	return cmds.getNumItems();
}

const wchar_t *AppCmdsI::appcmds_enumCmd(int n, int *side, int *id)
{
	CmdRec *cr = cmds[n];
	if (cr == NULL) return NULL;
	if (side != NULL) *side = cr->side;
	if (id != NULL) *id = cr->id;
	return cr->cmdname;
}

void AppCmdsI::appcmds_onCommand(int id, const RECT *buttonRect, int which_button)
{
	foreach(cmds)
	if (cmds.getfor()->id == id)
	{
		cmds.getfor()->onCommand(buttonRect, which_button);
		break;
	}
	endfor
}