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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 const SkColor kInfolistTitleBackgroundColor = SkColorSetRGB(0xdd, 0xdd, 0xdd); | 59 const SkColor kInfolistTitleBackgroundColor = SkColorSetRGB(0xdd, 0xdd, 0xdd); |
60 | 60 |
61 // We'll use a bigger font size, so Chinese characters are more readable | 61 // We'll use a bigger font size, so Chinese characters are more readable |
62 // in the candidate window. | 62 // in the candidate window. |
63 #if defined(CROS_FONTS_USING_BCI) | 63 #if defined(CROS_FONTS_USING_BCI) |
64 const int kFontSizeDelta = 1; | 64 const int kFontSizeDelta = 1; |
65 #else | 65 #else |
66 const int kFontSizeDelta = 2; | 66 const int kFontSizeDelta = 2; |
67 #endif | 67 #endif |
68 | 68 |
| 69 // Currently the infolist window only supports Japanese font. |
| 70 #if defined(GOOGLE_CHROME_BUILD) |
| 71 const char kJapaneseFontName[] = "MotoyaG04Gothic"; |
| 72 #else |
| 73 const char kJapaneseFontName[] = "IPAPGothic"; |
| 74 #endif |
| 75 |
69 // The minimum width of candidate labels in the vertical candidate | 76 // The minimum width of candidate labels in the vertical candidate |
70 // window. We use this value to prevent the candidate window from being | 77 // window. We use this value to prevent the candidate window from being |
71 // too narrow when all candidates are short. | 78 // too narrow when all candidates are short. |
72 const int kMinCandidateLabelWidth = 100; | 79 const int kMinCandidateLabelWidth = 100; |
73 // The maximum width of candidate labels in the vertical candidate | 80 // The maximum width of candidate labels in the vertical candidate |
74 // window. We use this value to prevent the candidate window from being | 81 // window. We use this value to prevent the candidate window from being |
75 // too wide when one of candidates are long. | 82 // too wide when one of candidates are long. |
76 const int kMaxCandidateLabelWidth = 500; | 83 const int kMaxCandidateLabelWidth = 500; |
77 // The minimum width of preedit area. We use this value to prevent the | 84 // The minimum width of preedit area. We use this value to prevent the |
78 // candidate window from being too narrow when candidate lists are not shown. | 85 // candidate window from being too narrow when candidate lists are not shown. |
(...skipping 1204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1283 InfolistWindowView* parent_infolist_window) | 1290 InfolistWindowView* parent_infolist_window) |
1284 : parent_infolist_window_(parent_infolist_window), | 1291 : parent_infolist_window_(parent_infolist_window), |
1285 title_label_(NULL), | 1292 title_label_(NULL), |
1286 description_label_(NULL), | 1293 description_label_(NULL), |
1287 selected_(false) { | 1294 selected_(false) { |
1288 } | 1295 } |
1289 | 1296 |
1290 void InfolistView::Init() { | 1297 void InfolistView::Init() { |
1291 title_label_ = new views::Label; | 1298 title_label_ = new views::Label; |
1292 title_label_->SetPosition(gfx::Point(0, 0)); | 1299 title_label_->SetPosition(gfx::Point(0, 0)); |
1293 title_label_->SetFont( | 1300 title_label_->SetFont(parent_infolist_window_->GetTitleFont()); |
1294 title_label_->font().DeriveFont(kFontSizeDelta + 2)); | |
1295 title_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 1301 title_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); |
1296 title_label_->set_border( | 1302 title_label_->set_border( |
1297 views::Border::CreateEmptyBorder(4, 7, 2, 4)); | 1303 views::Border::CreateEmptyBorder(4, 7, 2, 4)); |
1298 | 1304 |
1299 description_label_ = new views::Label; | 1305 description_label_ = new views::Label; |
1300 description_label_->SetPosition(gfx::Point(0, 0)); | 1306 description_label_->SetPosition(gfx::Point(0, 0)); |
1301 description_label_->SetFont( | 1307 description_label_->SetFont(parent_infolist_window_->GetDescriptionFont()); |
1302 description_label_->font().DeriveFont(kFontSizeDelta - 2)); | |
1303 description_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 1308 description_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); |
1304 description_label_->SetMultiLine(true); | 1309 description_label_->SetMultiLine(true); |
1305 description_label_->set_border( | 1310 description_label_->set_border( |
1306 views::Border::CreateEmptyBorder(2, 17, 4, 4)); | 1311 views::Border::CreateEmptyBorder(2, 17, 4, 4)); |
1307 AddChildView(title_label_); | 1312 AddChildView(title_label_); |
1308 AddChildView(description_label_); | 1313 AddChildView(description_label_); |
1309 UpdateLabelBackgroundColors(); | 1314 UpdateLabelBackgroundColors(); |
1310 } | 1315 } |
1311 | 1316 |
1312 void InfolistView::SetTitleAndDescriptionText(const string16& title, | 1317 void InfolistView::SetTitleAndDescriptionText(const string16& title, |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1360 title_label_->SetBackgroundColor(color); | 1365 title_label_->SetBackgroundColor(color); |
1361 description_label_->SetBackgroundColor(color); | 1366 description_label_->SetBackgroundColor(color); |
1362 } | 1367 } |
1363 | 1368 |
1364 InfolistWindowView::InfolistWindowView(views::Widget* parent_frame, | 1369 InfolistWindowView::InfolistWindowView(views::Widget* parent_frame, |
1365 views::Widget* candidate_window_frame) | 1370 views::Widget* candidate_window_frame) |
1366 : usages_(new mozc::commands::InformationList), | 1371 : usages_(new mozc::commands::InformationList), |
1367 parent_frame_(parent_frame), | 1372 parent_frame_(parent_frame), |
1368 candidate_window_frame_(candidate_window_frame), | 1373 candidate_window_frame_(candidate_window_frame), |
1369 infolist_area_(NULL), | 1374 infolist_area_(NULL), |
1370 visible_(false) { | 1375 visible_(false), |
| 1376 title_font_(new gfx::Font(kJapaneseFontName, kFontSizeDelta + 15)), |
| 1377 description_font_(new gfx::Font(kJapaneseFontName, kFontSizeDelta + 11)) { |
1371 } | 1378 } |
1372 | 1379 |
1373 InfolistWindowView::~InfolistWindowView() { | 1380 InfolistWindowView::~InfolistWindowView() { |
1374 if (infolist_area_ != NULL) { | 1381 if (infolist_area_ != NULL) { |
1375 infolist_area_->RemoveAllChildViews(false); | 1382 infolist_area_->RemoveAllChildViews(false); |
1376 } | 1383 } |
1377 | 1384 |
1378 for (size_t i = 0; i < infolist_views_.size(); ++i) { | 1385 for (size_t i = 0; i < infolist_views_.size(); ++i) { |
1379 delete infolist_views_[i]; | 1386 delete infolist_views_[i]; |
1380 } | 1387 } |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1550 } | 1557 } |
1551 | 1558 |
1552 void InfolistWindowView::VisibilityChanged(View* starting_from, | 1559 void InfolistWindowView::VisibilityChanged(View* starting_from, |
1553 bool is_visible) { | 1560 bool is_visible) { |
1554 if (is_visible) { | 1561 if (is_visible) { |
1555 // If the visibility of candidate window is changed, | 1562 // If the visibility of candidate window is changed, |
1556 // we should move the frame to the right position. | 1563 // we should move the frame to the right position. |
1557 ResizeAndMoveParentFrame(); | 1564 ResizeAndMoveParentFrame(); |
1558 } | 1565 } |
1559 } | 1566 } |
| 1567 |
1560 void InfolistWindowView::OnBoundsChanged(const gfx::Rect& previous_bounds) { | 1568 void InfolistWindowView::OnBoundsChanged(const gfx::Rect& previous_bounds) { |
1561 View::OnBoundsChanged(previous_bounds); | 1569 View::OnBoundsChanged(previous_bounds); |
1562 ResizeAndMoveParentFrame(); | 1570 ResizeAndMoveParentFrame(); |
1563 } | 1571 } |
1564 | 1572 |
| 1573 gfx::Font InfolistWindowView::GetTitleFont() const { |
| 1574 return *title_font_.get(); |
| 1575 } |
| 1576 |
| 1577 gfx::Font InfolistWindowView::GetDescriptionFont() const { |
| 1578 return *description_font_.get(); |
| 1579 } |
1565 | 1580 |
1566 bool CandidateWindowControllerImpl::Init() { | 1581 bool CandidateWindowControllerImpl::Init() { |
1567 // Create the candidate window view. | 1582 // Create the candidate window view. |
1568 CreateView(); | 1583 CreateView(); |
1569 | 1584 |
1570 // The observer should be added before Connect() so we can capture the | 1585 // The observer should be added before Connect() so we can capture the |
1571 // initial connection change. | 1586 // initial connection change. |
1572 ibus_ui_controller_->AddObserver(this); | 1587 ibus_ui_controller_->AddObserver(this); |
1573 ibus_ui_controller_->Connect(); | 1588 ibus_ui_controller_->Connect(); |
1574 return true; | 1589 return true; |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1755 } | 1770 } |
1756 | 1771 |
1757 // static | 1772 // static |
1758 CandidateWindowController* | 1773 CandidateWindowController* |
1759 CandidateWindowController::CreateCandidateWindowController() { | 1774 CandidateWindowController::CreateCandidateWindowController() { |
1760 return new CandidateWindowControllerImpl; | 1775 return new CandidateWindowControllerImpl; |
1761 } | 1776 } |
1762 | 1777 |
1763 } // namespace input_method | 1778 } // namespace input_method |
1764 } // namespace chromeos | 1779 } // namespace chromeos |
OLD | NEW |