Exemple #1
0
/*
 * LoadImages
 *
 * Load up the images so that we can display them in the
 * game and configure the colors.
 */
void LoadImages (GtkWidget *window)
{
    /* --- Load up the images --- */
    LoadPixmaps (window, sprite_man);
    LoadPixmaps (window, sprite_ship1);
    LoadPixmaps (window, sprite_ship2);
    LoadPixmaps (window, sprite_lander);
    LoadPixmaps (window, sprite_mutant);
    LoadPixmaps (window, sprite_missile);

    /* --- Get the colors defined --- */
    penRed = GetPen (NewColor (0xffff, 0x8888, 0x8888));
    penGreen = GetPen (NewColor (0, 0xffff, 0));
    penPurple = GetPen (NewColor (0xffff, 0, 0xffff));
    penWhite = GetPen (NewColor (0xffff, 0xffff, 0xffff));
}
void ACanvasSkia::_SetPaint_Draw()
{
	APen* pen = GetPen();
	m_Paint.setColor(toSkColor(pen->GetColor()));
	m_Paint.setStrokeWidth(SkScalar(pen->GetWidth()));
	m_Paint.setStyle(SkPaint::kStroke_Style);
}
void CDrawContext::SelectPen( COLORREF cr )
{
	if( !m_bPenSelected || cr != m_crCurrentPen )
	{
		VAPI( ::SelectObject( m_hdc, GetPen( cr ) ) );
		m_crCurrentPen = cr;
		m_bPenSelected = true;
	}
}
Exemple #4
0
void wxDCBase::DoDrawEllipticArcRot( wxCoord x, wxCoord y,
                                     wxCoord w, wxCoord h,
                                     double sa, double ea, double angle )
{
    wxList list;

    CalculateEllipticPoints( &list, x, y, w, h, sa, ea );
    Rotate( &list, angle, wxPoint( x+w/2, y+h/2 ) );

    // Add center (for polygon/pie)
    list.Append( (wxObject*) new wxPoint( x+w/2, y+h/2 ) );

    // copy list into array and delete list elements
    int n = list.Number();
    wxPoint *points = new wxPoint[n];
    int i = 0;
    wxNode* node = 0;
    for ( node = list.First(); node; node = node->Next(), i++ )
    {
        wxPoint *point = (wxPoint *)node->Data();
        points[i].x = point->x;
        points[i].y = point->y;
        delete point;
    }

    // first draw the pie without pen, if necessary
    if( GetBrush() != *wxTRANSPARENT_BRUSH )
    {
        wxPen tempPen( GetPen() );
        SetPen( *wxTRANSPARENT_PEN );
        DoDrawPolygon( n, points, 0, 0 );
        SetPen( tempPen );
    }

    // then draw the arc without brush, if necessary
    if( GetPen() != *wxTRANSPARENT_PEN )
    {
        // without center
        DoDrawLines( n-1, points, 0, 0 );
    }

    delete [] points;

} // DrawEllipticArcRot
void MyTriangle::Paint(const HDC& hdc) const
{
	HBRUSH hBrush = CreateSolidBrush(GetBrush());
	HPEN hPen = CreatePen(PS_SOLID, 1, GetPen());
	HBRUSH hBrushOld = (HBRUSH)SelectObject(hdc, hBrush);
	SelectObject(hdc, hPen);

	Polygon(hdc, poly, 3);

	DeleteObject(hBrush);
	DeleteObject(hPen);
}
//================>>> myCanvasPane::MouseDown <<<=================
  void myCanvasPane::MouseDown(int X, int Y, int button)
  {
    // Note beginning of line on mouse down
    _mouseDown = 1;
    _begx = _curx = X;    _begy = _cury = Y;

    _pt[_nextpt].x = X;  _pt[_nextpt].y = Y;
    _pt[_nextpt].pPen = GetPen();
    ++_nextpt;
    if (_nextpt >= 200)		// really dumb, but SIMPLE!
	_nextpt = 0;
  }
