]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/window.cpp
pc 2 mac conversion for file operations
[wxWidgets.git] / src / msw / window.cpp
index ec90c5d2b733e66f1ee4ae3e352ca105bfd83a79..21a1c344cd22b2feec545c9e84c18c30899f602d 100644 (file)
     #include "wx/msw/gnuwin32/extra.h"
 #endif
 
+#if defined(__GNUG__)
+#include "wx/msw/missing.h"
+#endif
+
 // ----------------------------------------------------------------------------
 // standard constants not available with all compilers/headers
 // ----------------------------------------------------------------------------
@@ -172,25 +176,16 @@ static bool gs_hasStdCmap = FALSE;
 // ---------------------------------------------------------------------------
 
 // the window proc for all our windows
-#ifdef __DIGITALMARS__
-extern "C" LRESULT WXDLLEXPORT APIENTRY _EXPORT wxWndProc(HWND hWnd, UINT message,
-                                   WPARAM wParam, LPARAM lParam);
-#else
 LRESULT WXDLLEXPORT APIENTRY _EXPORT wxWndProc(HWND hWnd, UINT message,
                                    WPARAM wParam, LPARAM lParam);
-#endif
-                                   
+
 
 #ifdef  __WXDEBUG__
     const char *wxGetMessageName(int message);
 #endif  //__WXDEBUG__
 
 void wxRemoveHandleAssociation(wxWindowMSW *win);
-#ifdef __DIGITALMARS__
-extern "C" void wxAssociateWinWithHandle(HWND hWnd, wxWindowMSW *win);
-#else
 extern void wxAssociateWinWithHandle(HWND hWnd, wxWindowMSW *win);
-#endif
 wxWindow *wxFindWinFromHandle(WXHWND hWnd);
 
 // this magical function is used to translate VK_APPS key presses to right
@@ -213,15 +208,13 @@ static inline void wxBringWindowToTop(HWND hwnd)
 
     // activate (set focus to) specified window
     ::SetFocus(hwnd);
+#endif
 
     // raise top level parent to top of z order
-    ::SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
-#else // !__WXMICROWIN__
-    if ( !::BringWindowToTop(hwnd) )
+    if (!::SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE))
     {
-        wxLogLastError(_T("BringWindowToTop"));
+        wxLogLastError(_T("SetWindowPos"));
     }
-#endif // __WXMICROWIN__/!__WXMICROWIN__
 }
 
 // ---------------------------------------------------------------------------
@@ -481,8 +474,6 @@ void wxWindowMSW::SetFocus()
 
 void wxWindowMSW::SetFocusFromKbd()
 {
-    wxWindowBase::SetFocusFromKbd();
-
     // when the focus is given to the control with DLGC_HASSETSEL style from
     // keyboard its contents should be entirely selected: this is what
     // ::IsDialogMessage() does and so we should do it as well to provide the
@@ -491,6 +482,11 @@ void wxWindowMSW::SetFocusFromKbd()
     {
         ::SendMessage(GetHwnd(), EM_SETSEL, 0, -1);
     }
+
+    // do this after (maybe) setting the selection as like this when
+    // wxEVT_SET_FOCUS handler is called, the selection would have been already
+    // set correctly -- this may be important
+    wxWindowBase::SetFocusFromKbd();
 }
 
 // Get the window with the focus
@@ -579,7 +575,7 @@ bool wxWindowMSW::Show(bool show)
     int cshow = show ? SW_SHOW : SW_HIDE;
     ::ShowWindow(hWnd, cshow);
 
-    if ( show )
+    if ( show && IsTopLevel() )
     {
         wxBringWindowToTop(hWnd);
     }
@@ -1026,25 +1022,31 @@ WXDWORD wxWindowMSW::MSWGetStyle(long flags, WXDWORD *exstyle) const
     if ( flags & wxCLIP_SIBLINGS )
         style |= WS_CLIPSIBLINGS;
 
+    if ( flags & wxVSCROLL )
+        style |= WS_VSCROLL;
+
+    if ( flags & wxHSCROLL )
+        style |= WS_HSCROLL;
+
     wxBorder border = (wxBorder)(flags & wxBORDER_MASK);
