NXWidgets  1.19
cwindoweventhandlerlist.hxx
Go to the documentation of this file.
1 /****************************************************************************
2  * NxWidgets/libnxwidgets/include/cwindoweventhandlerlist.hxx
3  *
4  * Copyright (C) 2012 Gregory Nutt. All rights reserved.
5  * Author: Gregory Nutt <gnutt@nuttx.org>
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * 1. Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following disclaimer in
15  * the documentation and/or other materials provided with the
16  * distribution.
17  * 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
18  * me be used to endorse or promote products derived from this software
19  * without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
28  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *
34  ****************************************************************************/
35 
36 #ifndef __INCLUDE_CWINDOWEVENTHANDLERLIST_HXX
37 #define __INCLUDE_CWINDOWEVENTHANDLERLIST_HXX
38 
39 /****************************************************************************
40  * Included Files
41  ****************************************************************************/
42 
43 #include <nuttx/config.h>
44 
45 #include <stdint.h>
46 #include <stdbool.h>
47 
48 #include <nuttx/nx/nxglib.h>
49 
50 #include "cwindoweventhandler.hxx"
51 #include "tnxarray.hxx"
52 
53 /****************************************************************************
54  * Pre-Processor Definitions
55  ****************************************************************************/
56 
57 /****************************************************************************
58  * Implementation Classes
59  ****************************************************************************/
60 
61 #if defined(__cplusplus)
62 
63 namespace NXWidgets
64 {
65  class CListDataItem;
66 
67  /**
68  * List of window event handlers.
69  */
71  {
72  protected:
73  TNxArray<CWindowEventHandler*> m_eventHandlers; /**< List of event handlers */
74 
75  /**
76  * Return the index to the window event handler.
77  */
78 
79  bool findWindowEventHandler(CWindowEventHandler *eventHandler, int &index);
80 
81  public:
82 
83  /**
84  * Constructor.
85  *
86  * @param widget The owning widget.
87  */
88 
90 
91  /**
92  * Destructor.
93  */
94 
95  inline ~CWindowEventHandlerList(void) { }
96 
97  /**
98  * Get the event handler at the specified index.
99  *
100  * @param index The index of the event handler.
101  * @return The event handler at the specified index.
102  */
103 
104  inline CWindowEventHandler *at(const int index) const
105  {
106  return m_eventHandlers.at(index);
107  }
108 
109  /**
110  * Get the size of the array.
111  *
112  * @return The size of the array.
113  */
114 
115  inline const nxgl_coord_t size(void) const
116  {
117  return m_eventHandlers.size();
118  }
119 
120  /**
121  * Adds a window event handler. The event handler will receive
122  * all events raised by this object.
123  * @param eventHandler A pointer to the event handler.
124  */
125 
126  void addWindowEventHandler(CWindowEventHandler *eventHandler);
127 
128  /**
129  * Remove a window event handler.
130  *
131  * @param eventHandler A pointer to the event handler to remove.
132  */
133 
134  void removeWindowEventHandler(CWindowEventHandler *eventHandler);
135 
136  /**
137  * Raise the NX window redraw event.
138  */
139 
140  void raiseRedrawEvent(void);
141 
142  /**
143  * Raise an NX window position/size change event.
144  */
145 
146  void raiseGeometryEvent(void);
147 
148  /**
149  * Raise an NX mouse window input event.
150  */
151 
152 #ifdef CONFIG_NX_XYINPUT
153  void raiseMouseEvent(void);
154 #endif
155 
156  /**
157  * Raise an NX keybord input event
158  */
159 
160 #ifdef CONFIG_NX_KBD
161  void raiseKeyboardEvent(void);
162 #endif
163 
164  /**
165  * Raise an NX window blocked event.
166  *
167  * @param arg - User provided argument (see nx_block or nxtk_block)
168  */
169 
170  void raiseBlockedEvent(FAR void *arg);
171  };
172 }
173 
174 #endif // __cplusplus
175 
176 #endif // __INCLUDE_CWINDOWEVENTHANDLERLIST_HXX
CWindowEventHandler * at(const int index) const
void addWindowEventHandler(CWindowEventHandler *eventHandler)
void removeWindowEventHandler(CWindowEventHandler *eventHandler)
TNxArray< CWindowEventHandler * > m_eventHandlers
const int size(void) const
Definition: tnxarray.hxx:261
T & at(const int index) const
Definition: tnxarray.hxx:404
bool findWindowEventHandler(CWindowEventHandler *eventHandler, int &index)