//==================>>> myCanvasPane::MouseUp <<<=================
  void myCanvasPane::MouseUp(int X, int Y, int button)
  {
    // Finish drawing line on mouse up
    _mouseDown = 0;
    if (_begx != X || _begy != Y)	// First time?
	DrawLine(_begx, _begy, X, Y);

    _pt[_nextpt].x = X;    _pt[_nextpt].y = Y;
    _pt[_nextpt].pPen = GetPen();
    ++_nextpt;

    if (_nextpt >= 200)		// really dumb, but SIMPLE!
	_nextpt = 0;

    _mouseDown = 0;		// ready for next line
    _begx = -1;  _begy = -1;  _curx = -1;  _cury = -1;
  }
Exemple #8
0
static boolean drawline (hdlheadrecord hnode) {
	
	register hdlheadrecord h = hnode;
	Point pt;
	Rect r;
	short listnum;
	short iconnum;
	tyfinderinfo info;
	byte typestring [6];
	boolean fltextmode = opeditingtext (hnode);
	
	opgetrefcon (hnode, &info, sizeof (info));
	
	GetPen (&pt);
	
	setrect (&r, pt.v - 12, pt.h - 2, pt.v + 4, pt.h + 14);
	
	listnum = findersmalliconlist;
	
	if (fltextmode)
		++listnum;
	
	plotsmallicon (r, listnum, geticonnum (h), false);
	
	movepento (pt.h + widthsmallicon, pt.v);
	
	if (info.flalias)		
 		pushstyle ((**outlinedata).fontnum, (**outlinedata).fontsize, italic);
	
	if (fltextmode)
		opeditupdate ();
	else
		pendrawstring ((**h).headstring);
	
	if (info.flalias)
		popstyle (); 
	
	movepento (pt.h + namecolwidth, pt.v);
	
	ostypetostring (info.filetype, typestring);
	
	pendrawstring (typestring);
	
	return (true);
	} /*drawline*/
