How to create rounded wxBitmap buttons?

219 Views Asked by At
CustomBitmap *bitmapCtrl1 = new CustomBitmap(mainPanel, bitmap1, id+1, rollover_bitmap1, NULL, wxDefaultPosition, wxSize(125, 125));

CustomBitmap class is derived from wxControl. And this is my OnPaint function.

void CustomBitmap::OnPaint(wxPaintEvent& WXUNUSED(event))
{
    wxPaintDC dc((wxWindow *) this);
    SetTransparent(0);
    
    if (m_enter)
    {
        dc.DrawBitmap(m_bmpmouseover, 0, 0, true);
    }
    else
    {
        if (m_leftdown || m_rightdown){
            dc.DrawBitmap(m_bmpclick, 0, 0, true);
        }
        else {
            dc.DrawBitmap(m_bmpstatic, 0, 0, true); 
        }
    }
#ifdef WX3 
    //dc.EndDrawing();
#else
    // dc.EndDrawing();
#endif
}
1

There are 1 best solutions below

0
On

Generally speaking, you can't customize drawing of the native controls, they just are not made to cooperate with you. If you need round buttons, you will have to draw them and also handle input and generate events for them entirely yourself.

You may find wxRendererNative and wxMouseEventsManager helpful for drawing and input handling respectively.