• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include "SkOSMenu.h"
2 
3 static int gOSMenuCmd = 7000;
4 
SkOSMenu(const char title[])5 SkOSMenu::SkOSMenu(const char title[])
6 {
7 	fTitle = title;
8 }
9 
~SkOSMenu()10 SkOSMenu::~SkOSMenu()
11 {
12 }
13 
countItems() const14 int SkOSMenu::countItems() const
15 {
16 	return fItems.count();
17 }
18 
appendItem(const char title[],const char eventType[],int32_t eventData)19 void SkOSMenu::appendItem(const char title[], const char eventType[], int32_t eventData)
20 {
21 	Item* item = fItems.append();
22 
23 	item->fTitle	 = title;
24 	item->fEventType = eventType;
25 	item->fEventData = eventData;
26 	item->fOSCmd	 = ++gOSMenuCmd;
27 }
28 
createEvent(uint32_t os_cmd)29 SkEvent* SkOSMenu::createEvent(uint32_t os_cmd)
30 {
31 	const Item* iter = fItems.begin();
32 	const Item*	stop = fItems.end();
33 
34 	while (iter < stop)
35 	{
36 		if (iter->fOSCmd == os_cmd)
37 		{
38 			SkEvent* evt = new SkEvent(iter->fEventType);
39 			evt->setFast32(iter->fEventData);
40 			return evt;
41 		}
42 		iter++;
43 	}
44 	return NULL;
45 }
46 
getItem(int index,uint32_t * cmdID) const47 const char* SkOSMenu::getItem(int index, uint32_t* cmdID) const
48 {
49 	if (cmdID)
50 		*cmdID = fItems[index].fOSCmd;
51 	return fItems[index].fTitle;
52 }
53 
54