--- np2/win9x/toolwin.cpp 2003/10/29 21:35:58 1.5 +++ np2/win9x/toolwin.cpp 2003/10/30 12:45:38 1.7 @@ -492,38 +492,80 @@ static void movingproc(RECT *rect) { return; } - changes = FALSE; - do { - if (toolwin.winflg & 1) { - toolwin.wingx += rect->left - toolwin.wintx; - rect->left = toolwin.wintx; + 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; } - else { - d = SNAPDOTPULL; + 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)); + connecty = ((rect->bottom >= mainrc.top) && (rect->top <= mainrc.bottom)); + if ((!connectx) || (!connecty)) { + if (toolwin.winflg & 0x01) { + toolwin.winflg &= ~0x01; + rect->left += toolwin.wingx; + rect->right = rect->left + winlx; + toolwin.wingx = 0; + } + if (toolwin.winflg & 0x04) { + toolwin.winflg &= ~0x04; + rect->top += toolwin.wingy; + rect->bottom = rect->top + winly; + toolwin.wingy = 0; + } + } + + do { + changes = FALSE; + if ((!(toolwin.winflg & 0x01)) && + (rect->bottom >= mainrc.top) && (rect->top <= mainrc.bottom)) { do { - connecty = ((rect->bottom >= mainrc.top) && - (rect->top <= mainrc.bottom)); - if (connecty) { - d = rect->left - mainrc.right; + d = rect->left - mainrc.right; + if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { + break; + } + d = rect->right - mainrc.left; + if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { + break; + } + if ((rect->bottom == mainrc.top) || + (rect->top == mainrc.bottom)) { + d = rect->left - mainrc.left; if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { break; } - d = rect->right - mainrc.left; + d = rect->right - mainrc.right; if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { break; } - if ((rect->bottom == mainrc.top) || - (rect->top == mainrc.bottom)) { - d = rect->left - mainrc.left; - if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { - break; - } - d = rect->right - mainrc.right; - if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { - break; - } - } } + } while(0); + if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { + toolwin.winflg |= 0x01; + rect->left -= d; + rect->right = rect->left + winlx; + toolwin.wingx = d; + toolwin.wintx = rect->left; + changes = TRUE; + } + } + if (!(toolwin.winflg & 0x03)) { + do { d = rect->left - workrc.left; if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { break; @@ -534,53 +576,49 @@ static void movingproc(RECT *rect) { } } while(0); if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { - toolwin.winflg |= 1; + toolwin.winflg |= 0x02; rect->left -= d; + rect->right = rect->left + winlx; toolwin.wingx = d; toolwin.wintx = rect->left; + changes = TRUE; } } - if ((toolwin.wingx >= SNAPDOTREL) || (toolwin.wingx <= -SNAPDOTREL)) { - toolwin.winflg &= ~1; - rect->left += toolwin.wingx; - toolwin.wingx = 0; - } - rect->right = rect->left + winlx; - - if (changes) { - break; - } - if (toolwin.winflg & 2) { - toolwin.wingy += rect->top - toolwin.winty; - rect->top = toolwin.winty; - } - else { - d = SNAPDOTPULL; + if ((!(toolwin.winflg & 0x04)) && + (rect->right >= mainrc.left) && (rect->left <= mainrc.right)) { do { - connectx = ((rect->right >= mainrc.left) && - (rect->left <= mainrc.right)); - if (connectx) { - d = rect->top - mainrc.bottom; + d = rect->top - mainrc.bottom; + if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { + break; + } + d = rect->bottom - mainrc.top; + if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { + break; + } + if ((rect->right == mainrc.left) || + (rect->left == mainrc.right)) { + d = rect->top - mainrc.top; if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { break; } - d = rect->bottom - mainrc.top; + d = rect->bottom - mainrc.bottom; if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { break; } - if ((rect->right == mainrc.left) || - (rect->left == mainrc.right)) { - d = rect->top - mainrc.top; - if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { - break; - } - d = rect->bottom - mainrc.bottom; - if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { - break; - } - } } + } while(0); + if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { + toolwin.winflg |= 0x04; + rect->top -= d; + rect->bottom = rect->top + winly; + toolwin.wingy = d; + toolwin.winty = rect->top; + changes = TRUE; + } + } + if (!(toolwin.winflg & 0x0c)) { + do { d = rect->top - workrc.top; if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { break; @@ -591,33 +629,15 @@ static void movingproc(RECT *rect) { } } while(0); if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { - toolwin.winflg |= 2; + toolwin.winflg |= 0x08; rect->top -= d; + rect->bottom = rect->top + winly; toolwin.wingy = d; toolwin.winty = rect->top; changes = TRUE; } } - if ((toolwin.wingy >= SNAPDOTREL) || (toolwin.wingy <= -SNAPDOTREL)) { - toolwin.winflg &= ~2; - rect->top += toolwin.wingy; - toolwin.wingy = 0; - changes = TRUE; - } - rect->bottom = rect->top + winly; } while(changes); - - connectx = ((rect->right >= mainrc.left) && (rect->left <= mainrc.right)); - connecty = ((rect->bottom >= mainrc.top) && (rect->top <= mainrc.bottom)); - if ((toolwin.winflg & 3) && ((!connectx) || (!connecty))) { - toolwin.winflg &= ~3; - rect->left += toolwin.wingx; - rect->top += toolwin.wingy; - rect->right = rect->left + winlx; - rect->bottom = rect->top + winly; - toolwin.wingx = 0; - toolwin.wingy = 0; - } } @@ -662,10 +682,10 @@ static LRESULT CALLBACK twproc(HWND hWnd break; case IDC_SKINSEL: - soundmng_stop(); + soundmng_disable(SNDPROC_TOOL); r = dlgs_selectfile(hWnd, &skinui, np2tool.skin, sizeof(np2tool.skin), NULL); - soundmng_play(); + soundmng_enable(SNDPROC_TOOL); if (r) { changeskin(hWnd); sysmng_update(SYS_UPDATEOSCFG); @@ -686,9 +706,9 @@ static LRESULT CALLBACK twproc(HWND hWnd break; case IDC_BASE + IDC_TOOLFDD1BROWSE: - soundmng_stop(); + soundmng_disable(SNDPROC_TOOL); dialog_changefdd(hWnd, 0); - soundmng_play(); + soundmng_enable(SNDPROC_TOOL); break; case IDC_BASE + IDC_TOOLFDD1EJECT: @@ -703,9 +723,9 @@ static LRESULT CALLBACK twproc(HWND hWnd break; case IDC_BASE + IDC_TOOLFDD2BROWSE: - soundmng_stop(); + soundmng_disable(SNDPROC_TOOL); dialog_changefdd(hWnd, 1); - soundmng_play(); + soundmng_enable(SNDPROC_TOOL); break; case IDC_BASE + IDC_TOOLFDD2EJECT: @@ -729,20 +749,20 @@ static LRESULT CALLBACK twproc(HWND hWnd break; case WM_ENTERMENULOOP: - soundmng_stop(); + soundmng_disable(SNDPROC_TOOL); break; case WM_EXITMENULOOP: - soundmng_play(); + soundmng_enable(SNDPROC_TOOL); break; case WM_ENTERSIZEMOVE: - soundmng_stop(); + soundmng_disable(SNDPROC_TOOL); movingstart(); break; case WM_EXITSIZEMOVE: - soundmng_play(); + soundmng_enable(SNDPROC_TOOL); break; case WM_MOVING: @@ -789,7 +809,7 @@ BOOL toolwin_initapp(HINSTANCE hInstance WNDCLASS wc; - wc.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS; + wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = twproc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; @@ -853,7 +873,6 @@ void toolwin_close(void) { } } -#if 1 void toolwin_movingstart(void) { RECT mainrc; @@ -954,46 +973,6 @@ void toolwin_movingend(void) { } MoveWindow(toolwin.hwnd, toolrc.left, toolrc.top, cx, cy, TRUE); } -#else -void toolwin_movingstart(void) { - - RECT mainrc; - RECT toolrc; - - if (toolwin.hwnd == NULL) { - return; - } - GetWindowRect(hWndMain, &mainrc); - GetWindowRect(toolwin.hwnd, &toolrc); - if (((toolrc.right >= mainrc.left) && (toolrc.left <= mainrc.right) && - ((toolrc.bottom == mainrc.top) || (toolrc.top == mainrc.bottom))) || - ((toolrc.bottom >= mainrc.top) && (toolrc.top <= mainrc.bottom) && - ((toolrc.right == mainrc.left) || (toolrc.left == mainrc.right)))) { - toolwin.parentcn = 1; - toolwin.parentx = mainrc.left; - toolwin.parenty = mainrc.top; - } -} - -void toolwin_movingend(void) { - - RECT mainrc; - RECT toolrc; - int dx; - int dy; - - if ((toolwin.hwnd) && (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; -} -#endif void toolwin_setfdd(BYTE drv, const char *name) {