[comp.windows.x] Xtk string to pixmap converter problem

gary@torch.UUCP (Gary Henderson) (08/05/88)

I am trying to write a string to pixmap converter for the X-toolkit so users
can specify background bitmaps for widgets from .Xdefaults files.

Two problems:

1) I need two colours to use when converting a bitmap file into a pixmap.  I
   can use the widget's background colour for one but what do I use for the
   other colour ? Some widgets have a foreground colour but this hasn't been
   set when the background string to pixmap conversion is required.  I can't
   use the main application colours either (using XtGetApplicationResources)
   as these haven't been set if the converter is called for the
   application's toplevel widget.

2) Once a given string has been converted into a pixmap, the resource
   converter manager caches the result (the pixmap XID) and will not call
   my routine again with the same string.  Unfortunately, a core widget frees
   its background pixmap when it is being destroyed, so if several widgets
   use the same background pixmap and widgets are being created and destroyed,
   you end up with "Parameter is not a pixmap" errors from the server when a
   widget tries to select a pixmap XID as its background, an XID that some
   other widget has just freed when it got destroyed !

PLEASE HELP !

swick@ATHENA.MIT.EDU (Ralph R. Swick) (08/11/88)

     Date:  5 Aug 88 15:54:51 GMT
     From:  mcvax!ukc!stl!stc!datlog!torch!gary@uunet.uu.net  (Gary Henderson)

     1) I need two colours to use when converting a bitmap file into a pixmap.  I
        can use the widget's background colour for one but what do I use for the
        other colour ? 

Since you haven't described the semantics of string to pixmap, all sorts
of things are possible.  It is not unreasonable to fetch additional
resources from the resource database within a conversion procedure.
You will want to carefully define the conversion attributes you depend
upon (in convert_args) so as to get maximum benefit from the resource
cache.

    2) Once a given string has been converted into a pixmap, the resource
       converter manager caches the result (the pixmap XID) and will not call
       my routine again with the same string.  Unfortunately, a core widget frees
       its background pixmap when it is being destroyed

The fact that Core frees resources that it did not create has been
reported as a bug.  There is no reasonable workaround, but you could
deduce a hack from what I said above.