Example #1
0
    HGDIOBJ createBrush(const GiContext* ctx)
    {
        if (ctx == NULL)
            ctx = &m_context;

        if (m_brush == NULL
            || m_context.getFillColor() != ctx->getFillColor()
            || m_context.getFillAlpha() != ctx->getFillAlpha())
        {
            m_context.setFillColor(ctx->getFillColor());
            m_context.setFillAlpha(ctx->getFillAlpha());

            if (m_brush != NULL)
                ::DeleteObject(m_brush);

            if (!ctx->hasFillColor() || ctx->getFillAlpha() < 127)
                m_brush = ::GetStockObject(NULL_BRUSH);
            else
            {
                GiColor color = m_this->gs()->calcPenColor(ctx->getFillColor());
                m_brush = ::CreateSolidBrush(RGB(color.r, color.g, color.b));
            }
        }

        return m_brush;
    }
Example #2
0
    G::SolidBrush* createBrush(const GiContext* ctx)
    {
        G::SolidBrush* pBrush = NULL;

        if (ctx == NULL)
            ctx = &m_context;

        m_brushNull = !ctx->hasFillColor();
        if (!m_brushNull)
        {
            if (m_brush == NULL
                || m_context.getFillColor() != ctx->getFillColor()
                || m_context.getFillAlpha() != ctx->getFillAlpha())
            {
                m_context.setFillColor(ctx->getFillColor());
                m_context.setFillAlpha(ctx->getFillAlpha());

                if (m_brush != NULL)
                {
                    delete m_brush;
                    m_brush = NULL;
                }

                GiColor color = gs()->calcPenColor(ctx->getFillColor());
                m_brush = new G::SolidBrush(
                    G::Color(ctx->getFillAlpha(), 
                    color.r, color.g, color.b));
            }
            pBrush = m_brush;
        }

        return pBrush;
    }