NXWidgets: capplicationwindow.hxx Source File

NXWidgets 1.19

capplicationwindow.hxx
Go to the documentation of this file.
1 /****************************************************************************
2 * NxWidgets/nxwm/include/capplicationwindow.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_CAPPLICATIONWINDOW_NXX
37 #define __INCLUDE_CAPPLICATIONWINDOW_NXX
38
39 /****************************************************************************
40 * Included Files
41 ****************************************************************************/
42
43 #include <nuttx/config.h>
44
45 #include "cnxtkwindow.hxx"
46 #include "cnxtoolbar.hxx"
47 #include "cwidgetcontrol.hxx"
48 #include "cwidgeteventargs.hxx"
49 #include "cwidgeteventhandler.hxx"
50 #include "cimage.hxx"
51 #include "clabel.hxx"
52 #include "crlepalettebitmap.hxx"
53
54 #include "iapplicationwindow.hxx"
55
56 /****************************************************************************
57 * Pre-Processor Definitions
58 ****************************************************************************/
59
60 /****************************************************************************
61 * Implementation Classes
62 ****************************************************************************/
63
64 #if defined(__cplusplus)
65
66 namespace NxWM
67 {
68 /**
69 * This class represents that application window. This class contains that the
70 * framed window and its toolbar. It manages callbacks from the toolbar minimize
71 * and close buttions and passes these to the application via callbacks.
72 */
73
74 class CApplicationWindow : public IApplicationWindow,
75 private NXWidgets::CWidgetEventHandler
76 {
77 public:
78 /**
79 * Enumeration describing the bit settings for each window flag
80 */
81
82 enum EWindowFlags
83 {
84 WINDOW_PERSISTENT = 0x01 /**< Persistent windows have no stop button */
85 };
86
87 protected:
88 NXWidgets::CNxTkWindow *m_window; /**< The framed window used by the application */
89 NXWidgets::CNxToolbar *m_toolbar; /**< The toolbar */
90 NXWidgets::CImage *m_minimizeImage; /**< The minimize icon */
91 NXWidgets::CImage *m_stopImage; /**< The close icon */
92 NXWidgets::CLabel *m_windowLabel; /**< The window title */
93 NXWidgets::CRlePaletteBitmap *m_minimizeBitmap; /**< The minimize icon bitmap */
94 NXWidgets::CRlePaletteBitmap *m_stopBitmap; /**< The stop icon bitmap */
95 NXWidgets::CNxFont *m_windowFont; /**< The font used to rend the window label */
96 IApplicationCallback *m_callback; /**< Toolbar action callbacks */
97 uint8_t m_flags; /**< Window flags */
98
99 /**
100 * Handle a widget action event. For CImage, this is a mouse button pre-release event.
101 *
102 * @param e The event data.
103 */
104
105 void handleActionEvent(const NXWidgets::CWidgetEventArgs &e);
106
107 public:
108
109 /**
110 * CApplicationWindow Constructor
111 *
112 * @param window. The window to be used by this application.
113 * @param flags. Optional flags to control the window configuration (See EWindowFlags).
114 */
115
116 CApplicationWindow(NXWidgets::CNxTkWindow *window, uint8_t flags = 0);
117
118 /**
119 * CApplicationWindow Destructor
120 */
121
122 ~CApplicationWindow(void);
123
124 /**
125 * Initialize window. Window initialization is separate from
126 * object instantiation so that failures can be reported.
127 *
128 * @return True if the window was successfully initialized.
129 */
130
131 bool open(void);
132
133 /**
134 * Re-draw the application window
135 */
136
137 void redraw(void);
138
139 /**
140 * The application window is hidden (either it is minimized or it is
141 * maximized, but not at the top of the hierarchy)
142 */
143
144 void hide(void);
145
146 /**
147 * Recover the contained NXTK window instance
148 *
149 * @return. The window used by this application
150 */
151
152 NXWidgets::INxWindow *getWindow(void) const;
153
154 /**
155 * Recover the contained widget control
156 *
157 * @return. The widget control used by this application
158 */
159
160 NXWidgets::CWidgetControl *getWidgetControl(void) const;
161
162 /**
163 * Block further activity on this window in preparation for window
164 * shutdown.
165 *
166 * @param app. The application to be blocked
167 */
168
169 void block(IApplication *app);
170
171 /**
172 * Set the window label
173 *
174 * @param appname. The name of the application to place on the window
175 */
176
177 void setWindowLabel(NXWidgets::CNxString &appname);
178
179 /**
180 * Report of this is a "normal" window or a full screen window. The
181 * primary purpose of this method is so that window manager will know
182 * whether or not it show draw the task bar.
183 *
184 * @return True if this is a full screen window.
185 */
186
187 bool isFullScreen(void) const;
188
189 /**
190 * Register to receive callbacks when toolbar icons are selected
191 */
192
193 void registerCallbacks(IApplicationCallback *callback);
194
195 /**
196 * Check if this window is configured for a persistent application (i.e.,
197 * an application that has no STOP icon
198 *
199 * @return True if the window is configured for a persistent application.
200 */
201
202 inline bool isPersistent(void) const
203 {
204 return (m_flags & WINDOW_PERSISTENT) != 0;
205 }
206
207 /**
208 * Simulate a mouse click or release on the minimize icon. This method
209 * is only available for automated testing of NxWM.
210 *
211 * @param click. True to click; false to release;
212 */
213
214 #if defined(CONFIG_NXWM_UNITTEST) && !defined(CONFIG_NXWM_TOUCHSCREEN)
215 void clickMinimizePosition(bool click);
216 #endif
217
218 /**
219 * Simulate a mouse click or release on the stop icon. This method
220 * is only available for automated testing of NxWM.
221 *
222 * @param click. True to click; false to release;
223 */
224
225 #if defined(CONFIG_NXWM_UNITTEST) && !defined(CONFIG_NXWM_TOUCHSCREEN)
226 void clickStopIcon(bool click);
227 #endif
228 };
229 }
230
231 #endif // __cplusplus
232
233 #endif // __INCLUDE_CAPPLICATIONWINDOW_NXX
NxWM::CApplicationWindow::m_stopImage
NXWidgets::CImage * m_stopImage
Definition: capplicationwindow.hxx:91
NxWM::CApplicationWindow
Definition: capplicationwindow.hxx:74
NxWM::CApplicationWindow::m_windowFont
NXWidgets::CNxFont * m_windowFont
Definition: capplicationwindow.hxx:95
crlepalettebitmap.hxx
NxWM::CApplicationWindow::clickStopIcon
void clickStopIcon(bool click)
Definition: capplicationwindow.cxx:543
NxWM::CApplicationWindow::EWindowFlags
EWindowFlags
Definition: capplicationwindow.hxx:82
NXWidgets::CWidgetEventHandler
Definition: cwidgeteventhandler.hxx:103
clabel.hxx
NXWidgets::CWidgetControl
Definition: cwidgetcontrol.hxx:95
NxWM::CApplicationWindow::CApplicationWindow
CApplicationWindow(NXWidgets::CNxTkWindow *window, uint8_t flags=0)
Definition: capplicationwindow.cxx:82
NXWidgets::CRlePaletteBitmap
Definition: crlepalettebitmap.hxx:100
NxWM::CApplicationWindow::hide
void hide(void)
Definition: capplicationwindow.cxx:403
cwidgetcontrol.hxx
NxWM::CApplicationWindow::setWindowLabel
void setWindowLabel(NXWidgets::CNxString &appname)
Definition: capplicationwindow.cxx:475
NxWM::CApplicationWindow::m_flags
uint8_t m_flags
Definition: capplicationwindow.hxx:97
cwidgeteventargs.hxx
iapplicationwindow.hxx
NxWM::CApplicationWindow::m_toolbar
NXWidgets::CNxToolbar * m_toolbar
Definition: capplicationwindow.hxx:89
NxWM::CApplicationWindow::isPersistent
bool isPersistent(void) const
Definition: capplicationwindow.hxx:202
NxWM::CApplicationWindow::~CApplicationWindow
~CApplicationWindow(void)
Definition: capplicationwindow.cxx:111
cimage.hxx
NxWM::CApplicationWindow::block
void block(IApplication *app)
Definition: capplicationwindow.cxx:457
NXWidgets::CNxFont
Definition: cnxfont.hxx:70
NxWM
Definition: capplicationwindow.hxx:66
NXWidgets::CNxToolbar
Definition: cnxtoolbar.hxx:85
NxWM::CApplicationWindow::clickMinimizePosition
void clickMinimizePosition(bool click)
Definition: capplicationwindow.cxx:510
NxWM::CApplicationWindow::registerCallbacks
void registerCallbacks(IApplicationCallback *callback)
Definition: capplicationwindow.cxx:497
NxWM::CApplicationWindow::m_windowLabel
NXWidgets::CLabel * m_windowLabel
Definition: capplicationwindow.hxx:92
NxWM::CApplicationWindow::getWindow
NXWidgets::INxWindow * getWindow(void) const
Definition: capplicationwindow.cxx:434
NXWidgets::CWidgetEventArgs
Definition: cwidgeteventargs.hxx:127
NxWM::CApplicationWindow::redraw
void redraw(void)
Definition: capplicationwindow.cxx:349
NxWM::CApplicationWindow::WINDOW_PERSISTENT
Definition: capplicationwindow.hxx:84
NXWidgets::CImage
Definition: cimage.hxx:109
NxWM::IApplicationWindow
Definition: iapplicationwindow.hxx:95
NxWM::CApplicationWindow::getWidgetControl
NXWidgets::CWidgetControl * getWidgetControl(void) const
Definition: capplicationwindow.cxx:445
NxWM::IApplication
Definition: iapplication.hxx:70
cnxtkwindow.hxx
NxWM::CApplicationWindow::m_window
NXWidgets::CNxTkWindow * m_window
Definition: capplicationwindow.hxx:88
NXWidgets::CNxString
Definition: cnxstring.hxx:121
NXWidgets::CLabel
Definition: clabel.hxx:112
cnxtoolbar.hxx
NxWM::CApplicationWindow::handleActionEvent
void handleActionEvent(const NXWidgets::CWidgetEventArgs &e)
Definition: capplicationwindow.cxx:579
NxWM::CApplicationWindow::m_minimizeImage
NXWidgets::CImage * m_minimizeImage
Definition: capplicationwindow.hxx:90
NxWM::CApplicationWindow::m_minimizeBitmap
NXWidgets::CRlePaletteBitmap * m_minimizeBitmap
Definition: capplicationwindow.hxx:93
NXWidgets::INxWindow
Definition: inxwindow.hxx:83
NxWM::CApplicationWindow::m_callback
IApplicationCallback * m_callback
Definition: capplicationwindow.hxx:96
NxWM::CApplicationWindow::open
bool open(void)
Definition: capplicationwindow.cxx:166
NXWidgets::CNxTkWindow
Definition: cnxtkwindow.hxx:84
NxWM::CApplicationWindow::m_stopBitmap
NXWidgets::CRlePaletteBitmap * m_stopBitmap
Definition: capplicationwindow.hxx:94
cwidgeteventhandler.hxx
NxWM::CApplicationWindow::isFullScreen
bool isFullScreen(void) const
Definition: capplicationwindow.cxx:488
NxWM::IApplicationCallback
Definition: iapplicationwindow.hxx:74