Exemple #1
0
// frame painting
void XMLDragFrame::FramePaint(Draw& w, const Rect& r)
{
	w.DrawRect(r, SColorFace());
	int x1 = r.left + 1;
	int x2 = r.right - 1;
	int y1 = r.top + 1;
	int y2 = r.bottom -1;
	w.DrawLine(x1, y1, x2, y1, 1, SColorLight());
	w.DrawLine(x2, y1, x2, y2, 1, SColorShadow());
	w.DrawLine(x2, y2, x1, y2, 1, SColorShadow());
	w.DrawLine(x1, y2, x1, y1, 1, SColorLight());
	if(align == ToolBar::BAR_LEFT || align == ToolBar::BAR_RIGHT)
	{
		x1 = r.left + 5;
		x2 = r.right - 5;
		y1 = r.top + 4;
		y2 = r.top + 9;
		w.DrawLine(x1, y1, x2, y1, 2, SColorShadow());
		w.DrawLine(x1, y2, x2, y2, 2, SColorShadow());
	}
	else
	{
		x1 = r.left + 4;
		x2 = r.left + 9;
		y1 = r.top + 5;
		y2 = r.bottom - 5;
		w.DrawLine(x1, y1, x1, y2, 2, SColorShadow());
		w.DrawLine(x2, y1, x2, y2, 2, SColorShadow());
	}
}
Exemple #2
0
	virtual void Paint(Draw& w) {
		w.DrawRect(GetSize(), White());

		w.DrawRect(10, 10, 60, 80, Green());

		w.DrawLine(100, 10, 160, 80, 0, Black());
		w.DrawLine(160, 10, 100, 80, 4, Red());
		w.DrawLine(160, 40, 100, 50, PEN_DOT, Red());

		w.DrawEllipse(210, 20, 80, 60, Blue());

		w.DrawEllipse(310, 20, 80, 60, LtBlue(), 5, Red());

		w.DrawArc(RectC(410, 20, 80, 60), Point(10, 10), Point(450, 80), 3, Cyan);

		Vector<Point> p;
		p << Point(30, 110) << Point(60, 180) << Point(10, 150) << Point(70, 150);
		w.DrawPolyline(p, 4, Black);

		p.Clear();
		p << Point(130, 110) << Point(160, 180) << Point(110, 150) << Point(170, 120)
		  << Point(130, 110);
		w.DrawPolygon(p, Blue);

		p.Clear();
		p << Point(230, 110) << Point(260, 180) << Point(210, 150) << Point(270, 120)
		  << Point(230, 110);
		w.DrawPolygon(p, Cyan, 5, Magenta);

		p.Clear();
		p << Point(330, 110) << Point(360, 180) << Point(310, 150) << Point(370, 120)
		  << Point(330, 110);
		w.DrawPolygon(p, Cyan, 5, Magenta, I64(0xaa55aa55aa55aa55));

		w.DrawImage(40, 240, CtrlImg::save());
		w.DrawImage(110, 210, 80, 80, CtrlImg::save());
		w.DrawImage(240, 240, CtrlImg::save(), Blue);
		w.DrawImage(310, 210, 80, 80, CtrlImg::save(), Blue);

		w.DrawText(20, 330, "Hello world!");
		w.DrawText(120, 330, "Hello world!", Arial(15).Bold());
		w.DrawText(220, 330, "Hello world!", Roman(15).Italic(), Red);
		w.DrawText(320, 380, 400, "Hello world!", Courier(15).Underline());
	}
