#endif
/*
* Copyright 1989 Massachusetts Institute of Technology
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of M.I.T. not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. M.I.T. makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
* BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
/*
* List.c - List widget
*
* This is the List widget, it is useful to display a list, without the
* overhead of having a widget for each item in the list. It allows
* the user to select an item in a list and notifies the application through
* a callback function.
*
* Created: 8/13/88
* By: Chris D. Peterson
* MIT X Consortium
*/
#include <stdio.h>
#include <ctype.h>
#include <X11/IntrinsicP.h>
#include <X11/StringDefs.h>
#include <./Xaw3_1XawInit.h>
#include <./Xaw3_1ListP.h>
/*
* Default Translation table.
*/
static char defaultTranslations[] =
"<Btn1Down>: Set()\n\
<Btn1Up>: Notify()";
/****************************************************************
*
* Full class record constant
*
****************************************************************/
/* Private Data */
};
static void Initialize();
static void ChangeSize();
static void Resize();
static void Redisplay();
static XtGeometryResult PreferredGeom();
{"Notify", Notify},
{"Set", Set},
{"Unset", Unset},
};
{
/* core_class fields */
/* class_name */ "List",
/* widget_size */ sizeof(ListRec),
/* class_initialize */ XawInitializeWidgetSet,
/* class_part_initialize */ NULL,
/* class_inited */ FALSE,
/* initialize */ Initialize,
/* initialize_hook */ NULL,
/* realize */ XtInheritRealize,
/* actions */ actions,
/* resources */ resources,
/* xrm_class */ NULLQUARK,
/* compress_motion */ TRUE,
/* compress_exposure */ FALSE,
/* compress_enterleave */ TRUE,
/* visible_interest */ FALSE,
/* destroy */ NULL,
/* resize */ Resize,
/* expose */ Redisplay,
/* set_values */ SetValues,
/* set_values_hook */ NULL,
/* set_values_almost */ XtInheritSetValuesAlmost,
/* get_values_hook */ NULL,
/* accept_focus */ NULL,
/* version */ XtVersion,
/* callback_private */ NULL,
/* tm_table */ defaultTranslations,
/* query_geometry */ PreferredGeom,
},
/* Simple class fields initialization */
{
/* change_sensitive */ XtInheritChangeSensitive
}
};
/****************************************************************
*
* Private Procedures
*
****************************************************************/
static void GetGCs(w)
Widget w;
{
&values);
&values);
&values);
}
/* Function Name: ResetList
* Description: Resets the new list when important things change.
* Arguments: w - the widget.
* changex, changey - allow the height or width to change?
* Returns: none.
*/
static void
Widget w;
{
register int i, len;
/*
* If list is NULL then the list will just be the name of the widget.
*/
}
}
}
/* Function Name: ChangeSize.
* Description: Laysout the widget.
* Arguments: w - the widget to try change the size of.
* Returns: none.
*/
static void
Widget w;
{
case XtGeometryYes:
case XtGeometryNo:
break;
case XtGeometryAlmost:
case XtGeometryYes:
case XtGeometryNo:
break;
case XtGeometryAlmost:
"Size Changed when it shouldn't have",
"when computing layout");
}
break;
default:
"List Widget: Unknown geometry return.");
break;
}
break;
default:
"List Widget: Unknown geometry return.");
break;
}
}
/* Function Name: Initialize
* Description: Function that initilizes the widget instance.
* Arguments: junk - NOT USED.
* new - the new widget.
* Returns: none
*/
/* ARGSUSED */
static void
{
/*
* Initialize all private resources.
*/
/* Set row height. */
} /* Initialize */
/* Function Name: CvtToItem
* Description: Converts Xcoord to item number of item containing that
* point.
* Arguments: w - the list widget.
* xloc, yloc - x location, and y location.
* Returns: the item number.
*/
static int
Widget w;
int *item;
{
/* If out of range, return minimum possible value. */
}
}
else {
/* If in right margin handle things right. */
}
}
return(ret_val);
}
/* Function Name: FindCornerItems.
* Description: Find the corners of the rectangle in item space.
* Arguments: w - the list widget.
* event - the event structure that has the rectangle it it.
* ul_ret, lr_ret - the corners ** RETURNED **.
* Returns: none.
*/
Widget w;
{
}
/* Function Name: ItemInRectangle
* Description: returns TRUE if the item passed is in the given rectangle.
* Arguments: w - the list widget.
* ul, lr - corners of the rectangle in item space.
* item - item to check.
* Returns: TRUE if the item passed is in the given rectangle.
*/
Widget w;
{
register int mod_item;
int things;
return(FALSE);
else
return(TRUE);
return(FALSE);
}
/* Function Name: HighlightBackground
* Description: paints the color of the background for the given item.
* Arguments: w - the widget.
* x, y - ul corner of the area item occupies.
* item - the item we are dealing with.
* gc - the gc that is used to paint this rectangle
* Returns:
*/
Widget w;
int x, y, item;
{
}
/* Function Name: PaintItemName
* Description: paints the name of the item in the appropriate location.
* Arguments: w - the list widget.
* item - the item to draw.
* Returns: none.
*
* NOTE: no action taken on an unrealized widget.
*/
void
Widget w;
int item;
{
char * str;
int x, y, str_y;
if (!XtIsRealized(w)) return; /* Just in case... */
}
else {
}
}
else {
if (XtIsSensitive(w))
else
}
}
else {
}
else {
if (XtIsSensitive(w))
else
}
}
}
/* Function Name: Redisplay
* Description: Repaints the widget window on expose events.
* Arguments: w - the list widget.
* event - the expose event for this repaint.
* junk - NOT USED.
* Returns:
*/
/* ARGSUSED */
static void
Widget w;
{
ul_item = 0;
}
else
PaintItemName(w, item);
}
/* Function Name: PreferredGeom
* Description: This tells the parent what size we would like to be
* given certain constraints.
* Arguments: w - the widget.
* intended - what the parent intends to do with us.
* requested - what we want to happen.
* Returns: none.
*/
static XtGeometryResult
Widget w;
{
if (width_req)
else
if (height_req)
else
requested->request_mode = 0;
/*
* We only care about our height and width.
*/
if ( !width_req && !height_req)
return(XtGeometryYes);
if (change)
return(XtGeometryAlmost);
return(XtGeometryYes);
}
/* Function Name: Resize
* Description: resizes the widget, by changing the number of rows and
* columns.
* Arguments: w - the widget.
* Returns: none.
*/
static void
Resize(w)
Widget w;
{
"List Widget: Size changed when it shouldn't have when resising.");
}
/* Function Name: Layout
* Description: lays out the item in the list.
* Arguments: w - the widget.
* xfree, yfree - TRUE if we are free to resize the widget in
* this direction.
* width, height - the is the current width and height that
* we are going to layout the list widget to,
* depending on xfree and yfree of course.
*
* Returns: TRUE if width or height have been changed.
*/
static Boolean
Widget w;
{
/*
* If force columns is set then always use number of columns specified
* by default_cols.
*/
/* 12/3 = 4 and 10/3 = 4, but 9/3 = 3 */
if (xfree) { /* If allowed resize width. */
}
if (yfree) { /* If allowed resize height. */
}
return(change);
}
/*
* If both width and height are free to change the use default_cols
* to determine the number columns and set new width and height to
* just fit the window.
*/
}
/*
* If the width is fixed then use it to determine the number of columns.
* If the height is free to move (width still fixed) then resize the height
* of the widget to fit the current list exactly.
*/
else if (!xfree) {
if ( yfree ) {
}
}
/*
* The last case is xfree and !yfree we use the height to determine
* the number of rows and then set the width to just fit the resulting
* number of columns.
*/
else if (!yfree) { /* xfree must be TRUE. */
}
return(change);
}
/* Function Name: Notify
* Description: Notifies the user that a button has been pressed, and
* calles the callback, if the XtNpasteBuffer resource
* is true then the name of the item is also put in the
* X cut buffer ( buf (0) ).
* Arguments: w - the widget that the notify occured in.
* event - event that caused this notification.
* params, num_params - not used.
* Returns: none.
*/
/* ARGSUSED */
static void
Widget w;
{
/*
* Find item and if out of range then unhighlight and return.
*
* If the current item is unhighlighted then the user has aborted the
* notify, so unhighlight and return.
*/
return;
}
/*
* Call Callback function.
*/
}
/* Function Name: Unset
* Description: unhighlights the current element.
* Arguments: w - the widget that the event occured in.
* event - not used.
* params, num_params - not used.
* Returns: none.
*/
/* ARGSUSED */
static void
Widget w;
{
}
/* Function Name: Set
* Description: Highlights the current element.
* Arguments: w - the widget that the event occured in.
* event - event that caused this notification.
* params, num_params - not used.
* Returns: none.
*/
/* ARGSUSED */
static void
Widget w;
{
int item;
== OUT_OF_RANGE)
XawListUnhighlight(w); /* Unhighlight current item. */
}
/*
* Set specified arguments into widget
*/
static Boolean
{
}
/* Reset row height. */
}
}
if (!XtIsRealized(current))
return(FALSE);
return(redraw);
}
/* Exported Functions */
/* Function Name: XawListChange.
* Description: Changes the list being used and shown.
* Arguments: w - the list widget.
* list - the new list.
* nitems - the number of items in the list.
* longest - the length (in Pixels) of the longest element
* in the list.
* resize - if TRUE the the list widget will
* try to resize itself.
* Returns: none.
* NOTE: If nitems of longest are <= 0 then they will be calculated.
* If nitems is <= 0 then the list needs to be NULL terminated.
*/
void
Widget w;
char ** list;
{
if ( XtIsRealized(w) )
}
/* Function Name: XawListUnhighlight
* Description: unlights the current highlighted element.
* Arguments: w - the widget.
* Returns: none.
*/
void
Widget w;
{
}
/* Function Name: XawListHighlight
* Description: Highlights the given item.
* Arguments: w - the list widget.
* item - the item to hightlight.
* Returns: none.
*/
void
Widget w;
int item;
{
if (XtIsSensitive(w)) {
}
}
/* Function Name: XawListShowCurrent
* Description: returns the currently highlighted object.
* Arguments: w - the list widget.
* Returns: the info about the currently highlighted object.
*/
Widget w;
{
else
return(ret_val);
}