iapplication.hxx 7.0 KB

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