Exemplo n.º 1
0
/*
** Draws the meter on the double buffer
**
*/
bool MeterButton::Draw(Gfx::Canvas& canvas)
{
	if (!Meter::Draw(canvas)) return false;

	const auto image = m_Image.GetImage();
	D2D1_RECT_F meterRect = GetMeterRectPadding();

	if (image)
	{
		canvas.DrawBitmap(
			image,
			D2D1::RectF(
				meterRect.left,
				meterRect.top,
				meterRect.left + (FLOAT)m_W,
				meterRect.top + (FLOAT)m_H),
			m_BitmapsRects[m_State]);
	}

	return true;
}
Exemplo n.º 2
0
/*
** Draws the meter on the double buffer
**
*/
bool MeterImage::Draw(Gfx::Canvas& canvas)
{
	if (!Meter::Draw(canvas)) return false;

	if (m_Image.IsLoaded())
	{
		// Copy the image over the doublebuffer
		Bitmap* drawBitmap = m_Image.GetImage();

		int imageW = drawBitmap->GetWidth();
		int imageH = drawBitmap->GetHeight();

		if (imageW == 0 || imageH == 0 || m_W == 0 || m_H == 0) return true;

		int x = GetX();
		int y = GetY();

		int drawW = m_W;
		int drawH = m_H;

		if (drawW == imageW && drawH == imageH &&
			m_ScaleMargins.left == 0 && m_ScaleMargins.top == 0 && m_ScaleMargins.right == 0 && m_ScaleMargins.bottom == 0)
		{
			canvas.DrawBitmap(drawBitmap, Rect(x, y, drawW, drawH), Rect(0, 0, imageW, imageH));
		}
		else if (m_DrawMode == DRAWMODE_TILE)
		{
			Gdiplus::Graphics& graphics = canvas.BeginGdiplusContext();

			ImageAttributes imgAttr;
			imgAttr.SetWrapMode(WrapModeTile);

			Rect r(x, y, drawW, drawH);
			graphics.DrawImage(drawBitmap, r, 0, 0, drawW, drawH, UnitPixel, &imgAttr);

			canvas.EndGdiplusContext();
		}
		else if (m_DrawMode == DRAWMODE_KEEPRATIO || m_DrawMode == DRAWMODE_KEEPRATIOANDCROP)
		{
			int cropX = 0;
			int cropY = 0;
			int cropW = imageW;
			int cropH = imageH;

			if (m_WDefined && m_HDefined)
			{
				REAL imageRatio = imageW / (REAL)imageH;
				REAL meterRatio = m_W / (REAL)m_H;

				if (imageRatio != meterRatio)
				{
					if (m_DrawMode == DRAWMODE_KEEPRATIO)
					{
						if (imageRatio > meterRatio)
						{
							drawH = m_W * imageH / imageW;
							y += (m_H - drawH) / 2;
						}
						else
						{
							drawW = m_H * imageW / imageH;
							x += (m_W - drawW) / 2;
						}
					}
					else
					{
						if (imageRatio > meterRatio)
						{
							cropW = (int)(imageH * meterRatio);
							cropX = (imageW - cropW) / 2;
						}
						else
						{
							cropH = (int)(imageW / meterRatio);
							cropY = (imageH - cropH) / 2;
						}
					}
				}
			}

			Rect r(x, y, drawW, drawH);
			canvas.DrawBitmap(drawBitmap, r, Rect(cropX, cropY, cropW, cropH));
		}
		else
		{
			const RECT& m = m_ScaleMargins;

			if (m.top > 0)
			{
				if (m.left > 0)
				{
					// Top-Left
					Rect r(x, y, m.left, m.top);
					canvas.DrawBitmap(drawBitmap, r, Rect(0, 0, m.left, m.top));
				}

				// Top
				Rect r(x + m.left, y, drawW - m.left - m.right, m.top);
				canvas.DrawBitmap(drawBitmap, r, Rect(m.left, 0, imageW - m.left - m.right, m.top));

				if (m.right > 0)
				{
					// Top-Right
					Rect r(x + drawW - m.right, y, m.right, m.top);
					canvas.DrawBitmap(drawBitmap, r, Rect(imageW - m.right, 0, m.right, m.top));
				}
			}

			if (m.left > 0)
			{
				// Left
				Rect r(x, y + m.top, m.left, drawH - m.top - m.bottom);
				canvas.DrawBitmap(drawBitmap, r, Rect(0, m.top, m.left, imageH - m.top - m.bottom));
			}

			// Center
			Rect r(x + m.left, y + m.top, drawW - m.left - m.right, drawH - m.top - m.bottom);
			canvas.DrawBitmap(drawBitmap, r, Rect(m.left, m.top, imageW - m.left - m.right, imageH - m.top - m.bottom));

			if (m.right > 0)
			{
				// Right
				Rect r(x + drawW - m.right, y + m.top, m.right, drawH - m.top - m.bottom);
				canvas.DrawBitmap(drawBitmap, r, Rect(imageW - m.right, m.top, m.right, imageH - m.top - m.bottom));
			}

			if (m.bottom > 0)
			{
				if (m.left > 0)
				{
					// Bottom-Left
					Rect r(x, y + drawH - m.bottom, m.left, m.bottom);
					canvas.DrawBitmap(drawBitmap, r, Rect(0, imageH - m.bottom, m.left, m.bottom));
				}

				// Bottom
				Rect r(x + m.left, y + drawH - m.bottom, drawW - m.left - m.right, m.bottom);
				canvas.DrawBitmap(drawBitmap, r, Rect(m.left, imageH - m.bottom, imageW - m.left - m.right, m.bottom));

				if (m.right > 0)
				{
					// Bottom-Right
					Rect r(x + drawW - m.right, y + drawH - m.bottom, m.right, m.bottom);
					canvas.DrawBitmap(drawBitmap, r, Rect(imageW - m.right, imageH - m.bottom, m.right, m.bottom));
				}
			}
		}
	}

	return true;
}
Exemplo n.º 3
0
/*
** Draws the meter on the double buffer
**
*/
bool MeterBitmap::Draw(Gfx::Canvas& canvas)
{
	if (!Meter::Draw(canvas)) return false;

	int newY, newX;

	if (m_FrameCount == 0 || !m_Image.IsLoaded()) return false;	// Unable to continue

	Bitmap* bitmap = m_Image.GetImage();

	int x = GetX();
	int y = GetY();

	if (m_Extend)
	{
		int value = (int)m_Value;
		value = max(0, value);		// Only positive integers are supported

		int transitionValue = (int)m_TransitionStartValue;
		transitionValue = max(0, transitionValue);		// Only positive integers are supported

		// Calc the number of numbers
		int numOfNums = 0;

		if (m_Digits > 0)
		{
			numOfNums = m_Digits;
		}
		else
		{
			int tmpValue = value;

			do
			{
				++numOfNums;
				if (m_FrameCount == 1)
				{
					tmpValue /= 2;
				}
				else
				{
					tmpValue /= m_FrameCount;
				}
			}
			while (tmpValue > 0);
		}

		// Blit the images
		int offset;
		if (m_Align == ALIGN_RIGHT)
		{
			offset = 0;
		}
		else if (m_Align == ALIGN_CENTER)
		{
			offset = numOfNums * (m_W + m_Separation) / 2;
		}
		else
		{
			offset = numOfNums * (m_W + m_Separation);
		}

		do
		{
			offset = offset - (m_W + m_Separation);

			int realFrames = (m_FrameCount / (m_TransitionFrameCount + 1));
			int frame = (value % realFrames) * (m_TransitionFrameCount + 1);

			// If transition is ongoing the pick the correct frame
			if (m_TransitionStartTicks > 0)
			{
				int diffTicks = (int)(System::GetTickCount64() - m_TransitionStartTicks);

				int range = ((value % realFrames) - (transitionValue % realFrames)) * (m_TransitionFrameCount + 1);
				if (range < 0)
				{
					range += m_FrameCount;
				}
				int frameAdjustment = range * diffTicks / ((m_TransitionFrameCount + 1) * m_MeterWindow->GetTransitionUpdate());
				if (frameAdjustment > range)
				{
					m_TransitionStartTicks = 0;		// The transition is over. Draw with the real value.
				}
				else
				{
					frame = (transitionValue % realFrames) * (m_TransitionFrameCount + 1);
					frame += frameAdjustment;
					frame %= m_FrameCount;
				}
			}

//			LogDebugF(L"[%u] Value: %f Frame: %i (Transition = %s)", GetTickCount(), m_Value, frame, m_TransitionStartTicks > 0 ? L"true" : L"false");

			if (bitmap->GetHeight() > bitmap->GetWidth())
			{
				newX = 0;
				newY = m_H * frame;
			}
			else
			{
				newX = m_W * frame;
				newY = 0;
			}

			canvas.DrawBitmap(bitmap, Rect(x + offset, y, m_W, m_H), Rect(newX, newY, m_W, m_H));
			if (m_FrameCount == 1)
			{
				value /= 2;
				transitionValue /= 2;
			}
			else
			{
				value /= realFrames;
				transitionValue /= realFrames;
			}
			--numOfNums;
		}
		while (numOfNums > 0);
	}
	else
	{
		int frame = 0;
		int realFrames = (m_FrameCount / (m_TransitionFrameCount + 1));

		if (m_ZeroFrame)
		{
			// Use the first frame only if the value is zero
			if (m_Value > 0)
			{
				frame = (int)(m_Value * (realFrames - 1)) * (m_TransitionFrameCount + 1);
			}
		}
		else
		{
			// Select the correct frame linearly
			frame = (int)(m_Value * realFrames) * (m_TransitionFrameCount + 1);
		}

		// If transition is ongoing the pick the correct frame
		if (m_TransitionStartTicks > 0)
		{
			int diffTicks = (int)(System::GetTickCount64() - m_TransitionStartTicks);

			if (diffTicks > ((m_TransitionFrameCount + 1) * m_MeterWindow->GetTransitionUpdate()))
			{
				m_TransitionStartTicks = 0;		// The transition is over. Draw with the real value.
			}
			else
			{
				double range = (m_Value - m_TransitionStartValue);
				double adjustment = range * diffTicks / ((m_TransitionFrameCount + 1) * m_MeterWindow->GetTransitionUpdate());
				double frameAdjustment = adjustment * m_FrameCount;

				frame = (int)(m_TransitionStartValue * realFrames) * (m_TransitionFrameCount + 1);
				frame += (int)frameAdjustment;
				frame %= m_FrameCount;
				frame = max(0, frame);
			}
		}

//		LogDebugF(L"[%u] Value: %f Frame: %i (Transition = %s)", GetTickCount(), m_Value, frame, m_TransitionStartTicks > 0 ? L"true" : L"false");

		if (bitmap->GetHeight() > bitmap->GetWidth())
		{
			newX = 0;
			newY = frame * m_H;
		}
		else
		{
			newX = frame * m_W;
			newY = 0;
		}

		canvas.DrawBitmap(bitmap, Rect(x, y, m_W, m_H), Rect(newX, newY, m_W, m_H));
	}

	return true;
}
Exemplo n.º 4
0
/*
** Draws the meter on the double buffer
**
*/
bool MeterBar::Draw(Gfx::Canvas& canvas)
{
	if (!Meter::Draw(canvas)) return false;

	const D2D1_RECT_F rect = GetMeterRectPadding();
	const FLOAT width = rect.right - rect.left;
	const FLOAT height = rect.bottom - rect.top;
	const FLOAT border = (FLOAT)m_Border;

	Gfx::D2DBitmap* drawBitmap = m_Image.GetImage();

	if (m_Orientation == VERTICAL)
	{
		const FLOAT barSize = height - 2.0f * border;
		FLOAT size = barSize * (FLOAT)m_Value;
		size = min(barSize, size);
		size = max(0.0f, size);

		if (drawBitmap)
		{
			if (m_Flip)
			{
				if (border > 0.0f)
				{
					const auto d = Gfx::Util::ToRectF(rect.left, rect.top, width, border);
					const auto s = Gfx::Util::ToRectF(0.0f, 0.0f, width, border);
					canvas.DrawBitmap(drawBitmap, d, s);

					const auto d2 = Gfx::Util::ToRectF(rect.left, rect.top + size + border, width, border);
					const auto s2 = Gfx::Util::ToRectF(0.0f, height - border, width, border);
					canvas.DrawBitmap(drawBitmap, d2, s2);
				}

				const auto d = Gfx::Util::ToRectF(rect.left, rect.top + border, width, size);
				const auto s = Gfx::Util::ToRectF(0.0f, border, width, size);
				canvas.DrawBitmap(drawBitmap, d, s);
			}
			else
			{
				if (border > 0.0f)
				{
					const auto d = Gfx::Util::ToRectF(rect.left, rect.bottom - size - 2.0f * border, width, border);
					const auto s = Gfx::Util::ToRectF(0.0f, 0.0f, width, border);
					canvas.DrawBitmap(drawBitmap, d, s);

					const auto d2 = Gfx::Util::ToRectF(rect.left, rect.bottom - border, width, border);
					const auto s2 = Gfx::Util::ToRectF(0.0f, height - border, width, border);
					canvas.DrawBitmap(drawBitmap, d2, s2);
				}

				const auto d = Gfx::Util::ToRectF(rect.left, rect.bottom - size - border, width, size);
				const auto s = Gfx::Util::ToRectF(0.0f, height - size - border, width, size);
				canvas.DrawBitmap(drawBitmap, d, s);
			}
		}
		else
		{
			if (m_Flip)
			{
				const auto r = Gfx::Util::ToRectF(rect.left, rect.top, width, size);
				canvas.FillRectangle(r, m_Color);
			}
			else
			{
				const auto r = Gfx::Util::ToRectF(rect.left, rect.bottom - size, width, size);
				canvas.FillRectangle(r, m_Color);
			}
		}
	}
	else
	{
		const FLOAT barSize = width - 2.0f * border;
		FLOAT size = barSize * (FLOAT)m_Value;
		size = min(barSize, size);
		size = max(0.0f, size);

		if (drawBitmap)
		{
			if (m_Flip)
			{
				if (border > 0.0f)
				{
					const auto d = Gfx::Util::ToRectF(rect.right - size - 2.0f * border, rect.top, border, height);
					const auto s = Gfx::Util::ToRectF(0.0f, 0.0f, border, height);
					canvas.DrawBitmap(drawBitmap, d, s);

					const auto d2 = Gfx::Util::ToRectF(rect.right - border, rect.top, border, height);
					const auto s2 = Gfx::Util::ToRectF(width - border, 0.0f, border, height);
					canvas.DrawBitmap(drawBitmap, d2, s2);
				}

				const auto d = Gfx::Util::ToRectF(rect.right - size - border, rect.top, size, height);
				const auto s = Gfx::Util::ToRectF(width - size - border, 0.0f, size, height);
				canvas.DrawBitmap(drawBitmap, d, s);
			}
			else
			{
				if (border > 0.0f)
				{
					const auto d = Gfx::Util::ToRectF(rect.left, rect.top, border, height);
					const auto s = Gfx::Util::ToRectF(0.0f, 0.0f, border, height);
					canvas.DrawBitmap(drawBitmap, d, s);

					const auto d2 = Gfx::Util::ToRectF(rect.left + size + border, rect.top, border, height);
					const auto s2 = Gfx::Util::ToRectF(width - border, 0.0f, border, height);
					canvas.DrawBitmap(drawBitmap, d2, s2);
				}

				const auto d = Gfx::Util::ToRectF(rect.left + border, rect.top, size, height);
				const auto s = Gfx::Util::ToRectF(border, 0.0f, size, height);
				canvas.DrawBitmap(drawBitmap, d, s);
			}
		}
		else
		{
			if (m_Flip)
			{
				const auto r = Gfx::Util::ToRectF(rect.right - size, rect.top, size, height);
				canvas.FillRectangle(r, m_Color);
			}
			else
			{
				const auto r = Gfx::Util::ToRectF(rect.left, rect.top, size, height);
				canvas.FillRectangle(r, m_Color);
			}
		}
	}

	return true;
}
Exemplo n.º 5
0
/*
** Draws the meter on the double buffer
**
*/
bool MeterImage::Draw(Gfx::Canvas& canvas)
{
	if (!Meter::Draw(canvas)) return false;

	if (m_Image.IsLoaded())
	{
		// Copy the image over the doublebuffer
		Bitmap* drawBitmap = m_Image.GetImage();

		int imageW = drawBitmap->GetWidth();
		int imageH = drawBitmap->GetHeight();
		
		if (imageW == 0 || imageH == 0 || m_W == 0 || m_H == 0) return true;

		Gdiplus::Rect meterRect = GetMeterRectPadding();

		int drawW = meterRect.Width;
		int drawH = meterRect.Height;

		bool hasMask = (m_Skin->GetUseD2D() && m_MaskImage.IsLoaded());
		if (hasMask)
		{
			Bitmap* maskBitmap = m_MaskImage.GetImage();

			imageW = maskBitmap->GetWidth();
			imageH = maskBitmap->GetHeight();
			int imageMW = drawBitmap->GetWidth();
			int imageMH = drawBitmap->GetHeight();

			int cropX = 0;
			int cropY = 0;
			int cropW = imageMW;
			int cropH = imageMH;

			REAL imageratio = imageMW / (REAL)imageMH;
			REAL meterRatio = meterRect.Width / (REAL)meterRect.Height;

			if (imageratio != meterRatio)
			{
				if (imageratio > meterRatio)
				{
					cropW = (int)(imageMH * meterRatio);
					cropX = (imageMW - cropW) / 2;
				}
				else
				{
					cropH = (int)(imageMW / meterRatio);
					cropY = (imageMH - cropH) / 2;
				}
			}

			canvas.DrawMaskedBitmap(drawBitmap, maskBitmap, meterRect, Rect(0, 0, imageW, imageH), Gdiplus::Rect(cropX, cropY, cropW, cropH));
		}

		else if (drawW == imageW && drawH == imageH &&
			m_ScaleMargins.left == 0 && m_ScaleMargins.top == 0 && m_ScaleMargins.right == 0 && m_ScaleMargins.bottom == 0)
		{
			canvas.DrawBitmap(drawBitmap, Rect(meterRect.X, meterRect.Y, drawW, drawH), Rect(0, 0, imageW, imageH));
		}
		else if (m_DrawMode == DRAWMODE_TILE)
		{
			Gdiplus::Graphics& graphics = canvas.BeginGdiplusContext();

			ImageAttributes imgAttr;
			imgAttr.SetWrapMode(WrapModeTile);

			Rect r(meterRect.X, meterRect.Y, drawW, drawH);
			graphics.DrawImage(drawBitmap, r, 0, 0, drawW, drawH, UnitPixel, &imgAttr);

			canvas.EndGdiplusContext();
		}
		else if (m_DrawMode == DRAWMODE_KEEPRATIO || m_DrawMode == DRAWMODE_KEEPRATIOANDCROP)
		{
			int cropX = 0;
			int cropY = 0;
			int cropW = imageW;
			int cropH = imageH;

			if (m_WDefined && m_HDefined)
			{
				REAL imageRatio = imageW / (REAL)imageH;
				REAL meterRatio = meterRect.Width / (REAL)meterRect.Height;

				if (imageRatio != meterRatio)
				{
					if (m_DrawMode == DRAWMODE_KEEPRATIO)
					{
						if (imageRatio > meterRatio)
						{
							drawH = meterRect.Width * imageH / imageW;
							meterRect.Y += (meterRect.Height - drawH) / 2;
						}
						else
						{
							drawW = meterRect.Height * imageW / imageH;
							meterRect.X += (meterRect.Width - drawW) / 2;
						}
					}
					else
					{
						if (imageRatio > meterRatio)
						{
							cropW = (int)(imageH * meterRatio);
							cropX = (imageW - cropW) / 2;
						}
						else
						{
							cropH = (int)(imageW / meterRatio);
							cropY = (imageH - cropH) / 2;
						}
					}
				}
			}

			Rect r(meterRect.X, meterRect.Y, drawW, drawH);
			canvas.DrawBitmap(drawBitmap, r, Rect(cropX, cropY, cropW, cropH));
		}
		else
		{
			const RECT& m = m_ScaleMargins;

			if (m.top > 0)
			{
				if (m.left > 0)
				{
					// Top-Left
					Rect r(meterRect.X, meterRect.Y, m.left, m.top);
					canvas.DrawBitmap(drawBitmap, r, Rect(0, 0, m.left, m.top));
				}

				// Top
				Rect r(meterRect.X + m.left, meterRect.Y, drawW - m.left - m.right, m.top);
				canvas.DrawBitmap(drawBitmap, r, Rect(m.left, 0, imageW - m.left - m.right, m.top));

				if (m.right > 0)
				{
					// Top-Right
					Rect r(meterRect.X + drawW - m.right, meterRect.Y, m.right, m.top);
					canvas.DrawBitmap(drawBitmap, r, Rect(imageW - m.right, 0, m.right, m.top));
				}
			}

			if (m.left > 0)
			{
				// Left
				Rect r(meterRect.X, meterRect.Y + m.top, m.left, drawH - m.top - m.bottom);
				canvas.DrawBitmap(drawBitmap, r, Rect(0, m.top, m.left, imageH - m.top - m.bottom));
			}

			// Center
			Rect r(meterRect.X + m.left, meterRect.Y + m.top, drawW - m.left - m.right, drawH - m.top - m.bottom);
			canvas.DrawBitmap(drawBitmap, r, Rect(m.left, m.top, imageW - m.left - m.right, imageH - m.top - m.bottom));

			if (m.right > 0)
			{
				// Right
				Rect r(meterRect.X + drawW - m.right, meterRect.Y + m.top, m.right, drawH - m.top - m.bottom);
				canvas.DrawBitmap(drawBitmap, r, Rect(imageW - m.right, m.top, m.right, imageH - m.top - m.bottom));
			}

			if (m.bottom > 0)
			{
				if (m.left > 0)
				{
					// Bottom-Left
					Rect r(meterRect.X, meterRect.Y + drawH - m.bottom, m.left, m.bottom);
					canvas.DrawBitmap(drawBitmap, r, Rect(0, imageH - m.bottom, m.left, m.bottom));
				}

				// Bottom
				Rect r(meterRect.X + m.left, meterRect.Y + drawH - m.bottom, drawW - m.left - m.right, m.bottom);
				canvas.DrawBitmap(drawBitmap, r, Rect(m.left, imageH - m.bottom, imageW - m.left - m.right, m.bottom));

				if (m.right > 0)
				{
					// Bottom-Right
					Rect r(meterRect.X + drawW - m.right, meterRect.Y + drawH - m.bottom, m.right, m.bottom);
					canvas.DrawBitmap(drawBitmap, r, Rect(imageW - m.right, imageH - m.bottom, m.right, m.bottom));
				}
			}
		}
	}

	return true;
}
Exemplo n.º 6
0
/*
** Draws the meter on the double buffer
**
*/
bool CMeterBar::Draw(Gfx::Canvas& canvas)
{
    if (!CMeter::Draw(canvas)) return false;

    int x = GetX();
    int y = GetY();

    Bitmap* drawBitmap = m_Image.GetImage();

    if (m_Orientation == VERTICAL)
    {
        int barSize = m_H - 2 * m_Border;
        int size = (int)(barSize * m_Value);
        size = min(barSize, size);
        size = max(0, size);

        if (drawBitmap)
        {
            if (m_Flip)
            {
                if (m_Border > 0)
                {
                    Rect r2(x, y, m_W, m_Border);
                    canvas.DrawBitmap(drawBitmap, r2, Rect(0, 0, m_W, m_Border));
                    r2.Y = y + size + m_Border;
                    canvas.DrawBitmap(drawBitmap, r2, Rect(0, m_H - m_Border, m_W, m_Border));
                }

                Rect r(x, y + m_Border, m_W, size);
                canvas.DrawBitmap(drawBitmap, r, Rect(0, m_Border, m_W, size));
            }
            else
            {
                if (m_Border > 0)
                {
                    Rect r2(x, y + m_H - size - 2 * m_Border, m_W, m_Border);
                    canvas.DrawBitmap(drawBitmap, r2, Rect(0, 0, m_W, m_Border));
                    r2.Y = y + m_H - m_Border;
                    canvas.DrawBitmap(drawBitmap, r2, Rect(0, m_H - m_Border, m_W, m_Border));
                }

                Rect r(x, y + m_H - size - m_Border, m_W, size);
                canvas.DrawBitmap(drawBitmap, r, Rect(0, m_H - size - m_Border, m_W, size));
            }
        }
        else
        {
            SolidBrush brush(m_Color);
            if (m_Flip)
            {
                Rect r(x, y, m_W, size);
                canvas.FillRectangle(r, brush);
            }
            else
            {
                Rect r(x, y + m_H - size, m_W, size);
                canvas.FillRectangle(r, brush);
            }
        }
    }
    else
    {
        int barSize = m_W - 2 * m_Border;
        int size = (int)(barSize * m_Value);
        size = min(barSize, size);
        size = max(0, size);

        if (drawBitmap)
        {
            if (m_Flip)
            {
                if (m_Border > 0)
                {
                    Rect r2(x + m_W - size - 2 * m_Border, y, m_Border, m_H);
                    canvas.DrawBitmap(drawBitmap, r2, Rect(0, 0, m_Border, m_H));
                    r2.X = x + m_W - m_Border;
                    canvas.DrawBitmap(drawBitmap, r2, Rect(m_W - m_Border, 0, m_Border, m_H));
                }

                Rect r(x + m_W - size - m_Border, y, size, m_H);
                canvas.DrawBitmap(drawBitmap, r, Rect(m_W - size - m_Border, 0, size, m_H));
            }
            else
            {
                if (m_Border > 0)
                {
                    Rect r2(x, y, m_Border, m_H);
                    canvas.DrawBitmap(drawBitmap, r2, Rect(0, 0, m_Border, m_H));
                    r2.X = x + size + m_Border;
                    canvas.DrawBitmap(drawBitmap, r2, Rect(m_W - m_Border, 0, m_Border, m_H));
                }

                Rect r(x + m_Border, y, size, m_H);
                canvas.DrawBitmap(drawBitmap, r, Rect(m_Border, 0, size, m_H));
            }
        }
        else
        {
            SolidBrush brush(m_Color);
            if (m_Flip)
            {
                Rect r(x + m_W - size, y, size, m_H);
                canvas.FillRectangle(r, brush);
            }
            else
            {
                Rect r(x, y, size, m_H);
                canvas.FillRectangle(r, brush);
            }
        }
    }

    return true;
}