NXWidgets  1.19
cnxterm.hxx
Go to the documentation of this file.
1 /****************************************************************************
2  * NxWidgets/nxwm/include/cnxterm.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_CNXTERM_HXX
37 #define __INCLUDE_CNXTERM_HXX
38 
39 /****************************************************************************
40  * Included Files
41  ****************************************************************************/
42 
43 #include <nuttx/config.h>
44 
45 #include <sys/types.h>
46 #include <nuttx/nx/nxtk.h>
47 #include <nuttx/nx/nxterm.h>
48 
49 #include "iapplication.hxx"
50 #include "capplicationwindow.hxx"
51 #include "ctaskbar.hxx"
52 
53 /****************************************************************************
54  * Pre-Processor Definitions
55  ****************************************************************************/
56 
57 /****************************************************************************
58  * Implementation Classes
59  ****************************************************************************/
60 
61 #if defined(__cplusplus)
62 
63 namespace NxWM
64 {
65  /**
66  * One time NSH initialization. This function must be called exactly
67  * once during the boot-up sequence to initialize the NSH library.
68  *
69  * @return True on successful initialization
70  */
71 
72  bool nshlibInitialize(void);
73 
74  /**
75  * This class implements the NxTerm application.
76  */
77 
78  class CNxTerm : public IApplication, private IApplicationCallback
79  {
80  private:
81  CTaskbar *m_taskbar; /**< Reference to the "parent" taskbar */
82  CApplicationWindow *m_window; /**< Reference to the application window */
83  NXTERM m_nxterm; /**< NxTerm handle */
84  pid_t m_pid; /**< Task ID of the NxTerm thread */
85 
86  /**
87  * This is the NxTerm task. This function first redirects output to the
88  * console window then calls to start the NSH logic.
89  */
90 
91  static int nxterm(int argc, char *argv[]);
92 
93  /**
94  * This is the NxTerm task exit handler. It is registered with on_exit()
95  * and called automatically when the nxterm task exits.
96  */
97 
98  static void exitHandler(int code, FAR void *arg);
99 
100  /**
101  * Called when the window minimize button is pressed.
102  */
103 
104  void minimize(void);
105 
106  /**
107  * Called when the window close button is pressed.
108  */
109 
110  void close(void);
111 
112  public:
113  /**
114  * CNxTerm constructor
115  *
116  * @param window. The application window
117  *
118  * @param taskbar. A pointer to the parent task bar instance
119  * @param window. The window to be used by this application.
120  */
121 
122  CNxTerm(CTaskbar *taskbar, CApplicationWindow *window);
123 
124  /**
125  * CNxTerm destructor
126  */
127 
128  ~CNxTerm(void);
129 
130  /**
131  * Each implementation of IApplication must provide a method to recover
132  * the contained CApplicationWindow instance.
133  */
134 
135  IApplicationWindow *getWindow(void) const;
136 
137  /**
138  * Get the icon associated with the application
139  *
140  * @return An instance if IBitmap that may be used to rend the
141  * application's icon. This is an new IBitmap instance that must
142  * be deleted by the caller when it is no long needed.
143  */
144 
146 
147  /**
148  * Get the name string associated with the application
149  *
150  * @return A copy if CNxString that contains the name of the application.
151  */
152 
154 
155  /**
156  * Start the application (perhaps in the minimized state).
157  *
158  * @return True if the application was successfully started.
159  */
160 
161  bool run(void);
162 
163  /**
164  * Stop the application.
165  */
166 
167  void stop(void);
168 
169  /**
170  * Destroy the application and free all of its resources. This method
171  * will initiate blocking of messages from the NX server. The server
172  * will flush the window message queue and reply with the blocked
173  * message. When the block message is received by CWindowMessenger,
174  * it will send the destroy message to the start window task which
175  * will, finally, safely delete the application.
176  */
177 
178  void destroy(void);
179 
180  /**
181  * The application window is hidden (either it is minimized or it is
182  * maximized, but not at the top of the hierarchy
183  */
184 
185  void hide(void);
186 
187  /**
188  * Redraw the entire window. The application has been maximized or
189  * otherwise moved to the top of the hierarchy. This method is call from
190  * CTaskbar when the application window must be displayed
191  */
192 
193  void redraw(void);
194 
195  /**
196  * Report of this is a "normal" window or a full screen window. The
197  * primary purpose of this method is so that window manager will know
198  * whether or not it show draw the task bar.
199  *
200  * @return True if this is a full screen window.
201  */
202 
203  bool isFullScreen(void) const;
204  };
205 
207  {
208  private:
209  CTaskbar *m_taskbar; /**< The taskbar */
210 
211  public:
212  /**
213  * CNxTermFactory Constructor
214  *
215  * @param taskbar. The taskbar instance used to terminate calibration
216  */
217 
218  CNxTermFactory(CTaskbar *taskbar);
219 
220  /**
221  * CNxTermFactory Destructor
222  */
223 
224  inline ~CNxTermFactory(void) { }
225 
226  /**
227  * Create a new instance of an CNxTerm (as IApplication).
228  */
229 
230  IApplication *create(void);
231 
232  /**
233  * Get the icon associated with the application
234  *
235  * @return An instance if IBitmap that may be used to rend the
236  * application's icon. This is an new IBitmap instance that must
237  * be deleted by the caller when it is no long needed.
238  */
239 
241  };
242 }
243 #endif // __cplusplus
244 
245 #endif // __INCLUDE_CNXTERM_HXX
NXWidgets::IBitmap * getIcon(void)
Definition: cnxterm.cxx:188
CTaskbar * m_taskbar
Definition: cnxterm.hxx:81
CTaskbar * m_taskbar
Definition: cnxterm.hxx:209
static int nxterm(int argc, char *argv[])
Definition: cnxterm.cxx:431
bool isFullScreen(void) const
Definition: cnxterm.cxx:421
~CNxTerm(void)
Definition: cnxterm.cxx:157
IApplicationWindow * getWindow(void) const
Definition: cnxterm.cxx:175
void stop(void)
Definition: cnxterm.cxx:316
void redraw(void)
Definition: cnxterm.cxx:391
CApplicationWindow * m_window
Definition: cnxterm.hxx:82
NXTERM m_nxterm
Definition: cnxterm.hxx:83
bool nshlibInitialize(void)
Definition: cnxterm.cxx:653
void hide(void)
Definition: cnxterm.cxx:380
pid_t m_pid
Definition: cnxterm.hxx:84
bool run(void)
Definition: cnxterm.cxx:213
NXWidgets::CNxString getName(void)
Definition: cnxterm.cxx:202
void destroy(void)
Definition: cnxterm.cxx:364
CNxTerm(CTaskbar *taskbar, CApplicationWindow *window)
Definition: cnxterm.cxx:129
void minimize(void)
Definition: cnxterm.cxx:566
void close(void)
Definition: cnxterm.cxx:575
static void exitHandler(int code, FAR void *arg)
Definition: cnxterm.cxx:540