Mercurial > projects > dwt-win
comparison dwt/widgets/Shell.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 | 43c42c637c9c |
children | f353be82b6be |
comparison
equal
deleted
inserted
replaced
106:e4a62cdcd2e0 | 108:6f75fdfa1bcd |
---|---|
477 HANDLE balloonTipHandle () { | 477 HANDLE balloonTipHandle () { |
478 if (balloonTipHandle_ is null) createBalloonTipHandle (); | 478 if (balloonTipHandle_ is null) createBalloonTipHandle (); |
479 return balloonTipHandle_; | 479 return balloonTipHandle_; |
480 } | 480 } |
481 | 481 |
482 override LRESULT callWindowProc (HWND hwnd, int msg, int wParam, int lParam) { | 482 override int callWindowProc (HWND hwnd, int msg, int wParam, int lParam) { |
483 if (handle is null) return LRESULT.ZERO; | 483 if (handle is null) return 0; |
484 if (hwnd is toolTipHandle_ || hwnd is balloonTipHandle_) { | 484 if (hwnd is toolTipHandle_ || hwnd is balloonTipHandle_) { |
485 return cast(LRESULT) ToolTipProc( hwnd, msg, wParam, lParam); | 485 return OS.CallWindowProc (ToolTipProc, hwnd, msg, wParam, lParam); |
486 } | 486 } |
487 if (hwndMDIClient_ !is null) { | 487 if (hwndMDIClient_ !is null) { |
488 return cast(LRESULT) OS.DefFrameProc (hwnd, hwndMDIClient_, msg, wParam, lParam); | 488 return OS.DefFrameProc (hwnd, hwndMDIClient_, msg, wParam, lParam); |
489 } | 489 } |
490 if (windowProc_ !is null) { | 490 if (windowProc_ !is null) { |
491 return cast(LRESULT) windowProc_( hwnd, msg, wParam, lParam); | 491 return OS.CallWindowProc (windowProc_, hwnd, msg, wParam, lParam); |
492 } | 492 } |
493 if ((style & DWT.TOOL) !is 0) { | 493 if ((style & DWT.TOOL) !is 0) { |
494 int trim = DWT.TITLE | DWT.CLOSE | DWT.MIN | DWT.MAX | DWT.BORDER | DWT.RESIZE; | 494 int trim = DWT.TITLE | DWT.CLOSE | DWT.MIN | DWT.MAX | DWT.BORDER | DWT.RESIZE; |
495 if ((style & trim) is 0) return cast(LRESULT) OS.DefWindowProc (hwnd, msg, wParam, lParam); | 495 if ((style & trim) is 0) return OS.DefWindowProc (hwnd, msg, wParam, lParam); |
496 } | 496 } |
497 if (parent !is null) { | 497 if (parent !is null) { |
498 switch (msg) { | 498 switch (msg) { |
499 case OS.WM_KILLFOCUS: | 499 case OS.WM_KILLFOCUS: |
500 case OS.WM_SETFOCUS: | 500 case OS.WM_SETFOCUS: |
501 return cast(LRESULT) OS.DefWindowProc (hwnd, msg, wParam, lParam); | 501 return OS.DefWindowProc (hwnd, msg, wParam, lParam); |
502 default: | 502 default: |
503 } | 503 } |
504 return cast(LRESULT) DialogProc( hwnd, msg, wParam, lParam); | 504 return OS.CallWindowProc (DialogProc, hwnd, msg, wParam, lParam); |
505 } | 505 } |
506 return cast(LRESULT) OS.DefWindowProc (hwnd, msg, wParam, lParam); | 506 return OS.DefWindowProc (hwnd, msg, wParam, lParam); |
507 } | 507 } |
508 | 508 |
509 /** | 509 /** |
510 * Requests that the window manager close the receiver in | 510 * Requests that the window manager close the receiver in |
511 * the same way it would be closed when the user clicks on | 511 * the same way it would be closed when the user clicks on |
1955 return result; | 1955 return result; |
1956 } | 1956 } |
1957 | 1957 |
1958 override LRESULT WM_ERASEBKGND (int wParam, int lParam) { | 1958 override LRESULT WM_ERASEBKGND (int wParam, int lParam) { |
1959 LRESULT result = super.WM_ERASEBKGND (wParam, lParam); | 1959 LRESULT result = super.WM_ERASEBKGND (wParam, lParam); |
1960 if (result !is LRESULT.NULL) return result; | 1960 if (result !is null) return result; |
1961 /* | 1961 /* |
1962 * Feature in Windows. When a shell is resized by dragging | 1962 * Feature in Windows. When a shell is resized by dragging |
1963 * the resize handles, Windows temporarily fills in black | 1963 * the resize handles, Windows temporarily fills in black |
1964 * rectangles where the new contents of the shell should | 1964 * rectangles where the new contents of the shell should |
1965 * draw. The fix is to always draw the background of shells. | 1965 * draw. The fix is to always draw the background of shells. |
1973 return result; | 1973 return result; |
1974 } | 1974 } |
1975 | 1975 |
1976 override LRESULT WM_ENTERIDLE (int wParam, int lParam) { | 1976 override LRESULT WM_ENTERIDLE (int wParam, int lParam) { |
1977 LRESULT result = super.WM_ENTERIDLE (wParam, lParam); | 1977 LRESULT result = super.WM_ENTERIDLE (wParam, lParam); |
1978 if (result !is LRESULT.NULL) return result; | 1978 if (result !is null) return result; |
1979 if (OS.IsWinCE && display.runMessages) { | 1979 if (OS.IsWinCE && display.runMessages) { |
1980 if (display.runAsyncMessages (true)) display.wakeThread (); | 1980 if (display.runAsyncMessages (true)) display.wakeThread (); |
1981 } | 1981 } |
1982 return result; | 1982 return result; |
1983 } | 1983 } |
1984 | 1984 |
1985 override LRESULT WM_GETMINMAXINFO (int wParam, int lParam) { | 1985 override LRESULT WM_GETMINMAXINFO (int wParam, int lParam) { |
1986 LRESULT result = super.WM_GETMINMAXINFO (wParam, lParam); | 1986 LRESULT result = super.WM_GETMINMAXINFO (wParam, lParam); |
1987 if (result !is LRESULT.NULL) return result; | 1987 if (result !is null) return result; |
1988 if (minWidth !is DWT.DEFAULT || minHeight !is DWT.DEFAULT) { | 1988 if (minWidth !is DWT.DEFAULT || minHeight !is DWT.DEFAULT) { |
1989 MINMAXINFO* info = cast(MINMAXINFO*)lParam; | 1989 MINMAXINFO* info = cast(MINMAXINFO*)lParam; |
1990 //OS.MoveMemory (info, lParam, MINMAXINFO.sizeof); | 1990 //OS.MoveMemory (info, lParam, MINMAXINFO.sizeof); |
1991 if (minWidth !is DWT.DEFAULT) info.ptMinTrackSize.x = minWidth; | 1991 if (minWidth !is DWT.DEFAULT) info.ptMinTrackSize.x = minWidth; |
1992 if (minHeight !is DWT.DEFAULT) info.ptMinTrackSize.y = minHeight; | 1992 if (minHeight !is DWT.DEFAULT) info.ptMinTrackSize.y = minHeight; |
1996 return result; | 1996 return result; |
1997 } | 1997 } |
1998 | 1998 |
1999 override LRESULT WM_MOUSEACTIVATE (int wParam, int lParam) { | 1999 override LRESULT WM_MOUSEACTIVATE (int wParam, int lParam) { |
2000 LRESULT result = super.WM_MOUSEACTIVATE (wParam, lParam); | 2000 LRESULT result = super.WM_MOUSEACTIVATE (wParam, lParam); |
2001 if (result !is LRESULT.NULL) return result; | 2001 if (result !is null) return result; |
2002 | 2002 |
2003 /* | 2003 /* |
2004 * Check for WM_MOUSEACTIVATE when an MDI shell is active | 2004 * Check for WM_MOUSEACTIVATE when an MDI shell is active |
2005 * and stop the normal shell activation but allow the mouse | 2005 * and stop the normal shell activation but allow the mouse |
2006 * down to be delivered. | 2006 * down to be delivered. |
2019 display.ignoreRestoreFocus = true; | 2019 display.ignoreRestoreFocus = true; |
2020 display.lastHittest = hittest; | 2020 display.lastHittest = hittest; |
2021 display.lastHittestControl = null; | 2021 display.lastHittestControl = null; |
2022 if (hittest is OS.HTMENU || hittest is OS.HTSYSMENU) { | 2022 if (hittest is OS.HTMENU || hittest is OS.HTSYSMENU) { |
2023 display.lastHittestControl = control; | 2023 display.lastHittestControl = control; |
2024 return LRESULT.NULL; | 2024 return null; |
2025 } | 2025 } |
2026 if (OS.IsWin95 && hittest is OS.HTCAPTION) { | 2026 if (OS.IsWin95 && hittest is OS.HTCAPTION) { |
2027 display.lastHittestControl = control; | 2027 display.lastHittestControl = control; |
2028 } | 2028 } |
2029 return cast( LRESULT )(OS.MA_NOACTIVATE); | 2029 return new LRESULT (OS.MA_NOACTIVATE); |
2030 } | 2030 } |
2031 } | 2031 } |
2032 } | 2032 } |
2033 } | 2033 } |
2034 if (hittest is OS.HTMENU) return LRESULT.NULL; | 2034 if (hittest is OS.HTMENU) return null; |
2035 | 2035 |
2036 /* | 2036 /* |
2037 * Get the current location of the cursor, | 2037 * Get the current location of the cursor, |
2038 * not the location of the cursor when the | 2038 * not the location of the cursor when the |
2039 * WM_MOUSEACTIVATE was generated. This is | 2039 * WM_MOUSEACTIVATE was generated. This is |
2050 int pos = OS.GetMessagePos (); | 2050 int pos = OS.GetMessagePos (); |
2051 pt.x = cast(short) (pos & 0xFFFF); | 2051 pt.x = cast(short) (pos & 0xFFFF); |
2052 pt.y = cast(short) (pos >> 16); | 2052 pt.y = cast(short) (pos >> 16); |
2053 } | 2053 } |
2054 auto hwnd = OS.WindowFromPoint (pt); | 2054 auto hwnd = OS.WindowFromPoint (pt); |
2055 if (hwnd is null) return LRESULT.NULL; | 2055 if (hwnd is null) return null; |
2056 Control control = display.findControl (hwnd); | 2056 Control control = display.findControl (hwnd); |
2057 | 2057 |
2058 /* | 2058 /* |
2059 * When a shell is created with DWT.ON_TOP and DWT.NO_FOCUS, | 2059 * When a shell is created with DWT.ON_TOP and DWT.NO_FOCUS, |
2060 * do not activate the shell when the user clicks on the | 2060 * do not activate the shell when the user clicks on the |
2064 if (control !is null && (control.state & CANVAS) !is 0) { | 2064 if (control !is null && (control.state & CANVAS) !is 0) { |
2065 if ((control.style & DWT.NO_FOCUS) !is 0) { | 2065 if ((control.style & DWT.NO_FOCUS) !is 0) { |
2066 int bits = DWT.ON_TOP | DWT.NO_FOCUS; | 2066 int bits = DWT.ON_TOP | DWT.NO_FOCUS; |
2067 if ((style & bits) is bits) { | 2067 if ((style & bits) is bits) { |
2068 if (hittest is OS.HTBORDER || hittest is OS.HTCLIENT) { | 2068 if (hittest is OS.HTBORDER || hittest is OS.HTCLIENT) { |
2069 return cast( LRESULT )(OS.MA_NOACTIVATE); | 2069 return new LRESULT (OS.MA_NOACTIVATE); |
2070 } | 2070 } |
2071 } | 2071 } |
2072 } | 2072 } |
2073 } | 2073 } |
2074 | 2074 |
2075 setActiveControl (control); | 2075 setActiveControl (control); |
2076 return LRESULT.NULL; | 2076 return null; |
2077 } | 2077 } |
2078 | 2078 |
2079 override LRESULT WM_MOVE (int wParam, int lParam) { | 2079 override LRESULT WM_MOVE (int wParam, int lParam) { |
2080 LRESULT result = super.WM_MOVE (wParam, lParam); | 2080 LRESULT result = super.WM_MOVE (wParam, lParam); |
2081 if (result !is LRESULT.NULL) return result; | 2081 if (result !is null) return result; |
2082 ToolTip tip = getCurrentToolTip (); | 2082 ToolTip tip = getCurrentToolTip (); |
2083 if (tip !is null) tip.setVisible (false); | 2083 if (tip !is null) tip.setVisible (false); |
2084 return result; | 2084 return result; |
2085 } | 2085 } |
2086 | 2086 |
2099 } | 2099 } |
2100 return result; | 2100 return result; |
2101 } | 2101 } |
2102 | 2102 |
2103 override LRESULT WM_NCHITTEST (int wParam, int lParam) { | 2103 override LRESULT WM_NCHITTEST (int wParam, int lParam) { |
2104 if (!OS.IsWindowEnabled (handle)) return LRESULT.NULL; | 2104 if (!OS.IsWindowEnabled (handle)) return null; |
2105 if (!isEnabled () || !isActive ()) { | 2105 if (!isEnabled () || !isActive ()) { |
2106 if (!Display.TrimEnabled) return cast( LRESULT )(OS.HTNOWHERE); | 2106 if (!Display.TrimEnabled) return new LRESULT (OS.HTNOWHERE); |
2107 int hittest = callWindowProc (handle, OS.WM_NCHITTEST, wParam, lParam); | 2107 int hittest = callWindowProc (handle, OS.WM_NCHITTEST, wParam, lParam); |
2108 if (hittest is OS.HTCLIENT || hittest is OS.HTMENU) hittest = OS.HTBORDER; | 2108 if (hittest is OS.HTCLIENT || hittest is OS.HTMENU) hittest = OS.HTBORDER; |
2109 return cast( LRESULT )(hittest); | 2109 return new LRESULT (hittest); |
2110 } | 2110 } |
2111 if (menuBar !is null && !menuBar.getEnabled ()) { | 2111 if (menuBar !is null && !menuBar.getEnabled ()) { |
2112 int hittest = callWindowProc (handle, OS.WM_NCHITTEST, wParam, lParam); | 2112 int hittest = callWindowProc (handle, OS.WM_NCHITTEST, wParam, lParam); |
2113 if (hittest is OS.HTMENU) hittest = OS.HTBORDER; | 2113 if (hittest is OS.HTMENU) hittest = OS.HTBORDER; |
2114 return cast( LRESULT )(hittest); | 2114 return new LRESULT (hittest); |
2115 } | 2115 } |
2116 return LRESULT.NULL; | 2116 return null; |
2117 } | 2117 } |
2118 | 2118 |
2119 override LRESULT WM_NCLBUTTONDOWN (int wParam, int lParam) { | 2119 override LRESULT WM_NCLBUTTONDOWN (int wParam, int lParam) { |
2120 LRESULT result = super.WM_NCLBUTTONDOWN (wParam, lParam); | 2120 LRESULT result = super.WM_NCLBUTTONDOWN (wParam, lParam); |
2121 if (result !is LRESULT.NULL) return result; | 2121 if (result !is null) return result; |
2122 /* | 2122 /* |
2123 * When the normal activation was interrupted in WM_MOUSEACTIVATE | 2123 * When the normal activation was interrupted in WM_MOUSEACTIVATE |
2124 * because the active shell was an MDI shell, set the active window | 2124 * because the active shell was an MDI shell, set the active window |
2125 * to the top level shell but lock the active window and stop focus | 2125 * to the top level shell but lock the active window and stop focus |
2126 * changes. This allows the user to interact the top level shell | 2126 * changes. This allows the user to interact the top level shell |
2139 if (focusControl !is null && !focusControl.isDisposed ()) { | 2139 if (focusControl !is null && !focusControl.isDisposed ()) { |
2140 focusControl.setFocus (); | 2140 focusControl.setFocus (); |
2141 } | 2141 } |
2142 display.lastHittestControl = null; | 2142 display.lastHittestControl = null; |
2143 display.ignoreRestoreFocus = false; | 2143 display.ignoreRestoreFocus = false; |
2144 return cast( LRESULT )(code); | 2144 return new LRESULT (code); |
2145 } | 2145 } |
2146 | 2146 |
2147 override LRESULT WM_PALETTECHANGED (int wParam, int lParam) { | 2147 override LRESULT WM_PALETTECHANGED (int wParam, int lParam) { |
2148 if ( cast(HANDLE)wParam !is handle) { | 2148 if ( cast(HANDLE)wParam !is handle) { |
2149 auto hPalette = display.hPalette; | 2149 auto hPalette = display.hPalette; |
2232 return super.WM_SETCURSOR (wParam, lParam); | 2232 return super.WM_SETCURSOR (wParam, lParam); |
2233 } | 2233 } |
2234 | 2234 |
2235 override LRESULT WM_SETTINGCHANGE (int wParam, int lParam) { | 2235 override LRESULT WM_SETTINGCHANGE (int wParam, int lParam) { |
2236 LRESULT result = super.WM_SETTINGCHANGE (wParam, lParam); | 2236 LRESULT result = super.WM_SETTINGCHANGE (wParam, lParam); |
2237 if (result !is LRESULT.NULL) return result; | 2237 if (result !is null) return result; |
2238 static if (OS.IsPPC) { | 2238 static if (OS.IsPPC) { |
2239 if (wParam is OS.SPI_SETSIPINFO) { | 2239 if (wParam is OS.SPI_SETSIPINFO) { |
2240 /* | 2240 /* |
2241 * The SIP is in a new state. Cache its new value. | 2241 * The SIP is in a new state. Cache its new value. |
2242 * Resize the Shell if it has the style DWT.RESIZE. | 2242 * Resize the Shell if it has the style DWT.RESIZE. |
2257 return result; | 2257 return result; |
2258 } | 2258 } |
2259 | 2259 |
2260 override LRESULT WM_SHOWWINDOW (int wParam, int lParam) { | 2260 override LRESULT WM_SHOWWINDOW (int wParam, int lParam) { |
2261 LRESULT result = super.WM_SHOWWINDOW (wParam, lParam); | 2261 LRESULT result = super.WM_SHOWWINDOW (wParam, lParam); |
2262 if (result !is LRESULT.NULL) return result; | 2262 if (result !is null) return result; |
2263 /* | 2263 /* |
2264 * Bug in Windows. If the shell is hidden while the parent | 2264 * Bug in Windows. If the shell is hidden while the parent |
2265 * is iconic, Windows shows the shell when the parent is | 2265 * is iconic, Windows shows the shell when the parent is |
2266 * deiconified. This does not happen if the shell is hidden | 2266 * deiconified. This does not happen if the shell is hidden |
2267 * while the parent is not an icon. The fix is to track | 2267 * while the parent is not an icon. The fix is to track |
2279 return result; | 2279 return result; |
2280 } | 2280 } |
2281 | 2281 |
2282 override LRESULT WM_SYSCOMMAND (int wParam, int lParam) { | 2282 override LRESULT WM_SYSCOMMAND (int wParam, int lParam) { |
2283 LRESULT result = super.WM_SYSCOMMAND (wParam, lParam); | 2283 LRESULT result = super.WM_SYSCOMMAND (wParam, lParam); |
2284 if (result !is LRESULT.NULL) return result; | 2284 if (result !is null) return result; |
2285 /* | 2285 /* |
2286 * Feature in Windows. When the last visible window in | 2286 * Feature in Windows. When the last visible window in |
2287 * a process minimized, Windows swaps out the memory for | 2287 * a process minimized, Windows swaps out the memory for |
2288 * the process. The assumption is that the user can no | 2288 * the process. The assumption is that the user can no |
2289 * longer interact with the window, so the memory can be | 2289 * longer interact with the window, so the memory can be |
2314 return result; | 2314 return result; |
2315 } | 2315 } |
2316 | 2316 |
2317 override LRESULT WM_WINDOWPOSCHANGING (int wParam, int lParam) { | 2317 override LRESULT WM_WINDOWPOSCHANGING (int wParam, int lParam) { |
2318 LRESULT result = super.WM_WINDOWPOSCHANGING (wParam,lParam); | 2318 LRESULT result = super.WM_WINDOWPOSCHANGING (wParam,lParam); |
2319 if (result !is LRESULT.NULL) return result; | 2319 if (result !is null) return result; |
2320 auto lpwp = cast(WINDOWPOS*)lParam; | 2320 auto lpwp = cast(WINDOWPOS*)lParam; |
2321 //OS.MoveMemory (lpwp, lParam, WINDOWPOS.sizeof); | 2321 //OS.MoveMemory (lpwp, lParam, WINDOWPOS.sizeof); |
2322 if ((lpwp.flags & OS.SWP_NOSIZE) is 0) { | 2322 if ((lpwp.flags & OS.SWP_NOSIZE) is 0) { |
2323 lpwp.cx = Math.max (lpwp.cx, minWidth); | 2323 lpwp.cx = Math.max (lpwp.cx, minWidth); |
2324 int trim = DWT.TITLE | DWT.CLOSE | DWT.MIN | DWT.MAX; | 2324 int trim = DWT.TITLE | DWT.CLOSE | DWT.MIN | DWT.MAX; |