capplicationwindow.hxx 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. /****************************************************************************
  2. * apps/include/graphics/nxwm/capplicationwindow.hxx
  3. *
  4. * Licensed to the Apache Software Foundation (ASF) under one or more
  5. * contributor license agreements. See the NOTICE file distributed with
  6. * this work for additional information regarding copyright ownership. The
  7. * ASF licenses this file to you under the Apache License, Version 2.0 (the
  8. * "License"); you may not use this file except in compliance with the
  9. * License. You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  15. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  16. * License for the specific language governing permissions and limitations
  17. * under the License.
  18. *
  19. ****************************************************************************/
  20. #ifndef __APPS_INCLUDE_GRAPHICS_NXWM_CAPPLICATIONWINDOW_NXX
  21. #define __APPS_INCLUDE_GRAPHICS_NXWM_CAPPLICATIONWINDOW_NXX
  22. /****************************************************************************
  23. * Included Files
  24. ****************************************************************************/
  25. #include <nuttx/config.h>
  26. #include "graphics/nxwidgets/cnxtkwindow.hxx"
  27. #include "graphics/nxwidgets/cnxtoolbar.hxx"
  28. #include "graphics/nxwidgets/cwidgetcontrol.hxx"
  29. #include "graphics/nxwidgets/cwidgeteventargs.hxx"
  30. #include "graphics/nxwidgets/cwidgeteventhandler.hxx"
  31. #include "graphics/nxwidgets/cimage.hxx"
  32. #include "graphics/nxwidgets/clabel.hxx"
  33. #include "graphics/nxwidgets/crlepalettebitmap.hxx"
  34. #include "graphics/nxwm/iapplicationwindow.hxx"
  35. /****************************************************************************
  36. * Pre-Processor Definitions
  37. ****************************************************************************/
  38. /****************************************************************************
  39. * Implementation Classes
  40. ****************************************************************************/
  41. #if defined(__cplusplus)
  42. namespace NxWM
  43. {
  44. /**
  45. * This class represents that application window. This class contains that the
  46. * framed window and its toolbar. It manages callbacks from the toolbar minimize
  47. * and close buttions and passes these to the application via callbacks.
  48. */
  49. class CApplicationWindow : public IApplicationWindow,
  50. private NXWidgets::CWidgetEventHandler
  51. {
  52. public:
  53. /**
  54. * Enumeration describing the bit settings for each window flag
  55. */
  56. enum EWindowFlags
  57. {
  58. WINDOW_PERSISTENT = 0x01 /**< Persistent windows have no stop button */
  59. };
  60. protected:
  61. NXWidgets::CNxTkWindow *m_window; /**< The framed window used by the application */
  62. NXWidgets::CNxToolbar *m_toolbar; /**< The toolbar */
  63. NXWidgets::CImage *m_minimizeImage; /**< The minimize icon */
  64. NXWidgets::CImage *m_stopImage; /**< The close icon */
  65. NXWidgets::CLabel *m_windowLabel; /**< The window title */
  66. NXWidgets::CRlePaletteBitmap *m_minimizeBitmap; /**< The minimize icon bitmap */
  67. NXWidgets::CRlePaletteBitmap *m_stopBitmap; /**< The stop icon bitmap */
  68. NXWidgets::CNxFont *m_windowFont; /**< The font used to rend the window label */
  69. IApplicationCallback *m_callback; /**< Toolbar action callbacks */
  70. uint8_t m_flags; /**< Window flags */
  71. /**
  72. * Handle a widget action event. For CImage, this is a mouse button pre-release event.
  73. *
  74. * @param e The event data.
  75. */
  76. void handleActionEvent(const NXWidgets::CWidgetEventArgs &e);
  77. public:
  78. /**
  79. * CApplicationWindow Constructor
  80. *
  81. * @param window. The window to be used by this application.
  82. * @param flags. Optional flags to control the window configuration (See EWindowFlags).
  83. */
  84. CApplicationWindow(NXWidgets::CNxTkWindow *window, uint8_t flags = 0);
  85. /**
  86. * CApplicationWindow Destructor
  87. */
  88. ~CApplicationWindow(void);
  89. /**
  90. * Initialize window. Window initialization is separate from
  91. * object instantiation so that failures can be reported.
  92. *
  93. * @return True if the window was successfully initialized.
  94. */
  95. bool open(void);
  96. /**
  97. * Re-draw the application window
  98. */
  99. void redraw(void);
  100. /**
  101. * The application window is hidden (either it is minimized or it is
  102. * maximized, but not at the top of the hierarchy)
  103. */
  104. void hide(void);
  105. /**
  106. * Recover the contained NXTK window instance
  107. *
  108. * @return. The window used by this application
  109. */
  110. NXWidgets::INxWindow *getWindow(void) const;
  111. /**
  112. * Recover the contained widget control
  113. *
  114. * @return. The widget control used by this application
  115. */
  116. NXWidgets::CWidgetControl *getWidgetControl(void) const;
  117. /**
  118. * Block further activity on this window in preparation for window
  119. * shutdown.
  120. *
  121. * @param app. The application to be blocked
  122. */
  123. void block(IApplication *app);
  124. /**
  125. * Set the window label
  126. *
  127. * @param appname. The name of the application to place on the window
  128. */
  129. void setWindowLabel(NXWidgets::CNxString &appname);
  130. /**
  131. * Report of this is a "normal" window or a full screen window. The
  132. * primary purpose of this method is so that window manager will know
  133. * whether or not it show draw the task bar.
  134. *
  135. * @return True if this is a full screen window.
  136. */
  137. bool isFullScreen(void) const;
  138. /**
  139. * Register to receive callbacks when toolbar icons are selected
  140. */
  141. void registerCallbacks(IApplicationCallback *callback);
  142. /**
  143. * Check if this window is configured for a persistent application (i.e.,
  144. * an application that has no STOP icon
  145. *
  146. * @return True if the window is configured for a persistent application.
  147. */
  148. inline bool isPersistent(void) const
  149. {
  150. return (m_flags & WINDOW_PERSISTENT) != 0;
  151. }
  152. };
  153. }
  154. #endif // __cplusplus
  155. #endif // __APPS_INCLUDE_GRAPHICS_NXWM_CAPPLICATIONWINDOW_NXX