| version 1.1.1.1, 2003/10/16 17:59:04 | version 1.3, 2003/11/21 06:51:14 | 
| Line 1 | Line 1 | 
 | #include        "compiler.h" | #include        "compiler.h" | 
 | #include        "strres.h" | #include        "strres.h" | 
 |  | #include        "bmpdata.h" | 
 | #include        "dosio.h" | #include        "dosio.h" | 
 | #include        "commng.h" | #include        "commng.h" | 
 | #include        "sysmng.h" |  | 
 | #include        "dialogs.h" | #include        "dialogs.h" | 
 |  |  | 
 |  |  | 
 | static const char str_nc[] = "N/C"; | static const char str_nc[] = "N/C"; | 
 |  |  | 
| static  char    pathname[MAX_PATH]; | // static       char    pathname[MAX_PATH]; | 
| static  char    filename[MAX_PATH]; | // static       char    filename[MAX_PATH]; | 
 |  |  | 
 | const char str_int0[] = "INT0"; | const char str_int0[] = "INT0"; | 
 | const char str_int1[] = "INT1"; | const char str_int1[] = "INT1"; | 
| Line 21  const char str_int6[] = "INT6"; | Line 21  const char str_int6[] = "INT6"; | 
 |  |  | 
 | // ---- file select | // ---- file select | 
 |  |  | 
| const char *dlgs_selectfile(HWND hWnd, const FILESEL *item, | BOOL dlgs_selectfile(HWND hWnd, const FILESEL *item, | 
| const char *defname, char *folder, UINT size, int *ro) { | char *path, UINT size, int *ro) { | 
 |  |  | 
 | OPENFILENAME    ofn; | OPENFILENAME    ofn; | 
 |  |  | 
| if ((defname) && (defname[0])) { | if ((item == NULL) || (path == NULL) || (size == 0)) { | 
| milstr_ncpy(pathname, defname, sizeof(pathname)); | return(FALSE); | 
 | } | } | 
 | else if (folder) { |  | 
 | milstr_ncpy(pathname, folder, sizeof(pathname)); |  | 
 | } |  | 
 | else { |  | 
 | pathname[0] = '\0'; |  | 
 | } |  | 
 | filename[0] = '\0'; |  | 
 |  |  | 
 | ZeroMemory(&ofn, sizeof(OPENFILENAME)); | ZeroMemory(&ofn, sizeof(OPENFILENAME)); | 
 | ofn.lStructSize = sizeof(OPENFILENAME); | ofn.lStructSize = sizeof(OPENFILENAME); | 
 | ofn.hwndOwner = hWnd; | ofn.hwndOwner = hWnd; | 
 | ofn.lpstrFilter = item->filter; | ofn.lpstrFilter = item->filter; | 
 | ofn.nFilterIndex = item->defindex; | ofn.nFilterIndex = item->defindex; | 
| ofn.lpstrFile = pathname; | ofn.lpstrFile = path; | 
| ofn.lpstrFileTitle = filename; | ofn.nMaxFile = size; | 
| ofn.nMaxFile = MAX_PATH; |  | 
 | ofn.Flags = OFN_FILEMUSTEXIST; | ofn.Flags = OFN_FILEMUSTEXIST; | 
 | ofn.lpstrDefExt = item->ext; | ofn.lpstrDefExt = item->ext; | 
 | ofn.lpstrTitle = item->title; | ofn.lpstrTitle = item->title; | 
 | if (!GetOpenFileName(&ofn)) { | if (!GetOpenFileName(&ofn)) { | 
| return(NULL); | return(FALSE); | 
| } |  | 
| if (folder) { |  | 
| milstr_ncpy(folder, pathname, size); |  | 
| sysmng_update(SYS_UPDATEOSCFG); |  | 
 | } | } | 
 | if (ro) { | if (ro) { | 
 | *ro = ofn.Flags & OFN_READONLY; | *ro = ofn.Flags & OFN_READONLY; | 
 | } | } | 
| return(pathname); | return(TRUE); | 
 | } | } | 
 |  |  | 
