コード例 #1
0
ファイル: bboxdevicecontext.cpp プロジェクト: ahwitz/verovio
// calculated better
void BBoxDeviceContext::DrawComplexBezierPath(Point bezier1[4], Point bezier2[4])
{
    Point pos;
    int width, height;
    int minYPos, maxYPos;

    BoundingBox::ApproximateBezierBoundingBox(bezier1, pos, width, height, minYPos, maxYPos);
    // LogDebug("x %d, y %d, width %d, height %d", pos.x, pos.y, width, height);
    UpdateBB(pos.x, pos.y, pos.x + width, pos.y + height);
    BoundingBox::ApproximateBezierBoundingBox(bezier2, pos, width, height, minYPos, maxYPos);
    // LogDebug("x %d, y %d, width %d, height %d", pos.x, pos.y, width, height);
    UpdateBB(pos.x, pos.y, pos.x + width, pos.y + height);
}
コード例 #2
0
void BBoxDeviceContext::DrawMusicText(const std::wstring& text, int x, int y)
{
    assert( m_fontStack.top() );

    int g_x, g_y, g_w, g_h;
    int lastCharWidth = 0;

    for (unsigned int i = 0; i < text.length(); i++)
    {
        wchar_t c = text[i];
        Glyph *glyph = Resources::GetGlyph(c);
        if (!glyph) {
            continue;
        }
        glyph->GetBoundingBox(&g_x, &g_y, &g_w, &g_h);

        int x_off = x + g_x * m_fontStack.top()->GetPointSize() / glyph->GetUnitsPerEm();
        // because we are in the drawing context, y position are already flipped
        int y_off = y - g_y * m_fontStack.top()->GetPointSize() / glyph->GetUnitsPerEm();

        UpdateBB(x_off, y_off,
                 x_off + g_w * m_fontStack.top()->GetPointSize() / glyph->GetUnitsPerEm(),
                 // idem, y position are flipped
                 y_off - g_h * m_fontStack.top()->GetPointSize() / glyph->GetUnitsPerEm());

        lastCharWidth = g_w * m_fontStack.top()->GetPointSize() / glyph->GetUnitsPerEm();
        x += lastCharWidth; // move x to next char

    }
}
コード例 #3
0
void BBoxDeviceContext::DrawLine(int x1, int y1, int x2, int y2)
{
    if ( x1 > x2 ) {
        int tmp = x1;
        x1 = x2;
        x2 = tmp;
    }
    if ( y1 > y2 ) {
        int tmp = y1;
        y1 = y2;
        y2 = tmp;
    }

    int penWidth = m_penStack.top().GetWidth();
    int p1 = penWidth / 2;
    int p2 = p1;
    // how odd line width is handled might depend on the implementation of the device context.
    // however, we expect the actualy with to be shifted on the left/top
    // e.g. with 7, 4 on the left and 3 on the right
    if ( penWidth % 2 ) {
        p1++;
    }

    UpdateBB( x1 - p1, y1 - p1, x2 + p2, y2 + p2);
}
コード例 #4
0
ファイル: CGUITextBox.cpp プロジェクト: kumorikarasu/KylTek
void CGUITextBox::Draw(CGraphicsHandler *g){
	if(GetVisible()){
		UpdateBB();
		if(m_pSprites){
			if(m_bButtonDown && m_bMouseOver && m_pSprites->Button->MouseDown && m_bEnabled)
				g->DrawSpriteTL(m_pSprites->Button->MouseDown, 0, m_pos);
			else if((m_bMouseOver || m_bButtonDown) && m_pSprites->Button->MouseOver && m_bEnabled)
				g->DrawSpriteTL(m_pSprites->Button->MouseOver, 0, m_pos);
			else if(m_pSprites->Button->Default)
				g->DrawSpriteTL(m_pSprites->Button->Default, 0, m_pos);
		}else if(m_pColors)
			g->DrawRectTL(m_pos, m_width, m_height, m_pColors->BG, m_border, m_pColors->Border);

		if((m_Caretx!=m_SelStartx || m_Carety!=m_SelStarty) && GetFocus()){
			if(m_SelStarty==m_Carety && !(m_SelStarty<m_Scrolly) && !(m_SelStarty>=m_Scrolly+((int)(m_height/13))))
				g->DrawRectTL(Vector2(m_pos.x+m_border+2+(m_SelStartx-m_Scrollx)*8, m_pos.y+m_border+2+(m_SelStarty-m_Scrolly)*13), (m_Caretx-m_SelStartx)*8, 13, ColorARGB(255, 0,0,255));
			else{
				if(m_Carety>m_SelStarty){
					if(!(m_SelStarty<m_Scrolly) && !(m_SelStarty>=m_Scrolly+((int)(m_height/13))))
						g->DrawRectTL(Vector2(m_pos.x+m_border+2+(m_SelStartx-m_Scrollx)*8, m_pos.y+m_border+2+(m_SelStarty-m_Scrolly)*13), m_Text[m_SelStarty].substr(m_SelStartx).length()*8, 13, ColorARGB(255, 0,0,255));
					
					for(UINT a=m_SelStarty+1; a<m_Carety; a++)
						if(!(a<m_Scrolly) && !(a>=m_Scrolly+((int)(m_height/13))))
							g->DrawRectTL(Vector2(m_pos.x+m_border+2+(-(int)m_Scrollx)*8, m_pos.y+m_border+2+(a-m_Scrolly)*13), m_Text[a].length()*8, 13, ColorARGB(255, 0,0,255));
					if(!(m_Carety<m_Scrolly) && !(m_Carety>=m_Scrolly+((int)(m_height/13))))
						g->DrawRectTL(Vector2(m_pos.x+m_border+2+(-(int)m_Scrollx)*8, m_pos.y+m_border+2+(m_Carety-m_Scrolly)*13), m_Text[m_Carety].substr(0, m_Caretx).length()*8, 13, ColorARGB(255, 0,0,255));
				}else{
					if(!(m_SelStarty<m_Scrolly) && !(m_SelStarty>=m_Scrolly+((int)(m_height/13))))
						g->DrawRectTL(Vector2(m_pos.x+m_border+2+(m_SelStartx-(int)m_Scrollx)*8, m_pos.y+m_border+2+(m_SelStarty-(int)m_Scrolly)*13), -(int)m_Text[m_SelStarty].substr(0, m_SelStartx).length()*8, 13, ColorARGB(255, 0,0,255));
					
					for(UINT a=m_SelStarty-1; a>m_Carety; a--)
						if(!(a<m_Scrolly) && !(a>=m_Scrolly+((int)(m_height/13))))
							g->DrawRectTL(Vector2(m_pos.x+m_border+2+(-(int)m_Scrollx)*8, m_pos.y+m_border+2+(a-m_Scrolly)*13), m_Text[a].length()*8, 13, ColorARGB(255, 0,0,255));
					if(!(m_Carety<m_Scrolly) && !(m_Carety>=m_Scrolly+((int)(m_height/13))))
						g->DrawRectTL(Vector2(m_pos.x+m_border+2+(m_Text[m_Carety].length())*8, m_pos.y+m_border+2+(m_Carety-(int)m_Scrolly)*13), -(int)m_Text[m_Carety].substr(m_Caretx).length()*8, 13, ColorARGB(255, 0,0,255));
				}
			}
		}
		
		if(m_TextDraw!=L"" && m_pColors){
			//if(m_Carety==m_SelStarty)
				g->DrawTextTL(m_TextDraw, Vector2(m_pos.x+m_border+2, m_pos.y+m_border+3), m_pColors->Text);
			//else{
				//g->DrawTextTL(m_TextDraw, Vector2(m_pos.x+m_border+2, m_pos.y+m_border+3), ColorARGB(255, 255, 0,0));
			//}
		}
		if(m_bCaretOn && GetFocus() && m_bSelectable && !(m_Carety<m_Scrolly) && !(m_Carety>=m_Scrolly+((int)(m_height/13))))
			g->DrawRectTL(Vector2(m_pos.x+m_border+2+(m_Caretx-m_Scrollx)*8, m_pos.y+m_border+2+(m_Carety-m_Scrolly)*13), 1, 13, ColorARGB(255, 0,0,0));

		if(m_pVSB!=NULL)
			m_pVSB->Draw(g);
		if(m_pHSB!=NULL)
			m_pHSB->Draw(g);

		if(!GetEnabled())
			g->DrawRectTL(m_pos, m_width, m_height, ColorARGB(128, 128, 128, 128));
		else if(m_bMouseOver && m_pSprites && m_pSprites->Cursor)
			g->DrawSpriteTL(m_pSprites->Cursor, 0, m_pos);
	}
}
コード例 #5
0
void BBoxDeviceContext::DrawEllipticArc(int x, int y, int width, int height, double start, double end)
{
    /*
    Draws an arc of an ellipse. The current pen is used for drawing the arc
    and the current brush is used for drawing the pie. This function is
    currently only available for X window and PostScript device contexts.

    x and y specify the x and y coordinates of the upper-left corner of the
    rectangle that contains the ellipse.

    width and height specify the width and height of the rectangle that
    contains the ellipse.

    start and end specify the start and end of the arc relative to the
    three-o'clock position from the center of the rectangle. Angles are
    specified in degrees (360 is a complete circle). Positive values mean
    counter-clockwise motion. If start is equal to end, a complete ellipse
    will be drawn. */

    //known bug: SVG draws with the current pen along the radii, but this does not happen in wxMSW

    std::string s ;
    //radius
    double rx = width / 2 ;
    double ry = height / 2 ;
    // center
    double xc = x + rx ;
    double yc = y + ry ;

    double xs, ys, xe, ye ;
    xs = xc + rx * cos (DegToRad(start)) ;
    xe = xc + rx * cos (DegToRad(end)) ;
    ys = yc - ry * sin (DegToRad(start)) ;
    ye = yc - ry * sin (DegToRad(end)) ;

    ///now same as circle arc...

    double theta1 = atan2(ys-yc, xs-xc);
    double theta2 = atan2(ye-yc, xe-xc);

    int fArc  ;                  // flag for large or small arc 0 means less than 180 degrees
    if ( (theta2 - theta1) > 0 ) fArc = 1;
    else fArc = 0 ;

    int fSweep ;
    if ( fabs(theta2 - theta1) > M_PI) fSweep = 1;
    else fSweep = 0 ;

    //WriteLine( StringFormat("<path d=\"M%d %d A%d %d 0.0 %d %d  %d %d \" />",
    //    int(xs), int(ys), int(rx), int(ry),
    //    fArc, fSweep, int(xe), int(ye) ) );

    int penWidth = m_penStack.top().GetWidth();
    if ( penWidth % 2 ) {
        penWidth += 1;
    }
    // needs to be fixed - for now uses the entire rectangle
    UpdateBB( x - penWidth / 2, y - penWidth / 2, x + width + penWidth / 2, y + height + penWidth / 2);
}
コード例 #6
0
void CGUIHorizontalScrollBar::Resize(int width, int height){
	m_width=width;
	m_height=height;
	m_pRight->SetPos(m_pos+Vector2(m_width-m_height, 0));
	m_maxBarWidth=m_width-(m_height*2);
	ResizeBar(m_barWidth);
	UpdateBB();
}
コード例 #7
0
ファイル: bboxdevicecontext.cpp プロジェクト: ahwitz/verovio
void BBoxDeviceContext::DrawEllipticArc(int x, int y, int width, int height, double start, double end)
{
    int penWidth = m_penStack.top().GetWidth();
    if (penWidth % 2) {
        penWidth += 1;
    }
    // needs to be fixed - for now uses the entire rectangle
    UpdateBB(x - penWidth / 2, y - penWidth / 2, x + width + penWidth / 2, y + height + penWidth / 2);
}
コード例 #8
0
// calculated better
void BBoxDeviceContext::DrawComplexBezierPath(int x, int y, int bezier1_coord[6], int bezier2_coord[6])
{
    int vals[4];
    FindPointsForBounds( Point(x, y),
                         Point(bezier1_coord[0], bezier1_coord[1]),
                         Point(bezier1_coord[2], bezier1_coord[3]),
                         Point(bezier1_coord[4], bezier1_coord[5]),
                         vals);

    UpdateBB(vals[0], vals[1], vals[2], vals[3]);
}
コード例 #9
0
ファイル: SpaceStation.cpp プロジェクト: Snaar/pioneer
void SpaceStation::TimeStepUpdate(const float timeStep)
{
	if (Pi::GetGameTime() > m_lastUpdatedShipyard) {
		UpdateBB();
		UpdateShipyard();
		// update again in an hour or two
		m_lastUpdatedShipyard = Pi::GetGameTime() + 3600.0 + 3600.0*Pi::rng.Double();
	}
	DoDockingAnimation(timeStep);
	DoLawAndOrder();
}
コード例 #10
0
void BBoxDeviceContext::DrawText(const std::string& text, const std::wstring wtext)
{
    assert( m_fontStack.top() );

    //unsigned long length = wtext.length();
    int w, h;
    GetTextExtent(wtext, &w, &h);
    m_textWidth += w;
    m_textHeight = std::max( m_textHeight, h );
    // very approximative, we should use GetTextExtend once implemented
    //m_textWidth += length * m_fontStack.top()->GetPointSize() / 7;
    // ignore y bounding boxes for text
    //m_textHeight = m_fontStack.top()->GetPointSize();
    UpdateBB( m_textX, m_textY, m_textX + m_textWidth, m_textY - m_textHeight);


}
コード例 #11
0
void BBoxDeviceContext::DrawRoundedRectangle(int x, int y, int width, int height, double radius)
{
    // avoid negative heights or widths
    if ( height < 0 ) {
        height = -height;
        y -= height;
    }
    if ( width < 0 ) {
        width = -width;
        x -= width;
    }
    int penWidth = m_penStack.top().GetWidth();;
    if ( penWidth % 2 ) {
        penWidth += 1;
    }

    UpdateBB( x - penWidth / 2, y - penWidth / 2, x + width + penWidth / 2, y + height + penWidth / 2);
}
コード例 #12
0
ファイル: bboxdevicecontext.cpp プロジェクト: ahwitz/verovio
void BBoxDeviceContext::DrawPolygon(int n, Point points[], int xoffset, int yoffset, int fill_style)
{
    if (n == 0) {
        return;
    }
    int x1 = points[0].x + xoffset;
    int x2 = x1;
    int y1 = points[0].y + yoffset;
    int y2 = y1;

    for (int i = 0; i < n; i++) {
        if (points[i].x + xoffset < x1) x1 = points[i].x + xoffset;
        if (points[i].x + xoffset > x2) x2 = points[i].x + xoffset;
        if (points[i].y + yoffset < y1) y1 = points[i].y + yoffset;
        if (points[i].y + yoffset > y2) y2 = points[i].y + yoffset;
    }
    UpdateBB(x1, y1, x2, y2);
}
コード例 #13
0
ファイル: bboxdevicecontext.cpp プロジェクト: ahwitz/verovio
void BBoxDeviceContext::DrawText(const std::string &text, const std::wstring wtext)
{
    assert(m_fontStack.top());

    TextExtend extend;
    GetTextExtent(wtext, &extend);
    m_textWidth += extend.m_width;
    // keep that maximum values for ascent and descent
    m_textAscent = std::max(m_textAscent, extend.m_ascent);
    m_textDescent = std::max(m_textDescent, extend.m_descent);
    m_textHeight = m_textAscent + m_textDescent;
    if (m_textAlignment == RIGHT) {
        m_textX -= extend.m_width;
    }
    else if (m_textAlignment == CENTER) {
        m_textX -= (extend.m_width / 2);
    }
    UpdateBB(m_textX, m_textY + m_textDescent, m_textX + m_textWidth, m_textY - m_textAscent);
}
コード例 #14
0
void CGUIHorizontalScrollBar::Draw(CGraphicsHandler *g){
	if(GetVisible()){
		UpdateBB();
		if(m_pColors)
			g->DrawRectTL(m_pos, m_width, m_height, m_pColors->BG, m_border, m_pColors->Border);
		if(m_pSprites){
			if(m_bButtonDown && m_bMouseOver && m_pSprites->Button->MouseDown && m_bEnabled)
				g->DrawSpriteTL(m_pSprites->Button->MouseDown, 0, m_pos+m_barPos, Vector2(m_barWidth/m_pSprites->Button->MouseOver->SpriteWidth,1),0, ColorARGB(255,255,255,255));
			else if((m_bMouseOver || m_bButtonDown) && m_pSprites->Button->MouseOver && m_bEnabled)
				g->DrawSpriteTL(m_pSprites->Button->MouseOver, 0, m_pos+m_barPos, Vector2(m_barWidth/m_pSprites->Button->MouseOver->SpriteWidth,1),0, ColorARGB(255,255,255,255));
			else if(m_pSprites->Button->Default)
				g->DrawSpriteTL(m_pSprites->Button->Default, 0, m_pos+m_barPos, Vector2(m_barWidth/m_pSprites->Button->MouseOver->SpriteWidth,1),0, ColorARGB(255,255,255,255));
		}

		m_pLeft->Draw(g);
		m_pRight->Draw(g);
	
		if(!GetEnabled())
			g->DrawRectTL(m_pos, m_width, m_height, ColorARGB(128, 128, 128, 128));
		else if(m_bMouseOver && m_pSprites && m_pSprites->Cursor)
			g->DrawSpriteTL(m_pSprites->Cursor, 0, m_pos);
	}
}
コード例 #15
0
void BBoxDeviceContext::DrawPlaceholder( int x, int y )
{
    UpdateBB( x, y, x, y );
}
コード例 #16
0
void BBoxDeviceContext::DrawEllipse(int x, int y, int width, int height)
{
    UpdateBB(x, y, x + width, y + height);
}