Smartphone menus.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@27832 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Włodzimierz Skiba
2004-06-16 06:37:55 +00:00
parent 665b71b17c
commit fb8a56b77c
9 changed files with 393 additions and 136 deletions

View File

@@ -1319,6 +1319,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
src/msw/wince/filedlgwce.cpp src/msw/wince/filedlgwce.cpp
src/msw/wince/helpwce.cpp src/msw/wince/helpwce.cpp
src/msw/wince/tbarwce.cpp src/msw/wince/tbarwce.cpp
src/msw/wince/menuce.cpp
</set> </set>
<set var="WINCE_HDR" hints="files"> <set var="WINCE_HDR" hints="files">
wx/generic/fdrepdlg.h wx/generic/fdrepdlg.h
@@ -1327,6 +1328,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
wx/msw/wince/libraries.h wx/msw/wince/libraries.h
wx/msw/wince/missing.h wx/msw/wince/missing.h
wx/msw/wince/tbarwce.h wx/msw/wince/tbarwce.h
wx/msw/wince/resources.h
</set> </set>

View File

@@ -81,6 +81,12 @@ public:
void SetLastFocus(wxWindow *win) { m_winLastFocused = win; } void SetLastFocus(wxWindow *win) { m_winLastFocused = win; }
wxWindow *GetLastFocus() const { return m_winLastFocused; } wxWindow *GetLastFocus() const { return m_winLastFocused; }
#ifdef __SMARTPHONE__
void SetLeftMenu(int id = wxID_ANY, const wxString& label = wxEmptyString, wxMenu *subMenu = NULL);
void SetRightMenu(int id = wxID_ANY, const wxString& label = wxEmptyString, wxMenu *subMenu = NULL);
bool HandleCommand(WXWORD id, WXWORD cmd, WXHWND control);
#endif // __SMARTPHONE__
protected: protected:
// common part of all ctors // common part of all ctors
void Init(); void Init();
@@ -123,6 +129,41 @@ protected:
// the last focused child: we restore focus to it on activation // the last focused child: we restore focus to it on activation
wxWindow *m_winLastFocused; wxWindow *m_winLastFocused;
#ifdef __SMARTPHONE__
class ButtonMenu
{
public:
ButtonMenu();
~ButtonMenu();
void SetButton(int id = wxID_ANY,
const wxString& label = wxEmptyString,
wxMenu *subMenu = NULL);
bool IsAssigned() const {return m_assigned;}
bool IsMenu() const {return m_menu!=NULL;}
int GetId() const {return m_id;}
wxMenu* GetMenu() const {return m_menu;}
wxString GetLabel() {return m_label;}
static wxMenu *DuplicateMenu(wxMenu *menu);
protected:
int m_id;
wxString m_label;
wxMenu *m_menu;
bool m_assigned;
};
ButtonMenu m_LeftButton;
ButtonMenu m_RightButton;
HWND m_MenuBarHWND;
void ReloadButton(ButtonMenu& button, UINT menuID);
void ReloadAllButtons();
#endif // __SMARTPHONE__
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
DECLARE_NO_COPY_CLASS(wxTopLevelWindowMSW) DECLARE_NO_COPY_CLASS(wxTopLevelWindowMSW)
}; };

View File

@@ -522,7 +522,11 @@
// Default is 1 // Default is 1
// //
// Recommended setting: 1 // Recommended setting: 1
#ifdef __SMARTPHONE__
#define wxUSE_STATUSBAR 0
#else
#define wxUSE_STATUSBAR 1 #define wxUSE_STATUSBAR 1
#endif
// Two status bar implementations are available under Win32: the generic one // Two status bar implementations are available under Win32: the generic one
// or the wrapper around native control. For native look and feel the native // or the wrapper around native control. For native look and feel the native

View File

