]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/window.cpp
detabified
[wxWidgets.git] / src / msw / window.cpp
index 316917aafbd3b5e6243af6cc74991016c0e5cbb0..74a6560574f144a5843c6677e8ac23af5b90366b 100644 (file)
@@ -160,7 +160,7 @@ static void TranslateKbdEventToMouse(wxWindowMSW *win,
 static TEXTMETRIC wxGetTextMetrics(const wxWindowMSW *win);
 
 // check if the mouse is in the window or its child
 static TEXTMETRIC wxGetTextMetrics(const wxWindowMSW *win);
 
 // check if the mouse is in the window or its child
-static bool IsMouseInWindow(HWND hwnd);
+//static bool IsMouseInWindow(HWND hwnd);
 
 // ---------------------------------------------------------------------------
 // event tables
 
 // ---------------------------------------------------------------------------
 // event tables
@@ -421,12 +421,19 @@ void wxWindowMSW::SetFocus()
     HWND hWnd = GetHwnd();
     wxCHECK_RET( hWnd, _T("can't set focus to invalid window") );
 
     HWND hWnd = GetHwnd();
     wxCHECK_RET( hWnd, _T("can't set focus to invalid window") );
 
+#ifndef __WXMICROWIN__
     ::SetLastError(0);
     ::SetLastError(0);
+#endif
 
     if ( !::SetFocus(hWnd) )
     {
         // was there really an error?
 
     if ( !::SetFocus(hWnd) )
     {
         // was there really an error?
+#ifndef __WXMICROWIN__
         DWORD dwRes = ::GetLastError();
         DWORD dwRes = ::GetLastError();
+#else
+
+        DWORD dwRes = 0;
+#endif
         if ( dwRes )
         {
             wxLogApiError(_T("SetFocus"), dwRes);
         if ( dwRes )
         {
             wxLogApiError(_T("SetFocus"), dwRes);
@@ -489,7 +496,19 @@ bool wxWindowMSW::Show(bool show)
 
     if ( show )
     {
 
     if ( show )
     {
+#ifdef __WXMICROWIN__
+       // It seems that MicroWindows brings the _parent_ of the
+       // window to the top, which can be the wrong one.
+
+       /* activate (set focus to) specified window*/
+       ::SetFocus(hWnd);
+
+       /* raise top level parent to top of z order*/
+       ::SetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0,
+               SWP_NOMOVE|SWP_NOSIZE);
+#else
         BringWindowToTop(hWnd);
         BringWindowToTop(hWnd);
+#endif
     }
 
     return TRUE;
     }
 
     return TRUE;
@@ -501,8 +520,20 @@ void wxWindowMSW::Raise()
 #ifdef __WIN16__
     ::BringWindowToTop(GetHwnd());
 #else // Win32
 #ifdef __WIN16__
     ::BringWindowToTop(GetHwnd());
 #else // Win32
+#ifdef __WXMICROWIN__
+       // It seems that MicroWindows brings the _parent_ of the
+       // window to the top, which can be the wrong one.
+
+       /* activate (set focus to) specified window*/
+       ::SetFocus(GetHwnd());
+
+       /* raise top level parent to top of z order*/
+       ::SetWindowPos(GetHwnd(), HWND_TOP, 0, 0, 0, 0,
+               SWP_NOMOVE|SWP_NOSIZE);
+#else
     ::SetForegroundWindow(GetHwnd());
 #endif
     ::SetForegroundWindow(GetHwnd());
 #endif
+#endif
 }
 
 // Lower the window to the bottom of the Z order
 }
 
 // Lower the window to the bottom of the Z order
@@ -914,6 +945,9 @@ void wxWindowMSW::SubclassWin(WXHWND hWnd)
     wxAssociateWinWithHandle(hwnd, this);
 
     m_oldWndProc = (WXFARPROC) GetWindowLong(hwnd, GWL_WNDPROC);
     wxAssociateWinWithHandle(hwnd, this);
 
     m_oldWndProc = (WXFARPROC) GetWindowLong(hwnd, GWL_WNDPROC);
+
+    wxASSERT( (WXFARPROC) m_oldWndProc != (WXFARPROC) wxWndProc );
+
     SetWindowLong(hwnd, GWL_WNDPROC, (LONG) wxWndProc);
 }
 
     SetWindowLong(hwnd, GWL_WNDPROC, (LONG) wxWndProc);
 }
 
