From f4f53db66c932a9a0002a9dd3041e5323bad67c1 Mon Sep 17 00:00:00 2001 From: patacongo Date: Thu, 4 Dec 2008 12:57:22 +0000 Subject: [PATCH] Removed superfluous toolbar handle git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@1412 7fd9a85b-ad96-42d3-883c-3090e2eb8679 --- nuttx/examples/nx/nx_events.c | 2 +- nuttx/examples/nx/nx_main.c | 24 ++++--- nuttx/graphics/nxtk/nxtk_bitmaptoolbar.c | 10 +-- nuttx/graphics/nxtk/nxtk_closetoolbar.c | 6 +- nuttx/graphics/nxtk/nxtk_filltoolbar.c | 10 +-- nuttx/graphics/nxtk/nxtk_filltraptoolbar.c | 10 +-- nuttx/graphics/nxtk/nxtk_movetoolbar.c | 13 ++-- nuttx/graphics/nxtk/nxtk_opentoolbar.c | 13 ++-- nuttx/include/nuttx/nxtk.h | 75 +++++++++++++++++----- 9 files changed, 103 insertions(+), 60 deletions(-) diff --git a/nuttx/examples/nx/nx_events.c b/nuttx/examples/nx/nx_events.c index 864b267c8..083bb0f03 100644 --- a/nuttx/examples/nx/nx_events.c +++ b/nuttx/examples/nx/nx_events.c @@ -166,7 +166,7 @@ static inline void nxeg_fillwindow(NXEGWINDOW hwnd, ****************************************************************************/ #ifndef CONFIG_EXAMPLES_NX_RAWWINDOWS -static inline void nxeg_filltoolbar(NXTKTOOLBAR htb, +static inline void nxeg_filltoolbar(NXTKWINDOW htb, FAR const struct nxgl_rect_s *rect, nxgl_mxpixel_t color[CONFIG_NX_NPLANES]) { diff --git a/nuttx/examples/nx/nx_main.c b/nuttx/examples/nx/nx_main.c index ed7b7a3bb..bc4bd0abe 100644 --- a/nuttx/examples/nx/nx_main.c +++ b/nuttx/examples/nx/nx_main.c @@ -256,18 +256,18 @@ static inline int nxeg_setposition(NXTKWINDOW hwnd, FAR struct nxgl_point_s *pos ****************************************************************************/ #ifndef CONFIG_EXAMPLES_NX_RAWWINDOWS -static inline NXTKTOOLBAR nxeq_opentoolbar(NXTKWINDOW hwnd, nxgl_coord_t height, - FAR const struct nx_callback_s *cb, - FAR void *arg) +static inline int nxeq_opentoolbar(NXTKWINDOW hwnd, nxgl_coord_t height, + FAR const struct nx_callback_s *cb, + FAR void *arg) { - NXTKTOOLBAR htb; - htb = nxtk_opentoolbar(hwnd, height, cb, arg); - if (!htb < 0) + int ret; + ret = nxtk_opentoolbar(hwnd, height, cb, arg); + if (ret < 0) { message("user_start: nxtk_opentoolbar failed: %d\n", errno); g_exitcode = NXEXIT_NXOPENTOOLBAR; } - return htb; + return ret; } #endif @@ -505,8 +505,6 @@ int user_start(int argc, char *argv[]) #else NXTKWINDOW hwnd1; NXTKWINDOW hwnd2; - NXTKTOOLBAR htb1; - NXTKTOOLBAR htb2; #endif struct nxgl_size_s size; struct nxgl_point_s pt; @@ -595,8 +593,8 @@ int user_start(int argc, char *argv[]) #ifndef CONFIG_EXAMPLES_NX_RAWWINDOWS message("user_start: Add toolbar to window #1\n"); - htb1 = nxeq_opentoolbar(hwnd1, CONFIG_TOOLBAR_HEIGHT, &g_tbcb, (FAR void*)1); - if (!htb1) + ret = nxeq_opentoolbar(hwnd1, CONFIG_TOOLBAR_HEIGHT, &g_tbcb, (FAR void*)1); + if (ret < 0) { goto errout_with_hwnd1; } @@ -655,8 +653,8 @@ int user_start(int argc, char *argv[]) #ifndef CONFIG_EXAMPLES_NX_RAWWINDOWS message("user_start: Add toolbar to window #2\n"); - htb2 = nxeq_opentoolbar(hwnd2, CONFIG_TOOLBAR_HEIGHT, &g_tbcb, (FAR void*)2); - if (!htb2) + ret = nxeq_opentoolbar(hwnd2, CONFIG_TOOLBAR_HEIGHT, &g_tbcb, (FAR void*)2); + if (ret < 0) { goto errout_with_hwnd2; } diff --git a/nuttx/graphics/nxtk/nxtk_bitmaptoolbar.c b/nuttx/graphics/nxtk/nxtk_bitmaptoolbar.c index 6b5769e88..dde83d9ef 100644 --- a/nuttx/graphics/nxtk/nxtk_bitmaptoolbar.c +++ b/nuttx/graphics/nxtk/nxtk_bitmaptoolbar.c @@ -80,7 +80,7 @@ * specified toolbar sub-window. * * Input Parameters: - * htb - The toolbar sub-window that will receive the bitmap image + * hfwnd - The sub-window twhose toolbar will receive the bitmap image * dest - Describes the rectangular region on in the toolbar sub-window * will receive the bit map. * src - The start of the source image. @@ -94,15 +94,15 @@ * ****************************************************************************/ -int nxtk_bitmaptoolbar(NXTKWINDOW htb, FAR const struct nxgl_rect_s *dest, +int nxtk_bitmaptoolbar(NXTKWINDOW hfwnd, FAR const struct nxgl_rect_s *dest, FAR const void *src[CONFIG_NX_NPLANES], FAR const struct nxgl_point_s *origin, unsigned int stride) { - FAR struct nxtk_framedwindow_s *fwnd = (FAR struct nxtk_framedwindow_s *)htb; + FAR struct nxtk_framedwindow_s *fwnd = (FAR struct nxtk_framedwindow_s *)hfwnd; struct nxgl_rect_s clipdest; #ifdef CONFIG_DEBUG - if (!htb || !dest || !src || !origin) + if (!hfwnd || !dest || !src || !origin) { errno = EINVAL; return ERROR; @@ -118,6 +118,6 @@ int nxtk_bitmaptoolbar(NXTKWINDOW htb, FAR const struct nxgl_rect_s *dest, /* Then copy the bitmap */ - nx_bitmap((NXWINDOW)htb, &clipdest, src, origin, stride); + nx_bitmap((NXWINDOW)hfwnd, &clipdest, src, origin, stride); return OK; } diff --git a/nuttx/graphics/nxtk/nxtk_closetoolbar.c b/nuttx/graphics/nxtk/nxtk_closetoolbar.c index 2cd44dfc3..e7557aeba 100644 --- a/nuttx/graphics/nxtk/nxtk_closetoolbar.c +++ b/nuttx/graphics/nxtk/nxtk_closetoolbar.c @@ -81,16 +81,16 @@ * Create a tool bar at the top of the specified framed window * * Input Parameters: - * htb - The toolbar handle returned by nxtk_opentoolbar + * hfwnd - The handle returned by nxtk_openwindow * * Return: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ -int nxtk_closetoolbar(NXTKTOOLBAR htb) +int nxtk_closetoolbar(NXTKWINDOW hfwnd) { - FAR struct nxtk_framedwindow_s *fwnd = (FAR struct nxtk_framedwindow_s *)htb; + FAR struct nxtk_framedwindow_s *fwnd = (FAR struct nxtk_framedwindow_s *)hfwnd; /* Un-initialize the toolbar info */ diff --git a/nuttx/graphics/nxtk/nxtk_filltoolbar.c b/nuttx/graphics/nxtk/nxtk_filltoolbar.c index 73760be24..946cfd076 100644 --- a/nuttx/graphics/nxtk/nxtk_filltoolbar.c +++ b/nuttx/graphics/nxtk/nxtk_filltoolbar.c @@ -81,7 +81,7 @@ * Fill the specified rectangle in the client window with the specified color * * Input Parameters: - * htb - The toolbar handle returned by nxtk_opentoolbar + * hfwnd - The handle returned by nxtk_openwindow * rect - The location within the toolbar window to be filled * color - The color to use in the fill * @@ -90,14 +90,14 @@ * ****************************************************************************/ -int nxtk_filltoolbar(NXTKTOOLBAR htb, FAR const struct nxgl_rect_s *rect, +int nxtk_filltoolbar(NXTKWINDOW hfwnd, FAR const struct nxgl_rect_s *rect, nxgl_mxpixel_t color[CONFIG_NX_NPLANES]) { - FAR struct nxtk_framedwindow_s *fwnd = (FAR struct nxtk_framedwindow_s *)htb; + FAR struct nxtk_framedwindow_s *fwnd = (FAR struct nxtk_framedwindow_s *)hfwnd; struct nxgl_rect_s fillrect; #ifdef CONFIG_DEBUG - if (!htb || !rect || !color) + if (!hfwnd || !rect || !color) { errno = EINVAL; return ERROR; @@ -113,5 +113,5 @@ int nxtk_filltoolbar(NXTKTOOLBAR htb, FAR const struct nxgl_rect_s *rect, /* Then fill it */ - return nx_fill((NXWINDOW)htb, &fillrect, color); + return nx_fill((NXWINDOW)hfwnd, &fillrect, color); } diff --git a/nuttx/graphics/nxtk/nxtk_filltraptoolbar.c b/nuttx/graphics/nxtk/nxtk_filltraptoolbar.c index 526dfec8f..03e9c749c 100644 --- a/nuttx/graphics/nxtk/nxtk_filltraptoolbar.c +++ b/nuttx/graphics/nxtk/nxtk_filltraptoolbar.c @@ -81,7 +81,7 @@ * Fill the specified rectangle in the toolbar with the specified color * * Input Parameters: - * htb - The window handle returned by nxtk_openwindow + * hfwnd - The handle returned by nxtk_openwindow * trap - The trapezoidal region to be filled * color - The color to use in the fill * @@ -90,14 +90,14 @@ * ****************************************************************************/ -int nxtk_filltraptoolbar(NXTKTOOLBAR htb, FAR const struct nxgl_trapezoid_s *trap, +int nxtk_filltraptoolbar(NXTKWINDOW hfwnd, FAR const struct nxgl_trapezoid_s *trap, nxgl_mxpixel_t color[CONFIG_NX_NPLANES]) { - FAR struct nxtk_framedwindow_s *fwnd = (FAR struct nxtk_framedwindow_s *)htb; + FAR struct nxtk_framedwindow_s *fwnd = (FAR struct nxtk_framedwindow_s *)hfwnd; struct nxgl_rect_s relclip; #ifdef CONFIG_DEBUG - if (!htb || !trap || !color) + if (!hfwnd || !trap || !color) { errno = EINVAL; return ERROR; @@ -107,5 +107,5 @@ int nxtk_filltraptoolbar(NXTKTOOLBAR htb, FAR const struct nxgl_trapezoid_s *tra /* Perform the fill, clipping to the client window */ nxgl_rectoffset(&relclip, &fwnd->tbrect, -fwnd->wnd.bounds.pt1.x, -fwnd->wnd.bounds.pt1.y); - return nx_filltrapezoid((NXWINDOW)htb, &relclip, trap, color); + return nx_filltrapezoid((NXWINDOW)hfwnd, &relclip, trap, color); } diff --git a/nuttx/graphics/nxtk/nxtk_movetoolbar.c b/nuttx/graphics/nxtk/nxtk_movetoolbar.c index 78a20b54e..6e464c375 100644 --- a/nuttx/graphics/nxtk/nxtk_movetoolbar.c +++ b/nuttx/graphics/nxtk/nxtk_movetoolbar.c @@ -81,8 +81,9 @@ * Move a rectangular region within the toolbar sub-window of a framed window * * Input Parameters: - * htb - The toolbar sub-window within which the move is to be done. - * This must have been previously created by nxtk_openwindow(). + * hfwnd - The sub-window containing the toolbar within which the move is + * to be done. This must have been previously created by + * nxtk_openwindow(). * rect - Describes the rectangular region relative to the toolbar * sub-window to move * offset - The offset to move the region @@ -92,15 +93,15 @@ * ****************************************************************************/ -int nxtk_movetoolbar(NXTKTOOLBAR htb, FAR const struct nxgl_rect_s *rect, +int nxtk_movetoolbar(NXTKWINDOW hfwnd, FAR const struct nxgl_rect_s *rect, FAR const struct nxgl_point_s *offset) { - FAR struct nxtk_framedwindow_s *fwnd = (FAR struct nxtk_framedwindow_s *)htb; + FAR struct nxtk_framedwindow_s *fwnd = (FAR struct nxtk_framedwindow_s *)hfwnd; struct nxgl_rect_s srcrect; struct nxgl_point_s clipoffset; #ifdef CONFIG_DEBUG - if (!htb || !rect || !offset) + if (!hfwnd || !rect || !offset) { errno = EINVAL; return ERROR; @@ -115,5 +116,5 @@ int nxtk_movetoolbar(NXTKTOOLBAR htb, FAR const struct nxgl_rect_s *rect, /* Then move it within the toolbar window */ - return nx_move((NXTKTOOLBAR)htb, &srcrect, &clipoffset); + return nx_move((NXWINDOW)hfwnd, &srcrect, &clipoffset); } diff --git a/nuttx/graphics/nxtk/nxtk_opentoolbar.c b/nuttx/graphics/nxtk/nxtk_opentoolbar.c index 315e72a5a..64525b766 100644 --- a/nuttx/graphics/nxtk/nxtk_opentoolbar.c +++ b/nuttx/graphics/nxtk/nxtk_opentoolbar.c @@ -87,14 +87,13 @@ * arg - User provided value that will be returned with toolbar callbacks. * * Return: - * Success: A non-NULL handle used with subsequent NXTK toolbar accesses - * Failure: NULL is returned and errno is set appropriately + * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ -NXTKTOOLBAR nxtk_opentoolbar(NXTKWINDOW hfwnd, nxgl_coord_t height, - FAR const struct nx_callback_s *cb, - FAR void *arg) +int nxtk_opentoolbar(NXTKWINDOW hfwnd, nxgl_coord_t height, + FAR const struct nx_callback_s *cb, + FAR void *arg) { FAR struct nxtk_framedwindow_s *fwnd = (FAR struct nxtk_framedwindow_s *)hfwnd; @@ -102,7 +101,7 @@ NXTKTOOLBAR nxtk_opentoolbar(NXTKWINDOW hfwnd, nxgl_coord_t height, if (!hfwnd || !cb) { errno = EINVAL; - return NULL; + return ERROR; } #endif @@ -124,6 +123,6 @@ NXTKTOOLBAR nxtk_opentoolbar(NXTKWINDOW hfwnd, nxgl_coord_t height, /* Return the initialized toolbar reference */ - return (NXTKTOOLBAR)fwnd; + return OK; } diff --git a/nuttx/include/nuttx/nxtk.h b/nuttx/include/nuttx/nxtk.h index 44ba800af..7cfb61ac5 100644 --- a/nuttx/include/nuttx/nxtk.h +++ b/nuttx/include/nuttx/nxtk.h @@ -57,10 +57,6 @@ typedef FAR void *NXTKWINDOW; -/* This is the handle that can be used to access the window toolbar */ - -typedef FAR void *NXTKTOOLBAR; - /**************************************************************************** * Public Data ****************************************************************************/ @@ -307,14 +303,13 @@ EXTERN int nxtk_bitmapwindow(NXTKWINDOW hfwnd, * arg - User provided value that will be returned with toolbar callbacks. * * Return: - * Success: A non-NULL handle used with subsequent NXTK toolbar accesses - * Failure: NULL is returned and errno is set appropriately + * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ -EXTERN NXTKTOOLBAR nxtk_opentoolbar(NXTKWINDOW hfwnd, nxgl_coord_t height, - FAR const struct nx_callback_s *cb, - FAR void *arg); +EXTERN int nxtk_opentoolbar(NXTKWINDOW hfwnd, nxgl_coord_t height, + FAR const struct nx_callback_s *cb, + FAR void *arg); /**************************************************************************** * Name: nxtk_closetoolbar @@ -323,14 +318,14 @@ EXTERN NXTKTOOLBAR nxtk_opentoolbar(NXTKWINDOW hfwnd, nxgl_coord_t height, * Create a tool bar at the top of the specified framed window * * Input Parameters: - * htb - The toolbar handle returned by nxtk_opentoolbar + * hfwnd - The handle returned by nxtk_openwindow * * Return: * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ -EXTERN int nxtk_closetoolbar(NXTKTOOLBAR htb); +EXTERN int nxtk_closetoolbar(NXTKWINDOW hfwnd); /**************************************************************************** * Name: nxtk_filltoolbar @@ -339,7 +334,7 @@ EXTERN int nxtk_closetoolbar(NXTKTOOLBAR htb); * Fill the specified rectangle in the client window with the specified color * * Input Parameters: - * htb - The toolbar handle returned by nxtk_opentoolbar + * hfwnd - The handle returned by nxtk_openwindow * rect - The location within the toolbar window to be filled * color - The color to use in the fill * @@ -348,7 +343,7 @@ EXTERN int nxtk_closetoolbar(NXTKTOOLBAR htb); * ****************************************************************************/ -EXTERN int nxtk_filltoolbar(NXTKTOOLBAR htb, FAR const struct nxgl_rect_s *rect, +EXTERN int nxtk_filltoolbar(NXTKWINDOW hfwnd, FAR const struct nxgl_rect_s *rect, nxgl_mxpixel_t color[CONFIG_NX_NPLANES]); /**************************************************************************** @@ -358,7 +353,7 @@ EXTERN int nxtk_filltoolbar(NXTKTOOLBAR htb, FAR const struct nxgl_rect_s *rect, * Fill the specified rectangle in the toolbar with the specified color * * Input Parameters: - * htb - The window handle returned by nxtk_openwindow + * hfwnd - The handle returned by nxtk_openwindow * trap - The trapezoidal region to be filled * color - The color to use in the fill * @@ -367,8 +362,58 @@ EXTERN int nxtk_filltoolbar(NXTKTOOLBAR htb, FAR const struct nxgl_rect_s *rect, * ****************************************************************************/ -EXTERN int nxtk_filltraptoolbar(NXTKTOOLBAR htb, FAR const struct nxgl_trapezoid_s *trap, +EXTERN int nxtk_filltraptoolbar(NXTKWINDOW hfwnd, FAR const struct nxgl_trapezoid_s *trap, nxgl_mxpixel_t color[CONFIG_NX_NPLANES]); +/**************************************************************************** + * Name: nxtk_movetoolbar + * + * Description: + * Move a rectangular region within the toolbar sub-window of a framed window + * + * Input Parameters: + * hfwnd - The sub-window containing the toolbar within which the move is + * to be done. This must have been previously created by + * nxtk_openwindow(). + * rect - Describes the rectangular region relative to the toolbar + * sub-window to move + * offset - The offset to move the region + * + * Return: + * OK on success; ERROR on failure with errno set appropriately + * + ****************************************************************************/ + +EXTERN int nxtk_movetoolbar(NXTKWINDOW hfwnd, FAR const struct nxgl_rect_s *rect, + FAR const struct nxgl_point_s *offset); + +/**************************************************************************** + * Name: nxtk_bitmaptoolbar + * + * Description: + * Copy a rectangular region of a larger image into the rectangle in the + * specified toolbar sub-window. + * + * Input Parameters: + * hfwnd - The sub-window twhose toolbar will receive the bitmap image + * dest - Describes the rectangular region on in the toolbar sub-window + * will receive the bit map. + * src - The start of the source image. + * origin - The origin of the upper, left-most corner of the full bitmap. + * Both dest and origin are in window coordinates, however, origin + * may lie outside of the display. + * stride - The width of the full source image in pixels. + * + * Return: + * OK on success; ERROR on failure with errno set appropriately + * + ****************************************************************************/ + +EXTERN int nxtk_bitmaptoolbar(NXTKWINDOW hfwnd, + FAR const struct nxgl_rect_s *dest, + FAR const void *src[CONFIG_NX_NPLANES], + FAR const struct nxgl_point_s *origin, + unsigned int stride); + #undef EXTERN #if defined(__cplusplus) }