Chromium Code Reviews| 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 #ifndef UI_VIEWS_CONTROLS_LABEL_H_ | 5 #ifndef UI_VIEWS_CONTROLS_LABEL_H_ |
| 6 #define UI_VIEWS_CONTROLS_LABEL_H_ | 6 #define UI_VIEWS_CONTROLS_LABEL_H_ |
| 7 | 7 |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/gtest_prod_util.h" | 9 #include "base/gtest_prod_util.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "ui/base/models/simple_menu_model.h" | 11 #include "ui/base/models/simple_menu_model.h" |
| 12 #include "ui/gfx/render_text.h" | 12 #include "ui/gfx/render_text.h" |
| 13 #include "ui/views/context_menu_controller.h" | 13 #include "ui/views/context_menu_controller.h" |
| 14 #include "ui/views/selection_controller_delegate.h" | 14 #include "ui/views/selection_controller_delegate.h" |
| 15 #include "ui/views/view.h" | 15 #include "ui/views/view.h" |
| 16 #include "ui/views/word_lookup_client.h" | |
| 16 | 17 |
| 17 namespace views { | 18 namespace views { |
| 18 class LabelSelectionTest; | 19 class LabelSelectionTest; |
| 19 class MenuRunner; | 20 class MenuRunner; |
| 20 class SelectionController; | 21 class SelectionController; |
| 21 | 22 |
| 22 // A view subclass that can display a string. | 23 // A view subclass that can display a string. |
| 23 class VIEWS_EXPORT Label : public View, | 24 class VIEWS_EXPORT Label : public View, |
| 24 public ContextMenuController, | 25 public ContextMenuController, |
| 26 public WordLookupClient, | |
|
msw
2017/01/20 16:45:32
nit: it'd be nice if we could use composition inst
karandeepb
2017/01/23 00:20:25
That may turn out to be a bit more verbose.
| |
| 25 public SelectionControllerDelegate, | 27 public SelectionControllerDelegate, |
| 26 public ui::SimpleMenuModel::Delegate { | 28 public ui::SimpleMenuModel::Delegate { |
| 27 public: | 29 public: |
| 28 // Internal class name. | 30 // Internal class name. |
| 29 static const char kViewClassName[]; | 31 static const char kViewClassName[]; |
| 30 | 32 |
| 31 // The padding for the focus border when rendering focused text. | 33 // The padding for the focus border when rendering focused text. |
| 32 static const int kFocusBorderPadding; | 34 static const int kFocusBorderPadding; |
| 33 | 35 |
| 34 Label(); | 36 Label(); |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 178 // View: | 180 // View: |
| 179 gfx::Insets GetInsets() const override; | 181 gfx::Insets GetInsets() const override; |
| 180 int GetBaseline() const override; | 182 int GetBaseline() const override; |
| 181 gfx::Size GetPreferredSize() const override; | 183 gfx::Size GetPreferredSize() const override; |
| 182 gfx::Size GetMinimumSize() const override; | 184 gfx::Size GetMinimumSize() const override; |
| 183 int GetHeightForWidth(int w) const override; | 185 int GetHeightForWidth(int w) const override; |
| 184 void Layout() override; | 186 void Layout() override; |
| 185 const char* GetClassName() const override; | 187 const char* GetClassName() const override; |
| 186 View* GetTooltipHandlerForPoint(const gfx::Point& point) override; | 188 View* GetTooltipHandlerForPoint(const gfx::Point& point) override; |
| 187 bool CanProcessEventsWithinSubtree() const override; | 189 bool CanProcessEventsWithinSubtree() const override; |
| 190 WordLookupClient* GetWordLookupClient() override; | |
| 188 void GetAccessibleNodeData(ui::AXNodeData* node_data) override; | 191 void GetAccessibleNodeData(ui::AXNodeData* node_data) override; |
| 189 bool GetTooltipText(const gfx::Point& p, | 192 bool GetTooltipText(const gfx::Point& p, |
| 190 base::string16* tooltip) const override; | 193 base::string16* tooltip) const override; |
| 191 void OnEnabledChanged() override; | 194 void OnEnabledChanged() override; |
| 192 | 195 |
| 193 protected: | 196 protected: |
| 194 // Create a single RenderText instance to actually be painted. | 197 // Create a single RenderText instance to actually be painted. |
| 195 virtual std::unique_ptr<gfx::RenderText> CreateRenderText( | 198 virtual std::unique_ptr<gfx::RenderText> CreateRenderText( |
| 196 const base::string16& text, | 199 const base::string16& text, |
| 197 gfx::HorizontalAlignment alignment, | 200 gfx::HorizontalAlignment alignment, |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 226 FRIEND_TEST_ALL_PREFIXES(LabelTest, EmptyLabel); | 229 FRIEND_TEST_ALL_PREFIXES(LabelTest, EmptyLabel); |
| 227 FRIEND_TEST_ALL_PREFIXES(LabelTest, FocusBounds); | 230 FRIEND_TEST_ALL_PREFIXES(LabelTest, FocusBounds); |
| 228 FRIEND_TEST_ALL_PREFIXES(LabelTest, MultiLineSizingWithElide); | 231 FRIEND_TEST_ALL_PREFIXES(LabelTest, MultiLineSizingWithElide); |
| 229 friend class LabelSelectionTest; | 232 friend class LabelSelectionTest; |
| 230 | 233 |
| 231 // ContextMenuController overrides: | 234 // ContextMenuController overrides: |
| 232 void ShowContextMenuForView(View* source, | 235 void ShowContextMenuForView(View* source, |
| 233 const gfx::Point& point, | 236 const gfx::Point& point, |
| 234 ui::MenuSourceType source_type) override; | 237 ui::MenuSourceType source_type) override; |
| 235 | 238 |
| 239 // WordLookupClient overrides: | |
| 240 bool GetDecoratedWordAtPoint(const gfx::Point& point, | |
| 241 gfx::DecoratedText* decorated_word, | |
| 242 gfx::Point* baseline_point) override; | |
| 243 | |
| 236 // SelectionControllerDelegate overrides: | 244 // SelectionControllerDelegate overrides: |
| 237 gfx::RenderText* GetRenderTextForSelectionController() override; | 245 gfx::RenderText* GetRenderTextForSelectionController() override; |
| 238 bool IsReadOnly() const override; | 246 bool IsReadOnly() const override; |
| 239 bool SupportsDrag() const override; | 247 bool SupportsDrag() const override; |
| 240 bool HasTextBeingDragged() const override; | 248 bool HasTextBeingDragged() const override; |
| 241 void SetTextBeingDragged(bool value) override; | 249 void SetTextBeingDragged(bool value) override; |
| 242 int GetViewHeight() const override; | 250 int GetViewHeight() const override; |
| 243 int GetViewWidth() const override; | 251 int GetViewWidth() const override; |
| 244 int GetDragSelectionDelay() const override; | 252 int GetDragSelectionDelay() const override; |
| 245 void OnBeforePointerAction() override; | 253 void OnBeforePointerAction() override; |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 343 // Context menu related members. | 351 // Context menu related members. |
| 344 ui::SimpleMenuModel context_menu_contents_; | 352 ui::SimpleMenuModel context_menu_contents_; |
| 345 std::unique_ptr<views::MenuRunner> context_menu_runner_; | 353 std::unique_ptr<views::MenuRunner> context_menu_runner_; |
| 346 | 354 |
| 347 DISALLOW_COPY_AND_ASSIGN(Label); | 355 DISALLOW_COPY_AND_ASSIGN(Label); |
| 348 }; | 356 }; |
| 349 | 357 |
| 350 } // namespace views | 358 } // namespace views |
| 351 | 359 |
| 352 #endif // UI_VIEWS_CONTROLS_LABEL_H_ | 360 #endif // UI_VIEWS_CONTROLS_LABEL_H_ |
| OLD | NEW |