
changing background colour of an rc_graphic window
I asked
Quote:
> >Does anyone know how to change bacground colour of rc_graphic window?
Jon replied
Quote:
> thinking laterally, try:
> define rc_set_background(color);
> color -> rc_window("foreground");
> XpwFillRectangle(rc_window, 0, 0, rc_window("width"), rc_window("height"));
> enddefine;
Sure enough - it changed the colour of whole window, but as it changed
the foreground colour too, so subsequent drawing did not show up. You
can use dlocal to make the change to the foreground colour temporary:
define rc_set_background(colour);
lvars colour;
dlocal %rc_window("foreground")% = colour;
XpwFillRectangle(rc_window, 0, 0, rc_window("width"), rc_window("height"));
enddefine;
So this works
'black' -> rc_window("foreground");
rc_set_background('pink');
rc_drawline(-100,0,0,100);
But if you change the background to white
rc_set_background('white');
the black line disappears so the line has to be redrawn. This is one of
the advantages of GO. You can change the background colour of a window
and all the objects on it will remain visible if the foreground colour
is different.
Jon went on:
Quote:
> Of course, rc_start() may not use this color though I wouldn't be surprised
> if:
> 'pink' -> rc_window("background");
> rc_start();
> works...
So it does, so, since rc_start uses XpwClearWindow, another version
would be this:
define rc_set_background(colour);
lvars colour;
colour -> rc_window("background");
XpwClearWindow(rc_window);
enddefine;
And this does indeed work. Moreover, it has the advantage that you can
later interrogate rc_window("background"). So this should presumably
be added to LIB RC_GRAPHIC
But I wonder what's going on when you do
'pink' -> rc_window("background");
and why that doesn't change it? It certainly changes something!
Thanks
Aaron