mirror of
https://github.com/apache/nuttx.git
synced 2025-01-13 10:58:49 +08:00
Add nx_constructwindow
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1367 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
4f6ef2af8d
commit
538c321bfc
9 changed files with 391 additions and 50 deletions
|
@ -59,7 +59,7 @@
|
||||||
|
|
||||||
#ifndef CONFIG_EXAMPLES_NX_BGCOLOR
|
#ifndef CONFIG_EXAMPLES_NX_BGCOLOR
|
||||||
# if CONFIG_SIM_FBBPP == 24 || CONFIG_SIM_FBBPP == 32
|
# if CONFIG_SIM_FBBPP == 24 || CONFIG_SIM_FBBPP == 32
|
||||||
# define CONFIG_EXAMPLES_NX_BGCOLOR 0x00602020
|
# define CONFIG_EXAMPLES_NX_BGCOLOR 0x007b68ee
|
||||||
# elif CONFIG_SIM_FBBPP = 16
|
# elif CONFIG_SIM_FBBPP = 16
|
||||||
# define CONFIG_EXAMPLES_NX_BGCOLOR 0x3088
|
# define CONFIG_EXAMPLES_NX_BGCOLOR 0x3088
|
||||||
# else
|
# else
|
||||||
|
@ -69,7 +69,7 @@
|
||||||
|
|
||||||
#ifndef CONFIG_EXAMPLES_NX_COLOR1
|
#ifndef CONFIG_EXAMPLES_NX_COLOR1
|
||||||
# if CONFIG_SIM_FBBPP == 24 || CONFIG_SIM_FBBPP == 32
|
# if CONFIG_SIM_FBBPP == 24 || CONFIG_SIM_FBBPP == 32
|
||||||
# define CONFIG_EXAMPLES_NX_COLOR1 0x00606020
|
# define CONFIG_EXAMPLES_NX_COLOR1 0x00e6e6fa
|
||||||
# elif CONFIG_SIM_FBBPP = 16
|
# elif CONFIG_SIM_FBBPP = 16
|
||||||
# define CONFIG_EXAMPLES_NX_COLOR1 0x30c8
|
# define CONFIG_EXAMPLES_NX_COLOR1 0x30c8
|
||||||
# else
|
# else
|
||||||
|
@ -79,7 +79,7 @@
|
||||||
|
|
||||||
#ifndef CONFIG_EXAMPLES_NX_COLOR2
|
#ifndef CONFIG_EXAMPLES_NX_COLOR2
|
||||||
# if CONFIG_SIM_FBBPP == 24 || CONFIG_SIM_FBBPP == 32
|
# if CONFIG_SIM_FBBPP == 24 || CONFIG_SIM_FBBPP == 32
|
||||||
# define CONFIG_EXAMPLES_NX_COLOR2 0x00606060
|
# define CONFIG_EXAMPLES_NX_COLOR2 0x00dcdcdc
|
||||||
# elif CONFIG_SIM_FBBPP = 16
|
# elif CONFIG_SIM_FBBPP = 16
|
||||||
# define CONFIG_EXAMPLES_NX_COLOR2 0x30cc
|
# define CONFIG_EXAMPLES_NX_COLOR2 0x30cc
|
||||||
# else
|
# else
|
||||||
|
|
|
@ -40,7 +40,8 @@ NXAPI_CSRCS = nx_bitmap.c nx_closewindow.c nx_connect.c nx_disconnect.c \
|
||||||
nx_mousein.c nx_move.c nx_openwindow.c nx_raise.c \
|
nx_mousein.c nx_move.c nx_openwindow.c nx_raise.c \
|
||||||
nx_releasebkgd.c nx_requestbkgd.c nx_setsize.c \
|
nx_releasebkgd.c nx_requestbkgd.c nx_setsize.c \
|
||||||
nx_setbgcolor.c nx_setposition.c
|
nx_setbgcolor.c nx_setposition.c
|
||||||
NXMU_CSRCS = nxmu_kbdin.c nxmu_mouse.c nxmu_openwindow.c nxmu_redrawreq.c \
|
NXMU_CSRCS = nxmu_constructwindow.c nxmu_kbdin.c nxmu_mouse.c \
|
||||||
nxmu_releasebkgd.c nxmu_requestbkgd.c nxmu_reportposition.c \
|
nxmu_openwindow.c nxmu_redrawreq.c nxmu_releasebkgd.c \
|
||||||
nxmu_semtake.c nxmu_server.c
|
nxmu_requestbkgd.c nxmu_reportposition.c nxmu_semtake.c \
|
||||||
|
nxmu_server.c
|
||||||
NX_CSRCS = $(NXAPI_CSRCS) $(NXMU_CSRCS)
|
NX_CSRCS = $(NXAPI_CSRCS) $(NXMU_CSRCS)
|
||||||
|
|
|
@ -80,6 +80,7 @@
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* handle - The handle returned by nx_connect
|
* handle - The handle returned by nx_connect
|
||||||
* cb - Callbacks used to process windo events
|
* cb - Callbacks used to process windo events
|
||||||
|
* arg - User provided value that will be returned with NX callbacks.
|
||||||
*
|
*
|
||||||
* Return:
|
* Return:
|
||||||
* Success: A non-NULL handle used with subsequent NX accesses
|
* Success: A non-NULL handle used with subsequent NX accesses
|
||||||
|
@ -87,11 +88,10 @@
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
NXWINDOW nx_openwindow(NXHANDLE handle, FAR const struct nx_callback_s *cb)
|
NXWINDOW nx_openwindow(NXHANDLE handle, FAR const struct nx_callback_s *cb,
|
||||||
|
FAR void *arg)
|
||||||
{
|
{
|
||||||
FAR struct nxfe_conn_s *conn = (FAR struct nxfe_conn_s *)handle;
|
|
||||||
FAR struct nxbe_window_s *wnd;
|
FAR struct nxbe_window_s *wnd;
|
||||||
struct nxsvrmsg_openwindow_s outmsg;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
#ifdef CONFIG_DEBUG
|
#ifdef CONFIG_DEBUG
|
||||||
|
@ -111,23 +111,13 @@ NXWINDOW nx_openwindow(NXHANDLE handle, FAR const struct nx_callback_s *cb)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Setup only the connection structure. We'll need this to communicate with
|
/* Then let nxfe_constructwindow do the rest */
|
||||||
* the server. The server will set everything else up.
|
|
||||||
*/
|
|
||||||
|
|
||||||
wnd->conn = conn;
|
ret = nxfe_constructwindow(handle, wnd, cb, arg);
|
||||||
wnd->cb = cb;
|
|
||||||
|
|
||||||
/* Request initialization the new window from the server */
|
|
||||||
|
|
||||||
outmsg.msgid = NX_SVRMSG_OPENWINDOW;
|
|
||||||
outmsg.wnd = wnd;
|
|
||||||
|
|
||||||
ret = mq_send(conn->cwrmq, &outmsg, sizeof(struct nxsvrmsg_openwindow_s), NX_SVRMSG_PRIO);
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
gdbg("mq_send failed: %d\n", errno);
|
/* An error occurred, the window has been freed */
|
||||||
free(wnd);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -427,6 +427,39 @@ extern "C" {
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: nxfe_constructwindow
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* This function is the same a nx_openwindow EXCEPT that the client provides
|
||||||
|
* the window structure instance. nx_constructwindow will initialize the
|
||||||
|
* the pre-allocated window structure for use by NX. This function is
|
||||||
|
* provided in addition to nx_open window in order to support a kind of
|
||||||
|
* inheritance: The caller's window structure may include extensions that
|
||||||
|
* are not visible to NX.
|
||||||
|
*
|
||||||
|
* NOTE: wnd must have been allocated using malloc() (or related allocators)
|
||||||
|
* Once provided to nxfe_constructwindow() that memory is owned and managed
|
||||||
|
* by NX. On certain error conditions or when the window is closed, NX will
|
||||||
|
* free() the the window.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* handle - The handle returned by nx_connect
|
||||||
|
* wnd - The pre-allocated window structure.
|
||||||
|
* cb - Callbacks used to process window events
|
||||||
|
* arg - User provided value that will be returned with NX callbacks.
|
||||||
|
*
|
||||||
|
* Return:
|
||||||
|
* OK on success; ERROR on failure with errno set appropriately. In the
|
||||||
|
* case of ERROR, NX will have dealloated the pre-allocated window.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
EXTERN int nxfe_constructwindow(NXHANDLE handle,
|
||||||
|
FAR struct nxbe_window_s *wnd,
|
||||||
|
FAR const struct nx_callback_s *cb,
|
||||||
|
FAR void *arg);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: nxmu_semtake
|
* Name: nxmu_semtake
|
||||||
*
|
*
|
||||||
|
|
147
graphics/nxmu/nxmu_constructwindow.c
Normal file
147
graphics/nxmu/nxmu_constructwindow.c
Normal file
|
@ -0,0 +1,147 @@
|
||||||
|
/****************************************************************************
|
||||||
|
* graphics/nxmu/nx_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"
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Pre-Processor Definitions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Types
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Data
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Data
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: nxfe_constructwindow
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* This function is the same a nx_openwindow EXCEPT that the client provides
|
||||||
|
* the window structure instance. nx_constructwindow will initialize the
|
||||||
|
* the pre-allocated window structure for use by NX. This function is
|
||||||
|
* provided in addition to nx_open window in order to support a kind of
|
||||||
|
* inheritance: The caller's window structure may include extensions that
|
||||||
|
* are not visible to NX.
|
||||||
|
*
|
||||||
|
* NOTE: wnd must have been allocated using malloc() (or related allocators)
|
||||||
|
* Once provided to nxfe_constructwindow() that memory is owned and managed
|
||||||
|
* by NX. On certain error conditions or when the window is closed, NX will
|
||||||
|
* free() the the window.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* handle - The handle returned by nx_connect
|
||||||
|
* wnd - The pre-allocated window structure.
|
||||||
|
* cb - Callbacks used to process window events
|
||||||
|
* arg - User provided value that will be returned with NX callbacks.
|
||||||
|
*
|
||||||
|
* Return:
|
||||||
|
* OK on success; ERROR on failure with errno set appropriately. In the
|
||||||
|
* case of ERROR, NX will have dealloated the pre-allocated window.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int nxfe_constructwindow(NXHANDLE handle, FAR struct nxbe_window_s *wnd,
|
||||||
|
FAR const struct nx_callback_s *cb, FAR void *arg)
|
||||||
|
{
|
||||||
|
FAR struct nxfe_conn_s *conn = (FAR struct nxfe_conn_s *)handle;
|
||||||
|
struct nxsvrmsg_openwindow_s outmsg;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
#ifdef CONFIG_DEBUG
|
||||||
|
if (!wnd)
|
||||||
|
{
|
||||||
|
errno = EINVAL;
|
||||||
|
return ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!conn || !cb)
|
||||||
|
{
|
||||||
|
free(wnd);
|
||||||
|
errno = EINVAL;
|
||||||
|
return ERROR;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Setup only the connection structure, callbacks and client private data
|
||||||
|
* reference. The server will set everything else up.
|
||||||
|
*/
|
||||||
|
|
||||||
|
wnd->conn = conn;
|
||||||
|
wnd->cb = cb;
|
||||||
|
wnd->arg = arg;
|
||||||
|
|
||||||
|
/* Request initialization the new window from the server */
|
||||||
|
|
||||||
|
outmsg.msgid = NX_SVRMSG_OPENWINDOW;
|
||||||
|
outmsg.wnd = wnd;
|
||||||
|
|
||||||
|
ret = mq_send(conn->cwrmq, &outmsg, sizeof(struct nxsvrmsg_openwindow_s), NX_SVRMSG_PRIO);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
gdbg("mq_send failed: %d\n", errno);
|
||||||
|
free(wnd);
|
||||||
|
return ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
|
@ -39,5 +39,5 @@ NXAPI_CSRCS = nx_bitmap.c nx_close.c nx_closewindow.c nx_fill.c \
|
||||||
nx_kbdin.c nx_lower.c nx_mousein.c nx_move.c nx_open.c \
|
nx_kbdin.c nx_lower.c nx_mousein.c nx_move.c nx_open.c \
|
||||||
nx_openwindow.c nx_raise.c nx_releasebkgd.c nx_requestbkgd.c \
|
nx_openwindow.c nx_raise.c nx_releasebkgd.c nx_requestbkgd.c \
|
||||||
nx_setsize.c nx_setbgcolor.c nx_setposition.c
|
nx_setsize.c nx_setbgcolor.c nx_setposition.c
|
||||||
NXSU_CSRCS = nxsu_redrawreq.c nxsu_reportposition.c
|
NXSU_CSRCS = nxsu_constructwindow.c nxsu_redrawreq.c nxsu_reportposition.c
|
||||||
NX_CSRCS = $(NXAPI_CSRCS) $(NXSU_CSRCS)
|
NX_CSRCS = $(NXAPI_CSRCS) $(NXSU_CSRCS)
|
||||||
|
|
|
@ -80,6 +80,7 @@
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* handle - The handle returned by nx_connect
|
* handle - The handle returned by nx_connect
|
||||||
* cb - Callbacks used to process windo events
|
* cb - Callbacks used to process windo events
|
||||||
|
* arg - User provided value that will be returned with NX callbacks.
|
||||||
*
|
*
|
||||||
* Return:
|
* Return:
|
||||||
* Success: A non-NULL handle used with subsequent NX accesses
|
* Success: A non-NULL handle used with subsequent NX accesses
|
||||||
|
@ -87,14 +88,14 @@
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
NXWINDOW nx_openwindow(NXHANDLE handle, FAR const struct nx_callback_s *cb)
|
NXWINDOW nx_openwindow(NXHANDLE handle, FAR const struct nx_callback_s *cb,
|
||||||
|
FAR void *arg)
|
||||||
{
|
{
|
||||||
FAR struct nxfe_state_s *fe = (FAR struct nxfe_state_s *)handle;
|
|
||||||
FAR struct nxbe_state_s *be = &fe->be;
|
|
||||||
FAR struct nxbe_window_s *wnd;
|
FAR struct nxbe_window_s *wnd;
|
||||||
|
int ret;
|
||||||
|
|
||||||
#ifdef CONFIG_DEBUG
|
#ifdef CONFIG_DEBUG
|
||||||
if (!fe || !cb)
|
if (!handle || !cb)
|
||||||
{
|
{
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -110,30 +111,15 @@ NXWINDOW nx_openwindow(NXHANDLE handle, FAR const struct nx_callback_s *cb)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize the window structure */
|
/* Then let nxfe_constructwindow do the rest */
|
||||||
|
|
||||||
wnd->be = be;
|
ret = nxfe_constructwindow(handle, wnd, cb, arg);
|
||||||
wnd->cb = cb;
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
/* An error occurred, the window has been freed */
|
||||||
|
|
||||||
/* Insert the new window at the top on the display. topwind is
|
return NULL;
|
||||||
* never NULL (it may point only at the background window, however)
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
wnd->above = NULL;
|
|
||||||
wnd->below = be->topwnd;
|
|
||||||
|
|
||||||
be->topwnd->above = wnd;
|
|
||||||
be->topwnd = wnd;
|
|
||||||
|
|
||||||
/* Report the initialize size/position of the window */
|
|
||||||
|
|
||||||
nxfe_reportposition((NXWINDOW)wnd);
|
|
||||||
|
|
||||||
/* Provide the initial mouse settings */
|
|
||||||
|
|
||||||
#ifdef CONFIG_NX_MOUSE
|
|
||||||
nxsu_mousereport(wnd);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Return the initialized window reference */
|
/* Return the initialized window reference */
|
||||||
|
|
||||||
|
|
|
@ -94,6 +94,39 @@ EXTERN const struct nx_callback_s g_bkgdcb;
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: nxfe_constructwindow
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* This function is the same a nx_openwindow EXCEPT that the client provides
|
||||||
|
* the window structure instance. nx_constructwindow will initialize the
|
||||||
|
* the pre-allocated window structure for use by NX. This function is
|
||||||
|
* provided in addition to nx_open window in order to support a kind of
|
||||||
|
* inheritance: The caller's window structure may include extensions that
|
||||||
|
* are not visible to NX.
|
||||||
|
*
|
||||||
|
* NOTE: wnd must have been allocated using malloc() (or related allocators)
|
||||||
|
* Once provided to nxfe_constructwindow() that memory is owned and managed
|
||||||
|
* by NX. On certain error conditions or when the window is closed, NX will
|
||||||
|
* free() the the window.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* handle - The handle returned by nx_connect
|
||||||
|
* wnd - The pre-allocated window structure.
|
||||||
|
* cb - Callbacks used to process window events
|
||||||
|
* arg - User provided value that will be returned with NX callbacks.
|
||||||
|
*
|
||||||
|
* Return:
|
||||||
|
* OK on success; ERROR on failure with errno set appropriately. In the
|
||||||
|
* case of ERROR, NX will have dealloated the pre-allocated window.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
EXTERN int nxfe_constructwindow(NXHANDLE handle,
|
||||||
|
FAR struct nxbe_window_s *wnd,
|
||||||
|
FAR const struct nx_callback_s *cb,
|
||||||
|
FAR void *arg);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: nxfe_redrawreq
|
* Name: nxfe_redrawreq
|
||||||
*
|
*
|
||||||
|
|
151
graphics/nxsu/nxsu_constructwindow.c
Normal file
151
graphics/nxsu/nxsu_constructwindow.c
Normal file
|
@ -0,0 +1,151 @@
|
||||||
|
/****************************************************************************
|
||||||
|
* graphics/nxsu/nx_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"
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Pre-Processor Definitions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Types
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Data
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Data
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: nxfe_constructwindow
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* This function is the same a nx_openwindow EXCEPT that the client provides
|
||||||
|
* the window structure instance. nx_constructwindow will initialize the
|
||||||
|
* the pre-allocated window structure for use by NX. This function is
|
||||||
|
* provided in addition to nx_open window in order to support a kind of
|
||||||
|
* inheritance: The caller's window structure may include extensions that
|
||||||
|
* are not visible to NX.
|
||||||
|
*
|
||||||
|
* NOTE: wnd must have been allocated using malloc() (or related allocators)
|
||||||
|
* Once provided to nxfe_constructwindow() that memory is owned and managed
|
||||||
|
* by NX. On certain error conditions or when the window is closed, NX will
|
||||||
|
* free() the the window.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* handle - The handle returned by nx_connect
|
||||||
|
* wnd - The pre-allocated window structure.
|
||||||
|
* cb - Callbacks used to process window events
|
||||||
|
* arg - User provided value that will be returned with NX callbacks.
|
||||||
|
*
|
||||||
|
* Return:
|
||||||
|
* OK on success; ERROR on failure with errno set appropriately. In the
|
||||||
|
* case of ERROR, NX will have dealloated the pre-allocated window.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int nxfe_constructwindow(NXHANDLE handle, FAR struct nxbe_window_s *wnd,
|
||||||
|
FAR const struct nx_callback_s *cb, FAR void *arg)
|
||||||
|
{
|
||||||
|
FAR struct nxfe_state_s *fe = (FAR struct nxfe_state_s *)handle;
|
||||||
|
FAR struct nxbe_state_s *be = &fe->be;
|
||||||
|
|
||||||
|
#ifdef CONFIG_DEBUG
|
||||||
|
if (!wnd)
|
||||||
|
{
|
||||||
|
errno = EINVAL;
|
||||||
|
return ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!fe || !cb)
|
||||||
|
{
|
||||||
|
free(wnd);
|
||||||
|
errno = EINVAL;
|
||||||
|
return ERROR;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Initialize the window structure */
|
||||||
|
|
||||||
|
wnd->be = be;
|
||||||
|
wnd->cb = cb;
|
||||||
|
wnd->arg = arg;
|
||||||
|
|
||||||
|
/* Insert the new window at the top on the display. topwind is
|
||||||
|
* never NULL (it may point only at the background window, however)
|
||||||
|
*/
|
||||||
|
|
||||||
|
wnd->above = NULL;
|
||||||
|
wnd->below = be->topwnd;
|
||||||
|
|
||||||
|
be->topwnd->above = wnd;
|
||||||
|
be->topwnd = wnd;
|
||||||
|
|
||||||
|
/* Report the initialize size/position of the window */
|
||||||
|
|
||||||
|
nxfe_reportposition((NXWINDOW)wnd);
|
||||||
|
|
||||||
|
/* Provide the initial mouse settings */
|
||||||
|
|
||||||
|
#ifdef CONFIG_NX_MOUSE
|
||||||
|
nxsu_mousereport(wnd);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue