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

Side by Side Diff: ui/views/controls/label.cc

Issue 2164483006: [MacViews] Implemented text context menu (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 3 years, 10 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
« no previous file with comments | « ui/views/controls/label.h ('k') | ui/views/controls/textfield/textfield.h » ('j') | 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/controls/label.h" 5 #include "ui/views/controls/label.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 634
635 context_menu_runner_.reset( 635 context_menu_runner_.reset(
636 new MenuRunner(&context_menu_contents_, MenuRunner::HAS_MNEMONICS | 636 new MenuRunner(&context_menu_contents_, MenuRunner::HAS_MNEMONICS |
637 MenuRunner::CONTEXT_MENU | 637 MenuRunner::CONTEXT_MENU |
638 MenuRunner::ASYNC)); 638 MenuRunner::ASYNC));
639 ignore_result(context_menu_runner_->RunMenuAt( 639 ignore_result(context_menu_runner_->RunMenuAt(
640 GetWidget(), nullptr, gfx::Rect(point, gfx::Size()), MENU_ANCHOR_TOPLEFT, 640 GetWidget(), nullptr, gfx::Rect(point, gfx::Size()), MENU_ANCHOR_TOPLEFT,
641 source_type)); 641 source_type));
642 } 642 }
643 643
644 bool Label::GetDecoratedWordAtPoint(const gfx::Point& point, 644 bool Label::GetDecoratedWordAndBaselineAtPoint(
645 gfx::DecoratedText* decorated_word, 645 const gfx::Point& point,
646 gfx::Point* baseline_point) { 646 gfx::DecoratedText* decorated_word,
647 gfx::Point* baseline_point) {
647 gfx::RenderText* render_text = GetRenderTextForSelectionController(); 648 gfx::RenderText* render_text = GetRenderTextForSelectionController();
648 return render_text 649 return render_text
649 ? render_text->GetDecoratedWordAtPoint(point, decorated_word, 650 ? render_text->GetDecoratedWordAndBaselineAtPoint(
650 baseline_point) 651 point, decorated_word, baseline_point)
651 : false; 652 : false;
652 } 653 }
653 654
655 bool Label::GetDecoratedTextAndBaselineFromSelection(
656 gfx::DecoratedText* decorated_text,
657 gfx::Point* baseline_point) {
658 if (!selectable())
659 return false;
660
661 gfx::RenderText* render_text = GetRenderTextForSelectionController();
662 if (!render_text)
663 return false;
664
665 return render_text->GetDecoratedTextAndBaselineForRange(
666 render_text->selection(), decorated_text, baseline_point);
667 }
668
654 gfx::RenderText* Label::GetRenderTextForSelectionController() { 669 gfx::RenderText* Label::GetRenderTextForSelectionController() {
655 return const_cast<gfx::RenderText*>( 670 return const_cast<gfx::RenderText*>(
656 static_cast<const Label*>(this)->GetRenderTextForSelectionController()); 671 static_cast<const Label*>(this)->GetRenderTextForSelectionController());
657 } 672 }
658 673
659 bool Label::IsReadOnly() const { 674 bool Label::IsReadOnly() const {
660 return true; 675 return true;
661 } 676 }
662 677
663 bool Label::SupportsDrag() const { 678 bool Label::SupportsDrag() const {
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
1032 .WriteText(GetSelectedText()); 1047 .WriteText(GetSelectedText());
1033 } 1048 }
1034 1049
1035 void Label::BuildContextMenuContents() { 1050 void Label::BuildContextMenuContents() {
1036 context_menu_contents_.AddItemWithStringId(IDS_APP_COPY, IDS_APP_COPY); 1051 context_menu_contents_.AddItemWithStringId(IDS_APP_COPY, IDS_APP_COPY);
1037 context_menu_contents_.AddItemWithStringId(IDS_APP_SELECT_ALL, 1052 context_menu_contents_.AddItemWithStringId(IDS_APP_SELECT_ALL,
1038 IDS_APP_SELECT_ALL); 1053 IDS_APP_SELECT_ALL);
1039 } 1054 }
1040 1055
1041 } // namespace views 1056 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/label.h ('k') | ui/views/controls/textfield/textfield.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698