|
|
| version 1.3, 2003/10/29 10:09:37 | version 1.7, 2003/10/30 12:45:38 |
|---|---|
| Line 9 | Line 9 |
| #include "toolwin.h" | #include "toolwin.h" |
| #include "ini.h" | #include "ini.h" |
| #include "dialog.h" | #include "dialog.h" |
| #include "dialogs.h" | |
| #include "pccore.h" | #include "pccore.h" |
| #include "diskdrv.h" | #include "diskdrv.h" |
| #ifdef STRICT | |
| #define SCPROC WNDPROC | |
| #else | |
| #define SCPROC FARPROC | |
| #endif | |
| NP2TOOL np2tool; | |
| static const char np2toolclass[] = "np2-toolwin"; | |
| static const char np2tooltitle[] = "NP2 tool"; | |
| static const char str_deffont[] = "£Í£Ó £Ð¥´¥·¥Ã¥¯"; | |
| static const char str_static[] = "STATIC"; | |
| static const char str_combobox[] = "COMBOBOX"; | |
| static const char str_button[] = "BUTTON"; | |
| static const char str_browse[] = "..."; | |
| static const char str_eject[] = "Eject"; | |
| enum { | enum { |
| IDC_TOOLHDDACC = 0, | IDC_TOOLHDDACC = 0, |
| IDC_TOOLFDD1ACC, | IDC_TOOLFDD1ACC, |
| Line 44 enum { | Line 26 enum { |
| IDC_TOOLFDD2EJECT, | IDC_TOOLFDD2EJECT, |
| IDC_MAXITEMS, | IDC_MAXITEMS, |
| IDC_BASE = 3000 | IDC_BASE = 3000, |
| IDC_SKINDEF = 3100, | |
| IDC_SKINSEL = 3101, | |
| IDC_TOOLCLOSE = 3102 | |
| }; | }; |
| typedef struct { | typedef struct { |
| char main[MAX_PATH]; | |
| char font[64]; | |
| SINT32 fontsize; | |
| UINT32 color1; | |
| UINT32 color2; | |
| } TOOLSKIN; | |
| typedef struct { | |
| const char *cname; | const char *cname; |
| const char *text; | const char *text; |
| DWORD style; | DWORD style; |
| DWORD exstyle; | |
| short posx; | short posx; |
| short posy; | short posy; |
| short width; | short width; |
| short height; | short height; |
| BOOL tabstop; | |
| } SUBITEM; | } SUBITEM; |
| static const BYTE fddlist[FDDLIST_DRV] = { | |
| IDC_TOOLFDD1LIST, IDC_TOOLFDD2LIST}; | |
| static const SUBITEM subitem[IDC_MAXITEMS] = { | |
| {str_static, NULL, WS_VISIBLE, 0, 49, 44, 8, 3}, | |
| {str_static, NULL, WS_VISIBLE, 0, 93, 19, 8, 3}, | |
| {str_combobox, NULL, | |
| WS_VISIBLE | CBS_DROPDOWNLIST | WS_VSCROLL, 0, 104, 6, 248, 160}, | |
| {str_button, str_browse, | |
| WS_VISIBLE | BS_PUSHBUTTON, 0, 352, 7, 18, 17}, | |
| {str_button, str_eject, | |
| WS_VISIBLE | BS_PUSHBUTTON, 0, 370, 7, 34, 17}, | |
| {str_static, NULL, WS_VISIBLE, 0, 93, 41, 8, 3}, | |
| {str_combobox, NULL, | |
| WS_VISIBLE | CBS_DROPDOWNLIST | WS_VSCROLL, 0, 104, 28, 248, 160}, | |
| {str_button, str_browse, | |
| WS_VISIBLE | BS_PUSHBUTTON, 0, 352, 29, 18, 17}, | |
| {str_button, str_eject, | |
| WS_VISIBLE | BS_PUSHBUTTON, 0, 370, 29, 34, 17}, | |
| }; | |
| // static const DWORD mvccol[MVC_MAXCOLOR] = { | |
| // 0xc0e8f8, 0xd8ecf4, 0x48a8c8, 0x000000}; | |
| typedef struct { | typedef struct { |
| HWND hwnd; | HWND hwnd; |
| BYTE fddaccess[2]; | HBITMAP hbmp; |
| BYTE hddaccess; | BYTE fddaccess[2]; |
| BYTE _padding; | BYTE hddaccess; |
| int winflg; | BYTE _padding; |
| int wingx; | int winflg; |
| int wingy; | int wingx; |
| int wintx; | int wingy; |
| int winty; | int wintx; |
| int parentcn; | int winty; |
| int parentx; | UINT parentcn; |
| int parenty; | int parentx; |
| HFONT hfont; | int parenty; |
| HDC hdcfont; | HFONT hfont; |
| HBRUSH access[2]; | HDC hdcfont; |
| HWND sub[IDC_MAXITEMS]; | HBRUSH access[2]; |
| SCPROC subproc[IDC_MAXITEMS]; | HWND sub[IDC_MAXITEMS]; |
| SUBCLASSPROC subproc[IDC_MAXITEMS]; | |
| } TOOLWIN; | } TOOLWIN; |
| NP2TOOL np2tool; | |
| static TOOLSKIN toolskin; | |
| static SUBITEM subitem[IDC_MAXITEMS]; | |
| static TOOLWIN toolwin; | static TOOLWIN toolwin; |
| #include "toolwin.res" | |
| typedef struct { | typedef struct { |
| WORD idc; | WORD idc; |
| BYTE *counter; | BYTE *counter; |
| } DISKACC; | } DISKACC; |
| static const BYTE fddlist[FDDLIST_DRV] = { | |
| IDC_TOOLFDD1LIST, IDC_TOOLFDD2LIST}; | |
| static const DISKACC diskacc[3] = { | static const DISKACC diskacc[3] = { |
| {IDC_TOOLFDD1ACC, &toolwin.fddaccess[0]}, | {IDC_TOOLFDD1ACC, &toolwin.fddaccess[0]}, |
| {IDC_TOOLFDD2ACC, &toolwin.fddaccess[1]}, | {IDC_TOOLFDD2ACC, &toolwin.fddaccess[1]}, |
| {IDC_TOOLHDDACC, &toolwin.hddaccess}}; | {IDC_TOOLHDDACC, &toolwin.hddaccess}}; |
| // ---- | |
| static HBITMAP skinload(const char *path) { | |
| char fname[MAX_PATH]; | |
| HBITMAP ret; | |
| ZeroMemory(&toolskin, sizeof(toolskin)); | |
| toolskin.fontsize = 12; | |
| milstr_ncpy(toolskin.font, str_deffont, sizeof(toolskin.font)); | |
| toolskin.color1 = 0x600000; | |
| toolskin.color2 = 0xff0000; | |
| CopyMemory(subitem, defsubitem, sizeof(defsubitem)); | |
| if (path) { | |
| ini_read(path, skintitle, skinini, sizeof(skinini)/sizeof(INITBL)); | |
| } | |
| if ((path) && (toolskin.main[0])) { | |
| milstr_ncpy(fname, path, sizeof(fname)); | |
| file_cutname(fname); | |
| file_catname(fname, toolskin.main, sizeof(fname)); | |
| ret = (HBITMAP)LoadImage(hInst, fname, IMAGE_BITMAP, | |
| 0, 0, LR_LOADFROMFILE); | |
| if (ret != NULL) { | |
| return(ret); | |
| } | |
| } | |
| return(LoadBitmap(hInst, "NP2TOOL")); | |
| } | |
| // ---- | |
| 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; |
| Line 163 static void calctextsize(char *path, int | Line 177 static void calctextsize(char *path, int |
| milstr_ncat(path, work, leng); | milstr_ncat(path, work, leng); |
| } | } |
| static void setlist(UINT drv) { | static void setlist(HWND hwnd, const TOOLFDD *fdd, UINT sel) { |
| HWND hwnd; | |
| RECT rc; | RECT rc; |
| int width; | int width; |
| TOOLFDD *fdd; | |
| char *p; | |
| UINT i; | |
| char basedir[MAX_PATH]; | char basedir[MAX_PATH]; |
| UINT i; | |
| const char *p; | |
| char dir[MAX_PATH]; | char dir[MAX_PATH]; |
| char *q; | const char *q; |
| if (drv >= FDDLIST_DRV) { | SendMessage(hwnd, CB_RESETCONTENT, (WPARAM)0, (LPARAM)0); |
| return; | |
| } | |
| hwnd = toolwin.sub[fddlist[drv]]; | |
| GetClientRect(hwnd, &rc); | GetClientRect(hwnd, &rc); |
| width = rc.right - rc.left - 6; // border size? | width = rc.right - rc.left - 6; // border size? |
| SendMessage(hwnd, CB_RESETCONTENT, (WPARAM)0, (LPARAM)0); | |
| fdd = np2tool.fdd + drv; | |
| p = fdd->name[0]; | |
| basedir[0] = '\0'; | basedir[0] = '\0'; |
| if (fdd->insert) { | if (sel < fdd->cnt) { |
| milstr_ncpy(basedir, p, sizeof(basedir)); | milstr_ncpy(basedir, fdd->name[fdd->pos[sel]], sizeof(basedir)); |
| file_cutname(basedir); | file_cutname(basedir); |
| } | } |
| for (i=0; i<FDDLIST_MAX; i++) { | for (i=0; i<fdd->cnt; i++) { |
| if (p[0] == '\0') { | p = fdd->name[fdd->pos[i]]; |
| break; | |
| } | |
| milstr_ncpy(dir, p, sizeof(dir)); | milstr_ncpy(dir, p, sizeof(dir)); |
| file_cutname(dir); | file_cutname(dir); |
| if (!file_cmpname(basedir, dir)) { | if (!file_cmpname(basedir, dir)) { |
| q = file_getname(p); | q = file_getname((char *)p); |
| } | } |
| else { | else { |
| calctextsize(dir, sizeof(dir), p, width); | calctextsize(dir, sizeof(dir), p, width); |
| Line 205 static void setlist(UINT drv) { | Line 209 static void setlist(UINT drv) { |
| SendMessage(hwnd, CB_INSERTSTRING, (WPARAM)i, (LPARAM)q); | SendMessage(hwnd, CB_INSERTSTRING, (WPARAM)i, (LPARAM)q); |
| p += sizeof(fdd->name[0]); | p += sizeof(fdd->name[0]); |
| } | } |
| if (fdd->insert) { | if (sel < fdd->cnt) { |
| SendMessage(hwnd, CB_SETCURSEL, (WPARAM)0, (LPARAM)0); | SendMessage(hwnd, CB_SETCURSEL, (WPARAM)sel, (LPARAM)0); |
| } | } |
| } | } |
| static void sellist(UINT drv) { | static void sellist(UINT drv) { |
| HWND hwnd; | HWND hwnd; |
| TOOLFDD *fdd; | |
| UINT sel; | UINT sel; |
| char path[MAX_PATH]; | |
| if (drv >= FDDLIST_DRV) { | if (drv >= FDDLIST_DRV) { |
| return; | return; |
| } | } |
| hwnd = toolwin.sub[fddlist[drv]]; | hwnd = toolwin.sub[fddlist[drv]]; |
| fdd = np2tool.fdd + drv; | |
| sel = (UINT)SendMessage(hwnd, CB_GETCURSEL, 0, 0); | sel = (UINT)SendMessage(hwnd, CB_GETCURSEL, 0, 0); |
| if (sel < FDDLIST_MAX) { | if (sel < fdd->cnt) { |
| milstr_ncpy(path, np2tool.fdd[drv].name[sel], sizeof(path)); | diskdrv_setfdd(drv, fdd->name[fdd->pos[sel]], 0); |
| diskdrv_setfdd(drv, path, 0); | fdd->insert = 1; |
| toolwin_setfdd(drv, path); | setlist(hwnd, fdd, sel); |
| } | } |
| } | } |
| static void remakefddlist(UINT drv) { | |
| TOOLFDD *fdd; | |
| char *p; | |
| UINT cnt; | |
| char *q; | |
| char *fname[FDDLIST_MAX]; | |
| UINT i; | |
| UINT j; | |
| UINT sel; | |
| if (drv >= FDDLIST_DRV) { | |
| return; | |
| } | |
| fdd = np2tool.fdd + drv; | |
| p = fdd->name[0]; | |
| for (cnt=0; cnt<FDDLIST_MAX; cnt++) { | |
| if (p[0] == '\0') { | |
| break; | |
| } | |
| q = file_getname(p); | |
| fname[cnt] = q; | |
| for (i=0; i<cnt; i++) { | |
| if (file_cmpname(q, fname[fdd->pos[i]]) < 0) { | |
| break; | |
| } | |
| } | |
| for (j=cnt; j>i; j--) { | |
| fdd->pos[j] = fdd->pos[j-1]; | |
| } | |
| fdd->pos[i] = cnt; | |
| p += sizeof(fdd->name[0]); | |
| } | |
| fdd->cnt = cnt; | |
| sel = (UINT)-1; | |
| if (fdd->insert) { | |
| for (i=0; i<cnt; i++) { | |
| if (fdd->pos[i] == 0) { | |
| sel = i; | |
| break; | |
| } | |
| } | |
| } | |
| setlist(toolwin.sub[fddlist[drv]], fdd, sel); | |
| } | |
| static void accdraw(HWND hWnd, BYTE count) { | static void accdraw(HWND hWnd, BYTE count) { |
| HDC hdc; | HDC hdc; |
| Line 246 static void accdraw(HWND hWnd, BYTE coun | Line 297 static void accdraw(HWND hWnd, BYTE coun |
| 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; |
| int dir; | |
| UINT newidc; | |
| int files; | int files; |
| char fname[MAX_PATH]; | char fname[MAX_PATH]; |
| Line 257 static LRESULT CALLBACK twsub(HWND hWnd, | Line 310 static LRESULT CALLBACK twsub(HWND hWnd, |
| if (idc >= IDC_MAXITEMS) { | if (idc >= IDC_MAXITEMS) { |
| return(0); | return(0); |
| } | } |
| if (msg == WM_DROPFILES) { | if (msg == WM_KEYDOWN) { |
| if ((TCHAR)wp == VK_TAB) { | |
| dir = (GetKeyState(VK_SHIFT) >= 0)?1:-1; | |
| newidc = idc; | |
| do { | |
| newidc += dir; | |
| if (newidc >= IDC_MAXITEMS) { | |
| newidc = (dir >= 0)?0:(IDC_MAXITEMS - 1); | |
| } | |
| if (subitem[newidc].tabstop) { | |
| SetFocus(toolwin.sub[newidc]); | |
| break; | |
| } | |
| } while(idc != newidc); | |
| } | |
| else if ((TCHAR)wp == VK_RETURN) { | |
| if (subitem[idc].cname == str_button) { | |
| return(CallWindowProc(toolwin.subproc[idc], | |
| hWnd, WM_KEYDOWN, VK_SPACE, 0)); | |
| } | |
| } | |
| } | |
| else if (msg == WM_DROPFILES) { | |
| files = DragQueryFile((HDROP)wp, (UINT)-1, 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)); |
| Line 290 static LRESULT CALLBACK twsub(HWND hWnd, | Line 365 static LRESULT CALLBACK twsub(HWND hWnd, |
| return(CallWindowProc(toolwin.subproc[idc], hWnd, msg, wp, lp)); | return(CallWindowProc(toolwin.subproc[idc], hWnd, msg, wp, lp)); |
| } | } |
| static void toolwincreate(HWND hWnd, LPARAM lp) { | static void toolwincreate(HWND hWnd) { |
| HDC hdc; | HDC hdc; |
| HINSTANCE hinstance; | |
| const SUBITEM *p; | const SUBITEM *p; |
| UINT i; | UINT i; |
| HWND sub; | HWND sub; |
| toolwin.hfont = CreateFont(12, 0, 0, 0, 0, 0, 0, 0, | toolwin.hfont = CreateFont(toolskin.fontsize, 0, 0, 0, 0, 0, 0, 0, |
| SHIFTJIS_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, | SHIFTJIS_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, |
| DEFAULT_QUALITY, FIXED_PITCH, str_deffont); | DEFAULT_QUALITY, FIXED_PITCH, toolskin.font); |
| hdc = GetDC(NULL); | hdc = GetDC(NULL); |
| toolwin.hdcfont = CreateCompatibleDC(hdc); | toolwin.hdcfont = CreateCompatibleDC(hdc); |
| ReleaseDC(NULL, hdc); | ReleaseDC(NULL, hdc); |
| Line 309 const SUBITEM *p; | Line 383 const SUBITEM *p; |
| toolwin.access[0] = CreateSolidBrush(0x000060); | toolwin.access[0] = CreateSolidBrush(0x000060); |
| toolwin.access[1] = CreateSolidBrush(0x0000ff); | toolwin.access[1] = CreateSolidBrush(0x0000ff); |
| hinstance = ((LPCREATESTRUCT)lp)->hInstance; | |
| p = subitem; | p = subitem; |
| for (i=0; i<IDC_MAXITEMS; i++) { | for (i=0; i<IDC_MAXITEMS; i++) { |
| sub = CreateWindowEx(p->exstyle, p->cname, p->text, | sub = CreateWindow(p->cname, p->text, |
| WS_CHILD | p->style, p->posx, p->posy, p->width, p->height, | WS_CHILD | p->style, p->posx, p->posy, p->width, p->height, |
| hWnd, (HMENU)(i + IDC_BASE), hinstance, NULL); | hWnd, (HMENU)(i + IDC_BASE), hInst, NULL); |
| toolwin.sub[i] = sub; | toolwin.sub[i] = sub; |
| toolwin.subproc[i] = (SCPROC)GetWindowLong(sub, GWL_WNDPROC); | toolwin.subproc[i] = (SUBCLASSPROC)GetWindowLong(sub, GWL_WNDPROC); |
| SetWindowLong(sub, GWL_WNDPROC, (LONG)twsub); | SetWindowLong(sub, GWL_WNDPROC, (LONG)twsub); |
| SendMessage(sub, WM_SETFONT, (WPARAM)toolwin.hfont, | SendMessage(sub, WM_SETFONT, (WPARAM)toolwin.hfont, |
| MAKELPARAM(TRUE, 0)); | MAKELPARAM(TRUE, 0)); |
| Line 324 const SUBITEM *p; | Line 397 const SUBITEM *p; |
| } | } |
| for (i=0; i<FDDLIST_DRV; i++) { | for (i=0; i<FDDLIST_DRV; i++) { |
| DragAcceptFiles(toolwin.sub[fddlist[i]], TRUE); | DragAcceptFiles(toolwin.sub[fddlist[i]], TRUE); |
| setlist((BYTE)i); | remakefddlist((BYTE)i); |
| } | } |
| } | } |
| Line 332 static void toolwindestroy(void) { | Line 405 static void toolwindestroy(void) { |
| UINT i; | UINT i; |
| for (i=0; i<IDC_MAXITEMS; i++) { | if (toolwin.hbmp) { |
| DestroyWindow(toolwin.sub[i]); | for (i=0; i<IDC_MAXITEMS; i++) { |
| DestroyWindow(toolwin.sub[i]); | |
| } | |
| DeleteObject(toolwin.access[0]); | |
| DeleteObject(toolwin.access[1]); | |
| DeleteObject(toolwin.hdcfont); | |
| DeleteObject(toolwin.hfont); | |
| DeleteObject(toolwin.hbmp); | |
| toolwin.hbmp = NULL; | |
| } | } |
| DeleteObject(toolwin.access[0]); | |
| DeleteObject(toolwin.access[1]); | |
| DeleteObject(toolwin.hdcfont); | |
| DeleteObject(toolwin.hfont); | |
| } | } |
| static void toolwinpaint(HWND hWnd) { | static void toolwinpaint(HWND hWnd) { |
| HDC hdc; | HDC hdc; |
| PAINTSTRUCT ps; | PAINTSTRUCT ps; |
| HINSTANCE hinst; | |
| HBITMAP hbmp; | |
| BITMAP bmp; | BITMAP bmp; |
| HDC hmdc; | HDC hmdc; |
| hdc = BeginPaint(hWnd, &ps); | hdc = BeginPaint(hWnd, &ps); |
| hinst = (HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE); | if (toolwin.hbmp) { |
| hbmp = LoadBitmap(hinst, "NP2TOOL"); | GetObject(toolwin.hbmp, sizeof(BITMAP), &bmp); |
| GetObject(hbmp, sizeof(BITMAP), &bmp); | hmdc = CreateCompatibleDC(hdc); |
| hmdc = CreateCompatibleDC(hdc); | SelectObject(hmdc, toolwin.hbmp); |
| SelectObject(hmdc, hbmp); | BitBlt(hdc, 0, 0, bmp.bmWidth, bmp.bmHeight, hmdc, 0, 0, SRCCOPY); |
| BitBlt(hdc, 0, 0, bmp.bmWidth, bmp.bmHeight, hmdc, 0, 0, SRCCOPY); | DeleteDC(hmdc); |
| DeleteDC(hmdc); | } |
| DeleteObject(hbmp); | |
| EndPaint(hWnd, &ps); | EndPaint(hWnd, &ps); |
| } | } |
| static void changeskin(HWND hWnd) { | |
| HBITMAP hbmp; | |
| BITMAP bmp; | |
| toolwin_movingstart(); | |
| toolwindestroy(); | |
| hbmp = skinload(np2tool.skin); | |
| if (hbmp == NULL) { | |
| SendMessage(hWnd, WM_CLOSE, 0, 0); | |
| return; | |
| } | |
| GetObject(hbmp, sizeof(BITMAP), &bmp); | |
| toolwin.hbmp = hbmp; | |
| MoveWindow(hWnd, np2tool.posx, np2tool.posy, | |
| bmp.bmWidth, bmp.bmHeight, TRUE); | |
| toolwincreate(hWnd); | |
| toolwin_movingend(); | |
| } | |
| // ---- moving | // ---- moving |
| Line 381 static void movingproc(RECT *rect) { | Line 475 static void movingproc(RECT *rect) { |
| RECT workrc; | RECT workrc; |
| RECT mainrc; | RECT mainrc; |
| int winlx, winly; | int winlx; |
| int winly; | |
| BOOL changes; | |
| BOOL connectx; | BOOL connectx; |
| BOOL connecty; | BOOL connecty; |
| int d; | int d; |
| Line 396 static void movingproc(RECT *rect) { | Line 492 static void movingproc(RECT *rect) { |
| return; | return; |
| } | } |
| if (toolwin.winflg & 0x03) { | |
| toolwin.wingx += rect->left - toolwin.wintx; | |
| rect->left = toolwin.wintx; | |
| if ((toolwin.wingx >= SNAPDOTREL) || (toolwin.wingx <= -SNAPDOTREL)) { | |
| toolwin.winflg &= ~0x03; | |
| rect->left += toolwin.wingx; | |
| toolwin.wingx = 0; | |
| } | |
| rect->right = rect->left + winlx; | |
| } | |
| if (toolwin.winflg & 0x0c) { | |
| toolwin.wingy += rect->top - toolwin.winty; | |
| rect->top = toolwin.winty; | |
| if ((toolwin.wingy >= SNAPDOTREL) || (toolwin.wingy <= -SNAPDOTREL)) { | |
| toolwin.winflg &= ~0x0c; | |
| rect->top += toolwin.wingy; | |
| toolwin.wingy = 0; | |
| } | |
| rect->bottom = rect->top + winly; | |
| } | |
| connectx = ((rect->right >= mainrc.left) && (rect->left <= mainrc.right)); | connectx = ((rect->right >= mainrc.left) && (rect->left <= mainrc.right)); |
| connecty = ((rect->bottom >= mainrc.top) && (rect->top <= mainrc.bottom)); | connecty = ((rect->bottom >= mainrc.top) && (rect->top <= mainrc.bottom)); |
| if ((toolwin.winflg & 3) && (!connectx) && (!connecty)) { | if ((!connectx) || (!connecty)) { |
| toolwin.winflg &= ~3; | if (toolwin.winflg & 0x01) { |
| rect->left += toolwin.wingx; | toolwin.winflg &= ~0x01; |
| rect->top += toolwin.wingy; | rect->left += toolwin.wingx; |
| toolwin.wingx = 0; | rect->right = rect->left + winlx; |
| toolwin.wingy = 0; | toolwin.wingx = 0; |
| } | |
| if (toolwin.winflg & 0x04) { | |
| toolwin.winflg &= ~0x04; | |
| rect->top += toolwin.wingy; | |
| rect->bottom = rect->top + winly; | |
| toolwin.wingy = 0; | |
| } | |
| } | } |
| if (toolwin.winflg & 1) { | do { |
| toolwin.wingx += rect->left - toolwin.wintx; | changes = FALSE; |
| rect->left = toolwin.wintx; | if ((!(toolwin.winflg & 0x01)) && |
| } | (rect->bottom >= mainrc.top) && (rect->top <= mainrc.bottom)) { |
| else { | do { |
| d = SNAPDOTPULL; | d = rect->left - mainrc.right; |
| do { | |
| if (connecty) { | |
| d = rect->right - mainrc.left; | |
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { | if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { |
| break; | break; |
| } | } |
| d = rect->left - mainrc.right; | d = rect->right - mainrc.left; |
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { | if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { |
| break; | break; |
| } | } |
| Line 433 static void movingproc(RECT *rect) { | Line 554 static void movingproc(RECT *rect) { |
| break; | break; |
| } | } |
| } | } |
| } | } while(0); |
| d = rect->left - workrc.left; | |
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { | if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { |
| break; | toolwin.winflg |= 0x01; |
| rect->left -= d; | |
| rect->right = rect->left + winlx; | |
| toolwin.wingx = d; | |
| toolwin.wintx = rect->left; | |
| changes = TRUE; | |
| } | } |
| d = rect->right - workrc.right; | } |
| if (!(toolwin.winflg & 0x03)) { | |
| do { | |
| d = rect->left - workrc.left; | |
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { | |
| break; | |
| } | |
| d = rect->right - workrc.right; | |
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { | |
| break; | |
| } | |
| } while(0); | |
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { | if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { |
| break; | toolwin.winflg |= 0x02; |
| rect->left -= d; | |
| rect->right = rect->left + winlx; | |
| toolwin.wingx = d; | |
| toolwin.wintx = rect->left; | |
| changes = TRUE; | |
| } | } |
| } while(0); | |
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { | |
| toolwin.winflg |= 1; | |
| rect->left -= d; | |
| toolwin.wingx = d; | |
| toolwin.wintx = rect->left; | |
| } | } |
| } | |
| if ((toolwin.wingx >= SNAPDOTREL) || (toolwin.wingx <= -SNAPDOTREL)) { | |
| toolwin.winflg &= ~1; | |
| rect->left += toolwin.wingx; | |
| toolwin.wingx = 0; | |
| } | |
| if (toolwin.winflg & 2) { | if ((!(toolwin.winflg & 0x04)) && |
| toolwin.wingy += rect->top - toolwin.winty; | (rect->right >= mainrc.left) && (rect->left <= mainrc.right)) { |
| rect->top = toolwin.winty; | do { |
| } | d = rect->top - mainrc.bottom; |
| else { | |
| d = SNAPDOTPULL; | |
| do { | |
| if (connectx) { | |
| d = rect->bottom - mainrc.top; | |
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { | if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { |
| break; | break; |
| } | } |
| d = rect->top - mainrc.bottom; | d = rect->bottom - mainrc.top; |
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { | if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { |
| break; | break; |
| } | } |
| Line 483 static void movingproc(RECT *rect) { | Line 607 static void movingproc(RECT *rect) { |
| break; | break; |
| } | } |
| } | } |
| } | } while(0); |
| d = rect->top - workrc.top; | |
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { | if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { |
| break; | toolwin.winflg |= 0x04; |
| rect->top -= d; | |
| rect->bottom = rect->top + winly; | |
| toolwin.wingy = d; | |
| toolwin.winty = rect->top; | |
| changes = TRUE; | |
| } | } |
| d = rect->bottom - workrc.bottom; | } |
| if (!(toolwin.winflg & 0x0c)) { | |
| do { | |
| d = rect->top - workrc.top; | |
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { | |
| break; | |
| } | |
| d = rect->bottom - workrc.bottom; | |
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { | |
| break; | |
| } | |
| } while(0); | |
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { | if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { |
| break; | toolwin.winflg |= 0x08; |
| rect->top -= d; | |
| rect->bottom = rect->top + winly; | |
| toolwin.wingy = d; | |
| toolwin.winty = rect->top; | |
| changes = TRUE; | |
| } | } |
| } while(0); | } |
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { | } while(changes); |
| toolwin.winflg |= 2; | |
| rect->top -= d; | |
| toolwin.wingy = d; | |
| toolwin.winty = rect->top; | |
| } | |
| } | |
| if ((toolwin.wingy >= SNAPDOTREL) || (toolwin.wingy <= -SNAPDOTREL)) { | |
| toolwin.winflg &= ~2; | |
| rect->top += toolwin.wingy; | |
| toolwin.wingy = 0; | |
| } | |
| rect->right = rect->left + winlx; | |
| rect->bottom = rect->top + winly; | |
| } | } |
| // ---- | // ---- |
| static void open_popup(HWND hWnd, LPARAM lp) { | |
| HMENU hMenu; | |
| POINT pt; | |
| hMenu = CreatePopupMenu(); | |
| AppendMenu(hMenu, MF_STRING, IDC_SKINDEF, str_skindef); | |
| AppendMenu(hMenu, MF_STRING, IDC_SKINSEL, str_skinsel); | |
| AppendMenu(hMenu, MF_SEPARATOR, 0, NULL); | |
| AppendMenu(hMenu, MF_STRING, IDC_TOOLCLOSE, str_toolclose); | |
| pt.x = LOWORD(lp); | |
| pt.y = HIWORD(lp); | |
| ClientToScreen(hWnd, &pt); | |
| TrackPopupMenu(hMenu, TPM_LEFTALIGN, pt.x, pt.y, 0, hWnd, NULL); | |
| DestroyMenu(hMenu); | |
| } | |
| static LRESULT CALLBACK twproc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) { | static LRESULT CALLBACK twproc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) { |
| BOOL r; | |
| switch(msg) { | switch(msg) { |
| case WM_CREATE: | case WM_CREATE: |
| SetWindowLong(hWnd, GWL_STYLE, | SetWindowLong(hWnd, GWL_STYLE, |
| GetWindowLong(hWnd, GWL_STYLE) & (~WS_CAPTION)); | GetWindowLong(hWnd, GWL_STYLE) & (~WS_CAPTION)); |
| SetWindowPos(hWnd, 0, 0, 0, 0, 0, | SetWindowPos(hWnd, 0, 0, 0, 0, 0, |
| SWP_DRAWFRAME | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER); | SWP_DRAWFRAME | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER); |
| toolwincreate(hWnd, lp); | toolwincreate(hWnd); |
| break; | |
| case WM_SYSCOMMAND: | |
| switch(wp) { | |
| case IDC_SKINDEF: | |
| np2tool.skin[0] = '\0'; | |
| changeskin(hWnd); | |
| sysmng_update(SYS_UPDATEOSCFG); | |
| break; | |
| case IDC_SKINSEL: | |
| soundmng_disable(SNDPROC_TOOL); | |
| r = dlgs_selectfile(hWnd, &skinui, np2tool.skin, | |
| sizeof(np2tool.skin), NULL); | |
| soundmng_enable(SNDPROC_TOOL); | |
| if (r) { | |
| changeskin(hWnd); | |
| sysmng_update(SYS_UPDATEOSCFG); | |
| } | |
| break; | |
| default: | |
| return(DefWindowProc(hWnd, msg, wp, lp)); | |
| } | |
| break; | break; |
| case WM_COMMAND: | case WM_COMMAND: |
| Line 533 static LRESULT CALLBACK twproc(HWND hWnd | Line 706 static LRESULT CALLBACK twproc(HWND hWnd |
| break; | break; |
| case IDC_BASE + IDC_TOOLFDD1BROWSE: | case IDC_BASE + IDC_TOOLFDD1BROWSE: |
| soundmng_stop(); | soundmng_disable(SNDPROC_TOOL); |
| dialog_changefdd(hWnd, 0); | dialog_changefdd(hWnd, 0); |
| soundmng_play(); | soundmng_enable(SNDPROC_TOOL); |
| break; | break; |
| case IDC_BASE + IDC_TOOLFDD1EJECT: | case IDC_BASE + IDC_TOOLFDD1EJECT: |
| Line 550 static LRESULT CALLBACK twproc(HWND hWnd | Line 723 static LRESULT CALLBACK twproc(HWND hWnd |
| break; | break; |
| case IDC_BASE + IDC_TOOLFDD2BROWSE: | case IDC_BASE + IDC_TOOLFDD2BROWSE: |
| soundmng_stop(); | soundmng_disable(SNDPROC_TOOL); |
| dialog_changefdd(hWnd, 1); | dialog_changefdd(hWnd, 1); |
| soundmng_play(); | soundmng_enable(SNDPROC_TOOL); |
| break; | break; |
| case IDC_BASE + IDC_TOOLFDD2EJECT: | case IDC_BASE + IDC_TOOLFDD2EJECT: |
| diskdrv_setfdd(1, NULL, 0); | diskdrv_setfdd(1, NULL, 0); |
| toolwin_setfdd(1, NULL); | toolwin_setfdd(1, NULL); |
| break; | break; |
| case IDC_SKINDEF: | |
| case IDC_SKINSEL: | |
| SendMessage(hWnd, WM_SYSCOMMAND, wp, lp); | |
| break; | |
| case IDC_TOOLCLOSE: | |
| SendMessage(hWnd, WM_CLOSE, 0, 0); | |
| break; | |
| } | } |
| break; | break; |
| Line 567 static LRESULT CALLBACK twproc(HWND hWnd | Line 749 static LRESULT CALLBACK twproc(HWND hWnd |
| break; | break; |
| case WM_ENTERMENULOOP: | case WM_ENTERMENULOOP: |
| soundmng_stop(); | soundmng_disable(SNDPROC_TOOL); |
| break; | break; |
| case WM_EXITMENULOOP: | case WM_EXITMENULOOP: |
| soundmng_play(); | soundmng_enable(SNDPROC_TOOL); |
| break; | break; |
| case WM_ENTERSIZEMOVE: | case WM_ENTERSIZEMOVE: |
| soundmng_stop(); | soundmng_disable(SNDPROC_TOOL); |
| movingstart(); | movingstart(); |
| break; | break; |
| case WM_EXITSIZEMOVE: | case WM_EXITSIZEMOVE: |
| soundmng_play(); | soundmng_enable(SNDPROC_TOOL); |
| break; | break; |
| case WM_MOVING: | case WM_MOVING: |
| Line 600 static LRESULT CALLBACK twproc(HWND hWnd | Line 782 static LRESULT CALLBACK twproc(HWND hWnd |
| case WM_CLOSE: | case WM_CLOSE: |
| xmenu_settoolwin(0); | xmenu_settoolwin(0); |
| sysmng_update(SYS_UPDATEOSCFG); | |
| DestroyWindow(hWnd); | DestroyWindow(hWnd); |
| break; | break; |
| Line 612 static LRESULT CALLBACK twproc(HWND hWnd | Line 795 static LRESULT CALLBACK twproc(HWND hWnd |
| SendMessage(hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0L); | SendMessage(hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0L); |
| break; | break; |
| case WM_RBUTTONDOWN: | |
| open_popup(hWnd, lp); | |
| break; | |
| default: | default: |
| return(DefWindowProc(hWnd, msg, wp, lp)); | return(DefWindowProc(hWnd, msg, wp, lp)); |
| } | } |
| Line 622 BOOL toolwin_initapp(HINSTANCE hInstance | Line 809 BOOL toolwin_initapp(HINSTANCE hInstance |
| WNDCLASS wc; | WNDCLASS wc; |
| wc.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS; | wc.style = CS_HREDRAW | CS_VREDRAW; |
| wc.lpfnWndProc = twproc; | wc.lpfnWndProc = twproc; |
| wc.cbClsExtra = 0; | wc.cbClsExtra = 0; |
| wc.cbWndExtra = 0; | wc.cbWndExtra = 0; |
| Line 637 BOOL toolwin_initapp(HINSTANCE hInstance | Line 824 BOOL toolwin_initapp(HINSTANCE hInstance |
| void toolwin_open(void) { | void toolwin_open(void) { |
| HBITMAP hbmp; | |
| BITMAP bmp; | |
| HWND hWnd; | HWND hWnd; |
| HMENU hMenu; | |
| if (toolwin.hwnd) { | if (toolwin.hwnd) { |
| return; | return; |
| } | } |
| ZeroMemory(&toolwin, sizeof(toolwin)); | ZeroMemory(&toolwin, sizeof(toolwin)); |
| hWnd = CreateWindowEx(0, np2toolclass, np2tooltitle, WS_SYSMENU, | hbmp = skinload(np2tool.skin); |
| np2tool.posx, np2tool.posy, 410, 52, | if (hbmp == NULL) { |
| goto twope_err1; | |
| } | |
| GetObject(hbmp, sizeof(BITMAP), &bmp); | |
| toolwin.hbmp = hbmp; | |
| hWnd = CreateWindow(np2toolclass, np2tooltitle, WS_SYSMENU, | |
| np2tool.posx, np2tool.posy, | |
| bmp.bmWidth, bmp.bmHeight, | |
| NULL, NULL, hInst, NULL); | NULL, NULL, hInst, NULL); |
| toolwin.hwnd = hWnd; | toolwin.hwnd = hWnd; |
| if (hWnd == NULL) { | if (hWnd == NULL) { |
| return; | goto twope_err2; |
| } | } |
| UpdateWindow(hWnd); | UpdateWindow(hWnd); |
| ShowWindow(hWnd, SW_SHOW); | ShowWindow(hWnd, SW_SHOW); |
| hMenu = GetSystemMenu(hWnd, FALSE); | |
| InsertMenu(hMenu, 0, MF_BYPOSITION | MF_STRING, IDC_SKINDEF, str_skindef); | |
| InsertMenu(hMenu, 1, MF_BYPOSITION | MF_STRING, IDC_SKINSEL, str_skinsel); | |
| InsertMenu(hMenu, 2, MF_BYPOSITION | MF_SEPARATOR, 0, NULL); | |
| SetForegroundWindow(hWndMain); | |
| return; | |
| twope_err2: | |
| DeleteObject(hbmp); | |
| twope_err1: | |
| xmenu_settoolwin(0); | |
| sysmng_update(SYS_UPDATEOSCFG); | |
| return; | |
| } | } |
| void toolwin_close(void) { | void toolwin_close(void) { |
| Line 665 void toolwin_movingstart(void) { | Line 877 void toolwin_movingstart(void) { |
| RECT mainrc; | RECT mainrc; |
| RECT toolrc; | RECT toolrc; |
| UINT connect; | |
| if (toolwin.hwnd == NULL) { | if (toolwin.hwnd == NULL) { |
| return; | return; |
| } | } |
| GetWindowRect(hWndMain, &mainrc); | GetWindowRect(hWndMain, &mainrc); |
| GetWindowRect(toolwin.hwnd, &toolrc); | GetWindowRect(toolwin.hwnd, &toolrc); |
| if (((toolrc.right >= mainrc.left) && (toolrc.left <= mainrc.right) && | connect = 0; |
| ((toolrc.bottom == mainrc.top) || (toolrc.top == mainrc.bottom))) || | if ((toolrc.bottom >= mainrc.top) && (toolrc.top <= mainrc.bottom)) { |
| ((toolrc.bottom >= mainrc.top) && (toolrc.top <= mainrc.bottom) && | if (toolrc.right == mainrc.left) { |
| ((toolrc.right == mainrc.left) || (toolrc.left == mainrc.right)))) { | connect += 0x01; |
| toolwin.parentcn = 1; | } |
| toolwin.parentx = mainrc.left; | else if (toolrc.left == mainrc.right) { |
| toolwin.parenty = mainrc.top; | connect += 0x02; |
| } | |
| else if (toolrc.left == mainrc.left) { | |
| connect += 0x03; | |
| } | |
| else if (toolrc.right == mainrc.right) { | |
| connect += 0x04; | |
| } | |
| } | |
| if ((toolrc.right >= mainrc.left) && (toolrc.left <= mainrc.right)) { | |
| if (toolrc.bottom == mainrc.top) { | |
| connect += 1 << 4; | |
| } | |
| else if (toolrc.top == mainrc.bottom) { | |
| connect += 2 << 4; | |
| } | |
| else if (toolrc.top == mainrc.top) { | |
| connect += 3 << 4; | |
| } | |
| else if (toolrc.bottom == mainrc.bottom) { | |
| connect += 4 << 4; | |
| } | |
| } | } |
| toolwin.parentcn = connect; | |
| toolwin.parentx = mainrc.left; | |
| toolwin.parenty = mainrc.top; | |
| } | } |
| void toolwin_movingend(void) { | void toolwin_movingend(void) { |
| UINT connect; | |
| RECT mainrc; | RECT mainrc; |
| RECT toolrc; | RECT toolrc; |
| int dx; | int cx; |
| int dy; | int cy; |
| if ((toolwin.hwnd) && (toolwin.parentcn)) { | connect = toolwin.parentcn; |
| GetWindowRect(hWndMain, &mainrc); | |
| GetWindowRect(toolwin.hwnd, &toolrc); | |
| dx = mainrc.left - toolwin.parentx; | |
| dy = mainrc.top - toolwin.parenty; | |
| MoveWindow(toolwin.hwnd, toolrc.left + dx, toolrc.top + dy, | |
| toolrc.right - toolrc.left, | |
| toolrc.bottom - toolrc.top, TRUE); | |
| } | |
| toolwin.parentcn = 0; | toolwin.parentcn = 0; |
| if ((toolwin.hwnd == NULL) || (!connect)) { | |
| return; | |
| } | |
| GetWindowRect(hWndMain, &mainrc); | |
| GetWindowRect(toolwin.hwnd, &toolrc); | |
| cx = toolrc.right - toolrc.left; | |
| cy = toolrc.bottom - toolrc.top; | |
| toolrc.left += mainrc.left - toolwin.parentx; | |
| toolrc.top += mainrc.top - toolwin.parenty; | |
| switch(connect & 0x0f) { | |
| case 1: | |
| toolrc.left = mainrc.left - cx; | |
| break; | |
| case 2: | |
| toolrc.left = mainrc.right; | |
| break; | |
| case 3: | |
| toolrc.left = mainrc.left; | |
| break; | |
| case 4: | |
| toolrc.left = mainrc.right - cx; | |
| break; | |
| } | |
| switch((connect >> 4) & 0x0f) { | |
| case 1: | |
| toolrc.top = mainrc.top - cy; | |
| break; | |
| case 2: | |
| toolrc.top = mainrc.bottom; | |
| break; | |
| case 3: | |
| toolrc.top = mainrc.top; | |
| break; | |
| case 4: | |
| toolrc.top = mainrc.bottom - cy; | |
| break; | |
| } | |
| MoveWindow(toolwin.hwnd, toolrc.left, toolrc.top, cx, cy, TRUE); | |
| } | } |
| void toolwin_setfdd(BYTE drv, const char *name) { | void toolwin_setfdd(BYTE drv, const char *name) { |
| Line 734 void toolwin_setfdd(BYTE drv, const char | Line 1008 void toolwin_setfdd(BYTE drv, const char |
| } | } |
| sysmng_update(SYS_UPDATEOSCFG); | sysmng_update(SYS_UPDATEOSCFG); |
| if (toolwin.hwnd != NULL) { | if (toolwin.hwnd != NULL) { |
| setlist(drv); | remakefddlist(drv); |
| SetForegroundWindow(hWndMain); | SetForegroundWindow(hWndMain); |
| } | } |
| } | } |
| static void setdiskacc(UINT num, BYTE count) { | static void setdiskacc(UINT num, BYTE count) { |
| const DISKACC *acc; | const DISKACC *acc; |
| Line 808 static const char ini_title[] = "NP2 too | Line 1081 static const char ini_title[] = "NP2 too |
| static const INITBL iniitem[] = { | static const INITBL iniitem[] = { |
| {"WindposX", INITYPE_SINT32, &np2tool.posx, 0}, | {"WindposX", INITYPE_SINT32, &np2tool.posx, 0}, |
| {"WindposY", INITYPE_SINT32, &np2tool.posy, 0}, | {"WindposY", INITYPE_SINT32, &np2tool.posy, 0}, |
| {"SkinFile", INITYPE_STR, np2tool.skin, MAX_PATH}, | |
| {"FD1NAME0", INITYPE_STR, np2tool.fdd[0].name[0], MAX_PATH}, | {"FD1NAME0", INITYPE_STR, np2tool.fdd[0].name[0], MAX_PATH}, |
| {"FD1NAME1", INITYPE_STR, np2tool.fdd[0].name[1], MAX_PATH}, | {"FD1NAME1", INITYPE_STR, np2tool.fdd[0].name[1], MAX_PATH}, |
| {"FD1NAME2", INITYPE_STR, np2tool.fdd[0].name[2], MAX_PATH}, | {"FD1NAME2", INITYPE_STR, np2tool.fdd[0].name[2], MAX_PATH}, |