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