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

Side by Side Diff: ui/message_center/cocoa/settings_controller.mm

Issue 17593006: mac: Update clients of scoped_nsobject.h. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: iwyu, scoped_nsprotocol 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "ui/message_center/cocoa/settings_controller.h" 5 #import "ui/message_center/cocoa/settings_controller.h"
6 6
7 #include "base/mac/foundation_util.h" 7 #include "base/mac/foundation_util.h"
8 #import "base/mac/scoped_nsobject.h"
8 #include "base/strings/sys_string_conversions.h" 9 #include "base/strings/sys_string_conversions.h"
9 #include "grit/ui_strings.h" 10 #include "grit/ui_strings.h"
11 #include "skia/ext/skia_utils_mac.h"
10 #include "ui/base/l10n/l10n_util.h" 12 #include "ui/base/l10n/l10n_util.h"
11 #include "ui/base/resource/resource_bundle.h" 13 #include "ui/base/resource/resource_bundle.h"
12 #import "base/memory/scoped_nsobject.h"
13 #import "ui/message_center/cocoa/tray_view_controller.h" 14 #import "ui/message_center/cocoa/tray_view_controller.h"
14 #include "ui/message_center/message_center_style.h" 15 #include "ui/message_center/message_center_style.h"
15 #include "skia/ext/skia_utils_mac.h"
16 16
17 const int kMarginWidth = 16; 17 const int kMarginWidth = 16;
18 const int kEntryHeight = 38; 18 const int kEntryHeight = 38;
19 const int kIconSize = 16; 19 const int kIconSize = 16;
20 const int kIconTextPadding = 8; 20 const int kIconTextPadding = 8;
21 const int kCheckmarkIconPadding = 16; 21 const int kCheckmarkIconPadding = 16;
22 22
23 const int kIntrinsicCheckmarkPadding = 4; // Padding already provided by Cocoa. 23 const int kIntrinsicCheckmarkPadding = 4; // Padding already provided by Cocoa.
24 const int kCorrectedCheckmarkPadding = 24 const int kCorrectedCheckmarkPadding =
25 kCheckmarkIconPadding - kIntrinsicCheckmarkPadding; 25 kCheckmarkIconPadding - kIntrinsicCheckmarkPadding;
26 26
27 @interface MCSettingsButtonCell : NSButtonCell { 27 @interface MCSettingsButtonCell : NSButtonCell {
28 // A checkbox's regular image is the checkmark image. This additional image 28 // A checkbox's regular image is the checkmark image. This additional image
29 // is used for the favicon or app icon shown next to the checkmark. 29 // is used for the favicon or app icon shown next to the checkmark.
30 scoped_nsobject<NSImage> extraImage_; 30 base::scoped_nsobject<NSImage> extraImage_;
31 } 31 }
32 - (void)setExtraImage:(NSImage*)extraImage; 32 - (void)setExtraImage:(NSImage*)extraImage;
33 @end 33 @end
34 34
35 @implementation MCSettingsButtonCell 35 @implementation MCSettingsButtonCell
36 - (void)setExtraImage:(NSImage*)extraImage { 36 - (void)setExtraImage:(NSImage*)extraImage {
37 extraImage_.reset([extraImage retain]); 37 extraImage_.reset([extraImage retain]);
38 } 38 }
39 39
40 - (NSRect)drawTitle:(NSAttributedString*)title 40 - (NSRect)drawTitle:(NSAttributedString*)title
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 return label; 143 return label;
144 } 144 }
145 145
146 - (void)loadView { 146 - (void)loadView {
147 provider_->GetNotifierList(&notifiers_); 147 provider_->GetNotifierList(&notifiers_);
148 CGFloat maxHeight = [MCTrayViewController maxTrayClientHeight]; 148 CGFloat maxHeight = [MCTrayViewController maxTrayClientHeight];
149 149
150 // Container view. 150 // Container view.
151 NSRect fullFrame = 151 NSRect fullFrame =
152 NSMakeRect(0, 0, [MCTrayViewController trayWidth], maxHeight); 152 NSMakeRect(0, 0, [MCTrayViewController trayWidth], maxHeight);
153 scoped_nsobject<NSBox> view([[NSBox alloc] initWithFrame:fullFrame]); 153 base::scoped_nsobject<NSBox> view([[NSBox alloc] initWithFrame:fullFrame]);
154 [view setBorderType:NSNoBorder]; 154 [view setBorderType:NSNoBorder];
155 [view setBoxType:NSBoxCustom]; 155 [view setBoxType:NSBoxCustom];
156 [view setContentViewMargins:NSZeroSize]; 156 [view setContentViewMargins:NSZeroSize];
157 [view setFillColor:gfx::SkColorToCalibratedNSColor( 157 [view setFillColor:gfx::SkColorToCalibratedNSColor(
158 message_center::kMessageCenterBackgroundColor)]; 158 message_center::kMessageCenterBackgroundColor)];
159 [view setTitlePosition:NSNoTitle]; 159 [view setTitlePosition:NSNoTitle];
160 [self setView:view]; 160 [self setView:view];
161 161
162 // "Settings" text. 162 // "Settings" text.
163 NSRect headerFrame = NSMakeRect( 163 NSRect headerFrame = NSMakeRect(
(...skipping 28 matching lines...) Expand all
192 [detailsText_ sizeToFit]; 192 [detailsText_ sizeToFit];
193 subheaderFrame = [detailsText_ frame]; 193 subheaderFrame = [detailsText_ frame];
194 subheaderFrame.origin.y = 194 subheaderFrame.origin.y =
195 NSMinY(headerFrame) - message_center::kTextTopPadding - 195 NSMinY(headerFrame) - message_center::kTextTopPadding -
196 NSHeight(subheaderFrame); 196 NSHeight(subheaderFrame);
197 [[self view] addSubview:detailsText_]; 197 [[self view] addSubview:detailsText_];
198 198
199 // Document view for the notifier settings. 199 // Document view for the notifier settings.
200 CGFloat y = 0; 200 CGFloat y = 0;
201 NSRect documentFrame = NSMakeRect(0, 0, NSWidth(fullFrame), 0); 201 NSRect documentFrame = NSMakeRect(0, 0, NSWidth(fullFrame), 0);
202 scoped_nsobject<NSView> documentView( 202 base::scoped_nsobject<NSView> documentView(
203 [[NSView alloc] initWithFrame:documentFrame]); 203 [[NSView alloc] initWithFrame:documentFrame]);
204 for (int i = notifiers_.size() - 1; i >= 0; --i) { 204 for (int i = notifiers_.size() - 1; i >= 0; --i) {
205 message_center::Notifier* notifier = notifiers_[i]; 205 message_center::Notifier* notifier = notifiers_[i];
206 206
207 // TODO(thakis): Use a custom button cell. 207 // TODO(thakis): Use a custom button cell.
208 NSRect frame = NSMakeRect( 208 NSRect frame = NSMakeRect(
209 kMarginWidth, y, NSWidth(documentFrame) - kMarginWidth, kEntryHeight); 209 kMarginWidth, y, NSWidth(documentFrame) - kMarginWidth, kEntryHeight);
210 scoped_nsobject<NSButton> button([[NSButton alloc] initWithFrame:frame]); 210 base::scoped_nsobject<NSButton> button(
211 scoped_nsobject<MCSettingsButtonCell> cell( 211 [[NSButton alloc] initWithFrame:frame]);
212 base::scoped_nsobject<MCSettingsButtonCell> cell(
212 [[MCSettingsButtonCell alloc] 213 [[MCSettingsButtonCell alloc]
213 initTextCell:base::SysUTF16ToNSString(notifier->name)]); 214 initTextCell:base::SysUTF16ToNSString(notifier->name)]);
214 [button setCell:cell]; 215 [button setCell:cell];
215 [button setButtonType:NSSwitchButton]; 216 [button setButtonType:NSSwitchButton];
216 217
217 [button setState:notifier->enabled ? NSOnState : NSOffState]; 218 [button setState:notifier->enabled ? NSOnState : NSOffState];
218 [button setTag:i]; 219 [button setTag:i];
219 [button setTarget:self]; 220 [button setTarget:self];
220 [button setAction:@selector(checkboxClicked:)]; 221 [button setAction:@selector(checkboxClicked:)];
221 222
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 305
305 - (NSButton*)buttonForNotifierAtIndex:(size_t)index { 306 - (NSButton*)buttonForNotifierAtIndex:(size_t)index {
306 NSArray* subviews = [[scrollView_ documentView] subviews]; 307 NSArray* subviews = [[scrollView_ documentView] subviews];
307 // The checkboxes are in bottom-top order, the checkbox for notifiers_[0] is 308 // The checkboxes are in bottom-top order, the checkbox for notifiers_[0] is
308 // last. 309 // last.
309 NSView* view = [subviews objectAtIndex:notifiers_.size() - 1 - index]; 310 NSView* view = [subviews objectAtIndex:notifiers_.size() - 1 - index];
310 return base::mac::ObjCCastStrict<NSButton>(view); 311 return base::mac::ObjCCastStrict<NSButton>(view);
311 } 312 }
312 313
313 @end 314 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698