Ejemplo n.º 1
0
void VerticalTile::Draw(Gdiplus::Bitmap *buffer, Gdiplus::Graphics *graphics)
{
    int currentUnits = CalcUnits();
    int height = _rect.Height * currentUnits;

    graphics->FillRectangle(_texture, _rect.X, _rect.Y, _rect.Width, height);

    UpdateDrawnValues();
}
Ejemplo n.º 2
0
void HorizontalBar::Draw(Gdiplus::Bitmap *buffer, Gdiplus::Graphics *graphics) {
    int width = _pixelsPerUnit * CalcUnits();

    if (_reversed) {
        width = _rect.Width - width;
    }

    Gdiplus::Rect drawRect(_rect.X, _rect.Y, width, _rect.Height);

    graphics->DrawImage(_bitmap, drawRect, 0, 0, width, _rect.Height,
        Gdiplus::UnitPixel, &_imageAttributes, NULL, NULL);

    UpdateDrawnValues();
}
Ejemplo n.º 3
0
void Text::Draw(Gdiplus::Bitmap *buffer, Gdiplus::Graphics *graphics)
{
    int units = CalcUnits();

    Gdiplus::RectF layoutRect((float) _rect.X, (float) _rect.Y, 
        (float) _rect.Width, (float) _rect.Height);

    graphics->SetTextRenderingHint(Gdiplus::TextRenderingHintAntiAlias);

    wchar_t perc[4];
    _itow_s(units * (100 / _units), perc, 10);
    std::wstring tempstr(_formatString);
    const wchar_t *str = tempstr.replace(_replaceIndex, 8, perc).c_str();

    graphics->DrawString(str, -1, _font, layoutRect, 
        &_strFormat, _fontColor);

    UpdateDrawnValues();
}
Ejemplo n.º 4
0
void NumberStrip::Draw(Gdiplus::Bitmap *buffer, Gdiplus::Graphics *graphics) {
    int units = CalcUnits();
    int perc = units * (100 / _units);

    int digits[] = {
        perc % 10,
        (perc / 10) % 10,
        perc / 100,
    };

    int chars = 1;
    if (digits[1] > 0) {
        chars = 2;
    } else if (digits[2] > 0) {
        chars = 3;
    }

    int drawX = _charWidth * 2;
    if (_align == Gdiplus::StringAlignmentNear) {
        drawX = (chars - 1) * _charWidth;
    } else if (_align == Gdiplus::StringAlignmentFar) {
        drawX = (_charWidth * 2) - ((3 - chars) * (_charWidth / 2));
    }

    for (int i = 0, x = drawX; i < chars; ++i, x -= _charWidth) {
        int digit = digits[i];
        QCLOG(L"Drawing digit [%d]; x-offset: %d", digit, _rect.X + x);

        Gdiplus::Rect destRect(_rect.X + x, _rect.Y, _charWidth, _rect.Height);
        graphics->DrawImage(_bitmap, destRect,
            0, digit * _rect.Height, _charWidth, _rect.Height,
            Gdiplus::UnitPixel, NULL, NULL, NULL);
    }

    UpdateDrawnValues();
}
Ejemplo n.º 5
0
void CallbackMeter::Draw(Gdiplus::Bitmap *buffer, Gdiplus::Graphics *graphics) {
    int units = CalcUnits();
    _receiver.MeterChangeCallback(units);
    UpdateDrawnValues();
}