【问题标题】:How to create rounded wxBitmap buttons?如何创建圆角 wxBitmap 按钮?
【发布时间】:2021-04-23 17:39:13
【问题描述】:
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
}

【问题讨论】:

    标签: c++ user-interface wxwidgets onpaint wxtextctrl


    【解决方案1】:

    一般来说,原生控件的绘制是不能自定义的,只是它们不是为了配合你而设计的。如果您需要圆形按钮,则必须自己绘制它们并处理输入并为它们生成事件。

    您可能会发现wxRendererNativewxMouseEventsManager 分别对绘图和输入处理很有帮助。

    【讨论】:

      猜你喜欢
      • 2017-05-23
      • 1970-01-01
      • 2015-10-04
      • 2011-10-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-12-24
      相关资源
      最近更新 更多