NXWidgets  1.19
cwindowmessenger.hxx
Go to the documentation of this file.
1 /****************************************************************************
2  * NxWidgets/nxwm/include/cwindowmessenger.hxx
3  *
4  * Copyright (C) 2012-2013 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_CWINDOWMESSENGER_HXX
37 #define __INCLUDE_CWINDOWMESSENGER_HXX
38 
39 /****************************************************************************
40  * Included Files
41  ****************************************************************************/
42 
43 #include <nuttx/config.h>
44 
45 #include <sys/types.h>
46 
47 #include <nuttx/wqueue.h>
48 #include <nuttx/nx/nxtk.h>
49 #include <nuttx/nx/nxterm.h>
50 
51 #include "cwindoweventhandler.hxx"
52 #include "cwidgetstyle.hxx"
53 #include "cwidgetcontrol.hxx"
54 
55 /****************************************************************************
56  * Pre-Processor Definitions
57  ****************************************************************************/
58 
59 /****************************************************************************
60  * Implementation Classes
61  ****************************************************************************/
62 
63 #if defined(__cplusplus)
64 
65 namespace NxWM
66 {
67  /**
68  * Forward references.
69  */
70 
71  class IApplication;
72 
73  /**
74  * The class CWindowMessenger integrates the widget control with some special
75  * handling of mouse and keyboard inputs needs by NxWM. It use used
76  * in place of CWidgetControl whenever an NxWM window is created.
77  *
78  * CWindowMessenger cohabitates with CWidgetControl only because it needs the
79  * CWidgetControl as an argument in its messaging.
80  */
81 
84  {
85  private:
86  /** Structure that stores data for the work queue callback. */
87 
88  struct work_state_t
89  {
90  work_s work;
92  void *instance;
93 
94  work_state_t() : work() {}
95  };
96 
97  /** Work queue callback functions */
98 
99  static void inputWorkCallback(FAR void *arg);
100  static void destroyWorkCallback(FAR void *arg);
101 
102  /**
103  * Handle an NX window mouse input event.
104  *
105  * @param e The event data.
106  */
107 
108 #ifdef CONFIG_NX_XYINPUT
109  void handleMouseEvent(void);
110 #endif
111 
112  /**
113  * Handle a NX window keyboard input event.
114  */
115 
116 #ifdef CONFIG_NX_KBD
117  void handleKeyboardEvent(void);
118 #endif
119 
120  /**
121  * Handle a NX window blocked event
122  *
123  * @param arg - User provided argument (see nx_block or nxtk_block)
124  */
125 
126  void handleBlockedEvent(FAR void *arg);
127 
128  public:
129 
130  /**
131  * CWindowMessenger Constructor
132  *
133  * @param style The default style that all widgets on this display
134  * should use. If this is not specified, the widget will use the
135  * values stored in the defaultCWidgetStyle object.
136  */
137 
138  CWindowMessenger(FAR const NXWidgets::CWidgetStyle *style = (const NXWidgets::CWidgetStyle *)NULL);
139 
140  /**
141  * CWindowMessenger Destructor.
142  */
143 
144  ~CWindowMessenger(void);
145  };
146 }
147 #endif // __cplusplus
148 
149 #endif // __INCLUDE_CWINDOWMESSENGER_HXX
static void inputWorkCallback(FAR void *arg)
static void destroyWorkCallback(FAR void *arg)
CWindowMessenger(FAR const NXWidgets::CWidgetStyle *style=(const NXWidgets::CWidgetStyle *) NULL)
void handleBlockedEvent(FAR void *arg)