--- np2/embed/menubase/menudlg.c 2003/11/21 06:51:10 1.1 +++ np2/embed/menubase/menudlg.c 2005/02/11 21:17:22 1.9 @@ -1,4 +1,5 @@ #include "compiler.h" +#include "strres.h" #include "fontmng.h" #include "vramhdl.h" #include "vrammix.h" @@ -8,9 +9,10 @@ typedef struct _dprm { struct _dprm *next; - int width; + UINT16 width; + UINT16 num; VRAMHDL icon; - char str[128]; + OEMCHAR str[96]; } _DLGPRM, *DLGPRM; #define PRMNEXT_EMPTY ((DLGPRM)-1) @@ -27,20 +29,20 @@ typedef struct { typedef struct { void *font; - short fontsize; - short scrollbar; - short dispmax; - short basepos; + SINT16 fontsize; + SINT16 scrollbar; + SINT16 dispmax; + SINT16 basepos; } DLGLIST; typedef struct { - short minval; - short maxval; + SINT16 minval; + SINT16 maxval; int pos; - BYTE type; - BYTE moving; - BYTE sldh; - BYTE sldv; + UINT8 type; + UINT8 moving; + UINT8 sldh; + UINT8 sldv; } DLGSLD; typedef struct { @@ -102,10 +104,11 @@ static BOOL seaprmempty(void *vpItem, vo ((DLGPRM)vpItem)->icon = NULL; return(TRUE); } + (void)vpArg; return(FALSE); } -static DLGPRM resappend(MENUDLG dlg, const char *str) { +static DLGPRM resappend(MENUDLG dlg, const OEMCHAR *str) { DLGPRM prm; @@ -115,11 +118,12 @@ static DLGPRM resappend(MENUDLG dlg, con } if (prm) { prm->next = NULL; - prm->icon = NULL; prm->width = 0; + prm->num = 0; + prm->icon = NULL; prm->str[0] = '\0'; if (str) { - milstr_ncpy(prm->str, str, sizeof(prm->str)); + milstr_ncpy(prm->str, str, NELEMENTS(prm->str)); } } return(prm); @@ -130,6 +134,7 @@ static void resattachicon(MENUDLG dlg, D if (prm) { menuicon_unlock(prm->icon); + prm->num = icon; prm->icon = menuicon_lock(icon, width, height, dlg->vram->bpp); } } @@ -151,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) { @@ -160,12 +164,35 @@ 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)); } +static BRESULT gettextsz(DLGHDL hdl, POINT_T *sz) { + + DLGPRM prm; + + prm = hdl->prm; + if (prm == NULL) { + goto gts_err; + } + *sz = hdl->c.dt.pt; + if (prm->icon) { + if (sz->x) { +#if defined(SIZE_QVGA) + sz->x += 1; +#else + sz->x += 2; +#endif + } + sz->x += sz->y; + } + return(SUCCESS); + +gts_err: + return(FAILURE); +} static void getleft(POINT_T *pt, const RECT_T *rect, const POINT_T *sz) { @@ -174,7 +201,6 @@ static void getleft(POINT_T *pt, const R (void)sz; } - static void getcenter(POINT_T *pt, const RECT_T *rect, const POINT_T *sz) { pt->x = rect->left; @@ -188,7 +214,6 @@ static void getright(POINT_T *pt, const pt->y = rect->top; } - static void getmid(POINT_T *pt, const RECT_T *rect, const POINT_T *sz) { pt->x = rect->left; @@ -198,58 +223,75 @@ static void getmid(POINT_T *pt, const RE } -static BOOL _cre_settext(MENUDLG dlg, DLGHDL hdl, const void *arg) { +static BRESULT _cre_settext(MENUDLG dlg, DLGHDL hdl, const void *arg) { + +const OEMCHAR *str; - hdl->prm = resappend(dlg, (char *)arg); + str = (OEMCHAR *)arg; + if (str == NULL) { + str = str_null; + } + hdl->prm = resappend(dlg, str); hdl->c.dt.font = dlg->font; - fontmng_getsize(dlg->font, (char *)arg, &hdl->c.dt.pt); + fontmng_getsize(dlg->font, str, &hdl->c.dt.pt); return(SUCCESS); } - static void dlg_text(MENUDLG dlg, DLGHDL hdl, const POINT_T *pt, const RECT_T *rect) { -const char *string; - int color; - POINT_T p; + VRAMHDL icon; +const OEMCHAR *string; + int color; + POINT_T fp; + POINT_T p; if (hdl->prm == NULL) { - goto dgtx_exit; - } - string = hdl->prm->str; - if (string == NULL) { - goto dgtx_exit; + return; } - if (!(hdl->flag & MENU_GRAY)) { - color = MVC_TEXT; + fp = *pt; + icon = hdl->prm->icon; + if (icon) { + if (icon->alpha) { + vramcpy_cpyex(dlg->vram, &fp, icon, NULL); + } + else { + vramcpy_cpy(dlg->vram, &fp, icon, NULL); + } + fp.x += icon->width; +#if defined(SIZE_QVGA) + fp.x += 1; +#else + fp.x += 2; +#endif } - else { - p.x = pt->x + MENU_DSTEXT; - p.y = pt->y + MENU_DSTEXT; - vrammix_text(dlg->vram, hdl->c.dt.font, string, + string = hdl->prm->str; + if (string) { + if (!(hdl->flag & MENU_GRAY)) { + color = MVC_TEXT; + } + else { + p.x = fp.x + MENU_DSTEXT; + p.y = fp.y + MENU_DSTEXT; + vrammix_text(dlg->vram, hdl->c.dt.font, string, menucolor[MVC_GRAYTEXT2], &p, rect); - color = MVC_GRAYTEXT1; + color = MVC_GRAYTEXT1; + } + vrammix_text(dlg->vram, hdl->c.dt.font, string, + menucolor[color], &fp, rect); } - p.x = pt->x; - p.y = pt->y; - vrammix_text(dlg->vram, hdl->c.dt.font, string, - menucolor[color], &p, rect); - -dgtx_exit: - return; } // ---- base -static BOOL dlgbase_create(MENUDLG dlg, DLGHDL hdl, const void *arg) { +static BRESULT dlgbase_create(MENUDLG dlg, DLGHDL hdl, const void *arg) { RECT_T rct; rct.right = hdl->rect.right - hdl->rect.left - ((MENU_FBORDER + MENU_BORDER) * 2); - hdl->vram = vram_create(rct.right, MENUDLG_CYCAPTION, FALSE, DEFAULT_BPP); + hdl->vram = vram_create(rct.right, MENUDLG_CYCAPTION, FALSE, menubase.bpp); if (hdl->vram == NULL) { goto dbcre_err; } @@ -258,7 +300,7 @@ static BOOL dlgbase_create(MENUDLG dlg, rct.left = 0; rct.top = 0; rct.bottom = MENUDLG_CYCAPTION; - menuvram_caption(hdl->vram, &rct, MICON_NULL, (char *)arg); + menuvram_caption(hdl->vram, &rct, MICON_NULL, (OEMCHAR *)arg); return(SUCCESS); dbcre_err: @@ -269,7 +311,7 @@ dbcre_err: static void dlgbase_paint(MENUDLG dlg, DLGHDL hdl) { - char *title; + OEMCHAR *title; title = NULL; if (hdl->prm) { @@ -337,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; } @@ -352,6 +392,7 @@ static void dlgclose_rel(MENUDLG dlg, DL static void dlgbtn_paint(MENUDLG dlg, DLGHDL hdl) { + POINT_T sz; POINT_T pt; UINT c; @@ -364,8 +405,8 @@ static void dlgbtn_paint(MENUDLG dlg, DL } menuvram_box2(dlg->vram, &hdl->rect, c); - if (hdl->prm) { - getmid(&pt, &hdl->rect, &hdl->c.dt.pt); + if (gettextsz(hdl, &sz) == SUCCESS) { + getmid(&pt, &hdl->rect, &sz); if (hdl->val) { pt.x += MENU_DSTEXT; pt.y += MENU_DSTEXT; @@ -383,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) { @@ -394,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; } @@ -420,8 +459,8 @@ static void *dlglist_setfont(DLGHDL hdl, if ((pt.y <= 0) || (pt.y >= 65536)) { pt.y = 16; } - hdl->c.dl.fontsize = (short)pt.y; - hdl->c.dl.dispmax = (short)(hdl->vram->height / pt.y); + hdl->c.dl.fontsize = (SINT16)pt.y; + hdl->c.dl.dispmax = (SINT16)(hdl->vram->height / pt.y); return(ret); } @@ -431,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; @@ -445,14 +483,14 @@ static void dlglist_reset(MENUDLG dlg, D hdl->c.dl.basepos = 0; } -static BOOL dlglist_create(MENUDLG dlg, DLGHDL hdl, const void *arg) { +static BRESULT dlglist_create(MENUDLG dlg, DLGHDL hdl, const void *arg) { int width; int height; width = hdl->rect.right - hdl->rect.left - (MENU_LINE * 4); height = hdl->rect.bottom - hdl->rect.top - (MENU_LINE * 4); - hdl->vram = vram_create(width, height, FALSE, DEFAULT_BPP); + hdl->vram = vram_create(width, height, FALSE, menubase.bpp); if (hdl->vram == NULL) { goto dlcre_err; } @@ -493,12 +531,12 @@ static void dlglist_drawitem(DLGHDL hdl, vramcpy_cpy(hdl->vram, &fp, icon, NULL); } fp.x += icon->width; - } #if defined(SIZE_QVGA) - fp.x += 1; + fp.x += 1; #else - fp.x += 2; + fp.x += 2; #endif + } vrammix_text(hdl->vram, hdl->c.dl.font, prm->str, menucolor[focus?MVC_CURTEXT:MVC_TEXT], &fp, rct); } @@ -645,7 +683,7 @@ static BOOL dlglist_append(MENUDLG dlg, while(*sto) { sto = &((*sto)->next); } - *sto = resappend(dlg, (char *)arg); + *sto = resappend(dlg, (OEMCHAR *)arg); if (*sto) { r = dlglist_drawsub(hdl, hdl->prmcnt, FALSE); hdl->prmcnt++; @@ -687,36 +725,67 @@ 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)); + milstr_ncpy(dp->str, arg->str, NELEMENTS(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, + DLCUR_INCUR = 6 +}; + 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) { @@ -763,14 +832,19 @@ 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); + case DLCUR_INLIST: + val = dlglist_getpos(hdl, y); + if ((val == hdl->val) && (val != -1)) { + dlg->dragflg = DLCUR_INCUR; + } + dlglist_setval(dlg, hdl, val); dlg->proc(DLGMSG_COMMAND, hdl->id, 0); break; @@ -781,7 +855,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) { @@ -791,22 +865,40 @@ 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; } } static void dlglist_move(MENUDLG dlg, DLGHDL hdl, int x, int y, int focus) { int flg; + int val; 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: - if (flg == 0) { - dlglist_setval(dlg, hdl, (y / hdl->c.dl.fontsize) + - hdl->c.dl.basepos); - dlg->proc(DLGMSG_COMMAND, hdl->id, 0); + case DLCUR_INLIST: + case DLCUR_INCUR: + if (flg == DLCUR_INLIST) { + val = dlglist_getpos(hdl, y); + if (val != hdl->val) { + dlg->dragflg = DLCUR_INLIST; + dlglist_setval(dlg, hdl, val); + dlg->proc(DLGMSG_COMMAND, hdl->id, 0); + } } break; @@ -816,7 +908,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; @@ -838,7 +930,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: @@ -846,9 +938,11 @@ static void dlglist_rel(MENUDLG dlg, DLG dlglist_setbtn(hdl, dlg->dragflg - 1); drawctrls(dlg, hdl); break; + + case DLCUR_INCUR: + dlg->proc(DLGMSG_COMMAND, hdl->id, 1); + break; } - (void)x; - (void)y; (void)focus; } @@ -875,14 +969,14 @@ static void dlgslider_setflag(DLGHDL hdl else { type = 2 + (21 << 8) + (11 << 16); } - hdl->c.ds.type = (BYTE)type; + hdl->c.ds.type = (UINT8)type; if (!(hdl->flag & MSS_VERT)) { - hdl->c.ds.sldh = (BYTE)(type >> 16); - hdl->c.ds.sldv = (BYTE)(type >> 8); + hdl->c.ds.sldh = (UINT8)(type >> 16); + hdl->c.ds.sldv = (UINT8)(type >> 8); } else { - hdl->c.ds.sldh = (BYTE)(type >> 8); - hdl->c.ds.sldv = (BYTE)(type >> 16); + hdl->c.ds.sldh = (UINT8)(type >> 8); + hdl->c.ds.sldv = (UINT8)(type >> 16); } } @@ -927,10 +1021,10 @@ static int dlgslider_setpos(DLGHDL hdl, return(val); } -static BOOL dlgslider_create(MENUDLG dlg, DLGHDL hdl, const void *arg) { +static BRESULT dlgslider_create(MENUDLG dlg, DLGHDL hdl, const void *arg) { - hdl->c.ds.minval = (short)(long)arg; - hdl->c.ds.maxval = (short)((long)arg >> 16); + hdl->c.ds.minval = (SINT16)(long)arg; + hdl->c.ds.maxval = (SINT16)((long)arg >> 16); hdl->c.ds.moving = 0; dlgslider_setflag(hdl); hdl->c.ds.pos = dlgslider_setpos(hdl, 0); @@ -992,7 +1086,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; @@ -1004,7 +1097,6 @@ static void dlgslider_setval(MENUDLG dlg } } - static void dlgslider_onclick(MENUDLG dlg, DLGHDL hdl, int x, int y) { int width; @@ -1044,7 +1136,6 @@ static void dlgslider_onclick(MENUDLG dl } } - static void dlgslider_move(MENUDLG dlg, DLGHDL hdl, int x, int y, int focus) { int range; @@ -1086,14 +1177,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; } @@ -1122,7 +1211,7 @@ static void *dlgtablist_setfont(DLGHDL h return(ret); } -static BOOL dlgtablist_create(MENUDLG dlg, DLGHDL hdl, const void *arg) { +static BRESULT dlgtablist_create(MENUDLG dlg, DLGHDL hdl, const void *arg) { RECT_T rct; @@ -1133,7 +1222,6 @@ static BOOL dlgtablist_create(MENUDLG dl return(SUCCESS); } - static void dlgtablist_paint(MENUDLG dlg, DLGHDL hdl) { VRAMHDL dst; @@ -1239,7 +1327,6 @@ static void dlgtablist_paint(MENUDLG dlg } } - static void dlgtablist_setval(MENUDLG dlg, DLGHDL hdl, int val) { if (hdl->val != val) { @@ -1248,7 +1335,6 @@ static void dlgtablist_setval(MENUDLG dl } } - static void dlgtablist_append(MENUDLG dlg, DLGHDL hdl, const void *arg) { DLGPRM res; @@ -1259,16 +1345,15 @@ static void dlgtablist_append(MENUDLG dl while(*sto) { sto = &((*sto)->next); } - res = resappend(dlg, (char *)arg); + res = resappend(dlg, (OEMCHAR *)arg); if (res) { *sto = res; - fontmng_getsize(hdl->c.dtl.font, (char *)arg, &pt); + fontmng_getsize(hdl->c.dtl.font, (OEMCHAR *)arg, &pt); res->width = pt.x; hdl->prmcnt++; } } - static void dlgtablist_onclick(MENUDLG dlg, DLGHDL hdl, int x, int y) { DLGPRM prm; @@ -1300,9 +1385,9 @@ static void dlgtablist_onclick(MENUDLG d static void dlgedit_paint(MENUDLG dlg, DLGHDL hdl) { - RECT_T rct; - POINT_T pt; -const char *string; + RECT_T rct; + POINT_T pt; +const OEMCHAR *string; rct = hdl->rect; menuvram_box2(dlg->vram, &rct, @@ -1358,6 +1443,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; @@ -1378,12 +1468,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; @@ -1412,7 +1496,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)) { @@ -1458,7 +1541,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) { @@ -1467,7 +1549,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)) { @@ -1482,11 +1563,12 @@ static void dlgcheck_onclick(MENUDLG dlg static void dlgtext_paint(MENUDLG dlg, DLGHDL hdl) { + POINT_T sz; POINT_T pt; void (*getpt)(POINT_T *pt, const RECT_T *rect, const POINT_T *sz); vram_filldat(dlg->vram, &hdl->rect, menucolor[MVC_STATIC]); - if (hdl->prm) { + if (gettextsz(hdl, &sz) == SUCCESS) { switch(hdl->flag & MST_POSMASK) { case MST_LEFT: default: @@ -1501,23 +1583,31 @@ static void dlgtext_paint(MENUDLG dlg, D getpt = getright; break; } - getpt(&pt, &hdl->rect, &hdl->c.dt.pt); + getpt(&pt, &hdl->rect, &sz); dlg_text(dlg, hdl, &pt, &hdl->rect); } } +static void dlgtext_itemset(MENUDLG dlg, DLGHDL hdl, const void *arg) { -static void dlgtext_itemset(MENUDLG dlg, DLGHDL hdl, const void *str) { +const OEMCHAR *str; if (hdl->prm) { - if (str) { - milstr_ncpy(hdl->prm->str, (char *)str, sizeof(hdl->prm->str)); - fontmng_getsize(hdl->c.dt.font, (char *)str, &hdl->c.dt.pt); - } - else { - hdl->prm->str[0] = '\0'; - hdl->c.dt.pt.x = 0; + str = (OEMCHAR *)arg; + if (str == NULL) { + str = str_null; } + milstr_ncpy(hdl->prm->str, str, NELEMENTS(hdl->prm->str)); + fontmng_getsize(hdl->c.dt.font, str, &hdl->c.dt.pt); + } + (void)dlg; +} + +static void dlgtext_iconset(MENUDLG dlg, DLGHDL hdl, const void *arg) { + + if (hdl->prm) { + resattachicon(dlg, hdl->prm, (UINT16)(long)arg, + hdl->c.dt.pt.y, hdl->c.dt.pt.y); } (void)dlg; } @@ -1549,7 +1639,7 @@ static void iconpaint(MENUDLG dlg, DLGHD } } -static BOOL dlgicon_create(MENUDLG dlg, DLGHDL hdl, const void *arg) { +static BRESULT dlgicon_create(MENUDLG dlg, DLGHDL hdl, const void *arg) { hdl->prm = resappend(dlg, NULL); resattachicon(dlg, hdl->prm, (UINT16)(long)arg, @@ -1567,7 +1657,7 @@ static void dlgicon_paint(MENUDLG dlg, D } } -static BOOL dlgvram_create(MENUDLG dlg, DLGHDL hdl, const void *arg) { +static BRESULT dlgvram_create(MENUDLG dlg, DLGHDL hdl, const void *arg) { hdl->c.dv.vram = (VRAMHDL)arg; (void)dlg; @@ -1610,12 +1700,12 @@ static void dlgbox_paint(MENUDLG dlg, DL // ---- procs -static BOOL _cre(MENUDLG dlg, DLGHDL hdl, const void *arg) { +static BRESULT _cre(MENUDLG dlg, DLGHDL hdl, const void *arg) { (void)dlg; (void)hdl; (void)arg; - return(0); + return(SUCCESS); } #if 0 // not used @@ -1643,21 +1733,19 @@ 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; } -typedef BOOL (*DLGCRE)(MENUDLG dlg, DLGHDL hdl, const void *arg); +typedef BRESULT (*DLGCRE)(MENUDLG dlg, DLGHDL hdl, const void *arg); typedef void (*DLGPAINT)(MENUDLG dlg, DLGHDL hdl); 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 @@ -1783,7 +1871,7 @@ static BOOL dc_cb2(void *vpItem, void *v if (hdl->flag & MENU_REDRAW) { hdl->flag &= ~MENU_REDRAW; if ((!(hdl->flag & MENU_DISABLE)) && - ((unsigned int)hdl->type < (sizeof(dlgpaint)/sizeof(DLGPAINT)))) { + ((UINT)hdl->type < NELEMENTS(dlgpaint))) { dlgpaint[hdl->type](dlg, hdl); menubase_setrect(dlg->vram, &hdl->rect); } @@ -1851,7 +1939,7 @@ static int defproc(int msg, MENUID id, l } -BOOL menudlg_create(int width, int height, const char *str, +BRESULT menudlg_create(int width, int height, const OEMCHAR *str, int (*proc)(int msg, MENUID id, long param)) { MENUBASE *mb; @@ -1870,7 +1958,7 @@ BOOL menudlg_create(int width, int heigh MENUDLG_CYCAPTION + MENUDLG_BORDER; mb = &menubase; dlg->font = mb->font; - dlg->vram = vram_create(width, height, FALSE, DEFAULT_BPP); + dlg->vram = vram_create(width, height, FALSE, mb->bpp); if (dlg->vram == NULL) { goto mdcre_err; } @@ -1956,9 +2044,9 @@ void menudlg_destroy(void) { // ---- -BOOL menudlg_appends(const MENUPRM *res, int count) { +BRESULT menudlg_appends(const MENUPRM *res, int count) { - BOOL r; + BRESULT r; r = SUCCESS; while(count--) { @@ -1969,8 +2057,7 @@ BOOL menudlg_appends(const MENUPRM *res, return(r); } - -BOOL menudlg_append(int type, MENUID id, MENUFLG flg, const void *arg, +BRESULT menudlg_append(int type, MENUID id, MENUFLG flg, const void *arg, int posx, int posy, int width, int height) { MENUDLG dlg; @@ -2015,7 +2102,7 @@ BOOL menudlg_append(int type, MENUID id, dhdl.prm = NULL; dhdl.prmcnt = 0; dhdl.val = 0; - if (((unsigned int)type >= (sizeof(dlgcre)/sizeof(DLGCRE))) || + if (((UINT)type >= NELEMENTS(dlgcre)) || (dlgcre[type](dlg, &dhdl, arg))) { goto mda_err; } @@ -2081,8 +2168,7 @@ void menudlg_moving(int x, int y, int bt y -= hdl->rect.top; dlg->btn = 1; dlg->lastid = hdl->id; - if ((unsigned int)hdl->type < - (sizeof(dlgclick)/sizeof(DLGCLICK))) { + if ((UINT)hdl->type < NELEMENTS(dlgclick)) { dlgclick[hdl->type](dlg, hdl, x, y); } } @@ -2094,14 +2180,13 @@ void menudlg_moving(int x, int y, int bt focus = rect_in(&hdl->rect, x, y); x -= hdl->rect.left; y -= hdl->rect.top; - if ((unsigned int)hdl->type < (sizeof(dlgmov)/sizeof(DLGMOV))) { + if ((UINT)hdl->type < NELEMENTS(dlgmov)) { dlgmov[hdl->type](dlg, hdl, x, y, focus); } if (btn == 2) { dlg->btn = 0; - if ((unsigned int)hdl->type < - (sizeof(dlgrel)/sizeof(DLGREL))) { - dlgrel[hdl->type](dlg, hdl, x, y, focus); + if ((UINT)hdl->type < NELEMENTS(dlgrel)) { + dlgrel[hdl->type](dlg, hdl, focus); } } } @@ -2160,8 +2245,7 @@ void *menudlg_msg(int ctrl, MENUID id, v case DMSG_SETVAL: ret = (void *)hdl->val; - if ((unsigned int)hdl->type < - (sizeof(dlgsetval)/sizeof(DLGSETVAL))) { + if ((UINT)hdl->type < NELEMENTS(dlgsetval)) { dlgsetval[hdl->type](dlg, hdl, (int)arg); } break; @@ -2180,6 +2264,7 @@ void *menudlg_msg(int ctrl, MENUID id, v case DMSG_SETTEXT: switch(hdl->type) { + case DLGTYPE_BUTTON: case DLGTYPE_RADIO: case DLGTYPE_CHECK: case DLGTYPE_EDIT: @@ -2190,6 +2275,19 @@ void *menudlg_msg(int ctrl, MENUID id, v } break; + case DMSG_SETICON: + switch(hdl->type) { + case DLGTYPE_BUTTON: + case DLGTYPE_RADIO: + case DLGTYPE_CHECK: + case DLGTYPE_EDIT: + case DLGTYPE_TEXT: + dlgtext_iconset(dlg, hdl, arg); + drawctrls(dlg, hdl); + break; + } + break; + case DMSG_ITEMAPPEND: switch(hdl->type) { case DLGTYPE_LIST: @@ -2206,6 +2304,12 @@ void *menudlg_msg(int ctrl, MENUID id, v break; case DMSG_ITEMRESET: + if ((dlg->btn) && (dlg->lastid == hdl->id)) { + dlg->btn = 0; + if ((UINT)hdl->type < NELEMENTS(dlgrel)) { + dlgrel[hdl->type](dlg, hdl, FALSE); + } + } if (hdl->type == DLGTYPE_LIST) { dlglist_reset(dlg, hdl); drawctrls(dlg, hdl);