Bitmap Field

     

    This code was posted on the RIM Developer Discussion Forum by Thorsten Schiller.

    I needed the ability to use bitmaps with my screens. I noticed a number of conversation threads in the archives where people wanted to do the same thing. Here's a quick and dirty class that we are using successfully. Your milage may vary.

    Thorsten

    RimBitmap.hpp
    -------------
    class RimBitmap : public Field
    {
    public:
    RimBitmap(const BitMap* pBitmap, int offset = 0L);
    virtual ~RimBitmap();
    virtual void Paint(Graphics& g);
    virtual FIELDTYPE GetFieldType(FIELDTYPE * pDerived = NULL ) { return NULL_FIELD; }
    virtual void ResetDimensionDependentData() { }
    virtual int QueryLineHeight(int const MaximumRelevant);
    virtual int GetHeight() const;
    private:
    const BitMap* m_pBitmap;
    int m_offset;
    }; // class RimBitmap

    RimBitmap.cpp
    -------------
    #include "RimBitmap.hpp"

    RimBitmap::RimBitmap(const BitMap* pBitmap, int offset)
    : m_pBitmap(pBitmap),m_offset(offset)
    {
    } /* RimBitmap() */

    RimBitmap::~RimBitmap()
    {
    } /* ~RimBitmap() */

    void RimBitmap::Paint(Graphics& g)
    {
    g.DrawBitmap(m_pBitmap, 1 + m_offset, 1);
    } /* Paint() */

    int RimBitmap::GetHeight() const
    {
    return m_pBitmap->high;
    } /* GetHeight() */

    int RimBitmap::QueryLineHeight(int const maximumRelevant)
    {
    // no idea what this value means but since it's
    // a pure virtual we gotta define it...
    return GetHeight();
    } /* QueryLineHeight() */

Website design: Sessionware  Copyright ©2001 Bill Foust.  The BlackBerry and RIM families of related marks, images and symbols are the exclusive properties and trade-marks of Research In Motion Limited and are used by permission.  Trademarks and product names listed on this site are the sole property of their respective owners.  This page last updated on September 19, 2001