NXWidgets: iapplication.hxx Source File

NXWidgets 1.19

iapplication.hxx
Go to the documentation of this file.
1 /****************************************************************************
2 * NxWidgets/nxwm/include/iapplication.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_IAPPLICATION_NXX
37 #define __INCLUDE_IAPPLICATION_NXX
38
39 /****************************************************************************
40 * Included Files
41 ****************************************************************************/
42
43 #include <nuttx/config.h>
44
45 #include "cnxstring.hxx"
46 #include "ibitmap.hxx"
47
48 /****************************************************************************
49 * Pre-Processor Definitions
50 ****************************************************************************/
51
52 /****************************************************************************
53 * Abstract Base Classes
54 ****************************************************************************/
55
56 #if defined(__cplusplus)
57
58 namespace NxWM
59 {
60 /**
61 * Foward references
62 */
63
64 class IApplicationWindow;
65
66 /**
67 * IApplication provides the abstract base class for each NxWM application.
68 */
69
70 class IApplication
71 {
72 protected:
73 /**
74 * These values (and the accessors that go with them) violate the "purity"
75 * of the base class. These are really part of the task bar implementation:
76 * Each application provides this state information needed by the taskbar.
77 */
78
79 bool m_minimized; /**< True if the application is minimized */
80 bool m_topapp; /**< True if this application is at the top in the hiearchy */
81
82 public:
83 /**
84 * A virtual destructor is required in order to override the IApplication
85 * destructor. We do this because if we delete IApplication, we want the
86 * destructor of the class that inherits from IApplication to run, not this
87 * one.
88 */
89
90 virtual ~IApplication(void) { }
91
92 /**
93 * Each implementation of IApplication must provide a method to recover
94 * the contained CApplicationWindow instance.
95 */
96
97 virtual IApplicationWindow *getWindow(void) const = 0;
98
99 /**
100 * Get the icon associated with the application
101 *
102 * @return An instance if IBitmap that may be used to rend the
103 * application's icon. This is an new IBitmap instance that must
104 * be deleted by the caller when it is no long needed.
105 */
106
107 virtual NXWidgets::IBitmap *getIcon(void) = 0;
108
109 /**
110 * Get the name string associated with the application
111 *
112 * @return A copy if CNxString that contains the name of the application.
113 */
114
115 virtual NXWidgets::CNxString getName(void) = 0;
116
117 /**
118 * Start the application (perhaps in the minimized state).
119 *
120 * @return True if the application was successfully started.
121 */
122
123 virtual bool run(void) = 0;
124
125 /**
126 * Stop the application, put all widgets in a deactivated/disabled state
127 * and wait to see what happens next.
128 */
129
130 virtual void stop(void) = 0;
131
132 /**
133 * Destroy the application and free all of its resources. This method
134 * will initiate blocking of messages from the NX server. The server
135 * will flush the window message queue and reply with the blocked
136 * message. When the block message is received by CWindowMessenger,
137 * it will send the destroy message to the start window task which
138 * will, finally, safely delete the application.
139 */
140
141 virtual void destroy(void) = 0;
142
143 /**
144 * The application window is hidden (either it is minimized or it is
145 * maximized, but not at the top of the hierarchy
146 */
147
148 virtual void hide(void) = 0;
149
150 /**
151 * Redraw the entire window. The application has been maximized or
152 * otherwise moved to the top of the hierarchy. This method is call from
153 * CTaskbar when the application window must be displayed
154 */
155
156 virtual void redraw(void) = 0;
157
158 /**
159 * Set the application's minimized state
160 *
161 * @param minimized. True if the application is minimized
162 */
163
164 inline void setMinimized(bool minimized)
165 {
166 m_minimized = minimized;
167 }
168
169 /**
170 * Set the application's top state
171 *
172 * @param topapp. True if the application is the new top application
173 */
174
175 inline void setTopApplication(bool topapp)
176 {
177 m_topapp = topapp;
178 }
179
180 /**
181 * Get the application's minimized state
182 *
183 * @return True if the application is minimized
184 */
185
186 inline bool isMinimized(void) const
187 {
188 return m_minimized;
189 }
190
191 /**
192 * Return true if this is the top application
193 *
194 * @return True if the application is the new top application
195 */
196
197 inline bool isTopApplication(void) const
198 {
199 return m_topapp;
200 }
201
202 /**
203 * Report of this is a "normal" window or a full screen window. The
204 * primary purpose of this method is so that window manager will know
205 * whether or not it show draw the task bar.
206 *
207 * @return True if this is a full screen window.
208 */
209
210 virtual bool isFullScreen(void) const = 0;
211 };
212
213 /**
214 * IApplicationFactory provides a mechanism for creating multiple instances
215 * of an application.
216 */
217
218 class IApplicationFactory
219 {
220 public:
221 /**
222 * A virtual destructor is required in order to override the IApplicationFactory
223 * destructor. We do this because if we delete IApplicationFactory, we want the
224 * destructor of the class that inherits from IApplication to run, not this
225 * one.
226 */
227
228 virtual ~IApplicationFactory(void) { }
229
230 /**
231 * Create a new instance of an application.
232 */
233
234 virtual IApplication *create(void) = 0;
235
236 /**
237 * Get the icon associated with the application
238 *
239 * @return An instance if IBitmap that may be used to rend the
240 * application's icon. This is an new IBitmap instance that must
241 * be deleted by the caller when it is no long needed.
242 */
243
244 virtual NXWidgets::IBitmap *getIcon(void) = 0;
245 };
246 }
247
248 #endif // __cplusplus
249
250 #endif // __INCLUDE_IAPPLICATION_NXX
NxWM::IApplication::hide
virtual void hide(void)=0
ibitmap.hxx
NxWM::IApplicationFactory
Definition: iapplication.hxx:218
NxWM::IApplication::getWindow
virtual IApplicationWindow * getWindow(void) const =0
NxWM::IApplication::isTopApplication
bool isTopApplication(void) const
Definition: iapplication.hxx:197
NxWM::IApplication::isMinimized
bool isMinimized(void) const
Definition: iapplication.hxx:186
NxWM::IApplication::getName
virtual NXWidgets::CNxString getName(void)=0
NxWM::IApplication::stop
virtual void stop(void)=0
NxWM::IApplication::getIcon
virtual NXWidgets::IBitmap * getIcon(void)=0
NxWM::IApplication::setTopApplication
void setTopApplication(bool topapp)
Definition: iapplication.hxx:175
NxWM
Definition: capplicationwindow.hxx:66
NxWM::IApplication::m_topapp
bool m_topapp
Definition: iapplication.hxx:80
NxWM::IApplication::run
virtual bool run(void)=0
NxWM::IApplication::~IApplication
virtual ~IApplication(void)
Definition: iapplication.hxx:90
NxWM::IApplication::m_minimized
bool m_minimized
Definition: iapplication.hxx:79
NxWM::IApplicationWindow
Definition: iapplicationwindow.hxx:95
NxWM::IApplication
Definition: iapplication.hxx:70
NxWM::IApplicationFactory::~IApplicationFactory
virtual ~IApplicationFactory(void)
Definition: iapplication.hxx:228
NXWidgets::CNxString
Definition: cnxstring.hxx:121
NxWM::IApplication::redraw
virtual void redraw(void)=0
NxWM::IApplication::isFullScreen
virtual bool isFullScreen(void) const =0
NxWM::IApplication::destroy
virtual void destroy(void)=0
cnxstring.hxx
NXWidgets::IBitmap
Definition: ibitmap.hxx:103
NxWM::IApplication::setMinimized
void setMinimized(bool minimized)
Definition: iapplication.hxx:164