OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 VIEWS_VIEW_H_ | 5 #ifndef VIEWS_VIEW_H_ |
6 #define VIEWS_VIEW_H_ | 6 #define VIEWS_VIEW_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 | 10 |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 // TO BE MOVED --------------------------------------------------------------- | 146 // TO BE MOVED --------------------------------------------------------------- |
147 // TODO(beng): These methods are to be moved to other files/classes. | 147 // TODO(beng): These methods are to be moved to other files/classes. |
148 | 148 |
149 // TODO(beng): delete | 149 // TODO(beng): delete |
150 // Set whether this view is hottracked. A disabled view cannot be hottracked. | 150 // Set whether this view is hottracked. A disabled view cannot be hottracked. |
151 // If flag differs from the current value, SchedulePaint is invoked. | 151 // If flag differs from the current value, SchedulePaint is invoked. |
152 virtual void SetHotTracked(bool flag); | 152 virtual void SetHotTracked(bool flag); |
153 | 153 |
154 // TODO(beng): delete | 154 // TODO(beng): delete |
155 // Returns whether the view is hot-tracked. | 155 // Returns whether the view is hot-tracked. |
156 virtual bool IsHotTracked() const { return false; } | 156 virtual bool IsHotTracked() const; |
157 | 157 |
158 // FATE TBD ------------------------------------------------------------------ | 158 // FATE TBD ------------------------------------------------------------------ |
159 // TODO(beng): Figure out what these methods are for and delete them. | 159 // TODO(beng): Figure out what these methods are for and delete them. |
160 | 160 |
161 // TODO(beng): this one isn't even google3-style. wth. | 161 // TODO(beng): this one isn't even google3-style. wth. |
162 virtual Widget* child_widget() { return NULL; } | 162 virtual Widget* child_widget(); |
163 | 163 |
164 // Creation and lifetime ----------------------------------------------------- | 164 // Creation and lifetime ----------------------------------------------------- |
165 | 165 |
166 View(); | 166 View(); |
167 virtual ~View(); | 167 virtual ~View(); |
168 | 168 |
169 // Set whether this view is owned by its parent. A view that is owned by its | 169 // Set whether this view is owned by its parent. A view that is owned by its |
170 // parent is automatically deleted when the parent is deleted. The default is | 170 // parent is automatically deleted when the parent is deleted. The default is |
171 // true. Set to false if the view is owned by another object and should not | 171 // true. Set to false if the view is owned by another object and should not |
172 // be deleted by its parent. | 172 // be deleted by its parent. |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 // Return the height necessary to display this view with the provided width. | 301 // Return the height necessary to display this view with the provided width. |
302 // View's implementation returns the value from getPreferredSize.cy. | 302 // View's implementation returns the value from getPreferredSize.cy. |
303 // Override if your View's preferred height depends upon the width (such | 303 // Override if your View's preferred height depends upon the width (such |
304 // as with Labels). | 304 // as with Labels). |
305 virtual int GetHeightForWidth(int w); | 305 virtual int GetHeightForWidth(int w); |
306 | 306 |
307 // Set whether the receiving view is visible. Painting is scheduled as needed | 307 // Set whether the receiving view is visible. Painting is scheduled as needed |
308 virtual void SetVisible(bool flag); | 308 virtual void SetVisible(bool flag); |
309 | 309 |
310 // Return whether a view is visible | 310 // Return whether a view is visible |
311 virtual bool IsVisible() const { return is_visible_; } | 311 virtual bool IsVisible() const; |
312 | 312 |
313 // Return whether a view and its ancestors are visible. Returns true if the | 313 // Return whether a view and its ancestors are visible. Returns true if the |
314 // path from this view to the root view is visible. | 314 // path from this view to the root view is visible. |
315 virtual bool IsVisibleInRootView() const; | 315 virtual bool IsVisibleInRootView() const; |
316 | 316 |
317 // Set whether this view is enabled. A disabled view does not receive keyboard | 317 // Set whether this view is enabled. A disabled view does not receive keyboard |
318 // or mouse inputs. If flag differs from the current value, SchedulePaint is | 318 // or mouse inputs. If flag differs from the current value, SchedulePaint is |
319 // invoked. | 319 // invoked. |
320 virtual void SetEnabled(bool flag); | 320 virtual void SetEnabled(bool flag); |
321 | 321 |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 // Groups are currently used to implement radio button mutual exclusion. | 451 // Groups are currently used to implement radio button mutual exclusion. |
452 // The group id is immutable once it's set. | 452 // The group id is immutable once it's set. |
453 void SetGroup(int gid); | 453 void SetGroup(int gid); |
454 // Returns the group id of the view, or -1 if the id is not set yet. | 454 // Returns the group id of the view, or -1 if the id is not set yet. |
455 int GetGroup() const; | 455 int GetGroup() const; |
456 | 456 |
457 // If this returns true, the views from the same group can each be focused | 457 // If this returns true, the views from the same group can each be focused |
458 // when moving focus with the Tab/Shift-Tab key. If this returns false, | 458 // when moving focus with the Tab/Shift-Tab key. If this returns false, |
459 // only the selected view from the group (obtained with | 459 // only the selected view from the group (obtained with |
460 // GetSelectedViewForGroup()) is focused. | 460 // GetSelectedViewForGroup()) is focused. |
461 virtual bool IsGroupFocusTraversable() const { return true; } | 461 virtual bool IsGroupFocusTraversable() const; |
462 | 462 |
463 // Fills the provided vector with all the available views which belong to the | 463 // Fills the provided vector with all the available views which belong to the |
464 // provided group. | 464 // provided group. |
465 void GetViewsWithGroup(int group_id, std::vector<View*>* out); | 465 void GetViewsWithGroup(int group_id, std::vector<View*>* out); |
466 | 466 |
467 // Return the View that is currently selected in the specified group. | 467 // Return the View that is currently selected in the specified group. |
468 // The default implementation simply returns the first View found for that | 468 // The default implementation simply returns the first View found for that |
469 // group. | 469 // group. |
470 virtual View* GetSelectedViewForGroup(int group_id); | 470 virtual View* GetSelectedViewForGroup(int group_id); |
471 | 471 |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
685 // Removes the specified accelerator for this view. | 685 // Removes the specified accelerator for this view. |
686 virtual void RemoveAccelerator(const Accelerator& accelerator); | 686 virtual void RemoveAccelerator(const Accelerator& accelerator); |
687 | 687 |
688 // Removes all the keyboard accelerators for this view. | 688 // Removes all the keyboard accelerators for this view. |
689 virtual void ResetAccelerators(); | 689 virtual void ResetAccelerators(); |
690 | 690 |
691 // TODO(beng): Move to an AcceleratorTarget override section. | 691 // TODO(beng): Move to an AcceleratorTarget override section. |
692 // Called when a keyboard accelerator is pressed. | 692 // Called when a keyboard accelerator is pressed. |
693 // Derived classes should implement desired behavior and return true if they | 693 // Derived classes should implement desired behavior and return true if they |
694 // handled the accelerator. | 694 // handled the accelerator. |
695 virtual bool AcceleratorPressed(const Accelerator& accelerator) { | 695 virtual bool AcceleratorPressed(const Accelerator& accelerator); |
696 return false; | |
697 } | |
698 | 696 |
699 // Focus --------------------------------------------------------------------- | 697 // Focus --------------------------------------------------------------------- |
700 | 698 |
701 // Returns whether this view currently has the focus. | 699 // Returns whether this view currently has the focus. |
702 virtual bool HasFocus(); | 700 virtual bool HasFocus(); |
703 | 701 |
704 // Returns the view that should be selected next when pressing Tab. | 702 // Returns the view that should be selected next when pressing Tab. |
705 View* GetNextFocusableView(); | 703 View* GetNextFocusableView(); |
706 const View* GetNextFocusableView() const; | 704 const View* GetNextFocusableView() const; |
707 | 705 |
(...skipping 16 matching lines...) Expand all Loading... |
724 // view. See also IsFocusable. | 722 // view. See also IsFocusable. |
725 bool IsFocusableInRootView() const; | 723 bool IsFocusableInRootView() const; |
726 | 724 |
727 // Return whether this view is focusable when the user requires full keyboard | 725 // Return whether this view is focusable when the user requires full keyboard |
728 // access, even though it may not be normally focusable. | 726 // access, even though it may not be normally focusable. |
729 bool IsAccessibilityFocusableInRootView() const; | 727 bool IsAccessibilityFocusableInRootView() const; |
730 | 728 |
731 // Set whether this view can be made focusable if the user requires | 729 // Set whether this view can be made focusable if the user requires |
732 // full keyboard access, even though it's not normally focusable. | 730 // full keyboard access, even though it's not normally focusable. |
733 // Note that this is false by default. | 731 // Note that this is false by default. |
734 virtual void set_accessibility_focusable(bool accessibility_focusable) { | 732 virtual void set_accessibility_focusable(bool accessibility_focusable); |
735 accessibility_focusable_ = accessibility_focusable; | |
736 } | |
737 | 733 |
738 // Convenience method to retrieve the FocusManager associated with the | 734 // Convenience method to retrieve the FocusManager associated with the |
739 // Widget that contains this view. This can return NULL if this view is not | 735 // Widget that contains this view. This can return NULL if this view is not |
740 // part of a view hierarchy with a Widget. | 736 // part of a view hierarchy with a Widget. |
741 virtual FocusManager* GetFocusManager(); | 737 virtual FocusManager* GetFocusManager(); |
742 | 738 |
743 // Request the keyboard focus. The receiving view will become the | 739 // Request the keyboard focus. The receiving view will become the |
744 // focused view. | 740 // focused view. |
745 virtual void RequestFocus(); | 741 virtual void RequestFocus(); |
746 | 742 |
747 // Invoked when a view is about to be requested for focus due to the focus | 743 // Invoked when a view is about to be requested for focus due to the focus |
748 // traversal. Reverse is this request was generated going backward | 744 // traversal. Reverse is this request was generated going backward |
749 // (Shift-Tab). | 745 // (Shift-Tab). |
750 virtual void AboutToRequestFocusFromTabTraversal(bool reverse) { } | 746 virtual void AboutToRequestFocusFromTabTraversal(bool reverse) { } |
751 | 747 |
752 // Invoked when a key is pressed before the key event is processed (and | 748 // Invoked when a key is pressed before the key event is processed (and |
753 // potentially eaten) by the focus manager for tab traversal, accelerators and | 749 // potentially eaten) by the focus manager for tab traversal, accelerators and |
754 // other focus related actions. | 750 // other focus related actions. |
755 // The default implementation returns false, ensuring that tab traversal and | 751 // The default implementation returns false, ensuring that tab traversal and |
756 // accelerators processing is performed. | 752 // accelerators processing is performed. |
757 // Subclasses should return true if they want to process the key event and not | 753 // Subclasses should return true if they want to process the key event and not |
758 // have it processed as an accelerator (if any) or as a tab traversal (if the | 754 // have it processed as an accelerator (if any) or as a tab traversal (if the |
759 // key event is for the TAB key). In that case, OnKeyPressed will | 755 // key event is for the TAB key). In that case, OnKeyPressed will |
760 // subsequently be invoked for that event. | 756 // subsequently be invoked for that event. |
761 virtual bool SkipDefaultKeyEventProcessing(const KeyEvent& e) { | 757 virtual bool SkipDefaultKeyEventProcessing(const KeyEvent& e); |
762 return false; | |
763 } | |
764 | 758 |
765 // Subclasses that contain traversable children that are not directly | 759 // Subclasses that contain traversable children that are not directly |
766 // accessible through the children hierarchy should return the associated | 760 // accessible through the children hierarchy should return the associated |
767 // FocusTraversable for the focus traversal to work properly. | 761 // FocusTraversable for the focus traversal to work properly. |
768 virtual FocusTraversable* GetFocusTraversable() { return NULL; } | 762 virtual FocusTraversable* GetFocusTraversable(); |
769 | 763 |
770 // Subclasses that can act as a "pane" must implement their own | 764 // Subclasses that can act as a "pane" must implement their own |
771 // FocusTraversable to keep the focus trapped within the pane. | 765 // FocusTraversable to keep the focus trapped within the pane. |
772 // If this method returns an object, any view that's a direct or | 766 // If this method returns an object, any view that's a direct or |
773 // indirect child of this view will always use this FocusTraversable | 767 // indirect child of this view will always use this FocusTraversable |
774 // rather than the one from the widget. | 768 // rather than the one from the widget. |
775 virtual FocusTraversable* GetPaneFocusTraversable() { return NULL; } | 769 virtual FocusTraversable* GetPaneFocusTraversable(); |
776 | 770 |
777 // Tooltips ------------------------------------------------------------------ | 771 // Tooltips ------------------------------------------------------------------ |
778 | 772 |
779 // Gets the tooltip for this View. If the View does not have a tooltip, | 773 // Gets the tooltip for this View. If the View does not have a tooltip, |
780 // return false. If the View does have a tooltip, copy the tooltip into | 774 // return false. If the View does have a tooltip, copy the tooltip into |
781 // the supplied string and return true. | 775 // the supplied string and return true. |
782 // Any time the tooltip text that a View is displaying changes, it must | 776 // Any time the tooltip text that a View is displaying changes, it must |
783 // invoke TooltipTextChanged. | 777 // invoke TooltipTextChanged. |
784 // |p| provides the coordinates of the mouse (relative to this view). | 778 // |p| provides the coordinates of the mouse (relative to this view). |
785 virtual bool GetTooltipText(const gfx::Point& p, std::wstring* tooltip); | 779 virtual bool GetTooltipText(const gfx::Point& p, std::wstring* tooltip); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
885 | 879 |
886 // Raise an accessibility notification with an option to also raise a native | 880 // Raise an accessibility notification with an option to also raise a native |
887 // notification. | 881 // notification. |
888 virtual void NotifyAccessibilityEvent(AccessibilityTypes::Event event_type, | 882 virtual void NotifyAccessibilityEvent(AccessibilityTypes::Event event_type, |
889 bool send_native_event); | 883 bool send_native_event); |
890 | 884 |
891 // Returns the MSAA default action of the current view. The string returned | 885 // Returns the MSAA default action of the current view. The string returned |
892 // describes the default action that will occur when executing | 886 // describes the default action that will occur when executing |
893 // IAccessible::DoDefaultAction. For instance, default action of a button is | 887 // IAccessible::DoDefaultAction. For instance, default action of a button is |
894 // 'Press'. | 888 // 'Press'. |
895 virtual string16 GetAccessibleDefaultAction() { return string16(); } | 889 virtual string16 GetAccessibleDefaultAction(); |
896 | 890 |
897 // Returns a string containing the mnemonic, or the keyboard shortcut, for a | 891 // Returns a string containing the mnemonic, or the keyboard shortcut, for a |
898 // given control. | 892 // given control. |
899 virtual string16 GetAccessibleKeyboardShortcut() { | 893 virtual string16 GetAccessibleKeyboardShortcut(); |
900 return string16(); | |
901 } | |
902 | 894 |
903 // Returns a brief, identifying string, containing a unique, readable name of | 895 // Returns a brief, identifying string, containing a unique, readable name of |
904 // a given control. Sets the input string appropriately, and returns true if | 896 // a given control. Sets the input string appropriately, and returns true if |
905 // successful. | 897 // successful. |
906 bool GetAccessibleName(string16* name); | 898 bool GetAccessibleName(string16* name); |
907 | 899 |
908 // Returns the accessibility role of the current view. The role is what | 900 // Returns the accessibility role of the current view. The role is what |
909 // assistive technologies (ATs) use to determine what behavior to expect from | 901 // assistive technologies (ATs) use to determine what behavior to expect from |
910 // a given control. | 902 // a given control. |
911 virtual AccessibilityTypes::Role GetAccessibleRole(); | 903 virtual AccessibilityTypes::Role GetAccessibleRole(); |
912 | 904 |
913 // Returns the accessibility state of the current view. | 905 // Returns the accessibility state of the current view. |
914 virtual AccessibilityTypes::State GetAccessibleState() { | 906 virtual AccessibilityTypes::State GetAccessibleState(); |
915 return 0; | |
916 } | |
917 | 907 |
918 // Returns the current value associated with a view. | 908 // Returns the current value associated with a view. |
919 virtual string16 GetAccessibleValue() { return string16(); } | 909 virtual string16 GetAccessibleValue(); |
920 | 910 |
921 // Assigns a string name to the given control. Needed as a View does not know | 911 // Assigns a string name to the given control. Needed as a View does not know |
922 // which name will be associated with it until it is created to be a | 912 // which name will be associated with it until it is created to be a |
923 // certain type. | 913 // certain type. |
924 void SetAccessibleName(const string16& name); | 914 void SetAccessibleName(const string16& name); |
925 | 915 |
926 // Returns an instance of the (platform-specific) accessibility interface for | 916 // Returns an instance of the (platform-specific) accessibility interface for |
927 // the View. | 917 // the View. |
928 ViewAccessibility* GetViewAccessibility(); | 918 ViewAccessibility* GetViewAccessibility(); |
929 | 919 |
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1415 // The accessibility implementation for this View. | 1405 // The accessibility implementation for this View. |
1416 scoped_refptr<ViewAccessibility> view_accessibility_; | 1406 scoped_refptr<ViewAccessibility> view_accessibility_; |
1417 #endif | 1407 #endif |
1418 | 1408 |
1419 DISALLOW_COPY_AND_ASSIGN(View); | 1409 DISALLOW_COPY_AND_ASSIGN(View); |
1420 }; | 1410 }; |
1421 | 1411 |
1422 } // namespace views | 1412 } // namespace views |
1423 | 1413 |
1424 #endif // VIEWS_VIEW_H_ | 1414 #endif // VIEWS_VIEW_H_ |
OLD | NEW |