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

Side by Side Diff: ui/views/examples/text_example.cc

Issue 11362070: Remove unused custom vertical text alignment in CanvasSkia. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync and rebase. Created 8 years, 1 month 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
« no previous file with comments | « ui/views/examples/text_example.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "ui/views/examples/text_example.h" 5 #include "ui/views/examples/text_example.h"
6 6
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "ui/base/resource/resource_bundle.h" 8 #include "ui/base/resource/resource_bundle.h"
9 #include "ui/gfx/canvas.h" 9 #include "ui/gfx/canvas.h"
10 #include "ui/views/controls/button/checkbox.h" 10 #include "ui/views/controls/button/checkbox.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 "Hide", 61 "Hide",
62 }; 62 };
63 63
64 const char* kHorizontalAligments[] = { 64 const char* kHorizontalAligments[] = {
65 "Default", 65 "Default",
66 "Left", 66 "Left",
67 "Center", 67 "Center",
68 "Right", 68 "Right",
69 }; 69 };
70 70
71 const char* kVerticalAlignments[] = {
72 "Default",
73 "Top",
74 "Middle",
75 "Bottom",
76 };
77
78 // Toggles bit |flag| on |flags| based on state of |checkbox|. 71 // Toggles bit |flag| on |flags| based on state of |checkbox|.
79 void SetFlagFromCheckbox(Checkbox* checkbox, int* flags, int flag) { 72 void SetFlagFromCheckbox(Checkbox* checkbox, int* flags, int flag) {
80 if (checkbox->checked()) 73 if (checkbox->checked())
81 *flags |= flag; 74 *flags |= flag;
82 else 75 else
83 *flags &= ~flag; 76 *flags &= ~flag;
84 } 77 }
85 78
86 } // namespace 79 } // namespace
87 80
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 0.1f, GridLayout::USE_PREF, 0, 0); 208 0.1f, GridLayout::USE_PREF, 0, 0);
216 for (int i = 0; i < kNumColumns - 1; i++) 209 for (int i = 0; i < kNumColumns - 1; i++)
217 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 210 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL,
218 0.1f, GridLayout::USE_PREF, 0, 0); 211 0.1f, GridLayout::USE_PREF, 0, 0);
219 column_set->AddPaddingColumn(0, 8); 212 column_set->AddPaddingColumn(0, 8);
220 213
221 h_align_cb_ = AddCombobox(layout, 214 h_align_cb_ = AddCombobox(layout,
222 "H-Align", 215 "H-Align",
223 kHorizontalAligments, 216 kHorizontalAligments,
224 arraysize(kHorizontalAligments)); 217 arraysize(kHorizontalAligments));
225 v_align_cb_ = AddCombobox(layout,
226 "V-Align",
227 kVerticalAlignments,
228 arraysize(kVerticalAlignments));
229 eliding_cb_ = AddCombobox(layout, 218 eliding_cb_ = AddCombobox(layout,
230 "Eliding", 219 "Eliding",
231 kElidingBehaviors, 220 kElidingBehaviors,
232 arraysize(kElidingBehaviors)); 221 arraysize(kElidingBehaviors));
233 prefix_cb_ = AddCombobox(layout, 222 prefix_cb_ = AddCombobox(layout,
234 "Prefix", 223 "Prefix",
235 kPrefixOptions, 224 kPrefixOptions,
236 arraysize(kPrefixOptions)); 225 arraysize(kPrefixOptions));
237 text_cb_ = AddCombobox(layout, 226 text_cb_ = AddCombobox(layout,
238 "Example Text", 227 "Example Text",
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 case 1: 275 case 1:
287 text_flags |= gfx::Canvas::TEXT_ALIGN_LEFT; 276 text_flags |= gfx::Canvas::TEXT_ALIGN_LEFT;
288 break; 277 break;
289 case 2: 278 case 2:
290 text_flags |= gfx::Canvas::TEXT_ALIGN_CENTER; 279 text_flags |= gfx::Canvas::TEXT_ALIGN_CENTER;
291 break; 280 break;
292 case 3: 281 case 3:
293 text_flags |= gfx::Canvas::TEXT_ALIGN_RIGHT; 282 text_flags |= gfx::Canvas::TEXT_ALIGN_RIGHT;
294 break; 283 break;
295 } 284 }
296 } else if (combobox == v_align_cb_) {
297 text_flags &= ~(gfx::Canvas::TEXT_VALIGN_TOP |
298 gfx::Canvas::TEXT_VALIGN_MIDDLE |
299 gfx::Canvas::TEXT_VALIGN_BOTTOM);
300 switch (combobox->selected_index()) {
301 case 0:
302 break;
303 case 1:
304 text_flags |= gfx::Canvas::TEXT_VALIGN_TOP;
305 break;
306 case 2:
307 text_flags |= gfx::Canvas::TEXT_VALIGN_MIDDLE;
308 break;
309 case 3:
310 text_flags |= gfx::Canvas::TEXT_VALIGN_BOTTOM;
311 break;
312 }
313 } else if (combobox == text_cb_) { 285 } else if (combobox == text_cb_) {
314 switch (combobox->selected_index()) { 286 switch (combobox->selected_index()) {
315 case 0: 287 case 0:
316 text_view_->set_text(ASCIIToUTF16(kShortText)); 288 text_view_->set_text(ASCIIToUTF16(kShortText));
317 break; 289 break;
318 case 1: 290 case 1:
319 text_view_->set_text(ASCIIToUTF16(kMediumText)); 291 text_view_->set_text(ASCIIToUTF16(kMediumText));
320 break; 292 break;
321 case 2: 293 case 2:
322 text_view_->set_text(ASCIIToUTF16(kLongText)); 294 text_view_->set_text(ASCIIToUTF16(kLongText));
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 text_flags |= gfx::Canvas::HIDE_PREFIX; 337 text_flags |= gfx::Canvas::HIDE_PREFIX;
366 break; 338 break;
367 } 339 }
368 } 340 }
369 text_view_->set_text_flags(text_flags); 341 text_view_->set_text_flags(text_flags);
370 text_view_->SchedulePaint(); 342 text_view_->SchedulePaint();
371 } 343 }
372 344
373 } // namespace examples 345 } // namespace examples
374 } // namespace views 346 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/examples/text_example.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698