Exemple #3
0
void ScatterCtrl::Paint(Draw& w)
{
    GuiLock __;
    if (IsNull(highlight_0) && highlighting) {
        highlighting = false;
        KillTimeCallback();
    }
    if (!IsNull(highlight_0) && !highlighting) {
        highlighting = true;
        SetTimeCallback(-200, THISBACK(TimerCallback));
    }
    TimeStop t;
    lastRefresh0_ms = GetTickCount();
    if (IsEnabled()) {
        if (mode == MD_DRAW) {
            ScatterCtrl::SetDrawing(w, GetSize(), 1);
            PlotTexts(w, GetSize(), 1);
        } else {
            ImageBuffer ib(GetSize());
            BufferPainter bp(ib, mode);
            ScatterCtrl::SetDrawing(bp, GetSize(), 1);
            w.DrawImage(0, 0, ib);
            PlotTexts(w, GetSize(), 1);
        }
        if (HasFocus()) {
            w.DrawLine(0, 0, GetSize().cx, 0, 2, LtGray());
            w.DrawLine(0, 0, 0, GetSize().cy, 2, LtGray());
            int delta = -2;
#ifdef PLATFORM_WIN32
            delta = 0;
#endif
            w.DrawLine(GetSize().cx+delta, 0, GetSize().cx+delta, GetSize().cy, 2, LtGray());
            w.DrawLine(0, GetSize().cy+delta, GetSize().cx, GetSize().cy+delta, 2, LtGray());
        }
    }
    lastRefresh_ms = t.Elapsed();
}
Exemple #4
0
    void Paint(Draw &w)
    {
        Size sz = GetSize();
        Rect rc = w.GetClip();
        static bool first = true;

		DUMP(rc);

        if(first)
        {
            w.DrawRect(sz, SGreen);
            first = false;
        }
        else
        for(int i = rc.left; i <= rc.right; i++)
            w.DrawLine(i, rc.top , i, rc.bottom, 0,  (i & 1) ? SWhite : SBlack);
    }
