| 724 | } |
| 725 | |
| 726 | bool DoEditDialog(const char *title, char *buffer, int buflen, bool showcancel) { |
| 727 | newuiMessageBox mbox; |
| 728 | newuiSheet *sheet; |
| 729 | |
| 730 | int old_screen_mode, res; |
| 731 | char msgbuf[256]; |
| 732 | char *edit; |
| 733 | |
| 734 | // force menu mode |
| 735 | old_screen_mode = GetScreenMode(); |
| 736 | |
| 737 | textaux_WordWrap(title, msgbuf, NEWUI_MSGBOX_SHEET_W, MONITOR9_NEWUI_FONT); |
| 738 | |
| 739 | // make message box |
| 740 | mbox.Create("", showcancel ? MSGBOX_OKCANCEL : MSGBOX_OK); |
| 741 | |
| 742 | sheet = mbox.GetSheet(); |
| 743 | sheet->NewGroup(NULL, 0, 25); |
| 744 | edit = sheet->AddEditBox("", buflen, 0, DEFAULT_NEWUID, 0, true); |
| 745 | strcpy(edit, buffer); |
| 746 | |
| 747 | sheet->NewGroup(NULL, 0, 0); |
| 748 | sheet->AddText(msgbuf); |
| 749 | |
| 750 | mbox.Open(); |
| 751 | res = mbox.DoUI(); |
| 752 | mbox.Close(); |
| 753 | |
| 754 | if (res != UID_CANCEL && res != NEWUIRES_FORCEQUIT) { |
| 755 | if (strcmp(edit, NEWUI_EDIT_CANCELED_STR) != 0) { |
| 756 | strcpy(buffer, edit); |
| 757 | mprintf(0, "editdialog=%s\n", buffer); |
| 758 | } else { |
| 759 | res = UID_CANCEL; |
| 760 | } |
| 761 | } |
| 762 | |
| 763 | mbox.Destroy(); |
| 764 | |
| 765 | // restore screen |
| 766 | SetScreenMode(old_screen_mode); |
| 767 | |
| 768 | // return correct value. |
| 769 | return ((res != UID_CANCEL && res != NEWUIRES_FORCEQUIT) ? true : false); |
| 770 | } |
| 771 | |
| 772 | // puts up a file selector box |
| 773 | // Parameters: max_filename_len - the max length for the filename. filebuf have a length of at least max_filename_len+1 |
no test coverage detected