The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

92 lines
3.3KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2013 - Raw Material Software Ltd.
  5. Permission is granted to use this software under the terms of either:
  6. a) the GPL v2 (or any later version)
  7. b) the Affero GPL v3
  8. Details of these licenses can be found at: www.gnu.org/licenses
  9. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. ------------------------------------------------------------------------------
  13. To release a closed-source product which uses JUCE, commercial licenses are
  14. available: visit www.juce.com for more information.
  15. ==============================================================================
  16. */
  17. #ifndef __JUCE_KEYBOARDFOCUSTRAVERSER_JUCEHEADER__
  18. #define __JUCE_KEYBOARDFOCUSTRAVERSER_JUCEHEADER__
  19. class Component;
  20. //==============================================================================
  21. /**
  22. Controls the order in which focus moves between components.
  23. The default algorithm used by this class to work out the order of traversal
  24. is as follows:
  25. - if two components both have an explicit focus order specified, then the
  26. one with the lowest number comes first (see the Component::setExplicitFocusOrder()
  27. method).
  28. - any component with an explicit focus order greater than 0 comes before ones
  29. that don't have an order specified.
  30. - any unspecified components are traversed in a left-to-right, then top-to-bottom
  31. order.
  32. If you need traversal in a more customised way, you can create a subclass
  33. of KeyboardFocusTraverser that uses your own algorithm, and use
  34. Component::createFocusTraverser() to create it.
  35. @see Component::setExplicitFocusOrder, Component::createFocusTraverser
  36. */
  37. class JUCE_API KeyboardFocusTraverser
  38. {
  39. public:
  40. KeyboardFocusTraverser();
  41. /** Destructor. */
  42. virtual ~KeyboardFocusTraverser();
  43. /** Returns the component that should be given focus after the specified one
  44. when moving "forwards".
  45. The default implementation will return the next component which is to the
  46. right of or below this one.
  47. This may return 0 if there's no suitable candidate.
  48. */
  49. virtual Component* getNextComponent (Component* current);
  50. /** Returns the component that should be given focus after the specified one
  51. when moving "backwards".
  52. The default implementation will return the next component which is to the
  53. left of or above this one.
  54. This may return 0 if there's no suitable candidate.
  55. */
  56. virtual Component* getPreviousComponent (Component* current);
  57. /** Returns the component that should receive focus be default within the given
  58. parent component.
  59. The default implementation will just return the foremost child component that
  60. wants focus.
  61. This may return 0 if there's no suitable candidate.
  62. */
  63. virtual Component* getDefaultComponent (Component* parentComponent);
  64. };
  65. #endif // __JUCE_KEYBOARDFOCUSTRAVERSER_JUCEHEADER__