mirror of
https://github.com/apache/nuttx.git
synced 2025-01-13 10:58:49 +08:00
Revised/simplified toolkit concept
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1390 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
fcb0515526
commit
6a27ade4af
17 changed files with 1958 additions and 292 deletions
|
@ -34,4 +34,10 @@
|
|||
############################################################################
|
||||
|
||||
NXTK_ASRCS =
|
||||
NXTK_CSRCS = nxtk_rawwindow.c
|
||||
NXTKWIN_CSRCS = nxtk_openwindow.c nxtk_closewindow.c nxtk_getposition.c \
|
||||
nxtk_setposition.c nxtk_setsize.c nxtk_fillwindow.c \
|
||||
nxtk_filltrapwindow.c nxtk_events.c \
|
||||
nxtk_setsubwindows.c
|
||||
NXTKTB_CSRCS = nxtk_opentoolbar.c nxtk_closetoolbar.c nxtk_filltoolbar.c \
|
||||
nxtk_filltraptoolbar.c
|
||||
NXTK_CSRCS = $(NXTKWIN_CSRCS) $(NXTKTB_CSRCS)
|
111
graphics/nxtk/nxtk_closetoolbar.c
Normal file
111
graphics/nxtk/nxtk_closetoolbar.c
Normal file
|
@ -0,0 +1,111 @@
|
|||
/****************************************************************************
|
||||
* graphics/nxtk/nxtk_closetoolbar.c
|
||||
*
|
||||
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* 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 <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/nx.h>
|
||||
#include <nuttx/nxtk.h>
|
||||
|
||||
#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:
|
||||
* htb - The toolbar handle returned by nxtk_opentoolbar
|
||||
*
|
||||
* Return:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void nxtk_closetoolbar(NXTKTOOLBAR htb)
|
||||
{
|
||||
FAR struct nxtk_framedwindow_s *fwnd = (FAR struct nxtk_framedwindow_s *)htb;
|
||||
|
||||
/* 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);
|
||||
}
|
||||
|
96
graphics/nxtk/nxtk_closewindow.c
Normal file
96
graphics/nxtk/nxtk_closewindow.c
Normal file
|
@ -0,0 +1,96 @@
|
|||
/****************************************************************************
|
||||
* graphics/nxtk/nxtk_closewindow.c
|
||||
*
|
||||
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* 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 <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/nx.h>
|
||||
#include <nuttx/nxtk.h>
|
||||
|
||||
#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:
|
||||
* Success: A non-NULL handle used with subsequent NXTK window accesses
|
||||
* Failure: NULL is returned and errno is set appropriately
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void nxtk_closewindow(NXTKWINDOW hfwnd)
|
||||
{
|
||||
nx_closewindow((NXWINDOW)hfwnd);
|
||||
}
|
||||
|
253
graphics/nxtk/nxtk_events.c
Normal file
253
graphics/nxtk/nxtk_events.c
Normal file
|
@ -0,0 +1,253 @@
|
|||
/****************************************************************************
|
||||
* graphics/nxtk/nxtk_events.c
|
||||
*
|
||||
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* 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 <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
#include <semaphore.h>
|
||||
#include <debug.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <nuttx/nx.h>
|
||||
#include "nxtk_internal.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
static void nxtk_redraw(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
|
||||
boolean morem, FAR void *arg);
|
||||
static void nxtk_position(NXWINDOW hwnd, FAR const struct nxgl_rect_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,
|
||||
ubyte buttons, FAR void *arg);
|
||||
#endif
|
||||
#ifdef CONFIG_NX_KBD
|
||||
static void nxtk_kbdin(NXWINDOW hwnd, ubyte nch, const ubyte *ch);
|
||||
#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_kbdin1 /* kbdin */
|
||||
#endif
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxtk_redraw
|
||||
****************************************************************************/
|
||||
|
||||
static void nxtk_redraw(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
|
||||
boolean 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("nxtk_redraw: hwnd=%p rect={(%d,%d),(%d,%d)} more=%d\n",
|
||||
hwnd, rect->pt1.x, rect->pt1.y, rect->pt2.x, rect->pt2.y, more);
|
||||
|
||||
/* If any part of the rectangle overlaps the client window region, then
|
||||
* forward the redraw callback.
|
||||
*/
|
||||
|
||||
if (fwnd->fwcb->redraw)
|
||||
{
|
||||
nxgl_rectintersect(&intersection, &fwnd->fwrect, rect);
|
||||
gvdbg("nxtk_redraw: fwrect intersction={(%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)
|
||||
{
|
||||
nxgl_rectintersect(&intersection, &fwnd->tbrect, rect);
|
||||
gvdbg("nxtk_redraw: tbrect intersction={(%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);
|
||||
}
|
||||
}
|
||||
|
||||
#warning "Need to redraw frame as well"
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxtk_position
|
||||
****************************************************************************/
|
||||
|
||||
static void nxtk_position(NXWINDOW hwnd, FAR const struct nxgl_rect_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_rect_s relrect;
|
||||
|
||||
gvdbg("nxtk_position: hwnd=%p size={(%d,%d),(%d,%d)} pos=(%d,%d) bounds={(%d,%d),(%d,%d)}\n",
|
||||
hwnd, size->pt1.x, size->pt1.y, size->pt2.x, size->pt2.y,
|
||||
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_rectoffset(&relrect, &fwnd->fwrect, fwnd->fwrect.pt1.x, fwnd->fwrect.pt1.y);
|
||||
fwnd->fwcb->position((NXTKWINDOW)fwnd, &relrect, &fwnd->fwrect.pt1, bounds, fwnd->fwarg);
|
||||
}
|
||||
|
||||
/* Report the size position of the toolbar sub-window */
|
||||
|
||||
if (fwnd->tbcb && fwnd->tbcb->position)
|
||||
{
|
||||
nxgl_rectoffset(&relrect, &fwnd->tbrect, fwnd->tbrect.pt1.x, fwnd->tbrect.pt1.y);
|
||||
fwnd->tbcb->position((NXTKWINDOW)fwnd, &relrect, &fwnd->fwrect.pt1, bounds, fwnd->tbarg);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxtk_mousein
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NX_MOUSE
|
||||
static void nxtk_mousein(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos,
|
||||
ubyte buttons, FAR void *arg)
|
||||
{
|
||||
FAR struct nxtk_framedwindow_s *fwnd = (FAR struct nxtk_framedwindow_s *)hwnd;
|
||||
struct nxgl_point_s relpos;
|
||||
|
||||
/* Is the mouse position inside of the client window region? */
|
||||
|
||||
if (fwnd->fwcb->mousein && nxgl_rectinside(&fwnd->fwrect, pos))
|
||||
{
|
||||
nxgl_vectsubtract(&relpos, pos, &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, pos))
|
||||
{
|
||||
nxgl_vectsubtract(&relpos, pos, &fwnd->tbrect.pt1);
|
||||
fwnd->tbcb->mousein((NXTKWINDOW)fwnd, &relpos, buttons, fwnd->tbarg);
|
||||
}
|
||||
|
||||
/* Raise the window to the top if any mouse button was pressed or if auto-raise
|
||||
* is configured.
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_NXTK_AUTORAISE
|
||||
if (buttons != 0)
|
||||
#endif
|
||||
{
|
||||
nx_raise((NXWINDOW)&fwnd->wnd);
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxtk_kbdin
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NX_KBD
|
||||
static void nxtk_kbdin(NXWINDOW hwnd, ubyte nch, const ubyte *ch)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
116
graphics/nxtk/nxtk_filltoolbar.c
Normal file
116
graphics/nxtk/nxtk_filltoolbar.c
Normal file
|
@ -0,0 +1,116 @@
|
|||
/****************************************************************************
|
||||
* graphics/nxtk/nxtk_filltoolbar.c
|
||||
*
|
||||
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* 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 <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/nx.h>
|
||||
#include <nuttx/nxtk.h>
|
||||
|
||||
#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:
|
||||
* htb - The toolbar handle returned by nxtk_opentoolbar
|
||||
* 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(NXTKTOOLBAR htb, FAR const struct nxgl_rect_s *rect,
|
||||
nxgl_mxpixel_t color[CONFIG_NX_NPLANES])
|
||||
{
|
||||
FAR struct nxtk_framedwindow_s *fwnd = (FAR struct nxtk_framedwindow_s *)htb;
|
||||
struct nxgl_rect_s relbounds;
|
||||
struct nxgl_rect_s cliprect;
|
||||
|
||||
#ifdef CONFIG_DEBUG
|
||||
if (!htb || !rect || !color)
|
||||
{
|
||||
errno = EINVAL;
|
||||
return ERROR;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Clip the rectangle to lie within the toolbar region */
|
||||
|
||||
nxgl_rectoffset(&relbounds, &fwnd->tbrect, fwnd->tbrect.pt1.x, fwnd->tbrect.pt1.y);
|
||||
nxgl_rectintersect(&cliprect, rect, &relbounds);
|
||||
|
||||
/* Then fill it */
|
||||
|
||||
return nx_fill((NXWINDOW)htb, &cliprect, color);
|
||||
}
|
111
graphics/nxtk/nxtk_filltraptoolbar.c
Normal file
111
graphics/nxtk/nxtk_filltraptoolbar.c
Normal file
|
@ -0,0 +1,111 @@
|
|||
/****************************************************************************
|
||||
* graphics/nxtk/nxtk_filltraptoolbar.c
|
||||
*
|
||||
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* 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 <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/nx.h>
|
||||
#include <nuttx/nxtk.h>
|
||||
|
||||
#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:
|
||||
* htb - 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_filltraptoolbar(NXTKTOOLBAR htb, FAR const struct nxgl_trapezoid_s *trap,
|
||||
nxgl_mxpixel_t color[CONFIG_NX_NPLANES])
|
||||
{
|
||||
FAR struct nxtk_framedwindow_s *fwnd = (FAR struct nxtk_framedwindow_s *)htb;
|
||||
struct nxgl_rect_s relclip;
|
||||
|
||||
#ifdef CONFIG_DEBUG
|
||||
if (!htb || !trap || !color)
|
||||
{
|
||||
errno = EINVAL;
|
||||
return ERROR;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Perform the fill, clipping to the client window */
|
||||
|
||||
nxgl_rectoffset(&relclip, &fwnd->tbrect, -fwnd->wnd.origin.x, -fwnd->wnd.origin.y);
|
||||
return nx_filltrapezoid((NXWINDOW)htb, &relclip, trap, color);
|
||||
}
|
111
graphics/nxtk/nxtk_filltrapwindow.c
Normal file
111
graphics/nxtk/nxtk_filltrapwindow.c
Normal file
|
@ -0,0 +1,111 @@
|
|||
/****************************************************************************
|
||||
* graphics/nxtk/nxtk_filltrapwindow.c
|
||||
*
|
||||
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* 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 <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/nx.h>
|
||||
#include <nuttx/nxtk.h>
|
||||
|
||||
#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;
|
||||
|
||||
#ifdef CONFIG_DEBUG
|
||||
if (!hfwnd || !trap || !color)
|
||||
{
|
||||
errno = EINVAL;
|
||||
return ERROR;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Perform the fill, clipping to the client window */
|
||||
|
||||
nxgl_rectoffset(&relclip, &fwnd->fwrect, -fwnd->wnd.origin.x, -fwnd->wnd.origin.y);
|
||||
return nx_filltrapezoid((NXWINDOW)hfwnd, &relclip, trap, color);
|
||||
}
|
116
graphics/nxtk/nxtk_fillwindow.c
Normal file
116
graphics/nxtk/nxtk_fillwindow.c
Normal file
|
@ -0,0 +1,116 @@
|
|||
/****************************************************************************
|
||||
* graphics/nxtk/nxtk_fillwindow.c
|
||||
*
|
||||
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* 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 <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/nx.h>
|
||||
#include <nuttx/nxtk.h>
|
||||
|
||||
#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 relbounds;
|
||||
struct nxgl_rect_s cliprect;
|
||||
|
||||
#ifdef CONFIG_DEBUG
|
||||
if (!hfwnd || !rect || !color)
|
||||
{
|
||||
errno = EINVAL;
|
||||
return ERROR;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Clip the rectangle to lie within the client window region */
|
||||
|
||||
nxgl_rectoffset(&relbounds, &fwnd->fwrect, fwnd->fwrect.pt1.x, fwnd->fwrect.pt1.y);
|
||||
nxgl_rectintersect(&cliprect, rect, &relbounds);
|
||||
|
||||
/* Then fill it */
|
||||
|
||||
return nx_fill((NXWINDOW)hfwnd, &cliprect, color);
|
||||
}
|
96
graphics/nxtk/nxtk_getposition.c
Normal file
96
graphics/nxtk/nxtk_getposition.c
Normal file
|
@ -0,0 +1,96 @@
|
|||
/****************************************************************************
|
||||
* graphics/nxtk/nxtk_getposition.c
|
||||
*
|
||||
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* 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 <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/nx.h>
|
||||
#include <nuttx/nxtk.h>
|
||||
|
||||
#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);
|
||||
}
|
129
graphics/nxtk/nxtk_internal.h
Normal file
129
graphics/nxtk/nxtk_internal.h
Normal file
|
@ -0,0 +1,129 @@
|
|||
/****************************************************************************
|
||||
* graphics/nxtk/nxtk_internal.h
|
||||
*
|
||||
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* 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 <nuttx/config.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <nuttx/nxtk.h>
|
||||
#include "nxbe.h"
|
||||
#include "nxfe.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Configuration ************************************************************/
|
||||
|
||||
#ifndef CONFIG_NXTK_BORDERWIDTH
|
||||
# define CONFIG_NXTK_BORDERWIDTH 2
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_NXTK_BORDERCOLOR1
|
||||
# define CONFIG_NXTK_BORDERCOLOR1 0x00a9a9a9
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_NXTK_BORDERCOLOR2
|
||||
# define CONFIG_NXTK_BORDERCOLOR2 0x00696969
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* 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;
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* 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;
|
||||
|
||||
/****************************************************************************
|
||||
* 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);
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __GRAPHICS_NXTK_NXTK_INTERNAL_H */
|
129
graphics/nxtk/nxtk_opentoolbar.c
Normal file
129
graphics/nxtk/nxtk_opentoolbar.c
Normal file
|
@ -0,0 +1,129 @@
|
|||
/****************************************************************************
|
||||
* graphics/nxtk/nxtk_opentoolbar.c
|
||||
*
|
||||
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* 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 <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/nx.h>
|
||||
#include <nuttx/nxtk.h>
|
||||
|
||||
#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:
|
||||
* hwnd - 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:
|
||||
* Success: A non-NULL handle used with subsequent NXTK toolbar accesses
|
||||
* Failure: NULL is returned and errno is set appropriately
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
NXTKTOOLBAR nxtk_opentoolbar(NXTKWINDOW hwnd, 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 *)hwnd;
|
||||
|
||||
#ifdef CONFIG_DEBUG
|
||||
if (!hwnd || !cb)
|
||||
{
|
||||
errno = EINVAL;
|
||||
return NULL;
|
||||
}
|
||||
#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
|
||||
* redraw because it has changed its vertical position and size.
|
||||
*/
|
||||
|
||||
nxfe_redrawreq(&fwnd->wnd, &fwnd->wnd.bounds);
|
||||
|
||||
/* Return the initialized toolbar reference */
|
||||
|
||||
return (NXTKTOOLBAR)fwnd;
|
||||
}
|
||||
|
136
graphics/nxtk/nxtk_openwindow.c
Normal file
136
graphics/nxtk/nxtk_openwindow.c
Normal file
|
@ -0,0 +1,136 @@
|
|||
/****************************************************************************
|
||||
* graphics/nxtk/nxtk_openwindow.c
|
||||
*
|
||||
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* 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 <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/nx.h>
|
||||
|
||||
#include "nxfe.h"
|
||||
#include "nxtk_internal.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* 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 *)zalloc(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;
|
||||
}
|
||||
|
|
@ -1,246 +0,0 @@
|
|||
/****************************************************************************
|
||||
// * graphics/nxtk/nxtk_rawwindow.c
|
||||
*
|
||||
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* 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 <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/nx.h>
|
||||
#include <nuttx/nxtk.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
struct nxtk_rawwindow_s
|
||||
{
|
||||
struct nxtk_base_s base;
|
||||
NXHANDLE handle;
|
||||
NXWINDOW hwnd;
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxtk_close
|
||||
****************************************************************************/
|
||||
|
||||
static void nxtk_close(NXTWINDOW hwnd)
|
||||
{
|
||||
FAR struct nxtk_rawwindow_s *this = (FAR struct nxtk_rawwindow_s *)hwnd;
|
||||
nx_closewindow(this->hwnd);
|
||||
free(this);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxtk_getposition
|
||||
****************************************************************************/
|
||||
|
||||
static int nxtk_getposition(NXTWINDOW hwnd)
|
||||
{
|
||||
FAR struct nxtk_rawwindow_s *this = (FAR struct nxtk_rawwindow_s *)hwnd;
|
||||
return nx_getposition(this->hwnd);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxtk_setposition
|
||||
****************************************************************************/
|
||||
|
||||
static int nxtk_setposition(NXTWINDOW hwnd, FAR struct nxgl_point_s *pos)
|
||||
{
|
||||
FAR struct nxtk_rawwindow_s *this = (FAR struct nxtk_rawwindow_s *)hwnd;
|
||||
return nx_setposition(this->hwnd, pos);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxtk_setsize
|
||||
****************************************************************************/
|
||||
|
||||
static int nxtk_setsize(NXTWINDOW hwnd, FAR struct nxgl_rect_s *size)
|
||||
{
|
||||
FAR struct nxtk_rawwindow_s *this = (FAR struct nxtk_rawwindow_s *)hwnd;
|
||||
return nx_setsize(this->hwnd, size);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxtk_raise
|
||||
****************************************************************************/
|
||||
|
||||
static int nxtk_raise(NXTWINDOW hwnd)
|
||||
{
|
||||
FAR struct nxtk_rawwindow_s *this = (FAR struct nxtk_rawwindow_s *)hwnd;
|
||||
return nx_raise(this->hwnd);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxtk_lower
|
||||
****************************************************************************/
|
||||
|
||||
static int nxtk_lower(NXTWINDOW hwnd)
|
||||
{
|
||||
FAR struct nxtk_rawwindow_s *this = (FAR struct nxtk_rawwindow_s *)hwnd;
|
||||
return nx_lower(this->hwnd);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxtk_fill
|
||||
****************************************************************************/
|
||||
|
||||
static int nxtk_fill(NXTWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
|
||||
nxgl_mxpixel_t color[CONFIG_NX_NPLANES])
|
||||
{
|
||||
FAR struct nxtk_rawwindow_s *this = (FAR struct nxtk_rawwindow_s *)hwnd;
|
||||
return nx_fill(this->hwnd, rect, color);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxtk_filltrapezoid
|
||||
****************************************************************************/
|
||||
|
||||
static int nxtk_filltrapezoid(NXTWINDOW hwnd, FAR struct nxgl_trapezoid_s *trap,
|
||||
nxgl_mxpixel_t color[CONFIG_NX_NPLANES])
|
||||
{
|
||||
FAR struct nxtk_rawwindow_s *this = (FAR struct nxtk_rawwindow_s *)hwnd;
|
||||
return nx_filltrapezoid(this->hwnd, trap, color);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxtk_move
|
||||
****************************************************************************/
|
||||
|
||||
static int nxtk_move(NXTWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
|
||||
FAR const struct nxgl_point_s *offset)
|
||||
{
|
||||
FAR struct nxtk_rawwindow_s *this = (FAR struct nxtk_rawwindow_s *)hwnd;
|
||||
return nx_move(this->hwnd, rect, offset);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxtk_bitmap
|
||||
****************************************************************************/
|
||||
|
||||
static int nxtk_bitmap(NXTWINDOW 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)
|
||||
{
|
||||
FAR struct nxtk_rawwindow_s *this = (FAR struct nxtk_rawwindow_s *)hwnd;
|
||||
return nx_bitmap(this->hwnd, dest, src, origin, stride);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxtk_rawwindow
|
||||
*
|
||||
* Description:
|
||||
* This function is the constructor for a raw NXTWINDOW object.
|
||||
* This provides a one-to-one mapping with the window APIs in nx.h.
|
||||
*
|
||||
* Input Parameters:
|
||||
* handle - The handle returned by nx_connect or nx_open
|
||||
* cb - Callbacks used to process window events
|
||||
* arg - User provided value that will be returned with NX callbacks.
|
||||
*
|
||||
* Return:
|
||||
* Success: A non-NULL handle used with subsequent method calls
|
||||
* Failure: NULL is returned and errno is set appropriately
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
NXTWINDOW nxtk_rawwindow(NXHANDLE handle,
|
||||
FAR const struct nx_callback_s *cb,
|
||||
FAR void *arg)
|
||||
{
|
||||
FAR struct nxtk_rawwindow_s *this = malloc(sizeof(struct nxtk_rawwindow_s));
|
||||
|
||||
/* Pre-allocate this internal state structure so we won't don't have to
|
||||
* handle the failure to allocate later.
|
||||
*/
|
||||
|
||||
if (!this)
|
||||
{
|
||||
errno = ENOMEM;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Create the window */
|
||||
|
||||
this->hwnd = nx_openwindow(handle, cb, arg);
|
||||
if (!this->hwnd)
|
||||
{
|
||||
free(this);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Then initialize the rest of the object */
|
||||
|
||||
this->handle = handle;
|
||||
this->base.close = nxtk_close;
|
||||
this->base.getposition = nxtk_getposition;
|
||||
this->base.setposition = nxtk_setposition;
|
||||
this->base.setsize = nxtk_setsize;
|
||||
this->base.raise = nxtk_raise;
|
||||
this->base.lower = nxtk_lower;
|
||||
this->base.fill = nxtk_fill;
|
||||
this->base.filltrapezoid = nxtk_filltrapezoid;
|
||||
this->base.move = nxtk_move;
|
||||
this->base.bitmap = nxtk_bitmap;
|
||||
|
||||
return &this->base;
|
||||
}
|
108
graphics/nxtk/nxtk_setposition.c
Normal file
108
graphics/nxtk/nxtk_setposition.c
Normal file
|
@ -0,0 +1,108 @@
|
|||
/****************************************************************************
|
||||
* graphics/nxtk/tk_setposition.c
|
||||
*
|
||||
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* 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 <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/nx.h>
|
||||
#include <nuttx/nxtk.h>
|
||||
|
||||
#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 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.origin);
|
||||
|
||||
/* Then set that position */
|
||||
|
||||
return nx_setposition((NXWINDOW)hfwnd, &newpos);
|
||||
}
|
117
graphics/nxtk/nxtk_setsize.c
Normal file
117
graphics/nxtk/nxtk_setsize.c
Normal file
|
@ -0,0 +1,117 @@
|
|||
/****************************************************************************
|
||||
* graphics/nxtk/nxtk_setsize.c
|
||||
*
|
||||
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* 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 <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/nx.h>
|
||||
#include <nuttx/nxtk.h>
|
||||
|
||||
#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 struct nxgl_rect_s *size)
|
||||
{
|
||||
FAR struct nxtk_framedwindow_s *fwnd = (FAR struct nxtk_framedwindow_s *)hfwnd;
|
||||
struct nxgl_rect_s newsize;
|
||||
|
||||
#ifdef CONFIG_DEBUG
|
||||
if (!hfwnd || !size)
|
||||
{
|
||||
errno = EINVAL;
|
||||
return ERROR;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Add the sizes need for the toolbar and the borders */
|
||||
|
||||
newsize.pt1.x = 0;
|
||||
newsize.pt1.y = 0;
|
||||
newsize.pt2.x = size->pt2.x + 2 * CONFIG_NXTK_BORDERWIDTH;
|
||||
newsize.pt2.y = size->pt2.y + fwnd->tbheight + 2 * CONFIG_NXTK_BORDERWIDTH;
|
||||
|
||||
/* Then set the window size */
|
||||
|
||||
return nx_setsize((NXWINDOW)hfwnd, &newsize);
|
||||
}
|
161
graphics/nxtk/nxtk_setsubwindows.c
Normal file
161
graphics/nxtk/nxtk_setsubwindows.c
Normal file
|
@ -0,0 +1,161 @@
|
|||
/****************************************************************************
|
||||
* graphics/nxtk/nxtk_setsubwindows.c
|
||||
*
|
||||
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* 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 <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
#include <semaphore.h>
|
||||
#include <debug.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/nx.h>
|
||||
#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.origin.y;
|
||||
nxgl_coord_t tbheight = 0;
|
||||
nxgl_coord_t fwtop = fwnd->wnd.origin.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 */
|
||||
|
||||
tbtop += (bdrheight / 2);
|
||||
fwtop = tbtop;
|
||||
|
||||
/* 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;
|
||||
bdrwidth = ngl_min(2 * CONFIG_NXTK_BORDERWIDTH, fullwidth);
|
||||
fwwidth = fullwidth - bdrwidth;
|
||||
fwleft = fwnd->wnd.origin.x + bdrwidth/2;
|
||||
|
||||
/* Realize the positions/dimensions */
|
||||
|
||||
fwnd->tbrect.pt1.x = fwleft;
|
||||
fwnd->tbrect.pt1.y = tbtop;
|
||||
fwnd->tbrect.pt2.x = fwleft + fwwidth;
|
||||
fwnd->tbrect.pt2.y = tbtop + tbheight - 1;
|
||||
|
||||
fwnd->fwrect.pt1.x = fwleft;
|
||||
fwnd->fwrect.pt1.y = fwtop;
|
||||
fwnd->fwrect.pt2.x = fwleft + fwwidth;
|
||||
fwnd->fwrect.pt2.y = fwtop + fwheight - 1;
|
||||
}
|
|
@ -43,9 +43,7 @@
|
|||
#include <nuttx/config.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <nuttx/nxtk.h>
|
||||
#include "nxbe.h"
|
||||
#include "nxfe.h"
|
||||
#include <nuttx/nx.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor definitions
|
||||
|
@ -55,42 +53,13 @@
|
|||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/* This is an objects, implemented in C, that provides access to the NX
|
||||
* window APIs. Why would you use this object instead of direct calls to the
|
||||
* nx_ APIs? So that you can support polymorphism. (Doesn't this make you
|
||||
* really appreciate C++?). All of the APIs provided in the NX toolkit
|
||||
* export this interface.
|
||||
*
|
||||
* The methods provided in this call table are the nx_* window APIs discussed
|
||||
* in include/nx.h accessed through a vtable. See that header for description
|
||||
* of each method.
|
||||
*/
|
||||
/* This is the handle that can be used to access the window data region */
|
||||
|
||||
typedef FAR struct nxtk_base_s *NXTWINDOW;
|
||||
struct nxtk_base_s
|
||||
{
|
||||
/* Destructor */
|
||||
typedef FAR void *NXTKWINDOW;
|
||||
|
||||
void (*close)(NXTWINDOW hwnd);
|
||||
/* This is the handle that can be used to access the window toolbar */
|
||||
|
||||
/* Window methods (documented in include/nuttx/nx.h) */
|
||||
|
||||
int (*getposition)(NXTWINDOW hwnd);
|
||||
int (*setposition)(NXTWINDOW hwnd, FAR struct nxgl_point_s *pos);
|
||||
int (*setsize)(NXTWINDOW hwnd, FAR struct nxgl_rect_s *size);
|
||||
int (*raise)(NXTWINDOW hwnd);
|
||||
int (*lower)(NXTWINDOW hwnd);
|
||||
int (*fill)(NXTWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
|
||||
nxgl_mxpixel_t color[CONFIG_NX_NPLANES]);
|
||||
int (*filltrapezoid)(NXTWINDOW hwnd, FAR struct nxgl_trapezoid_s *trap,
|
||||
nxgl_mxpixel_t color[CONFIG_NX_NPLANES]);
|
||||
int (*move)(NXTWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
|
||||
FAR const struct nxgl_point_s *offset);
|
||||
int (*bitmap)(NXTWINDOW 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);
|
||||
};
|
||||
typedef FAR void *NXTKTOOLBAR;
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
|
@ -109,27 +78,174 @@ extern "C" {
|
|||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxtk_rawwindow
|
||||
* Name: nxtk_openwindow
|
||||
*
|
||||
* Description:
|
||||
* This function is the constructor for a raw NXTWINDOW object.
|
||||
* This provides a one-to-one mapping with the window APIs in nx.h.
|
||||
* Create a new, framed window.
|
||||
*
|
||||
* Input Parameters:
|
||||
* handle - The handle returned by nx_connect or nx_open
|
||||
* handle - The handle returned by nx_connect
|
||||
* cb - Callbacks used to process window events
|
||||
* arg - User provided value that will be returned with NX callbacks.
|
||||
* arg - User provided value that will be returned with NXTK callbacks.
|
||||
*
|
||||
* Return:
|
||||
* Success: A non-NULL handle used with subsequent method calls
|
||||
* Success: A non-NULL handle used with subsequent NXTK window accesses
|
||||
* Failure: NULL is returned and errno is set appropriately
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
EXTERN NXTWINDOW nxtk_rawwindow(NXHANDLE handle,
|
||||
FAR const struct nx_callback_s *cb,
|
||||
FAR void *arg);
|
||||
EXTERN NXTKWINDOW nxtk_openwindow(NXHANDLE handle,
|
||||
FAR const struct nx_callback_s *cb,
|
||||
FAR void *arg);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxtk_closewindow
|
||||
*
|
||||
* Description:
|
||||
* Close the window opened by nxtk_openwindow
|
||||
*
|
||||
* Input Parameters:
|
||||
* hfwnd - The handle returned by nxtk_openwindow
|
||||
*
|
||||
* Return:
|
||||
* Success: A non-NULL handle used with subsequent NXTK window accesses
|
||||
* Failure: NULL is returned and errno is set appropriately
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
EXTERN void nxtk_closewindow(NXTKWINDOW hfwnd);
|
||||
|
||||
/****************************************************************************
|
||||
* 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
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
EXTERN int nxtk_getposition(NXTKWINDOW hfwnd);
|
||||
|
||||
/****************************************************************************
|
||||
* 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
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
EXTERN int nxtk_setposition(NXTKWINDOW hfwnd, FAR struct nxgl_point_s *pos);
|
||||
|
||||
/****************************************************************************
|
||||
* 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
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
EXTERN int nxtk_setsize(NXTKWINDOW hfwnd, FAR struct nxgl_rect_s *size);
|
||||
|
||||
/****************************************************************************
|
||||
* 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
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
EXTERN int nxtk_fillwindow(NXTKWINDOW hfwnd, FAR const struct nxgl_rect_s *rect,
|
||||
nxgl_mxpixel_t color[CONFIG_NX_NPLANES]);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxtk_opentoolbar
|
||||
*
|
||||
* Description:
|
||||
* Create a tool bar at the top of the specified framed window
|
||||
*
|
||||
* Input Parameters:
|
||||
* hwnd - 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:
|
||||
* Success: A non-NULL handle used with subsequent NXTK toolbar accesses
|
||||
* Failure: NULL is returned and errno is set appropriately
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
EXTERN NXTKTOOLBAR nxtk_opentoolbar(NXTKWINDOW hwnd, nxgl_coord_t height,
|
||||
FAR const struct nx_callback_s *cb,
|
||||
FAR void *arg);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxtk_closetoolbar
|
||||
*
|
||||
* Description:
|
||||
* Create a tool bar at the top of the specified framed window
|
||||
*
|
||||
* Input Parameters:
|
||||
* htb - The toolbar handle returned by nxtk_opentoolbar
|
||||
*
|
||||
* Return:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
EXTERN void nxtk_closetoolbar(NXTKTOOLBAR htb);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxtk_filltoolbar
|
||||
*
|
||||
* Description:
|
||||
* Fill the specified rectangle in the client window with the specified color
|
||||
*
|
||||
* Input Parameters:
|
||||
* htb - The toolbar handle returned by nxtk_opentoolbar
|
||||
* 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
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
EXTERN int nxtk_filltoolbar(NXTKTOOLBAR htb, FAR const struct nxgl_rect_s *rect,
|
||||
nxgl_mxpixel_t color[CONFIG_NX_NPLANES]);
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue