Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!decwrl!adobe!asente From: asente@adobe.com (Paul Asente) Newsgroups: comp.windows.x Subject: Re: Pixmap size Message-ID: <5648@adobe.UUCP> Date: 16 Aug 90 17:13:24 GMT References: <3254@syma.sussex.ac.uk> Sender: news@adobe.COM Organization: Adobe Systems Inc. Lines: 37 In article <3254@syma.sussex.ac.uk> jonm@syma.sussex.ac.uk (Jonathan Meyer) writes: >I want to add a converter in Xt for the backgroundPixmap, that takes a string >(bitmap file) and creates a pixmap of the correct depth for the window, with >two colours (foreground and background). This is much harder than it seems! >Because there is no foreground_pixel in the Core widget, I can't think of >a good way of doing this - when the converter is being run it doesn't know >what foreground colour to use, because the foreground resource hasn't been set >yet. All it can do is create a black and white pixmap. You can do this, but it's not terribly pretty. Step 1: Define your string-to-pixmap converter, and pass the foreground and background in as conversion arguments. The converter argument should be of type XtResourceString, so the appropriate arguments are {XtResourceString, XtNforeground, sizeof(Pixel)}, {XtWidgetBaseOffset, XtOffsetOf(WidgetRec, core.background_pixel), sizeof(Pixel)} (see, those other converter arg types are good for something!) Specifying the arg as XtResourceString means that this converter can be used in different widget classes that may not all have XtNforeground in the same place in the widget record. Step 2: Define a new widget field and resource that will hold the result of the conversion. Rather than specifying the background pixmap, specify this resource. The resource list entry for this must occur *after* the entry for XtNforeground, otherwise the converter won't be able to use the foreground. Step 3: In your initialize procedure, if this new resource field is not None, copy it into the core.background_pixmap field. -paul asente New address! asente@adobe.com ...decwrl!adobe!asente