-    
+
     // Check if we want to automatically give it a sunken style.
     // Note than because 'sunken' actually maps to WS_EX_CLIENTEDGE, which
     // is a more neutral term, we don't necessarily get a sunken effect in
     // Windows XP. Instead we get the appropriate style for the theme.
 
-    if (border == wxBORDER_DEFAULT && wxTheApp->GetAuto3D() && 
-        GetParent() && (GetParent()->IsKindOf(CLASSINFO(wxPanel)) ||
-                        GetParent()->IsKindOf(CLASSINFO(wxDialog))) &&
+    if (border == wxBORDER_DEFAULT &&
+        IsKindOf(CLASSINFO(wxControl)) &&
+        GetParent() &&
         ((GetParent()->GetWindowStyleFlag() & wxUSER_COLOURS) != wxUSER_COLOURS))
     {
         border = (wxBorder)((flags & wxBORDER_MASK) | wxBORDER_SUNKEN);
-    }   
-    
+    }
+
     // Only give it WS_BORDER for wxBORDER_SIMPLE
     if (border & wxBORDER_SIMPLE)
         style |= WS_BORDER;
-    
+
     // now deal with ext style if the caller wants it
     if ( exstyle )
     {
@@ -1731,11 +1733,7 @@ bool wxWindowMSW::DoPopupMenu(wxMenu *menu, int x, int y)
 long wxWindowMSW::MSWDefWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
 {
     if ( m_oldWndProc )
-#ifdef __DIGITALMARS__
-        return ::CallWindowProc( (FARPROC) m_oldWndProc, GetHwnd(), (UINT) nMsg, (WPARAM) wParam, (LPARAM) lParam);
-#else
         return ::CallWindowProc(CASTWNDPROC m_oldWndProc, GetHwnd(), (UINT) nMsg, (WPARAM) wParam, (LPARAM) lParam);
-#endif
     else
         return ::DefWindowProc(GetHwnd(), nMsg, wParam, lParam);
 }
@@ -2183,6 +2181,24 @@ long wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam
             processed = HandleMove(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
             break;
 
+        case WM_MOVING:
+                       {
+                               LPRECT pRect = (LPRECT)lParam;
+                               wxRect rc;
+                               rc.SetLeft(pRect->left);
+                               rc.SetTop(pRect->top);
+                               rc.SetRight(pRect->right);
+                               rc.SetBottom(pRect->bottom);
+                               processed = HandleMoving(rc);
+                               if (processed) {
+                                       pRect->left = rc.GetLeft();
+                                       pRect->top = rc.GetTop();
+                                       pRect->right = rc.GetRight();
+                                       pRect->bottom = rc.GetBottom();
+                               }
+                       }
+            break;
+
         case WM_SIZE:
             switch ( wParam )
             {
@@ -2211,6 +2227,24 @@ long wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam
             }
             break;
 
+        case WM_SIZING:
+            {
+                LPRECT pRect = (LPRECT)lParam;
+                wxRect rc;
+                rc.SetLeft(pRect->left);
+                rc.SetTop(pRect->top);
+                rc.SetRight(pRect->right);
+                rc.SetBottom(pRect->bottom);
+                processed = HandleSizing(rc);
+                if (processed) {
+                    pRect->left = rc.GetLeft();
+                    pRect->top = rc.GetTop();
+                    pRect->right = rc.GetRight();
+                    pRect->bottom = rc.GetBottom();
+                }
+            }
+            break;
+
 #ifndef __WXMICROWIN__
         case WM_ACTIVATEAPP:
             wxTheApp->SetActive(wParam != 0, FindFocus());
@@ -3225,7 +3259,7 @@ bool wxWindowMSW::HandleInitDialog(WXHWND WXUNUSED(hWndFocus))
 
 bool wxWindowMSW::HandleDropFiles(WXWPARAM wParam)
 {
-#if defined (__WXMICROWIN__) 
+#if defined (__WXMICROWIN__)
     return FALSE;
 #else // __WXMICROWIN__
     HDROP hFilesInfo = (HDROP) wParam;
@@ -3265,9 +3299,6 @@ bool wxWindowMSW::HandleDropFiles(WXWPARAM wParam)
 #endif
 }
 
-#ifdef __DIGITALMARS__
-extern "C" HCURSOR wxGetCurrentBusyCursor();
-#endif
 
 bool wxWindowMSW::HandleSetCursor(WXHWND WXUNUSED(hWnd),
                                   short nHitTest,
@@ -3392,16 +3423,24 @@ bool wxWindowMSW::MSWOnDrawItem(int id, WXDRAWITEMSTRUCT *itemStruct)
     }
 #endif // wxUSE_MENUS_NATIVE
 
+#endif // USE_OWNER_DRAWN
+
 #if wxUSE_CONTROLS
+
+#if wxUSE_OWNER_DRAWN
     wxWindow *item = FindItem(id);
     if ( item && item->IsKindOf(CLASSINFO(wxControl)) )
-    {
         return ((wxControl *)item)->MSWOnDraw(itemStruct);
-    }
-#endif // wxUSE_CONTROLS
-
+#elif !defined(__WXUNIVERSAL__)
+    // we may still have owner-drawn buttons internally because we have to make
+    // them owner-drawn to support colour change
+    wxWindow *item = FindItem(id);
+    if ( item && item->IsKindOf(CLASSINFO(wxButton)) )
+        return ((wxButton *)item)->MSWOnDraw(itemStruct);
 #endif // USE_OWNER_DRAWN
 
+#endif // wxUSE_CONTROLS
+
     return FALSE;
 }
 
@@ -3694,6 +3733,9 @@ extern wxCOLORMAP *wxGetStdColourMap()
 
 bool wxWindowMSW::HandlePaint()
 {
+//    if (GetExtraStyle() & wxWS_EX_THEMED_BACKGROUND)
+//        return FALSE;
+
 #ifdef __WIN32__
     HRGN hRegion = ::CreateRectRgn(0, 0, 0, 0); // Dummy call to get a handle
     if ( !hRegion )
@@ -3746,6 +3788,29 @@ bool wxWindowMSW::HandleEraseBkgnd(WXHDC hdc)
     if ( ::IsIconic(GetHwnd()) )
         return TRUE;
 
+#if 0
+    if (GetParent() && GetParent()->GetExtraStyle() & wxWS_EX_THEMED_BACKGROUND)
+    {
+        return FALSE;
+    }
+
+    if (GetExtraStyle() & wxWS_EX_THEMED_BACKGROUND)
+    {
+        if (wxUxThemeEngine::Get())
+        {
+            WXHTHEME hTheme = wxUxThemeEngine::Get()->m_pfnOpenThemeData(GetHWND(), L"TAB");
+            if (hTheme)
+            {
+                WXURECT rect;
+                ::GetClientRect((HWND) GetHWND(), (RECT*) & rect);
+                wxUxThemeEngine::Get()->m_pfnDrawThemeBackground(hTheme, hdc, 10 /* TABP_BODY */, 0, &rect, &rect);
+                wxUxThemeEngine::Get()->m_pfnCloseThemeData(hTheme);
+                return TRUE;
+            }
+        }
+    }
+#endif
+
     wxDCTemp dc(hdc);
 
     dc.SetHDC(hdc);
@@ -3813,6 +3878,17 @@ bool wxWindowMSW::HandleMove(int x, int y)
     return GetEventHandler()->ProcessEvent(event);
 }
 
+bool wxWindowMSW::HandleMoving(wxRect& rect)
+{
+    wxMoveEvent event(rect, m_windowId);
+    event.SetEventObject(this);
+
+    bool rc = GetEventHandler()->ProcessEvent(event);
+    if (rc)
+        rect = event.GetRect();
+    return rc;
+}
+
 bool wxWindowMSW::HandleSize(int WXUNUSED(w), int WXUNUSED(h),
                              WXUINT WXUNUSED(flag))
 {
@@ -3825,6 +3901,17 @@ bool wxWindowMSW::HandleSize(int WXUNUSED(w), int WXUNUSED(h),
     return GetEventHandler()->ProcessEvent(event);
 }
 
+bool wxWindowMSW::HandleSizing(wxRect& rect)
+{
+    wxSizeEvent event(rect, m_windowId);
+    event.SetEventObject(this);
+
+    bool rc = GetEventHandler()->ProcessEvent(event);
+    if (rc)
+        rect = event.GetRect();
+    return rc;
+}
+
 bool wxWindowMSW::HandleGetMinMaxInfo(void *mmInfo)
 {
     MINMAXINFO *info = (MINMAXINFO *)mmInfo;