Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(118)

Side by Side Diff: ash/system/ime/tray_ime.cc

Issue 10008043: Allow non-radio button properties in uber tray. Simplified chinese will use it. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rewrite ActivateIMEProperty Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "ash/system/ime/tray_ime.h" 5 #include "ash/system/ime/tray_ime.h"
6 6
7 #include <utility>
7 #include <vector> 8 #include <vector>
8 9
9 #include "ash/shell.h" 10 #include "ash/shell.h"
10 #include "ash/system/tray/system_tray.h" 11 #include "ash/system/tray/system_tray.h"
11 #include "ash/system/tray/system_tray_delegate.h" 12 #include "ash/system/tray/system_tray_delegate.h"
12 #include "ash/system/tray/tray_constants.h" 13 #include "ash/system/tray/tray_constants.h"
13 #include "ash/system/tray/tray_item_more.h" 14 #include "ash/system/tray/tray_item_more.h"
14 #include "ash/system/tray/tray_views.h" 15 #include "ash/system/tray/tray_views.h"
15 #include "base/logging.h" 16 #include "base/logging.h"
16 #include "base/utf_string_conversions.h" 17 #include "base/utf_string_conversions.h"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 property_map_.clear(); 116 property_map_.clear();
116 views::View* properties = new views::View; 117 views::View* properties = new views::View;
117 properties->SetLayoutManager(new views::BoxLayout( 118 properties->SetLayoutManager(new views::BoxLayout(
118 views::BoxLayout::kVertical, 0, 0, 1)); 119 views::BoxLayout::kVertical, 0, 0, 1));
119 for (size_t i = 0; i < property_list.size(); i++) { 120 for (size_t i = 0; i < property_list.size(); i++) {
120 HoverHighlightView* container = new HoverHighlightView(this); 121 HoverHighlightView* container = new HoverHighlightView(this);
121 container->AddLabel( 122 container->AddLabel(
122 property_list[i].name, 123 property_list[i].name,
123 property_list[i].selected ? gfx::Font::BOLD : gfx::Font::NORMAL); 124 property_list[i].selected ? gfx::Font::BOLD : gfx::Font::NORMAL);
124 properties->AddChildView(container); 125 properties->AddChildView(container);
125 property_map_[container] = property_list[i].key; 126 property_map_[container] =
127 std::make_pair(property_list[i].key, property_list[i].is_selection);
126 } 128 }
127 properties->set_border(views::Border::CreateSolidSidedBorder( 129 properties->set_border(views::Border::CreateSolidSidedBorder(
128 0, 0, 1, 0, kBorderLightColor)); 130 0, 0, 1, 0, kBorderLightColor));
129 AddChildView(properties); 131 AddChildView(properties);
130 } 132 }
131 133
132 void AppendSettings() { 134 void AppendSettings() {
133 HoverHighlightView* container = new HoverHighlightView(this); 135 HoverHighlightView* container = new HoverHighlightView(this);
134 container->AddLabel(ui::ResourceBundle::GetSharedInstance(). 136 container->AddLabel(ui::ResourceBundle::GetSharedInstance().
135 GetLocalizedString(IDS_ASH_STATUS_TRAY_IME_SETTINGS), 137 GetLocalizedString(IDS_ASH_STATUS_TRAY_IME_SETTINGS),
(...skipping 10 matching lines...) Expand all
146 } else if (sender == settings_) { 148 } else if (sender == settings_) {
147 delegate->ShowIMESettings(); 149 delegate->ShowIMESettings();
148 } else { 150 } else {
149 std::map<views::View*, std::string>::const_iterator ime_find; 151 std::map<views::View*, std::string>::const_iterator ime_find;
150 ime_find = ime_map_.find(sender); 152 ime_find = ime_map_.find(sender);
151 if (ime_find != ime_map_.end()) { 153 if (ime_find != ime_map_.end()) {
152 std::string ime_id = ime_find->second; 154 std::string ime_id = ime_find->second;
153 delegate->SwitchIME(ime_id); 155 delegate->SwitchIME(ime_id);
154 GetWidget()->Close(); 156 GetWidget()->Close();
155 } else { 157 } else {
156 std::map<views::View*, std::string>::const_iterator prop_find; 158 std::map<views::View*, std::pair<std::string, bool> >::const_iterator
157 prop_find = property_map_.find(sender); 159 prop_find = property_map_.find(sender);
158 if (prop_find != property_map_.end()) { 160 if (prop_find != property_map_.end()) {
159 std::string key = prop_find->second; 161 const std::pair<std::string, bool>& prop = prop_find->second;
160 delegate->ActivateIMEProperty(key); 162 delegate->ActivateIMEProperty(prop.first, prop.second);
161 GetWidget()->Close(); 163 GetWidget()->Close();
162 } 164 }
163 } 165 }
164 } 166 }
165 } 167 }
166 168
167 user::LoginStatus login_; 169 user::LoginStatus login_;
168 170
169 std::map<views::View*, std::string> ime_map_; 171 std::map<views::View*, std::string> ime_map_;
170 std::map<views::View*, std::string> property_map_; 172 std::map<views::View*, std::pair<std::string, bool> > property_map_;
sky 2012/04/09 15:18:56 Document what the pair is.
Jun Mukai 2012/04/10 02:13:46 Use IMEPropertyInfo struct instead.
171 views::View* header_; 173 views::View* header_;
172 views::View* settings_; 174 views::View* settings_;
173 175
174 DISALLOW_COPY_AND_ASSIGN(IMEDetailedView); 176 DISALLOW_COPY_AND_ASSIGN(IMEDetailedView);
175 }; 177 };
176 178
177 } // namespace tray 179 } // namespace tray
178 180
179 TrayIME::TrayIME() { 181 TrayIME::TrayIME() {
180 } 182 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 UpdateTrayLabel(current, list.size()); 231 UpdateTrayLabel(current, list.size());
230 232
231 if (default_.get()) 233 if (default_.get())
232 default_->UpdateLabel(current); 234 default_->UpdateLabel(current);
233 if (detailed_.get()) 235 if (detailed_.get())
234 detailed_->Update(list, property_list); 236 detailed_->Update(list, property_list);
235 } 237 }
236 238
237 } // namespace internal 239 } // namespace internal
238 } // namespace ash 240 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698