OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 #include <stdarg.h> | 7 #include <stdarg.h> |
8 #include "SkOSMenu.h" | 8 #include "SkOSMenu.h" |
9 #include "SkThread.h" | 9 #include "SkThread.h" |
10 | 10 |
(...skipping 14 matching lines...) Expand all Loading... |
25 | 25 |
26 const SkOSMenu::Item* SkOSMenu::getItemByID(int itemID) const { | 26 const SkOSMenu::Item* SkOSMenu::getItemByID(int itemID) const { |
27 for (int i = 0; i < fItems.count(); ++i) { | 27 for (int i = 0; i < fItems.count(); ++i) { |
28 if (itemID == fItems[i]->getID()) | 28 if (itemID == fItems[i]->getID()) |
29 return fItems[i]; | 29 return fItems[i]; |
30 } | 30 } |
31 return NULL; | 31 return NULL; |
32 } | 32 } |
33 | 33 |
34 void SkOSMenu::getItems(const SkOSMenu::Item* items[]) const { | 34 void SkOSMenu::getItems(const SkOSMenu::Item* items[]) const { |
35 if (NULL != items) { | 35 if (items) { |
36 for (int i = 0; i < fItems.count(); ++i) { | 36 for (int i = 0; i < fItems.count(); ++i) { |
37 items[i] = fItems[i]; | 37 items[i] = fItems[i]; |
38 } | 38 } |
39 } | 39 } |
40 } | 40 } |
41 | 41 |
42 void SkOSMenu::assignKeyEquivalentToItem(int itemID, SkUnichar key) { | 42 void SkOSMenu::assignKeyEquivalentToItem(int itemID, SkUnichar key) { |
43 for (int i = 0; i < fItems.count(); ++i) { | 43 for (int i = 0; i < fItems.count(); ++i) { |
44 if (itemID == fItems[i]->getID()) | 44 if (itemID == fItems[i]->getID()) |
45 fItems[i]->setKeyEquivalent(key); | 45 fItems[i]->setKeyEquivalent(key); |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 SkEvent* evt = new SkEvent(gMenuEventType, target); | 197 SkEvent* evt = new SkEvent(gMenuEventType, target); |
198 evt->setString(slotName, placeholder); | 198 evt->setString(slotName, placeholder); |
199 return appendItem(label, SkOSMenu::kTextField_Type, slotName, evt); | 199 return appendItem(label, SkOSMenu::kTextField_Type, slotName, evt); |
200 } | 200 } |
201 | 201 |
202 bool SkOSMenu::FindListItemCount(const SkEvent& evt, int* count) { | 202 bool SkOSMenu::FindListItemCount(const SkEvent& evt, int* count) { |
203 return evt.isType(gMenuEventType) && evt.findS32(gList_ItemCount_S32, count)
; | 203 return evt.isType(gMenuEventType) && evt.findS32(gList_ItemCount_S32, count)
; |
204 } | 204 } |
205 | 205 |
206 bool SkOSMenu::FindListItems(const SkEvent& evt, SkString items[]) { | 206 bool SkOSMenu::FindListItems(const SkEvent& evt, SkString items[]) { |
207 if (evt.isType(gMenuEventType) && NULL != items) { | 207 if (evt.isType(gMenuEventType) && items) { |
208 const char* text = evt.findString(gList_Items_Str); | 208 const char* text = evt.findString(gList_Items_Str); |
209 if (text != NULL) { | 209 if (text != NULL) { |
210 SkString temp(text); | 210 SkString temp(text); |
211 char* token = strtok((char*)temp.c_str(), gDelimiter); | 211 char* token = strtok((char*)temp.c_str(), gDelimiter); |
212 int index = 0; | 212 int index = 0; |
213 while (token != NULL) { | 213 while (token != NULL) { |
214 items[index].set(token, strlen(token)); | 214 items[index].set(token, strlen(token)); |
215 token = strtok (NULL, gDelimiter); | 215 token = strtok (NULL, gDelimiter); |
216 ++index; | 216 ++index; |
217 } | 217 } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 const char* text = evt.findString(slotName); | 254 const char* text = evt.findString(slotName); |
255 if (!text || !*text) | 255 if (!text || !*text) |
256 return false; | 256 return false; |
257 else { | 257 else { |
258 value->set(text); | 258 value->set(text); |
259 return true; | 259 return true; |
260 } | 260 } |
261 } | 261 } |
262 return false; | 262 return false; |
263 } | 263 } |
OLD | NEW |