| const char *dlgs_selectwritefile(HWND hWnd, const FILESEL *item, | BOOL dlgs_selectwritefile(HWND hWnd, const FILESEL *item, | 
| const char *defname, char *folder, UINT size) { | char *path, UINT size) { | 
 |  |  | 
 | OPENFILENAME    ofn; | OPENFILENAME    ofn; | 
 |  |  | 
| if (defname) { | if ((item == NULL) || (path == NULL) || (size == 0)) { | 
| milstr_ncpy(pathname, defname, sizeof(pathname)); | return(FALSE); | 
 | } | } | 
 | else { |  | 
 | pathname[0] = '\0'; |  | 
 | } |  | 
 | filename[0] = '\0'; |  | 
 |  |  | 
 | ZeroMemory(&ofn, sizeof(OPENFILENAME)); | ZeroMemory(&ofn, sizeof(OPENFILENAME)); | 
 | ofn.lStructSize = sizeof(OPENFILENAME); | ofn.lStructSize = sizeof(OPENFILENAME); | 
 | ofn.hwndOwner = hWnd; | ofn.hwndOwner = hWnd; | 
 | ofn.lpstrFilter = item->filter; | ofn.lpstrFilter = item->filter; | 
 | ofn.lpstrFile = pathname; |  | 
 | ofn.lpstrFileTitle = filename; |  | 
 | ofn.nFilterIndex = item->defindex; | ofn.nFilterIndex = item->defindex; | 
| ofn.nMaxFile = MAX_PATH; | ofn.lpstrFile = path; | 
| ofn.nMaxFileTitle = sizeof(filename); | ofn.nMaxFile = size; | 
 | ofn.Flags = OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY; | ofn.Flags = OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY; | 
 | ofn.lpstrDefExt = item->ext; | ofn.lpstrDefExt = item->ext; | 
 | ofn.lpstrTitle = item->title; | ofn.lpstrTitle = item->title; | 
 | if (!GetSaveFileName(&ofn)) { | if (!GetSaveFileName(&ofn)) { | 
| return(NULL); | return(FALSE); | 
 | } | } | 
| if (folder) { | return(TRUE); | 
| milstr_ncpy(folder, pathname, size); |  | 
| sysmng_update(SYS_UPDATEOSCFG); |  | 
| } |  | 
| return(pathname); |  | 
 | } | } | 
 |  |  | 
| const char *dlgs_selectwritenum(HWND hWnd, const FILESEL *item, | BOOL dlgs_selectwritenum(HWND hWnd, const FILESEL *item, | 
| const char *defname, char *folder, UINT size) { | char *path, UINT size) { | 
 |  |  | 
| char    numfile[MAX_PATH]; | char    *file; | 
 | char    *p; | char    *p; | 
| int             i; | char    *q; | 
|  | UINT    i; | 
|  | BOOL    r; | 
 |  |  | 
| if (folder) { | if ((item == NULL) || (path == NULL) || (size == 0)) { | 
| milstr_ncpy(numfile, folder, sizeof(numfile)); | return(FALSE); | 
 | } | } | 
| else { | file = (char *)_MALLOC(size + 16, path); | 
| numfile[0] = '\0'; | if (file == NULL) { | 
| } | return(FALSE); | 
| file_cutname(numfile); | } | 
| p = numfile + strlen(numfile); | p = file_getname(path); | 
|  | milstr_ncpy(file, path, size); | 
|  | file_cutname(file); | 
|  | q = file + strlen(file); | 
|  |  | 
 | for (i=0; i<10000; i++) { | for (i=0; i<10000; i++) { | 
| wsprintf(p, defname, i); | SPRINTF(q, p, i); | 
| if (file_attr(numfile) == -1) { | if (file_attr(file) == (short)-1) { | 
 | break; | break; | 
 | } | } | 
 | } | } | 
| return(dlgs_selectwritefile(hWnd, item, numfile, folder, size)); | r = dlgs_selectwritefile(hWnd, item, file, size); | 
|  | if (r) { | 
|  | milstr_ncpy(path, file, size); | 
|  | } | 
|  | _MFREE(file); | 
|  | return(r); | 
 | } | } | 
 |  |  | 
 |  |  | 
| Line 136  const char *p; | Line 123  const char *p; | 
 |  |  | 
 | subwnd = GetDlgItem(hWnd, res); | subwnd = GetDlgItem(hWnd, res); | 
 | GetWindowText(subwnd, path, sizeof(path)); | GetWindowText(subwnd, path, sizeof(path)); | 
| p = dlgs_selectfile(hWnd, &mimpi, path, NULL, 0, NULL); | if (dlgs_selectfile(hWnd, &mimpi, path, sizeof(path), NULL)) { | 
| if (p == NULL) { | p = path; | 
|  | } | 
|  | else { | 
 | p = str_null; | p = str_null; | 
 | } | } | 
 | SetWindowText(subwnd, p); | SetWindowText(subwnd, p); | 
