示例#1
0
/* static */
wxBitmapButton*
wxBitmapButtonBase::NewCloseButton(wxWindow* parent, wxWindowID winid)
{
    wxCHECK_MSG( parent, NULL, wxS("Must have a valid parent") );

    const wxColour colBg = parent->GetBackgroundColour();

#ifdef wxHAS_DRAW_TITLE_BAR_BITMAP
    const wxSize sizeBmp = wxArtProvider::GetSizeHint(wxART_BUTTON);
    wxBitmap bmp = GetCloseButtonBitmap(parent, sizeBmp, colBg);
#else // !wxHAS_DRAW_TITLE_BAR_BITMAP
    wxBitmap bmp = wxArtProvider::GetBitmap(wxART_CLOSE, wxART_BUTTON);
#endif // wxHAS_DRAW_TITLE_BAR_BITMAP

    wxBitmapButton* const button = new wxBitmapButton
                                       (
                                        parent,
                                        winid,
                                        bmp,
                                        wxDefaultPosition,
                                        wxDefaultSize,
                                        wxBORDER_NONE
                                       );

#ifdef wxHAS_DRAW_TITLE_BAR_BITMAP
    button->SetBitmapPressed(
        GetCloseButtonBitmap(parent, sizeBmp, colBg, wxCONTROL_PRESSED));

    button->SetBitmapCurrent(
        GetCloseButtonBitmap(parent, sizeBmp, colBg, wxCONTROL_CURRENT));
#endif // wxHAS_DRAW_TITLE_BAR_BITMAP

    // The button should blend with its parent background.
    button->SetBackgroundColour(colBg);

    return button;
}
示例#2
0
bool wxInfoBarGeneric::Create(wxWindow *parent, wxWindowID winid)
{
    // calling Hide() before Create() ensures that we're created initially
    // hidden
    Hide();
    if ( !wxWindow::Create(parent, winid) )
        return false;

    // use special, easy to notice, colours
    const wxColour colBg = wxSystemSettings::GetColour(wxSYS_COLOUR_INFOBK);
    SetBackgroundColour(colBg);
    SetOwnForegroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_INFOTEXT));

    // create the controls: icon, text and the button to dismiss the
    // message.

    // the icon is not shown unless it's assigned a valid bitmap
    m_icon = new wxStaticBitmap(this, wxID_ANY, wxNullBitmap);

    m_text = new wxStaticText(this, wxID_ANY, "");

#ifdef wxHAS_DRAW_TITLE_BAR_BITMAP
    const wxSize sizeBmp = wxArtProvider::GetSizeHint(wxART_BUTTON);
    wxBitmap bmp = GetCloseButtonBitmap(this, sizeBmp, colBg);
#else // !wxHAS_DRAW_TITLE_BAR_BITMAP
    wxBitmap bmp = wxArtProvider::GetBitmap(wxART_CLOSE, wxART_BUTTON);
#endif // wxHAS_DRAW_TITLE_BAR_BITMAP
    m_button = new wxBitmapButton
                   (
                    this,
                    wxID_ANY,
                    bmp,
                    wxDefaultPosition,
                    wxDefaultSize,
                    wxBORDER_NONE
                   );

#ifdef wxHAS_DRAW_TITLE_BAR_BITMAP
    m_button->SetBitmapPressed(
        GetCloseButtonBitmap(this, sizeBmp, colBg, wxCONTROL_PRESSED));

    m_button->SetBitmapCurrent(
        GetCloseButtonBitmap(this, sizeBmp, colBg, wxCONTROL_CURRENT));
#endif // wxHAS_DRAW_TITLE_BAR_BITMAP

    m_button->SetBackgroundColour(colBg);
    m_button->SetToolTip(_("Hide this notification message."));

    // center the text inside the sizer with an icon to the left of it and a
    // button at the very right
    //
    // NB: AddButton() relies on the button being the last control in the sizer
    //     and being preceded by a spacer
    wxSizer * const sizer = new wxBoxSizer(wxHORIZONTAL);
    sizer->Add(m_icon, wxSizerFlags().Centre().Border());
    sizer->Add(m_text, wxSizerFlags().Centre());
    sizer->AddStretchSpacer();
    sizer->Add(m_button, wxSizerFlags().Centre().Border());
    SetSizer(sizer);

    return true;
}