platform_style.h 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. // Copyright 2015 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef UI_VIEWS_STYLE_PLATFORM_STYLE_H_
  5. #define UI_VIEWS_STYLE_PLATFORM_STYLE_H_
  6. #include <memory>
  7. #include "ui/views/controls/button/button.h"
  8. #include "ui/views/view.h"
  9. #include "ui/views/views_export.h"
  10. namespace gfx {
  11. class Range;
  12. } // namespace gfx
  13. namespace views {
  14. class ScrollBar;
  15. // Cross-platform API for providing platform-specific styling for toolkit-views.
  16. class VIEWS_EXPORT PlatformStyle {
  17. public:
  18. PlatformStyle() = delete;
  19. PlatformStyle(const PlatformStyle&) = delete;
  20. PlatformStyle& operator=(const PlatformStyle&) = delete;
  21. // Whether the ok button is in the leading position (left in LTR) in a
  22. // typical Cancel/OK button group.
  23. static const bool kIsOkButtonLeading;
  24. // Minimum size for platform-styled buttons.
  25. static const int kMinLabelButtonWidth;
  26. static const int kMinLabelButtonHeight;
  27. // Whether the default button for a dialog can be the Cancel button.
  28. static const bool kDialogDefaultButtonCanBeCancel;
  29. // Whether right clicking on text, selects the word under cursor.
  30. static const bool kSelectWordOnRightClick;
  31. // Whether right clicking inside an unfocused text view selects all the text.
  32. static const bool kSelectAllOnRightClickWhenUnfocused;
  33. // Whether the Space key clicks a button on key press or key release.
  34. static const Button::KeyClickAction kKeyClickActionOnSpace;
  35. // Whether the Return key clicks the focused control (on key press).
  36. // Otherwise, Return does nothing unless it is handled by an accelerator.
  37. static const bool kReturnClicksFocusedControl;
  38. // Whether cursor left and right can be used in a TableView to select and
  39. // resize columns and whether a focus ring should be shown around the active
  40. // cell.
  41. static const bool kTableViewSupportsKeyboardNavigationByCell;
  42. // Whether selecting a row in a TreeView selects the entire row or only the
  43. // label for that row.
  44. static const bool kTreeViewSelectionPaintsEntireRow;
  45. // Whether ripples should be used for visual feedback on control activation.
  46. static const bool kUseRipples;
  47. // Whether text fields should use a "drag" cursor when not actually
  48. // dragging but available to do so.
  49. static const bool kTextfieldUsesDragCursorWhenDraggable;
  50. // Whether controls in inactive widgets appear disabled.
  51. static const bool kInactiveWidgetControlsAppearDisabled;
  52. // Default setting at bubble creation time for whether arrow will be adjusted
  53. // for bubbles going off-screen to bring more bubble area into view.
  54. static const bool kAdjustBubbleIfOffscreen;
  55. // Default focus behavior on the platform.
  56. static const View::FocusBehavior kDefaultFocusBehavior;
  57. // Creates the default scrollbar for the given orientation.
  58. static std::unique_ptr<ScrollBar> CreateScrollBar(bool is_horizontal);
  59. // Called whenever a textfield edit fails. Gives visual/audio feedback about
  60. // the failed edit if platform-appropriate.
  61. static void OnTextfieldEditFailed();
  62. // When deleting backwards in |string| with the cursor at index
  63. // |cursor_position|, return the range of UTF-16 words to be deleted.
  64. // This is to support deleting entire graphemes instead of individual
  65. // characters when necessary on Mac, and code points made from surrogate
  66. // pairs on other platforms.
  67. static gfx::Range RangeToDeleteBackwards(const std::u16string& text,
  68. size_t cursor_position);
  69. };
  70. } // namespace views
  71. #endif // UI_VIEWS_STYLE_PLATFORM_STYLE_H_