smikes@hound.UUCP (S.MIKES) (04/28/89)
Well, here I am again, asking another silly question! My objective is to place icons in a window and be able to manipulate them (i.e. move, add, delete, re-color, etc.) My current thinking on this is that the icons themselves will be created using the bitmap client. What I am in the dark about is how to get the bitmap file's contents to appear in my specific window, and then be able to subsequently move it around. (Each icon must also be sensitive so that an appropriate callback can be invoked.) When the window is resized, the icons should stay in place and not be scaled to fit into the new size. The following code fragment illustrates the basics of what I am attempting in order to create and display an image from a bitmap (#included earlier): XImage *image; image=XCreateImage( dpy, visual, 1, XYBitmap, 0, (char *)the_bitmapbits, width, height, 8, (width/8) ); XPutImage( dpy, mywin, gc, image, 0,0, 50,50, width, height ); XMapWindow( dpy, mywin ); This doesn't work, needless to say; although I thought it should. Could anyone give me a clue what I need to do to get this to work? (Please be specific.) Secondly, once I get an image on screen, is it possible to make the image sensitive without making it a widget; and if so, how would I go about moving it in the same fashion as the uwm window manager moves windows? I am really looking for short cuts to develop this capability quickly, any help would be greatly appreciated. Thanks in advance, Steve {...}hound!smikes (201)949-7737 "It's good to be the King!" -- Mel Brooks
rws@EXPO.LCS.MIT.EDU (04/28/89)
XImage *image; image=XCreateImage( dpy, visual, 1, XYBitmap, 0, (char *)the_bitmapbits, width, height, 8, (width/8) ); You want (width + 7) / 8. But also, this call will set bitmap attributes based on the display rather than based on the source image. This is a defect in the Xlib interface; you'll want to smash values in the image after you create it. XPutImage( dpy, mywin, gc, image, 0,0, 50,50, width, height ); XMapWindow( dpy, mywin ); You can't expect to put graphics into an unmapped window, and then map it, and expect the graphics to appear. Do not pass Go, return to your favorite X book's explanation of mapping/exposure/redraw mechanics.