| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/ui/cocoa/confirm_bubble_cocoa.h" | 5 #import "chrome/browser/ui/cocoa/confirm_bubble_cocoa.h" |
| 6 | 6 |
| 7 #include "base/strings/string16.h" | 7 #include "base/strings/string16.h" |
| 8 #include "chrome/browser/themes/theme_service.h" | 8 #include "chrome/browser/themes/theme_service.h" |
| 9 #import "chrome/browser/ui/cocoa/confirm_bubble_controller.h" | 9 #import "chrome/browser/ui/cocoa/confirm_bubble_controller.h" |
| 10 #include "chrome/browser/ui/confirm_bubble.h" | 10 #include "chrome/browser/ui/confirm_bubble.h" |
| 11 #include "chrome/browser/ui/confirm_bubble_model.h" | 11 #include "chrome/browser/ui/confirm_bubble_model.h" |
| 12 #import "third_party/GTM/AppKit/GTMNSBezierPath+RoundRect.h" | 12 #import "third_party/GTM/AppKit/GTMNSBezierPath+RoundRect.h" |
| 13 #include "ui/gfx/image/image.h" | 13 #include "ui/gfx/image/image.h" |
| 14 #include "ui/gfx/point.h" | 14 #include "ui/gfx/point.h" |
| 15 | 15 |
| 16 namespace { | |
| 17 | |
| 18 // The width for the message text. We break lines so the specified message fits | 16 // The width for the message text. We break lines so the specified message fits |
| 19 // into this width. | 17 // into this width. |
| 20 const int kMaxMessageWidth = 400; | 18 const int kMaxMessageWidth = 400; |
| 21 | 19 |
| 22 // The corner redius of this bubble view. | 20 // The corner redius of this bubble view. |
| 23 const int kBubbleCornerRadius = 3; | 21 const int kBubbleCornerRadius = 3; |
| 24 | 22 |
| 25 // The color for the border of this bubble view. | 23 // The color for the border of this bubble view. |
| 26 const float kBubbleWindowEdge = 0.7f; | 24 const float kBubbleWindowEdge = 0.7f; |
| 27 | 25 |
| 28 // Constants used for layouting controls. These variables are copied from | 26 // Constants used for layouting controls. These variables are copied from |
| 29 // "ui/views/layout/layout_constants.h". | 27 // "ui/views/layout/layout_constants.h". |
| 30 // Vertical spacing between a label and some control. | 28 // Vertical spacing between a label and some control. |
| 31 const int kLabelToControlVerticalSpacing = 8; | 29 const int kLabelToControlVerticalSpacing = 8; |
| 32 | 30 |
| 33 // Horizontal spacing between controls that are logically related. | 31 // Horizontal spacing between controls that are logically related. |
| 34 const int kRelatedControlHorizontalSpacing = 8; | 32 const int kRelatedControlHorizontalSpacing = 8; |
| 35 | 33 |
| 36 // Vertical spacing between controls that are logically related. | 34 // Vertical spacing between controls that are logically related. |
| 37 const int kRelatedControlVerticalSpacing = 8; | 35 const int kRelatedControlVerticalSpacing = 8; |
| 38 | 36 |
| 39 // Horizontal spacing between controls that are logically unrelated. | |
| 40 const int kUnrelatedControlHorizontalSpacing = 12; | |
| 41 | |
| 42 // Vertical spacing between the edge of the window and the | 37 // Vertical spacing between the edge of the window and the |
| 43 // top or bottom of a button. | 38 // top or bottom of a button. |
| 44 const int kButtonVEdgeMargin = 6; | 39 const int kButtonVEdgeMargin = 6; |
| 45 | 40 |
| 46 // Horizontal spacing between the edge of the window and the | 41 // Horizontal spacing between the edge of the window and the |
| 47 // left or right of a button. | 42 // left or right of a button. |
| 48 const int kButtonHEdgeMargin = 7; | 43 const int kButtonHEdgeMargin = 7; |
| 49 | 44 |
| 50 } // namespace | |
| 51 | |
| 52 namespace chrome { | 45 namespace chrome { |
| 53 | 46 |
| 54 void ShowConfirmBubble(gfx::NativeView view, | 47 void ShowConfirmBubble(gfx::NativeView view, |
| 55 const gfx::Point& origin, | 48 const gfx::Point& origin, |
| 56 ConfirmBubbleModel* model) { | 49 ConfirmBubbleModel* model) { |
| 57 // Create a custom NSViewController that manages a bubble view, and add it to | 50 // Create a custom NSViewController that manages a bubble view, and add it to |
| 58 // a child to the specified view. This controller will be automatically | 51 // a child to the specified view. This controller will be automatically |
| 59 // deleted when it loses first-responder status. | 52 // deleted when it loses first-responder status. |
| 60 ConfirmBubbleController* controller = | 53 ConfirmBubbleController* controller = |
| 61 [[ConfirmBubbleController alloc] initWithParent:view | 54 [[ConfirmBubbleController alloc] initWithParent:view |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 | 287 |
| 295 - (void)clickCancel { | 288 - (void)clickCancel { |
| 296 [self cancel:self]; | 289 [self cancel:self]; |
| 297 } | 290 } |
| 298 | 291 |
| 299 - (void)clickLink { | 292 - (void)clickLink { |
| 300 [self textView:messageLabel_.get() clickedOnLink:nil atIndex:0]; | 293 [self textView:messageLabel_.get() clickedOnLink:nil atIndex:0]; |
| 301 } | 294 } |
| 302 | 295 |
| 303 @end | 296 @end |
| OLD | NEW |