@@ -30,13 +30,13 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#if (defined( __GNUWIN32__ ) && !defined(__TWIN32__)) || defined(__MWERKS__) #if (defined( __GNUWIN32__ ) && !defined(__TWIN32__)) || defined(__MWERKS__)
#include <wx/msw/gnuwin32/winresrc.h> #include <wx/msw/gnuwin32/winresrc.h>
#else #else
#include <windows.h> #include <windows.h>
#endif #endif
#if defined(_WIN32_WCE) #if defined(_WIN32_WCE)
#include <commctrl.h> #include "wx\msw\wince\wince.rc"
#endif #endif
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
@@ -57,95 +57,6 @@ BEGIN
END END
END END
#ifdef _WIN32_WCE
// Dummy menubar/toolbar for WinCE
5000 RCDATA DISCARDABLE
BEGIN
// Popup menu name
5000,
// Count of items to put on the menu
0
END
5000 MENU DISCARDABLE
BEGIN
POPUP "Dummy"
BEGIN
MENUITEM "Dummy" 99
END
END
// A menubar for Smartphone, which can only have 1 or 2 menu buttons.
#define IDR_SMARTPHONE_MENUBAR 5002
#define ID_FIRST_BUTTON 40001
#define ID_SECOND_BUTTON 40002
#define IDS_CAP_MENU 40003
#define ID_MENU_TEST 40004
#define IDS_DONE 40006
STRINGTABLE DISCARDABLE
BEGIN
5001 "Dummy menu"
IDS_DONE "Done"
IDS_CAP_MENU "Menu"
END
#ifndef I_IMAGENONE
#define I_IMAGENONE (-2)
#endif
#ifndef NOMENU
#define NOMENU 0xFFFF
#endif
#ifndef wxID_EXIT
#define wxID_EXIT 5006
#endif
// A resource for a one-button menubar
/*
IDR_SMARTPHONE_MENUBAR MENU DISCARDABLE
BEGIN
MENUITEM "Done", wxID_EXIT
END
STRINGTABLE DISCARDABLE
BEGIN
IDS_DONE "Done"
IDS_CAP_MENU "Menu"
END
IDR_SMARTPHONE_MENUBAR RCDATA DISCARDABLE
BEGIN
IDR_SMARTPHONE_MENUBAR, 1,
I_IMAGENONE, wxID_EXIT, TBSTATE_ENABLED, TBSTYLE_AUTOSIZE, IDS_DONE, 0, NOMENU,
END
*/
// A resource for a two-button menubar
IDR_SMARTPHONE_MENUBAR MENU DISCARDABLE
BEGIN
MENUITEM "Done", wxID_EXIT
POPUP "Menu"
BEGIN
MENUITEM "OK", wxID_EXIT
END
END
IDR_SMARTPHONE_MENUBAR RCDATA DISCARDABLE
BEGIN
IDR_SMARTPHONE_MENUBAR, 2,
I_IMAGENONE, wxID_EXIT, TBSTATE_ENABLED, TBSTYLE_AUTOSIZE, IDS_DONE, 0, NOMENU,
I_IMAGENONE, ID_SECOND_BUTTON, TBSTATE_ENABLED, TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE, IDS_CAP_MENU, 0, 1,
END
#endif
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
// //
// Standard wxWindows Cursors // Standard wxWindows Cursors

View File

@@ -25,6 +25,7 @@
#include "wx/wx.h" #include "wx/wx.h"
#endif #endif
#include "wx/datetime.h"
#include "wx/image.h" #include "wx/image.h"
#if wxUSE_COLOURDLG #if wxUSE_COLOURDLG
@@ -256,7 +257,7 @@ bool MyApp::OnInit()
file_menu->Append(wxID_ANY,_T("Entry dialogs"),entry_menu); file_menu->Append(wxID_ANY,_T("Entry dialogs"),entry_menu);
#endif #endif // wxUSE_TEXTDLG || wxUSE_NUMBERDLG
#if wxUSE_FILEDLG #if wxUSE_FILEDLG
@@ -327,9 +328,13 @@ bool MyApp::OnInit()
file_menu->AppendSeparator(); file_menu->AppendSeparator();
file_menu->Append(wxID_EXIT, _T("E&xit\tAlt-X")); file_menu->Append(wxID_EXIT, _T("E&xit\tAlt-X"));
#if !defined( __SMARTPHONE__ )
wxMenuBar *menu_bar = new wxMenuBar; wxMenuBar *menu_bar = new wxMenuBar;
menu_bar->Append(file_menu, _T("&File")); menu_bar->Append(file_menu, _T("&File"));
frame->SetMenuBar(menu_bar); frame->SetMenuBar(menu_bar);
#else
frame->SetRightMenu(wxID_ANY, _T("Menu"), file_menu);
#endif // __SMARTPHONE__
myCanvas = new MyCanvas(frame); myCanvas = new MyCanvas(frame);
myCanvas->SetBackgroundColour(*wxWHITE); myCanvas->SetBackgroundColour(*wxWHITE);
@@ -366,7 +371,9 @@ MyFrame::MyFrame(wxWindow *parent,
} }
#endif // wxUSE_COLOURDLG #endif // wxUSE_COLOURDLG
#if wxUSE_STATUSBAR
CreateStatusBar(); CreateStatusBar();
#endif // wxUSE_STATUSBAR
} }
#if wxUSE_COLOURDLG #if wxUSE_COLOURDLG

