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 "SkAtomics.h" | 7 #include "SkAtomics.h" |
8 #include "SkOSMenu.h" | 8 #include "SkOSMenu.h" |
9 #include <stdarg.h> | 9 #include <stdarg.h> |
10 | 10 |
(...skipping 10 matching lines...) Expand all Loading... |
21 void SkOSMenu::reset() { | 21 void SkOSMenu::reset() { |
22 fItems.deleteAll(); | 22 fItems.deleteAll(); |
23 fTitle.reset(); | 23 fTitle.reset(); |
24 } | 24 } |
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 nullptr; |
32 } | 32 } |
33 | 33 |
34 void SkOSMenu::getItems(const SkOSMenu::Item* items[]) const { | 34 void SkOSMenu::getItems(const SkOSMenu::Item* items[]) const { |
35 if (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 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 } | 148 } |
149 | 149 |
150 int SkOSMenu::appendList(const char label[], const char slotName[], | 150 int SkOSMenu::appendList(const char label[], const char slotName[], |
151 SkEventSinkID target, int index, const char option[], .
..) { | 151 SkEventSinkID target, int index, const char option[], .
..) { |
152 SkEvent* evt = new SkEvent(gMenuEventType, target); | 152 SkEvent* evt = new SkEvent(gMenuEventType, target); |
153 va_list args; | 153 va_list args; |
154 if (option) { | 154 if (option) { |
155 SkString str(option); | 155 SkString str(option); |
156 va_start(args, option); | 156 va_start(args, option); |
157 int count = 1; | 157 int count = 1; |
158 for (const char* arg = va_arg(args, const char*); arg != NULL; arg = va_
arg(args, const char*)) { | 158 for (const char* arg = va_arg(args, const char*); arg != nullptr; arg =
va_arg(args, const char*)) { |
159 str += gDelimiter; | 159 str += gDelimiter; |
160 str += arg; | 160 str += arg; |
161 ++count; | 161 ++count; |
162 } | 162 } |
163 va_end(args); | 163 va_end(args); |
164 evt->setString(gList_Items_Str, str); | 164 evt->setString(gList_Items_Str, str); |
165 evt->setS32(gList_ItemCount_S32, count); | 165 evt->setS32(gList_ItemCount_S32, count); |
166 evt->setS32(slotName, index); | 166 evt->setS32(slotName, index); |
167 } | 167 } |
168 return appendItem(label, SkOSMenu::kList_Type, slotName, evt); | 168 return appendItem(label, SkOSMenu::kList_Type, slotName, evt); |
(...skipping 30 matching lines...) Expand all Loading... |
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) && 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 != nullptr) { |
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 != nullptr) { |
214 items[index].set(token, strlen(token)); | 214 items[index].set(token, strlen(token)); |
215 token = strtok (NULL, gDelimiter); | 215 token = strtok (nullptr, gDelimiter); |
216 ++index; | 216 ++index; |
217 } | 217 } |
218 } | 218 } |
219 return true; | 219 return true; |
220 } | 220 } |
221 return false; | 221 return false; |
222 } | 222 } |
223 | 223 |
224 bool SkOSMenu::FindSliderMin(const SkEvent& evt, SkScalar* min) { | 224 bool SkOSMenu::FindSliderMin(const SkEvent& evt, SkScalar* min) { |
225 return evt.isType(gMenuEventType) && evt.findScalar(gSlider_Min_Scalar, min)
; | 225 return evt.isType(gMenuEventType) && evt.findScalar(gSlider_Min_Scalar, min)
; |
(...skipping 28 matching lines...) Expand all 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 |