| Line 238  void dlgs_setlistmidiin(HWND hWnd, WORD | Line 227  void dlgs_setlistmidiin(HWND hWnd, WORD | 
 |  |  | 
 | // ---- draw | // ---- draw | 
 |  |  | 
| void dlgs_linex(BYTE *image, int x, int y, int l, int align, BYTE c) { | void dlgs_drawbmp(HDC hdc, BYTE *bmp) { | 
|  |  | 
| image -= y * align; |  | 
| while(l--) { |  | 
| if (x & 1) { |  | 
| image[x/2] &= 0xf0; |  | 
| image[x/2] |= c; |  | 
| } |  | 
| else { |  | 
| image[x/2] &= 0x0f; |  | 
| image[x/2] |= (c << 4); |  | 
| } |  | 
| x++; |  | 
| } |  | 
| } |  | 
|  |  | 
| void dlgs_liney(BYTE *image, int x, int y, int l, int align, BYTE c) { |  | 
|  |  | 
| image += (x / 2) - y * align; |  | 
| if (x & 1) { |  | 
| while(l--) { |  | 
| *image &= 0xf0; |  | 
| *image |= c; |  | 
| image -= align; |  | 
| } |  | 
| } |  | 
| else { |  | 
| c <<= 4; |  | 
| while(l--) { |  | 
| *image &= 0x0f; |  | 
| *image |= c; |  | 
| image -= align; |  | 
| } |  | 
| } |  | 
| } |  | 
 |  |  | 
 |  | BMPFILE         *bf; | 
 |  | BMPINFO         *bi; | 
 |  | BMPDATA         inf; | 
 |  | HBITMAP         hbmp; | 
 |  | BYTE            *image; | 
 |  | HDC                     hmdc; | 
 |  |  | 
 |  | if (bmp == NULL) { | 
 |  | return; | 
 |  | } | 
 |  | bf = (BMPFILE *)bmp; | 
 |  | bi = (BMPINFO *)(bf + 1); | 
 |  | if (bmpdata_getinfo(bi, &inf) != SUCCESS) { | 
 |  | goto dsdb_err1; | 
 |  | } | 
 |  | hbmp = CreateDIBSection(hdc, (BITMAPINFO *)bi, DIB_RGB_COLORS, | 
 |  | (void **)&image, NULL, 0); | 
 |  | if (hbmp == NULL) { | 
 |  | goto dsdb_err1; | 
 |  | } | 
 |  | CopyMemory(image, bmp + (LOADINTELDWORD(bf->bfOffBits)), | 
 |  | bmpdata_getdatasize(bi)); | 
 |  | hmdc = CreateCompatibleDC(hdc); | 
 |  | SelectObject(hmdc, hbmp); | 
 |  | if (inf.height < 0) { | 
 |  | inf.height *= -1; | 
 |  | } | 
 |  | BitBlt(hdc, 0, 0, inf.width, inf.height, hmdc, 0, 0, SRCCOPY); | 
 |  | DeleteDC(hmdc); | 
 |  | DeleteObject(hbmp); | 
 |  |  | 
| // ---- jumper | dsdb_err1: | 
|  | _MFREE(bmp); | 
| void dlgs_setjumperx(BYTE *image, int x, int y, int align) { |  | 
|  |  | 
| int             i; |  | 
|  |  | 
| x *= 9; |  | 
| y *= 9; |  | 
| for (i=0; i<2; i++) { |  | 
| dlgs_linex(image, x, y+0+i, 19, align, 0); |  | 
| dlgs_linex(image, x, y+8+i, 19, align, 0); |  | 
| dlgs_liney(image, x+ 0+i, y, 9, align, 0); |  | 
| dlgs_liney(image, x+17+i, y, 9, align, 0); |  | 
| } |  | 
| } |  | 
|  |  | 
| void dlgs_setjumpery(BYTE *image, int x, int y, int align) { |  | 
|  |  | 
| int             i; |  | 
|  |  | 
| x *= 9; |  | 
| y *= 9; |  | 
| for (i=0; i<2; i++) { |  | 
| dlgs_linex(image, x, y+ 0+i, 9, align, 0); |  | 
| dlgs_linex(image, x, y+17+i, 9, align, 0); |  | 
| dlgs_liney(image, x+0+i, y, 19, align, 0); |  | 
| dlgs_liney(image, x+8+i, y, 19, align, 0); |  | 
| } |  | 
 | } | } | 
 |  |  |