void
ImageBox::DrawTabbedText()
{
	if (!shown)
	return;

	int x = 0;
	int y = 0;
	int w = rect.w;
	int h = rect.h;
	int img_w = picture.Width();
	int img_h = picture.Height();

	Rect box_rect(x,y,w,h);

	// draw the picture (if any)
	if (picture.Width()) {
		Rect irect = CalcPictureRect();
		DrawBitmap(irect.x,
		irect.y,
		irect.x + irect.w,
		irect.y + irect.h,
		&picture,
		Video::BLEND_ALPHA);
	}

	ActiveWindow::DrawTabbedText();
}
void
ImageBox::Draw()
{
	if (!shown)
	return;

	int x = 0;
	int y = 0;
	int w = rect.w;
	int h = rect.h;
	int img_w = picture.Width();
	int img_h = picture.Height();

	Rect box_rect(x,y,w,h);

	// draw the picture (if any)
	if (picture.Width()) {
		Rect irect = CalcPictureRect();
		DrawBitmap(irect.x,
		irect.y,
		irect.x + irect.w,
		irect.y + irect.h,
		&picture,
		blend_mode);
	}

	// draw the border:
	DrawStyleRect(0, 0, w, h, style);

	// draw text here:
	if (font && text.length()) {
		int border_size = 4;

		if (style & WIN_RAISED_FRAME && style & WIN_SUNK_FRAME)
		border_size = 8;

		Rect label_rect = CalcLabelRect(img_w,img_h);
		int  vert_space = label_rect.h;
		int  horz_space = label_rect.w;

		DrawText(text.data(), 0, label_rect, DT_CALCRECT | DT_WORDBREAK | DT_CENTER);
		vert_space = (vert_space - label_rect.h)/2;
		
		label_rect.w = horz_space;

		if (vert_space > 0)
		label_rect.y += vert_space;

		Color fore = ShadeColor(fore_color, 1);
		font->SetColor(fore);
		DrawText(text.data(), 0, label_rect, DT_WORDBREAK | DT_CENTER);
	}
}
void
Button::Draw()
{
	if (!IsShown()) return;

	int x = 0;
	int y = 0;
	int w = rect.w;
	int h = rect.h;
	int img_w = picture.Width();
	int img_h = picture.Height();

	float old_alpha = alpha;

	if (!enabled)
	SetAlpha(0.35);

	Rect btn_rect(x,y,w,h);

	if (!transparent) {
		if (standard_image) {
			if (!enabled) {
				texture = standard_image;
			}

			else {
				switch (button_state) {
				case -1:
					texture = activated_image;
					break;

				default:
				case 0:
					texture = standard_image;
					break;

				case 1:
					if (sticky)
					texture = activated_image;
					else
					texture = transition_image;
					break;

				case 2:
					texture = transition_image;
					break;
				}
			}

			if (!texture)
			texture = standard_image;

			DrawTextureGrid();
		}

		else {
			FillRect(0, 0, w, h, ShadeColor(back_color, 1.0));
			DrawStyleRect(0, 0, w, h, style);
		}
	}

	// draw the picture (if any)
	if (picture.Width()) {
		Rect irect = CalcPictureRect();
		DrawImage(&picture, irect);
	}

	// draw text here:
	if (font && text.length()) {
		Rect label_rect = CalcLabelRect(img_w,img_h);
		int  vert_space = label_rect.h;
		int  horz_space = label_rect.w;
		int  align      = DT_WORDBREAK | text_align;

		DrawText(text.data(), 0, label_rect, DT_CALCRECT | align);
		vert_space = (vert_space - label_rect.h)/2;
		
		label_rect.w = horz_space;

		if (vert_space > 0)
		label_rect.y += vert_space;

		if (animated && button_state > 0) {
			label_rect.x += button_state;
			label_rect.y += button_state;
		}

		if (drop_shadow) {
			label_rect.x++;
			label_rect.y++;
			
			font->SetColor(back_color);
			DrawText(text.data(), text.length(), label_rect, align);
			
			label_rect.x--;
			label_rect.y--;
		}
		
		font->SetColor(fore_color);
		DrawText(text.data(), text.length(), label_rect, align);
	}

	if (!enabled)
	SetAlpha(old_alpha);
}