nxtk_internal.h 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. /****************************************************************************
  2. * graphics/nxtk/nxtk_internal.h
  3. *
  4. * Copyright (C) 2008-2009, 2011-1021 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 nor the names of its contributors may be
  18. * 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. #ifndef __GRAPHICS_NXTK_NXTK_INTERNAL_H
  36. #define __GRAPHICS_NXTK_NXTK_INTERNAL_H
  37. /****************************************************************************
  38. * Included Files
  39. ****************************************************************************/
  40. #include <nuttx/config.h>
  41. #include <nuttx/nx/nxtk.h>
  42. #include "nxbe.h"
  43. #include "nxfe.h"
  44. /****************************************************************************
  45. * Pre-processor definitions
  46. ****************************************************************************/
  47. /****************************************************************************
  48. * Public Types
  49. ****************************************************************************/
  50. /* This is the internal representation of the framed window object */
  51. struct nxtk_framedwindow_s
  52. {
  53. struct nxbe_window_s wnd; /* The raw NX window */
  54. /* The toolbar region and callbacks */
  55. nxgl_coord_t tbheight;
  56. struct nxgl_rect_s tbrect;
  57. FAR const struct nx_callback_s *tbcb;
  58. FAR void *tbarg;
  59. /* Window data region and callbacks */
  60. struct nxgl_rect_s fwrect;
  61. FAR const struct nx_callback_s *fwcb;
  62. FAR void *fwarg;
  63. /* Initial mouse down location */
  64. uint8_t mbutton;
  65. struct nxgl_point_s mpos;
  66. };
  67. /****************************************************************************
  68. * Public Data
  69. ****************************************************************************/
  70. #undef EXTERN
  71. #if defined(__cplusplus)
  72. # define EXTERN extern "C"
  73. extern "C" {
  74. #else
  75. # define EXTERN extern
  76. #endif
  77. /* That is the callback for the framed window */
  78. extern FAR const struct nx_callback_s g_nxtkcb;
  79. /* Frame border colors */
  80. extern nxgl_mxpixel_t g_bordercolor1[CONFIG_NX_NPLANES];
  81. extern nxgl_mxpixel_t g_bordercolor2[CONFIG_NX_NPLANES];
  82. extern nxgl_mxpixel_t g_bordercolor3[CONFIG_NX_NPLANES];
  83. /****************************************************************************
  84. * Public Function Prototypes
  85. ****************************************************************************/
  86. /****************************************************************************
  87. * Name: nxtk_setsubwindows
  88. *
  89. * Description:
  90. * Give the window dimensions, border width, and toolbar height,
  91. * calculate the new dimensions of the toolbar region and client window
  92. * region
  93. *
  94. ****************************************************************************/
  95. EXTERN void nxtk_setsubwindows(FAR struct nxtk_framedwindow_s *fwnd);
  96. /****************************************************************************
  97. * Name: nxtk_subwindowclip
  98. *
  99. * Description:
  100. * Clip the src rectangle so that it lies within the sub-window bounds
  101. * then move the rectangle to that it is relative to the containing
  102. * window.
  103. *
  104. * Input parameters:
  105. * fwnd - The framed window to be used
  106. * dest - The locaton to put the result
  107. * src - The src rectangle in relative sub-window coordinates
  108. * bounds - The subwindow bounds in absolute screen coordinates.
  109. *
  110. * Returned value:
  111. * None
  112. *
  113. ****************************************************************************/
  114. EXTERN void nxtk_subwindowclip(FAR struct nxtk_framedwindow_s *fwnd,
  115. FAR struct nxgl_rect_s *dest,
  116. FAR const struct nxgl_rect_s *src,
  117. FAR const struct nxgl_rect_s *bounds);
  118. /****************************************************************************
  119. * Name: nxtk_containerclip
  120. *
  121. * Description:
  122. * We are given a 'src' rectangle in containing window, relative coordinates
  123. * (i.e., (0,0) is the top left corner of the outer, containing window).
  124. * This function will (1) clip that src rectangle so that it lies within
  125. * the sub-window bounds, and then (2) move the rectangle to that it is
  126. * relative to the sub-window (i.e., (0,0) is the top left corner of the
  127. * sub-window).
  128. *
  129. * Input parameters:
  130. * fwnd - The framed window to be used
  131. * dest - The locaton to put the result
  132. * src - The src rectangle in relative container-window coordinates
  133. * bounds - The subwindow bounds in absolute screen coordinates.
  134. *
  135. * Returned value:
  136. * None
  137. *
  138. ****************************************************************************/
  139. EXTERN void nxtk_containerclip(FAR struct nxtk_framedwindow_s *fwnd,
  140. FAR struct nxgl_rect_s *dest,
  141. FAR const struct nxgl_rect_s *src,
  142. FAR const struct nxgl_rect_s *bounds);
  143. /****************************************************************************
  144. * Name: nxtk_subwindowmove
  145. *
  146. * Description:
  147. * Perform common clipping operations in preparatons for calling nx_move()
  148. *
  149. * Input Parameters:
  150. * fwnd - The framed window within which the move is to be done.
  151. * This must have been previously created by nxtk_openwindow().
  152. * destrect - The loccation to receive the clipped rectangle relative
  153. * to containing window
  154. * destoffset - The location to received the clipped offset.
  155. * srcrect - Describes the rectangular region relative to the client
  156. * sub-window to move relative to the sub-window
  157. * srcoffset - The offset to move the region
  158. * bounds - The subwindow bounds in absolute screen coordinates.
  159. *
  160. * Return:
  161. * OK on success; ERROR on failure with errno set appropriately
  162. *
  163. ****************************************************************************/
  164. EXTERN void nxtk_subwindowmove(FAR struct nxtk_framedwindow_s *fwnd,
  165. FAR struct nxgl_rect_s *destrect,
  166. FAR struct nxgl_point_s *destoffset,
  167. FAR const struct nxgl_rect_s *srcrect,
  168. FAR const struct nxgl_point_s *srcoffset,
  169. FAR const struct nxgl_rect_s *bounds);
  170. /****************************************************************************
  171. * Name: nxtk_drawframe
  172. *
  173. * Description:
  174. * Redraw the window frame.
  175. *
  176. * Input parameters:
  177. * fwnd - the framed window whose frame needs to be re-drawn. This must
  178. * have been previously created by nxtk_openwindow().
  179. * bounds - Only draw the ports of the frame within this bounding box.
  180. * (window relative coordinates).
  181. *
  182. * Returned value:
  183. * OK on success; ERROR on failure with errno set appropriately
  184. *
  185. ****************************************************************************/
  186. EXTERN int nxtk_drawframe(FAR struct nxtk_framedwindow_s *fwnd,
  187. FAR const struct nxgl_rect_s *bounds);
  188. #undef EXTERN
  189. #if defined(__cplusplus)
  190. }
  191. #endif
  192. #endif /* __GRAPHICS_NXTK_NXTK_INTERNAL_H */