]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/wince/menuce.cpp
Fixed filename in wxOSX-Cocoa's file dialog using extension of wrong file type.
[wxWidgets.git] / src / msw / wince / menuce.cpp
index c9905e452f8c48f89c5459592e4b88ccde0b9f80..6231ea1e2209bccd18a569ef1a939b4606c63848 100644 (file)
@@ -6,7 +6,7 @@
 // Created:     28.05.2004
 // RCS-ID:      $Id$
 // Copyright:   (c) Wlodzimierz Skiba
-// License:     wxWindows licence
+// Licence:     wxWindows licence
 ///////////////////////////////////////////////////////////////////////////////
 
 // ============================================================================
 // headers
 // ----------------------------------------------------------------------------
 
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
-    #pragma implementation "menuce"
-#endif
-
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
@@ -28,9 +24,7 @@
     #pragma hdrstop
 #endif
 
-#ifndef WX_PRECOMP
-    #include "wx/wx.h"
-#endif
+#if defined(__SMARTPHONE__) && defined(__WXWINCE__)
 
 #ifndef WX_PRECOMP
     #include "wx/app.h"
     #include "wx/menu.h"
 #endif //WX_PRECOMP
 
-#ifdef __SMARTPHONE__
-
 #include <windows.h>
 #include <ole2.h>
 #include <shellapi.h>
 #include <aygshell.h>
+#include <tpcshell.h>
+#include <tpcuser.h>
 #include "wx/msw/wince/missing.h"
 
 #include "wx/msw/wince/resources.h"
 
