summaryrefslogtreecommitdiff
path: root/apps/examples/nxtext/nxtext_bkgd.c
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-07-08 20:55:49 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-07-08 20:55:49 +0000
commit825cac5ffae86dae959e3c378706e94c670d08c8 (patch)
treea98fd79f94e2ffc19113e8ae8786337cbb34df6c /apps/examples/nxtext/nxtext_bkgd.c
parent487bc7ed3b401ffd54ae3988368c92fe7551d9b1 (diff)
downloadnuttx-825cac5ffae86dae959e3c378706e94c670d08c8.tar.gz
nuttx-825cac5ffae86dae959e3c378706e94c670d08c8.tar.bz2
nuttx-825cac5ffae86dae959e3c378706e94c670d08c8.zip
Fix some NXTEXT pop-up window issues
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3757 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'apps/examples/nxtext/nxtext_bkgd.c')
-rw-r--r--apps/examples/nxtext/nxtext_bkgd.c79
1 files changed, 30 insertions, 49 deletions
diff --git a/apps/examples/nxtext/nxtext_bkgd.c b/apps/examples/nxtext/nxtext_bkgd.c
index 4daed7b84..ee6640bcc 100644
--- a/apps/examples/nxtext/nxtext_bkgd.c
+++ b/apps/examples/nxtext/nxtext_bkgd.c
@@ -116,48 +116,17 @@ NXHANDLE g_bgwnd;
****************************************************************************/
/****************************************************************************
- * Name: nxbg_fillwindow
- ****************************************************************************/
-
-static inline void nxbg_fillwindow(NXWINDOW hwnd,
- FAR const struct nxgl_rect_s *rect,
- FAR struct nxtext_state_s *st)
-{
- int ret;
- int i;
-
- ret = nx_fill(hwnd, rect, st->wcolor);
- if (ret < 0)
- {
- message("nxbg_fillwindow: nx_fill failed: %d\n", errno);
- }
-
- /* Fill each character on the display (Only the characters within rect
- * will actually be redrawn).
- */
-
-#ifdef CONFIG_NX_KBD
- nxtext_home(st);
- for (i = 0; i < st->nchars; i++)
- {
- nxtext_fillchar(hwnd, rect, &st->bm[i]);
- }
-#endif
-}
-
-/****************************************************************************
* Name: nxbg_redraw
****************************************************************************/
static void nxbg_redraw(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
bool more, FAR void *arg)
{
- FAR struct nxtext_state_s *st = (FAR struct nxtext_state_s *)arg;
message("nxbg_redraw: hwnd=%p rect={(%d,%d),(%d,%d)} more=%s\n",
hwnd, rect->pt1.x, rect->pt1.y, rect->pt2.x, rect->pt2.y,
more ? "true" : "false");
- nxbg_fillwindow(hwnd, rect, st);
+ nxbg_redrawrect(hwnd, rect);
}
/****************************************************************************
@@ -233,6 +202,7 @@ static void nxbg_kbdin(NXWINDOW hwnd, uint8_t nch, FAR const uint8_t *ch,
static void nxbg_scroll(NXWINDOW hwnd, int lineheight)
{
+ struct nxgl_rect_s rect;
int i;
int j;
@@ -240,7 +210,7 @@ static void nxbg_scroll(NXWINDOW hwnd, int lineheight)
* do this more than once (unlikely)
*/
- while (g_bgstate.pos.y >= g_bgstate.wsize.h - lineheight)
+ while (g_bgstate.fpos.y >= g_bgstate.wsize.h - lineheight)
{
/* Adjust the vertical position of each character */
@@ -283,12 +253,16 @@ static void nxbg_scroll(NXWINDOW hwnd, int lineheight)
/* And move the next display position up by one line as well */
- g_bgstate.pos.y -= lineheight;
+ g_bgstate.fpos.y -= lineheight;
}
/* Then re-draw the entire display */
- nxbg_refresh(hwnd);
+ rect.pt1.x = 0;
+ rect.pt1.y = 0;
+ rect.pt2.x = g_bgstate.wsize.w - 1;
+ rect.pt2.y = g_bgstate.wsize.h - 1;
+ nxbg_redrawrect(hwnd, &rect);
}
/****************************************************************************
@@ -351,7 +325,7 @@ void nxbg_write(NXWINDOW hwnd, FAR const uint8_t *buffer, size_t buflen)
{
/* Will another character fit on this line? */
- if (g_bgstate.pos.x + g_bgstate.fwidth > g_bgstate.wsize.w)
+ if (g_bgstate.fpos.x + g_bgstate.fwidth > g_bgstate.wsize.w)
{
/* No.. move to the next line */
@@ -368,7 +342,7 @@ void nxbg_write(NXWINDOW hwnd, FAR const uint8_t *buffer, size_t buflen)
/* Check if we need to scroll up */
- if (g_bgstate.pos.y >= g_bgstate.wsize.h - lineheight)
+ if (g_bgstate.fpos.y >= g_bgstate.wsize.h - lineheight)
{
nxbg_scroll(hwnd, lineheight);
}
@@ -380,22 +354,29 @@ void nxbg_write(NXWINDOW hwnd, FAR const uint8_t *buffer, size_t buflen)
}
/****************************************************************************
- * Name: nxbg_refresh
- *
- * Description:
- * Re-draw the entire background.
- *
+ * Name: nxbg_redrawrect
****************************************************************************/
-void nxbg_refresh(NXWINDOW hwnd)
+void nxbg_redrawrect(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect)
{
- struct nxgl_rect_s rect;
+ int ret;
+ int i;
- rect.pt1.x = 0;
- rect.pt1.y = 0;
- rect.pt2.x = g_bgstate.wsize.w - 1;
- rect.pt2.y = g_bgstate.wsize.h - 1;
- nxbg_fillwindow(hwnd, &rect, &g_bgstate);
+ ret = nx_fill(hwnd, rect, g_bgstate.wcolor);
+ if (ret < 0)
+ {
+ message("nxbg_redrawrect: nx_fill failed: %d\n", errno);
+ }
+
+ /* Fill each character on the display (Only the characters within rect
+ * will actually be redrawn).
+ */
+
+ nxtext_home(&g_bgstate);
+ for (i = 0; i < g_bgstate.nchars; i++)
+ {
+ nxtext_fillchar(hwnd, rect, &g_bgstate.bm[i]);
+ }
}