| 193 | // happens inside the InteractX() message loop. |
| 194 | |
| 195 | LRESULT API WndProcWCLI(HWND hwnd, UINT wMsg, WPARAM wParam, LPARAM lParam) |
| 196 | { |
| 197 | HDC hdc; |
| 198 | HPEN hpen, hpenOld; |
| 199 | int x, y, n; |
| 200 | |
| 201 | wi.hwnd = hwnd; |
| 202 | switch (wMsg) { |
| 203 | |
| 204 | // The window has been resized. Change the chart size if need be. |
| 205 | case WM_SIZE: |
| 206 | wi.xClient = gs.xWin = LOWORD(lParam); |
| 207 | wi.yClient = gs.yWin = HIWORD(lParam); |
| 208 | if (!wi.fNotManual) { |
| 209 | gi.xWinResize = gs.xWin; gi.yWinResize = gs.yWin; |
| 210 | } |
| 211 | wi.fDoResize = fTrue; |
| 212 | break; |
| 213 | |
| 214 | // All or part of the window needs to be redrawn. Will do so later. |
| 215 | case WM_PAINT: |
| 216 | wi.fDoRedraw = fTrue; |
| 217 | break; |
| 218 | |
| 219 | // The mouse has been left clicked or dragged over the window. |
| 220 | case WM_LBUTTONDOWN: |
| 221 | case WM_MOUSEMOVE: |
| 222 | x = WLo(lParam); |
| 223 | y = WHi(lParam); |
| 224 | if (wMsg == WM_MOUSEMOVE) { |
| 225 | |
| 226 | // Dragging with right mouse down rotates and tilts globes. |
| 227 | if ((wParam & MK_RBUTTON) != 0 && us.fGraphics && (fMap || |
| 228 | gi.nMode == gMidpoint || gi.nMode == gLocal || gi.nMode == gSphere || |
| 229 | gi.nMode == gGlobe || gi.nMode == gPolar || gi.nMode == gTelescope)) { |
| 230 | gs.rRot += (real)(x-WLo(wi.lParamRC)) * rDegHalf / (real)gs.xWin * |
| 231 | (gi.nMode == gLocal || gi.nMode == gTelescope ? -gi.zViewRatio : |
| 232 | 1.0); |
| 233 | gs.rTilt += (real)(y-WHi(wi.lParamRC)) * rDegHalf / (real)gs.yWin * |
| 234 | (gi.nMode == gLocal || gi.nMode == gTelescope ? gi.zViewRatio : |
| 235 | (gi.nMode == gGlobe ? -1.0 : 1.0)); |
| 236 | while (gs.rRot >= rDegMax) |
| 237 | gs.rRot -= rDegMax; |
| 238 | while (gs.rRot < 0.0) |
| 239 | gs.rRot += rDegMax; |
| 240 | while (gs.rTilt > rDegQuad) |
| 241 | gs.rTilt = rDegQuad; |
| 242 | while (gs.rTilt < -rDegQuad) |
| 243 | gs.rTilt = -rDegQuad; |
| 244 | if (gi.nMode == gMidpoint || gi.nMode == gTelescope) { |
| 245 | if (gi.nMode == gMidpoint && gs.objTrack >= 0) |
| 246 | gs.rRot = planet[gs.objTrack]; |
| 247 | gs.objTrack = -1; |
| 248 | } |
| 249 | wi.lParamRC = lParam; |
| 250 | wi.fDoRedraw = fTrue; |
| 251 | break; |
| 252 | } |