]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/frame.cpp
fix VC 7.x release build problems
[wxWidgets.git] / src / msw / frame.cpp
index 920e95879b136dd8ea26c392002e366a230d8288..4ed0d984d637d9716210c5bc07fb85ef6a19faa5 100644 (file)
@@ -5,7 +5,7 @@
 // Modified by:
 // Created:     01/02/97
 // RCS-ID:      $Id$
 // Modified by:
 // Created:     01/02/97
 // RCS-ID:      $Id$
-// Copyright:   (c) Julian Smart and Markus Holzem
+// Copyright:   (c) Julian Smart
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
 // globals
 // ----------------------------------------------------------------------------
 
 // globals
 // ----------------------------------------------------------------------------
 
-extern const wxChar *wxFrameClassName;
-
 #if wxUSE_MENUS_NATIVE
 #if wxUSE_MENUS_NATIVE
-extern wxMenu *wxCurrentPopupMenu;
+    extern wxMenu *wxCurrentPopupMenu;
 #endif // wxUSE_MENUS_NATIVE
 
 // ----------------------------------------------------------------------------
 #endif // wxUSE_MENUS_NATIVE
 
 // ----------------------------------------------------------------------------
@@ -74,7 +72,6 @@ extern wxMenu *wxCurrentPopupMenu;
 // ----------------------------------------------------------------------------
 
 BEGIN_EVENT_TABLE(wxFrame, wxFrameBase)
 // ----------------------------------------------------------------------------
 
 BEGIN_EVENT_TABLE(wxFrame, wxFrameBase)
-    EVT_ACTIVATE(wxFrame::OnActivate)
     EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged)
 END_EVENT_TABLE()
 
     EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged)
 END_EVENT_TABLE()
 
@@ -110,11 +107,8 @@ void wxFrame::Init()
     m_fsStatusBarFields = 0;
     m_fsStatusBarHeight = 0;
     m_fsToolBarHeight = 0;
     m_fsStatusBarFields = 0;
     m_fsStatusBarHeight = 0;
     m_fsToolBarHeight = 0;
-//  m_fsMenu = 0;
 
     m_wasMinimized = FALSE;
 
     m_wasMinimized = FALSE;
-
-    m_winLastFocused = (wxWindow *)NULL;
 }
 
 bool wxFrame::Create(wxWindow *parent,
 }
 
 bool wxFrame::Create(wxWindow *parent,
@@ -326,7 +320,7 @@ void wxFrame::OnSysColourChanged(wxSysColourChangedEvent& event)
 // Pass TRUE to show full screen, FALSE to restore.
 bool wxFrame::ShowFullScreen(bool show, long style)
 {
 // Pass TRUE to show full screen, FALSE to restore.
 bool wxFrame::ShowFullScreen(bool show, long style)
 {
-    if ( IsFullScreen() == show ) 
+    if ( IsFullScreen() == show )
         return FALSE;
 
     if (show)
         return FALSE;
 
     if (show)
@@ -397,58 +391,8 @@ bool wxFrame::ShowFullScreen(bool show, long style)
             SetMenu((HWND)GetHWND(), (HMENU)m_hMenu);
 #endif
     }
             SetMenu((HWND)GetHWND(), (HMENU)m_hMenu);
 #endif
     }
-    
-    return wxFrameBase::ShowFullScreen(show, style);
-}
-
-// Default activation behaviour - set the focus for the first child
-// subwindow found.
-void wxFrame::OnActivate(wxActivateEvent& event)
-{
-    if ( event.GetActive() )
-    {
-        // restore focus to the child which was last focused
-        wxLogTrace(_T("focus"), _T("wxFrame %08x activated."), m_hWnd);
-
-        wxWindow *parent = m_winLastFocused ? m_winLastFocused->GetParent()
-                                            : NULL;
-        if ( !parent )
-        {
-            parent = this;
-        }
-
-        wxSetFocusToChild(parent, &m_winLastFocused);
-    }
-    else // deactivating
-    {
-        // remember the last focused child if it is our child
-        m_winLastFocused = FindFocus();
 
 
-        // so we NULL it out if it's a child from some other frame
-        wxWindow *win = m_winLastFocused;
-        while ( win )
-        {
-            if ( win->IsTopLevel() )
-            {
-                if ( win != this )
-                {
-                    m_winLastFocused = NULL;
-                }
-
-                break;
-            }
-
-            win = win->GetParent();
-        }
-
-        wxLogTrace(_T("focus"),
-                   _T("wxFrame %08x deactivated, last focused: %08x."),
-                   m_hWnd,
-                   m_winLastFocused ? GetHwndOf(m_winLastFocused)
-                                    : NULL);
-
-        event.Skip();
-    }
+    return wxFrameBase::ShowFullScreen(show, style);
 }
 
 // ----------------------------------------------------------------------------
 }
 
 // ----------------------------------------------------------------------------
@@ -495,6 +439,8 @@ void wxFrame::PositionToolBar()
         else
         {
             tw = width;
         else
         {
             tw = width;
+            if ( toolbar->GetWindowStyleFlag() & wxTB_FLAT )
+                th -= 3;
         }
 
         // use the 'real' MSW position here, don't offset relativly to the
         }
 
         // use the 'real' MSW position here, don't offset relativly to the
