Question on Canv as

BlitzMax Forums/BlitzMax Programming/Question on Canv as

ziggy(Posted 2006) [#1]
How can I know wich is the active graphic canvas gadget?
I need to make a SetGraphics command in a function, to make some drawings, and then leave everything as it was, so I need to store the 'current' graphics object, before changing it, in order to put it again as the default one. It's very strange that there is a SetGraphics, but there is not a GetGraphics...

Any idea how this can be done?


ImaginaryHuman(Posted 2006) [#2]
Event.Source tells you the source of an event coming from a specific canvas.


ziggy(Posted 2006) [#3]
I know it. The problem is that I'm making a module that has event based drawings, but I don't want a event-base drawing to change the canvas where the user of my module is making his or her own drawings. So after this event-based drawing i need to leave everything as it was and I see no way to do this.


ImaginaryHuman(Posted 2006) [#4]
You don't need a GetGraphics(). All you need is to keep track of what object YOU are choosing each time you use SetGraphics. When you SetGraphics(), put the graphics object in an array or something, like a stack. Then when you want to temporarily set new graphics, do it, put it on the stack, then take it back off and setgraphics to the last item that was on the stack before.


ziggy(Posted 2006) [#5]
AngelDaniel: What you say doesn't fix anything. I don't spect my module users to add an item to this stack when THEY create a canvas or change it using a SetGraphics. My module handles all its canvas properly, that's not the problem, the problem is, if a user has defined his or her own canvas (otside my module), and I change it inside the module, how can I roll back this change if I have no information of what graphic object (canvas) was active before?

It's easy to store the alpha value, the blend mode,etc, using a GetAlpha, GetBlend, etc... Why GetGraphics doesn't exists?

My function needs to do the following:

1.- Get the state of all graphics (alpha, blending, active canvas, etc)

2.- Do whatever, changing whatever

3.- Leave everything as it was.

With current graphic commands that's not possible or, if it is, I would like to know how.
There's no sense to have a SetGraphics without a GetGraphics.

Said in other words, when you say 'Put it on the stack, then take it back off' How Am I supoused to take it back off, if I can't gess it's original state, becouse it depends on another person code?


tonyg(Posted 2006) [#6]
Doesn't canvasgraphics return the current canvas?
If not maxgui then doesn't can you save the TGraphics object?


ziggy(Posted 2006) [#7]
@tonyg: canvasgraphics doesn't return the current active canvas object, and that's what I need, and I can't save the TGraphics object unless I create it and keep it in a var, stack engine or whatever, but I can't do that becouse my problem is for canvas objects that are not created my myself, but created by my module users. It's a big problem I think it should be solved adding a GetGraphics command to BlitzMax.


Dreamora(Posted 2006) [#8]
And, where is the problem?
Make a function in your module, called "MyCreateCanvas" which they have to use in order to have your module working.

Then you can keep it active.

If you do not have the full knowledge of all created canvases, your plan is quite pointless as you need to know what is where and when to do it on a usefull level.


ziggy(Posted 2006) [#9]
@Dreamora: As always, you're right, it's just that I would like to avoid this. I don't like forcing users to use another command to make exactly the same they would do with an already existing command. There's really no problem, it's just a problem of code elegance...