OLD | NEW |
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 #include "chrome/browser/ui/views/validation_message_bubble_delegate.h" | 5 #include "chrome/browser/ui/views/validation_message_bubble_delegate.h" |
6 | 6 |
7 #include "grit/theme_resources.h" | 7 #include "grit/theme_resources.h" |
8 #include "ui/base/resource/resource_bundle.h" | 8 #include "ui/base/resource/resource_bundle.h" |
9 #include "ui/views/controls/image_view.h" | 9 #include "ui/views/controls/image_view.h" |
10 #include "ui/views/controls/label.h" | 10 #include "ui/views/controls/label.h" |
11 #include "ui/views/widget/widget.h" | 11 #include "ui/views/widget/widget.h" |
12 | 12 |
13 // static | 13 // static |
14 const int ValidationMessageBubbleDelegate::kWindowMinWidth = 64; | 14 const int ValidationMessageBubbleDelegate::kWindowMinWidth = 64; |
15 // static | 15 // static |
16 const int ValidationMessageBubbleDelegate::kWindowMaxWidth = 256; | 16 const int ValidationMessageBubbleDelegate::kWindowMaxWidth = 256; |
17 static const int kPadding = 0; | 17 static const int kPadding = 0; |
18 static const int kIconTextMargin = 8; | 18 static const int kIconTextMargin = 8; |
19 static const int kTextVerticalMargin = 4; | 19 static const int kTextVerticalMargin = 4; |
20 | 20 |
21 ValidationMessageBubbleDelegate::ValidationMessageBubbleDelegate( | 21 ValidationMessageBubbleDelegate::ValidationMessageBubbleDelegate( |
22 const gfx::Rect& anchor_in_screen, | 22 const gfx::Rect& anchor_in_screen, |
23 const base::string16& main_text, | 23 const base::string16& main_text, |
24 const base::string16& sub_text, | 24 const base::string16& sub_text, |
25 Observer* observer) | 25 Observer* observer) |
26 : observer_(observer), width_(0), height_(0) { | 26 : observer_(observer), width_(0), height_(0) { |
27 set_use_focusless(true); | 27 set_can_activate(false); |
28 set_arrow(views::BubbleBorder::TOP_LEFT); | 28 set_arrow(views::BubbleBorder::TOP_LEFT); |
29 SetAnchorRect(anchor_in_screen); | 29 SetAnchorRect(anchor_in_screen); |
30 | 30 |
31 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); | 31 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
32 views::ImageView* icon = new views::ImageView(); | 32 views::ImageView* icon = new views::ImageView(); |
33 icon->SetImage(*bundle.GetImageSkiaNamed(IDR_INPUT_ALERT)); | 33 icon->SetImage(*bundle.GetImageSkiaNamed(IDR_INPUT_ALERT)); |
34 gfx::Size size = icon->GetPreferredSize(); | 34 gfx::Size size = icon->GetPreferredSize(); |
35 icon->SetBounds(kPadding, kPadding, size.width(), size.height()); | 35 icon->SetBounds(kPadding, kPadding, size.width(), size.height()); |
36 AddChildView(icon); | 36 AddChildView(icon); |
37 | 37 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 } | 91 } |
92 | 92 |
93 void ValidationMessageBubbleDelegate::DeleteDelegate() { | 93 void ValidationMessageBubbleDelegate::DeleteDelegate() { |
94 delete this; | 94 delete this; |
95 } | 95 } |
96 | 96 |
97 void ValidationMessageBubbleDelegate::WindowClosing() { | 97 void ValidationMessageBubbleDelegate::WindowClosing() { |
98 if (observer_ != NULL) | 98 if (observer_ != NULL) |
99 observer_->WindowClosing(); | 99 observer_->WindowClosing(); |
100 } | 100 } |
OLD | NEW |