static void nxtk_mousein(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos, uint8_t buttons, FAR void *arg) { FAR struct nxtk_framedwindow_s *fwnd = (FAR struct nxtk_framedwindow_s *)hwnd; struct nxgl_point_s abspos; struct nxgl_point_s relpos; /* Raise the window to the top if any mouse button was pressed or if auto-raise * is configured. Do this before reporting the mouse event (because processing * of the mouse event could change the ordering again). */ /* REVISIT: This does not work correctly. In a scenario where (1) there are * multiple queued touchscreen events and (2) the result of the first input * was to switch windows, then this autoraise implementation will cause the * window to revert to the previous window. Not good behavior. */ #ifndef CONFIG_NX_MULTIUSER /* Queuing only happens in multi-user mode */ #ifdef CONFIG_NXTK_AUTORAISE if (fwnd->wnd.above != NULL) #else if (buttons != 0 && fwnd->wnd.above != NULL) #endif { nx_raise((NXWINDOW)&fwnd->wnd); } #endif /* When we get here, the mouse position that we receive has already been * offset by the window origin. Here we need to detect mouse events in * the various regions of the windows: The toolbar, the client window, * or the frame. And then offset the position accordingly. */ /* The fwrect and tbrect boxes are both in absolute display coordinates. So * the easiest thing to do is to restore the mouse position to absolute * display coordiantes before making the comparisons and adjustments. */ nxgl_vectoradd(&abspos, pos, &fwnd->wnd.bounds.pt1); /* Is the mouse position inside of the client window region? */ if (fwnd->fwcb->mousein && nxgl_rectinside(&fwnd->fwrect, &abspos)) { nxgl_vectsubtract(&relpos, &abspos, &fwnd->fwrect.pt1); fwnd->fwcb->mousein((NXTKWINDOW)fwnd, &relpos, buttons, fwnd->fwarg); } /* If the mouse position inside the toobar region? */ else if (fwnd->tbcb->mousein && nxgl_rectinside(&fwnd->tbrect, &abspos)) { nxgl_vectsubtract(&relpos, &abspos, &fwnd->tbrect.pt1); fwnd->tbcb->mousein((NXTKWINDOW)fwnd, &relpos, buttons, fwnd->tbarg); } }
void nxbe_setpixel(FAR struct nxbe_window_s *wnd, FAR const struct nxgl_point_s *pos, nxgl_mxpixel_t color[CONFIG_NX_NPLANES]) { struct nxbe_setpixel_s info; struct nxgl_rect_s rect; int i; #ifdef CONFIG_DEBUG if (!wnd || !pos) { return; } #endif /* Offset the position by the window origin */ nxgl_vectoradd(&rect.pt1, pos, &wnd->bounds.pt1); /* Make sure that the point is within the limits of the window * and of the background screen */ if (!nxgl_rectinside(&wnd->bounds, &rect.pt1) || !nxgl_rectinside(&wnd->be->bkgd.bounds, &rect.pt1)) { return; } /* Then create a bounding box and render the point if there it * is exposed. */ rect.pt2.x = rect.pt1.x; rect.pt2.y = rect.pt1.y; #if CONFIG_NX_NPLANES > 1 for (i = 0; i < wnd->be->vinfo.nplanes; i++) #else i = 0; #endif { info.cops.visible = nxbe_clipfill; info.cops.obscured = nxbe_clipnull; info.color = color[i]; nxbe_clipper(wnd->above, &rect, NX_CLIPORDER_DEFAULT, &info.cops, &wnd->be->plane[i]); } }
int nxtk_setposition(NXTKWINDOW hfwnd, FAR const struct nxgl_point_s *pos) { FAR struct nxtk_framedwindow_s *fwnd = (FAR struct nxtk_framedwindow_s *)hfwnd; struct nxgl_point_s offset; struct nxgl_point_s newpos; /* Calculate the offset that is requested and add that to the window origin. */ nxgl_vectsubtract(&offset, pos, &fwnd->fwrect.pt1); nxgl_vectoradd(&newpos, &offset, &fwnd->wnd.bounds.pt1); /* Then set that position */ return nx_setposition((NXWINDOW)hfwnd, &newpos); }
int nxtk_bitmapwindow(NXTKWINDOW hfwnd, FAR const struct nxgl_rect_s *dest, FAR const void **src, FAR const struct nxgl_point_s *origin, unsigned int stride) { FAR struct nxtk_framedwindow_s *fwnd = (FAR struct nxtk_framedwindow_s *)hfwnd; struct nxgl_point_s wndorigin; struct nxgl_rect_s clipdest; #ifdef CONFIG_DEBUG_FEATURES if (!hfwnd || !dest || !src || !origin) { set_errno(EINVAL); return ERROR; } #endif /* Clip the rectangle so that it lies within the sub-window bounds * then move the rectangle to that it is relative to the containing * window. */ nxtk_subwindowclip(fwnd, &clipdest, dest, &fwnd->fwrect); /* Now, move the bitmap origin so that it is relative to the containing * window, not the sub-window. * * Temporarily, position the origin in absolute screen coordinates */ nxgl_vectoradd(&wndorigin, origin, &fwnd->fwrect.pt1); /* Then move the origin so that is relative to the containing window, not the * client subwindow */ nxgl_vectsubtract(&wndorigin, &wndorigin, &fwnd->wnd.bounds.pt1); /* Then copy the bitmap */ nx_bitmap((NXWINDOW)hfwnd, &clipdest, src, &wndorigin, stride); return OK; }