|
|
| version 1.1, 2003/10/28 18:21:05 | version 1.3, 2003/10/29 10:09:37 |
|---|---|
| Line 3 | Line 3 |
| #include "resource.h" | #include "resource.h" |
| #include "np2.h" | #include "np2.h" |
| #include "dosio.h" | #include "dosio.h" |
| #include "soundmng.h" | |
| #include "sysmng.h" | #include "sysmng.h" |
| #include "menu.h" | |
| #include "toolwin.h" | #include "toolwin.h" |
| #include "ini.h" | #include "ini.h" |
| #include "dialog.h" | #include "dialog.h" |
| Line 60 static const BYTE fddlist[FDDLIST_DRV] = | Line 62 static const BYTE fddlist[FDDLIST_DRV] = |
| IDC_TOOLFDD1LIST, IDC_TOOLFDD2LIST}; | IDC_TOOLFDD1LIST, IDC_TOOLFDD2LIST}; |
| static const SUBITEM subitem[IDC_MAXITEMS] = { | static const SUBITEM subitem[IDC_MAXITEMS] = { |
| {str_static, NULL, WS_VISIBLE, 0, 47, 44, 8, 3}, | {str_static, NULL, WS_VISIBLE, 0, 49, 44, 8, 3}, |
| {str_static, NULL, WS_VISIBLE, 0, 93, 19, 8, 3}, | {str_static, NULL, WS_VISIBLE, 0, 93, 19, 8, 3}, |
| {str_combobox, NULL, | {str_combobox, NULL, |
| WS_VISIBLE | CBS_DROPDOWNLIST | WS_VSCROLL, 0, 104, 6, 248, 160}, | WS_VISIBLE | CBS_DROPDOWNLIST | WS_VSCROLL, 0, 104, 6, 248, 160}, |
| Line 82 static const SUBITEM subitem[IDC_MAXITEM | Line 84 static const SUBITEM subitem[IDC_MAXITEM |
| typedef struct { | typedef struct { |
| HWND hwnd; | HWND hwnd; |
| BYTE fddaccess[2]; | |
| BYTE hddaccess; | |
| BYTE _padding; | |
| int winflg; | int winflg; |
| int wingx; | int wingx; |
| int wingy; | int wingy; |
| Line 92 typedef struct { | Line 97 typedef struct { |
| int parenty; | int parenty; |
| HFONT hfont; | HFONT hfont; |
| HDC hdcfont; | HDC hdcfont; |
| HBRUSH access[2]; | |
| HWND sub[IDC_MAXITEMS]; | HWND sub[IDC_MAXITEMS]; |
| SCPROC subproc[IDC_MAXITEMS]; | SCPROC subproc[IDC_MAXITEMS]; |
| } TOOLWIN; | } TOOLWIN; |
| static TOOLWIN toolwin; | static TOOLWIN toolwin; |
| typedef struct { | |
| WORD idc; | |
| BYTE *counter; | |
| } DISKACC; | |
| static const DISKACC diskacc[3] = { | |
| {IDC_TOOLFDD1ACC, &toolwin.fddaccess[0]}, | |
| {IDC_TOOLFDD2ACC, &toolwin.fddaccess[1]}, | |
| {IDC_TOOLHDDACC, &toolwin.hddaccess}}; | |
| static void calctextsize(char *path, int leng, const char *p, int width) { | static void calctextsize(char *path, int leng, const char *p, int width) { |
| HDC hdc; | HDC hdc; |
| SIZE cur; | SIZE cur; |
| char work[MAX_PATH]; | char work[MAX_PATH]; |
| const char *q; | |
| int l; | int l; |
| SIZE tail; | SIZE tail; |
| int pos; | int pos; |
| int step; | int step; |
| // NetscapeÉ÷Ì£ | |
| milstr_ncpy(path, p, leng); | milstr_ncpy(path, p, leng); |
| hdc = toolwin.hdcfont; | hdc = toolwin.hdcfont; |
| GetTextExtentPoint32(hdc, p, strlen(p), &cur); | GetTextExtentPoint32(hdc, p, strlen(p), &cur); |
| Line 123 const char *q; | Line 138 const char *q; |
| l = strlen(path); | l = strlen(path); |
| if (l > 1) { | if (l > 1) { |
| l -= 1; | l -= 1; |
| if (milstr_kanji2nd(p, l)) { | if (milstr_kanji2nd(p, l - 1)) { |
| l--; | l--; |
| } | } |
| } | } |
| Line 213 static void sellist(UINT drv) { | Line 228 static void sellist(UINT drv) { |
| } | } |
| } | } |
| static void accdraw(HWND hWnd, BYTE count) { | |
| HDC hdc; | |
| PAINTSTRUCT ps; | |
| RECT rc; | |
| HBRUSH hbrush; | |
| hdc = BeginPaint(hWnd, &ps); | |
| GetClientRect(hWnd, &rc); | |
| hbrush = (HBRUSH)SelectObject(hdc, toolwin.access[(count)?1:0]); | |
| PatBlt(hdc, rc.left, rc.top, rc.right, rc.bottom, PATCOPY); | |
| SelectObject(hdc, hbrush); | |
| EndPaint(hWnd, &ps); | |
| } | |
| static LRESULT CALLBACK twsub(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) { | static LRESULT CALLBACK twsub(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) { |
| UINT idc; | UINT idc; |
| Line 228 static LRESULT CALLBACK twsub(HWND hWnd, | Line 258 static LRESULT CALLBACK twsub(HWND hWnd, |
| return(0); | return(0); |
| } | } |
| if (msg == WM_DROPFILES) { | if (msg == WM_DROPFILES) { |
| files = DragQueryFile((HDROP)wp, 0xFFFFFFFF, NULL, 0); | files = DragQueryFile((HDROP)wp, (UINT)-1, NULL, 0); |
| if (files == 1) { | if (files == 1) { |
| DragQueryFile((HDROP)wp, 0, fname, sizeof(fname)); | DragQueryFile((HDROP)wp, 0, fname, sizeof(fname)); |
| if (idc == IDC_TOOLFDD1LIST) { | if (idc == IDC_TOOLFDD1LIST) { |
| Line 243 static LRESULT CALLBACK twsub(HWND hWnd, | Line 273 static LRESULT CALLBACK twsub(HWND hWnd, |
| DragFinish((HDROP)wp); | DragFinish((HDROP)wp); |
| return(FALSE); | return(FALSE); |
| } | } |
| else if (msg == WM_PAINT) { | |
| if (idc == IDC_TOOLHDDACC) { | |
| accdraw(hWnd, toolwin.hddaccess); | |
| return(FALSE); | |
| } | |
| else if (idc == IDC_TOOLFDD1ACC) { | |
| accdraw(hWnd, toolwin.fddaccess[0]); | |
| return(FALSE); | |
| } | |
| else if (idc == IDC_TOOLFDD2ACC) { | |
| accdraw(hWnd, toolwin.fddaccess[1]); | |
| return(FALSE); | |
| } | |
| } | |
| return(CallWindowProc(toolwin.subproc[idc], hWnd, msg, wp, lp)); | return(CallWindowProc(toolwin.subproc[idc], hWnd, msg, wp, lp)); |
| } | } |
| Line 262 const SUBITEM *p; | Line 306 const SUBITEM *p; |
| ReleaseDC(NULL, hdc); | ReleaseDC(NULL, hdc); |
| SelectObject(toolwin.hdcfont, toolwin.hfont); | SelectObject(toolwin.hdcfont, toolwin.hfont); |
| toolwin.access[0] = CreateSolidBrush(0x000060); | |
| toolwin.access[1] = CreateSolidBrush(0x0000ff); | |
| hinstance = ((LPCREATESTRUCT)lp)->hInstance; | hinstance = ((LPCREATESTRUCT)lp)->hInstance; |
| p = subitem; | p = subitem; |
| for (i=0; i<IDC_MAXITEMS; i++) { | for (i=0; i<IDC_MAXITEMS; i++) { |
| Line 288 static void toolwindestroy(void) { | Line 335 static void toolwindestroy(void) { |
| for (i=0; i<IDC_MAXITEMS; i++) { | for (i=0; i<IDC_MAXITEMS; i++) { |
| DestroyWindow(toolwin.sub[i]); | DestroyWindow(toolwin.sub[i]); |
| } | } |
| DeleteObject(toolwin.access[0]); | |
| DeleteObject(toolwin.access[1]); | |
| DeleteObject(toolwin.hdcfont); | DeleteObject(toolwin.hdcfont); |
| DeleteObject(toolwin.hfont); | DeleteObject(toolwin.hfont); |
| } | } |
| Line 385 static void movingproc(RECT *rect) { | Line 434 static void movingproc(RECT *rect) { |
| } | } |
| } | } |
| } | } |
| d = rect->left - workrc.left; | |
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { | |
| break; | |
| } | |
| d = rect->right - workrc.right; | |
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { | |
| break; | |
| } | |
| } while(0); | } while(0); |
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { | if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { |
| toolwin.winflg |= 1; | toolwin.winflg |= 1; |
| Line 427 static void movingproc(RECT *rect) { | Line 484 static void movingproc(RECT *rect) { |
| } | } |
| } | } |
| } | } |
| d = rect->top - workrc.top; | |
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { | |
| break; | |
| } | |
| d = rect->bottom - workrc.bottom; | |
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { | |
| break; | |
| } | |
| } while(0); | } while(0); |
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { | if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { |
| toolwin.winflg |= 2; | toolwin.winflg |= 2; |
| Line 452 static LRESULT CALLBACK twproc(HWND hWnd | Line 517 static LRESULT CALLBACK twproc(HWND hWnd |
| switch(msg) { | switch(msg) { |
| case WM_CREATE: | case WM_CREATE: |
| SetWindowLong(hWnd, GWL_STYLE, | |
| GetWindowLong(hWnd, GWL_STYLE) & (~WS_CAPTION)); | |
| SetWindowPos(hWnd, 0, 0, 0, 0, 0, | |
| SWP_DRAWFRAME | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER); | |
| toolwincreate(hWnd, lp); | toolwincreate(hWnd, lp); |
| break; | break; |
| Line 464 static LRESULT CALLBACK twproc(HWND hWnd | Line 533 static LRESULT CALLBACK twproc(HWND hWnd |
| break; | break; |
| case IDC_BASE + IDC_TOOLFDD1BROWSE: | case IDC_BASE + IDC_TOOLFDD1BROWSE: |
| soundmng_stop(); | |
| dialog_changefdd(hWnd, 0); | dialog_changefdd(hWnd, 0); |
| soundmng_play(); | |
| break; | break; |
| case IDC_BASE + IDC_TOOLFDD1EJECT: | case IDC_BASE + IDC_TOOLFDD1EJECT: |
| Line 479 static LRESULT CALLBACK twproc(HWND hWnd | Line 550 static LRESULT CALLBACK twproc(HWND hWnd |
| break; | break; |
| case IDC_BASE + IDC_TOOLFDD2BROWSE: | case IDC_BASE + IDC_TOOLFDD2BROWSE: |
| soundmng_stop(); | |
| dialog_changefdd(hWnd, 1); | dialog_changefdd(hWnd, 1); |
| soundmng_play(); | |
| break; | break; |
| case IDC_BASE + IDC_TOOLFDD2EJECT: | case IDC_BASE + IDC_TOOLFDD2EJECT: |
| Line 493 static LRESULT CALLBACK twproc(HWND hWnd | Line 566 static LRESULT CALLBACK twproc(HWND hWnd |
| toolwinpaint(hWnd); | toolwinpaint(hWnd); |
| break; | break; |
| case WM_ENTERMENULOOP: | |
| soundmng_stop(); | |
| break; | |
| case WM_EXITMENULOOP: | |
| soundmng_play(); | |
| break; | |
| case WM_ENTERSIZEMOVE: | case WM_ENTERSIZEMOVE: |
| soundmng_stop(); | |
| movingstart(); | movingstart(); |
| break; | break; |
| case WM_EXITSIZEMOVE: | |
| soundmng_play(); | |
| break; | |
| case WM_MOVING: | case WM_MOVING: |
| movingproc((RECT *)lp); | movingproc((RECT *)lp); |
| break; | break; |
| Line 513 static LRESULT CALLBACK twproc(HWND hWnd | Line 599 static LRESULT CALLBACK twproc(HWND hWnd |
| break; | break; |
| case WM_CLOSE: | case WM_CLOSE: |
| xmenu_settoolwin(0); | |
| DestroyWindow(hWnd); | DestroyWindow(hWnd); |
| break; | break; |
| Line 555 void toolwin_open(void) { | Line 642 void toolwin_open(void) { |
| if (toolwin.hwnd) { | if (toolwin.hwnd) { |
| return; | return; |
| } | } |
| ZeroMemory(&toolwin, sizeof(toolwin)); | |
| hWnd = CreateWindowEx(0, np2toolclass, np2tooltitle, WS_SYSMENU, | hWnd = CreateWindowEx(0, np2toolclass, np2tooltitle, WS_SYSMENU, |
| np2tool.posx, np2tool.posy, 410, 52, | np2tool.posx, np2tool.posy, 410, 52, |
| NULL, NULL, hInst, NULL); | NULL, NULL, hInst, NULL); |
| Line 564 void toolwin_open(void) { | Line 652 void toolwin_open(void) { |
| } | } |
| UpdateWindow(hWnd); | UpdateWindow(hWnd); |
| ShowWindow(hWnd, SW_SHOW); | ShowWindow(hWnd, SW_SHOW); |
| SetWindowLong(hWnd, GWL_STYLE, | |
| GetWindowLong(hWnd, GWL_STYLE) & (~WS_CAPTION)); | |
| SetWindowPos(hWnd, 0, 0, 0, 0, 0, | |
| SWP_DRAWFRAME | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER); | |
| } | } |
| void toolwin_close(void) { | void toolwin_close(void) { |
| Line 656 void toolwin_setfdd(BYTE drv, const char | Line 740 void toolwin_setfdd(BYTE drv, const char |
| } | } |
| static void setdiskacc(UINT num, BYTE count) { | |
| const DISKACC *acc; | |
| BYTE counter; | |
| if (toolwin.hwnd == NULL) { | |
| return; | |
| } | |
| if (num < (sizeof(diskacc)/sizeof(DISKACC))) { | |
| acc = diskacc + num; | |
| counter = *(acc->counter); | |
| *(acc->counter) = count; | |
| if (counter) { | |
| InvalidateRect(toolwin.sub[acc->idc], NULL, TRUE); | |
| } | |
| } | |
| } | |
| void toolwin_fddaccess(BYTE drv) { | |
| if (drv < 2) { | |
| setdiskacc(drv, 20); | |
| } | |
| } | |
| void toolwin_hddaccess(BYTE drv) { | |
| setdiskacc(2, 10); | |
| } | |
| void toolwin_draw(BYTE frame) { | |
| const DISKACC *acc; | |
| const DISKACC *accterm; | |
| BYTE counter; | |
| if (toolwin.hwnd == NULL) { | |
| return; | |
| } | |
| if (!frame) { | |
| frame = 1; | |
| } | |
| acc = diskacc; | |
| accterm = acc + (sizeof(diskacc)/sizeof(DISKACC)); | |
| while(acc < accterm) { | |
| counter = *acc->counter; | |
| if (counter) { | |
| if (counter <= frame) { | |
| *(acc->counter) = 0; | |
| InvalidateRect(toolwin.sub[acc->idc], NULL, TRUE); | |
| } | |
| else { | |
| *(acc->counter) -= frame; | |
| } | |
| } | |
| acc++; | |
| } | |
| } | |
| // ---- | // ---- |
| static const char np2toolini[] = "np2tool.ini"; | static const char np2toolini[] = "np2tool.ini"; |