--- np2/embed/menubase/menudlg.c 2003/11/21 09:28:02 1.2 +++ np2/embed/menubase/menudlg.c 2004/06/28 12:31:32 1.5 @@ -39,10 +39,10 @@ typedef struct { short minval; short maxval; int pos; - BYTE type; - BYTE moving; - BYTE sldh; - BYTE sldv; + UINT8 type; + UINT8 moving; + UINT8 sldh; + UINT8 sldv; } DLGSLD; typedef struct { @@ -104,6 +104,7 @@ static BOOL seaprmempty(void *vpItem, vo ((DLGPRM)vpItem)->icon = NULL; return(TRUE); } + (void)vpArg; return(FALSE); } @@ -122,7 +123,7 @@ static DLGPRM resappend(MENUDLG dlg, con prm->icon = NULL; prm->str[0] = '\0'; if (str) { - milstr_ncpy(prm->str, str, sizeof(prm->str)); + milsjis_ncpy(prm->str, str, sizeof(prm->str)); } } return(prm); @@ -155,7 +156,6 @@ static DLGPRM ressea(DLGHDL hdl, int pos return(NULL); } - static BOOL dsbyid(void *vpItem, void *vpArg) { if (((DLGHDL)vpItem)->id == (MENUID)(unsigned long)vpArg) { @@ -164,7 +164,6 @@ static BOOL dsbyid(void *vpItem, void *v return(FALSE); } - static DLGHDL dlghdlsea(MENUDLG dlg, MENUID id) { return((DLGHDL)listarray_enum(dlg->dlg, dsbyid, (void *)(long)id)); @@ -380,14 +379,12 @@ static void dlgclose_move(MENUDLG dlg, D } -static void dlgclose_rel(MENUDLG dlg, DLGHDL hdl, int x, int y, int focus) { +static void dlgclose_rel(MENUDLG dlg, DLGHDL hdl, int focus) { if (focus) { dlg->proc(DLGMSG_CLOSE, 0, 0); } (void)hdl; - (void)x; - (void)y; } @@ -427,7 +424,6 @@ static void dlgbtn_onclick(MENUDLG dlg, (void)y; } - static void dlgbtn_move(MENUDLG dlg, DLGHDL hdl, int x, int y, int focus) { if (hdl->val != focus) { @@ -438,16 +434,15 @@ static void dlgbtn_move(MENUDLG dlg, DLG (void)y; } +static void dlgbtn_rel(MENUDLG dlg, DLGHDL hdl, int focus) { -static void dlgbtn_rel(MENUDLG dlg, DLGHDL hdl, int x, int y, int focus) { - - if (focus) { + if (hdl->val != 0) { hdl->val = 0; drawctrls(dlg, hdl); + } + if (focus) { dlg->proc(DLGMSG_COMMAND, hdl->id, 0); } - (void)x; - (void)y; } @@ -475,7 +470,6 @@ static void dlglist_reset(MENUDLG dlg, D DLGPRM next; vram_filldat(hdl->vram, NULL, 0xffffff); - dp = hdl->prm; while(dp) { next = dp->next; @@ -731,36 +725,66 @@ static BOOL dlglist_setex(MENUDLG dlg, D } resattachicon(dlg, dp, arg->icon, hdl->c.dl.fontsize, hdl->c.dl.fontsize); - milstr_ncpy(dp->str, arg->str, sizeof(dp->str)); + milsjis_ncpy(dp->str, arg->str, sizeof(dp->str)); return(dlglist_drawsub(hdl, arg->pos, (arg->pos == hdl->val))); } +static int dlglist_getpos(DLGHDL hdl, int y) { + + int val; + + val = (y / hdl->c.dl.fontsize) + hdl->c.dl.basepos; + if ((unsigned int)val < (unsigned int)hdl->prmcnt) { + return(val); + } + else { + return(-1); + } +} + +enum { + DLCUR_OUT = -1, + DLCUR_INLIST = 0, + DLCUR_UP = 1, + DLCUR_INBAR = 2, + DLCUR_DOWN = 3, + DLCUR_PGUP = 4, + DLCUR_PGDN = 5 +}; + static int dlglist_getpc(DLGHDL hdl, int x, int y) { - x -= (MENU_LINE * 2); if ((unsigned int)x >= (unsigned int)hdl->vram->width) { goto dlgp_out; } - y -= (MENU_LINE * 2); if ((unsigned int)y >= (unsigned int)hdl->vram->height) { goto dlgp_out; } + if ((hdl->prmcnt < hdl->c.dl.dispmax) || (x < (hdl->vram->width - MENUDLG_CXVSCR))) { - return(0); + return(DLCUR_INLIST); } else if (y < MENUDLG_CYVSCR) { - return(1); + return(DLCUR_UP); } else if (y >= (hdl->vram->height - MENUDLG_CYVSCR)) { - return(3); + return(DLCUR_DOWN); } - else if (hdl->c.dl.scrollbar) { - return(2); + y -= MENUDLG_CYVSCR; + y -= dlglist_barpos(hdl); + if (y < 0) { + return(DLCUR_PGUP); + } + else if (y < (int)hdl->c.dl.scrollbar) { + return(DLCUR_INBAR); + } + else { + return(DLCUR_PGDN); } dlgp_out: - return(-1); + return(DLCUR_OUT); } static void dlglist_setval(MENUDLG dlg, DLGHDL hdl, int val) { @@ -807,15 +831,22 @@ static void dlglist_setbasepos(MENUDLG d static void dlglist_onclick(MENUDLG dlg, DLGHDL hdl, int x, int y) { int flg; + int val; - flg = dlglist_getpc(hdl, x, y); + x -= (MENU_LINE * 2); y -= (MENU_LINE * 2); + flg = dlglist_getpc(hdl, x, y); dlg->dragflg = flg; switch(flg) { - case 0: - dlglist_setval(dlg, hdl, (y / hdl->c.dl.fontsize) + - hdl->c.dl.basepos); - dlg->proc(DLGMSG_COMMAND, hdl->id, 0); + case DLCUR_INLIST: + val = dlglist_getpos(hdl, y); + if ((val == hdl->val) && (val != -1)) { + dlg->proc(DLGMSG_COMMAND, hdl->id, 1); + } + else { + dlglist_setval(dlg, hdl, val); + dlg->proc(DLGMSG_COMMAND, hdl->id, 0); + } break; case 1: @@ -825,7 +856,7 @@ static void dlglist_onclick(MENUDLG dlg, drawctrls(dlg, hdl); break; - case 2: + case DLCUR_INBAR: y -= MENUDLG_CYVSCR; y -= dlglist_barpos(hdl); if ((unsigned int)y < (unsigned int)hdl->c.dl.scrollbar) { @@ -835,6 +866,18 @@ static void dlglist_onclick(MENUDLG dlg, dlg->lasty = -1; } break; + + case DLCUR_PGUP: + dlglist_setbasepos(dlg, hdl, hdl->c.dl.basepos + - hdl->c.dl.dispmax); + drawctrls(dlg, hdl); + break; + + case DLCUR_PGDN: + dlglist_setbasepos(dlg, hdl, hdl->c.dl.basepos + + hdl->c.dl.dispmax); + drawctrls(dlg, hdl); + break; } } @@ -843,13 +886,13 @@ static void dlglist_move(MENUDLG dlg, DL int flg; int height; - flg = dlglist_getpc(hdl, x, y); + x -= (MENU_LINE * 2); y -= (MENU_LINE * 2); + flg = dlglist_getpc(hdl, x, y); switch(dlg->dragflg) { - case 0: + case DLCUR_INLIST: if (flg == 0) { - dlglist_setval(dlg, hdl, (y / hdl->c.dl.fontsize) + - hdl->c.dl.basepos); + dlglist_setval(dlg, hdl, dlglist_getpos(hdl, y)); dlg->proc(DLGMSG_COMMAND, hdl->id, 0); } break; @@ -860,7 +903,7 @@ static void dlglist_move(MENUDLG dlg, DL drawctrls(dlg, hdl); break; - case 2: + case DLCUR_INBAR: if (dlg->lasty >= 0) { y -= MENUDLG_CYVSCR; y -= dlg->lasty; @@ -882,7 +925,7 @@ static void dlglist_move(MENUDLG dlg, DL (void)focus; } -static void dlglist_rel(MENUDLG dlg, DLGHDL hdl, int x, int y, int focus) { +static void dlglist_rel(MENUDLG dlg, DLGHDL hdl, int focus) { switch(dlg->dragflg) { case 1: @@ -891,8 +934,6 @@ static void dlglist_rel(MENUDLG dlg, DLG drawctrls(dlg, hdl); break; } - (void)x; - (void)y; (void)focus; } @@ -1036,7 +1077,6 @@ static void dlgslider_paint(MENUDLG dlg, menuvram_res2put(dlg->vram, &src, &pt); } - static void dlgslider_setval(MENUDLG dlg, DLGHDL hdl, int val) { int pos; @@ -1048,7 +1088,6 @@ static void dlgslider_setval(MENUDLG dlg } } - static void dlgslider_onclick(MENUDLG dlg, DLGHDL hdl, int x, int y) { int width; @@ -1088,7 +1127,6 @@ static void dlgslider_onclick(MENUDLG dl } } - static void dlgslider_move(MENUDLG dlg, DLGHDL hdl, int x, int y, int focus) { int range; @@ -1130,14 +1168,12 @@ static void dlgslider_move(MENUDLG dlg, } -static void dlgslider_rel(MENUDLG dlg, DLGHDL hdl, int x, int y, int focus) { +static void dlgslider_rel(MENUDLG dlg, DLGHDL hdl, int focus) { if (hdl->c.ds.moving) { hdl->c.ds.moving = 0; drawctrls(dlg, hdl); } - (void)x; - (void)y; (void)focus; } @@ -1177,7 +1213,6 @@ static BOOL dlgtablist_create(MENUDLG dl return(SUCCESS); } - static void dlgtablist_paint(MENUDLG dlg, DLGHDL hdl) { VRAMHDL dst; @@ -1283,7 +1318,6 @@ static void dlgtablist_paint(MENUDLG dlg } } - static void dlgtablist_setval(MENUDLG dlg, DLGHDL hdl, int val) { if (hdl->val != val) { @@ -1292,7 +1326,6 @@ static void dlgtablist_setval(MENUDLG dl } } - static void dlgtablist_append(MENUDLG dlg, DLGHDL hdl, const void *arg) { DLGPRM res; @@ -1312,7 +1345,6 @@ static void dlgtablist_append(MENUDLG dl } } - static void dlgtablist_onclick(MENUDLG dlg, DLGHDL hdl, int x, int y) { DLGPRM prm; @@ -1402,6 +1434,11 @@ static void dlgframe_paint(MENUDLG dlg, // ---- radio +typedef struct { + MENUDLG dlg; + MENUID group; +} MDCB1; + static void dlgradio_paint(MENUDLG dlg, DLGHDL hdl) { POINT_T pt; @@ -1422,12 +1459,6 @@ const MENURES2 *src; dlg_text(dlg, hdl, &pt, &hdl->rect); } - -typedef struct { - MENUDLG dlg; - MENUID group; -} MDCB1; - static BOOL drsv_cb(void *vpItem, void *vpArg) { DLGHDL item; @@ -1456,7 +1487,6 @@ static void dlgradio_setval(MENUDLG dlg, } } - static void dlgradio_onclick(MENUDLG dlg, DLGHDL hdl, int x, int y) { if (x < (hdl->c.dt.pt.x + MENUDLG_SXRADIO)) { @@ -1502,7 +1532,6 @@ static void dlgcheck_paint(MENUDLG dlg, dlg_text(dlg, hdl, &pt, &hdl->rect); } - static void dlgcheck_setval(MENUDLG dlg, DLGHDL hdl, int val) { if (hdl->val != val) { @@ -1511,7 +1540,6 @@ static void dlgcheck_setval(MENUDLG dlg, } } - static void dlgcheck_onclick(MENUDLG dlg, DLGHDL hdl, int x, int y) { if (x < (hdl->c.dt.pt.x + MENUDLG_SXCHECK)) { @@ -1560,7 +1588,7 @@ const void *str; if (str == NULL) { str = str_null; } - milstr_ncpy(hdl->prm->str, str, sizeof(hdl->prm->str)); + milsjis_ncpy(hdl->prm->str, str, sizeof(hdl->prm->str)); fontmng_getsize(hdl->c.dt.font, str, &hdl->c.dt.pt); } (void)dlg; @@ -1696,12 +1724,10 @@ static void _setval(MENUDLG dlg, DLGHDL (void)val; } -static void _moverel(MENUDLG dlg, DLGHDL hdl, int x, int y, int focus) { +static void _moverel(MENUDLG dlg, DLGHDL hdl, int focus) { (void)dlg; (void)hdl; - (void)x; - (void)y; (void)focus; } @@ -1710,7 +1736,7 @@ typedef void (*DLGPAINT)(MENUDLG dlg, DL typedef void (*DLGSETVAL)(MENUDLG dlg, DLGHDL hdl, int val); typedef void (*DLGCLICK)(MENUDLG dlg, DLGHDL hdl, int x, int y); typedef void (*DLGMOV)(MENUDLG dlg, DLGHDL hdl, int x, int y, int focus); -typedef void (*DLGREL)(MENUDLG dlg, DLGHDL hdl, int x, int y, int focus); +typedef void (*DLGREL)(MENUDLG dlg, DLGHDL hdl, int focus); static const DLGCRE dlgcre[] = { dlgbase_create, // DLGTYPE_BASE @@ -2022,7 +2048,6 @@ BOOL menudlg_appends(const MENUPRM *res, return(r); } - BOOL menudlg_append(int type, MENUID id, MENUFLG flg, const void *arg, int posx, int posy, int width, int height) { @@ -2154,7 +2179,7 @@ void menudlg_moving(int x, int y, int bt dlg->btn = 0; if ((unsigned int)hdl->type < (sizeof(dlgrel)/sizeof(DLGREL))) { - dlgrel[hdl->type](dlg, hdl, x, y, focus); + dlgrel[hdl->type](dlg, hdl, focus); } } } @@ -2273,6 +2298,13 @@ void *menudlg_msg(int ctrl, MENUID id, v break; case DMSG_ITEMRESET: + if ((dlg->btn) && (dlg->lastid == hdl->id)) { + dlg->btn = 0; + if ((unsigned int)hdl->type < + (sizeof(dlgrel)/sizeof(DLGREL))) { + dlgrel[hdl->type](dlg, hdl, FALSE); + } + } if (hdl->type == DLGTYPE_LIST) { dlglist_reset(dlg, hdl); drawctrls(dlg, hdl);