- Add InsertXXXButton() to wxRibbonButtonBar and wxRibbonToolBar (Emilien Kia).
- Allow enabling/disabling and toggling tools in wxRibbonToolBar (Emilien Kia).
- Fix multiple item selection in generic wxTreeCtrl (Igor Korot).
+- Implement wxMenuBar::IsEnabledTop() for all major ports (Igor Korot).
- Implement best size calculation for report mode wxListCtrl.
GTK:
virtual wxMenuItem* FindItem( int id, wxMenu **menu = NULL ) const;
virtual void EnableTop( size_t pos, bool flag );
+ virtual bool IsEnabledTop(size_t pos) const;
virtual void SetMenuLabel( size_t pos, const wxString& label );
virtual wxString GetMenuLabel( size_t pos ) const;
virtual wxMenu *Remove(size_t pos);
virtual void EnableTop( size_t pos, bool flag );
+ virtual bool IsEnabledTop(size_t pos) const;
virtual void SetMenuLabel( size_t pos, const wxString& label );
virtual wxString GetMenuLabel( size_t pos ) const;
virtual wxMenu *Remove(size_t pos);
virtual void EnableTop( size_t pos, bool flag );
+ virtual bool IsEnabledTop(size_t pos) const;
virtual void SetMenuLabel( size_t pos, const wxString& label );
virtual wxString GetMenuLabel( size_t pos ) const;
virtual bool Enable( bool enable = true );
*/
void Enable(int id, bool enable);
+ /**
+ Returns true if the menu with the given index is enabled.
+
+ @param pos
+ The menu position (0-based)
+
+ @since 2.9.4
+ */
+ bool IsEnabledTop(size_t pos) const;
+
/**
Enables or disables a whole menu.
gtk_widget_set_sensitive( menu->m_owner, flag );
}
+bool wxMenuBar::IsEnabledTop(size_t pos) const
+{
+ wxMenuList::compatibility_iterator node = m_menus.Item( pos );
+ wxCHECK_MSG( node, false, wxS("invalid index in IsEnabledTop") );
+ wxMenu* const menu = node->GetData();
+ wxCHECK_MSG( menu->m_owner, true, wxS("no menu owner?") );
+ return gtk_widget_get_sensitive( menu->m_owner );
+}
+
wxString wxMenuBar::GetMenuLabel( size_t pos ) const
{
wxMenuList::compatibility_iterator node = m_menus.Item( pos );
Refresh();
}
+bool wxMenuBar::IsEnabledTop(size_t pos) const
+{
+ wxCHECK_MSG( pos < GetMenuCount(), false, wxS("invalid menu index") );
+ WinStruct<MENUITEMINFO> mii;
+ mii.fMask = MIIM_STATE;
+ if ( !::GetMenuItemInfo(GetHmenu(), pos, TRUE, &mii) )
+ {
+ wxLogLastError(wxS("GetMenuItemInfo(menubar)"));
+ }
+
+ return !(mii.fState & MFS_GRAYED);
+}
+
void wxMenuBar::SetMenuLabel(size_t pos, const wxString& label)
{
wxCHECK_RET( pos < GetMenuCount(), wxT("invalid menu index") );
Refresh();
}
+bool wxMenuBar::IsEnabledTop(size_t pos) const
+{
+ wxCHECK_MSG( IsAttached(), true,
+ wxT("doesn't work with unattached menubars") );
+
+ wxMenuItem* const item = m_rootMenu->FindItemByPosition(pos+firstMenuPos);
+ wxCHECK_MSG( item, false, wxT("invalid menu index") );
+
+ return item->IsEnabled();
+}
+
bool wxMenuBar::Enable(bool enable)
{
wxCHECK_MSG( IsAttached(), false, wxT("doesn't work with unattached menubars") );
CPPUNIT_TEST_SUITE( MenuTestCase );
CPPUNIT_TEST( FindInMenubar );
CPPUNIT_TEST( FindInMenu );
+ CPPUNIT_TEST( EnableTop );
CPPUNIT_TEST( Count );
CPPUNIT_TEST( Labels );
CPPUNIT_TEST( RadioItems );
void FindInMenubar();
void FindInMenu();
+ void EnableTop();
void Count();
void Labels();
void RadioItems();
}
}
+void MenuTestCase::EnableTop()
+{
+ wxMenuBar* const bar = m_frame->GetMenuBar();
+ CPPUNIT_ASSERT( bar->IsEnabledTop(0) );
+ bar->EnableTop( 0, false );
+ CPPUNIT_ASSERT( !bar->IsEnabledTop(0) );
+ bar->EnableTop( 0, true );
+ CPPUNIT_ASSERT( bar->IsEnabledTop(0) );
+}
+
void MenuTestCase::Count()
{
wxMenuBar* bar = m_frame->GetMenuBar();