Drawing Program (which graphical toolkit to use)
Stefan Csomor
csomor at advancedconcepts.ch
Wed Nov 7 12:13:08 PST 2007
Hi
I don't think you have your handlers setup as you should, seems like you
still are doing drawing within a mouse handler...
the handler of a Paint event usually is like this
MyClass::OnPaint(wxPaintEvent &event )
{
wxPaintDC pdc(this);
so the wxPaintDC constructor's parameter is this, not another window,
and the method parameter is a wxPaintEvent, it doesn't have a
GetPosition or ButtonDown method. You setup the line coordinates from
within your MouseEvent handler, but the drawing must be done from within
a PaintEvent handler.
Best,
Stefan
Declan McMullen wrote:
> Nope but i have now, it compiles but crashes.
>
> I try to insert a line by clicking on a start point and end point,
> nothing appears on screen and the program crashes:
>
> wxPaintDC pdc(panel);
> wxGCDC gdc(pdc);
> wxDC &dc = (wxDC&) gdc ;
>
> wxPen pen(*wxBLACK, 3, wxSOLID);
> dc.SetPen(pen);
> if(event.ButtonDown())
> {
> if(lineX1 == 0 && lineY1 == 0)
> {
> wxPoint point = event.GetPosition();
> lineX1 = point.x;
> lineY1 = point.y;
> dc.DrawPoint(lineX1, lineY1);
> }
> else
> {
> wxPoint point = event.GetPosition();
> dc.DrawLine(lineX1,lineY1, point.x, point.y);
> dc.SetPen(wxNullPen);
> lineX1 = 0;
> lineY1 = 0;
> }
> }
>
> On 7 Nov 2007, at 16:54, Stefan Csomor wrote:
>
>> Hi
>>
>> Declan McMullen wrote:
>>> I meant to add I also tried
>>>
>>> wxPaintDC pdc(panel);
>>> wxGCDC gdc(pdc);
>>>
>>> but it told me wxGCDC was not declared in this scope.
>>>
>>> And i have included graphics.h
>>>
>> wxGCDC would be in wx/dcgraph.h
>>
>> did you include that as well ?
>>
>> Best,
>>
>> Stefan
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: wx-users-unsubscribe at lists.wxwidgets.org
>> <mailto:wx-users-unsubscribe at lists.wxwidgets.org>
>> For additional commands, e-mail: wx-users-help at lists.wxwidgets.org
>> <mailto:wx-users-help at lists.wxwidgets.org>
>>
>>
>
> http://www.computing.dcu.ie/~dmcmullen
> <http://www.computing.dcu.ie/%7Edmcmullen>
> declan.mcmullen at computing.dcu.ie <mailto:declan.mcmullen at computing.dcu.ie>
> School of Computing
> Dublin City University
> Postgrad Bay A
>
>
>
>
--
Advanced Concepts AG
Software-Engineering
Heldweg 10
CH-8475 Ossingen
Switzerland
phone:+41 52 245 0 245
fax:+41 52 245 0 246
http://www.advanced.ch
mailto:csomor at advanced.ch
More information about the wx-users
mailing list