wxZeroMemory(info);
info.cbSize = sizeof(info);
info.fMask = MIIM_STATE;
- if ( !GetMenuItemInfo(hMenu, id, flags & MF_BYCOMMAND ? FALSE : TRUE, & info) )
+ // MF_BYCOMMAND is zero so test MF_BYPOSITION
+ if ( !::GetMenuItemInfo(hMenu, id, flags & MF_BYPOSITION ? TRUE : FALSE , & info) )
wxLogLastError(wxT("GetMenuItemInfo"));
return info.fState;
}
wxBEGIN_HANDLERS_TABLE(wxMenuInfo)
wxEND_HANDLERS_TABLE()
-wxCONSTRUCTOR_2( wxMenuInfo , wxMenu* , Menu , wxString , Title )
+wxCONSTRUCTOR_2( wxMenuInfo , wxMenu* , Menu , wxString , Title )
wxCOLLECTION_TYPE_INFO( wxMenuInfo * , wxMenuInfoList ) ;
// Construct a menu with optional title (then use append)
void wxMenu::Init()
{
- m_doBreak = FALSE;
+ m_doBreak = false;
m_startRadioGroup = -1;
// create the menu
}
// if we have a title, insert it in the beginning of the menu
- if ( !!m_title )
+ if ( !m_title.IsEmpty() )
{
Append(idMenuTitle, m_title);
AppendSeparator();
void wxMenu::Break()
{
// this will take effect during the next call to Append()
- m_doBreak = TRUE;
+ m_doBreak = true;
}
void wxMenu::Attach(wxMenuBarBase *menubar)
// (and don't forget to reset the flag)
if ( m_doBreak ) {
flags |= MF_MENUBREAK;
- m_doBreak = FALSE;
+ m_doBreak = false;
}
if ( pItem->IsSeparator() ) {
{
wxLogLastError(wxT("Insert or AppendMenu"));
- return FALSE;
+ return false;
}
// if we just appended the title, highlight it
GetMenuBar()->Refresh();
}
- return TRUE;
+ return true;
}
void wxMenu::EndRadioGroup()
{
wxCHECK_MSG( item, NULL, _T("NULL item in wxMenu::DoAppend") );
- bool check = FALSE;
+ bool check = false;
if ( item->GetKind() == wxITEM_RADIO )
{
item->SetRadioGroupEnd(m_startRadioGroup);
// ensure that we have a checked item in the radio group
- check = TRUE;
+ check = true;
}
else // extend the current radio group
{
if ( check )
{
// check the item initially
- item->Check(TRUE);
+ item->Check(true);
}
return item;
bool wxMenu::MSWCommand(WXUINT WXUNUSED(param), WXWORD id)
{
// ignore commands from the menu title
-
- // NB: VC++ generates wrong assembler for `if ( id != idMenuTitle )'!!
if ( id != (WXWORD)idMenuTitle )
{
- // VZ: previosuly, the command int was set to id too which was quite
- // useless anyhow (as it could be retrieved using GetId()) and
- // uncompatible with wxGTK, so now we use the command int instead
- // to pass the checked status
- UINT menuState = ::GetMenuState(GetHmenu(), id, MF_BYCOMMAND) ;
- SendEvent(id, menuState & MF_CHECKED);
+ // get the checked status of the command: notice that menuState is the
+ // old state of the menu, so the test for MF_CHECKED must be inversed
+ UINT menuState = ::GetMenuState(GetHmenu(), id, MF_BYCOMMAND);
+ SendEvent(id, !(menuState & MF_CHECKED));
}
- return TRUE;
+ return true;
}
// ---------------------------------------------------------------------------
Init();
}
-wxMenuBar::wxMenuBar(int count, wxMenu *menus[], const wxString titles[])
+wxMenuBar::wxMenuBar(size_t count, wxMenu *menus[], const wxString titles[], long WXUNUSED(style))
{
Init();
m_titles.Alloc(count);
- for ( int i = 0; i < count; i++ )
+ for ( size_t i = 0; i < count; i++ )
{
m_menus.Append(menus[i]);
m_titles.Add(titles[i]);
{
// In Windows CE (not .NET), the menubar is always associated
// with a toolbar, which destroys the menu implicitly.
-#if defined(WINCE_WITHOUT_COMMANDBAR)
+#if defined(WINCE_WITHOUT_COMMANDBAR) && defined(__POCKETPC__)
if (GetToolBar())
- GetToolBar()->SetMenuBar(NULL);
+ {
+ wxToolMenuBar* toolMenuBar = wxDynamicCast(GetToolBar(), wxToolMenuBar);
+ if (toolMenuBar)
+ toolMenuBar->SetMenuBar(NULL);
+ }
#else
// we should free Windows resources only if Windows doesn't do it for us
// which happens if we're attached to a frame
m_commandBar = (WXHWND) NULL;
#else
::DestroyMenu((HMENU)m_hMenu);
-#endif
+#endif
m_hMenu = (WXHMENU)NULL;
}
#endif
HMENU hMenu = (HMENU)::SendMessage(hCommandBar, SHCMBM_GETMENU, (WPARAM)0, (LPARAM)0);
if (hMenu)
{
- TBBUTTON tbButton;
+ TBBUTTON tbButton;
memset(&tbButton, 0, sizeof(TBBUTTON));
tbButton.iBitmap = I_IMAGENONE;
tbButton.fsState = TBSTATE_ENABLED;
tbButton.fsStyle = TBSTYLE_DROPDOWN | TBSTYLE_NO_DROPDOWN_ARROW | TBSTYLE_AUTOSIZE;
-
+
size_t i;
for (i = 0; i < GetMenuCount(); i++)
{
tbButton.iString = (int) label.c_str();
int position = i;
-
+
tbButton.idCommand = NewControlId();
if (!::SendMessage(hCommandBar, TB_INSERTBUTTON, position, (LPARAM)&tbButton))
{
{
wxLogLastError(wxT("SetMenuItemInfo"));
}
-
+
#else
if ( ::ModifyMenu(GetHmenu(), mswpos, MF_BYPOSITION | MF_STRING | flagsOld,
id, label) == (int)0xFFFFFFFF )
: MSWPositionForWxMenu(GetMenu(pos),pos);
if ( !wxMenuBarBase::Insert(pos, menu, title) )
- return FALSE;
+ return false;
m_titles.Insert(title, pos);
{
#if defined(WINCE_WITHOUT_COMMANDAR)
if (!GetToolBar())
- return FALSE;
- TBBUTTON tbButton;
+ return false;
+ TBBUTTON tbButton;
memset(&tbButton, 0, sizeof(TBBUTTON));
tbButton.iBitmap = I_IMAGENONE;
tbButton.fsState = TBSTATE_ENABLED;
tbButton.fsStyle = TBSTYLE_DROPDOWN | TBSTYLE_NO_DROPDOWN_ARROW | TBSTYLE_AUTOSIZE;
-
+
HMENU hPopupMenu = (HMENU) menu->GetHMenu() ;
tbButton.dwData = (DWORD)hPopupMenu;
wxString label = wxStripMenuCodes(title);
tbButton.iString = (int) label.c_str();
-
+
tbButton.idCommand = NewControlId();
if (!::SendMessage((HWND) GetToolBar()->GetHWND(), TB_INSERTBUTTON, pos, (LPARAM)&tbButton))
{
wxLogLastError(wxT("TB_INSERTBUTTON"));
- return FALSE;
+ return false;
}
#else
if ( !::InsertMenu(GetHmenu(), mswpos,
Refresh();
}
- return TRUE;
+ return true;
}
bool wxMenuBar::Append(wxMenu *menu, const wxString& title)
{
WXHMENU submenu = menu ? menu->GetHMenu() : 0;
- wxCHECK_MSG( submenu, FALSE, wxT("can't append invalid menu to menubar") );
+ wxCHECK_MSG( submenu, false, wxT("can't append invalid menu to menubar") );
if ( !wxMenuBarBase::Append(menu, title) )
- return FALSE;
+ return false;
m_titles.Add(title);
{
#if defined(WINCE_WITHOUT_COMMANDAR)
if (!GetToolBar())
- return FALSE;
- TBBUTTON tbButton;
+ return false;
+ TBBUTTON tbButton;
memset(&tbButton, 0, sizeof(TBBUTTON));
tbButton.iBitmap = I_IMAGENONE;
tbButton.fsState = TBSTATE_ENABLED;
tbButton.fsStyle = TBSTYLE_DROPDOWN | TBSTYLE_NO_DROPDOWN_ARROW | TBSTYLE_AUTOSIZE;
-
+
size_t pos = GetMenuCount();
HMENU hPopupMenu = (HMENU) menu->GetHMenu() ;
tbButton.dwData = (DWORD)hPopupMenu;
wxString label = wxStripMenuCodes(title);
tbButton.iString = (int) label.c_str();
-
+
tbButton.idCommand = NewControlId();
if (!::SendMessage((HWND) GetToolBar()->GetHWND(), TB_INSERTBUTTON, pos, (LPARAM)&tbButton))
{
wxLogLastError(wxT("TB_INSERTBUTTON"));
- return FALSE;
+ return false;
}
#else
if ( !::AppendMenu(GetHmenu(), MF_POPUP | MF_STRING,
Refresh();
}
- return TRUE;
+ return true;
}
wxMenu *wxMenuBar::Remove(size_t pos)