NXWidgets: cwindoweventhandlerlist.cxx Source File

NXWidgets 1.19

cwindoweventhandlerlist.cxx
Go to the documentation of this file.
1 /****************************************************************************
2 * NxWidgets/libnxwidgets/src/cwindoweventhandlerlist.cxx
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 /****************************************************************************
37 * Included Files
38 ****************************************************************************/
39
40 #include "nxconfig.hxx"
41
42 #include "cwindoweventhandler.hxx"
43 #include "cwindoweventhandlerlist.hxx"
44
45 /****************************************************************************
46 * Pre-Processor Definitions
47 ****************************************************************************/
48
49 /****************************************************************************
50 * Method Implementations
51 ****************************************************************************/
52
53 using namespace NXWidgets;
54
55 /**
56 * Adds a window event handler. The event handler will receive
57 * all events raised by this object.
58 * @param eventHandler A pointer to the event handler.
59 */
60
61 void CWindowEventHandlerList::addWindowEventHandler(CWindowEventHandler *eventHandler)
62 {
63 // Make sure that the event handler does not already exist
64
65 int index;
66 if (!findWindowEventHandler(eventHandler, index))
67 {
68 // Add the new handler
69
70 m_eventHandlers.push_back(eventHandler);
71 }
72 }
73
74 /**
75 * Remove a window event handler.
76 *
77 * @param eventHandler A pointer to the event handler to remove.
78 */
79
80 void CWindowEventHandlerList::removeWindowEventHandler(CWindowEventHandler *eventHandler)
81 {
82 // Find the event handler to be removed
83
84 int index;
85 if (findWindowEventHandler(eventHandler, index))
86 {
87 // and remove it
88
89 m_eventHandlers.erase(index);
90 }
91 }
92
93 /**
94 * Return the index to the window event handler.
95 */
96
97 bool CWindowEventHandlerList::findWindowEventHandler(CWindowEventHandler *eventHandler, int &index)
98 {
99 for (int i = 0; i < m_eventHandlers.size(); ++i)
100 {
101 if (m_eventHandlers.at(i) == eventHandler)
102 {
103 index = i;
104 return true;
105 }
106 }
107
108 return false;
109 }
110
111 /**
112 * Raise the NX window redraw event.
113 */
114
115 void CWindowEventHandlerList::raiseRedrawEvent(void)
116 {
117 for (int i = 0; i < m_eventHandlers.size(); ++i)
118 {
119 m_eventHandlers.at(i)->handleRedrawEvent();
120 }
121 }
122
123 /**
124 * Raise an NX window position/size change event.
125 */
126
127 void CWindowEventHandlerList::raiseGeometryEvent(void)
128 {
129 for (int i = 0; i < m_eventHandlers.size(); ++i)
130 {
131 m_eventHandlers.at(i)->handleGeometryEvent();
132 }
133 }
134
135 /**
136 * Raise an NX mouse window input event.
137 */
138
139 #ifdef CONFIG_NX_XYINPUT
140 void CWindowEventHandlerList::raiseMouseEvent(void)
141 {
142 for (int i = 0; i < m_eventHandlers.size(); ++i)
143 {
144 m_eventHandlers.at(i)->handleMouseEvent();
145 }
146 }
147 #endif
148
149 /**
150 * Raise an NX keybord input event
151 */
152
153 #ifdef CONFIG_NX_KBD
154 void CWindowEventHandlerList::raiseKeyboardEvent(void)
155 {
156 for (int i = 0; i < m_eventHandlers.size(); ++i)
157 {
158 m_eventHandlers.at(i)->handleKeyboardEvent();
159 }
160 #endif
161 }
162
163 /**
164 * Raise an NX window blocked event.
165 *
166 * @param arg - User provided argument (see nx_block or nxtk_block)
167 */
168
169 void CWindowEventHandlerList::raiseBlockedEvent(FAR void *arg)
170 {
171 for (int i = 0; i < m_eventHandlers.size(); ++i)
172 {
173 m_eventHandlers.at(i)->handleBlockedEvent(arg);
174 }
175 }
NXWidgets::CWindowEventHandlerList::raiseGeometryEvent
void raiseGeometryEvent(void)
Definition: cwindoweventhandlerlist.cxx:127
NXWidgets::CWindowEventHandlerList::raiseRedrawEvent
void raiseRedrawEvent(void)
Definition: cwindoweventhandlerlist.cxx:115
cwindoweventhandler.hxx
NXWidgets::CWindowEventHandlerList::raiseMouseEvent
void raiseMouseEvent(void)
Definition: cwindoweventhandlerlist.cxx:140
NXWidgets
Definition: cbgwindow.hxx:65
NXWidgets::CWindowEventHandlerList::addWindowEventHandler
void addWindowEventHandler(CWindowEventHandler *eventHandler)
Definition: cwindoweventhandlerlist.cxx:61
nxconfig.hxx
NXWidgets::CWindowEventHandlerList::raiseKeyboardEvent
void raiseKeyboardEvent(void)
Definition: cwindoweventhandlerlist.cxx:154
NXWidgets::CWindowEventHandlerList::removeWindowEventHandler
void removeWindowEventHandler(CWindowEventHandler *eventHandler)
Definition: cwindoweventhandlerlist.cxx:80
NXWidgets::CWindowEventHandler
Definition: cwindoweventhandler.hxx:64
NXWidgets::CWindowEventHandlerList::m_eventHandlers
TNxArray< CWindowEventHandler * > m_eventHandlers
Definition: cwindoweventhandlerlist.hxx:73
NXWidgets::CWindowEventHandlerList::raiseBlockedEvent
void raiseBlockedEvent(FAR void *arg)
Definition: cwindoweventhandlerlist.cxx:169
NXWidgets::CWindowEventHandlerList::findWindowEventHandler
bool findWindowEventHandler(CWindowEventHandler *eventHandler, int &index)
Definition: cwindoweventhandlerlist.cxx:97
cwindoweventhandlerlist.hxx