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 "chrome/browser/chromeos/input_method/candidate_window.h" | 5 #include "chrome/browser/chromeos/input_method/candidate_window.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 // child view, hence it's deleted when |this| is deleted. | 224 // child view, hence it's deleted when |this| is deleted. |
225 if (orientation == InputMethodLookupTable::kVertical) { | 225 if (orientation == InputMethodLookupTable::kVertical) { |
226 candidate_label = new VerticalCandidateLabel; | 226 candidate_label = new VerticalCandidateLabel; |
227 } else { | 227 } else { |
228 candidate_label = new views::Label; | 228 candidate_label = new views::Label; |
229 } | 229 } |
230 | 230 |
231 // Change the font size. | 231 // Change the font size. |
232 candidate_label->SetFont( | 232 candidate_label->SetFont( |
233 candidate_label->font().DeriveFont(kFontSizeDelta)); | 233 candidate_label->font().DeriveFont(kFontSizeDelta)); |
234 candidate_label->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 234 candidate_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
235 | 235 |
236 return candidate_label; | 236 return candidate_label; |
237 } | 237 } |
238 | 238 |
239 // Creates the annotation label, and return it (never returns NULL). | 239 // Creates the annotation label, and return it (never returns NULL). |
240 // The label text is not set in this function. | 240 // The label text is not set in this function. |
241 views::Label* CreateAnnotationLabel( | 241 views::Label* CreateAnnotationLabel( |
242 InputMethodLookupTable::Orientation orientation) { | 242 InputMethodLookupTable::Orientation orientation) { |
243 // Create the annotation label. | 243 // Create the annotation label. |
244 views::Label* annotation_label = new views::Label; | 244 views::Label* annotation_label = new views::Label; |
245 | 245 |
246 // Change the font size and color. | 246 // Change the font size and color. |
247 annotation_label->SetFont( | 247 annotation_label->SetFont( |
248 annotation_label->font().DeriveFont(kFontSizeDelta)); | 248 annotation_label->font().DeriveFont(kFontSizeDelta)); |
249 annotation_label->SetEnabledColor(kAnnotationColor); | 249 annotation_label->SetEnabledColor(kAnnotationColor); |
250 annotation_label->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 250 annotation_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
251 | 251 |
252 return annotation_label; | 252 return annotation_label; |
253 } | 253 } |
254 | 254 |
255 // Computes shortcut column size. | 255 // Computes shortcut column size. |
256 gfx::Size ComputeShortcutColumnSize( | 256 gfx::Size ComputeShortcutColumnSize( |
257 const InputMethodLookupTable& lookup_table) { | 257 const InputMethodLookupTable& lookup_table) { |
258 int shortcut_column_width = 0; | 258 int shortcut_column_width = 0; |
259 int shortcut_column_height = 0; | 259 int shortcut_column_height = 0; |
260 // Create the shortcut label. The label will be owned by | 260 // Create the shortcut label. The label will be owned by |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 scoped_ptr<views::View> contents_; | 409 scoped_ptr<views::View> contents_; |
410 scoped_ptr<views::View> place_holder_; | 410 scoped_ptr<views::View> place_holder_; |
411 | 411 |
412 DISALLOW_COPY_AND_ASSIGN(HidableArea); | 412 DISALLOW_COPY_AND_ASSIGN(HidableArea); |
413 }; | 413 }; |
414 | 414 |
415 // InformationTextArea is a HidableArea having a single Label in it. | 415 // InformationTextArea is a HidableArea having a single Label in it. |
416 class InformationTextArea : public HidableArea { | 416 class InformationTextArea : public HidableArea { |
417 public: | 417 public: |
418 // Specify the alignment and initialize the control. | 418 // Specify the alignment and initialize the control. |
419 InformationTextArea(views::Label::Alignment align, int minWidth) | 419 InformationTextArea(gfx::HorizontalAlignment align, int minWidth) |
420 : minWidth_(minWidth) { | 420 : minWidth_(minWidth) { |
421 label_ = new views::Label; | 421 label_ = new views::Label; |
422 label_->SetHorizontalAlignment(align); | 422 label_->SetHorizontalAlignment(align); |
423 | 423 |
424 const gfx::Insets kInsets(2, 2, 2, 4); | 424 const gfx::Insets kInsets(2, 2, 2, 4); |
425 views::View* contents = WrapWithPadding(label_, kInsets); | 425 views::View* contents = WrapWithPadding(label_, kInsets); |
426 SetContents(contents); | 426 SetContents(contents); |
427 contents->set_border( | 427 contents->set_border( |
428 views::Border::CreateSolidBorder(1, kFrameColor)); | 428 views::Border::CreateSolidBorder(1, kFrameColor)); |
429 contents->set_background( | 429 contents->set_background( |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
793 CandidateWindowView::~CandidateWindowView() { | 793 CandidateWindowView::~CandidateWindowView() { |
794 } | 794 } |
795 | 795 |
796 void CandidateWindowView::Init() { | 796 void CandidateWindowView::Init() { |
797 // Set the background and the border of the view. | 797 // Set the background and the border of the view. |
798 set_background( | 798 set_background( |
799 views::Background::CreateSolidBackground(kDefaultBackgroundColor)); | 799 views::Background::CreateSolidBackground(kDefaultBackgroundColor)); |
800 set_border(views::Border::CreateSolidBorder(1, kFrameColor)); | 800 set_border(views::Border::CreateSolidBorder(1, kFrameColor)); |
801 | 801 |
802 // Create areas. | 802 // Create areas. |
803 preedit_area_ = new InformationTextArea(views::Label::ALIGN_LEFT, | 803 preedit_area_ = new InformationTextArea(gfx::ALIGN_LEFT, |
804 kMinPreeditAreaWidth); | 804 kMinPreeditAreaWidth); |
805 header_area_ = new InformationTextArea(views::Label::ALIGN_LEFT, 0); | 805 header_area_ = new InformationTextArea(gfx::ALIGN_LEFT, 0); |
806 candidate_area_ = new HidableArea; | 806 candidate_area_ = new HidableArea; |
807 candidate_area_->SetContents(new views::View); | 807 candidate_area_->SetContents(new views::View); |
808 footer_area_ = new InformationTextArea(views::Label::ALIGN_RIGHT, 0); | 808 footer_area_ = new InformationTextArea(gfx::ALIGN_RIGHT, 0); |
809 | 809 |
810 // Set the window layout of the view | 810 // Set the window layout of the view |
811 views::GridLayout* layout = new views::GridLayout(this); | 811 views::GridLayout* layout = new views::GridLayout(this); |
812 SetLayoutManager(layout); // |this| owns |layout|. | 812 SetLayoutManager(layout); // |this| owns |layout|. |
813 views::ColumnSet* column_set = layout->AddColumnSet(0); | 813 views::ColumnSet* column_set = layout->AddColumnSet(0); |
814 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, | 814 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, |
815 0, views::GridLayout::USE_PREF, 0, 0); | 815 0, views::GridLayout::USE_PREF, 0, 0); |
816 | 816 |
817 // Add the preedit area | 817 // Add the preedit area |
818 layout->StartRow(0, 0); | 818 layout->StartRow(0, 0); |
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1286 : parent_infolist_window_(parent_infolist_window), | 1286 : parent_infolist_window_(parent_infolist_window), |
1287 title_label_(NULL), | 1287 title_label_(NULL), |
1288 description_label_(NULL), | 1288 description_label_(NULL), |
1289 selected_(false) { | 1289 selected_(false) { |
1290 } | 1290 } |
1291 | 1291 |
1292 void InfolistView::Init() { | 1292 void InfolistView::Init() { |
1293 title_label_ = new views::Label; | 1293 title_label_ = new views::Label; |
1294 title_label_->SetPosition(gfx::Point(0, 0)); | 1294 title_label_->SetPosition(gfx::Point(0, 0)); |
1295 title_label_->SetFont(parent_infolist_window_->GetTitleFont()); | 1295 title_label_->SetFont(parent_infolist_window_->GetTitleFont()); |
1296 title_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 1296 title_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
1297 title_label_->set_border( | 1297 title_label_->set_border( |
1298 views::Border::CreateEmptyBorder(4, 7, 2, 4)); | 1298 views::Border::CreateEmptyBorder(4, 7, 2, 4)); |
1299 | 1299 |
1300 description_label_ = new views::Label; | 1300 description_label_ = new views::Label; |
1301 description_label_->SetPosition(gfx::Point(0, 0)); | 1301 description_label_->SetPosition(gfx::Point(0, 0)); |
1302 description_label_->SetFont(parent_infolist_window_->GetDescriptionFont()); | 1302 description_label_->SetFont(parent_infolist_window_->GetDescriptionFont()); |
1303 description_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 1303 description_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
1304 description_label_->SetMultiLine(true); | 1304 description_label_->SetMultiLine(true); |
1305 description_label_->set_border( | 1305 description_label_->set_border( |
1306 views::Border::CreateEmptyBorder(2, 17, 4, 4)); | 1306 views::Border::CreateEmptyBorder(2, 17, 4, 4)); |
1307 AddChildView(title_label_); | 1307 AddChildView(title_label_); |
1308 AddChildView(description_label_); | 1308 AddChildView(description_label_); |
1309 UpdateLabelBackgroundColors(); | 1309 UpdateLabelBackgroundColors(); |
1310 } | 1310 } |
1311 | 1311 |
1312 void InfolistView::SetTitleAndDescriptionText(const string16& title, | 1312 void InfolistView::SetTitleAndDescriptionText(const string16& title, |
1313 const string16& description) { | 1313 const string16& description) { |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1387 views::Background::CreateSolidBackground(kDefaultBackgroundColor)); | 1387 views::Background::CreateSolidBackground(kDefaultBackgroundColor)); |
1388 set_border(views::Border::CreateSolidBorder(1, kFrameColor)); | 1388 set_border(views::Border::CreateSolidBorder(1, kFrameColor)); |
1389 infolist_area_ = new views::View; | 1389 infolist_area_ = new views::View; |
1390 | 1390 |
1391 views::BoxLayout* layout = new views::BoxLayout(views::BoxLayout::kVertical, | 1391 views::BoxLayout* layout = new views::BoxLayout(views::BoxLayout::kVertical, |
1392 0, 0, 0); | 1392 0, 0, 0); |
1393 SetLayoutManager(layout); // |this| owns |layout|. | 1393 SetLayoutManager(layout); // |this| owns |layout|. |
1394 | 1394 |
1395 views::Label* caption_label = new views::Label; | 1395 views::Label* caption_label = new views::Label; |
1396 caption_label->SetFont(caption_label->font().DeriveFont(kFontSizeDelta - 2)); | 1396 caption_label->SetFont(caption_label->font().DeriveFont(kFontSizeDelta - 2)); |
1397 caption_label->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 1397 caption_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
1398 caption_label->SetText( | 1398 caption_label->SetText( |
1399 l10n_util::GetStringUTF16(IDS_INPUT_METHOD_INFOLIST_WINDOW_TITLE)); | 1399 l10n_util::GetStringUTF16(IDS_INPUT_METHOD_INFOLIST_WINDOW_TITLE)); |
1400 caption_label->set_border( | 1400 caption_label->set_border( |
1401 views::Border::CreateEmptyBorder(2, 2, 2, 2)); | 1401 views::Border::CreateEmptyBorder(2, 2, 2, 2)); |
1402 caption_label->set_background( | 1402 caption_label->set_background( |
1403 views::Background::CreateSolidBackground(kInfolistTitleBackgroundColor)); | 1403 views::Background::CreateSolidBackground(kInfolistTitleBackgroundColor)); |
1404 caption_label->SetBackgroundColor( | 1404 caption_label->SetBackgroundColor( |
1405 caption_label->background()->get_color()); | 1405 caption_label->background()->get_color()); |
1406 | 1406 |
1407 AddChildView(caption_label); | 1407 AddChildView(caption_label); |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1770 } | 1770 } |
1771 | 1771 |
1772 // static | 1772 // static |
1773 CandidateWindowController* | 1773 CandidateWindowController* |
1774 CandidateWindowController::CreateCandidateWindowController() { | 1774 CandidateWindowController::CreateCandidateWindowController() { |
1775 return new CandidateWindowControllerImpl; | 1775 return new CandidateWindowControllerImpl; |
1776 } | 1776 } |
1777 | 1777 |
1778 } // namespace input_method | 1778 } // namespace input_method |
1779 } // namespace chromeos | 1779 } // namespace chromeos |
OLD | NEW |