--- np2/embed/menubase/menumbox.c 2003/11/21 06:51:10 1.1 +++ np2/embed/menubase/menumbox.c 2005/02/11 21:17:22 1.3 @@ -12,17 +12,16 @@ typedef struct { int height; int lines; int fontsize; - char string[MENUMBOX_MAXLINE][MENUMBOX_MAXTEXT]; + OEMCHAR string[MENUMBOX_MAXLINE][MENUMBOX_MAXTEXT]; } MBOX; static MBOX mbox; -static const char *menumbox_txt[7] = { - (char *)mstr_ok, (char *)mstr_cancel,(char *)mstr_abort, - (char *)mstr_retry, (char *)mstr_ignore,(char *)mstr_yes, - (char *)mstr_no}; +static const OEMCHAR *menumbox_txt[7] = { + mstr_ok, mstr_cancel, mstr_abort, mstr_retry, + mstr_ignore, mstr_yes, mstr_no}; -static const BYTE b_res[6][4] = { +static const UINT8 b_res[6][4] = { {1, DID_OK, 0, 0}, {2, DID_OK, DID_CANCEL, 0}, {3, DID_ABORT, DID_RETRY, DID_IGNORE}, @@ -33,14 +32,15 @@ static const BYTE b_res[6][4] = { // ---- -static BOOL setmboxitem(MBOX *mb, const char *str, UINT type) { +static BRESULT setmboxitem(MBOX *mb, const OEMCHAR *str, UINT type) { - char *dst; + OEMCHAR *dst; int rem; int w; - char work[4]; + OEMCHAR work[4]; int width; POINT_T pt; + int leng; if (mb == NULL) { goto smbi_err; @@ -49,7 +49,6 @@ static BOOL setmboxitem(MBOX *mb, const if (str == NULL) { goto smbi_set; } - work[2] = '\0'; if ((type & 0xf) >= 6) { type &= ~0x0f; } @@ -63,56 +62,46 @@ static BOOL setmboxitem(MBOX *mb, const rem = 0; w = 0; while(1) { - work[0] = *str++; - if (work[0] & (~0x1f)) { - if ((((work[0] ^ 0x20) - 0xa1) & 0xff) < 0x3c) { - work[1] = *str++; - if (work[1] == 0) { - break; - } - rem--; - } - else { - work[1] = '\0'; - } - rem--; - - fontmng_getsize(menubase.font, work, &pt); - if ((rem < 0) || ((w + pt.x) > width)) { + leng = milstr_charsize(str); + if (leng == 0) { + break; + } + if ((str[0] >= 0) && (str[0] < 0x20)) { + if (str[0] == '\n') { dst = mb->string[mb->lines]; mb->lines++; if (mb->lines >= MENUMBOX_MAXLINE) { break; } - rem += sizeof(mb->string[0]) - 1; + rem = NELEMENTS(mb->string[0]) - 1; if (mb->width < w) { mb->width = w; } w = 0; } - w += pt.x; - *dst++ = work[0]; - if (work[1]) { - *dst++ = work[1]; - } } else { - if (work[0] == '\0') { - break; - } - else if (work[0] == '\n') { + CopyMemory(work, str, leng * sizeof(OEMCHAR)); + work[leng] = '\0'; + fontmng_getsize(menubase.font, work, &pt); + if ((rem < leng) || ((w + pt.x) > width)) { dst = mb->string[mb->lines]; mb->lines++; if (mb->lines >= MENUMBOX_MAXLINE) { break; } - rem = sizeof(mb->string[0]) - 1; + rem = NELEMENTS(mb->string[0]) - 1; if (mb->width < w) { mb->width = w; } w = 0; } + w += pt.x; + CopyMemory(dst, str, leng * sizeof(OEMCHAR)); + dst += leng; + rem -= leng; } + str += leng; } if (mb->width < w) { mb->width = w; @@ -149,7 +138,7 @@ static void mbox_open(MBOX *mb) { int posy; int posx; -const BYTE *btn; +const UINT8 *btn; int cnt; int btnid; @@ -232,12 +221,12 @@ static int mbox_cmd(int msg, MENUID id, } -int menumbox(const char *string, const char *title, UINT type) { +int menumbox(const OEMCHAR *string, const OEMCHAR *title, UINT type) { MBOX *mb; mb = &mbox; - if (!setmboxitem(mb, string, type)) { + if (setmboxitem(mb, string, type) == SUCCESS) { menudlg_create(mb->width, mb->height, title, mbox_cmd); menubase_modalproc(); return(mb->ret);