[ wxwindows-Bugs-1713158 ] misalignment of items with bitmaps in menus again

SourceForge.net noreply at sourceforge.net
Wed Mar 19 17:12:32 PDT 2008


Bugs item #1713158, was opened at 2007-05-04 23:15
Message generated for change (Comment added) made by vadz
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=109863&aid=1713158&group_id=9863

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: wxMSW specific
Group: None
Status: Open
Resolution: None
>Priority: 6
Private: No
Submitted By: troelsk (troelsk)
Assigned to: Nobody/Anonymous (nobody)
Summary: misalignment of items with bitmaps in menus again

Initial Comment:

The ownerdraw code in wxCheckListBox (and in other places too probably) interferes with - and breaks! - menu bitmap alignment. The problem is probably with 
static wxOwnerDrawn::ms_nLastMarginWidth
I don't quite understand what a static here is good for.

How to reproduce:
In samples/menu/menu.cpp, replace the ShowContextMenu implementation with the code below.

Using wxMSW 2.8.4 RC2, MSVC6, WinXP SP2

/Troels

#include <wx/checklst.h>
void MyFrame::ShowContextMenu(const wxPoint& pos)
{
    wxMenu menu;
    wxMenuItem *item = new wxMenuItem(&menu, Menu_Help_About, _T("&About"));
    item->SetBitmap(copy_xpm);
    menu.Append(item);
    menu.Append(Menu_Popup_Submenu, _T("&Submenu"), CreateDummyMenu(NULL));
    PopupMenu(&menu, pos.x, pos.y);

    wxCheckListBox lb;
    lb.Create(this, wxID_ANY);
    lb.Append("THIS SCREWS UP MENU MARGINS. THE BITMAP ABOVE BECOMES MISALIGNED NEXT TIME");
    // problem is probably with 
    // static wxOwnerDrawn::ms_nLastMarginWidth
}


----------------------------------------------------------------------

>Comment By: Vadim Zeitlin (vadz)
Date: 2008-03-20 01:12

Message:
Logged In: YES 
user_id=71618
Originator: NO

Note to self: The margin width should never have been global... We must
have different widths for different menus/controls.

----------------------------------------------------------------------

Comment By: troelsk (troelsk)
Date: 2008-02-10 00:35

Message:
Logged In: YES 
user_id=1290727
Originator: YES


The problem persists, in 2.8.7 and trunk.


File Added: misalignment.png

----------------------------------------------------------------------

Comment By: troelsk (troelsk)
Date: 2007-09-13 22:06

Message:
Logged In: YES 
user_id=1290727
Originator: YES

The problem persists, in 2.8.5 and 2.9 (Sept.7th).

>I don't quite understand what a static here is good for.
Read: It should go away.

Here's a user space workaround, if anybody needs it.

class MyCheckListBox : public wxCheckListBox
{
// Attributes
public:
   static int m_margin_width_bug;

// Construction
public:
   MyCheckListBox();
   virtual ~MyCheckListBox();
};

/*static*/ int
MyCheckListBox::m_margin_width_bug(wxOwnerDrawn().GetMarginWidth());

MyCheckListBox::MyCheckListBox() : wxCheckListBox(),
m_bFullRowSelection(true)
{
}

MyCheckListBox::~MyCheckListBox()
{
   wxOwnerDrawn().SetMarginWidth(m_margin_width_bug);
}

Make sure your app never instantiates wxCheckListBox, use MyCheckListBox
exclusively.


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=109863&aid=1713158&group_id=9863




More information about the wx-dev mailing list