Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Side by Side Diff: src/views/mac/SkOptionsTableView.mm

Issue 19569012: Turn on -Wall -Wextra on Mac, and fix all the warnings that crop up for /usr/bin/g++ and Clang 3.3. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: nit Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/utils/SkLayer.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #import "SkOptionsTableView.h" 9 #import "SkOptionsTableView.h"
10 #import "SkTextFieldCell.h" 10 #import "SkTextFieldCell.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 } 49 }
50 50
51 - (void)registerMenus:(const SkTDArray<SkOSMenu*>*)menus { 51 - (void)registerMenus:(const SkTDArray<SkOSMenu*>*)menus {
52 fMenus = menus; 52 fMenus = menus;
53 for (int i = 0; i < fMenus->count(); ++i) { 53 for (int i = 0; i < fMenus->count(); ++i) {
54 [self loadMenu:(*fMenus)[i]]; 54 [self loadMenu:(*fMenus)[i]];
55 } 55 }
56 } 56 }
57 57
58 - (void)updateMenu:(const SkOSMenu*)menu { 58 - (void)updateMenu:(const SkOSMenu*)menu {
59 // the first menu is always assumed to be the static, the second is 59 // the first menu is always assumed to be the static, the second is
60 // repopulated every time over and over again 60 // repopulated every time over and over again
61 61
62 // seems pretty weird that we have to get rid of the const'ness here, 62 // seems pretty weird that we have to get rid of the const'ness here,
63 // but trying to propagate the const'ness through all the way to the fMenus 63 // but trying to propagate the const'ness through all the way to the fMenus
64 // vector was a non-starter. 64 // vector was a non-starter.
65 65
66 int menuIndex = fMenus->find(const_cast<SkOSMenu *>(menu)); 66 int menuIndex = fMenus->find(const_cast<SkOSMenu *>(menu));
67 if (menuIndex >= 0 && menuIndex < fMenus->count()) { 67 if (menuIndex >= 0 && menuIndex < fMenus->count()) {
68 NSUInteger first = 0; 68 NSUInteger first = 0;
69 for (NSInteger i = 0; i < menuIndex; ++i) { 69 for (NSInteger i = 0; i < menuIndex; ++i) {
70 first += (*fMenus)[i]->getCount(); 70 first += (*fMenus)[i]->getCount();
(...skipping 13 matching lines...) Expand all
84 return NSMixedState; 84 return NSMixedState;
85 } 85 }
86 86
87 - (void)loadMenu:(const SkOSMenu*)menu { 87 - (void)loadMenu:(const SkOSMenu*)menu {
88 const SkOSMenu::Item* menuitems[menu->getCount()]; 88 const SkOSMenu::Item* menuitems[menu->getCount()];
89 menu->getItems(menuitems); 89 menu->getItems(menuitems);
90 for (int i = 0; i < menu->getCount(); ++i) { 90 for (int i = 0; i < menu->getCount(); ++i) {
91 const SkOSMenu::Item* item = menuitems[i]; 91 const SkOSMenu::Item* item = menuitems[i];
92 SkOptionItem* option = [[SkOptionItem alloc] init]; 92 SkOptionItem* option = [[SkOptionItem alloc] init];
93 option.fItem = item; 93 option.fItem = item;
94 94
95 if (SkOSMenu::kList_Type == item->getType()) { 95 if (SkOSMenu::kList_Type == item->getType()) {
96 int index = 0, count = 0; 96 int index = 0, count = 0;
97 SkOSMenu::FindListItemCount(*item->getEvent(), &count); 97 SkOSMenu::FindListItemCount(*item->getEvent(), &count);
98 NSMutableArray* optionstrs = [[NSMutableArray alloc] initWithCapacit y:count]; 98 NSMutableArray* optionstrs = [[NSMutableArray alloc] initWithCapacit y:count];
99 SkAutoTDeleteArray<SkString> ada(new SkString[count]); 99 SkAutoTDeleteArray<SkString> ada(new SkString[count]);
100 SkString* options = ada.get(); 100 SkString* options = ada.get();
101 SkOSMenu::FindListItems(*item->getEvent(), options); 101 SkOSMenu::FindListItems(*item->getEvent(), options);
102 for (int i = 0; i < count; ++i) 102 for (int i = 0; i < count; ++i)
103 [optionstrs addObject:[NSString stringWithUTF8String:options[i]. c_str()]]; 103 [optionstrs addObject:[NSString stringWithUTF8String:options[i]. c_str()]];
104 SkOSMenu::FindListIndex(*item->getEvent(), item->getSlotName(), &ind ex); 104 SkOSMenu::FindListIndex(*item->getEvent(), item->getSlotName(), &ind ex);
105 option.fCell = [self createList:optionstrs current:index]; 105 option.fCell = [self createList:optionstrs current:index];
106 [optionstrs release]; 106 [optionstrs release];
107 } 107 }
108 else { 108 else {
109 bool state = false; 109 bool state = false;
110 SkString str; 110 SkString str;
111 SkOSMenu::TriState tristate; 111 SkOSMenu::TriState tristate;
112 switch (item->getType()) { 112 switch (item->getType()) {
113 case SkOSMenu::kAction_Type: 113 case SkOSMenu::kAction_Type:
114 option.fCell = [self createAction]; 114 option.fCell = [self createAction];
115 break; 115 break;
116 case SkOSMenu::kSlider_Type: 116 case SkOSMenu::kSlider_Type:
117 SkScalar min, max, value; 117 SkScalar min, max, value;
118 SkOSMenu::FindSliderValue(*item->getEvent(), item->getSlotNa me(), &value); 118 SkOSMenu::FindSliderValue(*item->getEvent(), item->getSlotNa me(), &value);
119 SkOSMenu::FindSliderMin(*item->getEvent(), &min); 119 SkOSMenu::FindSliderMin(*item->getEvent(), &min);
120 SkOSMenu::FindSliderMax(*item->getEvent(), &max); 120 SkOSMenu::FindSliderMax(*item->getEvent(), &max);
121 option.fCell = [self createSlider:value 121 option.fCell = [self createSlider:value
122 min:min 122 min:min
123 max:max]; 123 max:max];
124 break; 124 break;
125 case SkOSMenu::kSwitch_Type: 125 case SkOSMenu::kSwitch_Type:
126 SkOSMenu::FindSwitchState(*item->getEvent(), item->getSlotNa me(), &state); 126 SkOSMenu::FindSwitchState(*item->getEvent(), item->getSlotNa me(), &state);
127 option.fCell = [self createSwitch:(BOOL)state]; 127 option.fCell = [self createSwitch:(BOOL)state];
128 break; 128 break;
129 case SkOSMenu::kTriState_Type: 129 case SkOSMenu::kTriState_Type:
130 SkOSMenu::FindTriState(*item->getEvent(), item->getSlotName( ), &tristate); 130 SkOSMenu::FindTriState(*item->getEvent(), item->getSlotName( ), &tristate);
131 option.fCell = [self createTriState:[self triStateToNSState: tristate]]; 131 option.fCell = [self createTriState:[self triStateToNSState: tristate]];
132 break; 132 break;
133 case SkOSMenu::kTextField_Type: 133 case SkOSMenu::kTextField_Type:
134 SkOSMenu::FindText(*item->getEvent(),item->getSlotName(), &s tr); 134 SkOSMenu::FindText(*item->getEvent(),item->getSlotName(), &s tr);
(...skipping 10 matching lines...) Expand all
145 145
146 - (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView { 146 - (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView {
147 return [self.fItems count]; 147 return [self.fItems count];
148 } 148 }
149 149
150 - (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColum n *)tableColumn row:(NSInteger)row { 150 - (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColum n *)tableColumn row:(NSInteger)row {
151 int columnIndex = [tableView columnWithIdentifier:[tableColumn identifier]]; 151 int columnIndex = [tableView columnWithIdentifier:[tableColumn identifier]];
152 if (columnIndex == 0) { 152 if (columnIndex == 0) {
153 const SkOSMenu::Item* item = ((SkOptionItem*)[fItems objectAtIndex:row]) .fItem; 153 const SkOSMenu::Item* item = ((SkOptionItem*)[fItems objectAtIndex:row]) .fItem;
154 NSString* label = [NSString stringWithUTF8String:item->getLabel()]; 154 NSString* label = [NSString stringWithUTF8String:item->getLabel()];
155 if (fShowKeys) 155 if (fShowKeys)
156 return [NSString stringWithFormat:@"%@ (%c)", label, item->getKeyEqu ivalent()]; 156 return [NSString stringWithFormat:@"%@ (%c)", label, item->getKeyEqu ivalent()];
157 else 157 else
158 return label; 158 return label;
159 } 159 }
160 else 160 else
161 return nil; 161 return nil;
162 } 162 }
163 163
164 - (NSCell *)tableView:(NSTableView *)tableView dataCellForTableColumn:(NSTableCo lumn *)tableColumn row:(NSInteger)row { 164 - (NSCell *)tableView:(NSTableView *)tableView dataCellForTableColumn:(NSTableCo lumn *)tableColumn row:(NSInteger)row {
165 if (tableColumn) { 165 if (tableColumn) {
166 int columnIndex = [tableView columnWithIdentifier:[tableColumn identifie r]]; 166 int columnIndex = [tableView columnWithIdentifier:[tableColumn identifie r]];
167 if (columnIndex == 1) 167 if (columnIndex == 1)
168 return [((SkOptionItem*)[fItems objectAtIndex:row]).fCell copy]; 168 return [((SkOptionItem*)[fItems objectAtIndex:row]).fCell copy];
169 else 169 else
170 return [[[SkTextFieldCell alloc] init] autorelease]; 170 return [[[SkTextFieldCell alloc] init] autorelease];
171 } 171 }
172 return nil; 172 return nil;
173 } 173 }
174 174
175 - (void)tableView:(NSTableView *)tableView willDisplayCell:(id)cell forTableColu mn:(NSTableColumn *)tableColumn row:(NSInteger)row { 175 - (void)tableView:(NSTableView *)tableView willDisplayCell:(id)cell forTableColu mn:(NSTableColumn *)tableColumn row:(NSInteger)row {
176 int columnIndex = [tableView columnWithIdentifier:[tableColumn identifier]]; 176 int columnIndex = [tableView columnWithIdentifier:[tableColumn identifier]];
177 if (columnIndex == 1) { 177 if (columnIndex == 1) {
178 SkOptionItem* option = (SkOptionItem*)[self.fItems objectAtIndex:row]; 178 SkOptionItem* option = (SkOptionItem*)[self.fItems objectAtIndex:row];
179 NSCell* storedCell = option.fCell; 179 NSCell* storedCell = option.fCell;
180 const SkOSMenu::Item* item = option.fItem; 180 const SkOSMenu::Item* item = option.fItem;
181 switch (item->getType()) { 181 switch (item->getType()) {
182 case SkOSMenu::kAction_Type: 182 case SkOSMenu::kAction_Type:
183 break; 183 break;
184 case SkOSMenu::kList_Type: 184 case SkOSMenu::kList_Type:
185 [cell selectItemAtIndex:[(NSPopUpButtonCell*)storedCell indexOfS electedItem]]; 185 [cell selectItemAtIndex:[(NSPopUpButtonCell*)storedCell indexOfS electedItem]];
186 break; 186 break;
187 case SkOSMenu::kSlider_Type: 187 case SkOSMenu::kSlider_Type:
188 [cell setFloatValue:[storedCell floatValue]]; 188 [cell setFloatValue:[storedCell floatValue]];
189 break; 189 break;
190 case SkOSMenu::kSwitch_Type: 190 case SkOSMenu::kSwitch_Type:
191 [cell setState:[(NSButtonCell*)storedCell state]]; 191 [cell setState:[(NSButtonCell*)storedCell state]];
192 break; 192 break;
193 case SkOSMenu::kTextField_Type: 193 case SkOSMenu::kTextField_Type:
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 [cell setBezelStyle:NSSmallSquareBezelStyle]; 252 [cell setBezelStyle:NSSmallSquareBezelStyle];
253 return cell; 253 return cell;
254 } 254 }
255 255
256 - (NSCell*)createList:(NSArray*)items current:(int)index { 256 - (NSCell*)createList:(NSArray*)items current:(int)index {
257 NSPopUpButtonCell* cell = [[[NSPopUpButtonCell alloc] init] autorelease]; 257 NSPopUpButtonCell* cell = [[[NSPopUpButtonCell alloc] init] autorelease];
258 [cell addItemsWithTitles:items]; 258 [cell addItemsWithTitles:items];
259 [cell selectItemAtIndex:index]; 259 [cell selectItemAtIndex:index];
260 [cell setArrowPosition:NSPopUpArrowAtBottom]; 260 [cell setArrowPosition:NSPopUpArrowAtBottom];
261 [cell setBezelStyle:NSSmallSquareBezelStyle]; 261 [cell setBezelStyle:NSSmallSquareBezelStyle];
262 return cell; 262 return cell;
263 } 263 }
264 264
265 - (NSCell*)createSlider:(float)value min:(float)min max:(float)max { 265 - (NSCell*)createSlider:(float)value min:(float)min max:(float)max {
266 NSSliderCell* cell = [[[NSSliderCell alloc] init] autorelease]; 266 NSSliderCell* cell = [[[NSSliderCell alloc] init] autorelease];
267 [cell setFloatValue:value]; 267 [cell setFloatValue:value];
268 [cell setMinValue:min]; 268 [cell setMinValue:min];
269 [cell setMaxValue:max]; 269 [cell setMaxValue:max];
270 return cell; 270 return cell;
271 } 271 }
272 272
273 - (NSCell*)createSwitch:(BOOL)state { 273 - (NSCell*)createSwitch:(BOOL)state {
274 NSButtonCell* cell = [[[NSButtonCell alloc] init] autorelease]; 274 NSButtonCell* cell = [[[NSButtonCell alloc] init] autorelease];
275 [cell setState:state]; 275 [cell setState:state];
276 [cell setTitle:@""]; 276 [cell setTitle:@""];
277 [cell setButtonType:NSSwitchButton]; 277 [cell setButtonType:NSSwitchButton];
278 return cell; 278 return cell;
279 } 279 }
280 280
281 - (NSCell*)createTextField:(NSString*)placeHolder; { 281 - (NSCell*)createTextField:(NSString*)placeHolder {
282 SkTextFieldCell* cell = [[[SkTextFieldCell alloc] init] autorelease]; 282 SkTextFieldCell* cell = [[[SkTextFieldCell alloc] init] autorelease];
283 [cell setEditable:YES]; 283 [cell setEditable:YES];
284 [cell setStringValue:@""]; 284 [cell setStringValue:@""];
285 [cell setPlaceholderString:placeHolder]; 285 [cell setPlaceholderString:placeHolder];
286 return cell; 286 return cell;
287 } 287 }
288 288
289 - (NSCell*)createTriState:(NSCellStateValue)state { 289 - (NSCell*)createTriState:(NSCellStateValue)state {
290 NSButtonCell* cell = [[[NSButtonCell alloc] init] autorelease]; 290 NSButtonCell* cell = [[[NSButtonCell alloc] init] autorelease];
291 [cell setAllowsMixedState:TRUE]; 291 [cell setAllowsMixedState:TRUE];
292 [cell setTitle:@""]; 292 [cell setTitle:@""];
293 [cell setState:(NSInteger)state]; 293 [cell setState:(NSInteger)state];
294 [cell setButtonType:NSSwitchButton]; 294 [cell setButtonType:NSSwitchButton];
295 return cell; 295 return cell;
296 } 296 }
297 @end 297 @end
OLDNEW
« no previous file with comments | « src/utils/SkLayer.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698