Page 1 of 1

PostPosted: Wed Mar 28, 2001 9:52 am
by guy
Mentioned before, but now deserves its own topic.

This must be a really easy one to add to the runtime:

Provide a function that you call to change the default device context for the drawing functions. Either a one-shot, that just affects the next drawing function, or one that you have to reset.

Currently you must call GetDC to get the context for the first parameter for each of the drawing functions anyway. Why not let the PocketC programmer define the context with a SetDC(guiid) type function.

Then, we can draw on controls.

Reason for request:

createctrl1() allows controls to be children of other controls, but you can't create "drawing object" children of a control.

I want to update the cmdbar library now that createctrl1() is around to make the menu components children of the command bar control itself. I'd also like to be able to draw bitmap buttons onto the command bar. This needs to be handled by drawing onto the command bar itself because show/hide would require too much interaction with the user's application otherwise (redraw/resize callbacks).

So. Simple function to add and implement.

Most convenient implementation would be via a "locking" rather than one-shot set:

setdc(myctrlid) ; // Start to draw on child
rect(10,10,100,100) ;
rect(110,110,100,100) ;
setdc(1) ; // Back to main screen

Needs to apply to all drawing functions including bitmaps.

One-shot may be easier to manage from the point of view of resources, but the code would look really nasty if you had lots of objects to draw.