如何创建圆角的wxBitmap按钮?


CustomBitmap *bitmapCtrl1 = new CustomBitmap(mainPanel, bitmap1, id+1, rollover_bitmap1, NULL, wxDefaultPosition, wxSize(125, 125));

CustomBitmap类来源于wxControl。这是我的OnPaint函数

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
}

一般来说,你不能自定义本地控件的绘图,它们只是不与你合作。如果你需要圆形按钮,你必须自己绘制它们,并为它们处理输入和生成事件。

您可以发现wxRendererNativewxMouseEventsManager分别有助于绘图和输入处理。

最新更新