Ejemplo n.º 1
0
	FOR_EACH_CONST(e, elements) {
		size_t start_ = max(start, e->start);
		size_t end_   = min(end,   e->end);
		if (start_ < end_) {
			e->draw(dc, scale,
			        RealRect(rect.x + xs[start_-start] - xs[0], rect.y,
			                 xs[end_-start] - xs[start_-start], rect.height),
			        xs + start_ - start, what, start_, end_);
		}
		if (end <= e->end) return; // nothing can be after this
	}
Ejemplo n.º 2
0
// judb draw a 'lowered button' border based on the given color
void CPainter::Draw3DLoweredRect(const CRect& Rect, const CRGBColor& Color)
{
	CRect RealRect(Rect);
	if (m_pWindow)	{
		RealRect = Rect + m_pWindow->GetClientRect().TopLeft();
		RealRect.ClipTo(m_pWindow->GetClientRect());
	}
	DrawHLine(RealRect.Left(), RealRect.Right(), RealRect.Top(), Color * 0.3);
	DrawHLine(RealRect.Left(), RealRect.Right(), RealRect.Bottom(), Color * 1.6);
	DrawVLine(RealRect.Top(), RealRect.Bottom(), RealRect.Left(), Color * 0.3);
	DrawVLine(RealRect.Top(), RealRect.Bottom(), RealRect.Right(), Color * 1.6);
}
Ejemplo n.º 3
0
RealRect Rotation::trRectToBB(const RealRect& r) const {
    const bool special_case_optimization = false;
    double x = r.x     * zoomX, y = r.y      * zoomY;
    double w = r.width * zoomX, h = r.height * zoomY;
    if (special_case_optimization && is_rad0(angle)) {
        return RealRect(origin.x + x, origin.y + y, w, h);
    } else if (special_case_optimization && is_rad180(angle)) {
        return RealRect(origin.x - x - w, origin.y - y - h, w, h);
    } else if (special_case_optimization && is_rad90(angle)) {
        return RealRect(origin.x + y, origin.y - x - w, h, w);
    } else if (special_case_optimization && is_rad270(angle)) {
        return RealRect(origin.x - y - h, origin.y + x, h, w);
    } else {
        double s = sin(angle), c = cos(angle);
        RealRect result(c * x + s * y + origin.x,
                        -s * x + c * y + origin.y,
                        0,0);
        if (c > 0) {
            result.width  += c * w;
            result.height += c * h;
        } else {
            result.x      += c * w;
            result.width  -= c * w;
            result.y      += c * h;
            result.height -= c * h;
        }
        if (s > 0) {
            result.width  += s * h;
            result.y      -= s * w;
            result.height += s * w;
        } else {
            result.x      += s * h;
            result.width  -= s * h;
            result.height -= s * w;
        }
        return result;
    }
}
Ejemplo n.º 4
0
void DropDownList::drawItem(DC& dc, int y, size_t item) {
    if (y + item_size.height <= 0 || y >= dc.GetSize().y) return; // not visible
    // draw background
    dc.SetPen(*wxTRANSPARENT_PEN);
    if (item == selected_item) {
        if (itemEnabled(item)) {
            dc.SetBrush         (wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT));
            dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT));
        } else {
            dc.SetBrush         (wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT));
            dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT));
        }
        dc.DrawRectangle(marginW, y, (int)item_size.width, (int)item_size.height);
    } else if (!itemEnabled(item)) {
        // mix between foreground and background
        dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT));
    } else if (highlightItem(item)) {
        // mix a color between selection and window
        dc.SetBrush         (lerp(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT),
                                  wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW), 0.75));
        dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
        dc.DrawRectangle(marginW, y, (int)item_size.width, (int)item_size.height);
    } else {
        dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
    }
    // draw text and icon
    drawIcon(dc, marginW, y, item, item == selected_item);
    dc.DrawText(capitalize(itemText(item)), marginW + (int)icon_size.width + 1, y + text_offset);
    // draw popup icon
    if (submenu(item)) {
        draw_menu_arrow(this, dc, RealRect(marginW, y, item_size.width, item_size.height), item == selected_item);
    }
    // draw line below
    if (lineBelow(item) && item != itemCount()) {
        dc.SetPen(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
        dc.DrawLine(marginW, y + (int)item_size.height, marginW + (int)item_size.width, y + (int)item_size.height);
    }
}
Ejemplo n.º 5
0
void CPainter::DrawRect(const CRect& Rect, bool bFilled, const CRGBColor& BorderColor, const CRGBColor& FillColor)
{
	CRect RealRect(Rect);
	if (m_pWindow)
	{
		RealRect = Rect + m_pWindow->GetClientRect().TopLeft();
		RealRect.ClipTo(m_pWindow->GetClientRect());
	}
	if (!bFilled || (BorderColor != FillColor))
	{
		DrawHLine(RealRect.Left(), RealRect.Right(), RealRect.Top(), BorderColor);
		DrawHLine(RealRect.Left(), RealRect.Right(), RealRect.Bottom(), BorderColor);
		DrawVLine(RealRect.Top(), RealRect.Bottom(), RealRect.Left(), BorderColor);
		DrawVLine(RealRect.Top(), RealRect.Bottom(), RealRect.Right(), BorderColor);
		RealRect.Grow(-1); //In case we have to fill the rect, then it's ready to go.
	}

	if (bFilled)
	{
		if (m_PaintMode == PAINT_REPLACE)
		{
			SDL_Rect FillRect = RealRect.SDLRect();
			SDL_FillRect(m_pSurface, &FillRect, FillColor.SDLColor(m_pSurface->format));
		}
		else
		{
			for (int iY = RealRect.Top(); iY <= RealRect.Bottom(); ++iY)
			{
				for (int iX = RealRect.Left(); iX <= RealRect.Right(); ++iX)
				{
					DrawPoint(CPoint(iX, iY), FillColor);
				}
			}
		}
	}
}
Ejemplo n.º 6
0
	inline operator RealRect () const { return RealRect(min, RealSize(max - min)); }
