aboutsummaryrefslogtreecommitdiffstats
path: root/src/views/SkOSMenu.cpp
blob: 3760ddd5cb036dbac67327446bad7081562451e5 (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 "SkOSMenu.h"

static int gOSMenuCmd = 7000;

SkOSMenu::SkOSMenu(const char title[])
{
	fTitle = title;
}

SkOSMenu::~SkOSMenu()
{
}

int SkOSMenu::countItems() const
{
	return fItems.count();
}

void SkOSMenu::appendItem(const char title[], const char eventType[], int32_t eventData)
{
	Item* item = fItems.append();

	item->fTitle	 = title;
	item->fEventType = eventType;
	item->fEventData = eventData;
	item->fOSCmd	 = ++gOSMenuCmd;
}

SkEvent* SkOSMenu::createEvent(uint32_t os_cmd)
{
	const Item* iter = fItems.begin();
	const Item*	stop = fItems.end();

	while (iter < stop)
	{
		if (iter->fOSCmd == os_cmd)
		{
			SkEvent* evt = new SkEvent(iter->fEventType);
			evt->setFast32(iter->fEventData);
			return evt;
		}
		iter++;
	}
	return NULL;
}

const char* SkOSMenu::getItem(int index, uint32_t* cmdID) const
{
	if (cmdID)
		*cmdID = fItems[index].fOSCmd;
	return fItems[index].fTitle;
}