Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Newbie - how to find centre of PtRaw: (2 Items)
   
Newbie - how to find centre of PtRaw  
Hi,
trying out PhaB, I created a PtRaw in a container, and in the raw draw function, use CalcCanvas to get UL and LR, as per
 the examples.
OK...I can draw a line or a grid in the right locations with this.

But...when I try to draw another line based on CalcCanvas-called-from-a-timer-callback (the timer is also in the 
container) the line appears in the wrong place, and sometimes moves its location based on resizing the application 
window!

I have tried PgGetGC in the raw draw function, passing the result over to a PgSetGC in the timer callback, but to no 
avail. (It DID help with the XOR draw, which was trashing a text box until I used PgDefaultMode(pRawCtx)  .) But I don't
 really know why that helped.

Basically, it appears that I do not know how to access the PtRaw drawing context outside the RawDraw function.

Help?
Re: Newbie - how to find centre of PtRaw  
You should not render from a timer callback. The draw context is not guarantied to be in a consistent state (more 
importantly translations) when timer/input/etc callbacks are called. You should only draw in your raw draw function. So,
 in your timer callback you should damage your raw widget. You can use these functions: PtDamageWidget() or 
PtDamageExtent(). The widget will get marked that it needs a redraw and it will be drawn in a proper time.
-Misha.