+#include "wx/stockitem.h"
+
 wxTopLevelWindowMSW::ButtonMenu::ButtonMenu()
 {
     m_id = wxID_ANY;
@@ -58,11 +54,7 @@ wxTopLevelWindowMSW::ButtonMenu::ButtonMenu()
 
 wxTopLevelWindowMSW::ButtonMenu::~ButtonMenu()
 {
-    if(m_menu)
-    {
-        delete m_menu;
-        m_menu = NULL;
-    };
+    wxDELETE(m_menu);
 }
 
 void wxTopLevelWindowMSW::SetLeftMenu(int id, const wxString& label, wxMenu *subMenu)
@@ -81,47 +73,50 @@ void wxTopLevelWindowMSW::ButtonMenu::SetButton(int id, const wxString& label, w
 {
     m_assigned = true;
     m_id = id;
-    m_label = label;
+    if(label.empty() && wxIsStockID(id))
+        m_label = wxGetStockLabel(id, wxSTOCK_NOFLAGS);
+    else
+        m_label = label;
     m_menu = subMenu;
 }
 
 wxMenu *wxTopLevelWindowMSW::ButtonMenu::DuplicateMenu(wxMenu *menu)
 {
-       // This is required in case of converting wxMenuBar to wxMenu in wxFrame::SetMenuBar.
-       // All submenus has to be recreated because of new owner.
+    // This is required in case of converting wxMenuBar to wxMenu in wxFrame::SetMenuBar.
+    // All submenus has to be recreated because of new owner.
 
-       wxMenu *duplication = new wxMenu;
+    wxMenu *duplication = new wxMenu;
 
-       if (menu)
-       {
+    if (menu)
+    {
         wxMenuItemList::compatibility_iterator node = menu->GetMenuItems().GetFirst();
         while (node)
-               {
-                       wxMenuItem *item = node->GetData();
-                       if (item)
-                       {
-                               wxMenu *submenu = NULL;
+        {
+            wxMenuItem *item = node->GetData();
+            if (item)
+            {
+                wxMenu *submenu = NULL;
 
-                               if(item->IsSubMenu())
-                                   submenu = DuplicateMenu( item->GetSubMenu() );
-                               else
-                                       submenu = NULL;
+                if(item->IsSubMenu())
+                    submenu = DuplicateMenu( item->GetSubMenu() );
+                else
+                    submenu = NULL;
 
-                               wxMenuItem *new_item = wxMenuItem::New(duplication, item->GetId(), item->GetLabel(), item->GetHelp(), item->GetKind(), submenu);
+                wxMenuItem *new_item = wxMenuItem::New(duplication, item->GetId(), item->GetLabel(), item->GetHelp(), item->GetKind(), submenu);
 
-                               if( item->IsCheckable() )
-                                   new_item->Check(item->IsChecked());
+                if( item->IsCheckable() )
+                    new_item->Check(item->IsChecked());
 
-                               new_item->Enable( item->IsEnabled() );
+                new_item->Enable( item->IsEnabled() );
 
-                               duplication->Append(new_item);
-                       }
+                duplication->Append(new_item);
+            }
             node = node->GetNext();
-               }
-               
-       }
+        }
 
-       return duplication;
+    }
+
+    return duplication;
 }
 
 void wxMenuToHMenu(wxMenu* in, HMENU hMenu)
@@ -189,11 +184,11 @@ void wxTopLevelWindowMSW::ReloadButton(ButtonMenu& button, UINT menuID)
     button_info.fsState = TBSTATE_ENABLED;
     wxStrcpy(buf, button.GetLabel().c_str());
     button_info.pszText = buf;
-    SendMessage(m_MenuBarHWND, TB_SETBUTTONINFO, menuID, (LPARAM) &button_info);
+    ::SendMessage(m_MenuBarHWND, TB_SETBUTTONINFO, menuID, (LPARAM) &button_info);
 
     if(button.IsMenu())
     {
-        HMENU hPopupMenu = (HMENU) SendMessage(m_MenuBarHWND, SHCMBM_GETSUBMENU, 0, menuID);
+        HMENU hPopupMenu = (HMENU) ::SendMessage(m_MenuBarHWND, SHCMBM_GETSUBMENU, 0, menuID);
         RemoveMenu(hPopupMenu, 0, MF_BYPOSITION);
         wxMenuToHMenu(button.GetMenu(), hPopupMenu);
     }
@@ -226,7 +221,7 @@ void wxTopLevelWindowMSW::ReloadAllButtons()
 
     if (!SHCreateMenuBar(&menu_bar))
     {
-        wxFAIL_MSG( _T("SHCreateMenuBar failed") );
+        wxFAIL_MSG( wxT("SHCreateMenuBar failed") );
         return;
     }
 
@@ -241,6 +236,10 @@ void wxTopLevelWindowMSW::ReloadAllButtons()
         ::ShowWindow( prev_MenuBar, SW_HIDE );
     ::ShowWindow( m_MenuBarHWND, SW_SHOW );
 
+    // Setup backspace key handling
+    SendMessage(m_MenuBarHWND, SHCMBM_OVERRIDEKEY, VK_TBACK,
+                MAKELPARAM( SHMBOF_NODEFAULT | SHMBOF_NOTIFY,
+                            SHMBOF_NODEFAULT | SHMBOF_NOTIFY ));
 }
 
 bool wxTopLevelWindowMSW::HandleCommand(WXWORD id, WXWORD WXUNUSED(cmd), WXHWND WXUNUSED(control))
@@ -257,5 +256,18 @@ bool wxTopLevelWindowMSW::HandleCommand(WXWORD id, WXWORD WXUNUSED(cmd), WXHWND
     return false;
 }
 
-#endif // __SMARTPHONE__
+bool wxTopLevelWindowMSW::MSWShouldPreProcessMessage(WXMSG* pMsg)
+{
+    MSG *msg = (MSG *)pMsg;
+
+    // Process back key to be like backspace.
+    if (msg->message == WM_HOTKEY)
+    {
+        if (HIWORD(msg->lParam) == VK_TBACK)
+            SHSendBackToFocusWindow(msg->message, msg->wParam, msg->lParam);
+    }
+
+    return wxTopLevelWindowBase::MSWShouldPreProcessMessage(pMsg);
+}
 
+#endif // __SMARTPHONE__ && __WXWINCE__