Page 1 of 1

How do draw a line for the data?

Posted: Wed Jul 22, 2015 1:20 pm
by manggae
i painted the line using a and b by mfc.
for example,

Code: Select all

        CStatic* stc = (CStatic *)GetDlgItem(IDC_STATIC_ENERGY); // i want to draw in ID_PANEL1, instead of IDC_STATIC_ENERGY
	CRect rect;

	CClientDC dc(stc);
	stc->GetClientRect(&rect);
	CBrush brush;
	brush.CreateSolidBrush(RGB(255, 255, 255));
	FillRect(dc, &rect, brush);

	dc.MoveTo(0, rect.bottom/2);
		for (int n=0; n<frameN; n++)
		{
			//dc.LineTo(n/amp_scale2,2*feature2d[n][0]);
			dc.LineTo(n,2*feature2d[n][0]);
		}
		brush.DeleteObject();
As I tried to draw the data in the wxWidgets.
While reading the Reference, one by one, is not easy to learn.
please teach me about draw data(line) by wxwidgets.

Re: How do draw a line for the data?

Posted: Wed Jul 22, 2015 1:52 pm
by doublemax
This shows you how a create a wxPanel for custom drawings:
https://wiki.wxwidgets.org/Drawing_on_a_panel_with_a_DC

And this is the reference for wxDC:
http://docs.wxwidgets.org/trunk/classwx_d_c.html

Most method names are similar to MFC.

Re: How do draw a line for the data?

Posted: Wed Jul 22, 2015 2:22 pm
by manggae
i make source in mfc about connect CRect with CClientDC.
CStatic* stc = (CStatic *)GetDlgItem(IDC_STATIC_ENERGY);
CRect rect;
CClientDC dc(stc);
stc->GetClientRect(&rect);

hm....Perhaps, if i connect wxRect and wxclient, i can draw data..

wxRect rect;
wxClientDC dc(Panel1);

but I failed to find about connect wxRect and wxclient in Reference.
How should the connection?

Re: How do draw a line for the data?

Posted: Wed Jul 22, 2015 2:42 pm
by doublemax

Code: Select all

wxRect rect = Panel1->GetRect();