Ejemplo n.º 7
0
	inline RealRect  getInternalRect() const { return RealRect(0, 0, width, height); }
Ejemplo n.º 8
0
	inline RealRect  getExternalRect() const { return RealRect (left, top, width, height); }
Ejemplo n.º 9
0
void RotatedDC::DrawImage(const Image& image, const RealPoint& pos, ImageCombine combine) {
    Image rotated = rotate_image(image, angle);
    DrawPreRotatedImage(rotated, RealRect(pos,trInvS(RealSize(image))), combine);
}
Ejemplo n.º 10
0
// Render the menu frame.
void ClsXPMenu::OnDrawFrame( HDC hDC, LPCRECT pRect, LPCRECT pRectScr )
{
	// Old style, let the baseclass decide.
	if ( m_bDrawOldStyle )
	{
		ClsBitmapMenu::OnDrawFrame( hDC, pRect, pRectScr );
		return;
	}

	// Wrap the input DC.
	ClsDC *pDC = ClsDC::FromHandle( hDC );
	if ( pDC == NULL ) return;

	// Copy the input rectangle.
	ClsRect rc( *pRect );

	// Are shadows enabled? If so we only render the frame.
	// If not we have room to render the shadow ourselves.
	if ( ! ClsGetApp()->IsShadowEnabled() && m_bDrawShadow )
	{
		// Adjust for the shadow pixels.
		rc.Right()  -= 4;
		rc.Bottom() -= 4;
	}

	// Create brush and render the outer frame.
	ClsBrush brush( XPColors.GetXPColor( ClsXPColors::XPC_MENU_FRAME ));
	pDC->FrameRect( rc, &brush );

	// Do the same for the inner frame.
	brush.Delete();
	rc.Deflate( 1, 1 );
	brush.CreateSolidBrush( XPColors.GetXPColor( ClsXPColors::XPC_TEXT_BACKGROUND ));
	pDC->FrameRect( rc, &brush );

	// Do we render the shadow ourselves?
	if ( ! ClsGetApp()->IsShadowEnabled() && m_bDrawShadow )
	{
		// Do we have a parent rectangle?
		if ( m_LastParent.IsEmpty() == FALSE )
		{
			// If the right-sides match we adjust the shadow rectangle to
			// be a union of both rectangle.
			if ( m_LastParent.Right() == pRectScr->right - 4 )
			{
				ClsRect rc2;
				rc2.Union( m_LastParent, *pRectScr );
				rc2.Offset( -pRectScr->left, -pRectScr->top );
				ClsDrawTools::DrawShadow( hDC, rc2 );
			}
			else
				ClsDrawTools::DrawShadow( hDC, pRect );
		}
		else
			ClsDrawTools::DrawShadow( hDC, pRect );
	}

	// Valid parent?
	if ( m_LastParent.IsEmpty() == FALSE )
	{
		// Create an intersection of the menu rectangle and the
		// parent-item rectangle.
		ClsRect RealRect( *pRectScr );

		// Do we have a shadow?
		if ( ! ClsGetApp()->IsShadowEnabled() && m_bDrawShadow )
			RealRect.Right() -= 4;

		// Clear the intersection.
		if ( rc.Intersect( RealRect, m_LastParent ))
		{
			// Create a rectangle relative to the menu top-left.
			rc.Offset( -pRectScr->left, -pRectScr->top );

			// Adjust to fit.
			if ( rc.Width() > rc.Height()) rc.Deflate( 1, 0 ); else rc.Deflate( 0, 1 );

			// Create a brush to erase the rectangle, which actually
			// is a line instead of a true rectangle.
			brush.Delete();
			brush.CreateSolidBrush( XPColors.GetXPColor( ClsXPColors::XPC_IMAGE_BACKGROUND ));

			// Render.
			pDC->FillRect( rc, brush );
		}
	}
}