Exemple #9
0
void ocpnDC::StrokeCircle( wxCoord x, wxCoord y, wxCoord radius )
{
#if wxUSE_GRAPHICS_CONTEXT
    if( pgc ) {
        wxGraphicsPath gpath = pgc->CreatePath();
        gpath.AddCircle( x, y, radius );

        pgc->SetPen( GetPen() );
        pgc->SetBrush( GetBrush() );
        pgc->DrawPath( gpath );

        // keep dc dirty box up-to-date
        dc->CalcBoundingBox( x + radius + 2, y + radius + 2 );
        dc->CalcBoundingBox( x - radius - 2, y - radius - 2 );
    } else
#endif
        DrawCircle( x, y, radius );
}
Exemple #10
0
void
wxDCBase::DoDrawPolyPolygon(int n,
                            int count[],
                            wxPoint points[],
                            wxCoord xoffset, wxCoord yoffset,
                            int fillStyle)
{
    if ( n == 1 )
    {
        DoDrawPolygon(count[0], points, xoffset, yoffset, fillStyle);
        return;
    }

    int      i, j, lastOfs;
    wxPoint* pts;
    wxPen    pen;

    for (i = j = lastOfs = 0; i < n; i++)
    {
        lastOfs = j;
        j      += count[i];
    }
    pts = new wxPoint[j+n-1];
    for (i = 0; i < j; i++)
        pts[i] = points[i];
    for (i = 2; i <= n; i++)
    {
        lastOfs -= count[n-i];
        pts[j++] = pts[lastOfs];
    }

    pen = GetPen();
    SetPen(wxPen(*wxBLACK, 0, wxTRANSPARENT));
    DoDrawPolygon(j, pts, xoffset, yoffset, fillStyle);
    SetPen(pen);
    for (i = j = 0; i < n; i++)
    {
        DoDrawLines(count[i], pts+j, xoffset, yoffset);
        j += count[i];
    }
    delete[] pts;
}
Exemple #11
0
void ocpnDC::StrokePolygon( int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset )
{
#if wxUSE_GRAPHICS_CONTEXT
    if( pgc ) {
        wxGraphicsPath gpath = pgc->CreatePath();
        gpath.MoveToPoint( points[0].x + xoffset, points[0].y + yoffset );
        for( int i = 1; i < n; i++ )
            gpath.AddLineToPoint( points[i].x + xoffset, points[i].y + yoffset );
        gpath.AddLineToPoint( points[0].x + xoffset, points[0].y + yoffset );

        pgc->SetPen( GetPen() );
        pgc->SetBrush( GetBrush() );
        pgc->DrawPath( gpath );

        for( int i = 0; i < n; i++ )
            dc->CalcBoundingBox( points[i].x + xoffset, points[i].y + yoffset );
    } else
#endif
        DrawPolygon( n, points, xoffset, yoffset );
}
//virtual
void PSVGPolylineElement::Render4(CHTMRenderContext* pC, LDraw::Bitmap* pBitmap, Gui::RenderContext* renderContext, double scaleX, double scaleY, bool bOffscreen, bool bDrawBehaviors)
{
	ASSERT(0);
#if 0
	SVGPolylineElement* psvgElement = static_cast<SVGPolylineElement*>(m_pNode);

	pGraphics->SetSmoothingMode(LDraw::SmoothingModeAntiAlias/*pGraphics->GetSmoothingMode()*/);

	LDraw::GraphicsPathF GraphicsPathF(m_computedFillRule == FillRule_nonzero? LDraw::FillModeWinding: LDraw::FillModeAlternate);
	psvgElement->m_points->m_animated->m_animVal->m_value->DrawToPath(&GraphicsPathF, false);

	double fillOpacity = m_computedFillOpacity;
	double strokeOpacity = m_computedStrokeOpacity;

	if (!bOffscreen)
	{
		fillOpacity *= m_computedOpacity;
		strokeOpacity *= m_computedOpacity;
	}

	LDraw::Brush* pFillBrush = GetFillBrush(fillOpacity, scaleX, scaleY);
	LDraw::Brush* pStrokeBrush = GetStrokeBrush(strokeOpacity, scaleX, scaleY);

	if (pFillBrush != NULL)
	{
		pGraphics->FillPath(pFillBrush, &GraphicsPathF);
	}

	if (pStrokeBrush != NULL)
	{
		LDraw::Pen* pPen = GetPen(pStrokeBrush);
		if (pPen != NULL)
		{
			pGraphics->DrawPath(pPen, &GraphicsPathF);
		}
	}
#endif
}
Exemple #13
0
void DrawObjectsList2(WindowRef w, RECTPTR r, long n)
// called once for each item in VList to draw nth line
{
	char s[256];
	short right, style = normal;
	Point p;
	ListItem item = model->GetNthListItem(n, 0, &style, s);
	
	if (item.owner == 0) return;
	
	GetPen(&p);	
	PenNormal();
	
	right = DrawBullet(item, r, FALSE, 0);
	
	MyMoveTo(right + 4, p.v - OBJECTLINEOFFSET);

	// set text-face according to style requested
	TextFontSizeFace(kFontIDGeneva,LISTTEXTSIZE,style);
	drawstring(s);		
	DrawBullet(item, r, TRUE, 0);
	TextFontSizeFace(kFontIDGeneva,LISTTEXTSIZE,normal);
}
Exemple #14
0
void VectDraw(DialogPtr d, Rect *rectPtr, long itemNumber)
{
#pragma unused (rectPtr)
	Point		p;
	short		h,v;
	RGBColor	rgb;
	Rect		rgbrect;
	char 		numstr[30],numstr2[30];
	double 		x  = (*gEditContourLevels)[itemNumber];
	float		colorLevel;
	long		numLevels = GetNumDoubleHdlItems(gEditContourLevels);
	
	SetRGBColor(&rgb,0,0,0);

	TextFont(kFontIDGeneva); TextSize(LISTTEXTSIZE);
	
	rgbrect=GetDialogItemBox(d,CONT_LISTID);
	h=(rgbrect.left);
	GetPen(&p);
	v=p.v;

	MySetRect(&rgbrect,h+4,v-9,h+14,v+1);
	
	// set unique color for each value, not on linear scale
	colorLevel = float(itemNumber)/float(numLevels-1);
	//rgb = GetRGBColor(colorLevel);
#ifdef IBM
	rgb = GetRGBColor(colorLevel);
#else
	rgb = GetRGBColor(1.-colorLevel);
#endif
	//rgb = GetRGBColor(0.8-colorLevel);
	RGBForeColor(&rgb);
	PaintRect(&rgbrect);
	MyFrameRect(&rgbrect);

	MyMoveTo(h+30,v+1);

	RGBForeColor(&colors[BLACK]);
	if (itemNumber<numLevels-1)
	{
		MyNumToStr(x,numstr);
		MyNumToStr((*gEditContourLevels)[itemNumber+1],numstr2);
		strcat(numstr," - ");
		strcat(numstr,numstr2);
	}
	else
	{
		strcpy(numstr,"> ");
		MyNumToStr(x,numstr2);
		strcat(numstr,numstr2);
	}
	if (gContourType==0)
	{
		strcat(numstr,"    mg/L");
	}
	else
	{
		MyNumToStr(x,numstr);
		strcat(numstr,"    m");
	}
	//drawstring(MyNumToStr(x,numstr));
	drawstring(numstr);
 
	return;
}
//virtual
void PSVGEllipseElement::Render4(CHTMRenderContext* pC, Graphics::Bitmap* pBitmap, Gui::RenderContext* renderContext, double scaleX, double scaleY, bool bOffscreen, bool bDrawBehaviors)
{
	SVGEllipseElement* psvgElement = static_cast<SVGEllipseElement*>(m_pNode);

	double fillOpacity = m_computedFillOpacity;
	double strokeOpacity = m_computedStrokeOpacity;

	Gui::Brush* fillBrush = GetBrush(renderContext, &m_computedFill, m_pFillElement, fillOpacity, scaleX, scaleY);
	Gui::Brush* strokeBrush = GetBrush(renderContext, &m_computedStroke, m_pStrokeElement, strokeOpacity, scaleX, scaleY);

	if (fillBrush)
	{
		renderContext->FillEllipse(m_computedCx, m_computedCy, m_computedRx, m_computedRy, fillBrush);
	}

	if (strokeBrush)
	{
		float strokeWidth = m_computedStrokeWidth;
		renderContext->DrawEllipse(m_computedCx, m_computedCy, m_computedRx, m_computedRy, strokeBrush, strokeWidth);
	}

#if 0
	D2D1_ELLIPSE ellipse;
	ellipse.point.x = m_computedCx;
	ellipse.point.y = m_computedCy;
	ellipse.radiusX = m_computedRx;
	ellipse.radiusY = m_computedRy;
	if (fillBrush)
	{
		renderContext->GetRT()->m_spRT->FillEllipse(ellipse, fillBrush);
		fillBrush->Release();
	}

	if (strokeBrush)
	{
	//	LDraw::Pen* pPen = GetPen(pStrokeBrush);
		float strokeWidth = m_computedStrokeWidth;
		ID2D1StrokeStyle* strokeStyle = NULL;
		renderContext->GetRT()->m_spRT->DrawEllipse(ellipse, strokeBrush, strokeWidth, strokeStyle);
		strokeBrush->Release();
	}
#endif

	return;
#if 0
	SVGEllipseElement* psvgElement = static_cast<SVGEllipseElement*>(m_pNode);

	pGraphics->SetSmoothingMode(LDraw::SmoothingModeAntiAlias/*pGraphics->GetSmoothingMode()*/);

//	__release<LDraw::GraphicsPathF> GraphicsPathF = new LDraw::GraphicsPathF;
//	GraphicsPathF->AddEllipse(float(m_bounds.X), float(m_bounds.Y), float(m_bounds.Width), float(m_bounds.Height));
	//DrawPathSegList(seglist, &GraphicsPathF, NULL);

	double fillOpacity = m_computedFillOpacity;
	double strokeOpacity = m_computedStrokeOpacity;

	if (!bOffscreen)
	{
		fillOpacity *= m_computedOpacity;
		strokeOpacity *= m_computedOpacity;
	}

	LDraw::Brush* pFillBrush = GetBrush(&m_computedFill, m_pFillElement, fillOpacity, scaleX, scaleY);
	LDraw::Brush* pStrokeBrush = GetBrush(&m_computedStroke, m_pStrokeElement, strokeOpacity, scaleX, scaleY);

	if (pFillBrush != NULL)
	{
		pGraphics->FillEllipse(pFillBrush, float(m_bounds.X), float(m_bounds.Y), float(m_bounds.Width), float(m_bounds.Height));
	}

	if (pStrokeBrush != NULL)
	{
		LDraw::Pen* pPen = GetPen(pStrokeBrush);
		if (pPen != NULL)
		{
			pGraphics->DrawEllipse(pPen, float(m_bounds.X), float(m_bounds.Y), float(m_bounds.Width), float(m_bounds.Height));
		}
	}
#endif
}
Exemple #16
0
void GCanvas::FillRoundRect(ARect r,int dx,int dy)
{
	GetPen()->SetWidth(0);
	Flush();
	::RoundRect(m_hDC,r.left,r.top,r.right,r.bottom,dx,dy);
}
Exemple #17
0

