Beispiel #1
0
// Get the bitmap
wxBitmap wxGenericImageList::GetBitmap(int index) const
{
    const wxBitmap* bmp = GetBitmapPtr(index);
    if (bmp)
        return *bmp;
    else
        return wxNullBitmap;
}
Beispiel #2
0
void wxBitmapComboBox::SetItemBitmap(unsigned int n, const wxBitmap& bitmap)
{
    wxCHECK_RET( n < GetCount(), wxT("invalid item index") );
    OnAddBitmap(bitmap);
    *GetBitmapPtr(n) = bitmap;

    if ( (int)n == GetSelection() )
        Refresh();
}
Beispiel #3
0
// Get the icon
wxIcon wxGenericImageList::GetIcon(int index) const
{
    const wxBitmap* bmp = GetBitmapPtr(index);
    if (bmp)
    {
        wxIcon icon;
        icon.CopyFromBitmap(*bmp);
        return icon;
    }
    else
        return wxNullIcon;
}
Beispiel #4
0
void wxBitmapComboBoxBase::BCBDoClear()
{
    for ( unsigned i = 0; i < m_bitmaps.size(); i++ )
        delete GetBitmapPtr(i);

    m_bitmaps.Empty();

    m_usedImgSize.x = -1;
    m_usedImgSize.y = -1;

    DetermineIndent();
}
Beispiel #5
0
void wxBitmapComboBox::Clear()
{
    wxOwnerDrawnComboBox::Clear();

    unsigned int i;

    for ( i=0; i<m_bitmaps.size(); i++ )
        delete GetBitmapPtr(i);

    m_bitmaps.Empty();

    m_usedImgSize.x = 0;
    m_usedImgSize.y = 0;

    DetermineIndent();
}
Beispiel #6
0
void wxBitmapComboBox::OnDrawItem(wxDC& dc,
                                 const wxRect& rect,
                                 int item,
                                 int flags) const
{
    wxString text;
    int imgAreaWidth = m_imgAreaWidth;
    bool drawText;

    if ( imgAreaWidth == 0 )
    {
        wxOwnerDrawnComboBox::OnDrawItem(dc, rect, item, flags);
        return;
    }

    if ( flags & wxODCB_PAINTING_CONTROL )
    {
        text = GetValue();
        if ( HasFlag(wxCB_READONLY) )
            drawText = true;
        else
            drawText = false;
    }
    else
    {
        text = GetString(item);
        drawText = true;
    }

    const wxBitmap& bmp = *GetBitmapPtr(item);
    if ( bmp.Ok() )
    {
        wxCoord w = bmp.GetWidth();
        wxCoord h = bmp.GetHeight();

        // Draw the image centered
        dc.DrawBitmap(bmp,
                      rect.x + (m_usedImgSize.x-w)/2 + IMAGE_SPACING_LEFT,
                      rect.y + (rect.height-h)/2,
                      true);
    }

    if ( drawText )
        dc.DrawText(GetString(item),
                    rect.x + imgAreaWidth + 1,
                    rect.y + (rect.height-dc.GetCharHeight())/2);
}
Beispiel #7
0
int wxBitmapComboBox::DoAppendWithImage(const wxString& item, const wxBitmap& image)
{
    unsigned int pos = m_bitmaps.size();

    if ( !DoInsertBitmap(image, pos) )
        return wxNOT_FOUND;

    int index = wxOwnerDrawnComboBox::DoAppend(item);

    if ( index < 0 )
        index = m_bitmaps.size();

    // Need to re-check the index incase DoAppend sorted
    if ( (unsigned int) index != pos )
    {
        wxBitmap* bmp = GetBitmapPtr(pos);
        m_bitmaps.RemoveAt(pos);
        m_bitmaps.Insert(bmp, index);
    }

    return index;
}
Beispiel #8
0
void wxBitmapComboBoxBase::DrawItem(wxDC& dc,
                                    const wxRect& rect,
                                    int item,
                                    const wxString& text,
                                    int WXUNUSED(flags)) const
{
    const wxBitmap& bmp = *GetBitmapPtr(item);
    if ( bmp.IsOk() )
    {
        wxCoord w = bmp.GetWidth();
        wxCoord h = bmp.GetHeight();

        // Draw the image centered
        dc.DrawBitmap(bmp,
                      rect.x + (m_usedImgSize.x-w)/2 + IMAGE_SPACING_LEFT,
                      rect.y + (rect.height-h)/2,
                      true);
    }

    if ( text.length() )
        dc.DrawText(text,
                    rect.x + m_imgAreaWidth + 1,
                    rect.y + (rect.height-dc.GetCharHeight())/2);
}
Beispiel #9
0
void wxBitmapComboBox::Delete(unsigned int n)
{
    wxOwnerDrawnComboBox::Delete(n);
    delete GetBitmapPtr(n);
    m_bitmaps.RemoveAt(n);
}
Beispiel #10
0
wxBitmap wxBitmapComboBox::GetItemBitmap(unsigned int n) const
{
    wxCHECK_MSG( n < GetCount(), wxNullBitmap, wxT("invalid item index") );
    return *GetBitmapPtr(n);
}
Beispiel #11
0
wxBitmap wxBitmapComboBoxBase::GetItemBitmap(unsigned int n) const
{
    wxCHECK_MSG( n < m_bitmaps.size(), wxNullBitmap, "invalid item index" );
    return *GetBitmapPtr(n);
}
Beispiel #12
0
void wxBitmapComboBoxBase::DoSetItemBitmap(unsigned int n, const wxBitmap& bitmap)
{
    wxCHECK_RET( n < m_bitmaps.size(), "invalid item index" );
    *GetBitmapPtr(n) = bitmap;
}
Beispiel #13
0
void wxBitmapComboBoxBase::BCBDoDeleteOneItem(unsigned int n)
{
    delete GetBitmapPtr(n);
    m_bitmaps.RemoveAt(n);
}