Mercurial > projects > dwt-win
comparison dwt/widgets/Scrollable.d @ 108:6f75fdfa1bcd
Change LRESULT to class, like done in the old DWT.
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Mon, 11 Feb 2008 02:44:32 +0100 |
parents | 3926f6c95d6f |
children | ab60f3309436 |
comparison
equal
deleted
inserted
replaced
106:e4a62cdcd2e0 | 108:6f75fdfa1bcd |
---|---|
86 */ | 86 */ |
87 public this (Composite parent, int style) { | 87 public this (Composite parent, int style) { |
88 super (parent, style); | 88 super (parent, style); |
89 } | 89 } |
90 | 90 |
91 override LRESULT callWindowProc (HWND hwnd, int msg, int wParam, int lParam) { | 91 override int callWindowProc (HWND hwnd, int msg, int wParam, int lParam) { |
92 if (handle is null) return LRESULT.ZERO; | 92 if (handle is null) return 0; |
93 return cast(LRESULT) OS.DefWindowProc (hwnd, msg, wParam, lParam); | 93 return OS.DefWindowProc (hwnd, msg, wParam, lParam); |
94 } | 94 } |
95 | 95 |
96 /** | 96 /** |
97 * Given a desired <em>client area</em> for the receiver | 97 * Given a desired <em>client area</em> for the receiver |
98 * (as described by the arguments), returns the bounding | 98 * (as described by the arguments), returns the bounding |
259 } | 259 } |
260 | 260 |
261 override LRESULT WM_HSCROLL (int wParam, int lParam) { | 261 override LRESULT WM_HSCROLL (int wParam, int lParam) { |
262 trc(__LINE__); | 262 trc(__LINE__); |
263 LRESULT result = super.WM_HSCROLL (wParam, lParam); | 263 LRESULT result = super.WM_HSCROLL (wParam, lParam); |
264 if (result !is LRESULT.NULL) return result; | 264 if (result !is null) return result; |
265 | 265 |
266 /* | 266 /* |
267 * Bug on WinCE. lParam should be NULL when the message is not sent | 267 * Bug on WinCE. lParam should be NULL when the message is not sent |
268 * by a scroll bar control, but it contains the handle to the window. | 268 * by a scroll bar control, but it contains the handle to the window. |
269 * When the message is sent by a scroll bar control, it correctly | 269 * When the message is sent by a scroll bar control, it correctly |
277 } | 277 } |
278 | 278 |
279 override LRESULT WM_MOUSEWHEEL (int wParam, int lParam) { | 279 override LRESULT WM_MOUSEWHEEL (int wParam, int lParam) { |
280 trc(__LINE__); | 280 trc(__LINE__); |
281 LRESULT result = super.WM_MOUSEWHEEL (wParam, lParam); | 281 LRESULT result = super.WM_MOUSEWHEEL (wParam, lParam); |
282 if (result !is LRESULT.NULL) return result; | 282 if (result !is null) return result; |
283 | 283 |
284 /* | 284 /* |
285 * Translate WM_MOUSEWHEEL to WM_VSCROLL or WM_HSCROLL. | 285 * Translate WM_MOUSEWHEEL to WM_VSCROLL or WM_HSCROLL. |
286 */ | 286 */ |
287 if ((state & CANVAS) !is 0) { | 287 if ((state & CANVAS) !is 0) { |
324 * then the application has already been notified. If not | 324 * then the application has already been notified. If not |
325 * explicitly send the event. | 325 * explicitly send the event. |
326 */ | 326 */ |
327 int vPosition = verticalBar is null ? 0 : verticalBar.getSelection (); | 327 int vPosition = verticalBar is null ? 0 : verticalBar.getSelection (); |
328 int hPosition = horizontalBar is null ? 0 : horizontalBar.getSelection (); | 328 int hPosition = horizontalBar is null ? 0 : horizontalBar.getSelection (); |
329 LRESULT code = callWindowProc (handle, OS.WM_MOUSEWHEEL, wParam, lParam); | 329 int code = callWindowProc (handle, OS.WM_MOUSEWHEEL, wParam, lParam); |
330 if (verticalBar !is null) { | 330 if (verticalBar !is null) { |
331 int position = verticalBar.getSelection (); | 331 int position = verticalBar.getSelection (); |
332 if (position !is vPosition) { | 332 if (position !is vPosition) { |
333 Event event = new Event (); | 333 Event event = new Event (); |
334 event.detail = position < vPosition ? DWT.PAGE_UP : DWT.PAGE_DOWN; | 334 event.detail = position < vPosition ? DWT.PAGE_UP : DWT.PAGE_DOWN; |
341 Event event = new Event (); | 341 Event event = new Event (); |
342 event.detail = position < hPosition ? DWT.PAGE_UP : DWT.PAGE_DOWN; | 342 event.detail = position < hPosition ? DWT.PAGE_UP : DWT.PAGE_DOWN; |
343 horizontalBar.sendEvent (DWT.Selection, event); | 343 horizontalBar.sendEvent (DWT.Selection, event); |
344 } | 344 } |
345 } | 345 } |
346 return code; | 346 return new LRESULT (code); |
347 } | 347 } |
348 | 348 |
349 override LRESULT WM_SIZE (int wParam, int lParam) { | 349 override LRESULT WM_SIZE (int wParam, int lParam) { |
350 trc(__LINE__); | 350 trc(__LINE__); |
351 LRESULT code = callWindowProc (handle, OS.WM_SIZE, wParam, lParam); | 351 int code = callWindowProc (handle, OS.WM_SIZE, wParam, lParam); |
352 assert( code !is LRESULT.NULL ); | |
353 super.WM_SIZE (wParam, lParam); | 352 super.WM_SIZE (wParam, lParam); |
354 // widget may be disposed at this point | 353 // widget may be disposed at this point |
355 if (code is 0) return LRESULT.ZERO; | 354 if (code is 0) return LRESULT.ZERO; |
356 return code; | 355 return new LRESULT (code); |
357 } | 356 } |
358 | 357 |
359 override LRESULT WM_VSCROLL (int wParam, int lParam) { | 358 override LRESULT WM_VSCROLL (int wParam, int lParam) { |
360 trc(__LINE__); | 359 trc(__LINE__); |
361 LRESULT result = super.WM_VSCROLL (wParam, lParam); | 360 LRESULT result = super.WM_VSCROLL (wParam, lParam); |
362 if (result !is LRESULT.NULL) return result; | 361 if (result !is null) return result; |
363 /* | 362 /* |
364 * Bug on WinCE. lParam should be NULL when the message is not sent | 363 * Bug on WinCE. lParam should be NULL when the message is not sent |
365 * by a scroll bar control, but it contains the handle to the window. | 364 * by a scroll bar control, but it contains the handle to the window. |
366 * When the message is sent by a scroll bar control, it correctly | 365 * When the message is sent by a scroll bar control, it correctly |
367 * contains the handle to the scroll bar. The fix is to check for | 366 * contains the handle to the scroll bar. The fix is to check for |
373 return result; | 372 return result; |
374 } | 373 } |
375 | 374 |
376 LRESULT wmScroll (ScrollBar bar, bool update, HWND hwnd, int msg, int wParam, int lParam) { | 375 LRESULT wmScroll (ScrollBar bar, bool update, HWND hwnd, int msg, int wParam, int lParam) { |
377 trc(__LINE__); | 376 trc(__LINE__); |
378 LRESULT result = LRESULT.NULL; | 377 LRESULT result = null; |
379 if (update) { | 378 if (update) { |
380 int type = msg is OS.WM_HSCROLL ? OS.SB_HORZ : OS.SB_VERT; | 379 int type = msg is OS.WM_HSCROLL ? OS.SB_HORZ : OS.SB_VERT; |
381 SCROLLINFO info; | 380 SCROLLINFO info; |
382 info.cbSize = SCROLLINFO.sizeof; | 381 info.cbSize = SCROLLINFO.sizeof; |
383 info.fMask = OS.SIF_TRACKPOS | OS.SIF_POS | OS.SIF_RANGE; | 382 info.fMask = OS.SIF_TRACKPOS | OS.SIF_POS | OS.SIF_RANGE; |
384 OS.GetScrollInfo (hwnd, type, &info); | 383 OS.GetScrollInfo (hwnd, type, &info); |
385 info.fMask = OS.SIF_POS; | 384 info.fMask = OS.SIF_POS; |
386 int code = wParam & 0xFFFF; | 385 int code = wParam & 0xFFFF; |
387 switch (code) { | 386 switch (code) { |
388 case OS.SB_ENDSCROLL: return LRESULT.NULL; | 387 case OS.SB_ENDSCROLL: return null; |
389 case OS.SB_THUMBPOSITION: | 388 case OS.SB_THUMBPOSITION: |
390 case OS.SB_THUMBTRACK: | 389 case OS.SB_THUMBTRACK: |
391 /* | 390 /* |
392 * Note: On WinCE, the value in SB_THUMBPOSITION is relative to nMin. | 391 * Note: On WinCE, the value in SB_THUMBPOSITION is relative to nMin. |
393 * Same for SB_THUMBPOSITION 'except' for the very first thumb track | 392 * Same for SB_THUMBPOSITION 'except' for the very first thumb track |
418 break; | 417 break; |
419 default: | 418 default: |
420 } | 419 } |
421 OS.SetScrollInfo (hwnd, type, &info, true); | 420 OS.SetScrollInfo (hwnd, type, &info, true); |
422 } else { | 421 } else { |
423 LRESULT code = callWindowProc (hwnd, msg, wParam, lParam); | 422 int code = callWindowProc (hwnd, msg, wParam, lParam); |
424 result = code is 0 ? LRESULT.ZERO : code; | 423 result = code is 0 ? LRESULT.ZERO : new LRESULT (code); |
425 } | 424 } |
426 bar.wmScrollChild (wParam, lParam); | 425 bar.wmScrollChild (wParam, lParam); |
427 return result; | 426 return result; |
428 } | 427 } |
429 | 428 |