#define IMPLGET(T, Name, Type, TYPE, v, def, ret) \
T CUIGlobals::Get##Name(UI##TYPE ui##v) \
{ \
	UI##TYPE##INFO *v = Get##Type##Info(ui##v); \
	if (!v) \
		return def; \
	return ret; \
}

IMPLGET(HGDIOBJ, Font, Element, ELEMENT, e, NULL, GetFont(e->eFont))
IMPLGET(HGDIOBJ, Font, Font, FONT, f, NULL, f->hFont)
IMPLGET(HGDIOBJ, Brush, Element, ELEMENT, e, NULL, GetBrush(e->eBrush))
IMPLGET(HGDIOBJ, Brush, Brush, BRUSH, b, NULL, b->hBrush)
IMPLGET(HGDIOBJ, Pen, Element, ELEMENT, e, NULL, GetPen(e->ePen))
IMPLGET(HGDIOBJ, Pen, Brush, BRUSH, b, NULL, b->hPen)
IMPLGET(HGDIOBJ, Pen, Pen, PEN, p, NULL, p->hPen)
IMPLGET(COLORREF, BrushColor, Element, ELEMENT, e, RGB(255, 127, 127), GetColor(e->eBrush))
IMPLGET(COLORREF, PenColor, Element, ELEMENT, e, RGB(255, 127, 127), GetColor(e->ePen))
IMPLGET(COLORREF, TextColor, Element, ELEMENT, e, RGB(255, 127, 127), GetColor(e->eText))
IMPLGET(COLORREF, BkColor, Element, ELEMENT, e, RGB(255, 127, 127), GetColor(e->eBk))
IMPLGET(COLORREF, Color, Brush, BRUSH, b, RGB(255, 127, 127), GetColor(b->eColor))
IMPLGET(COLORREF, Color, Pen, PEN, p, RGB(255, 127, 127), GetColor(p->eColor))
IMPLGET(COLORREF, Color, Color, COLOR, c, RGB(255, 127, 127), c->rgb)

#undef IMPLGET


CPaintHelper::CPaintHelper(CUIGlobals &uig, HDC hDC) :
	m_uig(uig), m_priv_hDC(hDC), m_hDC(m_priv_hDC),