From 212ec1530e550b6d4a4a5088dc45a8f8315e3e20 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sat, 28 Dec 2013 11:33:21 -0600 Subject: Move graphics/nxtk to libnx/nxtk --- nuttx/ChangeLog | 1 + nuttx/Documentation/NXGraphicsSubsystem.html | 7 +- nuttx/graphics/Makefile | 8 +- nuttx/graphics/README.txt | 4 +- nuttx/graphics/nxmu/nxfe.h | 33 --- nuttx/graphics/nxmu/nxmu_redrawreq.c | 1 - nuttx/graphics/nxmu/nxmu_server.c | 9 +- nuttx/graphics/nxsu/Make.defs | 7 +- nuttx/graphics/nxsu/nx_constructwindow.c | 152 ++++++++++++ nuttx/graphics/nxsu/nx_openwindow.c | 4 +- nuttx/graphics/nxsu/nx_redrawreq.c | 93 ++++++++ nuttx/graphics/nxsu/nxfe.h | 31 --- nuttx/graphics/nxsu/nxsu_constructwindow.c | 152 ------------ nuttx/graphics/nxsu/nxsu_redrawreq.c | 6 +- nuttx/graphics/nxtk/Make.defs | 48 ---- nuttx/graphics/nxtk/nxtk_bitmaptoolbar.c | 137 ----------- nuttx/graphics/nxtk/nxtk_bitmapwindow.c | 137 ----------- nuttx/graphics/nxtk/nxtk_block.c | 109 --------- nuttx/graphics/nxtk/nxtk_closetoolbar.c | 111 --------- nuttx/graphics/nxtk/nxtk_closewindow.c | 95 -------- nuttx/graphics/nxtk/nxtk_containerclip.c | 122 ---------- nuttx/graphics/nxtk/nxtk_drawcircletoolbar.c | 145 ------------ nuttx/graphics/nxtk/nxtk_drawcirclewindow.c | 145 ------------ nuttx/graphics/nxtk/nxtk_drawframe.c | 310 ------------------------- nuttx/graphics/nxtk/nxtk_drawlinetoolbar.c | 139 ----------- nuttx/graphics/nxtk/nxtk_drawlinewindow.c | 138 ----------- nuttx/graphics/nxtk/nxtk_events.c | 332 --------------------------- nuttx/graphics/nxtk/nxtk_fillcircletoolbar.c | 115 ---------- nuttx/graphics/nxtk/nxtk_fillcirclewindow.c | 115 ---------- nuttx/graphics/nxtk/nxtk_filltoolbar.c | 116 ---------- nuttx/graphics/nxtk/nxtk_filltraptoolbar.c | 110 --------- nuttx/graphics/nxtk/nxtk_filltrapwindow.c | 117 ---------- nuttx/graphics/nxtk/nxtk_fillwindow.c | 116 ---------- nuttx/graphics/nxtk/nxtk_getposition.c | 95 -------- nuttx/graphics/nxtk/nxtk_gettoolbar.c | 123 ---------- nuttx/graphics/nxtk/nxtk_getwindow.c | 126 ---------- nuttx/graphics/nxtk/nxtk_internal.h | 225 ------------------ nuttx/graphics/nxtk/nxtk_lower.c | 95 -------- nuttx/graphics/nxtk/nxtk_movetoolbar.c | 119 ---------- nuttx/graphics/nxtk/nxtk_movewindow.c | 118 ---------- nuttx/graphics/nxtk/nxtk_opentoolbar.c | 127 ---------- nuttx/graphics/nxtk/nxtk_openwindow.c | 160 ------------- nuttx/graphics/nxtk/nxtk_raise.c | 95 -------- nuttx/graphics/nxtk/nxtk_setposition.c | 107 --------- nuttx/graphics/nxtk/nxtk_setsize.c | 114 --------- nuttx/graphics/nxtk/nxtk_setsubwindows.c | 165 ------------- nuttx/graphics/nxtk/nxtk_subwindowclip.c | 118 ---------- nuttx/graphics/nxtk/nxtk_subwindowmove.c | 149 ------------ nuttx/graphics/nxtk/nxtk_toolbarbounds.c | 107 --------- nuttx/include/nuttx/nx/nx.h | 158 +++++++++---- nuttx/include/nuttx/nx/nxmu.h | 26 ++- nuttx/libnx/Makefile | 1 + nuttx/libnx/nxmu/Make.defs | 5 +- nuttx/libnx/nxmu/nx_constructwindow.c | 139 +++++++++++ nuttx/libnx/nxmu/nx_openwindow.c | 4 +- nuttx/libnx/nxmu/nx_redrawreq.c | 111 +++++++++ nuttx/libnx/nxmu/nxmu_constructwindow.c | 139 ----------- nuttx/libnx/nxtk/Make.defs | 60 +++++ nuttx/libnx/nxtk/nxtk_bitmaptoolbar.c | 137 +++++++++++ nuttx/libnx/nxtk/nxtk_bitmapwindow.c | 137 +++++++++++ nuttx/libnx/nxtk/nxtk_block.c | 108 +++++++++ nuttx/libnx/nxtk/nxtk_closetoolbar.c | 109 +++++++++ nuttx/libnx/nxtk/nxtk_closewindow.c | 93 ++++++++ nuttx/libnx/nxtk/nxtk_containerclip.c | 121 ++++++++++ nuttx/libnx/nxtk/nxtk_drawcircletoolbar.c | 145 ++++++++++++ nuttx/libnx/nxtk/nxtk_drawcirclewindow.c | 145 ++++++++++++ nuttx/libnx/nxtk/nxtk_drawframe.c | 309 +++++++++++++++++++++++++ nuttx/libnx/nxtk/nxtk_drawlinetoolbar.c | 139 +++++++++++ nuttx/libnx/nxtk/nxtk_drawlinewindow.c | 138 +++++++++++ nuttx/libnx/nxtk/nxtk_events.c | 332 +++++++++++++++++++++++++++ nuttx/libnx/nxtk/nxtk_fillcircletoolbar.c | 115 ++++++++++ nuttx/libnx/nxtk/nxtk_fillcirclewindow.c | 115 ++++++++++ nuttx/libnx/nxtk/nxtk_filltoolbar.c | 115 ++++++++++ nuttx/libnx/nxtk/nxtk_filltraptoolbar.c | 111 +++++++++ nuttx/libnx/nxtk/nxtk_filltrapwindow.c | 119 ++++++++++ nuttx/libnx/nxtk/nxtk_fillwindow.c | 115 ++++++++++ nuttx/libnx/nxtk/nxtk_getposition.c | 94 ++++++++ nuttx/libnx/nxtk/nxtk_gettoolbar.c | 122 ++++++++++ nuttx/libnx/nxtk/nxtk_getwindow.c | 125 ++++++++++ nuttx/libnx/nxtk/nxtk_internal.h | 225 ++++++++++++++++++ nuttx/libnx/nxtk/nxtk_lower.c | 94 ++++++++ nuttx/libnx/nxtk/nxtk_movetoolbar.c | 119 ++++++++++ nuttx/libnx/nxtk/nxtk_movewindow.c | 118 ++++++++++ nuttx/libnx/nxtk/nxtk_opentoolbar.c | 126 ++++++++++ nuttx/libnx/nxtk/nxtk_openwindow.c | 161 +++++++++++++ nuttx/libnx/nxtk/nxtk_raise.c | 94 ++++++++ nuttx/libnx/nxtk/nxtk_setposition.c | 106 +++++++++ nuttx/libnx/nxtk/nxtk_setsize.c | 113 +++++++++ nuttx/libnx/nxtk/nxtk_setsubwindows.c | 165 +++++++++++++ nuttx/libnx/nxtk/nxtk_subwindowclip.c | 117 ++++++++++ nuttx/libnx/nxtk/nxtk_subwindowmove.c | 149 ++++++++++++ nuttx/libnx/nxtk/nxtk_toolbarbounds.c | 105 +++++++++ 92 files changed, 5346 insertions(+), 5141 deletions(-) create mode 100644 nuttx/graphics/nxsu/nx_constructwindow.c create mode 100644 nuttx/graphics/nxsu/nx_redrawreq.c delete mode 100644 nuttx/graphics/nxsu/nxsu_constructwindow.c delete mode 100644 nuttx/graphics/nxtk/Make.defs delete mode 100644 nuttx/graphics/nxtk/nxtk_bitmaptoolbar.c delete mode 100644 nuttx/graphics/nxtk/nxtk_bitmapwindow.c delete mode 100644 nuttx/graphics/nxtk/nxtk_block.c delete mode 100644 nuttx/graphics/nxtk/nxtk_closetoolbar.c delete mode 100644 nuttx/graphics/nxtk/nxtk_closewindow.c delete mode 100644 nuttx/graphics/nxtk/nxtk_containerclip.c delete mode 100644 nuttx/graphics/nxtk/nxtk_drawcircletoolbar.c delete mode 100644 nuttx/graphics/nxtk/nxtk_drawcirclewindow.c delete mode 100644 nuttx/graphics/nxtk/nxtk_drawframe.c delete mode 100644 nuttx/graphics/nxtk/nxtk_drawlinetoolbar.c delete mode 100644 nuttx/graphics/nxtk/nxtk_drawlinewindow.c delete mode 100644 nuttx/graphics/nxtk/nxtk_events.c delete mode 100644 nuttx/graphics/nxtk/nxtk_fillcircletoolbar.c delete mode 100644 nuttx/graphics/nxtk/nxtk_fillcirclewindow.c delete mode 100644 nuttx/graphics/nxtk/nxtk_filltoolbar.c delete mode 100644 nuttx/graphics/nxtk/nxtk_filltraptoolbar.c delete mode 100644 nuttx/graphics/nxtk/nxtk_filltrapwindow.c delete mode 100644 nuttx/graphics/nxtk/nxtk_fillwindow.c delete mode 100644 nuttx/graphics/nxtk/nxtk_getposition.c delete mode 100644 nuttx/graphics/nxtk/nxtk_gettoolbar.c delete mode 100644 nuttx/graphics/nxtk/nxtk_getwindow.c delete mode 100644 nuttx/graphics/nxtk/nxtk_internal.h delete mode 100644 nuttx/graphics/nxtk/nxtk_lower.c delete mode 100644 nuttx/graphics/nxtk/nxtk_movetoolbar.c delete mode 100644 nuttx/graphics/nxtk/nxtk_movewindow.c delete mode 100644 nuttx/graphics/nxtk/nxtk_opentoolbar.c delete mode 100644 nuttx/graphics/nxtk/nxtk_openwindow.c delete mode 100644 nuttx/graphics/nxtk/nxtk_raise.c delete mode 100644 nuttx/graphics/nxtk/nxtk_setposition.c delete mode 100644 nuttx/graphics/nxtk/nxtk_setsize.c delete mode 100644 nuttx/graphics/nxtk/nxtk_setsubwindows.c delete mode 100644 nuttx/graphics/nxtk/nxtk_subwindowclip.c delete mode 100644 nuttx/graphics/nxtk/nxtk_subwindowmove.c delete mode 100644 nuttx/graphics/nxtk/nxtk_toolbarbounds.c create mode 100644 nuttx/libnx/nxmu/nx_constructwindow.c create mode 100644 nuttx/libnx/nxmu/nx_redrawreq.c delete mode 100644 nuttx/libnx/nxmu/nxmu_constructwindow.c create mode 100644 nuttx/libnx/nxtk/Make.defs create mode 100644 nuttx/libnx/nxtk/nxtk_bitmaptoolbar.c create mode 100644 nuttx/libnx/nxtk/nxtk_bitmapwindow.c create mode 100644 nuttx/libnx/nxtk/nxtk_block.c create mode 100644 nuttx/libnx/nxtk/nxtk_closetoolbar.c create mode 100644 nuttx/libnx/nxtk/nxtk_closewindow.c create mode 100644 nuttx/libnx/nxtk/nxtk_containerclip.c create mode 100644 nuttx/libnx/nxtk/nxtk_drawcircletoolbar.c create mode 100644 nuttx/libnx/nxtk/nxtk_drawcirclewindow.c create mode 100644 nuttx/libnx/nxtk/nxtk_drawframe.c create mode 100644 nuttx/libnx/nxtk/nxtk_drawlinetoolbar.c create mode 100644 nuttx/libnx/nxtk/nxtk_drawlinewindow.c create mode 100644 nuttx/libnx/nxtk/nxtk_events.c create mode 100644 nuttx/libnx/nxtk/nxtk_fillcircletoolbar.c create mode 100644 nuttx/libnx/nxtk/nxtk_fillcirclewindow.c create mode 100644 nuttx/libnx/nxtk/nxtk_filltoolbar.c create mode 100644 nuttx/libnx/nxtk/nxtk_filltraptoolbar.c create mode 100644 nuttx/libnx/nxtk/nxtk_filltrapwindow.c create mode 100644 nuttx/libnx/nxtk/nxtk_fillwindow.c create mode 100644 nuttx/libnx/nxtk/nxtk_getposition.c create mode 100644 nuttx/libnx/nxtk/nxtk_gettoolbar.c create mode 100644 nuttx/libnx/nxtk/nxtk_getwindow.c create mode 100644 nuttx/libnx/nxtk/nxtk_internal.h create mode 100644 nuttx/libnx/nxtk/nxtk_lower.c create mode 100644 nuttx/libnx/nxtk/nxtk_movetoolbar.c create mode 100644 nuttx/libnx/nxtk/nxtk_movewindow.c create mode 100644 nuttx/libnx/nxtk/nxtk_opentoolbar.c create mode 100644 nuttx/libnx/nxtk/nxtk_openwindow.c create mode 100644 nuttx/libnx/nxtk/nxtk_raise.c create mode 100644 nuttx/libnx/nxtk/nxtk_setposition.c create mode 100644 nuttx/libnx/nxtk/nxtk_setsize.c create mode 100644 nuttx/libnx/nxtk/nxtk_setsubwindows.c create mode 100644 nuttx/libnx/nxtk/nxtk_subwindowclip.c create mode 100644 nuttx/libnx/nxtk/nxtk_subwindowmove.c create mode 100644 nuttx/libnx/nxtk/nxtk_toolbarbounds.c diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index 74978df50..d9edffaf7 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -6329,4 +6329,5 @@ * Move libc/nx, nxmu, and nxglib to a new library, libnx. The NX graphics is not properly a part of libc (2013-12-28). * Move graphics/nxfonts to libnx/nxfonts (2013-12-28). + * Move graphics/nxtk to libnx/nxtk (2013-12-28). diff --git a/nuttx/Documentation/NXGraphicsSubsystem.html b/nuttx/Documentation/NXGraphicsSubsystem.html index 4aa754b6c..744607154 100644 --- a/nuttx/Documentation/NXGraphicsSubsystem.html +++ b/nuttx/Documentation/NXGraphicsSubsystem.html @@ -3196,19 +3196,18 @@ int nxf_convert_32bpp(FAR uint32_t *dest, uint16_t height, The multi-user front-end is selected when CONFIG_NX_MULTIUSER is defined in the NuttX configuration file. -
graphics/nxfonts +
libnx/nxfonts
This is where the NXFONTS implementation resides. This is a relatively low-level set of charset set/glyph management APIs. See include/nuttx/nx/nxfonts.h. -
graphics/nxtk +
libnx/nxtk
This is where the NXTOOLKIT implementation resides. This toolkit is built on top of NX and works with either the single-user or multi-user NX version. See include/nuttx/nx/nxtk.h.
nuttx/../nxwidgets -
The NxWidgets code is provided as a separate package located outside of the - NuttX source tree (probably at this location). +
The NxWidgets code is provided as a separate package located outside of the NuttX source tree (probably at this location).
graphics/nxconsole
The NxConsole driver is built on top of NX and works with either the single-user or multi-user NX version. diff --git a/nuttx/graphics/Makefile b/nuttx/graphics/Makefile index c3abfb0c6..b63a05312 100644 --- a/nuttx/graphics/Makefile +++ b/nuttx/graphics/Makefile @@ -59,10 +59,6 @@ DEPPATH += --dep-path nxsu CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" $(TOPDIR)/graphics/nxsu} endif -include nxtk/Make.defs -DEPPATH += --dep-path nxtk -CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" $(TOPDIR)/graphics/nxtk} - ifeq ($(CONFIG_NXCONSOLE),y) include nxconsole/Make.defs DEPPATH += --dep-path nxconsole @@ -81,9 +77,9 @@ OBJS = $(AOBJS) $(COBJS) BIN = libgraphics$(LIBEXT) ifeq ($(CONFIG_NX_MULTIUSER),y) -VPATH = nxglib:nxbe:nxmu:nxtk:nxconsole +VPATH = nxglib:nxbe:nxmu:nxconsole else -VPATH = nxglib:nxbe:nxsu:nxtk:nxconsole +VPATH = nxglib:nxbe:nxsu:nxconsole endif all: mklibgraphics diff --git a/nuttx/graphics/README.txt b/nuttx/graphics/README.txt index 9f3bdbe4e..c9f8442b5 100644 --- a/nuttx/graphics/README.txt +++ b/nuttx/graphics/README.txt @@ -99,11 +99,11 @@ libnx/nxmu queue to serialize window operations from many threads. The multi-user front-end is selected when CONFIG_NX_MULTIUSER is defined in the NuttX configuration file. -graphics/nxfonts +libnx/nxfonts This is where the NXFONTS implementation resides. This is a relatively low- level set of charset set/glyph management APIs. See include/nuttx/nx/nxfonts.h -graphics/nxtk +libnx/nxtk This is where the NXTOOLKIT implementation resides. This toolkit is built on top of NX and works with either the single-user or multi-user NX version. See include/nuttx/nx/nxtk.h diff --git a/nuttx/graphics/nxmu/nxfe.h b/nuttx/graphics/nxmu/nxfe.h index 34d680b2a..42e768267 100644 --- a/nuttx/graphics/nxmu/nxfe.h +++ b/nuttx/graphics/nxmu/nxfe.h @@ -95,39 +95,6 @@ extern "C" * Public Functions ****************************************************************************/ -/**************************************************************************** - * Name: nxfe_constructwindow - * - * Description: - * This function is the same a nx_openwindow EXCEPT that the client provides - * the window structure instance. nx_constructwindow will initialize the - * the pre-allocated window structure for use by NX. This function is - * provided in addition to nx_open window in order to support a kind of - * inheritance: The caller's window structure may include extensions that - * are not visible to NX. - * - * NOTE: wnd must have been allocated using kmalloc() (or related allocators) - * Once provided to nxfe_constructwindow() that memory is owned and managed - * by NX. On certain error conditions or when the window is closed, NX will - * free the window. - * - * Input Parameters: - * handle - The handle returned by nx_connect - * wnd - The pre-allocated window structure. - * cb - Callbacks used to process window events - * arg - User provided value that will be returned with NX callbacks. - * - * Return: - * OK on success; ERROR on failure with errno set appropriately. In the - * case of ERROR, NX will have deallocated the pre-allocated window. - * - ****************************************************************************/ - -int nxfe_constructwindow(NXHANDLE handle, - FAR struct nxbe_window_s *wnd, - FAR const struct nx_callback_s *cb, - FAR void *arg); - /**************************************************************************** * Name: nxmu_sendclient * diff --git a/nuttx/graphics/nxmu/nxmu_redrawreq.c b/nuttx/graphics/nxmu/nxmu_redrawreq.c index f54aa85a7..ef0fe1914 100644 --- a/nuttx/graphics/nxmu/nxmu_redrawreq.c +++ b/nuttx/graphics/nxmu/nxmu_redrawreq.c @@ -90,4 +90,3 @@ void nxfe_redrawreq(FAR struct nxbe_window_s *wnd, FAR const struct nxgl_rect_s (void)nxmu_sendclientwindow(wnd, &outmsg, sizeof(struct nxclimsg_redraw_s)); } - diff --git a/nuttx/graphics/nxmu/nxmu_server.c b/nuttx/graphics/nxmu/nxmu_server.c index cfaa5bbf5..2f7e54564 100644 --- a/nuttx/graphics/nxmu/nxmu_server.c +++ b/nuttx/graphics/nxmu/nxmu_server.c @@ -509,7 +509,14 @@ int nx_runinstance(FAR const char *mqname, FAR NX_DRIVERTYPE *dev) break; #endif - /* Messages sent to the backgound window ***************************/ + case NX_SVRMSG_REDRAWREQ: /* Request re-drawing of rectangular region */ + { + FAR struct nxsvrmsg_redrawreq_s *redrawmsg = (FAR struct nxsvrmsg_redrawreq_s *)buffer; + nxfe_redrawreq(redrawmsg->wnd, &redrawmsg->rect); + } + break; + + /* Messages sent to the background window **************************/ case NX_CLIMSG_REDRAW: /* Re-draw the background window */ { diff --git a/nuttx/graphics/nxsu/Make.defs b/nuttx/graphics/nxsu/Make.defs index cf668d93c..93abe9d81 100644 --- a/nuttx/graphics/nxsu/Make.defs +++ b/nuttx/graphics/nxsu/Make.defs @@ -38,6 +38,7 @@ NX_ASRCS = NX_CSRCS = nx_bitmap.c nx_close.c nx_closewindow.c nx_fill.c NX_CSRCS += nx_filltrapezoid.c nx_getposition.c nx_getrectangle.c nx_kbdchin.c NX_CSRCS += nx_kbdin.c nx_lower.c nx_mousein.c nx_move.c nx_open.c -NX_CSRCS += nx_openwindow.c nx_raise.c nx_releasebkgd.c nx_requestbkgd.c -NX_CSRCS += nx_setpixel.c nx_setsize.c nx_setbgcolor.c nx_setposition.c -NX_CSRCS += nxsu_constructwindow.c nxsu_redrawreq.c nxsu_reportposition.c +NX_CSRCS += nx_openwindow.c nx_raise.c nx_redrawreq.c nx_releasebkgd.c +NX_CSRCS += nx_requestbkgd.c nx_setpixel.c nx_setsize.c nx_setbgcolor.c +NX_CSRCS += nx_setposition.c nxsu_constructwindow.c nxsu_redrawreq.c +NX_CSRCS += nxsu_reportposition.c diff --git a/nuttx/graphics/nxsu/nx_constructwindow.c b/nuttx/graphics/nxsu/nx_constructwindow.c new file mode 100644 index 000000000..b77025dcf --- /dev/null +++ b/nuttx/graphics/nxsu/nx_constructwindow.c @@ -0,0 +1,152 @@ +/**************************************************************************** + * graphics/nxsu/nx_constructwindow.c + * + * Copyright (C) 2008-2009, 2012-2013 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include +#include + +#include "nxfe.h" + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nx_constructwindow + * + * Description: + * This function is the same a nx_openwindow EXCEPT that the client provides + * the window structure instance. nx_constructwindow will initialize the + * the pre-allocated window structure for use by NX. This function is + * provided in addition to nx_open window in order to support a kind of + * inheritance: The caller's window structure may include extensions that + * are not visible to NX. + * + * NOTE: wnd must have been allocated using kmalloc() (or related allocators) + * Once provided to nx_constructwindow() that memory is owned and managed + * by NX. On certain error conditions or when the window is closed, NX will + * free the window. + * + * Input Parameters: + * handle - The handle returned by nx_connect + * wnd - The pre-allocated window structure. + * cb - Callbacks used to process window events + * arg - User provided value that will be returned with NX callbacks. + * + * Return: + * OK on success; ERROR on failure with errno set appropriately. In the + * case of ERROR, NX will have deallocated the pre-allocated window. + * + ****************************************************************************/ + +int nx_constructwindow(NXHANDLE handle, FAR struct nxbe_window_s *wnd, + FAR const struct nx_callback_s *cb, FAR void *arg) +{ + FAR struct nxfe_state_s *fe = (FAR struct nxfe_state_s *)handle; + FAR struct nxbe_state_s *be = &fe->be; + +#ifdef CONFIG_DEBUG + if (!wnd) + { + errno = EINVAL; + return ERROR; + } + + if (!fe || !cb) + { + kfree(wnd); + errno = EINVAL; + return ERROR; + } +#endif + + /* Initialize the window structure */ + + wnd->be = be; + wnd->cb = cb; + wnd->arg = arg; + + /* Insert the new window at the top on the display. topwnd is + * never NULL (it may point only at the background window, however) + */ + + wnd->above = NULL; + wnd->below = be->topwnd; + + be->topwnd->above = wnd; + be->topwnd = wnd; + + /* Report the initialize size/position of the window */ + + nxfe_reportposition((NXWINDOW)wnd); + + /* Provide the initial mouse settings */ + +#ifdef CONFIG_NX_MOUSE + nxsu_mousereport(wnd); +#endif + + return OK; +} + diff --git a/nuttx/graphics/nxsu/nx_openwindow.c b/nuttx/graphics/nxsu/nx_openwindow.c index b002f1566..83851d94e 100644 --- a/nuttx/graphics/nxsu/nx_openwindow.c +++ b/nuttx/graphics/nxsu/nx_openwindow.c @@ -112,9 +112,9 @@ NXWINDOW nx_openwindow(NXHANDLE handle, FAR const struct nx_callback_s *cb, return NULL; } - /* Then let nxfe_constructwindow do the rest */ + /* Then let nx_constructwindow do the rest */ - ret = nxfe_constructwindow(handle, wnd, cb, arg); + ret = nx_constructwindow(handle, wnd, cb, arg); if (ret < 0) { /* An error occurred, the window has been freed */ diff --git a/nuttx/graphics/nxsu/nx_redrawreq.c b/nuttx/graphics/nxsu/nx_redrawreq.c new file mode 100644 index 000000000..2980990e0 --- /dev/null +++ b/nuttx/graphics/nxsu/nx_redrawreq.c @@ -0,0 +1,93 @@ +/**************************************************************************** + * graphics/nxsu/nx_redrawreq.c + * + * Copyright (C) 2013 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include + +#include +#include "nxfe.h" + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nx_redrawreq + * + * Descripton: + * This will cause a NX re-draw callback to the client that owns the + * window. This is not normally called from user code, but may be + * used within middle-ware layers when redrawing is needed. + * + * Input Parameters: + * hwnd - Window handle + * rect - The rectangle that needs to be re-drawn (in window relative + * coordinates) + * + * Returned Value: + * None + * + ****************************************************************************/ + +void nx_redrawreq(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect) +{ + nxfe_redrawreq((FAR struct nxbe_window_s *)hwnd, rect); +} diff --git a/nuttx/graphics/nxsu/nxfe.h b/nuttx/graphics/nxsu/nxfe.h index cd76dd16f..5bbfb040b 100644 --- a/nuttx/graphics/nxsu/nxfe.h +++ b/nuttx/graphics/nxsu/nxfe.h @@ -93,37 +93,6 @@ EXTERN const struct nx_callback_s g_bkgdcb; * Public Functions ****************************************************************************/ -/**************************************************************************** - * Name: nxfe_constructwindow - * - * Description: - * This function is the same a nx_openwindow EXCEPT that the client provides - * the window structure instance. nx_constructwindow will initialize the - * the pre-allocated window structure for use by NX. This function is - * provided in addition to nx_open window in order to support a kind of - * inheritance: The caller's window structure may include extensions that - * are not visible to NX. - * - * NOTE: wnd must have been allocated using kmalloc() (or related allocators) - * Once provided to nxfe_constructwindow() that memory is owned and managed - * by NX. On certain error conditions or when the window is closed, NX will - * free the window. - * - * Input Parameters: - * handle - The handle returned by nx_connect - * wnd - The pre-allocated window structure. - * cb - Callbacks used to process window events - * arg - User provided value that will be returned with NX callbacks. - * - * Return: - * OK on success; ERROR on failure with errno set appropriately. In the - * case of ERROR, NX will have deallocated the pre-allocated window. - * - ****************************************************************************/ - -int nxfe_constructwindow(NXHANDLE handle, FAR struct nxbe_window_s *wnd, - FAR const struct nx_callback_s *cb, FAR void *arg); - /**************************************************************************** * Name: nxfe_redrawreq * diff --git a/nuttx/graphics/nxsu/nxsu_constructwindow.c b/nuttx/graphics/nxsu/nxsu_constructwindow.c deleted file mode 100644 index 46b010cee..000000000 --- a/nuttx/graphics/nxsu/nxsu_constructwindow.c +++ /dev/null @@ -1,152 +0,0 @@ -/**************************************************************************** - * graphics/nxsu/nx_openwindow.c - * - * Copyright (C) 2008-2009, 2012-2013 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include - -#include -#include - -#include "nxfe.h" - -/**************************************************************************** - * Pre-Processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: nxfe_constructwindow - * - * Description: - * This function is the same a nx_openwindow EXCEPT that the client provides - * the window structure instance. nx_constructwindow will initialize the - * the pre-allocated window structure for use by NX. This function is - * provided in addition to nx_open window in order to support a kind of - * inheritance: The caller's window structure may include extensions that - * are not visible to NX. - * - * NOTE: wnd must have been allocated using kmalloc() (or related allocators) - * Once provided to nxfe_constructwindow() that memory is owned and managed - * by NX. On certain error conditions or when the window is closed, NX will - * free the window. - * - * Input Parameters: - * handle - The handle returned by nx_connect - * wnd - The pre-allocated window structure. - * cb - Callbacks used to process window events - * arg - User provided value that will be returned with NX callbacks. - * - * Return: - * OK on success; ERROR on failure with errno set appropriately. In the - * case of ERROR, NX will have deallocated the pre-allocated window. - * - ****************************************************************************/ - -int nxfe_constructwindow(NXHANDLE handle, FAR struct nxbe_window_s *wnd, - FAR const struct nx_callback_s *cb, FAR void *arg) -{ - FAR struct nxfe_state_s *fe = (FAR struct nxfe_state_s *)handle; - FAR struct nxbe_state_s *be = &fe->be; - -#ifdef CONFIG_DEBUG - if (!wnd) - { - errno = EINVAL; - return ERROR; - } - - if (!fe || !cb) - { - kfree(wnd); - errno = EINVAL; - return ERROR; - } -#endif - - /* Initialize the window structure */ - - wnd->be = be; - wnd->cb = cb; - wnd->arg = arg; - - /* Insert the new window at the top on the display. topwnd is - * never NULL (it may point only at the background window, however) - */ - - wnd->above = NULL; - wnd->below = be->topwnd; - - be->topwnd->above = wnd; - be->topwnd = wnd; - - /* Report the initialize size/position of the window */ - - nxfe_reportposition((NXWINDOW)wnd); - - /* Provide the initial mouse settings */ - -#ifdef CONFIG_NX_MOUSE - nxsu_mousereport(wnd); -#endif - - return OK; -} - diff --git a/nuttx/graphics/nxsu/nxsu_redrawreq.c b/nuttx/graphics/nxsu/nxsu_redrawreq.c index 21845f16f..b0116870b 100644 --- a/nuttx/graphics/nxsu/nxsu_redrawreq.c +++ b/nuttx/graphics/nxsu/nxsu_redrawreq.c @@ -1,7 +1,7 @@ /**************************************************************************** * graphics/nxsu/nxsu_redrawreq.c * - * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2009,2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -73,7 +73,7 @@ /**************************************************************************** * Name: nxfe_redrawreq * - * Descripton: + * Description: * Request the client that has this window to redraw the rectangular region. * ****************************************************************************/ @@ -100,5 +100,3 @@ void nxfe_redrawreq(FAR struct nxbe_window_s *wnd, FAR const struct nxgl_rect_s wnd->cb->redraw((NXWINDOW)wnd, &relrect, false, wnd->arg); } } - - diff --git a/nuttx/graphics/nxtk/Make.defs b/nuttx/graphics/nxtk/Make.defs deleted file mode 100644 index cc744309f..000000000 --- a/nuttx/graphics/nxtk/Make.defs +++ /dev/null @@ -1,48 +0,0 @@ -############################################################################ -# graphics/nxtk/Make.defs -# -# Copyright (C) 2008, 2011 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name NuttX nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - -NXTK_ASRCS = -NXTKWIN_CSRCS = nxtk_openwindow.c nxtk_closewindow.c nxtk_getposition.c \ - nxtk_setposition.c nxtk_setsize.c nxtk_raise.c nxtk_lower.c \ - nxtk_fillwindow.c nxtk_getwindow.c nxtk_filltrapwindow.c \ - nxtk_movewindow.c nxtk_bitmapwindow.c nxtk_events.c \ - nxtk_setsubwindows.c nxtk_drawcirclewindow.c nxtk_drawlinewindow.c \ - nxtk_fillcirclewindow.c nxtk_block.c -NXTKTB_CSRCS = nxtk_opentoolbar.c nxtk_closetoolbar.c nxtk_filltoolbar.c \ - nxtk_gettoolbar.c nxtk_filltraptoolbar.c nxtk_movetoolbar.c \ - nxtk_bitmaptoolbar.c nxtk_drawcircletoolbar.c nxtk_drawlinetoolbar.c \ - nxtk_fillcircletoolbar.c nxtk_toolbarbounds.c -NXTK_CSRCS = $(NXTKWIN_CSRCS) $(NXTKTB_CSRCS) nxtk_subwindowclip.c \ - nxtk_containerclip.c nxtk_subwindowmove.c nxtk_drawframe.c diff --git a/nuttx/graphics/nxtk/nxtk_bitmaptoolbar.c b/nuttx/graphics/nxtk/nxtk_bitmaptoolbar.c deleted file mode 100644 index 50bd5aff4..000000000 --- a/nuttx/graphics/nxtk/nxtk_bitmaptoolbar.c +++ /dev/null @@ -1,137 +0,0 @@ -/**************************************************************************** - * graphics/nxtk/nxtk_bitmaptoolbar.c - * - * Copyright (C) 2008-2009, 2012 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include - -#include -#include - -#include "nxtk_internal.h" - -/**************************************************************************** - * Pre-Processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * 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 sub-window coordinates, however, the - * origin may lie outside of the sub-window display. - * stride - The width of the full source image in pixels. - * - * Return: - * OK on success; ERROR on failure with errno set appropriately - * - ****************************************************************************/ - -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 *)hfwnd; - struct nxgl_point_s wndorigin; - struct nxgl_rect_s clipdest; - -#ifdef CONFIG_DEBUG - if (!hfwnd || !dest || !src || !origin) - { - errno = EINVAL; - return ERROR; - } -#endif - - /* Clip the rectangle so that it lies within the sub-window bounds - * then move the rectangle to that it is relative to the containing - * window. - */ - - nxtk_subwindowclip(fwnd, &clipdest, dest, &fwnd->tbrect); - - /* Now, move the bitmap origin so that it is relative to the containing - * window, not the sub-window. - * - * Temporarily, position the origin in absolute screen coordinates - */ - - nxgl_vectoradd(&wndorigin, origin, &fwnd->tbrect.pt1); - - /* Then move the origin so that is relative to the containing window, not the - * client subwindow - */ - - nxgl_vectsubtract(&wndorigin, &wndorigin, &fwnd->wnd.bounds.pt1); - - /* Then copy the bitmap */ - - nx_bitmap((NXWINDOW)hfwnd, &clipdest, src, &wndorigin, stride); - return OK; -} diff --git a/nuttx/graphics/nxtk/nxtk_bitmapwindow.c b/nuttx/graphics/nxtk/nxtk_bitmapwindow.c deleted file mode 100644 index 6847c44d4..000000000 --- a/nuttx/graphics/nxtk/nxtk_bitmapwindow.c +++ /dev/null @@ -1,137 +0,0 @@ -/**************************************************************************** - * graphics/nxtk/nxtk_bitmapwindow.c - * - * Copyright (C) 2008-2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include - -#include -#include - -#include "nxtk_internal.h" - -/**************************************************************************** - * Pre-Processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: nxtk_bitmapwindow - * - * Description: - * Copy a rectangular region of a larger image into the rectangle in the - * specified client sub-window. - * - * Input Parameters: - * hfwnd The client sub0window that will receive the bitmap image - * dest - Describes the rectangular region on in the client 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 sub-window coordinates, however, the - * origin may lie outside of the sub-window display. - * stride - The width of the full source image in pixels. - * - * Return: - * OK on success; ERROR on failure with errno set appropriately - * - ****************************************************************************/ - -int nxtk_bitmapwindow(NXTKWINDOW hfwnd, FAR const struct nxgl_rect_s *dest, - FAR const void **src, - FAR const struct nxgl_point_s *origin, unsigned int stride) -{ - FAR struct nxtk_framedwindow_s *fwnd = (FAR struct nxtk_framedwindow_s *)hfwnd; - struct nxgl_point_s wndorigin; - struct nxgl_rect_s clipdest; - -#ifdef CONFIG_DEBUG - if (!hfwnd || !dest || !src || !origin) - { - errno = EINVAL; - return ERROR; - } -#endif - - /* Clip the rectangle so that it lies within the sub-window bounds - * then move the rectangle to that it is relative to the containing - * window. - */ - - nxtk_subwindowclip(fwnd, &clipdest, dest, &fwnd->fwrect); - - /* Now, move the bitmap origin so that it is relative to the containing - * window, not the sub-window. - * - * Temporarily, position the origin in absolute screen coordinates - */ - - nxgl_vectoradd(&wndorigin, origin, &fwnd->fwrect.pt1); - - /* Then move the origin so that is relative to the containing window, not the - * client subwindow - */ - - nxgl_vectsubtract(&wndorigin, &wndorigin, &fwnd->wnd.bounds.pt1); - - /* Then copy the bitmap */ - - nx_bitmap((NXWINDOW)hfwnd, &clipdest, src, &wndorigin, stride); - return OK; -} diff --git a/nuttx/graphics/nxtk/nxtk_block.c b/nuttx/graphics/nxtk/nxtk_block.c deleted file mode 100644 index 11baf7f4f..000000000 --- a/nuttx/graphics/nxtk/nxtk_block.c +++ /dev/null @@ -1,109 +0,0 @@ -/**************************************************************************** - * graphics/nxtk/nxtk_block.c - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include - -#include "nxfe.h" - -#ifdef CONFIG_NX_MULTIUSER - -/**************************************************************************** - * Pre-Processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: nxtk_block - * - * Description: - * This is callback will do to things: (1) any queue a 'blocked' callback - * to the window and then (2) block any further window messaging. - * - * The 'blocked' callback is the response from nx_block (or nxtk_block). - * Those blocking interfaces are used to assure that no further messages are - * are directed to the window. Receipt of the blocked callback signifies - * that (1) there are no further pending callbacks and (2) that the - * window is now 'defunct' and will receive no further callbacks. - * - * This callback supports coordinated destruction of a window in multi- - * user mode. In multi-use mode, the client window logic must stay - * intact until all of the queued callbacks are processed. Then the - * window may be safely closed. Closing the window prior with pending - * callbacks can lead to bad behavior when the callback is executed. - * - * Multiple user mode only! - * - * Input Parameters: - * hfwnd - The window to be blocked - * arg - An argument that will accompany the block messages (This is arg2 - * in the blocked callback). - * - * Return: - * OK on success; ERROR on failure with errno set appropriately - * - ****************************************************************************/ - -int nxtk_block(NXTKWINDOW hfwnd, FAR void *arg) -{ - return nx_block((NXWINDOW)hfwnd, arg); -} - -#endif /* CONFIG_NX_MULTIUSER */ diff --git a/nuttx/graphics/nxtk/nxtk_closetoolbar.c b/nuttx/graphics/nxtk/nxtk_closetoolbar.c deleted file mode 100644 index 7ad36f9d8..000000000 --- a/nuttx/graphics/nxtk/nxtk_closetoolbar.c +++ /dev/null @@ -1,111 +0,0 @@ -/**************************************************************************** - * graphics/nxtk/nxtk_closetoolbar.c - * - * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include - -#include -#include - -#include "nxfe.h" -#include "nxtk_internal.h" - -/**************************************************************************** - * Pre-Processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: nxtk_closetoolbar - * - * Description: - * Create a tool bar at the top of the specified framed window - * - * Input Parameters: - * hfwnd - The handle returned by nxtk_openwindow - * - * Return: - * OK on success; ERROR on failure with errno set appropriately - * - ****************************************************************************/ - -int nxtk_closetoolbar(NXTKWINDOW hfwnd) -{ - FAR struct nxtk_framedwindow_s *fwnd = (FAR struct nxtk_framedwindow_s *)hfwnd; - - /* Un-initialize the toolbar info */ - - fwnd->tbheight = 0; - fwnd->tbcb = NULL; - fwnd->tbarg = NULL; - - /* Calculate the new dimensions of the client window */ - - nxtk_setsubwindows(fwnd); - - /* Then redraw the entire window, even the client window must be - * redraw because it has changed its vertical position and size. - */ - - nxfe_redrawreq(&fwnd->wnd, &fwnd->wnd.bounds); - return OK; -} - diff --git a/nuttx/graphics/nxtk/nxtk_closewindow.c b/nuttx/graphics/nxtk/nxtk_closewindow.c deleted file mode 100644 index e80cd0c66..000000000 --- a/nuttx/graphics/nxtk/nxtk_closewindow.c +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************** - * graphics/nxtk/nxtk_closewindow.c - * - * Copyright (C) 2008 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include -#include - -#include -#include - -#include "nxfe.h" -#include "nxtk_internal.h" - -/**************************************************************************** - * Pre-Processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: nxtk_closewindow - * - * Description: - * Close the window opened by nxtk_openwindow - * - * Input Parameters: - * hfwnd - The handle returned by nxtk_openwindow - * - * Return: - * OK on success; ERROR on failure with errno set appropriately - * - ****************************************************************************/ - -int nxtk_closewindow(NXTKWINDOW hfwnd) -{ - return nx_closewindow((NXWINDOW)hfwnd); -} - diff --git a/nuttx/graphics/nxtk/nxtk_containerclip.c b/nuttx/graphics/nxtk/nxtk_containerclip.c deleted file mode 100644 index a2fbcd0f8..000000000 --- a/nuttx/graphics/nxtk/nxtk_containerclip.c +++ /dev/null @@ -1,122 +0,0 @@ -/**************************************************************************** - * graphics/nxtk/nxtk_containerclip.c - * - * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include - -#include -#include - -#include "nxfe.h" -#include "nxtk_internal.h" - -/**************************************************************************** - * Pre-Processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: nxtk_containerclip - * - * Description: - * We are given a 'src' rectangle in containing window, relative coordinates - * (i.e., (0,0) is the top left corner of the outer, containing window). - * This function will (1) clip that src rectangle so that it lies within - * the sub-window bounds, and then (2) move the rectangle to that it is - * relative to the sub-window (i.e., (0,0) is the top left corner of the - * sub-window). - * - * Input parameters: - * fwnd - The framed window to be used - * dest - The locaton to put the result - * src - The src rectangle in relative container-window coordinates - * bounds - The subwindow bounds in absolute screen coordinates. - * - * Returned value: - * None - * - ****************************************************************************/ - -void nxtk_containerclip(FAR struct nxtk_framedwindow_s *fwnd, - FAR struct nxgl_rect_s *dest, - FAR const struct nxgl_rect_s *src, - FAR const struct nxgl_rect_s *bounds) -{ - struct nxgl_rect_s relbounds; - - /* The 'src' rectangle is relative to the containing window. Convert - * the sub-window to the same origin. - */ - - nxgl_rectoffset(&relbounds, bounds, -fwnd->wnd.bounds.pt1.x, - -fwnd->wnd.bounds.pt1.y); - - /* The interection then leaves the portion of the containing window that - * needs to be updated window that needs to be updated. - */ - - nxgl_rectintersect(dest, src, &relbounds); - - /* Offset this so that is relative to client subwindow origin */ - - nxgl_rectoffset(dest, dest, fwnd->wnd.bounds.pt1.x - bounds->pt1.x, - fwnd->wnd.bounds.pt1.y - bounds->pt1.y); -} diff --git a/nuttx/graphics/nxtk/nxtk_drawcircletoolbar.c b/nuttx/graphics/nxtk/nxtk_drawcircletoolbar.c deleted file mode 100644 index a36ed32ee..000000000 --- a/nuttx/graphics/nxtk/nxtk_drawcircletoolbar.c +++ /dev/null @@ -1,145 +0,0 @@ -/**************************************************************************** - * graphics/nxtk/nxtk_drawcircletoolbar.c - * - * Copyright (C) 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include - -#include -#include - -/**************************************************************************** - * Pre-Processor Definitions - ****************************************************************************/ -/* Named indices into the 16 circle points generated by nxgl_circlepts */ - -#define POINT_0p0 0 -#define POINT_22p5 1 -#define POINT_45p0 2 -#define POINT_67p5 3 -#define POINT_90p0 4 -#define POINT_112p5 5 -#define POINT_135p0 6 -#define POINT_157p5 7 -#define POINT_180p0 8 -#define POINT_202p5 9 -#define POINT_225p0 10 -#define POINT_247p5 11 -#define POINT_270p0 12 -#define POINT_292p5 13 -#define POINT_315p0 14 -#define POINT_337p5 15 -#define NCIRCLE_POINTS 16 - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: nxtk_drawcircletoolbar - * - * Description: - * Draw a circular outline using the specified line thickness and color. - * - * Input Parameters: - * hfwnd - The window handle returned by nxtk_openwindow() - * center - A pointer to the point that is the center of the circle - * radius - The radius of the circle in pixels. - * width - The width of the line - * color - The color to use to fill the line - * - * Return: - * OK on success; ERROR on failure with errno set appropriately - * - ****************************************************************************/ - -int nxtk_drawcircletoolbar(NXTKWINDOW hfwnd, FAR const struct nxgl_point_s *center, - nxgl_coord_t radius, nxgl_coord_t width, - nxgl_mxpixel_t color[CONFIG_NX_NPLANES]) -{ - struct nxgl_point_s pts[NCIRCLE_POINTS]; - FAR struct nxgl_vector_s vector; - int i; - int ret; - - /* Convert the circle to a set of 16 points */ - - nxgl_circlepts(center, radius, pts); - - /* Draw each pair of points as a vector */ - - for (i = POINT_0p0; i < POINT_337p5; i++) - { - vector.pt1.x = pts[i].x; - vector.pt1.y = pts[i].y; - vector.pt2.x = pts[i+1].x; - vector.pt2.y = pts[i+1].y; - ret = nxtk_drawlinetoolbar(hfwnd, &vector, width, color); - if (ret != OK) - { - return ret; - } - } - - /* The final, closing vector is a special case */ - - vector.pt1.x = pts[POINT_337p5].x; - vector.pt1.y = pts[POINT_337p5].y; - vector.pt2.x = pts[POINT_0p0].x; - vector.pt2.y = pts[POINT_0p0].y; - return nxtk_drawlinetoolbar(hfwnd, &vector, width, color); -} diff --git a/nuttx/graphics/nxtk/nxtk_drawcirclewindow.c b/nuttx/graphics/nxtk/nxtk_drawcirclewindow.c deleted file mode 100644 index 080e802ec..000000000 --- a/nuttx/graphics/nxtk/nxtk_drawcirclewindow.c +++ /dev/null @@ -1,145 +0,0 @@ -/**************************************************************************** - * graphics/nxtk/nxtk_drawcirclewindow.c - * - * Copyright (C) 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include - -#include -#include - -/**************************************************************************** - * Pre-Processor Definitions - ****************************************************************************/ -/* Named indices into the 16 circle points generated by nxgl_circlepts */ - -#define POINT_0p0 0 -#define POINT_22p5 1 -#define POINT_45p0 2 -#define POINT_67p5 3 -#define POINT_90p0 4 -#define POINT_112p5 5 -#define POINT_135p0 6 -#define POINT_157p5 7 -#define POINT_180p0 8 -#define POINT_202p5 9 -#define POINT_225p0 10 -#define POINT_247p5 11 -#define POINT_270p0 12 -#define POINT_292p5 13 -#define POINT_315p0 14 -#define POINT_337p5 15 -#define NCIRCLE_POINTS 16 - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: nxtk_drawcirclewindow - * - * Description: - * Draw a circular outline using the specified line thickness and color. - * - * Input Parameters: - * hfwnd - The window handle returned by nxtk_openwindow() - * center - A pointer to the point that is the center of the circle - * radius - The radius of the circle in pixels. - * width - The width of the line - * color - The color to use to fill the line - * - * Return: - * OK on success; ERROR on failure with errno set appropriately - * - ****************************************************************************/ - -int nxtk_drawcirclewindow(NXTKWINDOW hfwnd, FAR const struct nxgl_point_s *center, - nxgl_coord_t radius, nxgl_coord_t width, - nxgl_mxpixel_t color[CONFIG_NX_NPLANES]) -{ - struct nxgl_point_s pts[NCIRCLE_POINTS]; - FAR struct nxgl_vector_s vector; - int i; - int ret; - - /* Convert the circle to a set of 16 points */ - - nxgl_circlepts(center, radius, pts); - - /* Draw each pair of points as a vector */ - - for (i = POINT_0p0; i < POINT_337p5; i++) - { - vector.pt1.x = pts[i].x; - vector.pt1.y = pts[i].y; - vector.pt2.x = pts[i+1].x; - vector.pt2.y = pts[i+1].y; - ret = nxtk_drawlinewindow(hfwnd, &vector, width, color); - if (ret != OK) - { - return ret; - } - } - - /* The final, closing vector is a special case */ - - vector.pt1.x = pts[POINT_337p5].x; - vector.pt1.y = pts[POINT_337p5].y; - vector.pt2.x = pts[POINT_0p0].x; - vector.pt2.y = pts[POINT_0p0].y; - return nxtk_drawlinewindow(hfwnd, &vector, width, color); -} diff --git a/nuttx/graphics/nxtk/nxtk_drawframe.c b/nuttx/graphics/nxtk/nxtk_drawframe.c deleted file mode 100644 index 91745b323..000000000 --- a/nuttx/graphics/nxtk/nxtk_drawframe.c +++ /dev/null @@ -1,310 +0,0 @@ -/**************************************************************************** - * graphics/nxtk/nxtk_drawframe.c - * - * Copyright (C) 2008-2009, 2011-2012 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include - -#include -#include -#include - -#include "nxfe.h" -#include "nxtk_internal.h" - -/**************************************************************************** - * Pre-Processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: nxtk_drawframeside - ****************************************************************************/ - -static void nxtk_drawframeside(FAR struct nxtk_framedwindow_s *fwnd, - FAR const struct nxgl_rect_s *side, - FAR const struct nxgl_rect_s *bounds, - nxgl_mxpixel_t color[CONFIG_NX_NPLANES]) -{ - struct nxgl_rect_s intersection; - nxgl_rectintersect(&intersection, side, bounds); - if (!nxgl_nullrect(&intersection)) - { - nx_fill((NXWINDOW)fwnd, &intersection, color); - } -} - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: nxtk_drawframe - * - * Description: - * Redraw the window frame. - * - * Input parameters: - * fwnd - the framed window whose frame needs to be re-drawn. This must - * have been previously created by nxtk_openwindow(). - * bounds - Only draw the ports of the frame within this bounding box. - * (window relative coordinates). - * - * Returned value: - * OK on success; ERROR on failure with errno set appropriately - * - ****************************************************************************/ - -int nxtk_drawframe(FAR struct nxtk_framedwindow_s *fwnd, - FAR const struct nxgl_rect_s *bounds) -{ - struct nxgl_rect_s frame; - struct nxgl_size_s wndsize; - struct nxgl_size_s tbsize; - nxgl_coord_t thickness; - - /* Shiny edge: - * Thickness: 1 - * Color: CONFIG_NXTK_BORDERCOLOR3; - * Condition: CONFIG_NXTK_BORDERWIDTH > 2 - * Central part: - * Thickness: Varies with CONFIG_NXTK_BORDERWIDTH - * Color: CONFIG_NXTK_BORDERCOLOR1; - * Condition: CONFIG_NXTK_BORDERWIDTH > 0 - * Shadow part: - * Thickness: 1; - * Color: CONFIG_NXTK_BORDERCOLOR2; - * Condition: CONFIG_NXTK_BORDERWIDTH > 1 - */ - -#if CONFIG_NXTK_BORDERWIDTH > 2 - thickness = CONFIG_NXTK_BORDERWIDTH - 2; -#elif CONFIG_NXTK_BORDERWIDTH > 1 - thickness = CONFIG_NXTK_BORDERWIDTH - 1; -#else - thickness = CONFIG_NXTK_BORDERWIDTH; -#endif - - /* Get the size of the rectangle */ - - nxgl_rectsize(&wndsize, &fwnd->wnd.bounds); - nxgl_rectsize(&tbsize, &fwnd->tbrect); - - /* Draw the top ***********************************************************/ - -#if CONFIG_NXTK_BORDERWIDTH > 0 - frame.pt1.x = 0; - frame.pt2.x = wndsize.w - 1; - frame.pt1.y = 0; - - /* Draw the shiny edge */ - -#if CONFIG_NXTK_BORDERWIDTH > 2 - frame.pt2.y = 0; - nxtk_drawframeside(fwnd, &frame, bounds, g_bordercolor3); - frame.pt1.y = 1; -#endif - - /* Draw the central part */ - - frame.pt2.y = frame.pt1.y + thickness - 1; - nxtk_drawframeside(fwnd, &frame, bounds, g_bordercolor1); - - /* Draw a single line under the toolbar, color CONFIG_NXTK_BORDERCOLOR2 */ - -#if CONFIG_NXTK_BORDERWIDTH > 1 - frame.pt1.y += tbsize.h + thickness; - frame.pt2.y = frame.pt1.y; - nxtk_drawframeside(fwnd, &frame, bounds, g_bordercolor2); -#endif - - /* Draw the bottom ********************************************************/ - -#if CONFIG_NXTK_BORDERWIDTH > 0 - frame.pt1.y = wndsize.h - CONFIG_NXTK_BORDERWIDTH; - - /* Draw the shiny edge */ - -#if CONFIG_NXTK_BORDERWIDTH > 2 - frame.pt2.y = frame.pt1.y; - nxtk_drawframeside(fwnd, &frame, bounds, g_bordercolor3); - frame.pt1.y ++; -#endif - - /* Draw the central part */ - - frame.pt2.y = frame.pt1.y + thickness - 1; - nxtk_drawframeside(fwnd, &frame, bounds, g_bordercolor1); - - /* Then a single line at the very bottom, Color: CONFIG_NXTK_BORDERCOLOR2 */ - -#if CONFIG_NXTK_BORDERWIDTH > 1 - frame.pt1.y = wndsize.h - 1; - frame.pt2.y = frame.pt1.y; - nxtk_drawframeside(fwnd, &frame, bounds, g_bordercolor2); -#endif -#endif - - /* Draw left and right outer edges *****************************************/ - - /* Draw the shiny left out edge */ - -#if CONFIG_NXTK_BORDERWIDTH > 1 - frame.pt1.x = 0; - frame.pt1.y = 1; -#if CONFIG_NXTK_BORDERWIDTH > 2 - frame.pt2.x = frame.pt1.x; - frame.pt2.y = wndsize.h - 2; - nxtk_drawframeside(fwnd, &frame, bounds, g_bordercolor3); -#endif - - /* Draw the shadowed right outer edge */ - - frame.pt1.x = wndsize.w - 1; - frame.pt2.x = frame.pt1.x; - nxtk_drawframeside(fwnd, &frame, bounds, g_bordercolor2); -#endif - - /* Draw left and right central regions *************************************/ - -#if CONFIG_NXTK_BORDERWIDTH > 2 - frame.pt1.x = 1; - frame.pt1.y = 1; - frame.pt2.x = frame.pt1.x + thickness - 1; - frame.pt2.y = wndsize.h - 2; -#else - frame.pt1.x = 0; - frame.pt1.y = 0; - frame.pt2.x = frame.pt1.x + thickness - 1; - frame.pt2.y = wndsize.h - 1; -#endif - nxtk_drawframeside(fwnd, &frame, bounds, g_bordercolor1); - -#if CONFIG_NXTK_BORDERWIDTH > 2 - frame.pt1.x = wndsize.w - thickness - 1; - frame.pt2.x = wndsize.w - 2; -#else - frame.pt1.x = wndsize.w - thickness; - frame.pt2.x = wndsize.w - 1; -#endif - nxtk_drawframeside(fwnd, &frame, bounds, g_bordercolor1); -#endif - - /* Draw left and right inner sides *****************************************/ - /* This segment stops at the bottom of the toolbar. If there is a - * tool bar, then we have to continue this to the top of the display - * using g_bordercolor1 (see below) - */ - - /* Draw the shadowed left inner edge */ - -#if CONFIG_NXTK_BORDERWIDTH > 1 -#if CONFIG_NXTK_BORDERWIDTH > 2 - frame.pt1.x = thickness + 1; - frame.pt1.y = tbsize.h + thickness + 1; - frame.pt2.x = frame.pt1.x; - frame.pt2.y = wndsize.h - thickness - 2; -#else - frame.pt1.x = thickness; - frame.pt1.y = tbsize.h + thickness; - frame.pt2.x = frame.pt1.x; - frame.pt2.y = wndsize.h - thickness - 1; -#endif - nxtk_drawframeside(fwnd, &frame, bounds, g_bordercolor2); - - /* Draw the shiny right inner edge */ - -#if CONFIG_NXTK_BORDERWIDTH > 2 - frame.pt1.x = wndsize.w - thickness - 2; - frame.pt2.x = frame.pt1.x; - nxtk_drawframeside(fwnd, &frame, bounds, g_bordercolor3); -#endif -#endif - - /* Fix up the little line-seqments at the top inner edges that need to match - * the color of the toolbar. - */ - -#if CONFIG_NXTK_BORDERWIDTH > 1 - if (tbsize.h > 0) - { - /* Draw the right side */ - -#if CONFIG_NXTK_BORDERWIDTH > 2 - frame.pt1.x = thickness + 1; - frame.pt1.y = 1; - frame.pt2.x = frame.pt1.x; - frame.pt2.y = tbsize.h + thickness; -#else - frame.pt1.x = thickness; - frame.pt1.y = 0; - frame.pt2.x = frame.pt1.x; - frame.pt2.y = tbsize.h + thickness - 1; -#endif - nxtk_drawframeside(fwnd, &frame, bounds, g_bordercolor1); - - /* Draw the left size */ - -#if CONFIG_NXTK_BORDERWIDTH > 2 - frame.pt1.x = wndsize.w - thickness - 2; - frame.pt2.x = frame.pt1.x; - nxtk_drawframeside(fwnd, &frame, bounds, g_bordercolor1); -#endif - } -#endif - - return OK; -} diff --git a/nuttx/graphics/nxtk/nxtk_drawlinetoolbar.c b/nuttx/graphics/nxtk/nxtk_drawlinetoolbar.c deleted file mode 100644 index f2a559d69..000000000 --- a/nuttx/graphics/nxtk/nxtk_drawlinetoolbar.c +++ /dev/null @@ -1,139 +0,0 @@ -/**************************************************************************** - * graphics/nxtk/nxtk_drawlinetoolbar.c - * - * Copyright (C) 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include - -#include -#include -#include - -/**************************************************************************** - * Pre-Processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: nxtk_drawlinetoolbar - * - * Description: - * Fill the specified line in the toolbar sub-window with the specified - * color. This is simply a wrapper that uses nxgl_splitline() to break the - * line into trapezoids and then calls nxtk_filltrapwindow() to render the - * line. - * - * Input Parameters: - * hfwnd - The window handle returned by nxtk_openwindow - * vector - Describes the line to be drawn - * width - The width of the line - * color - The color to use to fill the line - * - * Return: - * OK on success; ERROR on failure with errno set appropriately - * - ****************************************************************************/ - -int nxtk_drawlinetoolbar(NXTKWINDOW hfwnd, FAR struct nxgl_vector_s *vector, - nxgl_coord_t width, nxgl_mxpixel_t color[CONFIG_NX_NPLANES]) - -{ - struct nxgl_trapezoid_s trap[3]; - struct nxgl_rect_s rect; - int ret; - -#ifdef CONFIG_DEBUG - if (!hfwnd || !vector || width < 1 || !color) - { - set_errno(EINVAL); - return ERROR; - } -#endif - - ret = nxgl_splitline(vector, trap, &rect, width); - switch (ret) - { - case 0: - ret = nxtk_filltraptoolbar(hfwnd, &trap[0], color); - if (ret == OK) - { - ret = nxtk_filltraptoolbar(hfwnd, &trap[1], color); - if (ret == OK) - { - ret = nxtk_filltraptoolbar(hfwnd, &trap[2], color); - } - } - break; - - case 1: - ret = nxtk_filltraptoolbar(hfwnd, &trap[1], color); - break; - - case 2: - ret = nxtk_filltoolbar(hfwnd, &rect, color); - break; - - default: - set_errno(EINVAL); - return ERROR; - } - - return ret; -} diff --git a/nuttx/graphics/nxtk/nxtk_drawlinewindow.c b/nuttx/graphics/nxtk/nxtk_drawlinewindow.c deleted file mode 100644 index a5534fa59..000000000 --- a/nuttx/graphics/nxtk/nxtk_drawlinewindow.c +++ /dev/null @@ -1,138 +0,0 @@ -/**************************************************************************** - * graphics/nxtk/nxtk_drawlinewindow.c - * - * Copyright (C) 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include - -#include -#include -#include - -/**************************************************************************** - * Pre-Processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: nxtk_drawlinewindow - * - * Description: - * Fill the specified line in the window with the specified color. This - * is simply a wrapper that uses nxgl_splitline() to break the line into - * trapezoids and call calls nxtk_filltrapwindow() to render the line. - * - * Input Parameters: - * hfwnd - The window handle returned by nxtk_openwindow - * vector - Describes the line to be drawn - * width - The width of the line - * color - The color to use to fill the line - * - * Return: - * OK on success; ERROR on failure with errno set appropriately - * - ****************************************************************************/ - -int nxtk_drawlinewindow(NXTKWINDOW hfwnd, FAR struct nxgl_vector_s *vector, - nxgl_coord_t width, nxgl_mxpixel_t color[CONFIG_NX_NPLANES]) - -{ - struct nxgl_trapezoid_s trap[3]; - struct nxgl_rect_s rect; - int ret; - -#ifdef CONFIG_DEBUG - if (!hfwnd || !vector || width < 1 || !color) - { - set_errno(EINVAL); - return ERROR; - } -#endif - - ret = nxgl_splitline(vector, trap, &rect, width); - switch (ret) - { - case 0: - ret = nxtk_filltrapwindow(hfwnd, &trap[0], color); - if (ret == OK) - { - ret = nxtk_filltrapwindow(hfwnd, &trap[1], color); - if (ret == OK) - { - ret = nxtk_filltrapwindow(hfwnd, &trap[2], color); - } - } - break; - - case 1: - ret = nxtk_filltrapwindow(hfwnd, &trap[1], color); - break; - - case 2: - ret = nxtk_fillwindow(hfwnd, &rect, color); - break; - - default: - set_errno(EINVAL); - return ERROR; - } - - return ret; -} diff --git a/nuttx/graphics/nxtk/nxtk_events.c b/nuttx/graphics/nxtk/nxtk_events.c deleted file mode 100644 index facf92176..000000000 --- a/nuttx/graphics/nxtk/nxtk_events.c +++ /dev/null @@ -1,332 +0,0 @@ -/**************************************************************************** - * graphics/nxtk/nxtk_events.c - * - * Copyright (C) 2008-2009, 2012 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include "nxtk_internal.h" - -/**************************************************************************** - * Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Function Prototypes - ****************************************************************************/ - -static void nxtk_redraw(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect, - bool morem, FAR void *arg); -static void nxtk_position(NXWINDOW hwnd, FAR const struct nxgl_size_s *size, - FAR const struct nxgl_point_s *pos, - FAR const struct nxgl_rect_s *bounds, - FAR void *arg); -#ifdef CONFIG_NX_MOUSE -static void nxtk_mousein(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos, - uint8_t buttons, FAR void *arg); -#endif -#ifdef CONFIG_NX_KBD -static void nxtk_kbdin(NXWINDOW hwnd, uint8_t nch, const uint8_t *ch, - FAR void *arg); -#endif -#ifdef CONFIG_NX_MULTIUSER -static void nxtk_blocked(NXWINDOW hwnd, FAR void *arg1, FAR void *arg2); -#endif - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -const struct nx_callback_s g_nxtkcb = -{ - nxtk_redraw, /* redraw */ - nxtk_position /* position */ -#ifdef CONFIG_NX_MOUSE - , nxtk_mousein /* mousein */ -#endif -#ifdef CONFIG_NX_KBD - , nxtk_kbdin /* kbdin */ -#endif -#ifdef CONFIG_NX_MULTIUSER - , nxtk_blocked -#endif -}; - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: nxtk_redraw - ****************************************************************************/ - -static void nxtk_redraw(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect, - bool more, FAR void *arg) -{ - FAR struct nxtk_framedwindow_s *fwnd = (FAR struct nxtk_framedwindow_s *)hwnd; - struct nxgl_rect_s intersection; - - DEBUGASSERT(hwnd && rect && fwnd->fwcb); - - gvdbg("hwnd=%p rect={(%d,%d),(%d,%d)} more=%d\n", - hwnd, rect->pt1.x, rect->pt1.y, rect->pt2.x, rect->pt2.y, more); - - /* The incoming rectangle (rect) is relative to the containing window - * (i.e., (0,0) is the top left corner of the outer, containing window). - * If any part of the rectangle overlaps the client sub-window region, then - * forward the redraw callback. - */ - - if (fwnd->fwcb->redraw) - { - /* Clip the redraw rectangle so that it lies within the client sub-window - * bounds and move the rectangle to that it is relative to the client - * sub-window (i.e., (0,0) is the top left corner of the client sub-window). - */ - - nxtk_containerclip(fwnd, &intersection, rect, &fwnd->fwrect); - - gvdbg("fwrect intersection={(%d,%d),(%d,%d)}\n", - intersection.pt1.x, intersection.pt1.y, - intersection.pt2.x, intersection.pt2.y); - - if (!nxgl_nullrect(&intersection)) - { - fwnd->fwcb->redraw((NXTKWINDOW)fwnd, &intersection, false, fwnd->fwarg); - } - } - - /* If any part of the rectangle overlaps the client toolbar region, then - * forward the redraw callback. - */ - - if (fwnd->tbcb && fwnd->tbcb->redraw) - { - /* Clip the redraw rectangle so that it lies within the toolbar sub-window - * bounds and move the rectangle to that it is relative to the toolbar - * sub-window (i.e., (0,0) is the top left corner of the client sub-window). - */ - - nxtk_containerclip(fwnd, &intersection, rect, &fwnd->tbrect); - - gvdbg("tbrect intersection={(%d,%d),(%d,%d)}\n", - intersection.pt1.x, intersection.pt1.y, - intersection.pt2.x, intersection.pt2.y); - - if (!nxgl_nullrect(&intersection)) - { - fwnd->tbcb->redraw((NXTKWINDOW)fwnd, &intersection, false, fwnd->tbarg); - } - } - - /* Then draw the frame */ - - nxtk_drawframe(fwnd, rect); -} - -/**************************************************************************** - * Name: nxtk_position - ****************************************************************************/ - -static void nxtk_position(NXWINDOW hwnd, FAR const struct nxgl_size_s *size, - FAR const struct nxgl_point_s *pos, - FAR const struct nxgl_rect_s *bounds, - FAR void *arg) -{ - FAR struct nxtk_framedwindow_s *fwnd = (FAR struct nxtk_framedwindow_s *)hwnd; - struct nxgl_size_s subwindowsize; - - gvdbg("hwnd=%p size=(%d,%d) pos=(%d,%d) bounds={(%d,%d),(%d,%d)}\n", - hwnd, size->w, size->h, pos->x, pos->y, - bounds->pt1.x, bounds->pt1.y, bounds->pt2.x, bounds->pt2.y); - - /* Recalculate the dimensions of the toolbar and client windows */ - - nxtk_setsubwindows(fwnd); - - /* Report the size / position of the client sub-window */ - - if (fwnd->fwcb->position) - { - nxgl_rectsize(&subwindowsize, &fwnd->fwrect); - fwnd->fwcb->position((NXTKWINDOW)fwnd, &subwindowsize, - &fwnd->fwrect.pt1, bounds, fwnd->fwarg); - } - - /* Report the size / position of the toolbar sub-window */ - - if (fwnd->tbcb && fwnd->tbcb->position) - { - nxgl_rectsize(&subwindowsize, &fwnd->tbrect); - fwnd->tbcb->position((NXTKWINDOW)fwnd, &subwindowsize, - &fwnd->tbrect.pt1, bounds, fwnd->tbarg); - } -} - -/**************************************************************************** - * Name: nxtk_mousein - ****************************************************************************/ - -#ifdef CONFIG_NX_MOUSE -static void nxtk_mousein(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos, - uint8_t buttons, FAR void *arg) -{ - FAR struct nxtk_framedwindow_s *fwnd = (FAR struct nxtk_framedwindow_s *)hwnd; - struct nxgl_point_s abspos; - struct nxgl_point_s relpos; - - /* Raise the window to the top if any mouse button was pressed or if auto-raise - * is configured. Do this before reporting the mouse event (because processing - * of the mouse event could change the ordering again). - */ - - /* REVISIT: This does not work correctly. In a scenario where (1) there are - * multiple queued touchscreen events and (2) the result of the first input - * was to switch windows, then this autoraise implementation will cause the - * window to revert to the previous window. Not good behavior. - */ - -#ifndef CONFIG_NX_MULTIUSER /* Queuing only happens in multi-user mode */ -#ifdef CONFIG_NXTK_AUTORAISE - if (fwnd->wnd.above != NULL) -#else - if (buttons != 0 && fwnd->wnd.above != NULL) -#endif - { - nx_raise((NXWINDOW)&fwnd->wnd); - } -#endif - - /* When we get here, the mouse position that we receive has already been - * offset by the window origin. Here we need to detect mouse events in - * the various regions of the windows: The toolbar, the client window, - * or the frame. And then offset the position accordingly. - */ - - /* The fwrect and tbrect boxes are both in absolute display coordinates. So - * the easiest thing to do is to restore the mouse position to absolute - * display coordiantes before making the comparisons and adjustments. - */ - - nxgl_vectoradd(&abspos, pos, &fwnd->wnd.bounds.pt1); - - /* In order to deliver mouse release events to the same window where the - * mouse down event happened, we store the initial mouse down location. - */ - - if (fwnd->mbutton == 0 && buttons != 0) - { - fwnd->mpos = abspos; - } - - fwnd->mbutton = buttons; - - /* Is the mouse position inside of the client window region? */ - - if (fwnd->fwcb->mousein && nxgl_rectinside(&fwnd->fwrect, &fwnd->mpos)) - { - nxgl_vectsubtract(&relpos, &abspos, &fwnd->fwrect.pt1); - fwnd->fwcb->mousein((NXTKWINDOW)fwnd, &relpos, buttons, fwnd->fwarg); - } - - /* If the mouse position inside the toobar region? */ - - else if (fwnd->tbcb->mousein && nxgl_rectinside(&fwnd->tbrect, &fwnd->mpos)) - { - nxgl_vectsubtract(&relpos, &abspos, &fwnd->tbrect.pt1); - fwnd->tbcb->mousein((NXTKWINDOW)fwnd, &relpos, buttons, fwnd->tbarg); - } -} -#endif - -/**************************************************************************** - * Name: nxtk_kbdin - ****************************************************************************/ - -#ifdef CONFIG_NX_KBD -static void nxtk_kbdin(NXWINDOW hwnd, uint8_t nch, const uint8_t *ch, - FAR void *arg) -{ - FAR struct nxtk_framedwindow_s *fwnd = (FAR struct nxtk_framedwindow_s *)hwnd; - - /* Only the client window gets keyboard input */ - - if (fwnd->fwcb->kbdin) - { - fwnd->fwcb->kbdin((NXTKWINDOW)fwnd, nch, ch, fwnd->fwarg); - } -} -#endif - -/**************************************************************************** - * Name: nxtk_blocked - ****************************************************************************/ - -#ifdef CONFIG_NX_MULTIUSER -static void nxtk_blocked(NXWINDOW hwnd, FAR void *arg1, FAR void *arg2) -{ - FAR struct nxtk_framedwindow_s *fwnd = (FAR struct nxtk_framedwindow_s *)hwnd; - - /* Only the client window gets keyboard input */ - - if (fwnd->fwcb->blocked) - { - fwnd->fwcb->blocked((NXTKWINDOW)fwnd, fwnd->fwarg, arg2); - } -} -#endif - -/**************************************************************************** - * Public Functions - ****************************************************************************/ diff --git a/nuttx/graphics/nxtk/nxtk_fillcircletoolbar.c b/nuttx/graphics/nxtk/nxtk_fillcircletoolbar.c deleted file mode 100644 index 92dee7e27..000000000 --- a/nuttx/graphics/nxtk/nxtk_fillcircletoolbar.c +++ /dev/null @@ -1,115 +0,0 @@ -/**************************************************************************** - * graphics/nxtk/nxtk_fillcircletoolbar.c - * - * Copyright (C) 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include - -#include -#include - -/**************************************************************************** - * Pre-Processor Definitions - ****************************************************************************/ - -#define NCIRCLE_TRAPS 8 - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: nxtk_fillcircletoolbar - * - * Description: - * Fill a circular region using the specified color. - * - * Input Parameters: - * hfwnd - The window handle returned by nxtk_openwindow() - * center - A pointer to the point that is the center of the circle - * radius - The radius of the circle in pixels. - * color - The color to use to fill the circle. - * - * Return: - * OK on success; ERROR on failure with errno set appropriately - * - ****************************************************************************/ - -int nxtk_fillcircletoolbar(NXWINDOW hfwnd, FAR const struct nxgl_point_s *center, - nxgl_coord_t radius, - nxgl_mxpixel_t color[CONFIG_NX_NPLANES]) -{ - FAR struct nxgl_trapezoid_s traps[NCIRCLE_TRAPS]; - int i; - int ret; - - /* Describe the circular region as a sequence of 8 trapezoids */ - - nxgl_circletraps(center, radius, traps); - - /* Then rend those trapezoids */ - - for (i = 0; i < NCIRCLE_TRAPS; i++) - { - ret = nxtk_filltraptoolbar(hfwnd, &traps[i], color); - if (ret != OK) - { - return ret; - } - } - return OK; -} diff --git a/nuttx/graphics/nxtk/nxtk_fillcirclewindow.c b/nuttx/graphics/nxtk/nxtk_fillcirclewindow.c deleted file mode 100644 index 5f093e035..000000000 --- a/nuttx/graphics/nxtk/nxtk_fillcirclewindow.c +++ /dev/null @@ -1,115 +0,0 @@ -/**************************************************************************** - * graphics/nxtk/nxtk_fillcirclewindow.c - * - * Copyright (C) 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include - -#include -#include - -/**************************************************************************** - * Pre-Processor Definitions - ****************************************************************************/ - -#define NCIRCLE_TRAPS 8 - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: nxtk_fillcirclewindow - * - * Description: - * Fill a circular region using the specified color. - * - * Input Parameters: - * hfwnd - The window handle returned by nxtk_openwindow() - * center - A pointer to the point that is the center of the circle - * radius - The radius of the circle in pixels. - * color - The color to use to fill the circle. - * - * Return: - * OK on success; ERROR on failure with errno set appropriately - * - ****************************************************************************/ - -int nxtk_fillcirclewindow(NXWINDOW hfwnd, FAR const struct nxgl_point_s *center, - nxgl_coord_t radius, - nxgl_mxpixel_t color[CONFIG_NX_NPLANES]) -{ - FAR struct nxgl_trapezoid_s traps[NCIRCLE_TRAPS]; - int i; - int ret; - - /* Describe the circular region as a sequence of 8 trapezoids */ - - nxgl_circletraps(center, radius, traps); - - /* Then rend those trapezoids */ - - for (i = 0; i < NCIRCLE_TRAPS; i++) - { - ret = nxtk_filltrapwindow(hfwnd, &traps[i], color); - if (ret != OK) - { - return ret; - } - } - return OK; -} diff --git a/nuttx/graphics/nxtk/nxtk_filltoolbar.c b/nuttx/graphics/nxtk/nxtk_filltoolbar.c deleted file mode 100644 index 931fa7dec..000000000 --- a/nuttx/graphics/nxtk/nxtk_filltoolbar.c +++ /dev/null @@ -1,116 +0,0 @@ -/**************************************************************************** - * graphics/nxtk/nxtk_filltoolbar.c - * - * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include - -#include -#include - -#include "nxfe.h" -#include "nxtk_internal.h" - -/**************************************************************************** - * Pre-Processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: nxtk_filltoolbar - * - * Description: - * Fill the specified rectangle in the client window with the specified color - * - * Input Parameters: - * 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 - * - * Return: - * OK on success; ERROR on failure with errno set appropriately - * - ****************************************************************************/ - -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 *)hfwnd; - struct nxgl_rect_s fillrect; - -#ifdef CONFIG_DEBUG - if (!hfwnd || !rect || !color) - { - errno = EINVAL; - return ERROR; - } -#endif - - /* Clip the rectangle so that it lies within the sub-window bounds - * then move the rectangle to that it is relative to the containing - * window. - */ - - nxtk_subwindowclip(fwnd, &fillrect, rect, &fwnd->tbrect); - - /* Then fill it */ - - return nx_fill((NXWINDOW)hfwnd, &fillrect, color); -} diff --git a/nuttx/graphics/nxtk/nxtk_filltraptoolbar.c b/nuttx/graphics/nxtk/nxtk_filltraptoolbar.c deleted file mode 100644 index 7108f42eb..000000000 --- a/nuttx/graphics/nxtk/nxtk_filltraptoolbar.c +++ /dev/null @@ -1,110 +0,0 @@ -/**************************************************************************** - * graphics/nxtk/nxtk_filltraptoolbar.c - * - * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include - -#include -#include - -#include "nxfe.h" -#include "nxtk_internal.h" - -/**************************************************************************** - * Pre-Processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: nxtk_filltraptoolbar - * - * Description: - * Fill the specified rectangle in the toolbar with the specified color - * - * Input Parameters: - * hfwnd - The handle returned by nxtk_openwindow - * trap - The trapezoidal region to be filled - * color - The color to use in the fill - * - * Return: - * OK on success; ERROR on failure with errno set appropriately - * - ****************************************************************************/ - -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 *)hfwnd; - struct nxgl_rect_s relclip; - -#ifdef CONFIG_DEBUG - if (!hfwnd || !trap || !color) - { - errno = EINVAL; - return ERROR; - } -#endif - - /* 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)hfwnd, &relclip, trap, color); -} diff --git a/nuttx/graphics/nxtk/nxtk_filltrapwindow.c b/nuttx/graphics/nxtk/nxtk_filltrapwindow.c deleted file mode 100644 index 55c051ffd..000000000 --- a/nuttx/graphics/nxtk/nxtk_filltrapwindow.c +++ /dev/null @@ -1,117 +0,0 @@ -/**************************************************************************** - * graphics/nxtk/nxtk_filltrapwindow.c - * - * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include - -#include -#include - -#include "nxfe.h" -#include "nxtk_internal.h" - -/**************************************************************************** - * Pre-Processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: nxtk_filltrapwindow - * - * Description: - * Fill the specified rectangle in the client window with the specified color - * - * Input Parameters: - * hfwnd - The window handle returned by nxtk_openwindow - * trap - The trapezoidal region to be filled - * color - The color to use in the fill - * - * Return: - * OK on success; ERROR on failure with errno set appropriately - * - ****************************************************************************/ - -int nxtk_filltrapwindow(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 *)hfwnd; - struct nxgl_rect_s relclip; - struct nxgl_trapezoid_s reltrap; - -#ifdef CONFIG_DEBUG - if (!hfwnd || !trap || !color) - { - errno = EINVAL; - return ERROR; - } -#endif - - /* Move the trapezoid from window contents area to window area */ - - nxgl_trapoffset(&reltrap, trap, - fwnd->fwrect.pt1.x - fwnd->wnd.bounds.pt1.x, - fwnd->fwrect.pt1.y - fwnd->wnd.bounds.pt1.y); - - /* Perform the fill, clipping to the client window */ - nxgl_rectoffset(&relclip, &fwnd->fwrect, -fwnd->wnd.bounds.pt1.x, -fwnd->wnd.bounds.pt1.y); - - return nx_filltrapezoid((NXWINDOW)hfwnd, &relclip, &reltrap, color); -} diff --git a/nuttx/graphics/nxtk/nxtk_fillwindow.c b/nuttx/graphics/nxtk/nxtk_fillwindow.c deleted file mode 100644 index c76dbfbb4..000000000 --- a/nuttx/graphics/nxtk/nxtk_fillwindow.c +++ /dev/null @@ -1,116 +0,0 @@ -/**************************************************************************** - * graphics/nxtk/nxtk_fillwindow.c - * - * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include - -#include -#include - -#include "nxfe.h" -#include "nxtk_internal.h" - -/**************************************************************************** - * Pre-Processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: nxtk_fillwindow - * - * Description: - * Fill the specified rectangle in the client window with the specified color - * - * Input Parameters: - * hfwnd - The window handle returned by nxtk_openwindow - * rect - The location within the client window to be filled - * color - The color to use in the fill - * - * Return: - * OK on success; ERROR on failure with errno set appropriately - * - ****************************************************************************/ - -int nxtk_fillwindow(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 *)hfwnd; - struct nxgl_rect_s fillrect; - -#ifdef CONFIG_DEBUG - if (!hfwnd || !rect || !color) - { - errno = EINVAL; - return ERROR; - } -#endif - - /* Clip the rectangle so that it lies within the sub-window bounds - * then move the rectangle to that it is relative to the containing - * window. - */ - - nxtk_subwindowclip(fwnd, &fillrect, rect, &fwnd->fwrect); - - /* Then fill it */ - - return nx_fill((NXWINDOW)hfwnd, &fillrect, color); -} diff --git a/nuttx/graphics/nxtk/nxtk_getposition.c b/nuttx/graphics/nxtk/nxtk_getposition.c deleted file mode 100644 index 7850f7714..000000000 --- a/nuttx/graphics/nxtk/nxtk_getposition.c +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************** - * graphics/nxtk/nxtk_getposition.c - * - * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include - -#include -#include - -#include "nxfe.h" -#include "nxtk_internal.h" - -/**************************************************************************** - * Pre-Processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: nxtk_getposition - * - * Description: - * Request the position and size information for the selected framed window. - * The size/position for the client window and toolbar will be return - * asynchronously through the client callback function pointer. - * - * Input Parameters: - * hfwnd - The window handle returned by nxtk_openwindow. - * - * Return: - * OK on success; ERROR on failure with errno set appropriately - * - ****************************************************************************/ - -int nxtk_getposition(NXTKWINDOW hfwnd) -{ - return nx_getposition((NXWINDOW)hfwnd); -} diff --git a/nuttx/graphics/nxtk/nxtk_gettoolbar.c b/nuttx/graphics/nxtk/nxtk_gettoolbar.c deleted file mode 100644 index 5b08fc840..000000000 --- a/nuttx/graphics/nxtk/nxtk_gettoolbar.c +++ /dev/null @@ -1,123 +0,0 @@ -/**************************************************************************** - * graphics/nxtk/nxtk_gettoolbar.c - * - * Copyright (C) 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include - -#include -#include - -#include "nxfe.h" -#include "nxtk_internal.h" - -/**************************************************************************** - * Pre-Processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: nxtk_gettoolbar - * - * Description: - * Get the raw contents of graphic memory within a rectangular region. NOTE: - * Since raw graphic memory is returned, the returned memory content may be - * the memory of windows above this one and may not necessarily belong to - * this window unless you assure that this is the top window. - * - * Input Parameters: - * wnd - The window structure reference - * rect - The location to be copied - * plane - Specifies the color plane to get from. - * dest - The location to copy the memory region - * deststride - The width, in bytes, of the dest memory - * - * Return: - * OK on success; ERROR on failure with errno set appropriately - * - ****************************************************************************/ - -int nxtk_gettoolbar(NXTKWINDOW hfwnd, FAR const struct nxgl_rect_s *rect, - unsigned int plane, FAR uint8_t *dest, - unsigned int deststride) -{ - FAR struct nxtk_framedwindow_s *fwnd = (FAR struct nxtk_framedwindow_s *)hfwnd; - struct nxgl_rect_s getrect; - -#ifdef CONFIG_DEBUG - if (!hfwnd || !rect || !dest) - { - gvdbg("Invalid parameters\n"); - set_errno(EINVAL); - return ERROR; - } -#endif - - /* Clip the rectangle so that it lies within the sub-window bounds - * then move the rectangle to that it is relative to the containing - * window. - */ - - nxtk_subwindowclip(fwnd, &getrect, rect, &fwnd->tbrect); - - /* Then get it */ - - return nx_getrectangle((NXWINDOW)hfwnd, &getrect, plane, dest, deststride); -} diff --git a/nuttx/graphics/nxtk/nxtk_getwindow.c b/nuttx/graphics/nxtk/nxtk_getwindow.c deleted file mode 100644 index b0082874f..000000000 --- a/nuttx/graphics/nxtk/nxtk_getwindow.c +++ /dev/null @@ -1,126 +0,0 @@ -/**************************************************************************** - * graphics/nxtk/nxtk_getwindow.c - * - * Copyright (C) 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include - -#include -#include - -#include "nxfe.h" -#include "nxtk_internal.h" - -/**************************************************************************** - * Pre-Processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: nxtk_getwindow - * - * Description: - * Get the raw contents of graphic memory within a rectangular region. NOTE: - * Since raw graphic memory is returned, the returned memory content may be - * the memory of windows above this one and may not necessarily belong to - * this window unless you assure that this is the top window. - * - * Input Parameters: - * wnd - The window structure reference - * rect - The location to be copied - * plane - Specifies the color plane to get from. - * dest - The location to copy the memory region - * deststride - The width, in bytes, of the dest memory - * - * Return: - * OK on success; ERROR on failure with errno set appropriately - * - ****************************************************************************/ - -int nxtk_getwindow(NXTKWINDOW hfwnd, FAR const struct nxgl_rect_s *rect, - unsigned int plane, FAR uint8_t *dest, - unsigned int deststride) -{ - FAR struct nxtk_framedwindow_s *fwnd = (FAR struct nxtk_framedwindow_s *)hfwnd; - struct nxgl_rect_s getrect; - -#ifdef CONFIG_DEBUG - if (!hfwnd || !rect || !dest) - { - gvdbg("Invalid parameters\n"); - set_errno(EINVAL); - return ERROR; - } -#endif - - /* Move the rectangle to that it is relative to the containing - * window. If part of the rectangle lies outside the window, - * it will contain garbage data, but the contained area will be - * valid. - */ - - nxgl_rectoffset(&getrect, rect, - fwnd->fwrect.pt1.x - fwnd->wnd.bounds.pt1.x, - fwnd->fwrect.pt1.y - fwnd->wnd.bounds.pt1.y); - - /* Then get it */ - - return nx_getrectangle((NXWINDOW)hfwnd, &getrect, plane, dest, deststride); -} diff --git a/nuttx/graphics/nxtk/nxtk_internal.h b/nuttx/graphics/nxtk/nxtk_internal.h deleted file mode 100644 index 3a31215d8..000000000 --- a/nuttx/graphics/nxtk/nxtk_internal.h +++ /dev/null @@ -1,225 +0,0 @@ -/**************************************************************************** - * graphics/nxtk/nxtk_internal.h - * - * Copyright (C) 2008-2009, 2011-1021 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -#ifndef __GRAPHICS_NXTK_NXTK_INTERNAL_H -#define __GRAPHICS_NXTK_NXTK_INTERNAL_H - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include "nxbe.h" -#include "nxfe.h" - -/**************************************************************************** - * Pre-processor definitions - ****************************************************************************/ - -/**************************************************************************** - * Public Types - ****************************************************************************/ - -/* This is the internal representation of the framed window object */ - -struct nxtk_framedwindow_s -{ - struct nxbe_window_s wnd; /* The raw NX window */ - - /* The toolbar region and callbacks */ - - nxgl_coord_t tbheight; - struct nxgl_rect_s tbrect; - FAR const struct nx_callback_s *tbcb; - FAR void *tbarg; - - /* Window data region and callbacks */ - - struct nxgl_rect_s fwrect; - FAR const struct nx_callback_s *fwcb; - FAR void *fwarg; - - /* Initial mouse down location */ - - uint8_t mbutton; - struct nxgl_point_s mpos; -}; - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -#undef EXTERN -#if defined(__cplusplus) -# define EXTERN extern "C" -extern "C" { -#else -# define EXTERN extern -#endif - -/* That is the callback for the framed window */ - -extern FAR const struct nx_callback_s g_nxtkcb; - -/* Frame border colors */ - -extern nxgl_mxpixel_t g_bordercolor1[CONFIG_NX_NPLANES]; -extern nxgl_mxpixel_t g_bordercolor2[CONFIG_NX_NPLANES]; -extern nxgl_mxpixel_t g_bordercolor3[CONFIG_NX_NPLANES]; - -/**************************************************************************** - * Public Function Prototypes - ****************************************************************************/ - -/**************************************************************************** - * Name: nxtk_setsubwindows - * - * Description: - * Give the window dimensions, border width, and toolbar height, - * calculate the new dimensions of the toolbar region and client window - * region - * - ****************************************************************************/ - -EXTERN void nxtk_setsubwindows(FAR struct nxtk_framedwindow_s *fwnd); - -/**************************************************************************** - * Name: nxtk_subwindowclip - * - * Description: - * Clip the src rectangle so that it lies within the sub-window bounds - * then move the rectangle to that it is relative to the containing - * window. - * - * Input parameters: - * fwnd - The framed window to be used - * dest - The locaton to put the result - * src - The src rectangle in relative sub-window coordinates - * bounds - The subwindow bounds in absolute screen coordinates. - * - * Returned value: - * None - * - ****************************************************************************/ - -EXTERN void nxtk_subwindowclip(FAR struct nxtk_framedwindow_s *fwnd, - FAR struct nxgl_rect_s *dest, - FAR const struct nxgl_rect_s *src, - FAR const struct nxgl_rect_s *bounds); - -/**************************************************************************** - * Name: nxtk_containerclip - * - * Description: - * We are given a 'src' rectangle in containing window, relative coordinates - * (i.e., (0,0) is the top left corner of the outer, containing window). - * This function will (1) clip that src rectangle so that it lies within - * the sub-window bounds, and then (2) move the rectangle to that it is - * relative to the sub-window (i.e., (0,0) is the top left corner of the - * sub-window). - * - * Input parameters: - * fwnd - The framed window to be used - * dest - The locaton to put the result - * src - The src rectangle in relative container-window coordinates - * bounds - The subwindow bounds in absolute screen coordinates. - * - * Returned value: - * None - * - ****************************************************************************/ - -EXTERN void nxtk_containerclip(FAR struct nxtk_framedwindow_s *fwnd, - FAR struct nxgl_rect_s *dest, - FAR const struct nxgl_rect_s *src, - FAR const struct nxgl_rect_s *bounds); - -/**************************************************************************** - * Name: nxtk_subwindowmove - * - * Description: - * Perform common clipping operations in preparatons for calling nx_move() - * - * Input Parameters: - * fwnd - The framed window within which the move is to be done. - * This must have been previously created by nxtk_openwindow(). - * destrect - The loccation to receive the clipped rectangle relative - * to containing window - * destoffset - The location to received the clipped offset. - * srcrect - Describes the rectangular region relative to the client - * sub-window to move relative to the sub-window - * srcoffset - The offset to move the region - * bounds - The subwindow bounds in absolute screen coordinates. - * - * Return: - * OK on success; ERROR on failure with errno set appropriately - * - ****************************************************************************/ - -EXTERN void nxtk_subwindowmove(FAR struct nxtk_framedwindow_s *fwnd, - FAR struct nxgl_rect_s *destrect, - FAR struct nxgl_point_s *destoffset, - FAR const struct nxgl_rect_s *srcrect, - FAR const struct nxgl_point_s *srcoffset, - FAR const struct nxgl_rect_s *bounds); - -/**************************************************************************** - * Name: nxtk_drawframe - * - * Description: - * Redraw the window frame. - * - * Input parameters: - * fwnd - the framed window whose frame needs to be re-drawn. This must - * have been previously created by nxtk_openwindow(). - * bounds - Only draw the ports of the frame within this bounding box. - * (window relative coordinates). - * - * Returned value: - * OK on success; ERROR on failure with errno set appropriately - * - ****************************************************************************/ - -EXTERN int nxtk_drawframe(FAR struct nxtk_framedwindow_s *fwnd, - FAR const struct nxgl_rect_s *bounds); - -#undef EXTERN -#if defined(__cplusplus) -} -#endif - -#endif /* __GRAPHICS_NXTK_NXTK_INTERNAL_H */ diff --git a/nuttx/graphics/nxtk/nxtk_lower.c b/nuttx/graphics/nxtk/nxtk_lower.c deleted file mode 100644 index e37e020fc..000000000 --- a/nuttx/graphics/nxtk/nxtk_lower.c +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************** - * graphics/nxtk/nxtk_lower.c - * - * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include - -#include -#include - -#include "nxfe.h" -#include "nxtk_internal.h" - -/**************************************************************************** - * Pre-Processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: nxtk_lower - * - * Description: - * Lower the window containing the specified client sub-window to the - * bottom of the display. - * - * Input parameters: - * hfwnd - the window to be lowered. This must have been previously created - * by nxtk_openwindow(). - * - * Returned value: - * OK on success; ERROR on failure with errno set appropriately - * - ****************************************************************************/ - -int nxtk_lower(NXTKWINDOW hfwnd) -{ - return nx_lower((NXWINDOW)hfwnd); -} diff --git a/nuttx/graphics/nxtk/nxtk_movetoolbar.c b/nuttx/graphics/nxtk/nxtk_movetoolbar.c deleted file mode 100644 index 9170394f1..000000000 --- a/nuttx/graphics/nxtk/nxtk_movetoolbar.c +++ /dev/null @@ -1,119 +0,0 @@ -/**************************************************************************** - * graphics/nxtk/nxtk_movetoolbar.c - * - * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include - -#include -#include - -#include "nxfe.h" -#include "nxtk_internal.h" - -/**************************************************************************** - * Pre-Processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * 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 - * - ****************************************************************************/ - -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 *)hfwnd; - struct nxgl_rect_s srcrect; - struct nxgl_point_s clipoffset; - -#ifdef CONFIG_DEBUG - if (!hfwnd || !rect || !offset) - { - errno = EINVAL; - return ERROR; - } -#endif - - /* Make sure that both the source and dest rectangle lie within the - * toolbar sub-window - */ - - nxtk_subwindowmove(fwnd, &srcrect, &clipoffset, rect, offset, &fwnd->tbrect); - - /* Then move it within the toolbar window */ - - return nx_move((NXWINDOW)hfwnd, &srcrect, &clipoffset); -} diff --git a/nuttx/graphics/nxtk/nxtk_movewindow.c b/nuttx/graphics/nxtk/nxtk_movewindow.c deleted file mode 100644 index 83d95b3a4..000000000 --- a/nuttx/graphics/nxtk/nxtk_movewindow.c +++ /dev/null @@ -1,118 +0,0 @@ -/**************************************************************************** - * graphics/nxtk/nxtk_movewindow.c - * - * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include - -#include -#include - -#include "nxfe.h" -#include "nxtk_internal.h" - -/**************************************************************************** - * Pre-Processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: nxtk_movewindow - * - * Description: - * Move a rectangular region within the client sub-window of a framed window - * - * Input Parameters: - * hfwnd - The client sub-window 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 client - * sub-window to move - * offset - The offset to move the region - * - * Return: - * OK on success; ERROR on failure with errno set appropriately - * - ****************************************************************************/ - -int nxtk_movewindow(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 *)hfwnd; - struct nxgl_rect_s srcrect; - struct nxgl_point_s clipoffset; - -#ifdef CONFIG_DEBUG - if (!hfwnd || !rect || !offset) - { - errno = EINVAL; - return ERROR; - } -#endif - - /* Make sure that both the source and dest rectangle lie within the - * client sub-window - */ - - nxtk_subwindowmove(fwnd, &srcrect, &clipoffset, rect, offset, &fwnd->fwrect); - - /* Then move it within the client window */ - - return nx_move((NXWINDOW)hfwnd, &srcrect, &clipoffset); -} diff --git a/nuttx/graphics/nxtk/nxtk_opentoolbar.c b/nuttx/graphics/nxtk/nxtk_opentoolbar.c deleted file mode 100644 index e82dbed6f..000000000 --- a/nuttx/graphics/nxtk/nxtk_opentoolbar.c +++ /dev/null @@ -1,127 +0,0 @@ -/**************************************************************************** - * graphics/nxtk/nxtk_opentoolbar.c - * - * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include - -#include -#include - -#include "nxfe.h" -#include "nxtk_internal.h" - -/**************************************************************************** - * Pre-Processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: nxtk_opentoolbar - * - * Description: - * Create a tool bar at the top of the specified framed window - * - * Input Parameters: - * hfwnd - The handle returned by nxtk_openwindow - * height - The request height of the toolbar in pixels - * cb - Callbacks used to process toolbar events - * arg - User provided value that will be returned with toolbar callbacks. - * - * Return: - * OK on success; ERROR on failure with errno set appropriately - * - ****************************************************************************/ - -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; - -#ifdef CONFIG_DEBUG - if (!hfwnd || !cb) - { - errno = EINVAL; - return ERROR; - } -#endif - - /* Initialize the toolbar info */ - - fwnd->tbheight = height; - fwnd->tbcb = cb; - fwnd->tbarg = arg; - - /* Calculate the new dimensions of the toolbar and client windows */ - - nxtk_setsubwindows(fwnd); - - /* Then redraw the entire window, even the client window must be - * redrawn because it has changed its vertical position and size. - */ - - nxfe_redrawreq(&fwnd->wnd, &fwnd->wnd.bounds); - - /* Return the initialized toolbar reference */ - - return OK; -} - diff --git a/nuttx/graphics/nxtk/nxtk_openwindow.c b/nuttx/graphics/nxtk/nxtk_openwindow.c deleted file mode 100644 index 0c77a6877..000000000 --- a/nuttx/graphics/nxtk/nxtk_openwindow.c +++ /dev/null @@ -1,160 +0,0 @@ -/**************************************************************************** - * graphics/nxtk/nxtk_openwindow.c - * - * Copyright (C) 2008-2009, 2012 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include - -#include -#include - -#include "nxfe.h" -#include "nxtk_internal.h" - -/**************************************************************************** - * Pre-Processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -nxgl_mxpixel_t g_bordercolor1[CONFIG_NX_NPLANES] = -{ - CONFIG_NXTK_BORDERCOLOR1 -#if CONFIG_NX_NPLANES > 1 -# error "Multiple plane border colors not defined" -#endif -}; - -nxgl_mxpixel_t g_bordercolor2[CONFIG_NX_NPLANES] = -{ - CONFIG_NXTK_BORDERCOLOR2 -#if CONFIG_NX_NPLANES > 1 -# error "Multiple plane border colors not defined" -#endif -}; - -nxgl_mxpixel_t g_bordercolor3[CONFIG_NX_NPLANES] = -{ - CONFIG_NXTK_BORDERCOLOR3 -#if CONFIG_NX_NPLANES > 1 -# error "Multiple plane border colors not defined" -#endif -}; - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: nxtk_openwindow - * - * Description: - * Create a new, framed window. - * - * Input Parameters: - * handle - The handle returned by nx_connect - * cb - Callbacks used to process window events - * arg - User provided value that will be returned with NXTK callbacks. - * - * Return: - * Success: A non-NULL handle used with subsequent NXTK window accesses - * Failure: NULL is returned and errno is set appropriately - * - ****************************************************************************/ - -NXTKWINDOW nxtk_openwindow(NXHANDLE handle, - FAR const struct nx_callback_s *cb, - FAR void *arg) -{ - FAR struct nxtk_framedwindow_s *fwnd; - int ret; - -#ifdef CONFIG_DEBUG - if (!handle || !cb) - { - errno = EINVAL; - return NULL; - } -#endif - - /* Pre-allocate the window structure */ - - fwnd = (FAR struct nxtk_framedwindow_s *)kzalloc(sizeof(struct nxtk_framedwindow_s)); - if (!fwnd) - { - errno = ENOMEM; - return NULL; - } - - /* Initialize the window structure */ - - fwnd->fwcb = cb; - fwnd->fwarg = arg; - - /* Then let nxfe_constructwindow do the rest */ - - ret = nxfe_constructwindow(handle, &fwnd->wnd, &g_nxtkcb, NULL); - if (ret < 0) - { - /* An error occurred, the window has been freed */ - - return NULL; - } - - /* Return the initialized window reference */ - - return (NXTKWINDOW)fwnd; -} - diff --git a/nuttx/graphics/nxtk/nxtk_raise.c b/nuttx/graphics/nxtk/nxtk_raise.c deleted file mode 100644 index f20b25899..000000000 --- a/nuttx/graphics/nxtk/nxtk_raise.c +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************** - * graphics/nxtk/nxtk_raise.c - * - * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include - -#include -#include - -#include "nxfe.h" -#include "nxtk_internal.h" - -/**************************************************************************** - * Pre-Processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: nxtk_raise - * - * Description: - * Bring the window containing the specified client sub-window to the top - * of the display. - * - * Input parameters: - * hfwnd - the window to be raised. This must have been previously created - * by nxtk_openwindow(). - * - * Returned value: - * OK on success; ERROR on failure with errno set appropriately - * - ****************************************************************************/ - -int nxtk_raise(NXTKWINDOW hfwnd) -{ - return nx_raise((NXWINDOW)hfwnd); -} diff --git a/nuttx/graphics/nxtk/nxtk_setposition.c b/nuttx/graphics/nxtk/nxtk_setposition.c deleted file mode 100644 index 2a2a60665..000000000 --- a/nuttx/graphics/nxtk/nxtk_setposition.c +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** - * graphics/nxtk/nxtk_setposition.c - * - * Copyright (C) 2008-2009, 2012 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include - -#include -#include - -#include "nxfe.h" -#include "nxtk_internal.h" - -/**************************************************************************** - * Pre-Processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: nxtk_setposition - * - * Description: - * Set the position for the selected client window. This position does not - * include the offsets for the borders nor for any toolbar. Those offsets - * will be added in to set the full window position. - * - * Input Parameters: - * hfwnd - The window handle returned by nxtk_openwindow - * pos - The new position of the client sub-window - * - * Return: - * OK on success; ERROR on failure with errno set appropriately - * - ****************************************************************************/ - -int nxtk_setposition(NXTKWINDOW hfwnd, FAR const struct nxgl_point_s *pos) -{ - FAR struct nxtk_framedwindow_s *fwnd = (FAR struct nxtk_framedwindow_s *)hfwnd; - struct nxgl_point_s offset; - struct nxgl_point_s newpos; - - /* Calculate the offset that is requested and add that to the window origin. */ - - nxgl_vectsubtract(&offset, pos, &fwnd->fwrect.pt1); - nxgl_vectoradd(&newpos, &offset, &fwnd->wnd.bounds.pt1); - - /* Then set that position */ - - return nx_setposition((NXWINDOW)hfwnd, &newpos); -} diff --git a/nuttx/graphics/nxtk/nxtk_setsize.c b/nuttx/graphics/nxtk/nxtk_setsize.c deleted file mode 100644 index 332ea00b5..000000000 --- a/nuttx/graphics/nxtk/nxtk_setsize.c +++ /dev/null @@ -1,114 +0,0 @@ -/**************************************************************************** - * graphics/nxtk/nxtk_setsize.c - * - * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include - -#include -#include - -#include "nxfe.h" -#include "nxtk_internal.h" - -/**************************************************************************** - * Pre-Processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: nxtk_setsize - * - * Description: - * Set the size for the selected client window. This size does not - * include the sizes of the borders nor for any toolbar. Those sizes - * will be added in to set the full window size. - * - * Input Parameters: - * hfwnd - The window handle returned by nxtk_openwindow - * size - The new size of the client sub-window. - * - * Return: - * OK on success; ERROR on failure with errno set appropriately - * - ****************************************************************************/ - -int nxtk_setsize(NXTKWINDOW hfwnd, FAR const struct nxgl_size_s *size) -{ - FAR struct nxtk_framedwindow_s *fwnd = (FAR struct nxtk_framedwindow_s *)hfwnd; - struct nxgl_size_s newsize; - -#ifdef CONFIG_DEBUG - if (!hfwnd || !size) - { - errno = EINVAL; - return ERROR; - } -#endif - - /* Add the sizes need for the toolbar and the borders */ - - newsize.w = size->w + 2 * CONFIG_NXTK_BORDERWIDTH; - newsize.h = size->h + fwnd->tbheight + 2 * CONFIG_NXTK_BORDERWIDTH; - - /* Then set the window size */ - - return nx_setsize((NXWINDOW)hfwnd, &newsize); -} diff --git a/nuttx/graphics/nxtk/nxtk_setsubwindows.c b/nuttx/graphics/nxtk/nxtk_setsubwindows.c deleted file mode 100644 index 143909ea4..000000000 --- a/nuttx/graphics/nxtk/nxtk_setsubwindows.c +++ /dev/null @@ -1,165 +0,0 @@ -/**************************************************************************** - * graphics/nxtk/nxtk_setsubwindows.c - * - * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include -#include - -#include -#include "nxtk_internal.h" - -/**************************************************************************** - * Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Function Prototypes - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: nxtk_setsubwindows - * - * Description: - * Give the window dimensions, border width, and toolbar height, - * calculate the new dimensions of the toolbar region and client window - * region - * - ****************************************************************************/ - -void nxtk_setsubwindows(FAR struct nxtk_framedwindow_s *fwnd) -{ - nxgl_coord_t fullheight; - nxgl_coord_t bdrheight = 0; - nxgl_coord_t tbtop = fwnd->wnd.bounds.pt1.y; - nxgl_coord_t tbheight = 0; - nxgl_coord_t fwtop = fwnd->wnd.bounds.pt1.y; - nxgl_coord_t fwheight = 0; - nxgl_coord_t fullwidth; - nxgl_coord_t bdrwidth; - nxgl_coord_t fwwidth; - nxgl_coord_t fwleft; - - /* Divide up the vertical dimension of the window */ - - fullheight = fwnd->wnd.bounds.pt2.y - fwnd->wnd.bounds.pt1.y + 1; - - /* Is it tall enough for a border? */ - - if (fullheight > 0) - { - /* Get the border height */ - - bdrheight = ngl_min(2 * CONFIG_NXTK_BORDERWIDTH, fullheight); - - /* Position the toolbar and client window just under the top border */ - -#if CONFIG_NXTK_BORDERWIDTH > 1 - tbtop += CONFIG_NXTK_BORDERWIDTH - 1; - fwtop = tbtop + 1; -#else - tbtop += CONFIG_NXTK_BORDERWIDTH; - fwtop = tbtop; -#endif - - /* Is it big enough for any part of the toolbar? */ - - if (fullheight > 2 * CONFIG_NXTK_BORDERWIDTH) - { - /* Yes.. get the height of the toolbar */ - - tbheight = fwnd->tbheight; - if (tbheight >= fullheight - bdrheight) - { - tbheight = fullheight - bdrheight; - } - else - { - /* And the client window gets whatever is left */ - - fwheight = fullheight - bdrheight - tbheight; - } - - /* Position the client window just under the toolbar */ - - fwtop += tbheight; - } - } - - /* Divide up the horizontal dimensions of the window */ - - fullwidth = fwnd->wnd.bounds.pt2.x - fwnd->wnd.bounds.pt1.x + 1; - bdrwidth = ngl_min(2 * CONFIG_NXTK_BORDERWIDTH, fullwidth); - fwwidth = fullwidth - bdrwidth; - fwleft = fwnd->wnd.bounds.pt1.x + bdrwidth / 2; - - /* Realize the positions/dimensions */ - - fwnd->tbrect.pt1.x = fwleft; - fwnd->tbrect.pt1.y = tbtop; - fwnd->tbrect.pt2.x = fwleft + fwwidth - 1; - fwnd->tbrect.pt2.y = tbtop + tbheight - 1; - - fwnd->fwrect.pt1.x = fwleft; - fwnd->fwrect.pt1.y = fwtop; - fwnd->fwrect.pt2.x = fwleft + fwwidth - 1; - fwnd->fwrect.pt2.y = fwtop + fwheight - 1; -} diff --git a/nuttx/graphics/nxtk/nxtk_subwindowclip.c b/nuttx/graphics/nxtk/nxtk_subwindowclip.c deleted file mode 100644 index 2dbefb648..000000000 --- a/nuttx/graphics/nxtk/nxtk_subwindowclip.c +++ /dev/null @@ -1,118 +0,0 @@ -/**************************************************************************** - * graphics/nxtk/nxtk_subwindowclip.c - * - * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include - -#include -#include - -#include "nxfe.h" -#include "nxtk_internal.h" - -/**************************************************************************** - * Pre-Processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: nxtk_subwindowclip - * - * Description: - * We are given a 'src' rectangle in sub-window, relative coordinates - * (i.e., (0,0) is the top left corner of the sub-window). This function - * will (1) clip that src rectangle so that it lies within the sub-window - * bounds, and then (2) move the rectangle to that it is relative to the - * containing window (i.e., (0,0) is the top left corner of the containing - * window). - * - * Input parameters: - * fwnd - The framed window to be used - * dest - The locaton to put the result - * src - The src rectangle in relative sub-window coordinates - * bounds - The subwindow bounds in absolute screen coordinates. - * - * Returned value: - * None - * - ****************************************************************************/ - -void nxtk_subwindowclip(FAR struct nxtk_framedwindow_s *fwnd, - FAR struct nxgl_rect_s *dest, - FAR const struct nxgl_rect_s *src, - FAR const struct nxgl_rect_s *bounds) -{ - struct nxgl_rect_s tmp; - - /* Temporarily, position the src rectangle in absolute screen coordinates */ - - nxgl_rectoffset(&tmp, src, bounds->pt1.x, bounds->pt1.y); - - /* Clip the src rectangle to lie within the client window region */ - - nxgl_rectintersect(&tmp, &tmp, bounds); - - /* Then move the rectangle so that is relative to the containing window, not the - * client subwindow - */ - - nxgl_rectoffset(dest, &tmp, -fwnd->wnd.bounds.pt1.x, -fwnd->wnd.bounds.pt1.y); -} diff --git a/nuttx/graphics/nxtk/nxtk_subwindowmove.c b/nuttx/graphics/nxtk/nxtk_subwindowmove.c deleted file mode 100644 index 3c2bb7f37..000000000 --- a/nuttx/graphics/nxtk/nxtk_subwindowmove.c +++ /dev/null @@ -1,149 +0,0 @@ -/**************************************************************************** - * graphics/nxtk/nxtk_subwindowmove.c - * - * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include - -#include -#include - -#include "nxfe.h" -#include "nxtk_internal.h" - -/**************************************************************************** - * Pre-Processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: nxtk_subwindowmove - * - * Description: - * Perform common clipping operations in preparatons for calling nx_move() - * - * Input Parameters: - * fwnd - The framed window within which the move is to be done. - * This must have been previously created by nxtk_openwindow(). - * destrect - The loccation to receive the clipped rectangle relative - * to containing window - * destoffset - The location to received the clipped offset. - * srcrect - Describes the rectangular region relative to the client - * sub-window to move relative to the sub-window - * srcoffset - The offset to move the region - * bounds - The subwindow bounds in absolute screen coordinates. - * - * Return: - * OK on success; ERROR on failure with errno set appropriately - * - ****************************************************************************/ - -void nxtk_subwindowmove(FAR struct nxtk_framedwindow_s *fwnd, - FAR struct nxgl_rect_s *destrect, - FAR struct nxgl_point_s *destoffset, - FAR const struct nxgl_rect_s *srcrect, - FAR const struct nxgl_point_s *srcoffset, - FAR const struct nxgl_rect_s *bounds) -{ - struct nxgl_rect_s abssrc; - - /* Temporarily, position the src rectangle in absolute screen coordinates */ - - nxgl_rectoffset(&abssrc, srcrect, bounds->pt1.x, bounds->pt1.y); - - /* Clip the src rectangle to lie within the client window region */ - - nxgl_rectintersect(&abssrc, &abssrc, &fwnd->fwrect); - - /* Clip the source rectangle so that destination area is within the window. */ - - destoffset->x = srcoffset->x; - if (destoffset->x < 0) - { - if (abssrc.pt1.x + destoffset->x < bounds->pt1.x) - { - abssrc.pt1.x = bounds->pt1.x - destoffset->x; - } - } - else if (abssrc.pt2.x + destoffset->x > bounds->pt2.x) - { - abssrc.pt2.x = bounds->pt2.x - destoffset->x; - } - - destoffset->y = srcoffset->y; - if (destoffset->y < 0) - { - if (abssrc.pt1.y + destoffset->y < bounds->pt1.y) - { - abssrc.pt1.y = bounds->pt1.y - destoffset->y; - } - } - else if (abssrc.pt2.y + destoffset->y > bounds->pt2.y) - { - abssrc.pt2.y = bounds->pt2.y - destoffset->y; - } - - - /* Then move the rectangle so that is relative to the containing window, not the - * client subwindow - */ - - nxgl_rectoffset(destrect, &abssrc, -fwnd->wnd.bounds.pt1.x, -fwnd->wnd.bounds.pt1.y); -} diff --git a/nuttx/graphics/nxtk/nxtk_toolbarbounds.c b/nuttx/graphics/nxtk/nxtk_toolbarbounds.c deleted file mode 100644 index ee49cb504..000000000 --- a/nuttx/graphics/nxtk/nxtk_toolbarbounds.c +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** - * graphics/nxtk/nxtk_toolbarbounds.c - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include - -#include -#include - -#include "nxfe.h" -#include "nxtk_internal.h" - -/**************************************************************************** - * Pre-Processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: nxtk_toolbarbounds - * - * Description: - * Return a bounding box that contains the toolbar in the coordinates of - * the containing, framed window. For example, the recturned origin - * (rect.pt1) is the offset toolbar in the framed window. - * - * NOTE: This function is unsafe in the case of the multi-user NX server - * where the width of the window may be being changed asynchronously! It - * may return the old size in this case. - * - * Input Parameters: - * hfwnd - The handle returned by nxtk_openwindow - * bounds - User provided location in which to return the bounding box. - * - * Return: - * OK on success; ERROR on failure with errno set appropriately - * - ****************************************************************************/ - -int nxtk_toolbarbounds(NXTKWINDOW hfwnd, FAR struct nxgl_rect_s *bounds) -{ - FAR struct nxtk_framedwindow_s *fwnd = (FAR struct nxtk_framedwindow_s *)hfwnd; - - DEBUGASSERT(hfwnd && bounds); - - /* Offset the rectangle by subtracting the current position of the window. */ - - nxgl_rectoffset(bounds, &fwnd->tbrect, - -fwnd->wnd.bounds.pt1.x, -fwnd->wnd.bounds.pt1.y); - return OK; -} - diff --git a/nuttx/include/nuttx/nx/nx.h b/nuttx/include/nuttx/nx/nx.h index 3b8cc49f4..016a30f73 100644 --- a/nuttx/include/nuttx/nx/nx.h +++ b/nuttx/include/nuttx/nx/nx.h @@ -230,7 +230,8 @@ struct nx_callback_s #undef EXTERN #if defined(__cplusplus) #define EXTERN extern "C" -extern "C" { +extern "C" +{ #else #define EXTERN extern #endif @@ -264,7 +265,7 @@ extern "C" { ****************************************************************************/ #ifdef CONFIG_NX_MULTIUSER -EXTERN int nx_runinstance(FAR const char *mqname, FAR NX_DRIVERTYPE *dev); +int nx_runinstance(FAR const char *mqname, FAR NX_DRIVERTYPE *dev); # define nx_run(dev) nx_runinstance(NX_DEFAULT_SERVER_MQNAME, dev) #endif @@ -298,7 +299,7 @@ EXTERN int nx_runinstance(FAR const char *mqname, FAR NX_DRIVERTYPE *dev); ****************************************************************************/ #ifdef CONFIG_NX_MULTIUSER -EXTERN NXHANDLE nx_connectinstance(FAR const char *svrmqname); +NXHANDLE nx_connectinstance(FAR const char *svrmqname); # define nx_connect(cb) nx_connectinstance(NX_DEFAULT_SERVER_MQNAME) #endif @@ -323,7 +324,7 @@ EXTERN NXHANDLE nx_connectinstance(FAR const char *svrmqname); ****************************************************************************/ #ifndef CONFIG_NX_MULTIUSER -EXTERN NXHANDLE nx_open(FAR NX_DRIVERTYPE *dev); +NXHANDLE nx_open(FAR NX_DRIVERTYPE *dev); #endif /**************************************************************************** @@ -345,7 +346,7 @@ EXTERN NXHANDLE nx_open(FAR NX_DRIVERTYPE *dev); ****************************************************************************/ #ifdef CONFIG_NX_MULTIUSER -EXTERN void nx_disconnect(NXHANDLE handle); +void nx_disconnect(NXHANDLE handle); #endif /**************************************************************************** @@ -366,7 +367,7 @@ EXTERN void nx_disconnect(NXHANDLE handle); ****************************************************************************/ #ifndef CONFIG_NX_MULTIUSER -EXTERN void nx_close(NXHANDLE handle); +void nx_close(NXHANDLE handle); #endif /**************************************************************************** @@ -397,7 +398,7 @@ EXTERN void nx_close(NXHANDLE handle); ****************************************************************************/ #ifdef CONFIG_NX_MULTIUSER -EXTERN int nx_eventhandler(NXHANDLE handle); +int nx_eventhandler(NXHANDLE handle); #else # define nx_eventhandler(handle) (OK) #endif @@ -423,7 +424,7 @@ EXTERN int nx_eventhandler(NXHANDLE handle); ****************************************************************************/ #if defined(CONFIG_NX_MULTIUSER) && !defined(CONFIG_DISABLE_SIGNALS) -EXTERN int nx_eventnotify(NXHANDLE handle, int signo); +int nx_eventnotify(NXHANDLE handle, int signo); #else # define nx_eventnotify(handle, signo) (OK) #endif @@ -445,9 +446,8 @@ EXTERN int nx_eventnotify(NXHANDLE handle, int signo); * ****************************************************************************/ -EXTERN NXWINDOW nx_openwindow(NXHANDLE handle, - FAR const struct nx_callback_s *cb, - FAR void *arg); +NXWINDOW nx_openwindow(NXHANDLE handle, FAR const struct nx_callback_s *cb, + FAR void *arg); /**************************************************************************** * Name: nx_closewindow @@ -463,7 +463,7 @@ EXTERN NXWINDOW nx_openwindow(NXHANDLE handle, * ****************************************************************************/ -EXTERN int nx_closewindow(NXWINDOW hwnd); +int nx_closewindow(NXWINDOW hwnd); /**************************************************************************** * Name: nx_block @@ -497,7 +497,7 @@ EXTERN int nx_closewindow(NXWINDOW hwnd); ****************************************************************************/ #ifdef CONFIG_NX_MULTIUSER -EXTERN int nx_block(NXWINDOW hwnd, FAR void *arg); +int nx_block(NXWINDOW hwnd, FAR void *arg); #endif /**************************************************************************** @@ -540,9 +540,8 @@ EXTERN int nx_block(NXWINDOW hwnd, FAR void *arg); * ****************************************************************************/ -EXTERN int nx_requestbkgd(NXHANDLE handle, - FAR const struct nx_callback_s *cb, - FAR void *arg); +int nx_requestbkgd(NXHANDLE handle, FAR const struct nx_callback_s *cb, + FAR void *arg); /**************************************************************************** * Name: nx_releasebkgd @@ -559,7 +558,7 @@ EXTERN int nx_requestbkgd(NXHANDLE handle, * ****************************************************************************/ -EXTERN int nx_releasebkgd(NXWINDOW hwnd); +int nx_releasebkgd(NXWINDOW hwnd); /**************************************************************************** * Name: nx_getposition @@ -577,7 +576,7 @@ EXTERN int nx_releasebkgd(NXWINDOW hwnd); * ****************************************************************************/ -EXTERN int nx_getposition(NXWINDOW hwnd); +int nx_getposition(NXWINDOW hwnd); /**************************************************************************** * Name: nx_setposition @@ -594,7 +593,7 @@ EXTERN int nx_getposition(NXWINDOW hwnd); * ****************************************************************************/ -EXTERN int nx_setposition(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos); +int nx_setposition(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos); /**************************************************************************** * Name: nx_setsize @@ -611,7 +610,7 @@ EXTERN int nx_setposition(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos); * ****************************************************************************/ -EXTERN int nx_setsize(NXWINDOW hwnd, FAR const struct nxgl_size_s *size); +int nx_setsize(NXWINDOW hwnd, FAR const struct nxgl_size_s *size); /**************************************************************************** * Name: nx_raise @@ -627,7 +626,7 @@ EXTERN int nx_setsize(NXWINDOW hwnd, FAR const struct nxgl_size_s *size); * ****************************************************************************/ -EXTERN int nx_raise(NXWINDOW hwnd); +int nx_raise(NXWINDOW hwnd); /**************************************************************************** * Name: nx_lower @@ -643,7 +642,7 @@ EXTERN int nx_raise(NXWINDOW hwnd); * ****************************************************************************/ -EXTERN int nx_lower(NXWINDOW hwnd); +int nx_lower(NXWINDOW hwnd); /**************************************************************************** * Name: nx_setpixel @@ -662,8 +661,8 @@ EXTERN int nx_lower(NXWINDOW hwnd); * ****************************************************************************/ -EXTERN int nx_setpixel(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos, - nxgl_mxpixel_t color[CONFIG_NX_NPLANES]); +int nx_setpixel(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos, + nxgl_mxpixel_t color[CONFIG_NX_NPLANES]); /**************************************************************************** * Name: nx_fill @@ -681,8 +680,8 @@ EXTERN int nx_setpixel(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos, * ****************************************************************************/ -EXTERN int nx_fill(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect, - nxgl_mxpixel_t color[CONFIG_NX_NPLANES]); +int nx_fill(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect, + nxgl_mxpixel_t color[CONFIG_NX_NPLANES]); /**************************************************************************** * Name: nx_getrectangle @@ -710,9 +709,9 @@ EXTERN int nx_fill(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect, * ****************************************************************************/ -EXTERN int nx_getrectangle(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect, - unsigned int plane, FAR uint8_t *dest, - unsigned int deststride); +int nx_getrectangle(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect, + unsigned int plane, FAR uint8_t *dest, + unsigned int deststride); /**************************************************************************** * Name: nx_filltrapezoid @@ -731,9 +730,9 @@ EXTERN int nx_getrectangle(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect, * ****************************************************************************/ -EXTERN int nx_filltrapezoid(NXWINDOW hwnd, FAR const struct nxgl_rect_s *clip, - FAR const struct nxgl_trapezoid_s *trap, - nxgl_mxpixel_t color[CONFIG_NX_NPLANES]); +int nx_filltrapezoid(NXWINDOW hwnd, FAR const struct nxgl_rect_s *clip, + FAR const struct nxgl_trapezoid_s *trap, + nxgl_mxpixel_t color[CONFIG_NX_NPLANES]); /**************************************************************************** * Name: nx_drawline @@ -754,8 +753,8 @@ EXTERN int nx_filltrapezoid(NXWINDOW hwnd, FAR const struct nxgl_rect_s *clip, * ****************************************************************************/ -EXTERN int nx_drawline(NXWINDOW hwnd, FAR struct nxgl_vector_s *vector, - nxgl_coord_t width, nxgl_mxpixel_t color[CONFIG_NX_NPLANES]); +int nx_drawline(NXWINDOW hwnd, FAR struct nxgl_vector_s *vector, + nxgl_coord_t width, nxgl_mxpixel_t color[CONFIG_NX_NPLANES]); /**************************************************************************** * Name: nx_drawcircle @@ -775,9 +774,9 @@ EXTERN int nx_drawline(NXWINDOW hwnd, FAR struct nxgl_vector_s *vector, * ****************************************************************************/ -EXTERN int nx_drawcircle(NXWINDOW hwnd, FAR const struct nxgl_point_s *center, - nxgl_coord_t radius, nxgl_coord_t width, - nxgl_mxpixel_t color[CONFIG_NX_NPLANES]); +int nx_drawcircle(NXWINDOW hwnd, FAR const struct nxgl_point_s *center, + nxgl_coord_t radius, nxgl_coord_t width, + nxgl_mxpixel_t color[CONFIG_NX_NPLANES]); /**************************************************************************** * Name: nx_fillcircle @@ -796,9 +795,9 @@ EXTERN int nx_drawcircle(NXWINDOW hwnd, FAR const struct nxgl_point_s *center, * ****************************************************************************/ -EXTERN int nx_fillcircle(NXWINDOW hwnd, FAR const struct nxgl_point_s *center, - nxgl_coord_t radius, - nxgl_mxpixel_t color[CONFIG_NX_NPLANES]); +int nx_fillcircle(NXWINDOW hwnd, FAR const struct nxgl_point_s *center, + nxgl_coord_t radius, + nxgl_mxpixel_t color[CONFIG_NX_NPLANES]); /**************************************************************************** * Name: nx_setbgcolor @@ -815,8 +814,7 @@ EXTERN int nx_fillcircle(NXWINDOW hwnd, FAR const struct nxgl_point_s *center, * ****************************************************************************/ -int nx_setbgcolor(NXHANDLE handle, - nxgl_mxpixel_t color[CONFIG_NX_NPLANES]); +int nx_setbgcolor(NXHANDLE handle, nxgl_mxpixel_t color[CONFIG_NX_NPLANES]); /**************************************************************************** * Name: nx_move @@ -835,8 +833,8 @@ int nx_setbgcolor(NXHANDLE handle, * ****************************************************************************/ -EXTERN int nx_move(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect, - FAR const struct nxgl_point_s *offset); +int nx_move(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect, + FAR const struct nxgl_point_s *offset); /**************************************************************************** * Name: nx_bitmap @@ -861,10 +859,9 @@ EXTERN int nx_move(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect, * ****************************************************************************/ -EXTERN int nx_bitmap(NXWINDOW hwnd, FAR const struct nxgl_rect_s *dest, - FAR const void *src[CONFIG_NX_NPLANES], - FAR const struct nxgl_point_s *origin, - unsigned int stride); +int nx_bitmap(NXWINDOW hwnd, FAR const struct nxgl_rect_s *dest, + FAR const void *src[CONFIG_NX_NPLANES], + FAR const struct nxgl_point_s *origin, unsigned int stride); /**************************************************************************** * Name: nx_kbdin @@ -877,8 +874,8 @@ EXTERN int nx_bitmap(NXWINDOW hwnd, FAR const struct nxgl_rect_s *dest, ****************************************************************************/ #ifdef CONFIG_NX_KBD -EXTERN int nx_kbdchin(NXHANDLE handle, uint8_t ch); -EXTERN int nx_kbdin(NXHANDLE handle, uint8_t nch, FAR const uint8_t *ch); +int nx_kbdchin(NXHANDLE handle, uint8_t ch); +int nx_kbdin(NXHANDLE handle, uint8_t nch, FAR const uint8_t *ch); #endif /**************************************************************************** @@ -892,9 +889,68 @@ EXTERN int nx_kbdin(NXHANDLE handle, uint8_t nch, FAR const uint8_t *ch); ****************************************************************************/ #ifdef CONFIG_NX_MOUSE -EXTERN int nx_mousein(NXHANDLE handle, nxgl_coord_t x, nxgl_coord_t y, uint8_t buttons); +int nx_mousein(NXHANDLE handle, nxgl_coord_t x, nxgl_coord_t y, uint8_t buttons); #endif +/**************************************************************************** + * NX-Internal Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nx_redrawreq + * + * Description: + * This will cause a NX re-draw callback to the client that owns the + * window. This is not normally called from user code, but may be + * used within middle-ware layers when redrawing is needed. + * + * NXTK uses this function, for example, when a change in the main window + * necessitates redrawing of the toolbar window. + * + * Input Parameters: + * hwnd - Window handle + * rect - The rectangle that needs to be re-drawn (in window relative + * coordinates) + * + * Returned Value: + * None + * + ****************************************************************************/ + +void nx_redrawreq(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect); + +/**************************************************************************** + * Name: nx_constructwindow + * + * Description: + * This function is the same a nx_openwindow EXCEPT that the client provides + * the window structure instance. nx_constructwindow will initialize the + * the pre-allocated window structure for use by NX. This function is + * provided in addition to nx_open window in order to support a kind of + * inheritance: The caller's window structure may include extensions that + * are not visible to NX. + * + * NOTE: wnd must have been allocated using kmalloc() (or related allocators) + * Once provided to nx_constructwindow() that memory is owned and managed + * by NX. On certain error conditions or when the window is closed, NX will + * free the window. + * + * Input Parameters: + * handle - The handle returned by nx_connect + * wnd - The pre-allocated window structure. + * cb - Callbacks used to process window events + * arg - User provided value that will be returned with NX callbacks. + * + * Return: + * OK on success; ERROR on failure with errno set appropriately. In the + * case of ERROR, NX will have deallocated the pre-allocated window. + * + ****************************************************************************/ + +struct nxbe_window_s; /* Forward reference */ +int nx_constructwindow(NXHANDLE handle, FAR struct nxbe_window_s *wnd, + FAR const struct nx_callback_s *cb, FAR void *arg); + #undef EXTERN #if defined(__cplusplus) } diff --git a/nuttx/include/nuttx/nx/nxmu.h b/nuttx/include/nuttx/nx/nxmu.h index a6a7ac145..019a8a35f 100644 --- a/nuttx/include/nuttx/nx/nxmu.h +++ b/nuttx/include/nuttx/nx/nxmu.h @@ -158,6 +158,7 @@ enum nxmsg_e NX_SVRMSG_SETBGCOLOR, /* Set the color of the background */ NX_SVRMSG_MOUSEIN, /* New mouse report from mouse client */ NX_SVRMSG_KBDIN, /* New keyboard report from keyboard client */ + NX_SVRMSG_REDRAWREQ /* Request re-drawing of rectangular region */ }; /* Server-to-Client Message Structures **************************************/ @@ -346,7 +347,7 @@ struct nxsvrmsg_lower_s struct nxsvrmsg_setpixel_s { - uint32_t msgid; /* NX_SVRMSG_SETPIXEL */ + uint32_t msgid; /* NX_SVRMSG_SETPIXEL */ FAR struct nxbe_window_s *wnd; /* The window to fill */ struct nxgl_point_s pos; /* The position of the pixel in the window */ nxgl_mxpixel_t color[CONFIG_NX_NPLANES]; /* Color to use in the fill */ @@ -356,7 +357,7 @@ struct nxsvrmsg_setpixel_s struct nxsvrmsg_fill_s { - uint32_t msgid; /* NX_SVRMSG_FILL */ + uint32_t msgid; /* NX_SVRMSG_FILL */ FAR struct nxbe_window_s *wnd; /* The window to fill */ struct nxgl_rect_s rect; /* The rectangle in the window to fill */ nxgl_mxpixel_t color[CONFIG_NX_NPLANES]; /* Color to use in the fill */ @@ -366,7 +367,7 @@ struct nxsvrmsg_fill_s struct nxsvrmsg_getrectangle_s { - uint32_t msgid; /* NX_SVRMSG_GETRECTANGLE */ + uint32_t msgid; /* NX_SVRMSG_GETRECTANGLE */ FAR struct nxbe_window_s *wnd; /* The window to get from */ struct nxgl_rect_s rect; /* The rectangle in the window to get from */ unsigned int plane; /* The plane number to read */ @@ -379,7 +380,7 @@ struct nxsvrmsg_getrectangle_s struct nxsvrmsg_filltrapezoid_s { - uint32_t msgid; /* NX_SVRMSG_FILLTRAP */ + uint32_t msgid; /* NX_SVRMSG_FILLTRAP */ FAR struct nxbe_window_s *wnd; /* The window to fill */ FAR struct nxgl_rect_s clip; /* The clipping window */ struct nxgl_trapezoid_s trap; /* The trapezoidal region in the window to fill */ @@ -413,7 +414,7 @@ struct nxsvrmsg_bitmap_s struct nxsvrmsg_setbgcolor_s { - uint32_t msgid; /* NX_SVRMSG_SETBGCOLOR */ + uint32_t msgid; /* NX_SVRMSG_SETBGCOLOR */ nxgl_mxpixel_t color[CONFIG_NX_NPLANES]; /* Color to use in the background */ }; @@ -439,12 +440,21 @@ struct nxsvrmsg_mousein_s #ifdef CONFIG_NX_KBD struct nxsvrmsg_kbdin_s { - uint32_t msgid; /* NX_SVRMSG_KBDIN */ - uint8_t nch ; /* Number of characters received */ - uint8_t ch[1]; /* Array of received characters */ + uint32_t msgid; /* NX_SVRMSG_KBDIN */ + uint8_t nch ; /* Number of characters received */ + uint8_t ch[1]; /* Array of received characters */ }; #endif +/* Request re-drawing of rectangular region */ + +struct nxsvrmsg_redrawreq_s +{ + uint32_t msgid; /* NX_SVRMSG_REDRAWREQ */ + FAR struct nxbe_window_s *wnd; /* The window to be redrawn */ + struct nxgl_rect_s rect; /* Describes the rectangular region to be redrawn */ +}; + /**************************************************************************** * Public Data ****************************************************************************/ diff --git a/nuttx/libnx/Makefile b/nuttx/libnx/Makefile index 75b19aade..37a195996 100644 --- a/nuttx/libnx/Makefile +++ b/nuttx/libnx/Makefile @@ -57,6 +57,7 @@ include nxglib/Make.defs include nx/Make.defs include nxmu/Make.defs include nxfonts/Make.defs +include nxtk/Make.defs BINDIR ?= bin diff --git a/nuttx/libnx/nxmu/Make.defs b/nuttx/libnx/nxmu/Make.defs index 2b316e772..ebf9c4f65 100644 --- a/nuttx/libnx/nxmu/Make.defs +++ b/nuttx/libnx/nxmu/Make.defs @@ -45,10 +45,11 @@ CSRCS += nxmu_semtake.c nx_block.c CSRCS += nx_kbdchin.c nx_kbdin.c nx_mousein.c CSRCS += nx_releasebkgd.c nx_requestbkgd.c nx_setbgcolor.c -CSRCS += nxmu_sendwindow.c nx_closewindow.c nxmu_constructwindow.c +CSRCS += nxmu_sendwindow.c nx_closewindow.c nx_constructwindow.c CSRCS += nx_bitmap.c nx_fill.c nx_filltrapezoid.c nx_getposition.c CSRCS += nx_getrectangle.c nx_lower.c nx_move.c nx_openwindow.c -CSRCS += nx_raise.c nx_setpixel.c nx_setposition.c nx_setsize.c +CSRCS += nx_raise.c nx_redrawreq.c nx_setpixel.c nx_setposition.c +CSRCS += nx_setsize.c # Add the nxmu/ directory to the build diff --git a/nuttx/libnx/nxmu/nx_constructwindow.c b/nuttx/libnx/nxmu/nx_constructwindow.c new file mode 100644 index 000000000..888f5b608 --- /dev/null +++ b/nuttx/libnx/nxmu/nx_constructwindow.c @@ -0,0 +1,139 @@ +/**************************************************************************** + * libnx/nxmu/nx_constsructwindow.c + * + * Copyright (C) 2008, 2011-2013 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include +#include +#include + +#include "nxcontext.h" + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nx_constructwindow + * + * Description: + * This function is the same a nx_openwindow EXCEPT that the client provides + * the window structure instance. nx_constructwindow will initialize the + * the pre-allocated window structure for use by NX. This function is + * provided in addition to nx_open window in order to support a kind of + * inheritance: The caller's window structure may include extensions that + * are not visible to NX. + * + * NOTE: wnd must have been allocated using kmalloc() (or related allocators) + * Once provided to nx_constructwindow() that memory is owned and managed + * by NX. On certain error conditions or when the window is closed, NX will + * free the window. + * + * Input Parameters: + * handle - The handle returned by nx_connect + * wnd - The pre-allocated window structure. + * cb - Callbacks used to process window events + * arg - User provided value that will be returned with NX callbacks. + * + * Return: + * OK on success; ERROR on failure with errno set appropriately. In the + * case of ERROR, NX will have deallocated the pre-allocated window. + * + ****************************************************************************/ + +int nx_constructwindow(NXHANDLE handle, FAR struct nxbe_window_s *wnd, + FAR const struct nx_callback_s *cb, FAR void *arg) +{ + FAR struct nxfe_conn_s *conn = (FAR struct nxfe_conn_s *)handle; + struct nxsvrmsg_openwindow_s outmsg; + +#ifdef CONFIG_DEBUG + if (!wnd) + { + set_errno(EINVAL); + return ERROR; + } + + if (!conn || !cb) + { + lib_free(wnd); + set_errno(EINVAL); + return ERROR; + } +#endif + + /* Setup only the connection structure, callbacks and client private data + * reference. The server will set everything else up. + */ + + wnd->conn = conn; + wnd->cb = cb; + wnd->arg = arg; + + /* Request initialization the new window from the server */ + + outmsg.msgid = NX_SVRMSG_OPENWINDOW; + outmsg.wnd = wnd; + + return nxmu_sendserver(conn, &outmsg, sizeof(struct nxsvrmsg_openwindow_s)); +} diff --git a/nuttx/libnx/nxmu/nx_openwindow.c b/nuttx/libnx/nxmu/nx_openwindow.c index c26a38087..0f331b9e5 100644 --- a/nuttx/libnx/nxmu/nx_openwindow.c +++ b/nuttx/libnx/nxmu/nx_openwindow.c @@ -112,9 +112,9 @@ NXWINDOW nx_openwindow(NXHANDLE handle, FAR const struct nx_callback_s *cb, return NULL; } - /* Then let nxfe_constructwindow do the rest */ + /* Then let nx_constructwindow do the rest */ - ret = nxfe_constructwindow(handle, wnd, cb, arg); + ret = nx_constructwindow(handle, wnd, cb, arg); if (ret < 0) { /* An error occurred, the window has been freed */ diff --git a/nuttx/libnx/nxmu/nx_redrawreq.c b/nuttx/libnx/nxmu/nx_redrawreq.c new file mode 100644 index 000000000..05ef8d071 --- /dev/null +++ b/nuttx/libnx/nxmu/nx_redrawreq.c @@ -0,0 +1,111 @@ +/**************************************************************************** + * libnx/nxmu/nx_redrawreq.c + * + * Copyright (C) 2013 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include + +#include +#include +#include + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nx_redrawreq + * + * Descripton: + * This will cause a NX re-draw callback to the client that owns the + * window. This is not normally called from user code, but may be + * used within middle-ware layers when redrawing is needed. + * + * Input Parameters: + * hwnd - Window handle + * rect - The rectangle that needs to be re-drawn (in window relative + * coordinates) + * + * Returned Value: + * None + * + ****************************************************************************/ + +void nx_redrawreq(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect) +{ + FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd; + struct nxsvrmsg_redrawreq_s outmsg; + +#ifdef CONFIG_DEBUG + if (!wnd || !rect) + { + set_errno(EINVAL); + return ERROR; + } +#endif + + /* Inform the server of the changed position */ + + outmsg.msgid = NX_SVRMSG_REDRAWREQ; + outmsg.wnd = wnd; + nxgl_rectcopy(&outmsg.rect, rect); + + return nxmu_sendwindow(wnd, &outmsg, sizeof(struct nxsvrmsg_redrawreq_s)); +} diff --git a/nuttx/libnx/nxmu/nxmu_constructwindow.c b/nuttx/libnx/nxmu/nxmu_constructwindow.c deleted file mode 100644 index e677c9eaa..000000000 --- a/nuttx/libnx/nxmu/nxmu_constructwindow.c +++ /dev/null @@ -1,139 +0,0 @@ -/**************************************************************************** - * libnx/nxmu/nx_openwindow.c - * - * Copyright (C) 2008, 2011-2013 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include - -#include -#include -#include - -#include "nxcontext.h" - -/**************************************************************************** - * Pre-Processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: nxfe_constructwindow - * - * Description: - * This function is the same a nx_openwindow EXCEPT that the client provides - * the window structure instance. nx_constructwindow will initialize the - * the pre-allocated window structure for use by NX. This function is - * provided in addition to nx_open window in order to support a kind of - * inheritance: The caller's window structure may include extensions that - * are not visible to NX. - * - * NOTE: wnd must have been allocated using kmalloc() (or related allocators) - * Once provided to nxfe_constructwindow() that memory is owned and managed - * by NX. On certain error conditions or when the window is closed, NX will - * free the window. - * - * Input Parameters: - * handle - The handle returned by nx_connect - * wnd - The pre-allocated window structure. - * cb - Callbacks used to process window events - * arg - User provided value that will be returned with NX callbacks. - * - * Return: - * OK on success; ERROR on failure with errno set appropriately. In the - * case of ERROR, NX will have deallocated the pre-allocated window. - * - ****************************************************************************/ - -int nxfe_constructwindow(NXHANDLE handle, FAR struct nxbe_window_s *wnd, - FAR const struct nx_callback_s *cb, FAR void *arg) -{ - FAR struct nxfe_conn_s *conn = (FAR struct nxfe_conn_s *)handle; - struct nxsvrmsg_openwindow_s outmsg; - -#ifdef CONFIG_DEBUG - if (!wnd) - { - set_errno(EINVAL); - return ERROR; - } - - if (!conn || !cb) - { - lib_free(wnd); - set_errno(EINVAL); - return ERROR; - } -#endif - - /* Setup only the connection structure, callbacks and client private data - * reference. The server will set everything else up. - */ - - wnd->conn = conn; - wnd->cb = cb; - wnd->arg = arg; - - /* Request initialization the new window from the server */ - - outmsg.msgid = NX_SVRMSG_OPENWINDOW; - outmsg.wnd = wnd; - - return nxmu_sendserver(conn, &outmsg, sizeof(struct nxsvrmsg_openwindow_s)); -} diff --git a/nuttx/libnx/nxtk/Make.defs b/nuttx/libnx/nxtk/Make.defs new file mode 100644 index 000000000..1800311be --- /dev/null +++ b/nuttx/libnx/nxtk/Make.defs @@ -0,0 +1,60 @@ +############################################################################ +# libnx/nxtk/Make.defs +# +# Copyright (C) 2008, 2011, 2013 Gregory Nutt. All rights reserved. +# Author: Gregory Nutt +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name NuttX nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +# Expose NXTK interfaces to applications + +ifeq ($(CONFIG_NX),y) + +CSRCS += nxtk_openwindow.c nxtk_closewindow.c nxtk_getposition.c +CSRCS += nxtk_setposition.c nxtk_setsize.c nxtk_raise.c nxtk_lower.c +CSRCS += nxtk_fillwindow.c nxtk_getwindow.c nxtk_filltrapwindow.c +CSRCS += nxtk_movewindow.c nxtk_bitmapwindow.c nxtk_events.c +CSRCS += nxtk_setsubwindows.c nxtk_drawcirclewindow.c nxtk_drawlinewindow.c +CSRCS += nxtk_fillcirclewindow.c nxtk_block.c + +CSRCS += nxtk_opentoolbar.c nxtk_closetoolbar.c nxtk_filltoolbar.c +CSRCS += nxtk_gettoolbar.c nxtk_filltraptoolbar.c nxtk_movetoolbar.c +CSRCS += nxtk_bitmaptoolbar.c nxtk_drawcircletoolbar.c nxtk_drawlinetoolbar.c +CSRCS += nxtk_fillcircletoolbar.c nxtk_toolbarbounds.c + +CSRCS += nxtk_subwindowclip.c nxtk_containerclip.c nxtk_subwindowmove.c +CSRCS += nxtk_drawframe.c + +# Add the nxtk/ directory to the build + +DEPPATH += --dep-path nxtk +VPATH += :nxtk + +endif diff --git a/nuttx/libnx/nxtk/nxtk_bitmaptoolbar.c b/nuttx/libnx/nxtk/nxtk_bitmaptoolbar.c new file mode 100644 index 000000000..8f99267dc --- /dev/null +++ b/nuttx/libnx/nxtk/nxtk_bitmaptoolbar.c @@ -0,0 +1,137 @@ +/**************************************************************************** + * libnx/nxtk/nxtk_bitmaptoolbar.c + * + * Copyright (C) 2008-2009, 2012 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include + +#include +#include + +#include "nxtk_internal.h" + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * 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 sub-window coordinates, however, the + * origin may lie outside of the sub-window display. + * stride - The width of the full source image in pixels. + * + * Return: + * OK on success; ERROR on failure with errno set appropriately + * + ****************************************************************************/ + +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 *)hfwnd; + struct nxgl_point_s wndorigin; + struct nxgl_rect_s clipdest; + +#ifdef CONFIG_DEBUG + if (!hfwnd || !dest || !src || !origin) + { + set_errno(EINVAL); + return ERROR; + } +#endif + + /* Clip the rectangle so that it lies within the sub-window bounds + * then move the rectangle to that it is relative to the containing + * window. + */ + + nxtk_subwindowclip(fwnd, &clipdest, dest, &fwnd->tbrect); + + /* Now, move the bitmap origin so that it is relative to the containing + * window, not the sub-window. + * + * Temporarily, position the origin in absolute screen coordinates + */ + + nxgl_vectoradd(&wndorigin, origin, &fwnd->tbrect.pt1); + + /* Then move the origin so that is relative to the containing window, not the + * client subwindow + */ + + nxgl_vectsubtract(&wndorigin, &wndorigin, &fwnd->wnd.bounds.pt1); + + /* Then copy the bitmap */ + + nx_bitmap((NXWINDOW)hfwnd, &clipdest, src, &wndorigin, stride); + return OK; +} diff --git a/nuttx/libnx/nxtk/nxtk_bitmapwindow.c b/nuttx/libnx/nxtk/nxtk_bitmapwindow.c new file mode 100644 index 000000000..11956aeb1 --- /dev/null +++ b/nuttx/libnx/nxtk/nxtk_bitmapwindow.c @@ -0,0 +1,137 @@ +/**************************************************************************** + * libnx/nxtk/nxtk_bitmapwindow.c + * + * Copyright (C) 2008-2009, 2011 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include + +#include +#include + +#include "nxtk_internal.h" + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nxtk_bitmapwindow + * + * Description: + * Copy a rectangular region of a larger image into the rectangle in the + * specified client sub-window. + * + * Input Parameters: + * hfwnd The client sub0window that will receive the bitmap image + * dest - Describes the rectangular region on in the client 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 sub-window coordinates, however, the + * origin may lie outside of the sub-window display. + * stride - The width of the full source image in pixels. + * + * Return: + * OK on success; ERROR on failure with errno set appropriately + * + ****************************************************************************/ + +int nxtk_bitmapwindow(NXTKWINDOW hfwnd, FAR const struct nxgl_rect_s *dest, + FAR const void **src, + FAR const struct nxgl_point_s *origin, unsigned int stride) +{ + FAR struct nxtk_framedwindow_s *fwnd = (FAR struct nxtk_framedwindow_s *)hfwnd; + struct nxgl_point_s wndorigin; + struct nxgl_rect_s clipdest; + +#ifdef CONFIG_DEBUG + if (!hfwnd || !dest || !src || !origin) + { + set_errno(EINVAL); + return ERROR; + } +#endif + + /* Clip the rectangle so that it lies within the sub-window bounds + * then move the rectangle to that it is relative to the containing + * window. + */ + + nxtk_subwindowclip(fwnd, &clipdest, dest, &fwnd->fwrect); + + /* Now, move the bitmap origin so that it is relative to the containing + * window, not the sub-window. + * + * Temporarily, position the origin in absolute screen coordinates + */ + + nxgl_vectoradd(&wndorigin, origin, &fwnd->fwrect.pt1); + + /* Then move the origin so that is relative to the containing window, not the + * client subwindow + */ + + nxgl_vectsubtract(&wndorigin, &wndorigin, &fwnd->wnd.bounds.pt1); + + /* Then copy the bitmap */ + + nx_bitmap((NXWINDOW)hfwnd, &clipdest, src, &wndorigin, stride); + return OK; +} diff --git a/nuttx/libnx/nxtk/nxtk_block.c b/nuttx/libnx/nxtk/nxtk_block.c new file mode 100644 index 000000000..3b089a74a --- /dev/null +++ b/nuttx/libnx/nxtk/nxtk_block.c @@ -0,0 +1,108 @@ +/**************************************************************************** + * libnx/nxtk/nxtk_block.c + * + * Copyright (C) 2012, 2013 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#ifdef CONFIG_NX_MULTIUSER + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nxtk_block + * + * Description: + * This is callback will do to things: (1) any queue a 'blocked' callback + * to the window and then (2) block any further window messaging. + * + * The 'blocked' callback is the response from nx_block (or nxtk_block). + * Those blocking interfaces are used to assure that no further messages are + * are directed to the window. Receipt of the blocked callback signifies + * that (1) there are no further pending callbacks and (2) that the + * window is now 'defunct' and will receive no further callbacks. + * + * This callback supports coordinated destruction of a window in multi- + * user mode. In multi-use mode, the client window logic must stay + * intact until all of the queued callbacks are processed. Then the + * window may be safely closed. Closing the window prior with pending + * callbacks can lead to bad behavior when the callback is executed. + * + * Multiple user mode only! + * + * Input Parameters: + * hfwnd - The window to be blocked + * arg - An argument that will accompany the block messages (This is arg2 + * in the blocked callback). + * + * Return: + * OK on success; ERROR on failure with errno set appropriately + * + ****************************************************************************/ + +int nxtk_block(NXTKWINDOW hfwnd, FAR void *arg) +{ + return nx_block((NXWINDOW)hfwnd, arg); +} + +#endif /* CONFIG_NX_MULTIUSER */ diff --git a/nuttx/libnx/nxtk/nxtk_closetoolbar.c b/nuttx/libnx/nxtk/nxtk_closetoolbar.c new file mode 100644 index 000000000..8f65a75a8 --- /dev/null +++ b/nuttx/libnx/nxtk/nxtk_closetoolbar.c @@ -0,0 +1,109 @@ +/**************************************************************************** + * libnx/nxtk/nxtk_closetoolbar.c + * + * Copyright (C) 2008-2009, 2013 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include +#include + +#include "nxtk_internal.h" + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nxtk_closetoolbar + * + * Description: + * Create a tool bar at the top of the specified framed window + * + * Input Parameters: + * hfwnd - The handle returned by nxtk_openwindow + * + * Return: + * OK on success; ERROR on failure with errno set appropriately + * + ****************************************************************************/ + +int nxtk_closetoolbar(NXTKWINDOW hfwnd) +{ + FAR struct nxtk_framedwindow_s *fwnd = (FAR struct nxtk_framedwindow_s *)hfwnd; + + /* Un-initialize the toolbar info */ + + fwnd->tbheight = 0; + fwnd->tbcb = NULL; + fwnd->tbarg = NULL; + + /* Calculate the new dimensions of the client window */ + + nxtk_setsubwindows(fwnd); + + /* Then redraw the entire window, even the client window must be + * redrawn because it has changed its vertical position and size. + */ + + nx_redrawreq(&fwnd->wnd, &fwnd->wnd.bounds); + return OK; +} diff --git a/nuttx/libnx/nxtk/nxtk_closewindow.c b/nuttx/libnx/nxtk/nxtk_closewindow.c new file mode 100644 index 000000000..7bda3ff06 --- /dev/null +++ b/nuttx/libnx/nxtk/nxtk_closewindow.c @@ -0,0 +1,93 @@ +/**************************************************************************** + * libnx/nxtk/nxtk_closewindow.c + * + * Copyright (C) 2008, 2013 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include +#include + +#include +#include + +#include "nxtk_internal.h" + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nxtk_closewindow + * + * Description: + * Close the window opened by nxtk_openwindow + * + * Input Parameters: + * hfwnd - The handle returned by nxtk_openwindow + * + * Return: + * OK on success; ERROR on failure with errno set appropriately + * + ****************************************************************************/ + +int nxtk_closewindow(NXTKWINDOW hfwnd) +{ + return nx_closewindow((NXWINDOW)hfwnd); +} diff --git a/nuttx/libnx/nxtk/nxtk_containerclip.c b/nuttx/libnx/nxtk/nxtk_containerclip.c new file mode 100644 index 000000000..12dc4987b --- /dev/null +++ b/nuttx/libnx/nxtk/nxtk_containerclip.c @@ -0,0 +1,121 @@ +/**************************************************************************** + * libnx/nxtk/nxtk_containerclip.c + * + * Copyright (C) 2008-2009, 2013 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include +#include + +#include "nxtk_internal.h" + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nxtk_containerclip + * + * Description: + * We are given a 'src' rectangle in containing window, relative coordinates + * (i.e., (0,0) is the top left corner of the outer, containing window). + * This function will (1) clip that src rectangle so that it lies within + * the sub-window bounds, and then (2) move the rectangle to that it is + * relative to the sub-window (i.e., (0,0) is the top left corner of the + * sub-window). + * + * Input parameters: + * fwnd - The framed window to be used + * dest - The locaton to put the result + * src - The src rectangle in relative container-window coordinates + * bounds - The subwindow bounds in absolute screen coordinates. + * + * Returned value: + * None + * + ****************************************************************************/ + +void nxtk_containerclip(FAR struct nxtk_framedwindow_s *fwnd, + FAR struct nxgl_rect_s *dest, + FAR const struct nxgl_rect_s *src, + FAR const struct nxgl_rect_s *bounds) +{ + struct nxgl_rect_s relbounds; + + /* The 'src' rectangle is relative to the containing window. Convert + * the sub-window to the same origin. + */ + + nxgl_rectoffset(&relbounds, bounds, -fwnd->wnd.bounds.pt1.x, + -fwnd->wnd.bounds.pt1.y); + + /* The interection then leaves the portion of the containing window that + * needs to be updated window that needs to be updated. + */ + + nxgl_rectintersect(dest, src, &relbounds); + + /* Offset this so that is relative to client subwindow origin */ + + nxgl_rectoffset(dest, dest, fwnd->wnd.bounds.pt1.x - bounds->pt1.x, + fwnd->wnd.bounds.pt1.y - bounds->pt1.y); +} diff --git a/nuttx/libnx/nxtk/nxtk_drawcircletoolbar.c b/nuttx/libnx/nxtk/nxtk_drawcircletoolbar.c new file mode 100644 index 000000000..99b1094b7 --- /dev/null +++ b/nuttx/libnx/nxtk/nxtk_drawcircletoolbar.c @@ -0,0 +1,145 @@ +/**************************************************************************** + * libnx/nxtk/nxtk_drawcircletoolbar.c + * + * Copyright (C) 2011 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include +#include + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ +/* Named indices into the 16 circle points generated by nxgl_circlepts */ + +#define POINT_0p0 0 +#define POINT_22p5 1 +#define POINT_45p0 2 +#define POINT_67p5 3 +#define POINT_90p0 4 +#define POINT_112p5 5 +#define POINT_135p0 6 +#define POINT_157p5 7 +#define POINT_180p0 8 +#define POINT_202p5 9 +#define POINT_225p0 10 +#define POINT_247p5 11 +#define POINT_270p0 12 +#define POINT_292p5 13 +#define POINT_315p0 14 +#define POINT_337p5 15 +#define NCIRCLE_POINTS 16 + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nxtk_drawcircletoolbar + * + * Description: + * Draw a circular outline using the specified line thickness and color. + * + * Input Parameters: + * hfwnd - The window handle returned by nxtk_openwindow() + * center - A pointer to the point that is the center of the circle + * radius - The radius of the circle in pixels. + * width - The width of the line + * color - The color to use to fill the line + * + * Return: + * OK on success; ERROR on failure with errno set appropriately + * + ****************************************************************************/ + +int nxtk_drawcircletoolbar(NXTKWINDOW hfwnd, FAR const struct nxgl_point_s *center, + nxgl_coord_t radius, nxgl_coord_t width, + nxgl_mxpixel_t color[CONFIG_NX_NPLANES]) +{ + struct nxgl_point_s pts[NCIRCLE_POINTS]; + FAR struct nxgl_vector_s vector; + int i; + int ret; + + /* Convert the circle to a set of 16 points */ + + nxgl_circlepts(center, radius, pts); + + /* Draw each pair of points as a vector */ + + for (i = POINT_0p0; i < POINT_337p5; i++) + { + vector.pt1.x = pts[i].x; + vector.pt1.y = pts[i].y; + vector.pt2.x = pts[i+1].x; + vector.pt2.y = pts[i+1].y; + ret = nxtk_drawlinetoolbar(hfwnd, &vector, width, color); + if (ret != OK) + { + return ret; + } + } + + /* The final, closing vector is a special case */ + + vector.pt1.x = pts[POINT_337p5].x; + vector.pt1.y = pts[POINT_337p5].y; + vector.pt2.x = pts[POINT_0p0].x; + vector.pt2.y = pts[POINT_0p0].y; + return nxtk_drawlinetoolbar(hfwnd, &vector, width, color); +} diff --git a/nuttx/libnx/nxtk/nxtk_drawcirclewindow.c b/nuttx/libnx/nxtk/nxtk_drawcirclewindow.c new file mode 100644 index 000000000..be6bc713f --- /dev/null +++ b/nuttx/libnx/nxtk/nxtk_drawcirclewindow.c @@ -0,0 +1,145 @@ +/**************************************************************************** + * libnx/nxtk/nxtk_drawcirclewindow.c + * + * Copyright (C) 2011 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include +#include + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ +/* Named indices into the 16 circle points generated by nxgl_circlepts */ + +#define POINT_0p0 0 +#define POINT_22p5 1 +#define POINT_45p0 2 +#define POINT_67p5 3 +#define POINT_90p0 4 +#define POINT_112p5 5 +#define POINT_135p0 6 +#define POINT_157p5 7 +#define POINT_180p0 8 +#define POINT_202p5 9 +#define POINT_225p0 10 +#define POINT_247p5 11 +#define POINT_270p0 12 +#define POINT_292p5 13 +#define POINT_315p0 14 +#define POINT_337p5 15 +#define NCIRCLE_POINTS 16 + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nxtk_drawcirclewindow + * + * Description: + * Draw a circular outline using the specified line thickness and color. + * + * Input Parameters: + * hfwnd - The window handle returned by nxtk_openwindow() + * center - A pointer to the point that is the center of the circle + * radius - The radius of the circle in pixels. + * width - The width of the line + * color - The color to use to fill the line + * + * Return: + * OK on success; ERROR on failure with errno set appropriately + * + ****************************************************************************/ + +int nxtk_drawcirclewindow(NXTKWINDOW hfwnd, FAR const struct nxgl_point_s *center, + nxgl_coord_t radius, nxgl_coord_t width, + nxgl_mxpixel_t color[CONFIG_NX_NPLANES]) +{ + struct nxgl_point_s pts[NCIRCLE_POINTS]; + FAR struct nxgl_vector_s vector; + int i; + int ret; + + /* Convert the circle to a set of 16 points */ + + nxgl_circlepts(center, radius, pts); + + /* Draw each pair of points as a vector */ + + for (i = POINT_0p0; i < POINT_337p5; i++) + { + vector.pt1.x = pts[i].x; + vector.pt1.y = pts[i].y; + vector.pt2.x = pts[i+1].x; + vector.pt2.y = pts[i+1].y; + ret = nxtk_drawlinewindow(hfwnd, &vector, width, color); + if (ret != OK) + { + return ret; + } + } + + /* The final, closing vector is a special case */ + + vector.pt1.x = pts[POINT_337p5].x; + vector.pt1.y = pts[POINT_337p5].y; + vector.pt2.x = pts[POINT_0p0].x; + vector.pt2.y = pts[POINT_0p0].y; + return nxtk_drawlinewindow(hfwnd, &vector, width, color); +} diff --git a/nuttx/libnx/nxtk/nxtk_drawframe.c b/nuttx/libnx/nxtk/nxtk_drawframe.c new file mode 100644 index 000000000..e30377dd3 --- /dev/null +++ b/nuttx/libnx/nxtk/nxtk_drawframe.c @@ -0,0 +1,309 @@ +/**************************************************************************** + * libnx/nxtk/nxtk_drawframe.c + * + * Copyright (C) 2008-2009, 2011-2013 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include +#include +#include + +#include "nxtk_internal.h" + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nxtk_drawframeside + ****************************************************************************/ + +static void nxtk_drawframeside(FAR struct nxtk_framedwindow_s *fwnd, + FAR const struct nxgl_rect_s *side, + FAR const struct nxgl_rect_s *bounds, + nxgl_mxpixel_t color[CONFIG_NX_NPLANES]) +{ + struct nxgl_rect_s intersection; + nxgl_rectintersect(&intersection, side, bounds); + if (!nxgl_nullrect(&intersection)) + { + nx_fill((NXWINDOW)fwnd, &intersection, color); + } +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nxtk_drawframe + * + * Description: + * Redraw the window frame. + * + * Input parameters: + * fwnd - the framed window whose frame needs to be re-drawn. This must + * have been previously created by nxtk_openwindow(). + * bounds - Only draw the ports of the frame within this bounding box. + * (window relative coordinates). + * + * Returned value: + * OK on success; ERROR on failure with errno set appropriately + * + ****************************************************************************/ + +int nxtk_drawframe(FAR struct nxtk_framedwindow_s *fwnd, + FAR const struct nxgl_rect_s *bounds) +{ + struct nxgl_rect_s frame; + struct nxgl_size_s wndsize; + struct nxgl_size_s tbsize; + nxgl_coord_t thickness; + + /* Shiny edge: + * Thickness: 1 + * Color: CONFIG_NXTK_BORDERCOLOR3; + * Condition: CONFIG_NXTK_BORDERWIDTH > 2 + * Central part: + * Thickness: Varies with CONFIG_NXTK_BORDERWIDTH + * Color: CONFIG_NXTK_BORDERCOLOR1; + * Condition: CONFIG_NXTK_BORDERWIDTH > 0 + * Shadow part: + * Thickness: 1; + * Color: CONFIG_NXTK_BORDERCOLOR2; + * Condition: CONFIG_NXTK_BORDERWIDTH > 1 + */ + +#if CONFIG_NXTK_BORDERWIDTH > 2 + thickness = CONFIG_NXTK_BORDERWIDTH - 2; +#elif CONFIG_NXTK_BORDERWIDTH > 1 + thickness = CONFIG_NXTK_BORDERWIDTH - 1; +#else + thickness = CONFIG_NXTK_BORDERWIDTH; +#endif + + /* Get the size of the rectangle */ + + nxgl_rectsize(&wndsize, &fwnd->wnd.bounds); + nxgl_rectsize(&tbsize, &fwnd->tbrect); + + /* Draw the top ***********************************************************/ + +#if CONFIG_NXTK_BORDERWIDTH > 0 + frame.pt1.x = 0; + frame.pt2.x = wndsize.w - 1; + frame.pt1.y = 0; + + /* Draw the shiny edge */ + +#if CONFIG_NXTK_BORDERWIDTH > 2 + frame.pt2.y = 0; + nxtk_drawframeside(fwnd, &frame, bounds, g_bordercolor3); + frame.pt1.y = 1; +#endif + + /* Draw the central part */ + + frame.pt2.y = frame.pt1.y + thickness - 1; + nxtk_drawframeside(fwnd, &frame, bounds, g_bordercolor1); + + /* Draw a single line under the toolbar, color CONFIG_NXTK_BORDERCOLOR2 */ + +#if CONFIG_NXTK_BORDERWIDTH > 1 + frame.pt1.y += tbsize.h + thickness; + frame.pt2.y = frame.pt1.y; + nxtk_drawframeside(fwnd, &frame, bounds, g_bordercolor2); +#endif + + /* Draw the bottom ********************************************************/ + +#if CONFIG_NXTK_BORDERWIDTH > 0 + frame.pt1.y = wndsize.h - CONFIG_NXTK_BORDERWIDTH; + + /* Draw the shiny edge */ + +#if CONFIG_NXTK_BORDERWIDTH > 2 + frame.pt2.y = frame.pt1.y; + nxtk_drawframeside(fwnd, &frame, bounds, g_bordercolor3); + frame.pt1.y ++; +#endif + + /* Draw the central part */ + + frame.pt2.y = frame.pt1.y + thickness - 1; + nxtk_drawframeside(fwnd, &frame, bounds, g_bordercolor1); + + /* Then a single line at the very bottom, Color: CONFIG_NXTK_BORDERCOLOR2 */ + +#if CONFIG_NXTK_BORDERWIDTH > 1 + frame.pt1.y = wndsize.h - 1; + frame.pt2.y = frame.pt1.y; + nxtk_drawframeside(fwnd, &frame, bounds, g_bordercolor2); +#endif +#endif + + /* Draw left and right outer edges *****************************************/ + + /* Draw the shiny left out edge */ + +#if CONFIG_NXTK_BORDERWIDTH > 1 + frame.pt1.x = 0; + frame.pt1.y = 1; +#if CONFIG_NXTK_BORDERWIDTH > 2 + frame.pt2.x = frame.pt1.x; + frame.pt2.y = wndsize.h - 2; + nxtk_drawframeside(fwnd, &frame, bounds, g_bordercolor3); +#endif + + /* Draw the shadowed right outer edge */ + + frame.pt1.x = wndsize.w - 1; + frame.pt2.x = frame.pt1.x; + nxtk_drawframeside(fwnd, &frame, bounds, g_bordercolor2); +#endif + + /* Draw left and right central regions *************************************/ + +#if CONFIG_NXTK_BORDERWIDTH > 2 + frame.pt1.x = 1; + frame.pt1.y = 1; + frame.pt2.x = frame.pt1.x + thickness - 1; + frame.pt2.y = wndsize.h - 2; +#else + frame.pt1.x = 0; + frame.pt1.y = 0; + frame.pt2.x = frame.pt1.x + thickness - 1; + frame.pt2.y = wndsize.h - 1; +#endif + nxtk_drawframeside(fwnd, &frame, bounds, g_bordercolor1); + +#if CONFIG_NXTK_BORDERWIDTH > 2 + frame.pt1.x = wndsize.w - thickness - 1; + frame.pt2.x = wndsize.w - 2; +#else + frame.pt1.x = wndsize.w - thickness; + frame.pt2.x = wndsize.w - 1; +#endif + nxtk_drawframeside(fwnd, &frame, bounds, g_bordercolor1); +#endif + + /* Draw left and right inner sides *****************************************/ + /* This segment stops at the bottom of the toolbar. If there is a + * tool bar, then we have to continue this to the top of the display + * using g_bordercolor1 (see below) + */ + + /* Draw the shadowed left inner edge */ + +#if CONFIG_NXTK_BORDERWIDTH > 1 +#if CONFIG_NXTK_BORDERWIDTH > 2 + frame.pt1.x = thickness + 1; + frame.pt1.y = tbsize.h + thickness + 1; + frame.pt2.x = frame.pt1.x; + frame.pt2.y = wndsize.h - thickness - 2; +#else + frame.pt1.x = thickness; + frame.pt1.y = tbsize.h + thickness; + frame.pt2.x = frame.pt1.x; + frame.pt2.y = wndsize.h - thickness - 1; +#endif + nxtk_drawframeside(fwnd, &frame, bounds, g_bordercolor2); + + /* Draw the shiny right inner edge */ + +#if CONFIG_NXTK_BORDERWIDTH > 2 + frame.pt1.x = wndsize.w - thickness - 2; + frame.pt2.x = frame.pt1.x; + nxtk_drawframeside(fwnd, &frame, bounds, g_bordercolor3); +#endif +#endif + + /* Fix up the little line-seqments at the top inner edges that need to match + * the color of the toolbar. + */ + +#if CONFIG_NXTK_BORDERWIDTH > 1 + if (tbsize.h > 0) + { + /* Draw the right side */ + +#if CONFIG_NXTK_BORDERWIDTH > 2 + frame.pt1.x = thickness + 1; + frame.pt1.y = 1; + frame.pt2.x = frame.pt1.x; + frame.pt2.y = tbsize.h + thickness; +#else + frame.pt1.x = thickness; + frame.pt1.y = 0; + frame.pt2.x = frame.pt1.x; + frame.pt2.y = tbsize.h + thickness - 1; +#endif + nxtk_drawframeside(fwnd, &frame, bounds, g_bordercolor1); + + /* Draw the left size */ + +#if CONFIG_NXTK_BORDERWIDTH > 2 + frame.pt1.x = wndsize.w - thickness - 2; + frame.pt2.x = frame.pt1.x; + nxtk_drawframeside(fwnd, &frame, bounds, g_bordercolor1); +#endif + } +#endif + + return OK; +} diff --git a/nuttx/libnx/nxtk/nxtk_drawlinetoolbar.c b/nuttx/libnx/nxtk/nxtk_drawlinetoolbar.c new file mode 100644 index 000000000..6a975536a --- /dev/null +++ b/nuttx/libnx/nxtk/nxtk_drawlinetoolbar.c @@ -0,0 +1,139 @@ +/**************************************************************************** + * libnx/nxtk/nxtk_drawlinetoolbar.c + * + * Copyright (C) 2011 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include +#include +#include + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nxtk_drawlinetoolbar + * + * Description: + * Fill the specified line in the toolbar sub-window with the specified + * color. This is simply a wrapper that uses nxgl_splitline() to break the + * line into trapezoids and then calls nxtk_filltrapwindow() to render the + * line. + * + * Input Parameters: + * hfwnd - The window handle returned by nxtk_openwindow + * vector - Describes the line to be drawn + * width - The width of the line + * color - The color to use to fill the line + * + * Return: + * OK on success; ERROR on failure with errno set appropriately + * + ****************************************************************************/ + +int nxtk_drawlinetoolbar(NXTKWINDOW hfwnd, FAR struct nxgl_vector_s *vector, + nxgl_coord_t width, nxgl_mxpixel_t color[CONFIG_NX_NPLANES]) + +{ + struct nxgl_trapezoid_s trap[3]; + struct nxgl_rect_s rect; + int ret; + +#ifdef CONFIG_DEBUG + if (!hfwnd || !vector || width < 1 || !color) + { + set_errno(EINVAL); + return ERROR; + } +#endif + + ret = nxgl_splitline(vector, trap, &rect, width); + switch (ret) + { + case 0: + ret = nxtk_filltraptoolbar(hfwnd, &trap[0], color); + if (ret == OK) + { + ret = nxtk_filltraptoolbar(hfwnd, &trap[1], color); + if (ret == OK) + { + ret = nxtk_filltraptoolbar(hfwnd, &trap[2], color); + } + } + break; + + case 1: + ret = nxtk_filltraptoolbar(hfwnd, &trap[1], color); + break; + + case 2: + ret = nxtk_filltoolbar(hfwnd, &rect, color); + break; + + default: + set_errno(EINVAL); + return ERROR; + } + + return ret; +} diff --git a/nuttx/libnx/nxtk/nxtk_drawlinewindow.c b/nuttx/libnx/nxtk/nxtk_drawlinewindow.c new file mode 100644 index 000000000..ba45a2dc8 --- /dev/null +++ b/nuttx/libnx/nxtk/nxtk_drawlinewindow.c @@ -0,0 +1,138 @@ +/**************************************************************************** + * libnx/nxtk/nxtk_drawlinewindow.c + * + * Copyright (C) 2011 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include +#include +#include + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nxtk_drawlinewindow + * + * Description: + * Fill the specified line in the window with the specified color. This + * is simply a wrapper that uses nxgl_splitline() to break the line into + * trapezoids and call calls nxtk_filltrapwindow() to render the line. + * + * Input Parameters: + * hfwnd - The window handle returned by nxtk_openwindow + * vector - Describes the line to be drawn + * width - The width of the line + * color - The color to use to fill the line + * + * Return: + * OK on success; ERROR on failure with errno set appropriately + * + ****************************************************************************/ + +int nxtk_drawlinewindow(NXTKWINDOW hfwnd, FAR struct nxgl_vector_s *vector, + nxgl_coord_t width, nxgl_mxpixel_t color[CONFIG_NX_NPLANES]) + +{ + struct nxgl_trapezoid_s trap[3]; + struct nxgl_rect_s rect; + int ret; + +#ifdef CONFIG_DEBUG + if (!hfwnd || !vector || width < 1 || !color) + { + set_errno(EINVAL); + return ERROR; + } +#endif + + ret = nxgl_splitline(vector, trap, &rect, width); + switch (ret) + { + case 0: + ret = nxtk_filltrapwindow(hfwnd, &trap[0], color); + if (ret == OK) + { + ret = nxtk_filltrapwindow(hfwnd, &trap[1], color); + if (ret == OK) + { + ret = nxtk_filltrapwindow(hfwnd, &trap[2], color); + } + } + break; + + case 1: + ret = nxtk_filltrapwindow(hfwnd, &trap[1], color); + break; + + case 2: + ret = nxtk_fillwindow(hfwnd, &rect, color); + break; + + default: + set_errno(EINVAL); + return ERROR; + } + + return ret; +} diff --git a/nuttx/libnx/nxtk/nxtk_events.c b/nuttx/libnx/nxtk/nxtk_events.c new file mode 100644 index 000000000..513bc98a8 --- /dev/null +++ b/nuttx/libnx/nxtk/nxtk_events.c @@ -0,0 +1,332 @@ +/**************************************************************************** + * libnx/nxtk/nxtk_events.c + * + * Copyright (C) 2008-2009, 2012 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include "nxtk_internal.h" + +/**************************************************************************** + * Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ + +static void nxtk_redraw(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect, + bool morem, FAR void *arg); +static void nxtk_position(NXWINDOW hwnd, FAR const struct nxgl_size_s *size, + FAR const struct nxgl_point_s *pos, + FAR const struct nxgl_rect_s *bounds, + FAR void *arg); +#ifdef CONFIG_NX_MOUSE +static void nxtk_mousein(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos, + uint8_t buttons, FAR void *arg); +#endif +#ifdef CONFIG_NX_KBD +static void nxtk_kbdin(NXWINDOW hwnd, uint8_t nch, const uint8_t *ch, + FAR void *arg); +#endif +#ifdef CONFIG_NX_MULTIUSER +static void nxtk_blocked(NXWINDOW hwnd, FAR void *arg1, FAR void *arg2); +#endif + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +const struct nx_callback_s g_nxtkcb = +{ + nxtk_redraw, /* redraw */ + nxtk_position /* position */ +#ifdef CONFIG_NX_MOUSE + , nxtk_mousein /* mousein */ +#endif +#ifdef CONFIG_NX_KBD + , nxtk_kbdin /* kbdin */ +#endif +#ifdef CONFIG_NX_MULTIUSER + , nxtk_blocked +#endif +}; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nxtk_redraw + ****************************************************************************/ + +static void nxtk_redraw(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect, + bool more, FAR void *arg) +{ + FAR struct nxtk_framedwindow_s *fwnd = (FAR struct nxtk_framedwindow_s *)hwnd; + struct nxgl_rect_s intersection; + + DEBUGASSERT(hwnd && rect && fwnd->fwcb); + + gvdbg("hwnd=%p rect={(%d,%d),(%d,%d)} more=%d\n", + hwnd, rect->pt1.x, rect->pt1.y, rect->pt2.x, rect->pt2.y, more); + + /* The incoming rectangle (rect) is relative to the containing window + * (i.e., (0,0) is the top left corner of the outer, containing window). + * If any part of the rectangle overlaps the client sub-window region, then + * forward the redraw callback. + */ + + if (fwnd->fwcb->redraw) + { + /* Clip the redraw rectangle so that it lies within the client sub-window + * bounds and move the rectangle to that it is relative to the client + * sub-window (i.e., (0,0) is the top left corner of the client sub-window). + */ + + nxtk_containerclip(fwnd, &intersection, rect, &fwnd->fwrect); + + gvdbg("fwrect intersection={(%d,%d),(%d,%d)}\n", + intersection.pt1.x, intersection.pt1.y, + intersection.pt2.x, intersection.pt2.y); + + if (!nxgl_nullrect(&intersection)) + { + fwnd->fwcb->redraw((NXTKWINDOW)fwnd, &intersection, false, fwnd->fwarg); + } + } + + /* If any part of the rectangle overlaps the client toolbar region, then + * forward the redraw callback. + */ + + if (fwnd->tbcb && fwnd->tbcb->redraw) + { + /* Clip the redraw rectangle so that it lies within the toolbar sub-window + * bounds and move the rectangle to that it is relative to the toolbar + * sub-window (i.e., (0,0) is the top left corner of the client sub-window). + */ + + nxtk_containerclip(fwnd, &intersection, rect, &fwnd->tbrect); + + gvdbg("tbrect intersection={(%d,%d),(%d,%d)}\n", + intersection.pt1.x, intersection.pt1.y, + intersection.pt2.x, intersection.pt2.y); + + if (!nxgl_nullrect(&intersection)) + { + fwnd->tbcb->redraw((NXTKWINDOW)fwnd, &intersection, false, fwnd->tbarg); + } + } + + /* Then draw the frame */ + + nxtk_drawframe(fwnd, rect); +} + +/**************************************************************************** + * Name: nxtk_position + ****************************************************************************/ + +static void nxtk_position(NXWINDOW hwnd, FAR const struct nxgl_size_s *size, + FAR const struct nxgl_point_s *pos, + FAR const struct nxgl_rect_s *bounds, + FAR void *arg) +{ + FAR struct nxtk_framedwindow_s *fwnd = (FAR struct nxtk_framedwindow_s *)hwnd; + struct nxgl_size_s subwindowsize; + + gvdbg("hwnd=%p size=(%d,%d) pos=(%d,%d) bounds={(%d,%d),(%d,%d)}\n", + hwnd, size->w, size->h, pos->x, pos->y, + bounds->pt1.x, bounds->pt1.y, bounds->pt2.x, bounds->pt2.y); + + /* Recalculate the dimensions of the toolbar and client windows */ + + nxtk_setsubwindows(fwnd); + + /* Report the size / position of the client sub-window */ + + if (fwnd->fwcb->position) + { + nxgl_rectsize(&subwindowsize, &fwnd->fwrect); + fwnd->fwcb->position((NXTKWINDOW)fwnd, &subwindowsize, + &fwnd->fwrect.pt1, bounds, fwnd->fwarg); + } + + /* Report the size / position of the toolbar sub-window */ + + if (fwnd->tbcb && fwnd->tbcb->position) + { + nxgl_rectsize(&subwindowsize, &fwnd->tbrect); + fwnd->tbcb->position((NXTKWINDOW)fwnd, &subwindowsize, + &fwnd->tbrect.pt1, bounds, fwnd->tbarg); + } +} + +/**************************************************************************** + * Name: nxtk_mousein + ****************************************************************************/ + +#ifdef CONFIG_NX_MOUSE +static void nxtk_mousein(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos, + uint8_t buttons, FAR void *arg) +{ + FAR struct nxtk_framedwindow_s *fwnd = (FAR struct nxtk_framedwindow_s *)hwnd; + struct nxgl_point_s abspos; + struct nxgl_point_s relpos; + + /* Raise the window to the top if any mouse button was pressed or if auto-raise + * is configured. Do this before reporting the mouse event (because processing + * of the mouse event could change the ordering again). + */ + + /* REVISIT: This does not work correctly. In a scenario where (1) there are + * multiple queued touchscreen events and (2) the result of the first input + * was to switch windows, then this autoraise implementation will cause the + * window to revert to the previous window. Not good behavior. + */ + +#ifndef CONFIG_NX_MULTIUSER /* Queuing only happens in multi-user mode */ +#ifdef CONFIG_NXTK_AUTORAISE + if (fwnd->wnd.above != NULL) +#else + if (buttons != 0 && fwnd->wnd.above != NULL) +#endif + { + nx_raise((NXWINDOW)&fwnd->wnd); + } +#endif + + /* When we get here, the mouse position that we receive has already been + * offset by the window origin. Here we need to detect mouse events in + * the various regions of the windows: The toolbar, the client window, + * or the frame. And then offset the position accordingly. + */ + + /* The fwrect and tbrect boxes are both in absolute display coordinates. So + * the easiest thing to do is to restore the mouse position to absolute + * display coordiantes before making the comparisons and adjustments. + */ + + nxgl_vectoradd(&abspos, pos, &fwnd->wnd.bounds.pt1); + + /* In order to deliver mouse release events to the same window where the + * mouse down event happened, we store the initial mouse down location. + */ + + if (fwnd->mbutton == 0 && buttons != 0) + { + fwnd->mpos = abspos; + } + + fwnd->mbutton = buttons; + + /* Is the mouse position inside of the client window region? */ + + if (fwnd->fwcb->mousein && nxgl_rectinside(&fwnd->fwrect, &fwnd->mpos)) + { + nxgl_vectsubtract(&relpos, &abspos, &fwnd->fwrect.pt1); + fwnd->fwcb->mousein((NXTKWINDOW)fwnd, &relpos, buttons, fwnd->fwarg); + } + + /* If the mouse position inside the toobar region? */ + + else if (fwnd->tbcb->mousein && nxgl_rectinside(&fwnd->tbrect, &fwnd->mpos)) + { + nxgl_vectsubtract(&relpos, &abspos, &fwnd->tbrect.pt1); + fwnd->tbcb->mousein((NXTKWINDOW)fwnd, &relpos, buttons, fwnd->tbarg); + } +} +#endif + +/**************************************************************************** + * Name: nxtk_kbdin + ****************************************************************************/ + +#ifdef CONFIG_NX_KBD +static void nxtk_kbdin(NXWINDOW hwnd, uint8_t nch, const uint8_t *ch, + FAR void *arg) +{ + FAR struct nxtk_framedwindow_s *fwnd = (FAR struct nxtk_framedwindow_s *)hwnd; + + /* Only the client window gets keyboard input */ + + if (fwnd->fwcb->kbdin) + { + fwnd->fwcb->kbdin((NXTKWINDOW)fwnd, nch, ch, fwnd->fwarg); + } +} +#endif + +/**************************************************************************** + * Name: nxtk_blocked + ****************************************************************************/ + +#ifdef CONFIG_NX_MULTIUSER +static void nxtk_blocked(NXWINDOW hwnd, FAR void *arg1, FAR void *arg2) +{ + FAR struct nxtk_framedwindow_s *fwnd = (FAR struct nxtk_framedwindow_s *)hwnd; + + /* Only the client window gets keyboard input */ + + if (fwnd->fwcb->blocked) + { + fwnd->fwcb->blocked((NXTKWINDOW)fwnd, fwnd->fwarg, arg2); + } +} +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ diff --git a/nuttx/libnx/nxtk/nxtk_fillcircletoolbar.c b/nuttx/libnx/nxtk/nxtk_fillcircletoolbar.c new file mode 100644 index 000000000..b4ec94edd --- /dev/null +++ b/nuttx/libnx/nxtk/nxtk_fillcircletoolbar.c @@ -0,0 +1,115 @@ +/**************************************************************************** + * libnx/nxtk/nxtk_fillcircletoolbar.c + * + * Copyright (C) 2011 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include +#include + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ + +#define NCIRCLE_TRAPS 8 + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nxtk_fillcircletoolbar + * + * Description: + * Fill a circular region using the specified color. + * + * Input Parameters: + * hfwnd - The window handle returned by nxtk_openwindow() + * center - A pointer to the point that is the center of the circle + * radius - The radius of the circle in pixels. + * color - The color to use to fill the circle. + * + * Return: + * OK on success; ERROR on failure with errno set appropriately + * + ****************************************************************************/ + +int nxtk_fillcircletoolbar(NXWINDOW hfwnd, FAR const struct nxgl_point_s *center, + nxgl_coord_t radius, + nxgl_mxpixel_t color[CONFIG_NX_NPLANES]) +{ + FAR struct nxgl_trapezoid_s traps[NCIRCLE_TRAPS]; + int i; + int ret; + + /* Describe the circular region as a sequence of 8 trapezoids */ + + nxgl_circletraps(center, radius, traps); + + /* Then rend those trapezoids */ + + for (i = 0; i < NCIRCLE_TRAPS; i++) + { + ret = nxtk_filltraptoolbar(hfwnd, &traps[i], color); + if (ret != OK) + { + return ret; + } + } + return OK; +} diff --git a/nuttx/libnx/nxtk/nxtk_fillcirclewindow.c b/nuttx/libnx/nxtk/nxtk_fillcirclewindow.c new file mode 100644 index 000000000..ee59ace1e --- /dev/null +++ b/nuttx/libnx/nxtk/nxtk_fillcirclewindow.c @@ -0,0 +1,115 @@ +/**************************************************************************** + * libnx/nxtk/nxtk_fillcirclewindow.c + * + * Copyright (C) 2011 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include +#include + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ + +#define NCIRCLE_TRAPS 8 + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nxtk_fillcirclewindow + * + * Description: + * Fill a circular region using the specified color. + * + * Input Parameters: + * hfwnd - The window handle returned by nxtk_openwindow() + * center - A pointer to the point that is the center of the circle + * radius - The radius of the circle in pixels. + * color - The color to use to fill the circle. + * + * Return: + * OK on success; ERROR on failure with errno set appropriately + * + ****************************************************************************/ + +int nxtk_fillcirclewindow(NXWINDOW hfwnd, FAR const struct nxgl_point_s *center, + nxgl_coord_t radius, + nxgl_mxpixel_t color[CONFIG_NX_NPLANES]) +{ + FAR struct nxgl_trapezoid_s traps[NCIRCLE_TRAPS]; + int i; + int ret; + + /* Describe the circular region as a sequence of 8 trapezoids */ + + nxgl_circletraps(center, radius, traps); + + /* Then rend those trapezoids */ + + for (i = 0; i < NCIRCLE_TRAPS; i++) + { + ret = nxtk_filltrapwindow(hfwnd, &traps[i], color); + if (ret != OK) + { + return ret; + } + } + return OK; +} diff --git a/nuttx/libnx/nxtk/nxtk_filltoolbar.c b/nuttx/libnx/nxtk/nxtk_filltoolbar.c new file mode 100644 index 000000000..13de37249 --- /dev/null +++ b/nuttx/libnx/nxtk/nxtk_filltoolbar.c @@ -0,0 +1,115 @@ +/**************************************************************************** + * libnx/nxtk/nxtk_filltoolbar.c + * + * Copyright (C) 2008-2009, 2013 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include +#include + +#include "nxtk_internal.h" + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nxtk_filltoolbar + * + * Description: + * Fill the specified rectangle in the client window with the specified color + * + * Input Parameters: + * 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 + * + * Return: + * OK on success; ERROR on failure with errno set appropriately + * + ****************************************************************************/ + +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 *)hfwnd; + struct nxgl_rect_s fillrect; + +#ifdef CONFIG_DEBUG + if (!hfwnd || !rect || !color) + { + set_errno(EINVAL); + return ERROR; + } +#endif + + /* Clip the rectangle so that it lies within the sub-window bounds + * then move the rectangle to that it is relative to the containing + * window. + */ + + nxtk_subwindowclip(fwnd, &fillrect, rect, &fwnd->tbrect); + + /* Then fill it */ + + return nx_fill((NXWINDOW)hfwnd, &fillrect, color); +} diff --git a/nuttx/libnx/nxtk/nxtk_filltraptoolbar.c b/nuttx/libnx/nxtk/nxtk_filltraptoolbar.c new file mode 100644 index 000000000..a55d05e7e --- /dev/null +++ b/nuttx/libnx/nxtk/nxtk_filltraptoolbar.c @@ -0,0 +1,111 @@ +/**************************************************************************** + * libnx/nxtk/nxtk_filltraptoolbar.c + * + * Copyright (C) 2008-2009, 2013 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include +#include + +#include "nxtk_internal.h" + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nxtk_filltraptoolbar + * + * Description: + * Fill the specified rectangle in the toolbar with the specified color + * + * Input Parameters: + * hfwnd - The handle returned by nxtk_openwindow + * trap - The trapezoidal region to be filled + * color - The color to use in the fill + * + * Return: + * OK on success; ERROR on failure with errno set appropriately + * + ****************************************************************************/ + +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 *)hfwnd; + struct nxgl_rect_s relclip; + +#ifdef CONFIG_DEBUG + if (!hfwnd || !trap || !color) + { + set_errno(EINVAL); + return ERROR; + } +#endif + + /* 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)hfwnd, &relclip, trap, color); +} diff --git a/nuttx/libnx/nxtk/nxtk_filltrapwindow.c b/nuttx/libnx/nxtk/nxtk_filltrapwindow.c new file mode 100644 index 000000000..e28f0d3bc --- /dev/null +++ b/nuttx/libnx/nxtk/nxtk_filltrapwindow.c @@ -0,0 +1,119 @@ +/**************************************************************************** + * libnx/nxtk/nxtk_filltrapwindow.c + * + * Copyright (C) 2008-2009, 2013 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include +#include + +#include "nxtk_internal.h" + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nxtk_filltrapwindow + * + * Description: + * Fill the specified rectangle in the client window with the specified color + * + * Input Parameters: + * hfwnd - The window handle returned by nxtk_openwindow + * trap - The trapezoidal region to be filled + * color - The color to use in the fill + * + * Return: + * OK on success; ERROR on failure with errno set appropriately + * + ****************************************************************************/ + +int nxtk_filltrapwindow(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 *)hfwnd; + struct nxgl_rect_s relclip; + struct nxgl_trapezoid_s reltrap; + +#ifdef CONFIG_DEBUG + if (!hfwnd || !trap || !color) + { + set_errno(EINVAL); + return ERROR; + } +#endif + + /* Move the trapezoid from window contents area to window area */ + + nxgl_trapoffset(&reltrap, trap, + fwnd->fwrect.pt1.x - fwnd->wnd.bounds.pt1.x, + fwnd->fwrect.pt1.y - fwnd->wnd.bounds.pt1.y); + + /* Perform the fill, clipping to the client window */ + + nxgl_rectoffset(&relclip, &fwnd->fwrect, -fwnd->wnd.bounds.pt1.x, + -fwnd->wnd.bounds.pt1.y); + + return nx_filltrapezoid((NXWINDOW)hfwnd, &relclip, &reltrap, color); +} diff --git a/nuttx/libnx/nxtk/nxtk_fillwindow.c b/nuttx/libnx/nxtk/nxtk_fillwindow.c new file mode 100644 index 000000000..77f043391 --- /dev/null +++ b/nuttx/libnx/nxtk/nxtk_fillwindow.c @@ -0,0 +1,115 @@ +/**************************************************************************** + * libnx/nxtk/nxtk_fillwindow.c + * + * Copyright (C) 2008-2009, 2013 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include +#include + +#include "nxtk_internal.h" + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nxtk_fillwindow + * + * Description: + * Fill the specified rectangle in the client window with the specified color + * + * Input Parameters: + * hfwnd - The window handle returned by nxtk_openwindow + * rect - The location within the client window to be filled + * color - The color to use in the fill + * + * Return: + * OK on success; ERROR on failure with errno set appropriately + * + ****************************************************************************/ + +int nxtk_fillwindow(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 *)hfwnd; + struct nxgl_rect_s fillrect; + +#ifdef CONFIG_DEBUG + if (!hfwnd || !rect || !color) + { + set_errno(EINVAL); + return ERROR; + } +#endif + + /* Clip the rectangle so that it lies within the sub-window bounds + * then move the rectangle to that it is relative to the containing + * window. + */ + + nxtk_subwindowclip(fwnd, &fillrect, rect, &fwnd->fwrect); + + /* Then fill it */ + + return nx_fill((NXWINDOW)hfwnd, &fillrect, color); +} diff --git a/nuttx/libnx/nxtk/nxtk_getposition.c b/nuttx/libnx/nxtk/nxtk_getposition.c new file mode 100644 index 000000000..a0b21bedb --- /dev/null +++ b/nuttx/libnx/nxtk/nxtk_getposition.c @@ -0,0 +1,94 @@ +/**************************************************************************** + * libnx/nxtk/nxtk_getposition.c + * + * Copyright (C) 2008-2009, 2013 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include +#include + +#include "nxtk_internal.h" + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nxtk_getposition + * + * Description: + * Request the position and size information for the selected framed window. + * The size/position for the client window and toolbar will be return + * asynchronously through the client callback function pointer. + * + * Input Parameters: + * hfwnd - The window handle returned by nxtk_openwindow. + * + * Return: + * OK on success; ERROR on failure with errno set appropriately + * + ****************************************************************************/ + +int nxtk_getposition(NXTKWINDOW hfwnd) +{ + return nx_getposition((NXWINDOW)hfwnd); +} diff --git a/nuttx/libnx/nxtk/nxtk_gettoolbar.c b/nuttx/libnx/nxtk/nxtk_gettoolbar.c new file mode 100644 index 000000000..a83a1aa3e --- /dev/null +++ b/nuttx/libnx/nxtk/nxtk_gettoolbar.c @@ -0,0 +1,122 @@ +/**************************************************************************** + * libnx/nxtk/nxtk_gettoolbar.c + * + * Copyright (C) 2011, 2013 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include +#include + +#include "nxtk_internal.h" + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nxtk_gettoolbar + * + * Description: + * Get the raw contents of graphic memory within a rectangular region. NOTE: + * Since raw graphic memory is returned, the returned memory content may be + * the memory of windows above this one and may not necessarily belong to + * this window unless you assure that this is the top window. + * + * Input Parameters: + * wnd - The window structure reference + * rect - The location to be copied + * plane - Specifies the color plane to get from. + * dest - The location to copy the memory region + * deststride - The width, in bytes, of the dest memory + * + * Return: + * OK on success; ERROR on failure with errno set appropriately + * + ****************************************************************************/ + +int nxtk_gettoolbar(NXTKWINDOW hfwnd, FAR const struct nxgl_rect_s *rect, + unsigned int plane, FAR uint8_t *dest, + unsigned int deststride) +{ + FAR struct nxtk_framedwindow_s *fwnd = (FAR struct nxtk_framedwindow_s *)hfwnd; + struct nxgl_rect_s getrect; + +#ifdef CONFIG_DEBUG + if (!hfwnd || !rect || !dest) + { + gvdbg("Invalid parameters\n"); + set_errno(EINVAL); + return ERROR; + } +#endif + + /* Clip the rectangle so that it lies within the sub-window bounds + * then move the rectangle to that it is relative to the containing + * window. + */ + + nxtk_subwindowclip(fwnd, &getrect, rect, &fwnd->tbrect); + + /* Then get it */ + + return nx_getrectangle((NXWINDOW)hfwnd, &getrect, plane, dest, deststride); +} diff --git a/nuttx/libnx/nxtk/nxtk_getwindow.c b/nuttx/libnx/nxtk/nxtk_getwindow.c new file mode 100644 index 000000000..a91ad05fc --- /dev/null +++ b/nuttx/libnx/nxtk/nxtk_getwindow.c @@ -0,0 +1,125 @@ +/**************************************************************************** + * libnx/nxtk/nxtk_getwindow.c + * + * Copyright (C) 2011, 2013 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include +#include + +#include "nxtk_internal.h" + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nxtk_getwindow + * + * Description: + * Get the raw contents of graphic memory within a rectangular region. NOTE: + * Since raw graphic memory is returned, the returned memory content may be + * the memory of windows above this one and may not necessarily belong to + * this window unless you assure that this is the top window. + * + * Input Parameters: + * wnd - The window structure reference + * rect - The location to be copied + * plane - Specifies the color plane to get from. + * dest - The location to copy the memory region + * deststride - The width, in bytes, of the dest memory + * + * Return: + * OK on success; ERROR on failure with errno set appropriately + * + ****************************************************************************/ + +int nxtk_getwindow(NXTKWINDOW hfwnd, FAR const struct nxgl_rect_s *rect, + unsigned int plane, FAR uint8_t *dest, + unsigned int deststride) +{ + FAR struct nxtk_framedwindow_s *fwnd = (FAR struct nxtk_framedwindow_s *)hfwnd; + struct nxgl_rect_s getrect; + +#ifdef CONFIG_DEBUG + if (!hfwnd || !rect || !dest) + { + gvdbg("Invalid parameters\n"); + set_errno(EINVAL); + return ERROR; + } +#endif + + /* Move the rectangle to that it is relative to the containing + * window. If part of the rectangle lies outside the window, + * it will contain garbage data, but the contained area will be + * valid. + */ + + nxgl_rectoffset(&getrect, rect, + fwnd->fwrect.pt1.x - fwnd->wnd.bounds.pt1.x, + fwnd->fwrect.pt1.y - fwnd->wnd.bounds.pt1.y); + + /* Then get it */ + + return nx_getrectangle((NXWINDOW)hfwnd, &getrect, plane, dest, deststride); +} diff --git a/nuttx/libnx/nxtk/nxtk_internal.h b/nuttx/libnx/nxtk/nxtk_internal.h new file mode 100644 index 000000000..7a6229341 --- /dev/null +++ b/nuttx/libnx/nxtk/nxtk_internal.h @@ -0,0 +1,225 @@ +/**************************************************************************** + * libnx/nxtk/nxtk_internal.h + * + * Copyright (C) 2008-2009, 2011-2012 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +#ifndef __LIBNX_NXTK_NXTK_INTERNAL_H +#define __LIBNX_NXTK_NXTK_INTERNAL_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include + +/**************************************************************************** + * Pre-processor definitions + ****************************************************************************/ + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +/* This is the internal representation of the framed window object */ + +struct nxtk_framedwindow_s +{ + struct nxbe_window_s wnd; /* The raw NX window */ + + /* The toolbar region and callbacks */ + + nxgl_coord_t tbheight; + struct nxgl_rect_s tbrect; + FAR const struct nx_callback_s *tbcb; + FAR void *tbarg; + + /* Window data region and callbacks */ + + struct nxgl_rect_s fwrect; + FAR const struct nx_callback_s *fwcb; + FAR void *fwarg; + + /* Initial mouse down location */ + + uint8_t mbutton; + struct nxgl_point_s mpos; +}; + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +#undef EXTERN +#if defined(__cplusplus) +# define EXTERN extern "C" +extern "C" +{ +#else +# define EXTERN extern +#endif + +/* That is the callback for the framed window */ + +EXTERN FAR const struct nx_callback_s g_nxtkcb; + +/* Frame border colors */ + +EXTERN nxgl_mxpixel_t g_bordercolor1[CONFIG_NX_NPLANES]; +EXTERN nxgl_mxpixel_t g_bordercolor2[CONFIG_NX_NPLANES]; +EXTERN nxgl_mxpixel_t g_bordercolor3[CONFIG_NX_NPLANES]; + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Name: nxtk_setsubwindows + * + * Description: + * Give the window dimensions, border width, and toolbar height, + * calculate the new dimensions of the toolbar region and client window + * region + * + ****************************************************************************/ + +void nxtk_setsubwindows(FAR struct nxtk_framedwindow_s *fwnd); + +/**************************************************************************** + * Name: nxtk_subwindowclip + * + * Description: + * Clip the src rectangle so that it lies within the sub-window bounds + * then move the rectangle to that it is relative to the containing + * window. + * + * Input parameters: + * fwnd - The framed window to be used + * dest - The locaton to put the result + * src - The src rectangle in relative sub-window coordinates + * bounds - The subwindow bounds in absolute screen coordinates. + * + * Returned value: + * None + * + ****************************************************************************/ + +void nxtk_subwindowclip(FAR struct nxtk_framedwindow_s *fwnd, + FAR struct nxgl_rect_s *dest, + FAR const struct nxgl_rect_s *src, + FAR const struct nxgl_rect_s *bounds); + +/**************************************************************************** + * Name: nxtk_containerclip + * + * Description: + * We are given a 'src' rectangle in containing window, relative coordinates + * (i.e., (0,0) is the top left corner of the outer, containing window). + * This function will (1) clip that src rectangle so that it lies within + * the sub-window bounds, and then (2) move the rectangle to that it is + * relative to the sub-window (i.e., (0,0) is the top left corner of the + * sub-window). + * + * Input parameters: + * fwnd - The framed window to be used + * dest - The location to put the result + * src - The src rectangle in relative container-window coordinates + * bounds - The subwindow bounds in absolute screen coordinates. + * + * Returned value: + * None + * + ****************************************************************************/ + +void nxtk_containerclip(FAR struct nxtk_framedwindow_s *fwnd, + FAR struct nxgl_rect_s *dest, + FAR const struct nxgl_rect_s *src, + FAR const struct nxgl_rect_s *bounds); + +/**************************************************************************** + * Name: nxtk_subwindowmove + * + * Description: + * Perform common clipping operations in preparation for calling nx_move() + * + * Input Parameters: + * fwnd - The framed window within which the move is to be done. + * This must have been previously created by nxtk_openwindow(). + * destrect - The location to receive the clipped rectangle relative + * to containing window + * destoffset - The location to received the clipped offset. + * srcrect - Describes the rectangular region relative to the client + * sub-window to move relative to the sub-window + * srcoffset - The offset to move the region + * bounds - The subwindow bounds in absolute screen coordinates. + * + * Return: + * OK on success; ERROR on failure with errno set appropriately + * + ****************************************************************************/ + +void nxtk_subwindowmove(FAR struct nxtk_framedwindow_s *fwnd, + FAR struct nxgl_rect_s *destrect, + FAR struct nxgl_point_s *destoffset, + FAR const struct nxgl_rect_s *srcrect, + FAR const struct nxgl_point_s *srcoffset, + FAR const struct nxgl_rect_s *bounds); + +/**************************************************************************** + * Name: nxtk_drawframe + * + * Description: + * Redraw the window frame. + * + * Input parameters: + * fwnd - the framed window whose frame needs to be re-drawn. This must + * have been previously created by nxtk_openwindow(). + * bounds - Only draw the ports of the frame within this bounding box. + * (window relative coordinates). + * + * Returned value: + * OK on success; ERROR on failure with errno set appropriately + * + ****************************************************************************/ + +int nxtk_drawframe(FAR struct nxtk_framedwindow_s *fwnd, + FAR const struct nxgl_rect_s *bounds); + +#undef EXTERN +#if defined(__cplusplus) +} +#endif + +#endif /* __LIBNX_NXTK_NXTK_INTERNAL_H */ diff --git a/nuttx/libnx/nxtk/nxtk_lower.c b/nuttx/libnx/nxtk/nxtk_lower.c new file mode 100644 index 000000000..de26ac509 --- /dev/null +++ b/nuttx/libnx/nxtk/nxtk_lower.c @@ -0,0 +1,94 @@ +/**************************************************************************** + * libnx/nxtk/nxtk_lower.c + * + * Copyright (C) 2008-2009, 2013 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include +#include + +#include "nxtk_internal.h" + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nxtk_lower + * + * Description: + * Lower the window containing the specified client sub-window to the + * bottom of the display. + * + * Input parameters: + * hfwnd - the window to be lowered. This must have been previously + * created by nxtk_openwindow(). + * + * Returned value: + * OK on success; ERROR on failure with errno set appropriately + * + ****************************************************************************/ + +int nxtk_lower(NXTKWINDOW hfwnd) +{ + return nx_lower((NXWINDOW)hfwnd); +} diff --git a/nuttx/libnx/nxtk/nxtk_movetoolbar.c b/nuttx/libnx/nxtk/nxtk_movetoolbar.c new file mode 100644 index 000000000..b5f05c096 --- /dev/null +++ b/nuttx/libnx/nxtk/nxtk_movetoolbar.c @@ -0,0 +1,119 @@ +/**************************************************************************** + * libnx/nxtk/nxtk_movetoolbar.c + * + * Copyright (C) 2008-2009, 2013 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include +#include + +#include "nxtk_internal.h" + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * 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 + * + ****************************************************************************/ + +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 *)hfwnd; + struct nxgl_rect_s srcrect; + struct nxgl_point_s clipoffset; + +#ifdef CONFIG_DEBUG + if (!hfwnd || !rect || !offset) + { + set_errno(EINVAL); + return ERROR; + } +#endif + + /* Make sure that both the source and dest rectangle lie within the + * toolbar sub-window + */ + + nxtk_subwindowmove(fwnd, &srcrect, &clipoffset, rect, offset, &fwnd->tbrect); + + /* Then move it within the toolbar window */ + + return nx_move((NXWINDOW)hfwnd, &srcrect, &clipoffset); +} diff --git a/nuttx/libnx/nxtk/nxtk_movewindow.c b/nuttx/libnx/nxtk/nxtk_movewindow.c new file mode 100644 index 000000000..f9bbbac41 --- /dev/null +++ b/nuttx/libnx/nxtk/nxtk_movewindow.c @@ -0,0 +1,118 @@ +/**************************************************************************** + * libnx/nxtk/nxtk_movewindow.c + * + * Copyright (C) 2008-2009, 2013 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include +#include + +#include "nxtk_internal.h" + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nxtk_movewindow + * + * Description: + * Move a rectangular region within the client sub-window of a framed + * window + * + * Input Parameters: + * hfwnd - The client sub-window 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 client + * sub-window to move + * offset - The offset to move the region + * + * Return: + * OK on success; ERROR on failure with errno set appropriately + * + ****************************************************************************/ + +int nxtk_movewindow(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 *)hfwnd; + struct nxgl_rect_s srcrect; + struct nxgl_point_s clipoffset; + +#ifdef CONFIG_DEBUG + if (!hfwnd || !rect || !offset) + { + set_errno(EINVAL); + return ERROR; + } +#endif + + /* Make sure that both the source and dest rectangle lie within the + * client sub-window + */ + + nxtk_subwindowmove(fwnd, &srcrect, &clipoffset, rect, offset, &fwnd->fwrect); + + /* Then move it within the client window */ + + return nx_move((NXWINDOW)hfwnd, &srcrect, &clipoffset); +} diff --git a/nuttx/libnx/nxtk/nxtk_opentoolbar.c b/nuttx/libnx/nxtk/nxtk_opentoolbar.c new file mode 100644 index 000000000..ffdf62901 --- /dev/null +++ b/nuttx/libnx/nxtk/nxtk_opentoolbar.c @@ -0,0 +1,126 @@ +/**************************************************************************** + * libnx/nxtk/nxtk_opentoolbar.c + * + * Copyright (C) 2008-2009, 2013 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include +#include + +#include "nxtk_internal.h" + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nxtk_opentoolbar + * + * Description: + * Create a tool bar at the top of the specified framed window + * + * Input Parameters: + * hfwnd - The handle returned by nxtk_openwindow + * height - The request height of the toolbar in pixels + * cb - Callbacks used to process toolbar events + * arg - User provided value that will be returned with toolbar + * callbacks. + * + * Return: + * OK on success; ERROR on failure with errno set appropriately + * + ****************************************************************************/ + +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; + +#ifdef CONFIG_DEBUG + if (!hfwnd || !cb) + { + set_errno(EINVAL); + return ERROR; + } +#endif + + /* Initialize the toolbar info */ + + fwnd->tbheight = height; + fwnd->tbcb = cb; + fwnd->tbarg = arg; + + /* Calculate the new dimensions of the toolbar and client windows */ + + nxtk_setsubwindows(fwnd); + + /* Then redraw the entire window, even the client window must be + * redrawn because it has changed its vertical position and size. + */ + + nx_redrawreq(&fwnd->wnd, &fwnd->wnd.bounds); + + /* Return the initialized toolbar reference */ + + return OK; +} diff --git a/nuttx/libnx/nxtk/nxtk_openwindow.c b/nuttx/libnx/nxtk/nxtk_openwindow.c new file mode 100644 index 000000000..fc7ddd869 --- /dev/null +++ b/nuttx/libnx/nxtk/nxtk_openwindow.c @@ -0,0 +1,161 @@ +/**************************************************************************** + * libnx/nxtk/nxtk_openwindow.c + * + * Copyright (C) 2008-2009, 2012-2013 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include + +#include "nxcontext.h" +#include "nxtk_internal.h" + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +nxgl_mxpixel_t g_bordercolor1[CONFIG_NX_NPLANES] = +{ + CONFIG_NXTK_BORDERCOLOR1 +#if CONFIG_NX_NPLANES > 1 +# error "Multiple plane border colors not defined" +#endif +}; + +nxgl_mxpixel_t g_bordercolor2[CONFIG_NX_NPLANES] = +{ + CONFIG_NXTK_BORDERCOLOR2 +#if CONFIG_NX_NPLANES > 1 +# error "Multiple plane border colors not defined" +#endif +}; + +nxgl_mxpixel_t g_bordercolor3[CONFIG_NX_NPLANES] = +{ + CONFIG_NXTK_BORDERCOLOR3 +#if CONFIG_NX_NPLANES > 1 +# error "Multiple plane border colors not defined" +#endif +}; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nxtk_openwindow + * + * Description: + * Create a new, framed window. + * + * Input Parameters: + * handle - The handle returned by nx_connect + * cb - Callbacks used to process window events + * arg - User provided value that will be returned with NXTK callbacks. + * + * Return: + * Success: A non-NULL handle used with subsequent NXTK window accesses + * Failure: NULL is returned and errno is set appropriately + * + ****************************************************************************/ + +NXTKWINDOW nxtk_openwindow(NXHANDLE handle, + FAR const struct nx_callback_s *cb, + FAR void *arg) +{ + FAR struct nxtk_framedwindow_s *fwnd; + int ret; + +#ifdef CONFIG_DEBUG + if (!handle || !cb) + { + set_errno(EINVAL); + return NULL; + } +#endif + + /* Pre-allocate the window structure */ + + fwnd = (FAR struct nxtk_framedwindow_s *) + lib_zalloc(sizeof(struct nxtk_framedwindow_s)); + + if (!fwnd) + { + set_errno(ENOMEM); + return NULL; + } + + /* Initialize the window structure */ + + fwnd->fwcb = cb; + fwnd->fwarg = arg; + + /* Then let nx_constructwindow do the rest */ + + ret = nx_constructwindow(handle, &fwnd->wnd, &g_nxtkcb, NULL); + if (ret < 0) + { + /* An error occurred, the window has been freed */ + + return NULL; + } + + /* Return the initialized window reference */ + + return (NXTKWINDOW)fwnd; +} + diff --git a/nuttx/libnx/nxtk/nxtk_raise.c b/nuttx/libnx/nxtk/nxtk_raise.c new file mode 100644 index 000000000..2b54f81cb --- /dev/null +++ b/nuttx/libnx/nxtk/nxtk_raise.c @@ -0,0 +1,94 @@ +/**************************************************************************** + * libnx/nxtk/nxtk_raise.c + * + * Copyright (C) 2008-2009, 2013 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include +#include + +#include "nxtk_internal.h" + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nxtk_raise + * + * Description: + * Bring the window containing the specified client sub-window to the top + * of the display. + * + * Input parameters: + * hfwnd - the window to be raised. This must have been previously + * created by nxtk_openwindow(). + * + * Returned value: + * OK on success; ERROR on failure with errno set appropriately + * + ****************************************************************************/ + +int nxtk_raise(NXTKWINDOW hfwnd) +{ + return nx_raise((NXWINDOW)hfwnd); +} diff --git a/nuttx/libnx/nxtk/nxtk_setposition.c b/nuttx/libnx/nxtk/nxtk_setposition.c new file mode 100644 index 000000000..f3ba11872 --- /dev/null +++ b/nuttx/libnx/nxtk/nxtk_setposition.c @@ -0,0 +1,106 @@ +/**************************************************************************** + * libnx/nxtk/nxtk_setposition.c + * + * Copyright (C) 2008-2009, 2012-2013 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include +#include + +#include "nxtk_internal.h" + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nxtk_setposition + * + * Description: + * Set the position for the selected client window. This position does not + * include the offsets for the borders nor for any toolbar. Those offsets + * will be added in to set the full window position. + * + * Input Parameters: + * hfwnd - The window handle returned by nxtk_openwindow + * pos - The new position of the client sub-window + * + * Return: + * OK on success; ERROR on failure with errno set appropriately + * + ****************************************************************************/ + +int nxtk_setposition(NXTKWINDOW hfwnd, FAR const struct nxgl_point_s *pos) +{ + FAR struct nxtk_framedwindow_s *fwnd = (FAR struct nxtk_framedwindow_s *)hfwnd; + struct nxgl_point_s offset; + struct nxgl_point_s newpos; + + /* Calculate the offset that is requested and add that to the window origin. */ + + nxgl_vectsubtract(&offset, pos, &fwnd->fwrect.pt1); + nxgl_vectoradd(&newpos, &offset, &fwnd->wnd.bounds.pt1); + + /* Then set that position */ + + return nx_setposition((NXWINDOW)hfwnd, &newpos); +} diff --git a/nuttx/libnx/nxtk/nxtk_setsize.c b/nuttx/libnx/nxtk/nxtk_setsize.c new file mode 100644 index 000000000..671aa8054 --- /dev/null +++ b/nuttx/libnx/nxtk/nxtk_setsize.c @@ -0,0 +1,113 @@ +/**************************************************************************** + * libnx/nxtk/nxtk_setsize.c + * + * Copyright (C) 2008-2009, 2013 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include +#include + +#include "nxtk_internal.h" + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nxtk_setsize + * + * Description: + * Set the size for the selected client window. This size does not + * include the sizes of the borders nor for any toolbar. Those sizes + * will be added in to set the full window size. + * + * Input Parameters: + * hfwnd - The window handle returned by nxtk_openwindow + * size - The new size of the client sub-window. + * + * Return: + * OK on success; ERROR on failure with errno set appropriately + * + ****************************************************************************/ + +int nxtk_setsize(NXTKWINDOW hfwnd, FAR const struct nxgl_size_s *size) +{ + FAR struct nxtk_framedwindow_s *fwnd = (FAR struct nxtk_framedwindow_s *)hfwnd; + struct nxgl_size_s newsize; + +#ifdef CONFIG_DEBUG + if (!hfwnd || !size) + { + set_errno(EINVAL); + return ERROR; + } +#endif + + /* Add the sizes need for the toolbar and the borders */ + + newsize.w = size->w + 2 * CONFIG_NXTK_BORDERWIDTH; + newsize.h = size->h + fwnd->tbheight + 2 * CONFIG_NXTK_BORDERWIDTH; + + /* Then set the window size */ + + return nx_setsize((NXWINDOW)hfwnd, &newsize); +} diff --git a/nuttx/libnx/nxtk/nxtk_setsubwindows.c b/nuttx/libnx/nxtk/nxtk_setsubwindows.c new file mode 100644 index 000000000..e528f43e9 --- /dev/null +++ b/nuttx/libnx/nxtk/nxtk_setsubwindows.c @@ -0,0 +1,165 @@ +/**************************************************************************** + * libnx/nxtk/nxtk_setsubwindows.c + * + * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include +#include + +#include +#include "nxtk_internal.h" + +/**************************************************************************** + * Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nxtk_setsubwindows + * + * Description: + * Give the window dimensions, border width, and toolbar height, + * calculate the new dimensions of the toolbar region and client window + * region + * + ****************************************************************************/ + +void nxtk_setsubwindows(FAR struct nxtk_framedwindow_s *fwnd) +{ + nxgl_coord_t fullheight; + nxgl_coord_t bdrheight = 0; + nxgl_coord_t tbtop = fwnd->wnd.bounds.pt1.y; + nxgl_coord_t tbheight = 0; + nxgl_coord_t fwtop = fwnd->wnd.bounds.pt1.y; + nxgl_coord_t fwheight = 0; + nxgl_coord_t fullwidth; + nxgl_coord_t bdrwidth; + nxgl_coord_t fwwidth; + nxgl_coord_t fwleft; + + /* Divide up the vertical dimension of the window */ + + fullheight = fwnd->wnd.bounds.pt2.y - fwnd->wnd.bounds.pt1.y + 1; + + /* Is it tall enough for a border? */ + + if (fullheight > 0) + { + /* Get the border height */ + + bdrheight = ngl_min(2 * CONFIG_NXTK_BORDERWIDTH, fullheight); + + /* Position the toolbar and client window just under the top border */ + +#if CONFIG_NXTK_BORDERWIDTH > 1 + tbtop += CONFIG_NXTK_BORDERWIDTH - 1; + fwtop = tbtop + 1; +#else + tbtop += CONFIG_NXTK_BORDERWIDTH; + fwtop = tbtop; +#endif + + /* Is it big enough for any part of the toolbar? */ + + if (fullheight > 2 * CONFIG_NXTK_BORDERWIDTH) + { + /* Yes.. get the height of the toolbar */ + + tbheight = fwnd->tbheight; + if (tbheight >= fullheight - bdrheight) + { + tbheight = fullheight - bdrheight; + } + else + { + /* And the client window gets whatever is left */ + + fwheight = fullheight - bdrheight - tbheight; + } + + /* Position the client window just under the toolbar */ + + fwtop += tbheight; + } + } + + /* Divide up the horizontal dimensions of the window */ + + fullwidth = fwnd->wnd.bounds.pt2.x - fwnd->wnd.bounds.pt1.x + 1; + bdrwidth = ngl_min(2 * CONFIG_NXTK_BORDERWIDTH, fullwidth); + fwwidth = fullwidth - bdrwidth; + fwleft = fwnd->wnd.bounds.pt1.x + bdrwidth / 2; + + /* Realize the positions/dimensions */ + + fwnd->tbrect.pt1.x = fwleft; + fwnd->tbrect.pt1.y = tbtop; + fwnd->tbrect.pt2.x = fwleft + fwwidth - 1; + fwnd->tbrect.pt2.y = tbtop + tbheight - 1; + + fwnd->fwrect.pt1.x = fwleft; + fwnd->fwrect.pt1.y = fwtop; + fwnd->fwrect.pt2.x = fwleft + fwwidth - 1; + fwnd->fwrect.pt2.y = fwtop + fwheight - 1; +} diff --git a/nuttx/libnx/nxtk/nxtk_subwindowclip.c b/nuttx/libnx/nxtk/nxtk_subwindowclip.c new file mode 100644 index 000000000..b2688a543 --- /dev/null +++ b/nuttx/libnx/nxtk/nxtk_subwindowclip.c @@ -0,0 +1,117 @@ +/**************************************************************************** + * libnx/nxtk/nxtk_subwindowclip.c + * + * Copyright (C) 2008-2009, 2013 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include +#include + +#include "nxtk_internal.h" + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nxtk_subwindowclip + * + * Description: + * We are given a 'src' rectangle in sub-window, relative coordinates + * (i.e., (0,0) is the top left corner of the sub-window). This function + * will (1) clip that src rectangle so that it lies within the sub-window + * bounds, and then (2) move the rectangle to that it is relative to the + * containing window (i.e., (0,0) is the top left corner of the containing + * window). + * + * Input parameters: + * fwnd - The framed window to be used + * dest - The locaton to put the result + * src - The src rectangle in relative sub-window coordinates + * bounds - The subwindow bounds in absolute screen coordinates. + * + * Returned value: + * None + * + ****************************************************************************/ + +void nxtk_subwindowclip(FAR struct nxtk_framedwindow_s *fwnd, + FAR struct nxgl_rect_s *dest, + FAR const struct nxgl_rect_s *src, + FAR const struct nxgl_rect_s *bounds) +{ + struct nxgl_rect_s tmp; + + /* Temporarily, position the src rectangle in absolute screen coordinates */ + + nxgl_rectoffset(&tmp, src, bounds->pt1.x, bounds->pt1.y); + + /* Clip the src rectangle to lie within the client window region */ + + nxgl_rectintersect(&tmp, &tmp, bounds); + + /* Then move the rectangle so that is relative to the containing window, not the + * client subwindow + */ + + nxgl_rectoffset(dest, &tmp, -fwnd->wnd.bounds.pt1.x, -fwnd->wnd.bounds.pt1.y); +} diff --git a/nuttx/libnx/nxtk/nxtk_subwindowmove.c b/nuttx/libnx/nxtk/nxtk_subwindowmove.c new file mode 100644 index 000000000..6ae737b58 --- /dev/null +++ b/nuttx/libnx/nxtk/nxtk_subwindowmove.c @@ -0,0 +1,149 @@ +/**************************************************************************** + * libnx/nxtk/nxtk_subwindowmove.c + * + * Copyright (C) 2008-2009, 2013 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include +#include + +#include "nxtk_internal.h" + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nxtk_subwindowmove + * + * Description: + * Perform common clipping operations in preparatons for calling nx_move() + * + * Input Parameters: + * fwnd - The framed window within which the move is to be done. + * This must have been previously created by nxtk_openwindow(). + * destrect - The loccation to receive the clipped rectangle relative + * to containing window + * destoffset - The location to received the clipped offset. + * srcrect - Describes the rectangular region relative to the client + * sub-window to move relative to the sub-window + * srcoffset - The offset to move the region + * bounds - The subwindow bounds in absolute screen coordinates. + * + * Return: + * OK on success; ERROR on failure with errno set appropriately + * + ****************************************************************************/ + +void nxtk_subwindowmove(FAR struct nxtk_framedwindow_s *fwnd, + FAR struct nxgl_rect_s *destrect, + FAR struct nxgl_point_s *destoffset, + FAR const struct nxgl_rect_s *srcrect, + FAR const struct nxgl_point_s *srcoffset, + FAR const struct nxgl_rect_s *bounds) +{ + struct nxgl_rect_s abssrc; + + /* Temporarily, position the src rectangle in absolute screen coordinates */ + + nxgl_rectoffset(&abssrc, srcrect, bounds->pt1.x, bounds->pt1.y); + + /* Clip the src rectangle to lie within the client window region */ + + nxgl_rectintersect(&abssrc, &abssrc, &fwnd->fwrect); + + /* Clip the source rectangle so that destination area is within the window. */ + + destoffset->x = srcoffset->x; + if (destoffset->x < 0) + { + if (abssrc.pt1.x + destoffset->x < bounds->pt1.x) + { + abssrc.pt1.x = bounds->pt1.x - destoffset->x; + } + } + else if (abssrc.pt2.x + destoffset->x > bounds->pt2.x) + { + abssrc.pt2.x = bounds->pt2.x - destoffset->x; + } + + destoffset->y = srcoffset->y; + if (destoffset->y < 0) + { + if (abssrc.pt1.y + destoffset->y < bounds->pt1.y) + { + abssrc.pt1.y = bounds->pt1.y - destoffset->y; + } + } + else if (abssrc.pt2.y + destoffset->y > bounds->pt2.y) + { + abssrc.pt2.y = bounds->pt2.y - destoffset->y; + } + + + /* Then move the rectangle so that is relative to the containing window, + * not the client subwindow + */ + + nxgl_rectoffset(destrect, &abssrc, -fwnd->wnd.bounds.pt1.x, + -fwnd->wnd.bounds.pt1.y); +} diff --git a/nuttx/libnx/nxtk/nxtk_toolbarbounds.c b/nuttx/libnx/nxtk/nxtk_toolbarbounds.c new file mode 100644 index 000000000..2f5991d70 --- /dev/null +++ b/nuttx/libnx/nxtk/nxtk_toolbarbounds.c @@ -0,0 +1,105 @@ +/**************************************************************************** + * libnx/nxtk/nxtk_toolbarbounds.c + * + * Copyright (C) 2012-2013 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include + +#include +#include + +#include "nxtk_internal.h" + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nxtk_toolbarbounds + * + * Description: + * Return a bounding box that contains the toolbar in the coordinates of + * the containing, framed window. For example, the recturned origin + * (rect.pt1) is the offset toolbar in the framed window. + * + * NOTE: This function is unsafe in the case of the multi-user NX server + * where the width of the window may be being changed asynchronously! It + * may return the old size in this case. + * + * Input Parameters: + * hfwnd - The handle returned by nxtk_openwindow + * bounds - User provided location in which to return the bounding box. + * + * Return: + * OK on success; ERROR on failure with errno set appropriately + * + ****************************************************************************/ + +int nxtk_toolbarbounds(NXTKWINDOW hfwnd, FAR struct nxgl_rect_s *bounds) +{ + FAR struct nxtk_framedwindow_s *fwnd = (FAR struct nxtk_framedwindow_s *)hfwnd; + + DEBUGASSERT(hfwnd && bounds); + + /* Offset the rectangle by subtracting the current position of the window. */ + + nxgl_rectoffset(bounds, &fwnd->tbrect, + -fwnd->wnd.bounds.pt1.x, -fwnd->wnd.bounds.pt1.y); + return OK; +} -- cgit v1.2.3