kit@athena.mit.edu (Chris D. Peterson) (03/12/88)
A group of application developers here at Project Athena wanted to be able to easily display graphics in their Xtk, applications. As a result I have made some changes to the Command and Label Widgets to allow pixmaps to be rendered rather than just text. I thought that some of you xperts might be interested in them, so I'm offering to mail the source code to interested parties. If I get flooded with requests I may just put it up on expo in the contrib directory, so let me know if you do not have ftp access to expo. Although I work for Project Athena I do not decide what goes into our widget set, so these enhancements are by no means blessed. Use them at your own risk. I have included documentation on the added features of these widgets at the end of this posting, all these features are in addition to those documented with the X11R2 Athena Widget Set. Chris D. Peterson Project Athena Systems Development Net: kit@athena.mit.edu Phone: (617) 253 - 1326 USMail: MIT - Room E40-342C 77 Massachusetts Ave. Cambridge, MA 02139 ------------------------------------------------------------ Graphics in the Athena Command and Label Widgets (X11R2). With these enhanced versions of the Command and Label widgets users may add bitmap pictures to their widgets at run time, and toolkit application programmers may easily create Labels with full color graphics in them, instead of text. These changes are all transparent, so putting these widgets in the place if the current widgets will cause no harm whatsever (bugs don't count, however). I will go into the details of the added functionality of these widgets, in the following few paragraphs. The Command button, is functionally the same in outside appearence, but the source code has Major changes. The net effect is that it now uses the redisplay proceedure of its ancestor (Label Widget) to paint the image into the window rather than assumimg that the image is text and displaying the text itself. I have made no changes in the arguments of the command button, (other than those it inherits from my new Label Widget). The Label button now has the following new aguments: imageType imageWidth imageHeight bitmap The imageType may be specified at runtime as either 'string' or 'bitmap', if the imageType is 'bitmap' them it will look for the name of a standard X bitmap file in the 'bitmap' field. Since the height and width of the bitmap are specified in the file, there is no need for the user to specify the image height and width. Here are a few lines from a sample .Xdefaults file: xmh*folderButtons*imageType: bitmap xmh*folderButtons.close.bitmap: /mit/kit/Icons/close.icon xmh*folderButtons.compose.bitmap: /mit/kit/Icons/compose.icon xmh*folderButtons.open.bitmap: /mit/kit/Icons/open.icon These bitmap files were all created using the bitmap editor, provided as part of the standard X Release. Bitmaps are rendered in the forground color everywhere there is a one (1) is in the bitmap and in the background color everywhere there is a zero (0). More flexablilty has been added for the toolkit application programmer at compile time, image types at compile time are: XtLabelPixmap XtLabelBitmap XtLabelString (default) If the image type is XtLabelPixmap the Label widget expects a pixmap the same depth as the current root window as its 'bitmap' argument. This name was chose for the convience of users rather than application programmers. A pixmap of depth one (1) is expected if the imageType 'XtLabelBitmap' is used. XtLabelString will allow the widget to display text in exactly the manner it currently uses. The reason that this is not allowed run time is that I had no way of converting a string to a pixmap, since there is no file format defined yet, for multi-planed pixmaps :-(. Since the widget needs to know the size of the pixmap/bitmap it is to display, the imageWidth and imageHeight arguments are used to tell the widget the size of the pixmap passed into the 'bitmap' argument. These arguments are ingored if the imageType is XtLabelString. Here is a list of all new options and their default values. In the arglist: ARGUMENT DEFAULT DESCRIPTION VALUE ------------------------------------------------------------ XtNbitmap NULL A bitmap or pixmap to be rendered in the widget. XtNimageType XtLabelString One of: XtLabelString XtLabelBitmap XtLabelPixmap XtimageWidth 4 Width of the pixmap passed in the arglist. XtimageHeight 2 Height of the pixmap passed in the arglist. At Runtime in a defaults file, or the command line: NAME DEFAULT DESCRIPTION VALUE ------------------------------------------------------------ imageType String Either String or Bitmap. bitmap none The name of a standard X bitmap file to be rendered if the imageType is bitmap. BUGS: I haven't found any yet, but then again no one but me has used these widgets yet, these really are alpha test folks. I don't have a color workstation, so although I tried to make the code work in color, it has not been tested yet (sigh).