]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/window.cpp
suppress warnings about implicit float -> int conversions
[wxWidgets.git] / src / msw / window.cpp
index 610126c65c0c650395cc1705991d79076c940049..659e65db1098f44c4576d2856773b1241a4ec9d8 100644 (file)
@@ -53,6 +53,8 @@
     #include "wx/ownerdrw.h"
 #endif
 
     #include "wx/ownerdrw.h"
 #endif
 
+#include "wx/module.h"
+
 #if wxUSE_DRAG_AND_DROP
     #include "wx/dnd.h"
 #endif
 #if wxUSE_DRAG_AND_DROP
     #include "wx/dnd.h"
 #endif
     #include "wx/msw/gnuwin32/extra.h"
 #endif
 
     #include "wx/msw/gnuwin32/extra.h"
 #endif
 
-#if defined(__GNUG__)
+#if defined(__GNUG__) || defined(__DMC__)
 #include "wx/msw/missing.h"
 #endif
 
 #include "wx/msw/missing.h"
 #endif
 
@@ -462,9 +464,6 @@ bool wxWindowMSW::MSWCommand(WXUINT WXUNUSED(param), WXWORD WXUNUSED(id))
 
 void wxWindowMSW::Init()
 {
 
 void wxWindowMSW::Init()
 {
-    // generic
-    InitBase();
-
     // MSW specific
     m_isBeingDeleted = FALSE;
     m_oldWndProc = NULL;
     // MSW specific
     m_isBeingDeleted = FALSE;
     m_oldWndProc = NULL;
@@ -2401,6 +2400,62 @@ long wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam
                                         wParam);
             break;
 
                                         wParam);
             break;
 
+            // Seems to be broken currently
+#if 0 // ndef __WXWINCE__
+        case WM_MOUSELEAVE:
+           {
+            wxASSERT_MSG( !m_mouseInWindow, wxT("the mouse should be in a window to generate this event!") );
+           
+            // only process this message if the mouse is not in the window,
+            // This can also check for children in composite windows. 
+            // however, this may mean the the wxEVT_LEAVE_WINDOW is never sent
+            // if the mouse does not enter the window from it's child before 
+            // leaving the scope of the window. ( perhaps this can be picked
+            // up in the OnIdle code as before, for this special case )
+            if ( /*IsComposite() && */ !IsMouseInWindow() )
+            {
+                m_mouseInWindow = FALSE;
+
+                // Unfortunately no mouse state is passed with a WM_MOUSE_LEAVE 
+                int state = 0;
+                if ( wxIsShiftDown() )
+                    state |= MK_SHIFT;
+                if ( wxIsCtrlDown() )
+                    state |= MK_CONTROL;
+                if ( GetKeyState( VK_LBUTTON ) )
+                    state |= MK_LBUTTON;
+                if ( GetKeyState( VK_MBUTTON ) )
+                    state |= MK_MBUTTON;
+                if ( GetKeyState( VK_RBUTTON ) )
+                    state |= MK_RBUTTON;
+
+                POINT pt;
+                if ( !::GetCursorPos(&pt) )
+                {
+                    wxLogLastError(_T("GetCursorPos"));
+                }
+
+                // we need to have client coordinates here for symmetry with
+                // wxEVT_ENTER_WINDOW
+                RECT rect = wxGetWindowRect(GetHwnd());
+                pt.x -= rect.left;
+                pt.y -= rect.top;
+
+                wxMouseEvent event2(wxEVT_LEAVE_WINDOW);
+                InitMouseEvent(event2, pt.x, pt.y, state);
+
+                (void)GetEventHandler()->ProcessEvent(event2);
+            }
+            // always pass processed back as false, this allows the window
+            // manager to process the message too.  This is needed to ensure
+            // windows XP themes work properly as the mouse moves over widgets
+            // like buttons.
+            processed = false;
+           }
+           break;
+#endif
+ // __WXWINCE__
+           
 #if wxUSE_MOUSEWHEEL
         case WM_MOUSEWHEEL:
             processed = HandleMouseWheel(wParam, lParam);
 #if wxUSE_MOUSEWHEEL
         case WM_MOUSEWHEEL:
             processed = HandleMouseWheel(wParam, lParam);
