OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ash/ime/candidate_window_view.h" | 5 #include "ash/ime/candidate_window_view.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "ash/ime/candidate_view.h" | 9 #include "ash/ime/candidate_view.h" |
10 #include "ash/ime/candidate_window_constants.h" | 10 #include "ash/ime/candidate_window_constants.h" |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 ui::NativeTheme::kColorId_WindowBackground), | 107 ui::NativeTheme::kColorId_WindowBackground), |
108 0x10))); | 108 0x10))); |
109 } | 109 } |
110 | 110 |
111 // Sets the text alignment. | 111 // Sets the text alignment. |
112 void SetAlignment(gfx::HorizontalAlignment alignment) { | 112 void SetAlignment(gfx::HorizontalAlignment alignment) { |
113 label_->SetHorizontalAlignment(alignment); | 113 label_->SetHorizontalAlignment(alignment); |
114 } | 114 } |
115 | 115 |
116 // Sets the displayed text. | 116 // Sets the displayed text. |
117 void SetText(const std::string& utf8_text) { | 117 void SetText(const base::string16& text) { |
118 label_->SetText(base::UTF8ToUTF16(utf8_text)); | 118 label_->SetText(text); |
119 } | 119 } |
120 | 120 |
121 // Sets the border thickness for top/bottom. | 121 // Sets the border thickness for top/bottom. |
122 void SetBorderFromPosition(BorderPosition position) { | 122 void SetBorderFromPosition(BorderPosition position) { |
123 SetBorder(views::Border::CreateSolidSidedBorder( | 123 SetBorder(views::Border::CreateSolidSidedBorder( |
124 (position == TOP) ? 1 : 0, | 124 (position == TOP) ? 1 : 0, |
125 0, | 125 0, |
126 (position == BOTTOM) ? 1 : 0, | 126 (position == BOTTOM) ? 1 : 0, |
127 0, | 127 0, |
128 GetNativeTheme()->GetSystemColor( | 128 GetNativeTheme()->GetSystemColor( |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 void CandidateWindowView::HidePreeditText() { | 218 void CandidateWindowView::HidePreeditText() { |
219 preedit_->SetVisible(false); | 219 preedit_->SetVisible(false); |
220 UpdateVisibility(); | 220 UpdateVisibility(); |
221 } | 221 } |
222 | 222 |
223 void CandidateWindowView::ShowPreeditText() { | 223 void CandidateWindowView::ShowPreeditText() { |
224 preedit_->SetVisible(true); | 224 preedit_->SetVisible(true); |
225 UpdateVisibility(); | 225 UpdateVisibility(); |
226 } | 226 } |
227 | 227 |
228 void CandidateWindowView::UpdatePreeditText(const std::string& utf8_text) { | 228 void CandidateWindowView::UpdatePreeditText(const base::string16& text) { |
229 preedit_->SetText(utf8_text); | 229 preedit_->SetText(text); |
230 } | 230 } |
231 | 231 |
232 void CandidateWindowView::ShowLookupTable() { | 232 void CandidateWindowView::ShowLookupTable() { |
233 candidate_area_->SetVisible(true); | 233 candidate_area_->SetVisible(true); |
234 auxiliary_text_->SetVisible(candidate_window_.is_auxiliary_text_visible()); | 234 auxiliary_text_->SetVisible(candidate_window_.is_auxiliary_text_visible()); |
235 UpdateVisibility(); | 235 UpdateVisibility(); |
236 } | 236 } |
237 | 237 |
238 void CandidateWindowView::UpdateCandidates( | 238 void CandidateWindowView::UpdateCandidates( |
239 const ui::CandidateWindow& new_candidate_window) { | 239 const ui::CandidateWindow& new_candidate_window) { |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 static_cast<size_t>(selected_candidate_index_in_page_) < | 328 static_cast<size_t>(selected_candidate_index_in_page_) < |
329 candidate_views_.size()) { | 329 candidate_views_.size()) { |
330 candidate_views_[selected_candidate_index_in_page_]->SetState( | 330 candidate_views_[selected_candidate_index_in_page_]->SetState( |
331 views::Button::STATE_NORMAL); | 331 views::Button::STATE_NORMAL); |
332 selected_candidate_index_in_page_ = -1; | 332 selected_candidate_index_in_page_ = -1; |
333 } | 333 } |
334 } | 334 } |
335 | 335 |
336 // Updates auxiliary text | 336 // Updates auxiliary text |
337 auxiliary_text_->SetVisible(candidate_window_.is_auxiliary_text_visible()); | 337 auxiliary_text_->SetVisible(candidate_window_.is_auxiliary_text_visible()); |
338 auxiliary_text_->SetText(candidate_window_.auxiliary_text()); | 338 auxiliary_text_->SetText(base::UTF8ToUTF16( |
| 339 candidate_window_.auxiliary_text())); |
339 } | 340 } |
340 | 341 |
341 void CandidateWindowView::SetCursorBounds(const gfx::Rect& cursor_bounds, | 342 void CandidateWindowView::SetCursorBounds(const gfx::Rect& cursor_bounds, |
342 const gfx::Rect& composition_head) { | 343 const gfx::Rect& composition_head) { |
343 if (candidate_window_.show_window_at_composition()) | 344 if (candidate_window_.show_window_at_composition()) |
344 SetAnchorRect(composition_head); | 345 SetAnchorRect(composition_head); |
345 else | 346 else |
346 SetAnchorRect(cursor_bounds); | 347 SetAnchorRect(cursor_bounds); |
347 } | 348 } |
348 | 349 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 for (size_t i = 0; i < candidate_views_.size(); ++i) { | 398 for (size_t i = 0; i < candidate_views_.size(); ++i) { |
398 if (sender == candidate_views_[i]) { | 399 if (sender == candidate_views_[i]) { |
399 FOR_EACH_OBSERVER(Observer, observers_, OnCandidateCommitted(i)); | 400 FOR_EACH_OBSERVER(Observer, observers_, OnCandidateCommitted(i)); |
400 return; | 401 return; |
401 } | 402 } |
402 } | 403 } |
403 } | 404 } |
404 | 405 |
405 } // namespace ime | 406 } // namespace ime |
406 } // namespace ash | 407 } // namespace ash |
OLD | NEW |