[comp.windows.x] Visuals and Xt

davy@wizzrobe.ee.washington.edu (12/30/90)

I would like to know if there is a way to use a different visual
than the default visual when using the Xt toolkit and/or if there
is a way to change the default visual to another visual that 
the server is exporting.

David Yee
University of Washington
davy@wizzrobe.ee.washington.edu

etaylor@wilkins.iaims.bcm.tmc.edu (Eric Taylor) (01/01/91)

Use XtNvisual for the shell widget.
You can bring up a different default visual
for a server with the 'cc' option I believe.

When I tried it, however, you have to give
a number for the visual.  This number seemed
totally random with respect to the visual it
was supposed to represent.

i.e.  with the mit server, 2 brought up gray scale,
1 brought up TrueColor.  The exact mapping was 
different from these numbers, but the apporximate 
range of numbers is correct.
--
					Eric Taylor
					Baylor College of Medicine
					etaylor@wilkins.bcm.tmc.edu
					(713) 798-3776

davy@wizzrobe.ee.washington.edu (01/01/91)

In article <3413@gazette.bcm.tmc.edu> etaylor@wilkins.iaims.bcm.tmc.edu (Eric Taylor) writes:
>
>Use XtNvisual for the shell widget.
>You can bring up a different default visual
>for a server with the 'cc' option I believe.
>

In my original question I forgot to mention that I am using R3 and
not R4.  And it seems like these two solutions do not work in R3.

So does anybody know how to easily use a different visual with the
Xt toolkit, or how to change the default visual for X11R3?

David Yee
University of Washington
davy@wizzrobe.ee.washington.edu

mouse@larry.mcrcim.mcgill.EDU (01/01/91)

> You can bring up a different default visual for a server with the
> 'cc' option I believe.

This is server-specific (though I believe the MIT server does this,
meaning most others supporting multiple visuals probably do as well).

> When I tried it, however, you have to give a number for the visual.
> This number seemed totally random with respect to the visual it was
> supposed to represent.

In the protocol, I find only one place where a mapping between small
integers and visual classes is listed.  The mapping given there is

     0         StaticGray
     1         GrayScale
     2         StaticColor
     3         PseudoColor
     4         TrueColor
     5         DirectColor

UTSLing indicates that this is the mapping used by the MIT server's -cc
option.  This probably should accept a string instead of a small
integer; I suspect it's just a case of nobody getting around to it.
(If it's still done this way in R5 I'll probably submit a fix...)

					der Mouse

			old: mcgill-vision!mouse
			new: mouse@larry.mcrcim.mcgill.edu

dbrooks@penge.osf.org (David Brooks) (01/02/91)

mouse@larry.mcrcim.mcgill.EDU writes:
>In the protocol, I find only one place where a mapping between small
>integers and visual classes is listed.  The mapping given there is
>
>     0         StaticGray
(etc...)

You'll also find it in /usr/include/X.h:

   /* Display classes  used in opening the connection 
    * Note that the statically allocated ones are even numbered and the
    * dynamically changeable ones are odd numbered */

   #define StaticGray		0
   #define GrayScale		1
   #define StaticColor		2
   #define PseudoColor		3
   #define TrueColor		4
   #define DirectColor		5

Admittedly, this still isn't much help in exporting the number to the
"-cc" option of the server.
-- 
David Brooks				dbrooks@osf.org
Systems Engineering, OSF		uunet!osf.org!dbrooks
In Memoriam: Chris Naughton, aged 16, killed by a drunk driver Dec 22, 1990

swick@athena.mit.EDU (Ralph Swick) (01/03/91)

    In my original question I forgot to mention that I am using R3 and
    not R4.  And it seems like these two solutions do not work in R3.

Right.  To specify the visual through Xt, you'll need to write some code
to replace the Realize method of one or more widget classes (e.g. the
ApplicationShell).  Not hard to do, but it can be awkward to get your
application to use a different shell class in some circumstances.

The proper way to replace the Realize method is by subclassing from
ApplicationShell (or from whatever shell(s) you use in your application),
but there are certainly other short-cuts (read "hacks") you could take
as a stop-gap measure 'till you can get the R4 Xt.