示例#1
0
void wxGenericColourButton::UpdateColour()
{
    if ( !m_colour.Ok() )
    {
#if wxCLRBTN_USES_BMP_BUTTON
        wxBitmap empty(1,1);
        SetBitmapLabel(empty);
#else
        if ( HasFlag(wxCLRP_SHOW_LABEL) )
            SetLabel(wxEmptyString);
#endif
        return;
    }

    // some combinations of the fg/bg colours may be unreadable, so we invert
    // the colour to make sure fg colour is different enough from m_colour
    wxColour colFg(~m_colour.Red(), ~m_colour.Green(), ~m_colour.Blue());

#if wxCLRBTN_USES_BMP_BUTTON
    wxSize sz = GetSize();
    sz.x -= 2*GetMarginX();
    sz.y -= 2*GetMarginY();

    wxPoint topleft;

    if ( sz.x < 1 )
        sz.x = 1;
    else
    if ( sz.y < 1 )
        sz.y = 1;

    wxBitmap bmp(sz.x, sz.y);
    {
        wxMemoryDC memdc(bmp);
        memdc.SetPen(colFg);
        memdc.SetBrush(m_colour);
        memdc.DrawRectangle(topleft,sz);
        if ( HasFlag(wxCLRP_SHOW_LABEL) )
        {
            int x, y, leading, desc;
            wxString label = m_colour.GetAsString(wxC2S_HTML_SYNTAX);
            memdc.GetTextExtent(label,&x,&y,&desc,&leading);
            if ( x <= sz.x && y <= sz.y )
            {
                topleft.x += (sz.x-x)/2;
                topleft.y += (sz.y-y)/2;
                memdc.SetTextForeground(colFg);
                memdc.DrawText(label,topleft);
            }
        }
    }
    SetBitmapLabel(bmp);
#else
    SetForegroundColour(colFg);
    SetBackgroundColour(m_colour);

    if ( HasFlag(wxCLRP_SHOW_LABEL) )
        SetLabel(m_colour.GetAsString(wxC2S_HTML_SYNTAX));
#endif
}
void ctlColourPicker::UpdateColour()
{
    if (!m_colour_clr.IsOk())
    {
        wxBitmap empty(1,1);
        SetBitmapLabel(empty);
        return;
    }

    wxSize sz = GetSize();
    sz.x -= 2*GetMarginX();
    sz.y -= 2*GetMarginY();

    wxPoint topleft;
    if ( sz.x < 1 )
        sz.x = 1;
    else
        if ( sz.y < 1 )
             sz.y = 1;
    wxBitmap bmp(sz.x, sz.y);

    wxMemoryDC dc(bmp);
    dc.SetBrush(wxBrush(m_colour_clr));
    dc.DrawRectangle(topleft,sz);

    ((wxBitmapButton *)this)->SetBitmapLabel(bmp);
}
示例#3
0
文件: bmpbuttn.cpp 项目: hgwells/tive
wxBitmapButton::~wxBitmapButton()
{
    SetBitmapLabel(wxNullBitmap);

    if (m_insensPixmap)
        XmDestroyPixmap (DefaultScreenOfDisplay ((Display*) GetXDisplay()),
                         (Pixmap) m_insensPixmap);
}
示例#4
0
ColourButton::ColourButton(wxWindow* parent, wxWindowID id, const wxSize& size, agi::Color col)
: wxBitmapButton(parent, id, wxBitmap(size), wxDefaultPosition, wxSize(size.GetWidth() + 6, size.GetHeight() + 6))
, bmp(GetBitmapLabel())
, colour(col)
{
	Paint();
	SetBitmapLabel(bmp);
	Bind(wxEVT_COMMAND_BUTTON_CLICKED, &ColourButton::OnClick, this);
}
示例#5
0
/// @brief Callback for the color picker dialog
/// @param col New color
void ColourButton::SetColour(agi::Color col) {
	colour = col;

	// Draw colour
	Paint();
	SetBitmapLabel(bmp);

	// Trigger a click event on this as some stuff relies on that to know
	// when the color has changed
	wxCommandEvent evt(wxEVT_COMMAND_BUTTON_CLICKED, GetId());
	evt.SetClientData(this);
	evt.SetEventObject(this);
	AddPendingEvent(evt);
}
示例#6
0
bool wxBitmapButton::Create(wxWindow *parent,
                            wxWindowID id,
                            const wxBitmap& bitmap,
                            const wxPoint& pos,
                            const wxSize& size, long style,
                            const wxValidator& validator,
                            const wxString& name)
{
    if ( !wxBitmapButtonBase::Create(parent, id, pos, size, style,
                                     validator, name) )
        return false;

    SetBitmapLabel(bitmap);

    return true;
}
示例#7
0
void wxGenericColourButton::UpdateColour()
{
    wxMemoryDC dc(m_bitmap);
    dc.SetPen( *wxTRANSPARENT_PEN );
    dc.SetBrush( wxBrush(m_colour) );
    dc.DrawRectangle( 0,0,m_bitmap.GetWidth(),m_bitmap.GetHeight() );

    if ( HasFlag(wxCLRP_SHOW_LABEL) )
    {
        wxColour col( ~m_colour.Red(), ~m_colour.Green(), ~m_colour.Blue() );
        dc.SetTextForeground( col );
        dc.SetFont( GetFont() );
        dc.DrawText( m_colour.GetAsString(wxC2S_HTML_SYNTAX), 0, 0 );
    }

    dc.SelectObject( wxNullBitmap );
    SetBitmapLabel( m_bitmap );
}
示例#8
0
bool wxBitmapToggleButton::Create(wxWindow *parent, wxWindowID id,
                            const wxBitmap &bitmap, const wxPoint &pos,
                            const wxSize &size, long style,
                            const wxValidator& validator,
                            const wxString &name)
{
    if ( !wxToggleButton::Create(parent, id, wxEmptyString, pos, size, style | wxBU_NOTEXT | wxBU_EXACTFIT,
                                 validator, name) )
        return false;

    if ( bitmap.IsOk() )
    {
        SetBitmapLabel(bitmap);

        // we need to adjust the size after setting the bitmap as it may be too
        // big for the default button size
        SetInitialSize(size);
    }

    return true;
}
    wxComboButton(wxComboControl *combo)
        : wxBitmapButton(combo->GetParent(), wxID_ANY, wxNullBitmap,
                         wxDefaultPosition, wxDefaultSize,
                         wxBORDER_NONE | wxBU_EXACTFIT)
    {
        m_combo = combo;

        wxBitmap bmpNormal, bmpFocus, bmpPressed, bmpDisabled;

        GetRenderer()->GetComboBitmaps(&bmpNormal,
                                       &bmpFocus,
                                       &bmpPressed,
                                       &bmpDisabled);

        SetBitmapLabel(bmpNormal);
        SetBitmapFocus(bmpFocus.Ok() ? bmpFocus : bmpNormal);
        SetBitmapSelected(bmpPressed.Ok() ? bmpPressed : bmpNormal);
        SetBitmapDisabled(bmpDisabled.Ok() ? bmpDisabled : bmpNormal);

        SetBestSize(wxDefaultSize);
    }
示例#10
0
bool wxBitmapButton::Create(wxWindow *parent,
                            wxWindowID id,
                            const wxBitmap& bitmap,
                            const wxPoint& pos,
                            const wxSize& size, long style,
                            const wxValidator& validator,
                            const wxString& name)
{
    if ( !wxBitmapButtonBase::Create(parent, id, pos, size, style,
                                     validator, name) )
        return false;

    if ( bitmap.IsOk() )
        SetBitmapLabel(bitmap);

    if ( !size.IsFullySpecified() )
    {
        // As our bitmap has just changed, our best size has changed as well so
        // reset the initial size using the new value.
        SetInitialSize(size);
    }

    return true;
}