| 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 #include "ui/message_center/views/notification_view.h" | 5 #include "ui/message_center/views/notification_view.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "grit/ui_resources.h" | 9 #include "grit/ui_resources.h" |
| 10 #include "ui/base/accessibility/accessible_view_state.h" | 10 #include "ui/base/accessibility/accessible_view_state.h" |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 DISALLOW_COPY_AND_ASSIGN(ItemView); | 130 DISALLOW_COPY_AND_ASSIGN(ItemView); |
| 131 }; | 131 }; |
| 132 | 132 |
| 133 ItemView::ItemView(const message_center::NotificationItem& item) { | 133 ItemView::ItemView(const message_center::NotificationItem& item) { |
| 134 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, | 134 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, |
| 135 0, 0, kItemTitleToMessagePadding)); | 135 0, 0, kItemTitleToMessagePadding)); |
| 136 | 136 |
| 137 views::Label* title = new views::Label(item.title); | 137 views::Label* title = new views::Label(item.title); |
| 138 title->set_collapse_when_hidden(true); | 138 title->set_collapse_when_hidden(true); |
| 139 title->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 139 title->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 140 title->SetElideBehavior(views::Label::ELIDE_AT_END); | |
| 141 title->SetEnabledColor(message_center::kRegularTextColor); | 140 title->SetEnabledColor(message_center::kRegularTextColor); |
| 142 title->SetBackgroundColor(kRegularTextBackgroundColor); | 141 title->SetBackgroundColor(kRegularTextBackgroundColor); |
| 143 AddChildView(title); | 142 AddChildView(title); |
| 144 | 143 |
| 145 views::Label* message = new views::Label(item.message); | 144 views::Label* message = new views::Label(item.message); |
| 146 message->set_collapse_when_hidden(true); | 145 message->set_collapse_when_hidden(true); |
| 147 message->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 146 message->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 148 message->SetElideBehavior(views::Label::ELIDE_AT_END); | |
| 149 message->SetEnabledColor(kDimTextColor); | 147 message->SetEnabledColor(kDimTextColor); |
| 150 message->SetBackgroundColor(kDimTextBackgroundColor); | 148 message->SetBackgroundColor(kDimTextBackgroundColor); |
| 151 AddChildView(message); | 149 AddChildView(message); |
| 152 | 150 |
| 153 PreferredSizeChanged(); | 151 PreferredSizeChanged(); |
| 154 SchedulePaint(); | 152 SchedulePaint(); |
| 155 } | 153 } |
| 156 | 154 |
| 157 ItemView::~ItemView() { | 155 ItemView::~ItemView() { |
| 158 } | 156 } |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 } | 296 } |
| 299 | 297 |
| 300 void NotificationButton::SetTitle(const string16& title) { | 298 void NotificationButton::SetTitle(const string16& title) { |
| 301 if (title_ != NULL) | 299 if (title_ != NULL) |
| 302 delete title_; // This removes the title from this view's children. | 300 delete title_; // This removes the title from this view's children. |
| 303 if (title.empty()) { | 301 if (title.empty()) { |
| 304 title_ = NULL; | 302 title_ = NULL; |
| 305 } else { | 303 } else { |
| 306 title_ = new views::Label(title); | 304 title_ = new views::Label(title); |
| 307 title_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 305 title_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 308 title_->SetElideBehavior(views::Label::ELIDE_AT_END); | |
| 309 title_->SetEnabledColor(message_center::kRegularTextColor); | 306 title_->SetEnabledColor(message_center::kRegularTextColor); |
| 310 title_->SetBackgroundColor(kRegularTextBackgroundColor); | 307 title_->SetBackgroundColor(kRegularTextBackgroundColor); |
| 311 title_->set_border(MakeEmptyBorder(kButtonTitleTopPadding, 0, 0, 0)); | 308 title_->set_border(MakeEmptyBorder(kButtonTitleTopPadding, 0, 0, 0)); |
| 312 AddChildView(title_); | 309 AddChildView(title_); |
| 313 } | 310 } |
| 314 SetAccessibleName(title); | 311 SetAccessibleName(title); |
| 315 } | 312 } |
| 316 | 313 |
| 317 gfx::Size NotificationButton::GetPreferredSize() { | 314 gfx::Size NotificationButton::GetPreferredSize() { |
| 318 return gfx::Size(message_center::kNotificationWidth, | 315 return gfx::Size(message_center::kNotificationWidth, |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 663 return message_view_ ? | 660 return message_view_ ? |
| 664 message_view_->GetLinesForWidthAndLimit(width, limit) : 0; | 661 message_view_->GetLinesForWidthAndLimit(width, limit) : 0; |
| 665 } | 662 } |
| 666 | 663 |
| 667 int NotificationView::GetMessageHeight(int width, int limit) { | 664 int NotificationView::GetMessageHeight(int width, int limit) { |
| 668 return message_view_ ? | 665 return message_view_ ? |
| 669 message_view_->GetSizeForWidthAndLines(width, limit).height() : 0; | 666 message_view_->GetSizeForWidthAndLines(width, limit).height() : 0; |
| 670 } | 667 } |
| 671 | 668 |
| 672 } // namespace message_center | 669 } // namespace message_center |
| OLD | NEW |