Exemple #5
0
void FormView::DrawSprings(Draw& w, const Rect& r, dword align, dword valign,
	bool drawLeft, bool drawTop, bool drawRight, bool drawBottom, bool centered)
{
	if (!IsLayout())
		return;

	int x = r.CenterPoint().x;
	int y = r.CenterPoint().y;

	if (drawLeft)
	{
		if (!centered)
			y = YToGrid(r.top + r.Height() / 3);

		if (align == Ctrl::LEFT || align == Ctrl::SIZE)
			w.DrawLine(2, y, r.left, y, 1, LtRed());
		else
			for (int i = 5; i <= r.left; i += 5)
				w.DrawLine(i, YToGrid(y - 5, !centered), i, YToGrid(y + 5, !centered), 1,
					LtRed());
	}

	if (drawRight)
	{
		if (!centered)
			y = YToGrid(r.top + r.Height() * 2 / 3);

		if (align == Ctrl::RIGHT || align == Ctrl::SIZE)
			w.DrawLine(r.right, y, GetRect().Width() - 2, y, 1, LtRed());
		else
			for (int i = r.right; i < GetRect().Width() + 5; i += 5)
				w.DrawLine(i, YToGrid(y - 5, !centered), i, YToGrid(y + 5, !centered), 1,
					LtRed());
	}

	if (drawTop)
	{
		if (!centered)
			x = XToGrid(r.left + r.Width() / 3);

		if (valign == Ctrl::TOP || valign == Ctrl::SIZE)
			w.DrawLine(x, 2, x, r.top, 1, LtRed());
		else
			for (int i = 5; i <= r.top; i += 5)
				w.DrawLine(XToGrid(x - 5, !centered), i, XToGrid(x + 5, !centered), i, 1,
					LtRed());
	}

	if (drawBottom)
	{
		if (!centered)
			x = XToGrid(r.left + r.Width() * 2 / 3);

		if (valign == Ctrl::BOTTOM || valign == Ctrl::SIZE)
			w.DrawLine(x, r.bottom, x, GetRect().Height() - 2, 1, LtRed());
		else
			for (int i = r.bottom; i < GetRect().Height() + 5; i += 5)
				w.DrawLine(XToGrid(x - 5, !centered), i, XToGrid(x + 5, !centered), i, 1,
					LtRed());
	}
}
void DrawRectLine(Draw& w, Rect &r, int lineWidth, const Color &color) {
	w.DrawLine(r.left, r.top, r.right, r.top, lineWidth, color);
	w.DrawLine(r.right, r.top, r.right, r.bottom, lineWidth, color);
	w.DrawLine(r.right, r.bottom, r.left, r.bottom, lineWidth, color);
	w.DrawLine(r.left, r.bottom, r.left, r.top, lineWidth, color);
}
void DrawRectLine(Draw& w, Point &pos, Size &s, int lineWidth, const Color &color) {
	w.DrawLine(pos.x, pos.y, pos.x+s.cx, pos.y, lineWidth, color);
	w.DrawLine(pos.x+s.cx, pos.y, pos.x+s.cx, pos.y+s.cy, lineWidth, color);
	w.DrawLine(pos.x+s.cx, pos.y+s.cy, pos.x, pos.y+s.cy, lineWidth, color);
	w.DrawLine(pos.x, pos.y+s.cy, pos.x, pos.y, lineWidth, color);
}
void DrawRectLine(Draw& w, int x, int y, int width, int height, int lineWidth, const Color &color) {
	w.DrawLine(x, y, x+width, y, lineWidth, color);
	w.DrawLine(x+width, y, x+width, y+height, lineWidth, color);
	w.DrawLine(x+width, y+height, x, y+height, lineWidth, color);
	w.DrawLine(x, y+height, x, y, lineWidth, color);
}
Exemple #9
0
void TreeTest::DrawGrid(Draw& w)
{
	// draw a coordinate grid
	// probably will be extracted into own object later
	// needs to be smarter / more configurable
	// would be nice to add a frame around the view

	int inc,mins;
	if(m_rcBnds.Width()>5000000.0)
	{
		inc = 1000000;
	}
	else if(m_rcBnds.Width()>500000.0)
	{
		inc = 100000;
	}	
	else if(m_rcBnds.Width()>50000.0)
	{
		inc = 10000;
	}
	else if(m_rcBnds.Width()>5000.0)
	{
		inc = 1000;
	}
	else
	{
		inc = 100;		
	}
	
	Color colGrid(128,128,128);
	
	// draw grid
	int x0 =  (int)(m_rcBnds.left - fmod(m_rcBnds.left,inc) +0.5);
	int y0 =  (int)(m_rcBnds.bottom - fmod(m_rcBnds.bottom,inc)+0.5);
	Pointf ptf1,ptf2;
	Point pt1,pt2;
	String s;

	ptf1.y = m_rcBnds.bottom;
	ptf2.y = m_rcBnds.top;
	
	Font font(StdFont().GetFace(),(int)(StdFont().GetHeight()));//*m_fTextSizeFactor));
	
	s = Format(" %.0f ",m_rcBnds.top);
	mins = ::GetTextSize(s,font).cx;
	
	for(int x = x0;x<m_rcBnds.right;x+=inc)
	{
		ptf1.x = ptf2.x = x;
		
		pt1 = MPtoLP(ptf1);
		pt2 = MPtoLP(ptf2);
		
		s = Format(" %.0f ",x);

		Size sz = ::GetTextSize(s,font);

		if(pt1.x < mins)//sz.cx)
			continue;

		w.DrawText(pt1.x-sz.cy/2,pt1.y,900,s,font,colGrid);
		
//		w.DrawText(pt1.x+sz.cy/2,pt1.y-sz.cx,-900,s,font,colGrid);
		
		pt1.y-=sz.cx;
		
		w.DrawLine(pt1, pt2, 1, colGrid);
	}

	ptf1.x = m_rcBnds.left;
	ptf2.x = m_rcBnds.right;

	s = Format(" %.0f ",m_rcBnds.right);
	mins = ::GetTextSize(s,font).cx;

	for(int y = y0;y<m_rcBnds.top;y+=inc)
	{
		ptf1.y = ptf2.y = y;
		
		pt1 = MPtoLP(ptf1);
		pt2 = MPtoLP(ptf2);
		
		s = Format(" %.0f ",y);

		Size sz = ::GetTextSize(s,font);

		if(pt1.y > m_rcClient.bottom - mins)//sz.cx)
			continue;

		w.DrawText(pt1.x,pt1.y-sz.cy/2,s,font,colGrid);

		pt1.x += sz.cx;

		w.DrawLine(pt1, pt2, 1, colGrid);
	}	
}