cwindoweventhandlerlist.hxx 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. /****************************************************************************
  2. * apps/include/graphics/nxwidgets/cwindoweventhandlerlist.hxx
  3. *
  4. * Licensed to the Apache Software Foundation (ASF) under one or more
  5. * contributor license agreements. See the NOTICE file distributed with
  6. * this work for additional information regarding copyright ownership. The
  7. * ASF licenses this file to you under the Apache License, Version 2.0 (the
  8. * "License"); you may not use this file except in compliance with the
  9. * License. You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  15. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  16. * License for the specific language governing permissions and limitations
  17. * under the License.
  18. *
  19. ****************************************************************************/
  20. #ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CWINDOWEVENTHANDLERLIST_HXX
  21. #define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CWINDOWEVENTHANDLERLIST_HXX
  22. /****************************************************************************
  23. * Included Files
  24. ****************************************************************************/
  25. #include <nuttx/config.h>
  26. #include <stdint.h>
  27. #include <stdbool.h>
  28. #include <nuttx/nx/nxglib.h>
  29. #include "graphics/nxwidgets/cwindoweventhandler.hxx"
  30. #include "graphics/nxwidgets/tnxarray.hxx"
  31. /****************************************************************************
  32. * Pre-Processor Definitions
  33. ****************************************************************************/
  34. /****************************************************************************
  35. * Implementation Classes
  36. ****************************************************************************/
  37. #if defined(__cplusplus)
  38. namespace NXWidgets
  39. {
  40. class CListDataItem;
  41. /**
  42. * List of window event handlers.
  43. */
  44. class CWindowEventHandlerList
  45. {
  46. protected:
  47. TNxArray<CWindowEventHandler*> m_eventHandlers; /**< List of event handlers */
  48. /**
  49. * Return the index to the window event handler.
  50. */
  51. bool findWindowEventHandler(CWindowEventHandler *eventHandler, int &index);
  52. public:
  53. /**
  54. * Constructor.
  55. *
  56. * @param widget The owning widget.
  57. */
  58. CWindowEventHandlerList(void) { }
  59. /**
  60. * Destructor.
  61. */
  62. inline ~CWindowEventHandlerList(void) { }
  63. /**
  64. * Get the event handler at the specified index.
  65. *
  66. * @param index The index of the event handler.
  67. * @return The event handler at the specified index.
  68. */
  69. inline CWindowEventHandler *at(const int index) const
  70. {
  71. return m_eventHandlers.at(index);
  72. }
  73. /**
  74. * Get the size of the array.
  75. *
  76. * @return The size of the array.
  77. */
  78. inline const nxgl_coord_t size(void) const
  79. {
  80. return m_eventHandlers.size();
  81. }
  82. /**
  83. * Adds a window event handler. The event handler will receive
  84. * all events raised by this object.
  85. * @param eventHandler A pointer to the event handler.
  86. */
  87. void addWindowEventHandler(CWindowEventHandler *eventHandler);
  88. /**
  89. * Remove a window event handler.
  90. *
  91. * @param eventHandler A pointer to the event handler to remove.
  92. */
  93. void removeWindowEventHandler(CWindowEventHandler *eventHandler);
  94. /**
  95. * Raise the NX window redraw event.
  96. *
  97. * @param nxRect The region in the window to be redrawn
  98. * @param more More redraw requests will follow
  99. */
  100. void raiseRedrawEvent(FAR const nxgl_rect_s *nxRect, bool more);
  101. /**
  102. * Raise an NX window position/size change event.
  103. */
  104. void raiseGeometryEvent(void);
  105. #ifdef CONFIG_NX_XYINPUT
  106. /**
  107. * Raise an NX mouse window input event.
  108. */
  109. void raiseMouseEvent(FAR const struct nxgl_point_s *pos,
  110. uint8_t buttons);
  111. #endif
  112. #ifdef CONFIG_NX_KBD
  113. /**
  114. * Raise an NX keyboard input event
  115. */
  116. void raiseKeyboardEvent(void);
  117. #endif
  118. /**
  119. * Raise an NX window blocked event.
  120. *
  121. * @param arg - User provided argument (see nx_block or nxtk_block)
  122. */
  123. void raiseBlockedEvent(FAR void *arg);
  124. };
  125. }
  126. #endif // __cplusplus
  127. #endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CWINDOWEVENTHANDLERLIST_HXX