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 
76  {
77  public:
78  /**
79  * Enumeration describing the bit settings for each window flag
80  */
81 
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 
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 
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
NXWidgets::CImage * m_stopImage
NXWidgets::CNxFont * m_windowFont
CApplicationWindow(NXWidgets::CNxTkWindow *window, uint8_t flags=0)
void setWindowLabel(NXWidgets::CNxString &appname)
NXWidgets::CNxToolbar * m_toolbar
void block(IApplication *app)
void clickMinimizePosition(bool click)
void registerCallbacks(IApplicationCallback *callback)
NXWidgets::CLabel * m_windowLabel
NXWidgets::INxWindow * getWindow(void) const
NXWidgets::CWidgetControl * getWidgetControl(void) const
NXWidgets::CNxTkWindow * m_window
void handleActionEvent(const NXWidgets::CWidgetEventArgs &e)
NXWidgets::CImage * m_minimizeImage
NXWidgets::CRlePaletteBitmap * m_minimizeBitmap
IApplicationCallback * m_callback
NXWidgets::CRlePaletteBitmap * m_stopBitmap