+
+ bool updateAllMargins = false;
+
+ // get size of bitmap always return valid value (0 for invalid bitmap),
+ // so we don't needed check if bitmap is valid ;)
+ int uncheckedW = pItem->GetBitmap(false).GetWidth();
+ int checkedW = pItem->GetBitmap(true).GetWidth();
+
+ if ( m_maxBitmapWidth < uncheckedW )
+ {
+ m_maxBitmapWidth = uncheckedW;
+ updateAllMargins = true;
+ }
+
+ if ( m_maxBitmapWidth < checkedW )
+ {
+ m_maxBitmapWidth = checkedW;
+ updateAllMargins = true;
+ }
+
+ // make other item ownerdrawn and update margin width for equals alignment
+ if ( !m_ownerDrawn || updateAllMargins )
+ {
+ wxMenuItemList::compatibility_iterator node = GetMenuItems().GetFirst();
+ while (node)
+ {
+ wxMenuItem* item = node->GetData();
+
+ if ( !item->IsSeparator() )
+ {
+ if ( !item->IsOwnerDrawn() )
+ {
+ item->SetOwnerDrawn(true);
+ SetOwnerDrawnMenuItem(GetHmenu(), item->GetMSWId(),
+ reinterpret_cast<ULONG_PTR>(item));
+ }
+ item->SetMarginWidth(m_maxBitmapWidth);
+ }
+
+ node = node->GetNext();
+ }
+
+ // set menu as ownerdrawn
+ m_ownerDrawn = true;
+ }
+ // only update our margin for equals alignment to other item
+ else if ( !updateAllMargins )
+ {
+ pItem->SetMarginWidth(m_maxBitmapWidth);
+ }