@@ -4342,7 +4397,19 @@ bool wxWindowMSW::HandleMouseMove(int x, int y, WXUINT flags)
         {
             // Generate an ENTER event
             m_mouseInWindow = TRUE;
         {
             // Generate an ENTER event
             m_mouseInWindow = TRUE;
-
+#if _WIN32_WINNT >= 0x0400
+#ifndef __WXWINCE__
+            TRACKMOUSEEVENT trackinfo;
+
+            trackinfo.cbSize = sizeof(trackinfo);
+            trackinfo.dwFlags = TME_LEAVE;
+            trackinfo.hwndTrack = GetHwnd();
+            //Use the commctrl.h _TrackMouseEvent, which will call the
+            // appropriate TrackMouseEvent or emulate it ( win95 )
+            // else we need _WIN32_WINNT >= 0x0400 
+            _TrackMouseEvent(&trackinfo);
+#endif
+#endif
             wxMouseEvent event(wxEVT_ENTER_WINDOW);
             InitMouseEvent(event, x, y, flags);
 
             wxMouseEvent event(wxEVT_ENTER_WINDOW);
             InitMouseEvent(event, x, y, flags);
 
@@ -4990,6 +5057,18 @@ int wxCharCodeWXToMSW(int id, bool *isVirtual)
     return keySym;
 }
 
     return keySym;
 }
 
+bool wxGetKeyState(wxKeyCode key)
+{
+    bool bVirtual;
+    int vkey = wxCharCodeWXToMSW(key, &bVirtual);
+    
+    //there aren't WXK_ macros for non-virtual key codes
+    if (bVirtual == false)
+        return false;
+
+    return GetKeyState(vkey) < 0;
+}
+
 wxWindow *wxGetActiveWindow()
 {
     HWND hWnd = GetActiveWindow();
 wxWindow *wxGetActiveWindow()
 {
     HWND hWnd = GetActiveWindow();
@@ -5686,3 +5765,54 @@ bool wxWindowMSW::HandleHotKey(WXWPARAM wParam, WXLPARAM lParam)
 
 #endif // wxUSE_HOTKEY
 
 
 #endif // wxUSE_HOTKEY
 
+// Not verified for WinCE
+#ifndef __WXWINCE__
+/*
+ *     wxEventFixModule (needs a better name) allows message handling to continute while a menu
+ *  is being shown - ie, to continue processing messages from a worker thread.
+ * 
+ *  Code originally by Jason W. from wx-dev, reworked into a wxModule by Chris Mellon
+ */
+
+class wxEventFixModule : public wxModule {
+public:
+       //base class virtuals
+       virtual bool OnInit() {
+               wxEventFixModule::s_hMsgHookProc = SetWindowsHookEx(
+                       WH_GETMESSAGE,
+                       &wxEventFixModule::MsgHookProc,
+                       NULL,
+                       GetCurrentThreadId());
+                       wxLogDebug(_T("Loaded event fix module"));
+                       return true;
+       };
+       virtual void OnExit() {
+               UnhookWindowsHookEx(wxEventFixModule::s_hMsgHookProc);
+
+       };
+       static LRESULT CALLBACK MsgHookProc(int nCode, WPARAM wParam, LPARAM lParam) {
+               MSG *msg = (MSG*)lParam;
+               switch (msg->message)
+               {
+        case WM_NULL:
+            static bool bInHookProc = false;
+            if (!bInHookProc)
+            {
+                bInHookProc = true;
+                wxTheApp->ProcessPendingEvents();
+                bInHookProc = false;
+            }
+            break;
+               }
+               return CallNextHookEx(wxEventFixModule::s_hMsgHookProc, nCode, wParam, lParam);
+       };
+private:
+       static HHOOK s_hMsgHookProc;
+DECLARE_DYNAMIC_CLASS(wxEventFixModule)
+};
+HHOOK wxEventFixModule::s_hMsgHookProc = 0;
+
+IMPLEMENT_DYNAMIC_CLASS(wxEventFixModule, wxModule)
+#endif
+    // __WXWINCE__
+