@@ -1178,7 +1212,7 @@ void wxWindowMSW::Update()
         wxLogLastError(_T("UpdateWindow"));
     }
 
         wxLogLastError(_T("UpdateWindow"));
     }
 
-#ifdef __WIN32__
+#if defined(__WIN32__) && !defined(__WXMICROWIN__)
     // just calling UpdateWindow() is not enough, what we did in our WM_PAINT
     // handler needs to be really drawn right now
     (void)::GdiFlush();
     // just calling UpdateWindow() is not enough, what we did in our WM_PAINT
     // handler needs to be really drawn right now
     (void)::GdiFlush();
@@ -2069,21 +2103,11 @@ long wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam
             }
             break;
 
             }
             break;
 
-#ifdef __WXUNIVERSAL__
+#ifndef __WXMICROWIN__
         case WM_ACTIVATEAPP:
             wxTheApp->SetActive(wParam != 0, FindFocus());
             break;
         case WM_ACTIVATEAPP:
             wxTheApp->SetActive(wParam != 0, FindFocus());
             break;
-
-        case WM_NCHITTEST:
-            // we shouldn't allow the windows which don't want to get focus to
-            // get it
-            if ( !AcceptsFocus() )
-            {
-                rc.result = HTTRANSPARENT;
-                processed = TRUE;
-            }
-            break;
-#endif // __WXUNIVERSAL__
+#endif
 
         case WM_ACTIVATE:
             {
 
         case WM_ACTIVATE:
             {
@@ -2131,12 +2155,6 @@ long wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam
 #endif
 
         case WM_LBUTTONDOWN:
 #endif
 
         case WM_LBUTTONDOWN:
-           // set focus to this window
-           if (AcceptsFocus())
-                SetFocus();
-
-           // fall through
-
         case WM_LBUTTONUP:
         case WM_LBUTTONDBLCLK:
         case WM_RBUTTONDOWN:
         case WM_LBUTTONUP:
         case WM_LBUTTONDBLCLK:
         case WM_RBUTTONDOWN:
@@ -2145,11 +2163,67 @@ long wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam
         case WM_MBUTTONDOWN:
         case WM_MBUTTONUP:
         case WM_MBUTTONDBLCLK:
         case WM_MBUTTONDOWN:
         case WM_MBUTTONUP:
         case WM_MBUTTONDBLCLK:
-            processed = HandleMouseEvent(message,
+         {
+                processed = FALSE;
+#ifdef __WXMICROWIN__
+                // MicroWindows seems to ignore the fact that a window
+                // is disabled. So catch mouse events and throw them away if necessary.
+                wxWindowMSW* win = this;
+                while (win)
+                {
+                    if (!win->IsEnabled())
+                    {
+                        processed = TRUE;
+                        break;
+                    }
+                    win = win->GetParent();
+                    if (win && win->IsTopLevel())
+                        break;
+                }
+#endif
+                if (!processed)
+                {
+                    if (message == WM_LBUTTONDOWN && AcceptsFocus())
+                        SetFocus();
+                     processed = HandleMouseEvent(message,
                                          GET_X_LPARAM(lParam),
                                          GET_Y_LPARAM(lParam),
                                          GET_X_LPARAM(lParam),
                                          GET_Y_LPARAM(lParam),
-                                         wParam);
-            break;
+                                                  wParam);
+                }
+                break;
+         }
+
+#ifdef __WXMICROWIN__
+        case WM_NCLBUTTONDOWN:
+        case WM_NCLBUTTONUP:
+        case WM_NCLBUTTONDBLCLK:
+        case WM_NCRBUTTONDOWN:
+        case WM_NCRBUTTONUP:
+        case WM_NCRBUTTONDBLCLK:
+#if 0
+        case WM_NCMBUTTONDOWN:
+        case WM_NCMBUTTONUP:
+        case WM_NCMBUTTONDBLCLK:
+#endif
+            {
+                // MicroWindows seems to ignore the fact that a window
+                // is disabled. So catch mouse events and throw them away if necessary.
+                processed = FALSE;
+                wxWindowMSW* win = this;
+                while (win)
+                {
+                    if (!win->IsEnabled())
+                    {
+                        processed = TRUE;
+                        break;
+                    }
+                    win = win->GetParent();
+                    if (win && win->IsTopLevel())
+                        break;
+                }
+                break;
+            }
+#endif
 
 #ifdef MM_JOY1MOVE // __WXMICROWIN__
         case MM_JOY1MOVE:
 
 #ifdef MM_JOY1MOVE // __WXMICROWIN__
         case MM_JOY1MOVE:
@@ -2456,6 +2530,18 @@ long wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam
             }
             break;
 #endif // __WIN32__
             }
             break;
 #endif // __WIN32__
