gichan@blake.u.washington.edu (Gilbert Chan) (08/14/90)
I'm posting the following message for a friend, PLEASE direct all your
responses to him at bchan@ddn-eur.ddn.mil . Thank you.
---------------------------------------------------------------------
My objective is to display a 2-D vector (say x vs y) using server images
(icons) on a base frame. [user clicks on the x panel buttons and then it will
do something else.] I first draw the 5 types of icons (image_?_bits) using
iconedit to represent, say integers from 0 - 4. Then I declare them by:
image_1 = (Server_image)xv_create(NULL, SERVER_IMAGE,
SERVER_IMAGE_COLORMAP, "palette",
XV_WIDTH, 16,
XV_HEIGHT, 16,
SERVER_IMAGE_DEPTH, 1,
SERVER_IMAGE_BITS, image_1_bits,
NULL);
(I show only one here.)
Then I treat the icon as a panel message and displayed the icon as fellow:
/* display icon */
(void) xv_create(l_panel, PANEL_MESSAGE,
XV_X, xv_col(l_panel, col),
XV_Y, xv_row(l_panel, row),
PANEL_LABEL_IMAGE, image_1,
NULL);
This scheme works fine. (I am using this approach since I don't have
worry about the font width, and height stuff when I need to display
the column and rows labels as panel buttons.)
The trouble is when I want to colorize individual icons, I hit a wall.
I have tried WIN_FOREGROUND and WIN_BACKGROUND and SERVER_IMAGE_DEPTH = 8.
No helps.
I also have taken the hint from the example color_objs.c under Color in
book 7 of the O'Reilly series:
void declare_image(panel)
Panel panel;
{
register int i;
Display *dpy = (Display *)xv_get(panel, XV_DISPLAY);
unsigned long mask, *pixels;
XGCValues values;
Pixmap pixmap;
GC gc;
if (DefaultDepth(dpy, DefaultScreen(dpy)) == 1) {
puts("You need a color display to run this program");
exit(1);
}
/* setup gc for drawing colord squares (chips) */
values.graphics_exposures = False;
values.foreground = 1;
mask = GCGraphicsExposures | GCForeground;
gc = XCreateGC(dpy,
RootWindow(dpy, DefaultScreen(dpy)), mask, &values);
/* Get the actual X pixel values from the colormap. The colormap
* has been installed on the panel, so use that. Any window with
* a cms colormap will do.
*/
pixels = (unsigned long *)xv_get(panel, WIN_X_COLOR_INDICES);
not_active_image = (Server_image)xv_create(NULL, SERVER_IMAGE,
SERVER_IMAGE_COLORMAP, "palette",
XV_WIDTH, 16,
XV_HEIGHT, 16,
WIN_FOREGROUND_COLOR, 3,
WIN_BACKGROUND_COLOR, 5,
SERVER_IMAGE_DEPTH, 8,
SERVER_IMAGE_BITS, not_active_bits,
NULL);
i=3; /* color index */
XSetForeground(dpy, gc, pixels[i]);
pixmap = (Pixmap)xv_get(not_active_image, XV_XID);
/* XFillRectangle(dpy, pixmap, gc, 0, 0, 16, 16); */
The foreground color didn't change. The icon was corrupted because of the
server_image_depth.
One of my problems I can think of is the pixmap business. But how can I
draw an icon using pixmap?
I have struggled on this problem for quite some time now. (I have less than
a month of XView experience under my belt.) Can anyone point me to the right
direction?
Thank you very much for your help,
Brian Chan
Stuttgart, FRG
Internet: bchan@ddn-eur.ddn.mil
Phone # 49-711-680-5364
Autovon # 430-5364