X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/3d27b5746f360ea930bd1046fd61b1b27440ba7b..adb799d6ef8e1ba754ab08b26e64fa40219f95f8:/src/msw/menu.cpp diff --git a/src/msw/menu.cpp b/src/msw/menu.cpp index 478048e703..a2162b9064 100644 --- a/src/msw/menu.cpp +++ b/src/msw/menu.cpp @@ -73,7 +73,7 @@ extern wxMenu *wxCurrentPopupMenu; // ---------------------------------------------------------------------------- // the (popup) menu title has this special id -static const int idMenuTitle = -2; +static const int idMenuTitle = -3; // ---------------------------------------------------------------------------- // private functions @@ -137,7 +137,7 @@ template<> void wxCollectionToVariantArray( wxMenuItemList const &theList, wxxVa wxBEGIN_PROPERTIES_TABLE(wxMenu) wxEVENT_PROPERTY( Select , wxEVT_COMMAND_MENU_SELECTED , wxCommandEvent) wxPROPERTY( Title, wxString , SetTitle, GetTitle, wxString(), 0 /*flags*/ , wxT("Helpstring") , wxT("group") ) - wxREADONLY_PROPERTY_FLAGS( MenuStyle , wxMenuStyle , long , GetStyle , , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style + wxREADONLY_PROPERTY_FLAGS( MenuStyle , wxMenuStyle , long , GetStyle , EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style wxPROPERTY_COLLECTION( MenuItems , wxMenuItemList , wxMenuItem* , Append , GetMenuItems , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) wxEND_PROPERTIES_TABLE() @@ -163,7 +163,7 @@ IMPLEMENT_DYNAMIC_CLASS_XTI_CALLBACK(wxMenuBar, wxWindow ,"wx/menu.h",wxMenuBarS IMPLEMENT_DYNAMIC_CLASS_XTI(wxMenuInfo, wxObject , "wx/menu.h" ) wxBEGIN_PROPERTIES_TABLE(wxMenuInfo) - wxREADONLY_PROPERTY( Menu , wxMenu* , GetMenu , , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) + wxREADONLY_PROPERTY( Menu , wxMenu* , GetMenu , EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) wxREADONLY_PROPERTY( Title , wxString , GetTitle , wxString() , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) wxEND_PROPERTIES_TABLE() @@ -321,7 +321,7 @@ void wxMenu::UpdateAccel(wxMenuItem *item) if ( IsAttached() ) { - m_menuBar->RebuildAccelTable(); + GetMenuBar()->RebuildAccelTable(); } } //else: it is a separator, they can't have accels, nothing to do @@ -419,9 +419,9 @@ bool wxMenu::DoInsertOrAppend(wxMenuItem *pItem, size_t pos) #endif // __WIN32__ // if we're already attached to the menubar, we must update it - if ( IsAttached() && m_menuBar->IsAttached() ) + if ( IsAttached() && GetMenuBar()->IsAttached() ) { - m_menuBar->Refresh(); + GetMenuBar()->Refresh(); } return TRUE; @@ -433,9 +433,9 @@ void wxMenu::EndRadioGroup() m_startRadioGroup = -1; } -bool wxMenu::DoAppend(wxMenuItem *item) +wxMenuItem* wxMenu::DoAppend(wxMenuItem *item) { - wxCHECK_MSG( item, FALSE, _T("NULL item in wxMenu::DoAppend") ); + wxCHECK_MSG( item, NULL, _T("NULL item in wxMenu::DoAppend") ); bool check = FALSE; @@ -478,7 +478,7 @@ bool wxMenu::DoAppend(wxMenuItem *item) if ( !wxMenuBase::DoAppend(item) || !DoInsertOrAppend(item) ) { - return FALSE; + return NULL; } if ( check ) @@ -487,12 +487,15 @@ bool wxMenu::DoAppend(wxMenuItem *item) item->Check(TRUE); } - return TRUE; + return item; } -bool wxMenu::DoInsert(size_t pos, wxMenuItem *item) +wxMenuItem* wxMenu::DoInsert(size_t pos, wxMenuItem *item) { - return wxMenuBase::DoInsert(pos, item) && DoInsertOrAppend(item, pos); + if (wxMenuBase::DoInsert(pos, item) && DoInsertOrAppend(item, pos)) + return item; + else + return NULL; } wxMenuItem *wxMenu::DoRemove(wxMenuItem *item) @@ -529,10 +532,10 @@ wxMenuItem *wxMenu::DoRemove(wxMenuItem *item) wxLogLastError(wxT("RemoveMenu")); } - if ( IsAttached() && m_menuBar->IsAttached() ) + if ( IsAttached() && GetMenuBar()->IsAttached() ) { // otherwise, the chane won't be visible - m_menuBar->Refresh(); + GetMenuBar()->Refresh(); } // and from internal data structures @@ -659,8 +662,8 @@ wxWindow *wxMenu::GetWindow() const { if ( m_invokingWindow != NULL ) return m_invokingWindow; - else if ( m_menuBar != NULL) - return m_menuBar->GetFrame(); + else if ( GetMenuBar() != NULL) + return GetMenuBar()->GetFrame(); return NULL; } @@ -673,14 +676,15 @@ void wxMenuBar::Init() { m_eventHandler = this; m_hMenu = 0; -#if wxUSE_TOOLBAR && defined(__WXWINCE__) && (_WIN32_WCE < 400 || wxUSE_POCKETPC_UI) +#if wxUSE_TOOLBAR && defined(__WXWINCE__) && (_WIN32_WCE < 400 || defined(__POCKETPC__) || defined(__SMARTPHONE__)) m_toolBar = NULL; #endif // Not using a combined wxToolBar/wxMenuBar? then use // a commandbar in WinCE .NET just to implement the // menubar. -#if defined(__WXWINCE__) && (_WIN32_WCE >= 400 && !wxUSE_POCKETPC_UI) +#if defined(__WXWINCE__) && (_WIN32_WCE >= 400 && !defined(__POCKETPC__) && !defined(__SMARTPHONE__)) m_commandBar = NULL; + m_adornmentsAdded = false; #endif } @@ -713,7 +717,7 @@ wxMenuBar::~wxMenuBar() { // In Windows CE (not .NET), the menubar is always associated // with a toolbar, which destroys the menu implicitly. -#if defined(__WXWINCE__) && (_WIN32_WCE < 400 || wxUSE_POCKETPC_UI) +#if defined(__WXWINCE__) && (_WIN32_WCE < 400 || defined(__POCKETPC__) || defined(__SMARTPHONE__)) if (GetToolBar()) GetToolBar()->SetMenuBar(NULL); #else @@ -721,7 +725,7 @@ wxMenuBar::~wxMenuBar() // which happens if we're attached to a frame if (m_hMenu && !IsAttached()) { -#if defined(__WXWINCE__) && (_WIN32_WCE >= 400 && !wxUSE_POCKETPC_UI) +#if defined(__WXWINCE__) && (_WIN32_WCE >= 400 && !defined(__POCKETPC__) && !defined(__SMARTPHONE__)) ::DestroyWindow((HWND) m_commandBar); m_commandBar = (WXHWND) NULL; #else @@ -740,12 +744,12 @@ void wxMenuBar::Refresh() { wxCHECK_RET( IsAttached(), wxT("can't refresh unattached menubar") ); -#if defined(__WXWINCE__) && (_WIN32_WCE < 400 || wxUSE_POCKETPC_UI) +#if defined(__WXWINCE__) && (_WIN32_WCE < 400 || defined(__POCKETPC__) || defined(__SMARTPHONE__)) if (GetToolBar()) { CommandBar_DrawMenuBar((HWND) GetToolBar()->GetHWND(), 0); } -#elif defined(__WXWINCE__) && (_WIN32_WCE >= 400 && !wxUSE_POCKETPC_UI) +#elif defined(__WXWINCE__) && (_WIN32_WCE >= 400 && !defined(__POCKETPC__) && !defined(__SMARTPHONE__)) if (m_commandBar) DrawMenuBar((HWND) m_commandBar); #else @@ -759,7 +763,7 @@ WXHMENU wxMenuBar::Create() // since you have to use resources. // We'll have to find another way to add a menu // by changing/adding menu items to an existing menu. -#if defined(__WXWINCE__) && _WIN32_WCE < 400 +#if defined(__WXWINCE__) && (_WIN32_WCE < 400 || defined(__POCKETPC__) || defined(__SMARTPHONE__)) if ( m_hMenu != 0 ) return m_hMenu; @@ -829,7 +833,13 @@ int wxMenuBar::MSWPositionForWxMenu(wxMenu *menu, int wxpos) wxASSERT(menu); wxASSERT(menu->GetHMenu()); wxASSERT(m_hMenu); + +#if defined(__WXWINCE__) + int totalMSWItems = GetMenuCount(); +#else int totalMSWItems = GetMenuItemCount((HMENU)m_hMenu); +#endif + int i; // For old C++ compatibility for(i=wxpos; iGetHWND(), TB_DELETEBUTTON, (UINT) pos, (LPARAM) 0)) @@ -1161,10 +1171,14 @@ void wxMenuBar::Attach(wxFrame *frame) { wxMenuBarBase::Attach(frame); -#if defined(__WXWINCE__) && _WIN32_WCE >= 400 +#if defined(__WXWINCE__) if (!m_hMenu) this->Create(); -#if wxUSE_POCKETPC_UI +#if _WIN32_WCE < 400 || defined(__POCKETPC__) || defined(__SMARTPHONE__) + + // No idea why this was here, but it seems to be obsolete. + // Remove after testing with other WinCE combinations - April 2004 +#if 0 if (GetToolBar()) { HWND hCommandBar = (HWND) GetToolBar()->GetHWND(); @@ -1173,6 +1187,7 @@ void wxMenuBar::Attach(wxFrame *frame) wxLogLastError(wxT("CommandBar_InsertMenubarEx")); } } +#endif #else if (!m_commandBar) m_commandBar = (WXHWND) CommandBar_Create(wxGetInstance(), (HWND) frame->GetHWND(), NewControlId()); @@ -1187,7 +1202,7 @@ void wxMenuBar::Attach(wxFrame *frame) } } #endif - // wxUSE_POCKETPC_UI + // PSPC/WFSP #endif // __WXWINCE__ && _WIN32_WCE >= 400 @@ -1196,6 +1211,23 @@ void wxMenuBar::Attach(wxFrame *frame) #endif // wxUSE_ACCEL } +#if defined(__WXWINCE__) && (_WIN32_WCE >= 400 && !defined(__POCKETPC__) && !defined(__SMARTPHONE__)) +bool wxMenuBar::AddAdornments(long style) +{ + if (m_adornmentsAdded || !m_commandBar) + return false; + + if (style & wxCLOSE_BOX) + { + if (!CommandBar_AddAdornments((HWND) m_commandBar, 0, 0)) + wxLogLastError(wxT("CommandBar_AddAdornments")); + else + return true; + } + return false; +} +#endif + void wxMenuBar::Detach() { wxMenuBarBase::Detach();