示例#1
0
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;
}
示例#2
0
NXWINDOW nx_openwindow(NXHANDLE handle, FAR const struct nx_callback_s *cb,
                       FAR void *arg)
{
  FAR struct nxbe_window_s *wnd;
  int ret;

#ifdef CONFIG_DEBUG
  if (!handle || !cb)
    {
      errno = EINVAL;
      return NULL;
    }
#endif

  /* Pre-allocate the window structure */

  wnd = (FAR struct nxbe_window_s *)kzalloc(sizeof(struct nxbe_window_s));
  if (!wnd)
    {
      errno = ENOMEM;
      return NULL;
    }

  /* Then let nxfe_constructwindow do the rest */

  ret = nxfe_constructwindow(handle, wnd, cb, arg);
  if (ret < 0)
    {
      /* An error occurred, the window has been freed */

      return NULL;
    }

  /* Return the uninitialized window reference.  Since the server
   * serializes all operations, we can be assured that the window will
   * be initialized before the first operation on the window.
   */

  return (NXWINDOW)wnd;
}