@@ -602,8 +548,9 @@ bool wxFrame::HandlePaint()
 #ifndef __WXMICROWIN__
         if ( m_iconized )
         {
 #ifndef __WXMICROWIN__
         if ( m_iconized )
         {
-            HICON hIcon = m_icon.Ok() ? GetHiconOf(m_icon)
-                                      : (HICON)GetDefaultIcon();
+            const wxIcon& icon = GetIcon();
+            HICON hIcon = icon.Ok() ? GetHiconOf(icon)
+                                    : (HICON)GetDefaultIcon();
 
             // Hold a pointer to the dc so long as the OnPaint() message
             // is being processed
 
             // Hold a pointer to the dc so long as the OnPaint() message
             // is being processed
@@ -691,9 +638,7 @@ bool wxFrame::HandleSize(int x, int y, WXUINT id)
         PositionToolBar();
 #endif // wxUSE_TOOLBAR
 
         PositionToolBar();
 #endif // wxUSE_TOOLBAR
 
-        wxSizeEvent event(wxSize(x, y), m_windowId);
-        event.SetEventObject( this );
-        processed = GetEventHandler()->ProcessEvent(event);
+        processed = wxWindow::HandleSize(x, y, id);
     }
 
     return processed;
     }
 
     return processed;
@@ -747,23 +692,27 @@ bool wxFrame::HandleMenuSelect(WXWORD nItem, WXWORD flags, WXHMENU hMenu)
 #endif
     else
     {
 #endif
     else
     {
-#if wxUSE_STATUSBAR
         // don't give hints for separators (doesn't make sense) nor for the
         // items opening popup menus (they don't have them anyhow) but do clear
         // the status line - otherwise, we would be left with the help message
         // for the previous item which doesn't apply any more
         // don't give hints for separators (doesn't make sense) nor for the
         // items opening popup menus (they don't have them anyhow) but do clear
         // the status line - otherwise, we would be left with the help message
         // for the previous item which doesn't apply any more
-        wxStatusBar *statbar = GetStatusBar();
-        if ( statbar )
-        {
-            statbar->SetStatusText(wxEmptyString);
-        }
-#endif // wxUSE_STATUSBAR
+        DoGiveHelp(wxEmptyString, FALSE);
 
         return FALSE;
     }
 
     wxMenuEvent event(wxEVT_MENU_HIGHLIGHT, item);
 
         return FALSE;
     }
 
     wxMenuEvent event(wxEVT_MENU_HIGHLIGHT, item);
-    event.SetEventObject( this );
+    event.SetEventObject(this);
+
+    return GetEventHandler()->ProcessEvent(event);
+}
+
+bool wxFrame::HandleMenuLoop(const wxEventType& evtType, WXWORD isPopup)
+{
+    // we don't have the menu id here, so we use the id to specify if the event
+    // was from a popup menu or a normal one
+    wxMenuEvent event(evtType, isPopup ? -1 : 0);
+    event.SetEventObject(this);
 
     return GetEventHandler()->ProcessEvent(event);
 }
 
     return GetEventHandler()->ProcessEvent(event);
 }
@@ -785,6 +734,10 @@ long wxFrame::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
             processed = !Close();
             break;
 
             processed = !Close();
             break;
 
+        case WM_SIZE:
+            processed = HandleSize(LOWORD(lParam), HIWORD(lParam), wParam);
+            break;
+
         case WM_COMMAND:
             {
                 WORD id, cmd;
         case WM_COMMAND:
             {
                 WORD id, cmd;
@@ -796,6 +749,10 @@ long wxFrame::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
             }
             break;
 
             }
             break;
 
+        case WM_PAINT:
+            processed = HandlePaint();
+            break;
+
 #ifndef __WXMICROWIN__
         case WM_MENUSELECT:
             {
 #ifndef __WXMICROWIN__
         case WM_MENUSELECT:
             {
@@ -806,30 +763,31 @@ long wxFrame::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
                 processed = HandleMenuSelect(item, flags, hmenu);
             }
             break;
                 processed = HandleMenuSelect(item, flags, hmenu);
             }
             break;
-#endif
 
 
-        case WM_PAINT:
-            processed = HandlePaint();
+#ifndef __WIN16__
+        case WM_ENTERMENULOOP:
+            processed = HandleMenuLoop(wxEVT_MENU_OPEN, wParam);
             break;
 
             break;
 
-#ifndef __WXMICROWIN__
+        case WM_EXITMENULOOP:
+            processed = HandleMenuLoop(wxEVT_MENU_CLOSE, wParam);
+            break;
+#endif // __WIN16__
+
         case WM_QUERYDRAGICON:
             {
         case WM_QUERYDRAGICON:
             {
-                HICON hIcon = m_icon.Ok() ? GetHiconOf(m_icon)
-                                          : (HICON)GetDefaultIcon();
+                const wxIcon& icon = GetIcon();
+                HICON hIcon = icon.Ok() ? GetHiconOf(icon)
+                                        : (HICON)GetDefaultIcon();
                 rc = (long)hIcon;
                 processed = rc != 0;
             }
             break;
                 rc = (long)hIcon;
                 processed = rc != 0;
             }
             break;
-#endif
-
-        case WM_SIZE:
-            processed = HandleSize(LOWORD(lParam), HIWORD(lParam), wParam);
-            break;
+#endif // !__WXMICROWIN__
     }
 
     if ( !processed )
     }
 
     if ( !processed )
-        rc = wxWindow::MSWWindowProc(message, wParam, lParam);
+        rc = wxFrameBase::MSWWindowProc(message, wParam, lParam);
 
     return rc;
 }
 
     return rc;
 }