+
+ 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 )
+ {
+ // we must use position in SetOwnerDrawnMenuItem because
+ // all separators have the same id
+ int pos = 0;
+ wxMenuItemList::compatibility_iterator node = GetMenuItems().GetFirst();
+ while (node)
+ {
+ wxMenuItem* item = node->GetData();
+
+ if ( !item->IsOwnerDrawn())
+ {
+ item->SetOwnerDrawn(true);
+ SetOwnerDrawnMenuItem(GetHmenu(), pos,
+ reinterpret_cast<ULONG_PTR>(item), TRUE);
+ }
+
+ item->SetMarginWidth(m_maxBitmapWidth);
+
+ node = node->GetNext();
+ pos++;
+ }
+
+ // set menu as ownerdrawn
+ m_ownerDrawn = true;
+
+ ResetMaxAccelWidth();
+ }
+ // only update our margin for equals alignment to other item
+ else if ( !updateAllMargins )
+ {
+ pItem->SetMarginWidth(m_maxBitmapWidth);
+ }