home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
x
/
volume13
/
xdtm
/
part03
< prev
next >
Wrap
Internet Message Format
|
1991-05-18
|
50KB
Path: uunet!cs.utexas.edu!sun-barr!newstop!exodus!cogs.sussex.ac.uk
From: eddyg@cogs.sussex.ac.uk (EdwardJ. Groenendaal)
Newsgroups: comp.sources.x
Subject: v13i008: xdtm - X Desktop Manager for the X Window System, Part03/11
Message-ID: <13572@exodus.Eng.Sun.COM>
Date: 19 May 91 00:02:54 GMT
References: <csx-13i006:xdtm@uunet.UU.NET>
Sender: news@exodus.Eng.Sun.COM
Lines: 1460
Approved: argv@sun.com
Submitted-by: Edward "J." Groenendaal <eddyg@cogs.sussex.ac.uk>
Posting-number: Volume 13, Issue 8
Archive-name: xdtm/part03
Submitted-by: eddyg@cste
Archive-name: xdtm/part03
---- Cut Here and feed the following to sh ----
#!/bin/sh
# This is part 03 of xdtm
# ============= xdtm/Xedw/XedwList.c ==============
if test ! -d 'xdtm'; then
echo 'x - creating directory xdtm'
mkdir 'xdtm'
fi
if test ! -d 'xdtm/Xedw'; then
echo 'x - creating directory xdtm/Xedw'
mkdir 'xdtm/Xedw'
fi
if test -f 'xdtm/Xedw/XedwList.c' -a X"$1" != X"-c"; then
echo 'x - skipping xdtm/Xedw/XedwList.c (File already exists)'
else
echo 'x - extracting xdtm/Xedw/XedwList.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'xdtm/Xedw/XedwList.c' &&
X#include <X11/copyright.h>
X
X/*
X * XedwList.c - XedwList widget
X *
X * This is the XedwList widget. It is very similar to the Athena Widget List,
X * except it has the ability to display an icon with the string. Plus allows
X * multiple selections.
X * It allows the user to select one or more items in a list and notifies the
X * application through a callback function.
X *
X * List Created: 8/13/88
X * By: Chris D. Peterson
X * MIT X Consortium
X *
X * Modified to XedwList: 1/26/91
X * By: Edward Groenendaal
X * University of Sussex, UK.
X */
X
X#include <stdio.h>
X#include <ctype.h>
X
X#include <X11/IntrinsicP.h>
X#include <X11/StringDefs.h>
X
X#include <X11/Xmu/Drawing.h>
X
X#include <X11/Xaw/XawInit.h>
X#include "XedwListP.h"
X
X/*
X * Include bitmap for the default icon
X */
X
X#include "DefIcon.icon"
X
X
X/*
X * Default Translation table.
X */
X
Xstatic char defaultTranslations[] =
X "!Shift<Btn1Down>: MultipleSet()\n\
X <Btn1Down>: Set()\n\
X !Shift<Btn1Down>,<Btn1Up>: Notify()\n\
X <Btn1Down>,<Btn1Up>: Notify()";
X
X/****************************************************************
X *
X * Full class record constant
X *
X ****************************************************************/
X
X/* Private Data */
X
X#define offset(field) XtOffset(XedwListWidget, field)
X
Xstatic XtResource resources[] = {
X {XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel),
X offset(xedwList.foreground), XtRString, "XtDefaultForeground"},
X {XtNcursor, XtCCursor, XtRCursor, sizeof(Cursor),
X offset(simple.cursor), XtRString, "left_ptr"},
X {XtNfont, XtCFont, XtRFontStruct, sizeof(XFontStruct *),
X offset(xedwList.font),XtRString, "XtDefaultFont"},
X {XtNxedwList, XtCXedwList, XtRPointer, sizeof(XedwList **), /* XedwList */
X offset(xedwList.xedwList), XtRString, NULL},
X {XtNdefaultColumns, XtCColumns, XtRInt, sizeof(int),
X offset(xedwList.default_cols), XtRImmediate, (caddr_t)2},
X {XtNlongest, XtCLongest, XtRInt, sizeof(int),
X offset(xedwList.longest), XtRImmediate, (caddr_t)0},
X {XtNnumberStrings, XtCNumberStrings, XtRInt, sizeof(int),
X offset(xedwList.nitems), XtRImmediate, (caddr_t)0},
X {XtNpasteBuffer, XtCBoolean, XtRBoolean, sizeof(Boolean),
X offset(xedwList.paste), XtRString, (caddr_t) "False"},
X {XtNforceColumns, XtCColumns, XtRBoolean, sizeof(Boolean),
X offset(xedwList.force_cols), XtRString, (caddr_t) "False"},
X {XtNverticalList, XtCBoolean, XtRBoolean, sizeof(Boolean),
X offset(xedwList.vertical_cols), XtRString, (caddr_t) "False"},
X {XtNinternalWidth, XtCWidth, XtRDimension, sizeof(Dimension),
X offset(xedwList.internal_width), XtRImmediate, (caddr_t)4},
X {XtNinternalHeight, XtCHeight, XtRDimension, sizeof(Dimension),
X offset(xedwList.internal_height), XtRImmediate, (caddr_t)2},
X {XtNcolumnSpacing, XtCSpacing, XtRDimension, sizeof(Dimension),
X offset(xedwList.column_space), XtRImmediate, (caddr_t)10},
X {XtNrowSpacing, XtCSpacing, XtRDimension, sizeof(Dimension),
X offset(xedwList.row_space), XtRImmediate, (caddr_t)10},
X {XtNiconWidth, XtCWidth, XtRDimension, sizeof(Dimension), /* IconWidth */
X offset(xedwList.icon_width), XtRImmediate, (caddr_t)32},
X {XtNiconHeight, XtCHeight, XtRDimension, sizeof(Dimension), /* IconHeight */
X offset(xedwList.icon_height), XtRImmediate, (caddr_t)32},
X {XtNshowIcons, XtCBoolean, XtRBoolean, sizeof(Boolean), /* ShowIcons */
X offset(xedwList.show_icons), XtRString, (caddr_t) "False"},
X {XtNmSelections, XtCBoolean, XtRBoolean, sizeof(Boolean), /* Multiple */
X offset(xedwList.multiple), XtRString, (caddr_t) "False"}, /* Selections */
X {XtNdefaultIcon, XtCPixmap, XtRPixmap, sizeof(Pixmap), /* DefaultIcon */
X offset(xedwList.default_icon), XtRPixmap, (caddr_t) NULL},
X {XtNcallback, XtCCallback, XtRCallback, sizeof(caddr_t),
X offset(xedwList.callback), XtRCallback, NULL},
X};
X
Xstatic void Initialize (Widget, Widget);
Xstatic void ChangeSize (Widget, Dimension, Dimension);
Xstatic void Resize (Widget);
Xstatic void Redisplay (Widget, XEvent*, Region);
Xstatic Boolean Layout (Widget, Boolean, Boolean, Dimension*, Dimension*);
Xstatic XtGeometryResult PreferredGeom(Widget, XtWidgetGeometry*, XtWidgetGeometry*);
Xstatic Boolean SetValues (Widget, Widget, Widget);
Xstatic void Notify (Widget, XEvent*, String*, Cardinal*),
X Set (Widget, XEvent*, String*, Cardinal*),
X MultipleSet (Widget, XEvent*, String*, Cardinal*),
X Unset (Widget, XEvent*, String*, Cardinal*);
Xstatic Boolean IsHighlighted(Widget, int);
Xstatic void AddNode (Widget, int);
Xstatic void RemoveNode (Widget, int);
X
Xstatic XtActionsRec actions[] = {
X {"Notify", Notify},
X {"Set", Set},
X {"Unset", Unset},
X {"MultipleSet", MultipleSet},
X {NULL,NULL}
X};
X
XXedwListClassRec xedwListClassRec = {
X {
X/* core_class fields */
X#define superclass (&simpleClassRec)
X /* superclass */ (WidgetClass) superclass,
X /* class_name */ "XedwList",
X /* widget_size */ sizeof(XedwListRec),
X /* class_initialize */ XawInitializeWidgetSet,
X /* class_part_initialize */ NULL,
X /* class_inited */ FALSE,
X /* initialize */ Initialize,
X /* initialize_hook */ NULL,
X /* realize */ XtInheritRealize,
X /* actions */ actions,
X /* num_actions */ XtNumber(actions),
X /* resources */ resources,
X /* num_resources */ XtNumber(resources),
X /* xrm_class */ NULLQUARK,
X /* compress_motion */ TRUE,
X /* compress_exposure */ FALSE,
X /* compress_enterleave */ TRUE,
X /* visible_interest */ FALSE,
X /* destroy */ NULL,
X /* resize */ Resize,
X /* expose */ Redisplay,
X /* set_values */ SetValues,
X /* set_values_hook */ NULL,
X /* set_values_almost */ XtInheritSetValuesAlmost,
X /* get_values_hook */ NULL,
X /* accept_focus */ NULL,
X /* version */ XtVersion,
X /* callback_private */ NULL,
X /* tm_table */ defaultTranslations,
X /* query_geometry */ PreferredGeom,
X },
X/* Simple class fields initialization */
X {
X /* change_sensitive */ XtInheritChangeSensitive
X }
X};
X
XWidgetClass xedwListWidgetClass = (WidgetClass)&xedwListClassRec;
X
X/****************************************************************
X *
X * Private Procedures
X *
X ****************************************************************/
X
Xstatic void GetGCs(Widget w)
X{
X
X XGCValues values;
X XedwListWidget ilw = (XedwListWidget) w;
X
X values.foreground = ilw->xedwList.foreground;
X values.background = ilw->core.background_pixel;
X values.font = ilw->xedwList.font->fid;
X ilw->xedwList.normgc = XtGetGC(w, (unsigned) GCBackground | GCForeground | GCFont,
X &values);
X
X values.foreground = ilw->core.background_pixel;
X values.background = ilw->xedwList.foreground;
X ilw->xedwList.revgc = XtGetGC(w, (unsigned) GCBackground | GCForeground | GCFont, &values);
X
X values.tile = XmuCreateStippledPixmap(XtScreen(w),
X ilw->xedwList.foreground,
X ilw->core.background_pixel,
X ilw->core.depth);
X values.fill_style = FillTiled;
X
X ilw->xedwList.graygc = XtGetGC(w, (unsigned) GCFont | GCTile | GCFillStyle,
X &values);
X}
X
X/* Function Name: ResetXedwList
X * Description: Resets the new xedwList when important things change.
X * Arguments: w - the widget.
X * changex, changey - allow the height or width to change?
X * Returns: none.
X */
X
Xstatic void ResetXedwList(Widget w, Boolean changex, Boolean changey)
X{
X XedwListWidget ilw = (XedwListWidget) w;
X Dimension width = w->core.width;
X Dimension height = w->core.height;
X register int i, len;
X
X /*
X * If xedwList is NULL then the xedwList will just be the name of the widget,
X * the icon will be set to the default icon. (defined in XedwListP.h)
X */
X
X if (ilw->xedwList.xedwList == NULL) {
X /* Make room for structure */
X ilw->xedwList.xedwList = XtNew(XedwList *);
X ilw->xedwList.xedwList[0] = XtNew(XedwList);
X ilw->xedwList.xedwList[0]->string = ilw->core.name;
X ilw->xedwList.xedwList[0]->icon = NULL;
X ilw->xedwList.nitems = 1;
X }
X
X if (ilw->xedwList.nitems == 0) /* Get number of items. */
X for ( ; ilw->xedwList.xedwList[ilw->xedwList.nitems] != NULL ; ilw->xedwList.nitems++);
X
X if (ilw->xedwList.longest == 0) /* Get column width. */
X for ( i = 0 ; i < ilw->xedwList.nitems; i++) {
X len = XTextWidth(ilw->xedwList.font, ilw->xedwList.xedwList[i]->string,
X strlen(ilw->xedwList.xedwList[i]->string));
X if (len > ilw->xedwList.longest)
X ilw->xedwList.longest = len;
X }
X
X /* If longest string is less than the width of a bitmap then the longest is
X * the width of a bitmap
X */
X if (ilw->xedwList.show_icons)
X if (ilw->xedwList.longest < ilw->xedwList.icon_width)
X ilw->xedwList.longest = ilw->xedwList.icon_width;
X
X
X ilw->xedwList.col_width = ilw->xedwList.longest + ilw->xedwList.column_space;
X
X if (Layout(w, changex, changey, &width, &height))
X ChangeSize(w, width, height);
X}
X
X/* Function Name: ChangeSize.
X * Description: Laysout the widget.
X * Arguments: w - the widget to try change the size of.
X * Returns: none.
X */
X
Xstatic void ChangeSize(Widget w, Dimension width, Dimension height)
X{
X XtWidgetGeometry request, reply;
X
X request.request_mode = CWWidth | CWHeight;
X request.width = width;
X request.height = height;
X
X switch ( XtMakeGeometryRequest(w, &request, &reply) ) {
X case XtGeometryYes:
X case XtGeometryNo:
X break;
X case XtGeometryAlmost:
X Layout(w, (request.height != reply.height),
X (request.width != reply.width),
X &(reply.width), &(reply.height));
X request = reply;
X switch (XtMakeGeometryRequest(w, &request, &reply) ) {
X case XtGeometryYes:
X case XtGeometryNo:
X break;
X case XtGeometryAlmost:
X request = reply;
X if (Layout(w, FALSE, FALSE,
X &(request.width), &(request.height))) {
X char buf[BUFSIZ];
X sprintf(buf, "XedwList Widget: %s %s",
X "Size Changed when it shouldn't have",
X "when computing layout");
X XtAppWarning(XtWidgetToApplicationContext(w), buf);
X }
X request.request_mode = CWWidth | CWHeight;
X XtMakeGeometryRequest(w, &request, &reply);
X break;
X default:
X XtAppWarning(XtWidgetToApplicationContext(w),
X "XedwList Widget: Unknown geometry return.");
X break;
X }
X break;
X default:
X XtAppWarning(XtWidgetToApplicationContext(w),
X "XedwList Widget: Unknown geometry return.");
X break;
X }
X}
X
X/* Function Name: Initialise
X * Description: Function that initilises the widget instance.
X * Arguments: junk - NOT USED.
X * new - the new widget.
X * Returns: none
X */
X
Xstatic void Initialize(Widget junk, Widget new)
X{
X XedwListWidget ilw = (XedwListWidget) new;
X
X/*
X * Initialize all private resources.
X */
X
X GetGCs(new);
X
X /* Set row height. */
X if (ilw->xedwList.show_icons)
X ilw->xedwList.row_height = ilw->xedwList.font->max_bounds.ascent
X + ilw->xedwList.font->max_bounds.descent
X + ilw->xedwList.row_space
X + ilw->xedwList.icon_height;
X else
X ilw->xedwList.row_height = ilw->xedwList.font->max_bounds.ascent
X + ilw->xedwList.font->max_bounds.descent
X + ilw->xedwList.row_space;
X
X ResetXedwList(new, (new->core.width == 0), (new->core.height == 0));
X
X ilw->xedwList.is_highlighted = (LinkedList*) XtMalloc (sizeof(LinkedList));
X
X ilw->xedwList.highlight = ilw->xedwList.is_highlighted->index = NO_HIGHLIGHT;
X ilw->xedwList.is_highlighted->next = NULL;
X
X} /* Initialize */
X
X/* Function Name: CvtToItem
X * Description: Converts Xcoord to item number of item containing that
X * point.
X * Arguments: w - the xedwList widget.
X * xloc, yloc - x location, and y location.
X * Returns: the item number.
X */
X
Xstatic int CvtToItem(Widget w, int xloc, int yloc, int *item)
X{
X int one, another;
X XedwListWidget ilw = (XedwListWidget) w;
X int ret_val = OKAY;
X
X if (ilw->xedwList.vertical_cols) {
X one = ilw->xedwList.nrows * ((xloc - (int) ilw->xedwList.internal_width)
X / ilw->xedwList.col_width);
X another = (yloc - (int) ilw->xedwList.internal_height)
X / ilw->xedwList.row_height;
X /* If out of range, return minimum possible value. */
X if (another >= ilw->xedwList.nrows) {
X another = ilw->xedwList.nrows - 1;
X ret_val = OUT_OF_RANGE;
X }
X }
X else {
X one = (ilw->xedwList.ncols * ((yloc - (int) ilw->xedwList.internal_height)
X / ilw->xedwList.row_height)) ;
X /* If in right margin handle things right. */
X another = (xloc - (int) ilw->xedwList.internal_width) / ilw->xedwList.col_width;
X if (another >= ilw->xedwList.ncols) {
X another = ilw->xedwList.ncols - 1;
X ret_val = OUT_OF_RANGE;
X }
X }
X if ((xloc < 0) || (yloc < 0))
X ret_val = OUT_OF_RANGE;
X if (one < 0) one = 0;
X if (another < 0) another = 0;
X *item = one + another;
X if (*item >= ilw->xedwList.nitems) return(OUT_OF_RANGE);
X return(ret_val);
X}
X
X/* Function Name: FindCornerItems.
X * Description: Find the corners of the rectangle in item space.
X * Arguments: w - the xedwList widget.
X * event - the event structure that has the rectangle it it.
X * ul_ret, lr_ret - the corners ** RETURNED **.
X * Returns: none.
X */
X
Xstatic int FindCornerItems(Widget w, XEvent *event, int *ul_ret, int *lr_ret)
X{
X int xloc, yloc;
X
X xloc = event->xexpose.x;
X yloc = event->xexpose.y;
X CvtToItem(w, xloc, yloc, ul_ret);
X xloc += event->xexpose.width;
X yloc += event->xexpose.height;
X CvtToItem(w, xloc, yloc, lr_ret);
X}
X
X/* Function Name: ItemInRectangle
X * Description: returns TRUE if the item passed is in the given rectangle.
X * Arguments: w - the xedwList widget.
X * ul, lr - corners of the rectangle in item space.
X * item - item to check.
X * Returns: TRUE if the item passed is in the given rectangle.
X */
X
Xstatic int ItemInRectangle(Widget w, int ul, int lr, int item)
X{
X XedwListWidget ilw = (XedwListWidget) w;
X register int mod_item;
X int things;
X
X if (item < ul || item > lr)
X return(FALSE);
X if (ilw->xedwList.vertical_cols)
X things = ilw->xedwList.nrows;
X else
X things = ilw->xedwList.ncols;
X
X mod_item = item % things;
X if ( (mod_item >= ul % things) && (mod_item <= lr % things ) )
X return(TRUE);
X return(FALSE);
X}
X
X/* Function Name: HighlightBackground
X * Description: paints the color of the background for the given item.
X * Arguments: w - the widget.
X * x, y - ul corner of the area item occupies.
X * item - the item we are dealing with.
X * gc - the gc that is used to paint this rectangle
X * Returns:
X */
X
Xstatic int HighlightBackground(Widget w, int x, int y, int item, GC gc)
X{
X XedwListWidget ilw = (XedwListWidget) w;
X int hl_x, hl_y, width, height;
X
X hl_x = x - ilw->xedwList.column_space/2;
X width = XTextWidth(ilw->xedwList.font, ilw->xedwList.xedwList[item]->string,
X strlen(ilw->xedwList.xedwList[item]->string))
X + ilw->xedwList.column_space;
X hl_y = y + ((ilw->xedwList.show_icons) ? ilw->xedwList.icon_height : 0);
X height = ilw->xedwList.row_height - ilw->xedwList.row_space -
X ((ilw->xedwList.show_icons) ? ilw->xedwList.icon_height : 0);
X
X XFillRectangle(XtDisplay(w), XtWindow(w), gc, hl_x, hl_y, width, height);
X}
X
X/* Function Name: PaintItemName
X * Description: paints the name of the item in the appropriate location.
X * Arguments: w - the xedwList widget.
X
X * item - the item to draw.
X * op - XedwOn, XedwOff
X * Returns: none.
X *
X * NOTE: no action taken on an unrealized widget.
X */
X
Xstatic int PaintItemName(Widget w, int item, int operation)
X{
X char * str;
X GC gc;
X unsigned normalmode, inversemode;
X int x, y, str_y, str_x;
X XedwListWidget ilw = (XedwListWidget) w;
X
X if (!XtIsRealized(w)) return; /* Just in case... */
X
X
X if (ilw->xedwList.vertical_cols) {
X x = ilw->xedwList.col_width * (item / ilw->xedwList.nrows)
X + ilw->xedwList.internal_width;
X y = ilw->xedwList.row_height * (item % ilw->xedwList.nrows)
X + ilw->xedwList.internal_height;
X }
X else {
X x = ilw->xedwList.col_width * (item % ilw->xedwList.ncols)
X + ilw->xedwList.internal_width;
X y = ilw->xedwList.row_height * (item / ilw->xedwList.ncols)
X + ilw->xedwList.internal_height;
X }
X
X
X str = ilw->xedwList.xedwList[item]->string;
X
X str_y = y + ilw->xedwList.font->max_bounds.ascent;
X
X if (ilw->xedwList.show_icons)
X str_x = x + ((ilw->xedwList.longest/2) -
X (XTextWidth(ilw->xedwList.font, str, strlen(str))/2));
X else
X str_x = x;
X
X if (DefaultDepthOfScreen(XtScreen(ilw)) == 1) {
X /* Monochrome */
X if ((BlackPixelOfScreen(XtScreen(ilw))) == 1) {
X normalmode = GXcopy;
X inversemode = GXcopyInverted;
X } else {
X normalmode = GXcopyInverted;
X inversemode = GXcopy;
X }
X } else {
X /* Colour */
X normalmode = GXcopy;
X inversemode = GXcopy;
X }
X
X if (ilw->xedwList.is_highlighted->index != NO_HIGHLIGHT) {
X /* There are some highlighted items */
X if (ilw->xedwList.highlight == NO_HIGHLIGHT) {
X /* This is an update */
X if (operation == XedwOn) {
X if (XtIsSensitive(w)) {
X /* Draw Inverse item */
X gc = ilw->xedwList.revgc;
X XSetFunction(XtDisplay(w), gc, inversemode);
X HighlightBackground(w, str_x, y, item, ilw->xedwList.normgc);
X } else {
X /* Draw Grey item */
X }
X } else {
X gc = ilw->xedwList.normgc;
X XSetFunction(XtDisplay(w), gc, normalmode); /* jcc */
X }
X } else {
X /* Were toggling something */
X if (operation == XedwOn) {
X if (XtIsSensitive(w)) {
X /* Draw Inverse item */
X gc = ilw->xedwList.revgc;
X XSetFunction(XtDisplay(w), gc, inversemode);
X HighlightBackground(w, str_x, y, item, ilw->xedwList.normgc);
X } else {
X /* Draw Grey item */
X }
X } else {
X /* Draw Normal item */
X gc = ilw->xedwList.normgc;
X XSetFunction(XtDisplay(ilw), gc, normalmode);
X HighlightBackground(w, str_x, y, item, ilw->xedwList.revgc);
X }
X }
X } else {
X gc = ilw->xedwList.normgc;
X XSetFunction(XtDisplay(ilw), gc, normalmode);
X }
X
X if (ilw->xedwList.default_icon == NULL)
X ilw->xedwList.default_icon =
X XCreateBitmapFromData(XtDisplay(ilw), XtWindow(ilw), default_bits,
X default_width, default_height);
X
X if (ilw->xedwList.show_icons){
X Pixmap icon;
X if (ilw->xedwList.xedwList[item]->icon == NULL &&
X ilw->xedwList.default_icon != NULL)
X icon = ilw->xedwList.default_icon;
X else
X icon = ilw->xedwList.xedwList[item]->icon;
X if (DefaultDepthOfScreen(XtScreen(ilw)) == 1)
X XCopyArea(XtDisplay(ilw), icon,
X XtWindow(ilw), gc, 0, 0,
X ilw->xedwList.icon_width, ilw->xedwList.icon_height, x +
X ((ilw->xedwList.longest/2) - (ilw->xedwList.icon_width/2)), y);
X else
X XCopyPlane(XtDisplay(ilw), icon,
X XtWindow(ilw), gc, 0,0,
X ilw->xedwList.icon_width,ilw->xedwList.icon_height,x +
X ((ilw->xedwList.longest/2) - (ilw->xedwList.icon_width/2)), y,1);
X /* Draw string */
X XSetFunction(XtDisplay(ilw), gc, GXcopy);
X XDrawString(XtDisplay(ilw), XtWindow(ilw), gc, str_x,
X str_y+ilw->xedwList.icon_height, str, strlen(str));
X } else { /* No Icons */
X XSetFunction(XtDisplay(ilw), gc, GXcopy);
X XDrawString(XtDisplay(ilw), XtWindow(ilw), gc, str_x, str_y, str, strlen(str));
X }
X}
X
X/* Function Name: Redisplay
X * Description: Repaints the widget window on expose events.
X * Arguments: w - the xedwList widget.
X * event - the expose event for this repaint.
X * junk - NOT USED.
X * Returns:
X */
X
Xstatic void Redisplay(Widget w, XEvent *event, Region junk)
X{
X int item; /* an item to work with. */
X int ul_item, lr_item; /* corners of items we need to paint. */
X XedwListWidget ilw = (XedwListWidget) w;
X
X if (event == NULL) { /* repaint all. */
X ul_item = 0;
X lr_item = ilw->xedwList.nrows * ilw->xedwList.ncols - 1;
X XClearWindow(XtDisplay(w), XtWindow(w));
X }
X else
X FindCornerItems(w, event, &ul_item, &lr_item);
X
X ilw->xedwList.highlight = NO_HIGHLIGHT;
X for (item = ul_item; (item <= lr_item && item < ilw->xedwList.nitems) ; item++)
X if (ItemInRectangle(w, ul_item, lr_item, item))
X if (IsHighlighted(w, item))
X PaintItemName(w, item, XedwOn);
X else
X PaintItemName(w, item, XedwOff);
X}
X
X/* Function Name: PreferredGeom
X * Description: This tells the parent what size we would like to be
X * given certain constraints.
X * Arguments: w - the widget.
X * intended - what the parent intends to do with us.
X * requested - what we want to happen.
X * Returns: none.
X */
X
Xstatic XtGeometryResult PreferredGeom(Widget w,
X XtWidgetGeometry *intended,
X XtWidgetGeometry *requested)
X{
X Dimension new_width, new_height;
X Boolean change, width_req, height_req;
X
X width_req = intended->request_mode & CWWidth;
X height_req = intended->request_mode & CWHeight;
X
X if (width_req)
X new_width = intended->width;
X else
X new_width = w->core.width;
X
X if (height_req)
X new_height = intended->height;
X else
X new_height = w->core.height;
X
X requested->request_mode = 0;
X
X /*
X * We only care about our height and width.
X */
X
X if ( !width_req && !height_req)
X return(XtGeometryYes);
X
X change = Layout(w, !width_req, !height_req, &new_width, &new_height);
X
X requested->request_mode |= CWWidth;
X requested->width = new_width;
X requested->request_mode |= CWHeight;
X requested->height = new_height;
X
X if (change)
X return(XtGeometryAlmost);
X return(XtGeometryYes);
X}
X
X/* Function Name: Resize
X * Description: resizes the widget, by changing the number of rows and
X * columns.
X * Arguments: w - the widget.
X * Returns: none.
X */
X
Xstatic void Resize(Widget w)
X{
X Dimension width, height;
X
X width = w->core.width;
X height = w->core.height;
X
X if (Layout(w, FALSE, FALSE, &width, &height))
X XtAppWarning(XtWidgetToApplicationContext(w),
X "XedwList Widget: Size changed when it shouldn't have when resising.");
X}
X
X/* Function Name: Layout
X * Description: lays out the item in the xedwList.
X * Arguments: w - the widget.
X * xfree, yfree - TRUE if we are free to resize the widget in
X * this direction.
X * width, height - the is the current width and height that
X * we are going to layout the xedwList widget to,
X * depending on xfree and yfree of course.
X *
X * Returns: TRUE if width or height have been changed.
X */
X
Xstatic Boolean Layout(Widget w, Boolean xfree, Boolean yfree,
X Dimension *width, Dimension *height)
X{
X XedwListWidget ilw = (XedwListWidget) w;
X Boolean change = FALSE;
X
X /*
X * If force columns is set then always use number of columns specified
X * by default_cols.
X */
X
X if (ilw->xedwList.force_cols) {
X ilw->xedwList.ncols = ilw->xedwList.default_cols;
X if (ilw->xedwList.ncols <= 0) ilw->xedwList.ncols = 1;
X /* 12/3 = 4 and 10/3 = 4, but 9/3 = 3 */
X ilw->xedwList.nrows = ( ( ilw->xedwList.nitems - 1) / ilw->xedwList.ncols) + 1 ;
X if (xfree) { /* If allowed resize width. */
X *width = ilw->xedwList.ncols * ilw->xedwList.col_width
X + 2 * ilw->xedwList.internal_width;
X change = TRUE;
X }
X if (yfree) { /* If allowed resize height. */
X *height = (ilw->xedwList.nrows * ilw->xedwList.row_height)
X + 2 * ilw->xedwList.internal_height;
X change = TRUE;
X }
X return(change);
X }
X
X /*
X * If both width and height are free to change the use default_cols
X * to determine the number columns and set new width and height to
X * just fit the window.
X */
X
X if (xfree && yfree) {
X ilw->xedwList.ncols = ilw->xedwList.default_cols;
X if (ilw->xedwList.ncols <= 0) ilw->xedwList.ncols = 1;
X ilw->xedwList.nrows = ( ( ilw->xedwList.nitems - 1) / ilw->xedwList.ncols) + 1 ;
X *width = ilw->xedwList.ncols * ilw->xedwList.col_width
X + 2 * ilw->xedwList.internal_width;
X *height = (ilw->xedwList.nrows * ilw->xedwList.row_height)
X + 2 * ilw->xedwList.internal_height;
X change = TRUE;
X }
X /*
X * If the width is fixed then use it to determine the number of columns.
X * If the height is free to move (width still fixed) then resize the height
X * of the widget to fit the current xedwList exactly.
X */
X else if (!xfree) {
X ilw->xedwList.ncols = ( (*width - 2 * ilw->xedwList.internal_width)
X / ilw->xedwList.col_width);
X if (ilw->xedwList.ncols <= 0) ilw->xedwList.ncols = 1;
X ilw->xedwList.nrows = ( ( ilw->xedwList.nitems - 1) / ilw->xedwList.ncols) + 1 ;
X if ( yfree ) {
X *height = (ilw->xedwList.nrows * ilw->xedwList.row_height)
X + 2 * ilw->xedwList.internal_height;
X change = TRUE;
X }
X }
X /*
X * The last case is xfree and !yfree we use the height to determine
X * the number of rows and then set the width to just fit the resulting
X * number of columns.
X */
X else if (!yfree) { /* xfree must be TRUE. */
X ilw->xedwList.nrows = (*height - 2 * ilw->xedwList.internal_height)
X / ilw->xedwList.row_height;
X if (ilw->xedwList.nrows <= 0) ilw->xedwList.nrows = 1;
X ilw->xedwList.ncols = (( ilw->xedwList.nitems - 1 ) / ilw->xedwList.nrows) + 1;
X *width = ilw->xedwList.ncols * ilw->xedwList.col_width
X + 2 * ilw->xedwList.internal_width;
X change = TRUE;
X }
X return(change);
X}
X
X/* Function Name: Notify
X * Description: Notifies the user that a button has been pressed, and
X * calles the callback, if the XtNpasteBuffer resource
X * is true then the name of the item is also put in the
X * X cut buffer ( buf (0) ).
X * Arguments: w - the widget that the notify occured in.
X * event - event that caused this notification.
X * params, num_params - not used.
X * Returns: none.
X */
X
Xstatic void Notify(Widget w, XEvent *event, String *params,
X Cardinal *num_params)
X{
X XedwListWidget ilw = ( XedwListWidget ) w;
X LinkedList *list = ilw->xedwList.is_highlighted;
X int item, item_len;
X XedwListReturnStruct ret_value;
X
X if ( ((CvtToItem(w, event->xbutton.x, event->xbutton.y, &item))
X == OUT_OF_RANGE) || (ilw->xedwList.highlight != item) ) {
X XedwListUnhighlight(w, ilw->xedwList.highlight);
X RemoveNode(w, ilw->xedwList.highlight);
X XtCallCallbacks(w, XtNcallback, (caddr_t) 0);
X return;
X }
X
X /* Put the name of ALL highlighted strings into the X cut buffer,
X * seperated by spaces.
X
X item_len = 0;
X while(list != NULL) {
X item_len += strlen(ilw->xedwList.xedwList[list.index]->string) + 1;
X list=list->next;
X }
X
X */
X
X item_len = strlen(ilw->xedwList.xedwList[item]->string);
X
X if ( ilw->xedwList.paste ) /* if XtNpasteBuffer set then paste it. */
X XStoreBytes(XtDisplay(w), ilw->xedwList.xedwList[item]->string, item_len);
X
X /*
X * Call Callback function.
X */
X
X ret_value.string = ilw->xedwList.xedwList[item]->string;
X ret_value.xedwList_index = item;
X ret_value.next = NULL;
X
X XtCallCallbacks( w, XtNcallback, (caddr_t) &ret_value);
X}
X
X/* Function Name: Unset
X * Description: unhighlights the current elements.
X * Arguments: w - the widget that the event occured in.
X * event - not used.
X * params, num_params - not used.
X * Returns: none.
X */
X
Xstatic void Unset(Widget w, XEvent *event, String *params,
X Cardinal *num_params)
X{
X XedwListUnhighlight(w, XedwAll);
X}
X
X/* Function Name: Set
X * Description: Highlights the current element.
X * Arguments: w - the widget that the event occured in.
X * event - event that caused this notification.
X * params, num_params - not used.
X * Returns: none.
X */
X
Xstatic void Set(Widget w, XEvent *event, String *params,
X Cardinal *num_params)
X{
X int item;
X XedwListWidget ilw = (XedwListWidget) w;
X
X if ( (CvtToItem(w, event->xbutton.x, event->xbutton.y, &item))
X == OUT_OF_RANGE)
X XedwListUnhighlight(w, XedwAll); /* Unhighlight current items. */
X else {
X if (ilw->xedwList.highlight != item ||
X ilw->xedwList.is_highlighted->next != NULL)
X XedwListUnhighlight(w, XedwAll); /* Unhighlight any others */
X XedwListHighlight(w, item); /* highlight it */
X }
X}
X
X/* Function Name: MultipleSet
X * Description: Highlights the current element.
X * Arguments: w - the widget that the event occured in.
X * event - event that caused this notification.
X * params, num_params - not used.
X * Returns: none.
X */
X
Xstatic void MultipleSet(Widget w, XEvent *event, String *params,
X Cardinal *num_params)
X{
X int item;
X XedwListWidget ilw = (XedwListWidget) w;
X
X if (ilw->xedwList.multiple == True)
X if ( (CvtToItem(w, event->xbutton.x, event->xbutton.y, &item))
X == OUT_OF_RANGE)
X XedwListUnhighlight(w, XedwAll); /* Unhighlight all current items. */
X else
X if (IsHighlighted(w, item)) /* If already highlighted, */
X XedwListUnhighlight(w, item); /* unhighlight it */
X else
X XedwListHighlight(w, item); /* otherwise highlight it */
X else
X XBell(XtDisplay(w), 100);
X}
X
X/*
X * Return state of a list item
X */
Xstatic Boolean IsHighlighted(Widget w, int item)
X{
X XedwListWidget ilw = (XedwListWidget) w;
X LinkedList *list = ilw->xedwList.is_highlighted;
X Boolean ret_val;
X
X while (list != NULL && list->index != item && list->index != NO_HIGHLIGHT)
X list = list->next;
X
X if (list == NULL || list->index == NO_HIGHLIGHT)
X ret_val=FALSE;
X else
X ret_val=TRUE;
X
X return(ret_val); /* true if item was in list false otherwise */
X}
X
X/*
X * Set specified arguments into widget
X */
X
Xstatic Boolean SetValues(Widget current,
X Widget request,
X Widget new)
X{
X XedwListWidget cl = (XedwListWidget) current;
X XedwListWidget rl = (XedwListWidget) request;
X XedwListWidget nl = (XedwListWidget) new;
X Boolean redraw = FALSE;
X
X if ((cl->xedwList.foreground != rl->xedwList.foreground) ||
X (cl->core.background_pixel != rl->core.background_pixel) ||
X (cl->xedwList.font != rl->xedwList.font) ) {
X XtDestroyGC(cl->xedwList.normgc);
X XtDestroyGC(cl->xedwList.graygc);
X XtDestroyGC(cl->xedwList.revgc);
X GetGCs(new);
X redraw = TRUE;
X }
X
X /* Reset row height. */
X
X if ((cl->xedwList.row_space != rl->xedwList.row_space) ||
X (cl->xedwList.font != rl->xedwList.font) ||
X (cl->xedwList.show_icons != rl->xedwList.show_icons) ||
X (cl->xedwList.icon_width != rl->xedwList.icon_width) ||
X (cl->xedwList.icon_height != rl->xedwList.icon_height))
X if (rl->xedwList.show_icons)
X nl->xedwList.row_height = nl->xedwList.font->max_bounds.ascent
X + nl->xedwList.font->max_bounds.descent
X + nl->xedwList.row_space
X + nl->xedwList.icon_height;
X else
X nl->xedwList.row_height = nl->xedwList.font->max_bounds.ascent
X + nl->xedwList.font->max_bounds.descent
X + nl->xedwList.row_space;
X
X if ((cl->core.width != rl->core.width) ||
X (cl->core.height != rl->core.height) ||
X (cl->xedwList.internal_width != rl->xedwList.internal_width) ||
X (cl->xedwList.internal_height != rl->xedwList.internal_height) ||
X (cl->xedwList.column_space != rl->xedwList.column_space) ||
X (cl->xedwList.row_space != rl->xedwList.row_space) ||
X (cl->xedwList.default_cols != rl->xedwList.default_cols) ||
X ((cl->xedwList.force_cols != rl->xedwList.force_cols) &&
X (rl->xedwList.force_cols != rl->xedwList.ncols)) ||
X (cl->xedwList.vertical_cols != rl->xedwList.vertical_cols) ||
X (cl->xedwList.longest != rl->xedwList.longest) ||
X (cl->xedwList.nitems != rl->xedwList.nitems) ||
X (cl->xedwList.font != rl->xedwList.font) ||
X (cl->xedwList.show_icons != rl->xedwList.show_icons) ||
X (cl->xedwList.icon_width != rl->xedwList.icon_width) ||
X (cl->xedwList.icon_height != rl->xedwList.icon_height) ||
X (cl->xedwList.default_icon != rl->xedwList.default_icon) ||
X (cl->xedwList.xedwList != rl->xedwList.xedwList) ) {
X
X ResetXedwList(new, TRUE, TRUE);
X redraw = TRUE;
X }
X
X if (cl->xedwList.xedwList != rl->xedwList.xedwList)
X nl->xedwList.highlight = NO_HIGHLIGHT;
X
X if ((cl->core.sensitive != rl->core.sensitive) ||
X (cl->core.ancestor_sensitive != rl->core.ancestor_sensitive)) {
X nl->xedwList.highlight = NO_HIGHLIGHT;
X redraw = TRUE;
X }
X
X if (!XtIsRealized(current))
X return(FALSE);
X
X return(redraw);
X}
X
X/* Exported Functions */
X
X/* Function Name: XedwListChange.
X * Description: Changes the xedwList being used and shown.
X * Arguments: w - the xedwList widget.
X * xedwList - the new xedwList.
X * nitems - the number of items in the xedwList.
X * longest - the length (in Pixels) of the longest element
X * in the xedwList.
X * resize - if TRUE the the xedwList widget will
X * try to resize itself.
X * Returns: none.
X * NOTE: If nitems of longest are <= 0 then they will be calculated.
X * If nitems is <= 0 then the xedwList needs to be NULL terminated.
X */
X
Xvoid XedwListChange(Widget w, XedwList **xedwList,
X int nitems, int longest, Boolean resize_it)
X{
X XedwListWidget ilw = (XedwListWidget) w;
X
X ilw->xedwList.xedwList = xedwList;
X
X if (nitems <= 0) nitems = 0;
X ilw->xedwList.nitems = nitems;
X if (longest <= 0) longest = 0;
X ilw->xedwList.longest = longest;
X
X ResetXedwList(w, resize_it, resize_it);
X /* Free the memeory in the old list TODO */
X ilw->xedwList.is_highlighted->index = ilw->xedwList.highlight = NO_HIGHLIGHT;
X ilw->xedwList.is_highlighted->next = NULL;
X if ( XtIsRealized(w) )
X Redisplay(w, NULL, NULL);
X}
X
X/* Function Name: XedwListUnhighlight
X * Description: unlights the current highlighted element.
X * Arguments: w - the widget.
X * Returns: none.
X */
X
Xvoid XedwListUnhighlight(Widget w, int item)
X{
X XedwListWidget ilw = ( XedwListWidget ) w;
X LinkedList *list = ilw->xedwList.is_highlighted;
X LinkedList *temp;
X
X if (ilw->xedwList.is_highlighted->index != NO_HIGHLIGHT)
X if (item == XedwAll) {
X ilw->xedwList.highlight = list->index;
X PaintItemName(w, list->index, XedwOff); /* unhighlight ALL */
X while (list->next != NULL) {
X temp = list;
X list = list->next;
X ilw->xedwList.highlight = list->index;
X PaintItemName(w, list->index, XedwOff);
X XtFree(temp);
X }
X list->index = NO_HIGHLIGHT;
X ilw->xedwList.is_highlighted = list;
X } else {
X ilw->xedwList.highlight = item;
X PaintItemName(w, item, XedwOff);
X RemoveNode(w, item);
X }
X}
X
X/* Function Name: XedwListHighlight
X * Description: Highlights the given item.
X * Arguments: w - the xedwList widget.
X * item - the item to hightlight.
X * Returns: none.
X */
X
Xvoid XedwListHighlight(Widget w, int item)
X{
X XedwListWidget ilw = ( XedwListWidget ) w;
X int n;
X
X if (XtIsSensitive(w)) {
X if (item == XedwAll) {
X for(n=0; n < ilw->xedwList.nitems; n++) {
X ilw->xedwList.highlight = n;
X RemoveNode(w, n);
X AddNode(w, n);
X PaintItemName(w, n, XedwOn);
X }
X } else {
X ilw->xedwList.highlight = item;
X RemoveNode(w, item);
X AddNode(w, item);
X PaintItemName(w, item, XedwOn);
X }
X }
X}
X
X/* Function Name: XedwListShowCurrent
X * Description: returns the currently highlighted object.
X * Arguments: w - the xedwList widget.
X * Returns: the info about the currently highlighted object.
X */
X
XXedwListReturnStruct *XedwListShowCurrent(Widget w)
X{
X XedwListWidget ilw = ( XedwListWidget ) w;
X LinkedList *hl = ilw->xedwList.is_highlighted;
X XedwListReturnStruct *ret_val, *rest;
X
X rest = NULL;
X while (hl != NULL) {
X ret_val = (XedwListReturnStruct *) XtMalloc (sizeof (XedwListReturnStruct));
X
X ret_val->xedwList_index = hl->index;
X if (ret_val->xedwList_index == XDTM_LIST_NONE)
X ret_val->string = "";
X else
X ret_val->string =
X XtNewString(ilw->xedwList.xedwList[ret_val->xedwList_index]->string);
X hl = hl->next;
X ret_val->next = rest;
X rest = ret_val;
X }
X return(ret_val);
X}
X
XBoolean XedwListSelection(Widget w)
X{
X XedwListWidget ilw = ( XedwListWidget ) w;
X LinkedList *hl = ilw->xedwList.is_highlighted;
X Boolean ret_val = True;
X
X if (hl->index == NO_HIGHLIGHT)
X ret_val = False;
X
X return(ret_val);
X}
X
X/* AddNode to LinkedList of highlighted items
X */
Xstatic void AddNode(Widget w, int item)
X{
X XedwListWidget ilw = ( XedwListWidget ) w;
X LinkedList *list = ilw->xedwList.is_highlighted;
X LinkedList *temp;
X
X if (list->index != NO_HIGHLIGHT) {
X temp = (LinkedList*) XtMalloc (sizeof(LinkedList));
X temp->index = item;
X temp->next = list;
X ilw->xedwList.is_highlighted = temp;
X } else {
X list->index = item; /* jcc */
X list->next = NULL;
X }
X}
X
X
Xstatic void RemoveNode(Widget w, int item)
X{
X XedwListWidget ilw = ( XedwListWidget ) w;
X LinkedList *list = ilw->xedwList.is_highlighted;
X LinkedList *last;
X
X last = list;
X while (list != NULL && list->index != item) {
X last = list;
X list=list->next;
X }
X if (list != NULL) { /* item WAS found */
X if (last == list) { /* it was the first item */
X if (list->next == NULL) /* there are no more in the list */
X list->index = NO_HIGHLIGHT;
X else {
X ilw->xedwList.is_highlighted = list->next;
X XtFree(list);
X }
X } else {
X last->next = list->next;
X XtFree(list);
X }
X }
X}
SHAR_EOF
chmod 0644 xdtm/Xedw/XedwList.c ||
echo 'restore of xdtm/Xedw/XedwList.c failed'
Wc_c="`wc -c < 'xdtm/Xedw/XedwList.c'`"
test 38223 -eq "$Wc_c" ||
echo 'xdtm/Xedw/XedwList.c: original size 38223, current size' "$Wc_c"
fi
# ============= xdtm/Xedw/XedwList.h ==============
if test -f 'xdtm/Xedw/XedwList.h' -a X"$1" != X"-c"; then
echo 'x - skipping xdtm/Xedw/XedwList.h (File already exists)'
else
echo 'x - extracting xdtm/Xedw/XedwList.h (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'xdtm/Xedw/XedwList.h' &&
X/*
X * Copyright 1989 Massachusetts Institute of Technology
X *
X * Permission to use, copy, modify, distribute, and sell this software and its
X * documentation for any purpose is hereby granted without fee, provided that
X * the above copyright notice appear in all copies and that both that
X * copyright notice and this permission notice appear in supporting
X * documentation, and that the name of M.I.T. not be used in advertising or
X * publicity pertaining to distribution of the software without specific,
X * written prior permission. M.I.T. makes no representations about the
X * suitability of this software for any purpose. It is provided "as is"
X * without express or implied warranty.
X *
X * M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
X * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
X * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
X * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
X * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
X */
X
X/*
X * XedwList.h - XedwList widget
X *
X * This is the XedwList widget. It is very similar to the Athena Widget List,
X * except it has the ability to display an icon with the string.
X * It allows the user to select an item in a xedwList and notifies the
X * application through a callback function.
X *
X * List Created: 8/13/88
X * By: Chris D. Peterson
X * MIT X Consortium
X *
X * Modified to XedwList: 1/26/90
X * By: Edward Groenendaal
X * University of Sussex, UK.
X */
X
X#ifndef _XawXedwList_h
X#define _XawXedwList_h
X
X/***********************************************************************
X *
X * XedwList Widget
X *
X ***********************************************************************/
X
X#include <X11/Xaw/Simple.h>
X
X/* Resources:
X
X Name Class RepType Default Value
X ---- ----- ------- -------------
X background Background Pixel XtDefaultBackground
X border BorderColor Pixel XtDefaultForeground
X borderWidth BorderWidth Dimension 1
X callback Callback XtCallbackXedwList NULL **6
X columnSpacing Spacing Dimension 6
X cursor Cursor Cursor left_ptr
X defaultColumns Columns int 2 **5
X destroyCallback Callback Pointer NULL
X font Font XFontStruct* XtDefaultFont
X forceColumns Columns Boolean False **5
X foreground Foreground Pixel XtDefaultForeground
X height Height Dimension 0 **1
X insensitiveBorder Insensitive Pixmap Gray
X internalHeight Height Dimension 2
X internalWidth Width Dimension 4
X xedwList XedwList XedwList ** NULL **2
X iconWidth Width Dimension 32
X iconHeight Height Dimension 32
X longest Longest int 0 **3 **4
X mappedWhenManaged MappedWhenManaged Boolean True
X mSelections Boolean Boolean False
X numberStrings NumberStrings int 0 **4
X pasteBuffer Boolean Boolean False
X rowSpacing Spacing Dimension 4
X sensitive Sensitive Boolean True
X showIcons Boolean Boolean False
X verticalList Boolean Boolean False
X width Width Dimension 0 **1
X x Position Position 0
X y Position Position 0
X
X **1 - If the Width or Height of the xedwList widget is zero (0) then the value
X is set to the minimum size necessay to fit the entire list.
X
X If both Width and Height are zero then they are adjusted to fit the
X entire list that is created width the number of default columns
X specified in the defaultColumns resource.
X
X **2 - This is an array of strings the specify elements of the xedwList.
X This resource must be specified.
X
X **3 - Longest is the length of the widest string in pixels.
X
X **4 - If either of these values are zero (0) then the xedwList widget calculates
X the correct value.
X
X (This allows you to make startup faster if you already have
X this information calculated)
X
X NOTE: If the numberStrings value is zero the xedwList must
X be NULL terminated.
X
X **5 - By setting the XedwList.Columns resource you can force the application to
X have a given number of columns.
X
X **6 - This returns the name and index of the item selected in an
X XedwListReturnStruct that is pointed to by the client_data
X in the CallbackProc.
X
X*/
X
X
X/*
X * Value returned when there are no highlighted objects.
X */
X
X#define XDTM_LIST_NONE -1
X
X#define XtCXedwList "XedwList"
X#define XtCSpacing "Spacing"
X#define XtCColumns "Columns"
X#define XtCLongest "Longest"
X#define XtCNumberStrings "NumberStrings"
X
X#define XtNcursor "cursor"
X#define XtNcolumnSpacing "columnSpacing"
X#define XtNdefaultColumns "defaultColumns"
X#define XtNforceColumns "forceColumns"
X#define XtNxedwList "xedwList"
X#define XtNiconWidth "iconWidth"
X#define XtNiconHeight "iconHeight"
X#define XtNdefaultIcon "defaultIcon"
X#define XtNlongest "longest"
X#define XtNnumberStrings "numberStrings"
X#define XtNpasteBuffer "pasteBuffer"
X#define XtNrowSpacing "rowSpacing"
X#define XtNshowIcons "showIcons"
X#define XtNmSelections "mSelections"
X#define XtNverticalList "verticalList"
X
X#define XedwSingle 1
X#define XedwMultiple 2
X
X#define XedwAll -1
X
X#define IconBitmapWidth 32
X#define IconBitmapHeight 32
X
X/* Class record constants */
X
Xextern WidgetClass xedwListWidgetClass;
X
Xtypedef struct _XedwListClassRec *XedwListWidgetClass;
Xtypedef struct _XedwListRec *XedwListWidget;
X
X/* The structure of XedwList */
X
Xtypedef struct _XedwList {
X String string;
X Pixmap icon;
X} XedwList;
X
X/* The xedwList return structure. */
X
Xtypedef struct _XedwListReturnStruct {
X String string; /* String */
X int xedwList_index; /* Index into list */
X struct _XedwListReturnStruct *next; /* Next highlighted entry */
X} XedwListReturnStruct;
X
X/******************************************************************
X *
X * Exported Functions
X *
X *****************************************************************/
X
X/* Function Name: XedwListChange.
X * Description: Changes the xedwList being used and shown.
X * Arguments: w - the xedwList widget.
X * xedwList - the new xedwList.
X * nitems - the number of items in the xedwList.
X * longest - the length (in Pixels) of the longest element
X * in the xedwList.
X * resize - if TRUE the the xedwList widget will
X * try to resize itself.
X * Returns: none.
X * NOTE: If nitems of longest are <= 0 then they will be caluculated.
X * If nitems is <= 0 then the xedwList needs to be NULL terminated.
X */
X
Xextern void XedwListChange(Widget, XedwList**,int,int,Boolean);
X
X/* Function Name: XedwListUnhighlight
X * Description: unlights the current highlighted element.
X * Arguments: w - the widget.
X * Returns: none.
X */
X
Xextern void XedwListUnhighlight(Widget, int);
X
X/* Function Name: XedwListHighlight
X * Description: Highlights the given item.
X * Arguments: w - the xedwList widget.
X * item - the item to hightlight.
X * Returns: none.
X */
X
Xextern void XedwListHighlight(Widget, int);
X
X
X/* Function Name: XedwListShowCurrent
X * Description: returns the currently highlighted objects.
X * Arguments: w - the xedwList widget.
X * Returns: the info about the currently highlighted object.
X */
X
Xextern XedwListReturnStruct *XedwListShowCurrent(Widget);
X
Xextern Boolean XedwListSelection(Widget);
X
X#endif /* _XedwList_h */
X
SHAR_EOF
chmod 0644 xdtm/Xedw/XedwList.h ||
echo 'restore of xdtm/Xedw/XedwList.h failed'
Wc_c="`wc -c < 'xdtm/Xedw/XedwList.h'`"
test 8356 -eq "$Wc_c" ||
echo 'xdtm/Xedw/XedwList.h: original size 8356, current size' "$Wc_c"
fi
true || echo 'restore of xdtm/Xedw/XedwListP.h failed'
echo End of part 3, continue with part 4
exit 0
--
Dan Heller
O'Reilly && Associates Z-Code Software Comp-sources-x:
Senior Writer President comp-sources-x@uunet.uu.net
argv@ora.com argv@zipcode.com