View File

@@ -131,7 +131,7 @@ wxEND_FLAGS( wxFrameStyle )
IMPLEMENT_DYNAMIC_CLASS_XTI(wxFrame, wxTopLevelWindow,"wx/frame.h") IMPLEMENT_DYNAMIC_CLASS_XTI(wxFrame, wxTopLevelWindow,"wx/frame.h")
wxBEGIN_PROPERTIES_TABLE(wxFrame) wxBEGIN_PROPERTIES_TABLE(wxFrame)
wxEVENT_PROPERTY( Menu , wxEVT_COMMAND_MENU_SELECTED , wxCommandEvent) wxEVENT_PROPERTY( Menu , wxEVT_COMMAND_MENU_SELECTED , wxCommandEvent)
wxPROPERTY( Title,wxString, SetTitle, GetTitle, wxString() , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) wxPROPERTY( Title,wxString, SetTitle, GetTitle, wxString() , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
wxPROPERTY_FLAGS( WindowStyle , wxFrameStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style wxPROPERTY_FLAGS( WindowStyle , wxFrameStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
@@ -318,7 +318,19 @@ void wxFrame::PositionStatusBar()
void wxFrame::AttachMenuBar(wxMenuBar *menubar) void wxFrame::AttachMenuBar(wxMenuBar *menubar)
{ {
#if defined(WINCE_WITHOUT_COMMANDBAR) #if defined(__SMARTPHONE__)
wxMenu *autoMenu = new wxMenu;
for( size_t n = 0; n < menubar->GetMenuCount(); n++ )
{
wxMenu *item = menubar->GetMenu(n);
wxString label = menubar->GetLabelTop(n);
wxMenu *new_item = wxTopLevelWindowMSW::ButtonMenu::DuplicateMenu(item);
autoMenu->Append(wxID_ANY, label, new_item);
}
SetRightMenu(wxID_ANY, _("Menu"), autoMenu);
#elif defined(WINCE_WITHOUT_COMMANDBAR)
if (!GetToolBar()) if (!GetToolBar())
{ {
wxToolBar* toolBar = new wxToolBar(this, -1, wxToolBar* toolBar = new wxToolBar(this, -1,
@@ -328,20 +340,20 @@ void wxFrame::AttachMenuBar(wxMenuBar *menubar)
SetToolBar(toolBar); SetToolBar(toolBar);
menubar->SetToolBar(toolBar); menubar->SetToolBar(toolBar);
} }
// Now adjust size for menu bar // Now adjust size for menu bar
int menuHeight = 26; int menuHeight = 26;
//When the main window is created using CW_USEDEFAULT the height of the //When the main window is created using CW_USEDEFAULT the height of the
// is created is not taken into account). So we resize the window after // is created is not taken into account). So we resize the window after
// if a menubar is present // if a menubar is present
{ {
RECT rc; RECT rc;
::GetWindowRect((HWND) GetHWND(), &rc); ::GetWindowRect((HWND) GetHWND(), &rc);
// adjust for menu / titlebar height // adjust for menu / titlebar height
rc.bottom -= (2*menuHeight-1); rc.bottom -= (2*menuHeight-1);
MoveWindow((HWND) GetHWND(), rc.left, rc.top, rc.right, rc.bottom, FALSE); MoveWindow((HWND) GetHWND(), rc.left, rc.top, rc.right, rc.bottom, FALSE);
} }
#endif #endif
wxFrameBase::AttachMenuBar(menubar); wxFrameBase::AttachMenuBar(menubar);
@@ -546,16 +558,16 @@ void wxFrame::PositionToolBar()
} }
#endif // wxUSE_STATUSBAR #endif // wxUSE_STATUSBAR
int x = 0; int x = 0;
int y = 0; int y = 0;
#if defined(WINCE_WITH_COMMANDBAR) #if defined(WINCE_WITH_COMMANDBAR)
// We're using a commandbar - so we have to allow for it. // We're using a commandbar - so we have to allow for it.
if (GetMenuBar() && GetMenuBar()->GetCommandBar()) if (GetMenuBar() && GetMenuBar()->GetCommandBar())
{ {
RECT rect; RECT rect;
::GetWindowRect((HWND) GetMenuBar()->GetCommandBar(), &rect); ::GetWindowRect((HWND) GetMenuBar()->GetCommandBar(), &rect);
y = rect.bottom - rect.top; y = rect.bottom - rect.top;
} }
#endif #endif
int tx, ty; int tx, ty;
@@ -807,19 +819,19 @@ bool wxFrame::HandleSize(int x, int y, WXUINT id)
#endif // wxUSE_TOOLBAR #endif // wxUSE_TOOLBAR
#if defined(WINCE_WITH_COMMANDBAR) #if defined(WINCE_WITH_COMMANDBAR)
// Position the menu command bar // Position the menu command bar
if (GetMenuBar() && GetMenuBar()->GetCommandBar()) if (GetMenuBar() && GetMenuBar()->GetCommandBar())
{ {
RECT rect; RECT rect;
::GetWindowRect((HWND) GetMenuBar()->GetCommandBar(), &rect); ::GetWindowRect((HWND) GetMenuBar()->GetCommandBar(), &rect);
wxSize clientSz = GetClientSize(); wxSize clientSz = GetClientSize();
if ( !::MoveWindow((HWND) GetMenuBar()->GetCommandBar(), 0, 0, clientSz.x, rect.bottom - rect.top, true ) ) if ( !::MoveWindow((HWND) GetMenuBar()->GetCommandBar(), 0, 0, clientSz.x, rect.bottom - rect.top, true ) )
{ {
wxLogLastError(wxT("MoveWindow")); wxLogLastError(wxT("MoveWindow"));
} }
} }
#endif #endif
@@ -852,6 +864,14 @@ bool wxFrame::HandleCommand(WXWORD id, WXWORD cmd, WXHWND control)
} }
#endif // wxUSE_MENUS_NATIVE #endif // wxUSE_MENUS_NATIVE
#ifdef __SMARTPHONE__
// handle here commands from Smartphone menu bar
if ( wxTopLevelWindow::HandleCommand(id, cmd, control ) )
{
return true;
}
#endif // __SMARTPHONE__
if ( ProcessCommand(id) ) if ( ProcessCommand(id) )
{ {
return TRUE; return TRUE;
@@ -1029,12 +1049,12 @@ wxPoint wxFrame::GetClientAreaOrigin() const
#endif // wxUSE_TOOLBAR #endif // wxUSE_TOOLBAR
#if defined(WINCE_WITH_COMMANDBAR) #if defined(WINCE_WITH_COMMANDBAR)
if (GetMenuBar() && GetMenuBar()->GetCommandBar()) if (GetMenuBar() && GetMenuBar()->GetCommandBar())
{ {
RECT rect; RECT rect;
::GetWindowRect((HWND) GetMenuBar()->GetCommandBar(), &rect); ::GetWindowRect((HWND) GetMenuBar()->GetCommandBar(), &rect);
pt.y += (rect.bottom - rect.top); pt.y += (rect.bottom - rect.top);
} }
#endif #endif
return pt; return pt;

View File

@@ -79,9 +79,11 @@ int wxMessageDialog::ShowModal()
unsigned int msStyle = MB_OK; unsigned int msStyle = MB_OK;
if (m_dialogStyle & wxYES_NO) if (m_dialogStyle & wxYES_NO)
{ {
#if !defined(__SMARTPHONE__)
if (m_dialogStyle & wxCANCEL) if (m_dialogStyle & wxCANCEL)
msStyle = MB_YESNOCANCEL; msStyle = MB_YESNOCANCEL;
else else
#endif // __SMARTPHONE__
msStyle = MB_YESNO; msStyle = MB_YESNO;
if (m_dialogStyle & wxNO_DEFAULT) if (m_dialogStyle & wxNO_DEFAULT)

View File

@@ -143,6 +143,10 @@ void wxTopLevelWindowMSW::Init()
m_fsIsShowing = FALSE; m_fsIsShowing = FALSE;
m_winLastFocused = (wxWindow *)NULL; m_winLastFocused = (wxWindow *)NULL;
#ifdef __SMARTPHONE__
m_MenuBarHWND = 0;
#endif
} }
WXDWORD wxTopLevelWindowMSW::MSWGetStyle(long style, WXDWORD *exflags) const WXDWORD wxTopLevelWindowMSW::MSWGetStyle(long style, WXDWORD *exflags) const
@@ -523,6 +527,11 @@ bool wxTopLevelWindowMSW::Create(wxWindow *parent,
} }
#endif #endif
#ifdef __SMARTPHONE__
SetLeftMenu(wxID_EXIT, _("Done"));
SetRightMenu(); // to nothing for initialization
#endif
return ret; return ret;
} }

261
src/msw/wince/menuce.cpp Normal file
View File

@@ -0,0 +1,261 @@
///////////////////////////////////////////////////////////////////////////////
// Name: src/msw/wince/menuce.cpp
// Purpose: Smartphone menus implementation
// Author: Wlodzimierz ABX Skiba
// Modified by:
// Created: 28.05.2004
// RCS-ID: $Id$
// Copyright: (c) Wlodzimierz Skiba
// License: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
// ============================================================================
// declarations
// ============================================================================
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma implementation "menuce"
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
#ifndef WX_PRECOMP
#include "wx/app.h"
#include "wx/toplevel.h"
#include "wx/menu.h"
#endif //WX_PRECOMP
#ifdef __SMARTPHONE__
#include <windows.h>
#include <ole2.h>
#include <shellapi.h>
#include <aygshell.h>
#include "wx/msw/wince/missing.h"
#include "wx/msw/wince/resources.h"
wxTopLevelWindowMSW::ButtonMenu::ButtonMenu()
{
m_id = wxID_ANY;
m_label = wxEmptyString;
m_menu = NULL;
m_assigned = false;
}
wxTopLevelWindowMSW::ButtonMenu::~ButtonMenu()
{
if(m_menu)
{
delete m_menu;
m_menu = NULL;
};
}
void wxTopLevelWindowMSW::SetLeftMenu(int id, const wxString& label, wxMenu *subMenu)
{
m_LeftButton.SetButton(id, label, subMenu);
ReloadAllButtons();
}
void wxTopLevelWindowMSW::SetRightMenu(int id, const wxString& label, wxMenu *subMenu)
{
m_RightButton.SetButton(id, label, subMenu);
ReloadAllButtons();
}
void wxTopLevelWindowMSW::ButtonMenu::SetButton(int id, const wxString& label, wxMenu *subMenu)
{
m_assigned = true;
m_id = id;
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.
wxMenu *duplication = new wxMenu;
if (menu)
{
wxMenuItemList::compatibility_iterator node = menu->GetMenuItems().GetFirst();
while (node)
{
wxMenuItem *item = node->GetData();
if (item)
{
wxMenu *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);
if( item->IsCheckable() )
new_item->Check(item->IsChecked());
new_item->Enable( item->IsEnabled() );
duplication->Append(new_item);
}
node = node->GetNext();
}
}
return duplication;
}
void wxMenuToHMenu(wxMenu* in, HMENU hMenu)
{
if(!in) return;
wxChar buf[256];
wxMenuItemList::compatibility_iterator node = in->GetMenuItems().GetFirst();
while ( node )
{
wxMenuItem *item = node->GetData();
UINT uFlags = 0;
UINT uIDNewItem;
LPCTSTR lpNewItem;
if( item->IsSeparator() )
{
uFlags |= MF_SEPARATOR;
uIDNewItem = (unsigned)wxID_ANY;
lpNewItem = NULL;
}
else
{
// label
uFlags |= MF_STRING;
wxStrcpy(buf, item->GetLabel().c_str());
lpNewItem = buf;
// state
uFlags |= ( item->IsEnabled() ? MF_ENABLED : MF_GRAYED );
// checked
uFlags |= ( item->IsChecked() ? MF_CHECKED : MF_UNCHECKED );
if( item->IsSubMenu() )
{
uFlags |= MF_POPUP;
HMENU hSubMenu = CreatePopupMenu();
wxMenuToHMenu(item->GetSubMenu(), hSubMenu);
uIDNewItem = (UINT) hSubMenu;
}
else
{
uIDNewItem = item->GetId();
}
}
AppendMenu(hMenu, uFlags, uIDNewItem, lpNewItem);
node = node->GetNext();
}
}
void wxTopLevelWindowMSW::ReloadButton(ButtonMenu& button, UINT menuID)
{
TBBUTTONINFO button_info;
wxChar buf[256];
// set button name
memset (&button_info, 0, sizeof (TBBUTTONINFO));
button_info.cbSize = sizeof(TBBUTTONINFO);
button_info.dwMask = TBIF_TEXT | TBIF_STATE;
button_info.fsState = TBSTATE_ENABLED;
wxStrcpy(buf, button.GetLabel().c_str());
button_info.pszText = buf;
SendMessage(m_MenuBarHWND, TB_SETBUTTONINFO, menuID, (LPARAM) &button_info);
if(button.IsMenu())
{
HMENU hPopupMenu = (HMENU) SendMessage(m_MenuBarHWND, SHCMBM_GETSUBMENU, 0, menuID);
RemoveMenu(hPopupMenu, 0, MF_BYPOSITION);
wxMenuToHMenu(button.GetMenu(), hPopupMenu);
}
}
void wxTopLevelWindowMSW::ReloadAllButtons()
{
// first reaload only after initialization of both buttons
// it should is done at the end of Create() of wxTLW
if(!m_LeftButton.IsAssigned() || !m_RightButton.IsAssigned())
return;
SHMENUBARINFO menu_bar;
wxString label;
memset (&menu_bar, 0, sizeof (SHMENUBARINFO));
menu_bar.cbSize = sizeof (SHMENUBARINFO);
menu_bar.hwndParent = (HWND) GetHWND();
if(m_LeftButton.IsMenu() && m_RightButton.IsMenu())
menu_bar.nToolBarId = IDR_MENUBAR_BOTH_MENUS;
else if(m_LeftButton.IsMenu())
menu_bar.nToolBarId = IDR_MENUBAR_LEFT_MENU;
else if(m_RightButton.IsMenu())
menu_bar.nToolBarId = IDR_MENUBAR_RIGHT_MENU;
else
menu_bar.nToolBarId = IDR_MENUBAR_ONE_BUTTON;
menu_bar.hInstRes = wxGetInstance();
if (!SHCreateMenuBar(&menu_bar))
{
wxFAIL_MSG( _T("SHCreateMenuBar failed") );
return;
}
HWND prev_MenuBar = m_MenuBarHWND;
m_MenuBarHWND = menu_bar.hwndMB;
ReloadButton(m_LeftButton, IDM_LEFT);
ReloadButton(m_RightButton, IDM_RIGHT);
// hide previous and show new menubar
if ( prev_MenuBar )
::ShowWindow( prev_MenuBar, SW_HIDE );
::ShowWindow( m_MenuBarHWND, SW_SHOW );
}
bool wxTopLevelWindowMSW::HandleCommand(WXWORD id, WXWORD WXUNUSED(cmd), WXHWND WXUNUSED(control))
{
// handle here commands from Smartphone menu bar
if ( id == IDM_LEFT || id == IDM_RIGHT )
{
int menuId = id == IDM_LEFT ? m_LeftButton.GetId() : m_RightButton.GetId() ;
wxCommandEvent commandEvent(wxEVT_COMMAND_MENU_SELECTED, menuId);
commandEvent.SetEventObject(this);
GetEventHandler()->ProcessEvent(commandEvent);
return true;
}
return false;
}
#endif // __SMARTPHONE__