]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/toplevel.cpp
Added MSWPositionForWxMenu() method which is used to translate wxWindows
[wxWidgets.git] / src / msw / toplevel.cpp
index 41d5a0d46a434211df9ad6ef78cceab198443de1..760362ee3d835ff4521ce15befdda9dc575175e7 100644 (file)
 #include "wx/module.h"
 
 #include "wx/msw/private.h"
+
+#if defined(__WXWINCE__)
+  #include <ole2.h>
+  #include <shellapi.h>
+  #if _WIN32_WCE < 400
+    #include <aygshell.h>
+  #endif
+#include "wx/msw/wince/missing.h"
+#endif
+
 #include "wx/msw/winundef.h"
 
 // This can't be undefed in winundef.h or
@@ -124,6 +134,24 @@ END_EVENT_TABLE()
 // wxTopLevelWindowMSW creation
 // ----------------------------------------------------------------------------
 
+wxTopLevelWindowMSW::wxTopLevelWindowMSW()
+{
+    Init();
+}
+
+wxTopLevelWindowMSW::wxTopLevelWindowMSW(wxWindow *parent,
+                                         wxWindowID id,
+                                         const wxString& title,
+                                         const wxPoint& pos,
+                                         const wxSize& size,
+                                         long style,
+                                         const wxString& name)
+{
+    Init();
+
+    (void)Create(parent, id, title, pos, size, style, name);
+}
+
 void wxTopLevelWindowMSW::Init()
 {
     m_iconized =
@@ -445,7 +473,7 @@ bool wxTopLevelWindowMSW::Create(wxWindow *parent,
                                  long style,
                                  const wxString& name)
 {
-    bool ret = false;
+    bool ret wxDUMMY_INITIALIZE(false);
 
     // init our fields
     Init();
@@ -697,10 +725,13 @@ bool wxTopLevelWindowMSW::ShowFullScreen(bool show, long style)
         else // fall back to the main desktop
 #else // wxUSE_DISPLAY
         {
-            // FIXME: implement for WinCE
-#ifndef __WXWINCE__
             // resize to the size of the desktop
             wxCopyRECTToRect(wxGetWindowRect(::GetDesktopWindow()), rect);
+#ifdef __WXWINCE__
+            // FIXME: size of the bottom menu (toolbar)
+            // should be taken in account
+            rect.height += rect.y;
+            rect.y       = 0;
 #endif
         }
 #endif // wxUSE_DISPLAY
@@ -727,12 +758,19 @@ bool wxTopLevelWindowMSW::ShowFullScreen(bool show, long style)
                      rect.x, rect.y, rect.width, rect.height,
                      flags);
 
+#if defined(__WXWINCE__) && _WIN32_WCE < 400
+        ::SHFullScreen(GetHwnd(), SHFS_HIDETASKBAR | SHFS_HIDESIPBUTTON);
+#endif
+
         // finally send an event allowing the window to relayout itself &c
         wxSizeEvent event(rect.GetSize(), GetId());
         GetEventHandler()->ProcessEvent(event);
     }
     else // stop showing full screen
     {
+#if defined(__WXWINCE__) && _WIN32_WCE < 400
+        ::SHFullScreen(GetHwnd(), SHFS_SHOWTASKBAR | SHFS_SHOWSIPBUTTON);
+#endif
         Maximize(m_fsIsMaximized);
         SetWindowLong(GetHwnd(),GWL_STYLE, m_fsOldWindowStyle);
         SetWindowPos(GetHwnd(),HWND_TOP,m_fsOldSize.x, m_fsOldSize.y,
@@ -863,17 +901,22 @@ void wxTopLevelWindowMSW::OnActivate(wxActivateEvent& event)
 {
     if ( event.GetActive() )
     {
-        // restore focus to the child which was last focused
-//        wxLogTrace(_T("focus"), _T("wxTLW %08x activated."), (int) m_hWnd);
+        // restore focus to the child which was last focused unless we already
+        // have it
+        wxLogTrace(_T("focus"), _T("wxTLW %08x activated."), (int) m_hWnd);
 
-        wxWindow *parent = m_winLastFocused ? m_winLastFocused->GetParent()
-                                            : NULL;
-        if ( !parent )
+        wxWindow *winFocus = FindFocus();
+        if ( !winFocus || wxGetTopLevelParent(winFocus) != this )
         {
-            parent = this;
-        }
+            wxWindow *parent = m_winLastFocused ? m_winLastFocused->GetParent()
+                                                : NULL;
+            if ( !parent )
+            {
+                parent = this;
+            }
 
-        wxSetFocusToChild(parent, &m_winLastFocused);
+            wxSetFocusToChild(parent, &m_winLastFocused);
+        }
     }
     else // deactivating
     {
@@ -884,23 +927,12 @@ void wxTopLevelWindowMSW::OnActivate(wxActivateEvent& event)
         {
             // let it know that it doesn't have focus any more
             m_winLastFocused->HandleKillFocus((WXHWND)NULL);
-        }
 
-        // so we NULL it out if it's a child from some other frame
-        wxWindow *win = m_winLastFocused;
-        while ( win )
-        {
-            if ( win->IsTopLevel() )
+            // and don't remember it if it's a child from some other frame
+            if ( wxGetTopLevelParent(m_winLastFocused) != this )
             {
-                if ( win != this )
-                {
-                    m_winLastFocused = NULL;
-                }
-
-                break;
+                m_winLastFocused = NULL;
             }
-
-            win = win->GetParent();
         }
 
         wxLogTrace(_T("focus"),