1 #include "SkOSMenu.h" 2 3 static int gOSMenuCmd = 7000; 4 SkOSMenu(const char title[])5SkOSMenu::SkOSMenu(const char title[]) 6 { 7 fTitle = title; 8 } 9 ~SkOSMenu()10SkOSMenu::~SkOSMenu() 11 { 12 } 13 countItems() const14int SkOSMenu::countItems() const 15 { 16 return fItems.count(); 17 } 18 appendItem(const char title[],const char eventType[],int32_t eventData)19void 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)29SkEvent* 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) const47const 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