changing background colour of an rc_graphic window 
Author Message
 changing background colour of an rc_graphic window

Does anyone know how to change bacground colour of rc_graphic window?

XpwSetColor can be used to change the foreground colour (as shown in
TEACH RC_GRAPHIC), but I have found no way to change the background
colour (except within the new GO (Graphical Objects) package, which is
not generally available yet).

You can also change the foreground colour of the rc_graphic window by
doing, for example

'red' -> rc_window("foreground");   ;;; NOT in TEACH RC_GRAPHIC!

But this doesn't work, alas

'pink' -> rc_window("background");

There must be a way surely? I tried this code, based on stuff in
GO but it did not work either.

define rc_set_bgcolour(colourstring, widget);
    lvars colourstring, widget, colournumber, widget, oldcolour;

    ;;; remember original colour
    XptValue(widget, XtN foreground) -> oldcolour;

    ;;; find the new integer colour number
    colourstring -> widget("foreground");
    XptValue(widget, XtN foreground) -> colournumber;

    ;;; reinstate old fg colour
    oldcolour -> XptValue(widget, XtN foreground);
    ;;; set new background
    colournumber -> XptValue( widget, XtN background );
enddefine;

/*
;;; test it
lib rc_graphic;

rc_start();

rc_set_bgcolour('green', rc_window);

;;; doesn't work
*/

Any ideas welcome.
Aaron



Tue, 07 May 1996 16:55:56 GMT  
 changing background colour of an rc_graphic window

Quote:
>Does anyone know how to change bacground colour of rc_graphic window?

thinking laterally, try:

define rc_set_background(color);
   color -> rc_window("foreground");
   XpwFillRectangle(rc_window, 0, 0, rc_window("width"), rc_window("height"));
enddefine;

Of course, rc_start() may not use this color though I wouldn't be surprised
if:

        'red' -> rc_window("background");
        rc_start();

works...

Jon.



Wed, 08 May 1996 02:45:10 GMT  
 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



Wed, 08 May 1996 05:13:21 GMT  
 changing background colour of an rc_graphic window

    XpwSetColor(rc_window, colour) -> XptValue(rc_window, XtN background);

works (with the side effect of setting the foreground colour to be the same -
needs to be reset). But it won't have a visible effect until the next

    rc_clear_window();

or some other "clear" operation.

Colin



Sat, 11 May 1996 00:32:19 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. VW2 Changing Background Colour

2. Changing image background colour on canvas?

3. Changing background colour of BLT hiertable

4. How to change Pythonwin background colour?

5. 24 Bit colour and RC_GRAPHIC

6. Tkinter: changing colour of scrollbars on Windows

7. Default Colour of Windows - How to change ?

8. VOS2 - Changing Window Backgrounds

9. Change Window Background Color at Runtime

10. Changing window background for printing

11. programatically changing windows desktop background

12. C55 Internet & Background Colour

 

 
Powered by phpBB® Forum Software