+
+#ifdef __WXUNIVERSAL__
+        case WM_NCHITTEST:
+            // we shouldn't allow the windows which don't want to get focus to
+            // get it
+            if ( !AcceptsFocus() )
+            {
+                rc.result = HTTRANSPARENT;
+                processed = TRUE;
+            }
+            break;
+#endif // __WXUNIVERSAL__
     }
 
     if ( !processed )
     }
 
     if ( !processed )
@@ -2546,6 +2632,7 @@ void wxWindowMSW::MSWDestroyWindow()
 
 void wxWindowMSW::MSWDetachWindowMenu()
 {
 
 void wxWindowMSW::MSWDetachWindowMenu()
 {
+#ifndef __WXUNIVERSAL__
     if ( m_hMenu )
     {
         wxChar buf[1024];
     if ( m_hMenu )
     {
         wxChar buf[1024];
@@ -2572,6 +2659,7 @@ void wxWindowMSW::MSWDetachWindowMenu()
             }
         }
     }
             }
         }
     }
+#endif
 }
 
 bool wxWindowMSW::MSWCreate(int id,
 }
 
 bool wxWindowMSW::MSWCreate(int id,
@@ -2645,9 +2733,9 @@ bool wxWindowMSW::MSWCreate(int id,
 
     wxWndHook = this;
 
 
     wxWndHook = this;
 
+#ifndef __WXMICROWIN__
     if ( dialog_template )
     {
     if ( dialog_template )
     {
-#ifndef __WXMICROWIN__
         // for the dialogs without wxDIALOG_NO_PARENT style, use the top level
         // app window as parent - this avoids creating modal dialogs without
         // parent
         // for the dialogs without wxDIALOG_NO_PARENT style, use the top level
         // app window as parent - this avoids creating modal dialogs without
         // parent
@@ -2719,11 +2807,11 @@ bool wxWindowMSW::MSWCreate(int id,
         {
             wxLogLastError(wxT("MoveWindow"));
         }
         {
             wxLogLastError(wxT("MoveWindow"));
         }
-#endif
-       // __WXMICROWIN__
 
     }
     else // creating a normal window, not a dialog
 
     }
     else // creating a normal window, not a dialog
+#endif
+       // __WXMICROWIN__
     {
         int controlId = 0;
         if ( style & WS_CHILD )
     {
         int controlId = 0;
         if ( style & WS_CHILD )
@@ -3830,6 +3918,7 @@ bool wxWindowMSW::HandleKeyUp(WXWPARAM wParam, WXLPARAM lParam)
 
 bool wxWindowMSW::HandleJoystickEvent(WXUINT msg, int x, int y, WXUINT flags)
 {
 
 bool wxWindowMSW::HandleJoystickEvent(WXUINT msg, int x, int y, WXUINT flags)
 {
+#ifdef JOY_BUTTON1
     int change = 0;
     if ( flags & JOY_BUTTON1CHG )
         change = wxJOY_BUTTON1;
     int change = 0;
     if ( flags & JOY_BUTTON1CHG )
         change = wxJOY_BUTTON1;
@@ -3906,6 +3995,9 @@ bool wxWindowMSW::HandleJoystickEvent(WXUINT msg, int x, int y, WXUINT flags)
     event.SetEventObject(this);
 
     return GetEventHandler()->ProcessEvent(event);
     event.SetEventObject(this);
 
     return GetEventHandler()->ProcessEvent(event);
+#else
+    return FALSE;
+#endif
 }
 
 // ---------------------------------------------------------------------------
 }
 
 // ---------------------------------------------------------------------------