Exemplo n.º 1
0
void
ActiveWindow::Draw()
{
    int w = rect.w;
    int h = rect.h;

    if (w < 1 || h < 1 || !shown)
    return;

    float old_alpha = alpha;

    if (!enabled)
    SetAlpha(0.5);

    if (!transparent) {
        if (texture && texture->Width()) {
            DrawTextureGrid();
        }
        else {
            FillRect(0, 0, w, h, ShadeColor(back_color, 1.0));
        }
    }

    if (enabled && view_list.size()) {
        ListIter<View> v = view_list;
        while (++v)
        v->Refresh();
    }

    if (!transparent) {
        DrawStyleRect(0, 0, w, h, style);
    }

    // draw text here:
    DrawTabbedText();

    if (!enabled)
    SetAlpha(old_alpha);

    // update children windows:
    ListIter<ActiveWindow> iter = children;
    while (++iter) {
        ActiveWindow* child = iter.value();
        child->Draw();
    }
}
Exemplo n.º 2
0
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);
}