Developer forums (C::B DEVELOPMENT STRICTLY!) > Development

Refixed wxWidget Patch: menu items with icon not correctly aligned (since wx263)

<< < (6/11) > >>

stahta01:

--- Quote from: killerbot on December 30, 2006, 04:09:05 pm ---damn berlios, can't get to the raw patch :-(

--- End quote ---


--- Code: ---Index: src/plugins/contrib/keybinder/menuutils.cpp
===================================================================
--- src/plugins/contrib/keybinder/menuutils.cpp (revision 3442)
+++ src/plugins/contrib/keybinder/menuutils.cpp (working copy)
@@ -190,40 +190,54 @@
 // ----------------------------------------------------------------------------
 // RebuildMenuitem
 // ----------------------------------------------------------------------------
-wxMenuItem* wxMenuCmd::RebuildMenuitem(wxMenuItem* pMnuItem)
-{//+v0.4.25 WXMSW
-   // Since wxWidgets 2.6.3, we don't have to rebuild the menuitem
-   // to preserve the bitmapped menu icon.
-    return pMnuItem;
-
-}//RebuildMenuitem
+//wxMenuItem* wxMenuCmd::RebuildMenuitem(wxMenuItem* pMnuItem)
+//{//+v0.4.25 WXMSW
+//   // Since wxWidgets 2.6.3, we don't have to rebuild the menuitem
+//   // to preserve the bitmapped menu icon.
+//    return pMnuItem;
+//
+//}//RebuildMenuitem
 // ----------------------------------------------------------------------------
 // The following routine was used when wxWidgets would not SetText()
 // without clobbering the menu Bitmap icon
 // ----------------------------------------------------------------------------
-//wxMenuItem* wxMenuCmd::RebuildMenuitem(wxMenuItem* pMnuItem)
-//{//+v0.4.6 WXMSW
-// // ---------------------------------------------------------------
-// //  Do it the slow/hard way, remove and delete the menu item
-// // ---------------------------------------------------------------
-//    wxMenu* pMenu = pMnuItem->GetMenu();
-//    wxMenuItemList items = pMenu->GetMenuItems();
-//    int pos = items.IndexOf(pMnuItem);
-//   // rebuild the menuitem
-//    wxMenuItem* pnewitem = new wxMenuItem(pMenu, m_nId, pMnuItem->GetText(),
-//                pMnuItem->GetHelp(), pMnuItem->GetKind(),
-//                pMnuItem->GetSubMenu() );
-//    pnewitem->SetBitmap(pMnuItem->GetBitmap() );
-//    pnewitem->SetFont(pMnuItem->GetFont() );
-//    // remove the menuitem
-//    pMenu->Destroy(pMnuItem);
-//    // update keybinder array menu item pointer
-//    m_pItem = pnewitem;
-//    // put the menuitem back on the menu
-//    pMenu->Insert(pos, pnewitem);
-//    return pnewitem;
-//
-//}//RebuildMenuitem
+wxMenuItem* wxMenuCmd::RebuildMenuitem(wxMenuItem* pMnuItem)
+{   //+v0.4.6 WXMSW
+ // ---------------------------------------------------------------
+ //  Do it the slow/hard way, remove and delete the menu item
+ // ---------------------------------------------------------------
+    wxMenu* pMenu = pMnuItem->GetMenu();
+    wxMenuItemList items = pMenu->GetMenuItems();
+    int pos = items.IndexOf(pMnuItem);
+    // rebuild the menuitem
+    wxMenuItem* pnewitem = new wxMenuItem(pMenu, m_nId, pMnuItem->GetText(),
+                pMnuItem->GetHelp(), pMnuItem->GetKind(),
+                pMnuItem->GetSubMenu() );
+    pnewitem->SetBitmap(pMnuItem->GetBitmap() );
+    pnewitem->SetFont(pMnuItem->GetFont() );
+#if wxUSE_OWNER_DRAWN
+    if ( pMnuItem->IsOwnerDrawn() )
+    {
+        pnewitem->SetOwnerDrawn(true);
+        pnewitem->SetMarginWidth(pMnuItem->GetMarginWidth());
+        pnewitem->SetDisabledBitmap(pMnuItem->GetDisabledBitmap());
+        if (pMnuItem->IsCheckable())
+        {
+            pnewitem->SetCheckable(true);
+            pnewitem->SetBitmaps(pMnuItem->GetBitmap(true), pMnuItem->GetBitmap(false));
+        }
+    }
+#endif
+
+    // remove the menuitem
+    pMenu->Destroy(pMnuItem);
+    // update keybinder array menu item pointer
+    m_pItem = pnewitem;
+    // put the menuitem back on the menu
+    pMenu->Insert(pos, pnewitem);
+    return pnewitem;
+
+}//RebuildMenuitem
 #endif //#if defined( __WXMSW__ )
 // ----------------------------------------------------------------------------
 bool wxMenuCmd::IsNumericMenuItem(wxMenuItem* pwxMenuItem)   //v0.2

--- End code ---

Tim S

Pecan:

--- Quote from: stahta01 on December 30, 2006, 03:30:20 pm ---Look at the Raw Patch View

https://developer.berlios.de/patch/download.php?id=1777

Tim S

--- End quote ---

Applied (w/verbage) SVN 3443.

I don't know what you want done with the menu.cpp patch.
I'll leave that to Lieven.

stahta01:

--- Quote from: Pecan on December 30, 2006, 05:23:04 pm ---
I don't know what you want done with the menu.cpp patch.
I'll leave that to Lieven.


--- End quote ---

Sorry, that is just in case someone wanted to test it, and see it fixes the icon alignment bug.
Tim S

killerbot:
yes, it works nicely. Well done guys.

stahta01:
The wxWidgets people have not done any thing yet, so I am starting work on the patch submission process.
I am looking at the wxWidgets sample going to try to compile and verify problem exists with ownerdrw sample. If anyone has a better sample to demo the bug please email me which one is better. Tim S

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version