diff options
Diffstat (limited to 'vendor/x11iraf/obm/ObmW/zz')
-rw-r--r-- | vendor/x11iraf/obm/ObmW/zz/Separator.c | 357 | ||||
-rw-r--r-- | vendor/x11iraf/obm/ObmW/zz/Separator.h | 99 | ||||
-rw-r--r-- | vendor/x11iraf/obm/ObmW/zz/SeparatorP.h | 60 | ||||
-rw-r--r-- | vendor/x11iraf/obm/ObmW/zz/Simple.c | 489 | ||||
-rw-r--r-- | vendor/x11iraf/obm/ObmW/zz/Simple.h | 96 | ||||
-rw-r--r-- | vendor/x11iraf/obm/ObmW/zz/SimpleMenP.h | 113 | ||||
-rw-r--r-- | vendor/x11iraf/obm/ObmW/zz/SimpleMenu.c | 1467 | ||||
-rw-r--r-- | vendor/x11iraf/obm/ObmW/zz/SimpleMenu.h | 169 | ||||
-rw-r--r-- | vendor/x11iraf/obm/ObmW/zz/SimpleP.h | 62 | ||||
-rw-r--r-- | vendor/x11iraf/obm/ObmW/zz/Table.c | 4529 | ||||
-rw-r--r-- | vendor/x11iraf/obm/ObmW/zz/Table.h | 539 | ||||
-rw-r--r-- | vendor/x11iraf/obm/ObmW/zz/Table3d.c | 924 | ||||
-rw-r--r-- | vendor/x11iraf/obm/ObmW/zz/Table3d.h | 145 | ||||
-rw-r--r-- | vendor/x11iraf/obm/ObmW/zz/TableP.h | 166 | ||||
-rw-r--r-- | vendor/x11iraf/obm/ObmW/zz/TableUtil.c | 918 | ||||
-rw-r--r-- | vendor/x11iraf/obm/ObmW/zz/TableUtil.h | 94 | ||||
-rw-r--r-- | vendor/x11iraf/obm/ObmW/zz/XrawInit.h | 60 |
17 files changed, 10287 insertions, 0 deletions
diff --git a/vendor/x11iraf/obm/ObmW/zz/Separator.c b/vendor/x11iraf/obm/ObmW/zz/Separator.c new file mode 100644 index 00000000..f7669a76 --- /dev/null +++ b/vendor/x11iraf/obm/ObmW/zz/Separator.c @@ -0,0 +1,357 @@ +/* + * Separator.c - Separator widget Vladimir Romanovski + * + */ +#include <X11/IntrinsicP.h> +#include <X11/RectObjP.h> +#include <X11/StringDefs.h> +#include <X11/Xos.h> + +#include <X11/Xraw/XawInit.h> +#include <X11/Xraw/SeparatorP.h> + +#include <X11/Xmu/Converters.h> +#include <X11/Xmu/CharSet.h> +#include <X11/Xmu/Drawing.h> + +#include <stdio.h> +#include <ctype.h> + +/**************************************************************** + * + * Full class record constant + * + ****************************************************************/ + +/* Private Data */ + +#define offset(field) XtOffsetOf(SeparatorRec, field) + +static XtResource resources[] = { + { + XtNorientation, XtCOrientation, XtROrientation, sizeof(XtOrientation), + offset(separator.orientation), XtRImmediate, (XtPointer) XtorientHorizontal + }, + { + XtNmargin, XtCMargin, XtRDimension, sizeof(Dimension), + offset(separator.margin), XtRImmediate, (caddr_t)1 + }, + { + XtNseparatorType, XtCSeparatorType, XtRSeparatorType, + sizeof(XawSeparatorType), offset(separator.separatorType), + XtRImmediate,(caddr_t)XawSHADOW_ETCHED_IN + }, + { + XtNshadowWidth, XtCShadowWidth, XtRDimension, sizeof(Dimension), + offset(simple.shadow_thickness), XtRImmediate, (XtPointer)0 + } +}; +#undef offset + +static void Initialize(); +static void Resize(); +static void Redisplay(); +static Boolean SetValues(); +static void ClassInitialize(); +static void Destroy(); + +SeparatorClassRec separatorClassRec = { + { + /* core_class fields */ + /* superclass */ (WidgetClass) &simpleClassRec, + /* class_name */ "Separator", + /* widget_size */ sizeof(SeparatorRec), + /* class_initialize */ ClassInitialize, + /* class_part_initialize */ NULL, + /* class_inited */ FALSE, + /* initialize */ Initialize, + /* initialize_hook */ NULL, + /* realize */ XtInheritRealize, + /* actions */ NULL, + /* num_actions */ 0, + /* resources */ resources, + /* num_resources */ XtNumber(resources), + /* xrm_class */ NULLQUARK, + /* compress_motion */ TRUE, + /* compress_exposure */ TRUE, + /* compress_enterleave */ TRUE, + /* visible_interest */ FALSE, + /* destroy */ Destroy, + /* 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 */ NULL, + /* query_geometry */ XtInheritQueryGeometry, + /* display_accelerator */ XtInheritDisplayAccelerator, + /* extension */ NULL + }, + { /* Simple class fields initialization */ + /* change_sensitive */ XtInheritChangeSensitive, + /* display_rect */ XtInheritDisplayRectProc, + /* extension */ NULL + }, + { /* Separator class fields initialization */ + /* ignore */ 0 + } +}; + +WidgetClass separatorWidgetClass = (WidgetClass)&separatorClassRec; + +/**************************************************************** + * + * Private Procedures + * + ****************************************************************/ + +/*---------------------------------------------*/ +#define done( type, value ) \ +{ \ + if ( toVal->addr != NULL ) \ + { \ + if ( toVal->size < sizeof( type ) ) \ + { \ + toVal->size = sizeof( type ); \ + return False; \ + } \ + *(type*)(toVal->addr) = (value); \ + } \ + else \ + { \ + static type static_val; \ + static_val = (value); \ + toVal->addr = (caddr_t)&static_val; \ + } \ + toVal->size = sizeof(type); \ + return True; \ +} \ +/*---------------------------------------------*/ + +static XrmQuark QSingle, QDouble, QShadowIn, QShadowOut; + +/* ARGSUSED */ +static Boolean +CvtStringToSeparatorType(dpy, args, num_args, fromVal, toVal, convData) + Display *dpy; + XrmValuePtr args; /* unused */ + Cardinal *num_args; /* unused */ + XrmValuePtr fromVal; + XrmValuePtr toVal; + XtPointer *convData; /* unused */ +{ + static XawSeparatorType separatorType; + XrmQuark q; + char lowerName[BUFSIZ]; + + XmuCopyISOLatin1Lowered (lowerName, (char *)fromVal->addr); + q = XrmStringToQuark(lowerName); + + separatorType = XawSINGLE_LINE; + + if (q == QSingle) separatorType = XawSINGLE_LINE; + else if (q == QDouble) separatorType = XawDOUBLE_LINE; + else if (q == QShadowIn) separatorType = XawSHADOW_ETCHED_IN; + else if (q == QShadowOut) separatorType = XawSHADOW_ETCHED_OUT; + else + XtDisplayStringConversionWarning( dpy, (char *)fromVal->addr, + XtRSeparatorType); + + done(XawSeparatorType, separatorType); +} +#undef done + +static void ClassInitialize() +{ + XawInitializeWidgetSet(); + XtSetTypeConverter( XtRString, XtRSeparatorType, CvtStringToSeparatorType, + (XtConvertArgList)NULL, (Cardinal)0, + XtCacheNone, (XtDestructor)NULL); + + QSingle = XrmStringToQuark(XawSingle_Line); + QDouble = XrmStringToQuark(XawDouble_Line); + QShadowIn = XrmStringToQuark(XawShadow_Etched_In); + QShadowOut = XrmStringToQuark(XawShadow_Etched_Out); +} + +static void GetGC(sw) + SeparatorWidget sw; +{ + XGCValues values; + unsigned long mask; + + values.foreground = sw->simple.foreground; + values.line_width = 0; + mask = GCForeground | GCLineWidth; + + sw->separator.gc = XtGetGC ((Widget)sw, mask, (XGCValues*)&values); +} + +/* ARGSUSED */ +static void Initialize(request, new, args, num_args) + Widget request, new; + ArgList args; + Cardinal *num_args; +{ + SeparatorWidget newsw = (SeparatorWidget) new; + + if (newsw->core.width == 0) + newsw->core.width = 8 + 2*SIMPLE_MARGIN(new); + + if (newsw->core.height == 0) + newsw->core.height = 8 + 2*SIMPLE_MARGIN(new); + + GetGC(newsw); + +} + +static void Resize(w) + Widget w; +{ + /* If widget is realized, clear and redisplay it */ + + if (XtIsRealized(w)) { + XClearWindow(XtDisplay(w), XtWindow(w)); + (*separatorClassRec.core_class.expose) (w, (XEvent*)NULL, (Region)NULL); + } +} + +/* ARGSUSED */ +static Boolean SetValues(current, request, new, args, num_args) + Widget current, request, new; + ArgList args; + Cardinal *num_args; +{ + SeparatorWidget cursw = (SeparatorWidget) current; + SeparatorWidget newsw = (SeparatorWidget) new; + Boolean redisplay = False; + +#define NE(field) (cursw->separator.field != newsw->separator.field) + + if (newsw->core.width == 0) + newsw->core.width = 8 + 2*SIMPLE_MARGIN(new); + + if (newsw->core.height == 0) + newsw->core.height = 8 + 2*SIMPLE_MARGIN(new); + + if (NE(margin) || NE(separatorType)) + redisplay = True; + + if (cursw->simple.foreground != newsw->simple.foreground) + { + XtReleaseGC(new, cursw->separator.gc); + GetGC(newsw); + redisplay = True; + } + + return redisplay; +} + +static void Destroy(w) + Widget w; +{ + XtReleaseGC( w, ((SeparatorWidget)w)->separator.gc ); +} + +static void Redisplay(gw, event, region) + Widget gw; + XEvent *event; + Region region; +{ + register SeparatorWidget sw = (SeparatorWidget) gw; + int x1, y1, x2, y2; + + if (!XtIsRealized(gw)) + return; + + if (sw->simple.shadow_thickness > 0) + (*simpleWidgetClass->core_class.expose) (gw, event, region); + + if (sw->separator.orientation == XtorientHorizontal) { + x1 = sw->separator.margin; + x2 = sw->core.width - (x1 * 2); + + switch(sw->separator.separatorType) { + + case XawSHADOW_ETCHED_IN : + y1 = (sw->core.height - 2) / 2; + y2 = y1 + 1; + + XDrawLine(XtDisplay(gw), XtWindow(gw), sw->simple.bottom_shadow_GC, + x1, y1, x2, y1); + XDrawLine(XtDisplay(gw), XtWindow(gw), sw->simple.top_shadow_GC, + x1, y2, x2, y2); + break; + case XawSHADOW_ETCHED_OUT: + y1 = (sw->core.height - 2) / 2; + y2 = y1 + 1; + XDrawLine(XtDisplay(gw), XtWindow(gw), sw->simple.bottom_shadow_GC, + x1, y2, x2, y2); + XDrawLine(XtDisplay(gw), XtWindow(gw), sw->simple.top_shadow_GC, + x1, y1, x2, y1); + break; + + case XawDOUBLE_LINE: + y1 = (sw->core.height - 2)/ 2; + y2 = y1 + 2; + XDrawLine(XtDisplay(gw), XtWindow(gw), sw->separator.gc, + x1, y1, x2, y1); + XDrawLine(XtDisplay(gw), XtWindow(gw), sw->separator.gc, + x1, y2, x2, y2); + break; + + case XawSINGLE_LINE : + y1 = sw->core.height / 2; + XDrawLine(XtDisplay(gw), XtWindow(gw), sw->separator.gc, + x1, y1, x2, y1); + default: + break; + } + } else { + y1 = sw->separator.margin; + y2 = sw->core.height - (y1 * 2); + + switch(sw->separator.separatorType) { + + case XawSHADOW_ETCHED_IN : + x1 = (sw->core.width - 2) / 2; + x2 = x1 + 1; + + XDrawLine(XtDisplay(gw), XtWindow(gw), sw->simple.bottom_shadow_GC, + x1, y1, x1, y2); + XDrawLine(XtDisplay(gw), XtWindow(gw), sw->simple.top_shadow_GC, + x2, y1, x2, y2); + break; + case XawSHADOW_ETCHED_OUT: + x1 = (sw->core.width - 2) / 2; + x2 = x1 + 1; + XDrawLine(XtDisplay(gw), XtWindow(gw), sw->simple.bottom_shadow_GC, + x1, y1, x1, y2); + XDrawLine(XtDisplay(gw), XtWindow(gw), sw->simple.top_shadow_GC, + x2, y1, x2, y2); + break; + + case XawDOUBLE_LINE: + x1 = (sw->core.width - 2)/ 2; + x2 = x1 + 2; + XDrawLine(XtDisplay(gw), XtWindow(gw), sw->separator.gc, + x1, y1, x1, y2); + XDrawLine(XtDisplay(gw), XtWindow(gw), sw->separator.gc, + x2, y1, x2, y2); + break; + + case XawSINGLE_LINE : + x1 = sw->core.width / 2; + XDrawLine(XtDisplay(gw), XtWindow(gw), sw->separator.gc, + x1, y1, x1, y2); + default: + break; + } + } +} + + diff --git a/vendor/x11iraf/obm/ObmW/zz/Separator.h b/vendor/x11iraf/obm/ObmW/zz/Separator.h new file mode 100644 index 00000000..6d5ad87f --- /dev/null +++ b/vendor/x11iraf/obm/ObmW/zz/Separator.h @@ -0,0 +1,99 @@ +#ifndef _XawSeparator_h +#define _XawSeparator_h + +/*********************************************************************** + * + * Separator Widget + * + ***********************************************************************/ + +#include <X11/Xraw/XawInit.h> +#include <X11/Xraw/Simple.h> + +/* Resources: + + Name Class RepType Default Value + ---- ----- ------- ------------- + background Background Pixel XtDefaultBackground + bitmap Pixmap Pixmap None + border BorderColor Pixel XtDefaultForeground + borderWidth BorderWidth Dimension 1 + cursor Cursor Cursor None + cursorName Cursor String NULL + destroyCallback Callback XtCallbackList NULL + foreground Foreground Pixel XtDefaultForeground + height Height Dimension text height + mappedWhenManaged MappedWhenManaged Boolean True + width Width Dimension text width + x Position Position 0 + y Position Position 0 + +*/ + + + + +typedef enum { + XawSINGLE_LINE = Xraw_SEPARATOR, + XawDOUBLE_LINE, + XawSHADOW_ETCHED_IN, + XawSHADOW_ETCHED_OUT +} XawSeparatorType; + + +#define XawSingle_Line "singleline" +#define XawDouble_Line "doubleline" +#define XawShadow_Etched_In "shadowetchedin" +#define XawShadow_Etched_Out "shadowetchedout" + + + +#ifndef XtNmargin +#define XtNmargin "margin" +#endif + +#ifndef XtCMargin +#define XtCMargin "Margin" +#endif + +#ifndef XtNseparatorType +#define XtNseparatorType "separatorType" +#endif + +#ifndef XtCSeparatorType +#define XtCSeparatorType "SeparatorType" +#endif + +#ifndef XtRSeparatorType +#define XtRSeparatorType "SeparatorType" +#endif + +#define XawTextEncoding8bit 0 +#define XawTextEncodingChar2b 1 + +#define XtNleftBitmap "leftBitmap" +#define XtCLeftBitmap "LeftBitmap" +#define XtNencoding "encoding" +#define XtCEncoding "Encoding" + +#ifndef _XtStringDefs_h_ +#define XtNbitmap "bitmap" +#define XtNforeground "foreground" +#define XtNseparator "separator" +#define XtNfont "font" +#define XtNinternalWidth "internalWidth" +#define XtNinternalHeight "internalHeight" +#define XtNresize "resize" +#define XtCResize "Resize" +#define XtCBitmap "Bitmap" +#endif + +/* Class record constants */ + +extern WidgetClass separatorWidgetClass; + +typedef struct _SeparatorClassRec *SeparatorWidgetClass; +typedef struct _SeparatorRec *SeparatorWidget; + +#endif /* _XawSeparator_h */ +/* DON'T ADD STUFF AFTER THIS #endif */ diff --git a/vendor/x11iraf/obm/ObmW/zz/SeparatorP.h b/vendor/x11iraf/obm/ObmW/zz/SeparatorP.h new file mode 100644 index 00000000..75250d38 --- /dev/null +++ b/vendor/x11iraf/obm/ObmW/zz/SeparatorP.h @@ -0,0 +1,60 @@ +/* + * SeparatorP.h - Private definitions for Separator widget + * + */ + +#ifndef _XawSeparatorP_h +#define _XawSeparatorP_h + +/*********************************************************************** + * + * Separator Widget Private Data + * + ***********************************************************************/ + +#include <X11/Xmu/Converters.h> +#include <X11/Xraw/SimpleP.h> +#include <X11/Xraw/Separator.h> + + +/* New fields for the Separator widget class record */ + +typedef struct {int foo;} SeparatorClassPart; + +/* Full class record declaration */ +typedef struct _SeparatorClassRec { + CoreClassPart core_class; + SimpleClassPart simple_class; + SeparatorClassPart separator_class; +} SeparatorClassRec; + +extern SeparatorClassRec separatorClassRec; + +/* New fields for the Separator widget record */ + +typedef struct { + + /* Public Resources */ + XtOrientation orientation; + Dimension margin; + XawSeparatorType separatorType; + + /* Private part */ + GC gc; + +} SeparatorPart; + + +/**************************************************************** + * + * Full instance record declaration + * + ****************************************************************/ + +typedef struct _SeparatorRec { + CorePart core; + SimplePart simple; + SeparatorPart separator; +} SeparatorRec; + +#endif /* _XawSeparatorP_h */ diff --git a/vendor/x11iraf/obm/ObmW/zz/Simple.c b/vendor/x11iraf/obm/ObmW/zz/Simple.c new file mode 100644 index 00000000..83797833 --- /dev/null +++ b/vendor/x11iraf/obm/ObmW/zz/Simple.c @@ -0,0 +1,489 @@ +#include <stdio.h> + +#include <X11/IntrinsicP.h> +#include <X11/StringDefs.h> + +#include <X11/Xmu/Drawing.h> + +#include <X11/Xraw/XawInit.h> +#include <X11/Xraw/3d.h> +#include <X11/Xraw/SimpleP.h> +#include <X11/Xraw/ContainerP.h> + +#define UnspecifiedPixmap (Pixmap)2 +#define UndefinedGC (GC)2 + +static void InsPixel(); + +static XtResource resources[] = { +#define offset(field) XtOffset(SimpleWidget, simple.field) + { + XtNcursor, XtCCursor, XtRCursor, sizeof(Cursor), + offset(cursor), XtRImmediate, (XtPointer) None + }, + { + XtNinsensitiveBorder, XtCInsensitive, XtRPixmap, sizeof(Pixmap), + offset(insensitive_border), XtRImmediate, (XtPointer) None + }, + { + XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel), + offset(foreground), XtRImmediate, (XtPointer) XtDefaultForeground + }, + { + "top.gc", "Top.gc", XtRString, sizeof(String), + offset(top_shadow_GC), XtRImmediate, (XtPointer)NULL + }, + { + "bottom.gc", "Bottom.gc", XtRString, sizeof(String), + offset(bottom_shadow_GC), XtRImmediate, (XtPointer)NULL + }, + { + "highlight.gc", "Highlight.gc", XtRString, sizeof(String), + offset(highlight_GC), XtRImmediate, (XtPointer)NULL + }, + { + XtNshadowWidth, XtCShadowWidth, XtRDimension, sizeof(Dimension), + offset(shadow_thickness), XtRImmediate, (XtPointer) 0 + }, + { + XtNtopShadowPixmap, XtCTopShadowPixmap, XtRPixmap, sizeof(Pixmap), + offset(top_shadow_pixmap), XtRImmediate, (XtPointer) UnspecifiedPixmap + }, + { + XtNtopShadowPixel, XtCTopShadowPixel, XtRPixel, sizeof(Pixel), + offset(top_shadow_color), XtRCallProc, (XtPointer) InsPixel + }, + { + XtNbottomShadowPixmap, XtCBottomShadowPixmap, XtRPixmap, sizeof(Pixmap), + offset(bottom_shadow_pixmap), XtRImmediate, (XtPointer) UnspecifiedPixmap + }, + { + XtNbottomShadowPixel, XtCBottomShadowPixel, XtRPixel, sizeof(Pixel), + offset(bottom_shadow_color), XtRCallProc, (XtPointer) InsPixel + }, + { + XtNhighlightPixmap, XtCHighlightPixmap, XtRPixmap, sizeof(Pixmap), + offset(highlight_pixmap), XtRImmediate, (XtPointer) UnspecifiedPixmap + }, + { + XtNhighlightPixel, XtCHighlightPixel, XtRPixel, sizeof(Pixel), + offset(highlight_color), XtRCallProc, (XtPointer) InsPixel + }, + { + XtNhighlightThickness, XtCHighlightThickness, XtRDimension, + sizeof(Dimension), + offset(highlight_thickness), XtRImmediate, (XtPointer) 2 + }, + { + XtNuserData, XtCUserData, XtRPixmap, sizeof(Pixmap), + offset(user_data), XtRImmediate, (XtPointer) NULL + }, + { + XtNborderWidth, XtCBorderWidth, XtRDimension, sizeof(Dimension), + XtOffsetOf(RectObjRec,rectangle.border_width), XtRImmediate, (XtPointer)0 + } + +}; + +static void InsPixel(w, off, value) + Widget w; + int off; + XrmValue *value; +{ + register SimpleWidget p = (SimpleWidget) w; + static Pixel pixel; + + if (off == offset(top_shadow_color)) + { + p->simple.top_shadow_GC = UndefinedGC; + } + else if (off == offset(bottom_shadow_color)) + { + p->simple.bottom_shadow_GC = UndefinedGC; + } + else + { + p->simple.highlight_GC = UndefinedGC; + } + value->addr = (XtPointer) &pixel; +} + +#undef offset + +static void ClasstInitialize(); +static void ClassPartInitialize(); +static void Initialize(); +static void Realize(); +static void Redisplay(); +static void Destroy(); + +static Boolean SetValues(); +static Boolean DisplayRectProc(); +static Boolean ChangeSensitive(); + +static XtGeometryResult QueryGeometry(); + +SimpleClassRec simpleClassRec = { + { /* core fields */ + /* superclass */ (WidgetClass) &widgetClassRec, + /* class_name */ "Simple", + /* widget_size */ sizeof(SimpleRec), + /* class_initialize */ ClasstInitialize, + /* class_part_initialize */ ClassPartInitialize, + /* class_inited */ FALSE, + /* initialize */ Initialize, + /* initialize_hook */ NULL, + /* realize */ Realize, + /* actions */ NULL, + /* num_actions */ 0, + /* resources */ resources, + /* num_resources */ XtNumber(resources), + /* xrm_class */ NULLQUARK, + /* compress_motion */ TRUE, + /* compress_exposure */ TRUE, + /* compress_enterleave */ TRUE, + /* visible_interest */ FALSE, + /* destroy */ Destroy, + /* resize */ NULL, + /* 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 */ NULL, + /* query_geometry */ QueryGeometry, + /* display_accelerator */ XtInheritDisplayAccelerator, + /* extension */ NULL + }, + { /* simple fields */ + /* change_sensitive */ ChangeSensitive, + /* display_rect */ DisplayRectProc, + /* extension */ NULL + } +}; + +WidgetClass simpleWidgetClass = (WidgetClass)&simpleClassRec; + +static void ClasstInitialize() +{ +/* EMPTY */ +} + +static void ClassPartInitialize(class) + WidgetClass class; +{ + register SimpleWidgetClass c = (SimpleWidgetClass)class; + + if (c->simple_class.change_sensitive == NULL) + { + char buf[BUFSIZ]; + + sprintf(buf, + "%s Widget: The Simple Widget class method 'change_sensitive' is undefined.\nA function must be defined or inherited.", + c->core_class.class_name); + XtWarning(buf); + c->simple_class.change_sensitive = ChangeSensitive; + } + + if (c->simple_class.change_sensitive == XtInheritChangeSensitive) + c->simple_class.change_sensitive = ChangeSensitive; + + if (c->simple_class.display_rect == XtInheritDisplayRectProc) + c->simple_class.display_rect = DisplayRectProc; +} + +/* ARGSUSED */ +static void Initialize(request, new, args, num_args) + Widget request, new; + ArgList args; + Cardinal *num_args; +{ + SimpleWidget sw = (SimpleWidget)new; + SimplePart* sp = (SimplePart*)&(sw->simple); + + if (sp->top_shadow_pixmap == UnspecifiedPixmap) + sp->top_shadow_pixmap = None; + + if (sp->top_shadow_GC == NULL){ + if (sp->top_shadow_pixmap != None) + sp->top_shadow_GC = AllocGCFromPixmap (new, sp->top_shadow_pixmap); + else + sp->top_shadow_GC = AllocGCFromPixel (new, sp->top_shadow_color); + } else if (sp->top_shadow_GC == UndefinedGC) + sp->top_shadow_GC = MakeTopShadowGC (new, new->core.background_pixel); + + + if (sp->bottom_shadow_pixmap == UnspecifiedPixmap) + sp->bottom_shadow_pixmap = None; + + if (sp->bottom_shadow_GC == NULL){ + if (sp->bottom_shadow_pixmap != None) + sp->bottom_shadow_GC = AllocGCFromPixmap (new, sp->bottom_shadow_pixmap); + else + sp->bottom_shadow_GC = AllocGCFromPixel (new, sp->bottom_shadow_color); + } else if (sp->bottom_shadow_GC == UndefinedGC) + sp->bottom_shadow_GC =MakeBottomShadowGC (new, new->core.background_pixel); + + + if (sp->highlight_pixmap == UnspecifiedPixmap) + sp->highlight_pixmap = None; + + if (sp->highlight_GC == NULL){ + if (sp->highlight_pixmap != None) + sp->highlight_GC = AllocGCFromPixmap (new, sp->highlight_pixmap); + else + sp->highlight_GC = AllocGCFromPixel (new, sp->highlight_color); + } else if (sp->highlight_GC == UndefinedGC) + sp->highlight_GC = MakeBottomShadowGC (new, new->core.background_pixel); + +} + +static void Realize(w, valueMask, attributes) + Widget w; + Mask *valueMask; + XSetWindowAttributes *attributes; +{ + Pixmap border_pixmap; + + if (!XtIsSensitive(w)) + { + /* change border to gray; have to remember the old one, + * so XtDestroyWidget deletes the proper one */ + if (((SimpleWidget)w)->simple.insensitive_border == None) + ((SimpleWidget)w)->simple.insensitive_border = + XmuCreateStippledPixmap(XtScreen(w), + w->core.border_pixel, + w->core.background_pixel, + w->core.depth); + border_pixmap = w->core.border_pixmap; + attributes->border_pixmap = + w->core.border_pixmap = ((SimpleWidget)w)->simple.insensitive_border; + + *valueMask |= CWBorderPixmap; + *valueMask &= ~CWBorderPixel; + } + + if ((attributes->cursor = ((SimpleWidget)w)->simple.cursor) != None) + *valueMask |= CWCursor; + + XtCreateWindow( w, (unsigned int)InputOutput, (Visual *)CopyFromParent, + *valueMask, attributes ); + + if (!XtIsSensitive(w)) + w->core.border_pixmap = border_pixmap; +} + +/* ARGSUSED */ +static Boolean SetValues(current, request, new, args, num_args) + Widget current, request, new; + ArgList args; + Cardinal *num_args; +{ + SimpleWidget s_old = (SimpleWidget) current; + SimpleWidget s_new = (SimpleWidget) new; + SimplePart* sp = (SimplePart*)&(s_new->simple); + Boolean redraw = False; + +#define NE(field) (s_new->simple.field != s_old->simple.field) + + if ( XtIsSensitive(current) != XtIsSensitive(new) ) + (*((SimpleWidgetClass)XtClass(new))-> + simple_class.change_sensitive) ( new ); + + if ( NE(cursor) && XtIsRealized(new)) + XDefineCursor(XtDisplay(new), XtWindow(new), s_new->simple.cursor); + + if (NE(top_shadow_pixmap)) + { + XtReleaseGC (new, sp->top_shadow_GC); + sp->top_shadow_GC = AllocGCFromPixmap (new, sp->top_shadow_pixmap); + redraw = True; + } + else if (NE(top_shadow_color) && sp->top_shadow_pixmap == None) + { + XtReleaseGC (new, sp->top_shadow_GC); + sp->top_shadow_GC = AllocGCFromPixel (new, sp->top_shadow_color); + redraw = True; + } + + if (NE(bottom_shadow_pixmap)) + { + XtReleaseGC (new, sp->bottom_shadow_GC); + sp->bottom_shadow_GC = AllocGCFromPixmap (new, sp->bottom_shadow_pixmap); + redraw = True; + } + else if (NE(bottom_shadow_color) && sp->bottom_shadow_pixmap == None) + { + XtReleaseGC (new, sp->bottom_shadow_GC); + sp->bottom_shadow_GC = AllocGCFromPixel (new, sp->bottom_shadow_color); + redraw = True; + } + + if (NE(highlight_pixmap)) + { + XtReleaseGC (new, sp->highlight_GC); + sp->highlight_GC = AllocGCFromPixmap (new, sp->highlight_pixmap); + redraw = True; + } + else if (NE(highlight_color) && sp->highlight_pixmap) + { + XtReleaseGC (new, sp->highlight_GC); + sp->highlight_GC = AllocGCFromPixel (new, sp->highlight_color); + redraw = True; + } + +#undef NE + + return redraw; +} + + +static void Unhighlight (gw) + Widget gw; +{ + register Dimension thick = ((SimpleWidget)gw)->simple.highlight_thickness; + register Dimension width = gw->core.width; + register Dimension height = gw->core.height; + + if (!XtIsRealized(gw)) + return; + + if ( XtIsSubclass(XtParent(gw), containerWidgetClass)) + { + XRectangle rectangles[4]; + GC gc = ((ContainerWidget) XtParent(gw))->container.background_GC; + +#define SET_RECTANGLE(I,X,Y,W,H) \ + rectangles[I].x = X; rectangles[I].y = Y; \ + rectangles[I].width = W; rectangles[I].height = H + + SET_RECTANGLE(0, 0, 0, thick, height); + SET_RECTANGLE(1, 0, height - thick, width, thick); + SET_RECTANGLE(2, 0, 0, width, thick); + SET_RECTANGLE(3, width - thick, 0, thick, height); + + XFillRectangles (XtDisplay(gw), XtWindow(gw), gc, rectangles, 4); + + } + else + { + Display *dpy = XtDisplay(gw); + Window win = XtWindow(gw); + + XClearArea( dpy, win, 0, 0, thick, height, False); + XClearArea( dpy, win, 0, height - thick, width, thick, False); + XClearArea( dpy, win, 0, 0, width, thick, False); + XClearArea( dpy, win, width - thick, 0, thick, height, False); + } +} + + +/* ARGSUSED */ +static void Redisplay( gw, event, region ) + Widget gw; + XEvent *event; + Region region; +{ + register SimpleWidget s = (SimpleWidget)gw; + + if (XtIsRealized(gw)) + { + Unhighlight (gw); + + if (s->simple.shadow_thickness) + XawDrawFrame (gw, + s->simple.highlight_thickness, + s->simple.highlight_thickness, + s->core.width - 2 * s->simple.highlight_thickness, + s->core.height - 2 * s->simple.highlight_thickness, + XawRAISED, + s->simple.shadow_thickness, + s->simple.top_shadow_GC, + s->simple.bottom_shadow_GC); + } +} + +static void Destroy(w) + Widget w; +{ + register SimpleWidget s = (SimpleWidget)w; + + XtReleaseGC(w, s->simple.top_shadow_GC); + XtReleaseGC(w, s->simple.bottom_shadow_GC); +} + +static Boolean DisplayRectProc (w, rect) + Widget w; + XRectangle *rect; +{ + register SimpleWidget s = (SimpleWidget)w; + + rect->x = + rect->y = s->simple.highlight_thickness + s->simple.shadow_thickness; + rect->width = s->core.width - 2 * rect->x; + rect->height = s->core.height - 2 * rect->y; + + return True; +} + + +static XtGeometryResult QueryGeometry(w, intended, preferred) + Widget w; + XtWidgetGeometry *intended, *preferred; +{ + register SimpleWidget sw = (SimpleWidget)w; + + + preferred->request_mode = CWWidth | CWHeight; + + preferred->width = preferred->height = 2 * SIMPLE_MARGIN(sw) + 1; + +#define WIDTH_HEIGHT (CWWidth | CWHeight) + + if (intended + && ((intended->request_mode & WIDTH_HEIGHT) == WIDTH_HEIGHT) + && intended->width == preferred->width + && intended->height == preferred->height) + { + return XtGeometryYes; + } + else if (preferred->width == w->core.width + && preferred->height == w->core.height) + { + return XtGeometryNo; + } + else + { + return XtGeometryAlmost; + } +} + + +static Boolean ChangeSensitive(w) + register Widget w; +{ + if (XtIsRealized(w)) { + if (XtIsSensitive(w)) + if (w->core.border_pixmap != UnspecifiedPixmap) + XSetWindowBorderPixmap( XtDisplay(w), XtWindow(w), + w->core.border_pixmap ); + else + XSetWindowBorder( XtDisplay(w), XtWindow(w), + w->core.border_pixel ); + else { + if (((SimpleWidget)w)->simple.insensitive_border == None) + ((SimpleWidget)w)->simple.insensitive_border = + XmuCreateStippledPixmap(XtScreen(w), + w->core.border_pixel, + w->core.background_pixel, + w->core.depth); + XSetWindowBorderPixmap( XtDisplay(w), XtWindow(w), + ((SimpleWidget)w)-> + simple.insensitive_border ); + } + } + return False; +} diff --git a/vendor/x11iraf/obm/ObmW/zz/Simple.h b/vendor/x11iraf/obm/ObmW/zz/Simple.h new file mode 100644 index 00000000..bbe11cda --- /dev/null +++ b/vendor/x11iraf/obm/ObmW/zz/Simple.h @@ -0,0 +1,96 @@ +/* + * $XConsortium: Simple.h,v 1.9 89/07/21 01:44:53 kit Exp $ + */ + +/*********************************************************** +Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts, +and the Massachusetts Institute of Technology, Cambridge, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +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 names of Digital or MIT not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL 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. + +******************************************************************/ + +#ifndef _Simple_h +#define _Simple_h + +/**************************************************************** + * + * Simple widgets + * + ****************************************************************/ + +/* Resources: + + Name Class RepType Default Value + ---- ----- ------- ------------- + background Background Pixel XtDefaultBackground + border BorderColor Pixel XtDefaultForeground + borderWidth BorderWidth Dimension 1 + cursor Cursor Cursor None + destroyCallback Callback Pointer NULL + height Height Dimension 0 + insensitiveBorder Insensitive Pixmap Gray + mappedWhenManaged MappedWhenManaged Boolean True + sensitive Sensitive Boolean True + width Width Dimension 0 + x Position Position 0 + y Position Position 0 + + shadowWidth ShadowWidth Dimension 2 + topShadowPixel TopShadowPixel Pixel dynamic + bottomShadowPixel BottomShadowPixel Pixel dynamic + topShadowContrast TopShadowContrast Int 20 + bottomShadowContrast BottomShadowContrast Int 40 + userData UserData XtPointer NULL + beNiceToColormap BeNiceToColormap Boolean False + +*/ + +#define XtNcursor "cursor" +#define XtNinsensitiveBorder "insensitiveBorder" +#define XtNuserData "userData" +#define XtCUserData "UserData" + +#define XtCInsensitive "Insensitive" + +#define XtNtopShadowPixmap "topShadowPixmap" +#define XtCTopShadowPixmap "TopShadowPixmap" +#define XtNbottomShadowPixmap "bottomShadowPixmap" +#define XtCBottomShadowPixmap "BottomShadowPixmap" +#define XtNhighlightPixmap "highlightPixmap" +#define XtCHighlightPixmap "HighlightPixmap" +#define XtNhighlightThickness "highlightThickness" +#define XtCHighlightThickness "HighlightThickness" + + +#define XtNshadowWidth "shadowWidth" +#define XtCShadowWidth "ShadowWidth" +#define XtNtopShadowPixel "topShadowPixel" +#define XtCTopShadowPixel "TopShadowPixel" +#define XtNbottomShadowPixel "bottomShadowPixel" +#define XtCBottomShadowPixel "BottomShadowPixel" +#define XtNhighlightPixel "highlightPixel" +#define XtCHighlightPixel "HighlightPixel" + +typedef struct _SimpleClassRec *SimpleWidgetClass; +typedef struct _SimpleRec *SimpleWidget; + +extern WidgetClass simpleWidgetClass; + +#endif /* _Simple_h */ diff --git a/vendor/x11iraf/obm/ObmW/zz/SimpleMenP.h b/vendor/x11iraf/obm/ObmW/zz/SimpleMenP.h new file mode 100644 index 00000000..32f5ccf9 --- /dev/null +++ b/vendor/x11iraf/obm/ObmW/zz/SimpleMenP.h @@ -0,0 +1,113 @@ +/* + * $XConsortium: SimpleMenP.h,v 1.12 89/12/11 15:01:39 kit Exp $ + * + * 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. + * + */ + +/* + * SimpleMenuP.h - Private Header file for SimpleMenu widget. + * + * Date: April 3, 1989 + * + * By: Chris D. Peterson + * MIT X Consortium + * kit@expo.lcs.mit.edu + */ + +#ifndef _SimpleMenuP_h +#define _SimpleMenuP_h + +#include <X11/ShellP.h> +#include <X11/Xraw/3d.h> +#include <X11/Xraw/SimpleMenu.h> +#include <X11/Xraw/SmeP.h> + +#define SMW(w) ((SimpleMenuWidget)w)->simple_menu + +typedef struct { + XtPointer extension; /* For future needs. */ +} SimpleMenuClassPart; + +typedef struct _SimpleMenuClassRec { + CoreClassPart core_class; + CompositeClassPart composite_class; + ShellClassPart shell_class; + OverrideShellClassPart override_shell_class; + SimpleMenuClassPart simpleMenu_class; +} SimpleMenuClassRec; + +extern SimpleMenuClassRec simpleMenuClassRec; + +typedef struct _SimpleMenuPart { + /* resources */ + Dimension shadow_thickness; + Dimension bsb_shadow_thickness; + + Pixel top_shadow_color; + Pixmap top_shadow_pixmap; + Pixel bottom_shadow_color; + Pixmap bottom_shadow_pixmap; + + GC top_shadow_GC; + GC bottom_shadow_GC; + + XawFrameType frame_type; + + XtPointer user_data; + + /* resources */ + + String label_string; /* The string for the label or NULL. */ + SmeObject label; /* If label_string is non-NULL then this is + the label widget. */ + WidgetClass label_class; /* Widget Class of the menu label object. */ + + Dimension top_margin; /* Top and bottom margins. */ + Dimension bottom_margin; + Dimension row_height; /* height of each row (menu entry) */ + + Cursor cursor; /* The menu's cursor. */ + SmeObject popup_entry; /* The entry to position the cursor on for + when using XawPositionSimpleMenu. */ + Boolean menu_on_screen; /* Force the menus to be fully on the screen.*/ + int backing_store; /* What type of backing store to use. */ + + /* private state */ + + Boolean recursive_set_values; /* contain a possible infinite loop. */ + + Boolean menu_width; /* If true then force width to remain + core.width */ + Boolean menu_height; /* Just like menu_width, but for height. */ + + SmeObject entry_set; /* The entry that is currently set or + highlighted. */ +} SimpleMenuPart; + +typedef struct _SimpleMenuRec { + CorePart core; + CompositePart composite; + ShellPart shell; + OverrideShellPart override; + SimpleMenuPart simple_menu; +} SimpleMenuRec, *SimpleMenu; + +#endif /* _SimpleMenuP_h */ diff --git a/vendor/x11iraf/obm/ObmW/zz/SimpleMenu.c b/vendor/x11iraf/obm/ObmW/zz/SimpleMenu.c new file mode 100644 index 00000000..eeade452 --- /dev/null +++ b/vendor/x11iraf/obm/ObmW/zz/SimpleMenu.c @@ -0,0 +1,1467 @@ +/* $XConsortium: SimpleMenu.c,v 1.32 89/12/11 15:01:50 kit Exp $ */ + +/* + * 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. + */ + +/* + * SimpleMenu.c - Source code file for SimpleMenu widget. + * + * Date: April 3, 1989 + * + * By: Chris D. Peterson + * MIT X Consortium + * kit@expo.lcs.mit.edu + * -------------------------------- + * + * Date: Jul 4, 1995 + * + * Changes: Vladimir T. Romanovski + * romsky@hp1.oea.ihep.su // IHEP (Russia) + * romsky@munin.ucsf.edu // University of California San Francisco + * + */ + +#include <stdio.h> +#include <X11/IntrinsicP.h> +#include <X11/StringDefs.h> + +#include <X11/Xraw/XawInit.h> +#include <X11/Xraw/3d.h> +#include <X11/Xraw/SimpleMenP.h> +#include <X11/Xraw/SmeBSB.h> +#include <X11/Xraw/Cardinals.h> +#include <X11/Xraw/SmeLineP.h> + +#include <X11/Xmu/Initer.h> +#include <X11/Xmu/CharSet.h> + +#define CORE(w) (w)->core + +#define ForAllChildren(smw, childP) \ + for ( (childP) = (SmeObject *) (smw)->composite.children ; \ + (childP) < (SmeObject *) ((smw)->composite.children + \ + (smw)->composite.num_children ) ; \ + (childP)++ ) + + +#define UnspecifiedPixmap (Pixmap)2 +#define UndefinedGC (GC)2 + +static void InsPixel(); + +static XtResource resources[] = { +#define offset(field) XtOffset(SimpleMenuWidget, simple_menu.field) + { + "top.gc", "Top.gc", XtRString, sizeof(String), + offset(top_shadow_GC), XtRImmediate, (XtPointer)NULL + }, + { + "bottom.gc", "Bottom.gc", XtRString, sizeof(String), + offset(bottom_shadow_GC), XtRImmediate, (XtPointer)NULL + }, + { + XtNshadowWidth, XtCShadowWidth, XtRDimension, sizeof(Dimension), + offset(shadow_thickness), XtRImmediate, (XtPointer) 2 + }, + { + XtNbsbShadowWidth, XtCBsbShadowWidth, XtRDimension, sizeof(Dimension), + offset(bsb_shadow_thickness), XtRImmediate, (XtPointer) 2 + }, + { + XtNtopShadowPixmap, XtCTopShadowPixmap, XtRPixmap, sizeof(Pixmap), + offset(top_shadow_pixmap), XtRImmediate, (XtPointer) UnspecifiedPixmap + }, + { + XtNtopShadowPixel, XtCTopShadowPixel, XtRPixel, sizeof(Pixel), + offset(top_shadow_color), XtRCallProc, (XtPointer) InsPixel + }, + { + XtNbottomShadowPixmap, XtCBottomShadowPixmap, XtRPixmap, sizeof(Pixmap), + offset(bottom_shadow_pixmap), XtRImmediate, (XtPointer) UnspecifiedPixmap + }, + { + XtNbottomShadowPixel, XtCBottomShadowPixel, XtRPixel, sizeof(Pixel), + offset(bottom_shadow_color), XtRCallProc, (XtPointer) InsPixel + }, + { + XtNuserData, XtCUserData, XtRPixmap, sizeof(Pixmap), + offset(user_data), XtRImmediate, (XtPointer) NULL + }, + { + XtNborderWidth, XtCBorderWidth, XtRDimension, sizeof(Dimension), + XtOffsetOf(RectObjRec,rectangle.border_width), XtRImmediate, (XtPointer)0 + }, + { + XtNframeType, XtCFrameType, XtRFrameType, sizeof(XawFrameType), + offset(frame_type), XtRImmediate, (XtPointer) XawRAISED + }, + +/* + * Label Resources. + */ + + { + XtNlabel, XtCLabel, XtRString, sizeof(String), + offset(label_string), XtRString, NULL + }, + { + XtNlabelClass, XtCLabelClass, XtRPointer, sizeof(WidgetClass), + offset(label_class), XtRImmediate, (XtPointer) NULL + }, + +/* + * Layout Resources. + */ + + { + XtNrowHeight, XtCRowHeight, XtRDimension, sizeof(Dimension), + offset(row_height), XtRImmediate, (XtPointer) 0 + }, + { + XtNtopMargin, XtCVerticalMargins, XtRDimension, sizeof(Dimension), + offset(top_margin), XtRImmediate, (XtPointer) 0 + }, + { + XtNbottomMargin, XtCVerticalMargins, XtRDimension, sizeof(Dimension), + offset(bottom_margin), XtRImmediate, (XtPointer) 0 + }, + +/* + * Misc. Resources + */ + + { + XtNallowShellResize, XtCAllowShellResize, XtRBoolean, sizeof(Boolean), + XtOffset(SimpleMenuWidget, shell.allow_shell_resize), + XtRImmediate, (XtPointer) TRUE + }, + { + XtNcursor, XtCCursor, XtRCursor, sizeof(Cursor), + offset(cursor), XtRImmediate, (XtPointer) None + }, + { + XtNmenuOnScreen, XtCMenuOnScreen, XtRBoolean, sizeof(Boolean), + offset(menu_on_screen), XtRImmediate, (XtPointer) TRUE + }, + { + XtNpopupOnEntry, XtCPopupOnEntry, XtRWidget, sizeof(Widget), + offset(popup_entry), XtRWidget, NULL + }, + { + XtNbackingStore, XtCBackingStore, XtRBackingStore, sizeof (int), + offset(backing_store), XtRImmediate, + (XtPointer) (Always + WhenMapped + NotUseful) + } +}; + +static void InsPixel(w, off, value) + Widget w; + int off; + XrmValue *value; +{ + register SimpleMenuWidget p = (SimpleMenuWidget) w; + static Pixel pixel; + + if (off == offset(top_shadow_color)) + { + p->simple_menu.top_shadow_GC = UndefinedGC; + } + else if (off == offset(bottom_shadow_color)) + { + p->simple_menu.bottom_shadow_GC = UndefinedGC; + } + value->addr = (XtPointer) &pixel; +} + +#undef offset + +static char defaultTranslations[] = + "<EnterWindow>: highlight() \n\ + <LeaveWindow>: unhighlight() \n\ + <BtnMotion>: highlight() \n\ + <BtnUp>: MenuPopdown() notify() unhighlight()"; + +/* + * Semi Public function definitions. + */ + +static void Redisplay(), Realize(), Resize(), ChangeManaged(); +static void Initialize(), ClassInitialize(), ClassPartInitialize(); +static Boolean SetValues(), SetValuesHook(); +static XtGeometryResult GeometryManager(); + +/* + * Action Routine Definitions + */ + +static void Highlight(), Unhighlight(), Notify(), PositionMenuAction(); + +/* + * Private Function Definitions. + */ + +static void MakeSetValuesRequest(), CreateLabel(), Layout(); +static void AddPositionAction(), PositionMenu(); +static Dimension GetMenuWidth(), GetMenuHeight(); +static Widget FindMenu(); +static SmeObject GetEventEntry(); + +static XtActionsRec actionsList[] = +{ + {"notify", Notify}, + {"highlight", Highlight}, + {"unhighlight", Unhighlight} +}; + +CompositeClassExtensionRec extension_rec = { + /* next_extension */ NULL, + /* record_type */ NULLQUARK, + /* version */ XtCompositeExtensionVersion, + /* record_size */ sizeof(CompositeClassExtensionRec), + /* accepts_objects */ TRUE, +}; + +#define superclass (&overrideShellClassRec) + +SimpleMenuClassRec simpleMenuClassRec = { + { + /* superclass */ (WidgetClass) superclass, + /* class_name */ "SimpleMenu", + /* size */ sizeof(SimpleMenuRec), + /* class_initialize */ ClassInitialize, + /* class_part_initialize*/ ClassPartInitialize, + /* Class init'ed */ False, + /* initialize */ Initialize, + /* initialize_hook */ NULL, + /* realize */ Realize, + /* actions */ actionsList, + /* num_actions */ XtNumber(actionsList), + /* resources */ resources, + /* resource_count */ XtNumber(resources), + /* xrm_class */ NULLQUARK, + /* compress_motion */ TRUE, + /* compress_exposure */ TRUE, + /* compress_enterleave*/ TRUE, + /* visible_interest */ False, + /* destroy */ NULL, + /* resize */ Resize, + /* expose */ Redisplay, + /* set_values */ SetValues, + /* set_values_hook */ SetValuesHook, + /* set_values_almost */ XtInheritSetValuesAlmost, + /* get_values_hook */ NULL, + /* accept_focus */ NULL, + /* intrinsics version */ XtVersion, + /* callback offsets */ NULL, + /* tm_table */ defaultTranslations, + /* query_geometry */ NULL, + /* display_accelerator*/ NULL, + /* extension */ NULL + },{ + /* geometry_manager */ GeometryManager, + /* change_managed */ ChangeManaged, + /* insert_child */ XtInheritInsertChild, + /* delete_child */ XtInheritDeleteChild, + /* extension */ NULL + },{ + /* Shell extension */ NULL + },{ + /* Override extension */ NULL + },{ + /* Simple Menu extension*/ NULL + } +}; + +WidgetClass simpleMenuWidgetClass = (WidgetClass)&simpleMenuClassRec; + +/************************************************************ + * + * Semi-Public Functions. + * + ************************************************************/ +#define done(type, value) \ + { \ + if (to->addr != NULL) { \ + if (to->size < sizeof(type)) { \ + to->size = sizeof(type); \ + return False; \ + } \ + *(type*)(to->addr) = (value); \ + } else { \ + static type static_val; \ + static_val = (value); \ + to->addr = (XtPointer)&static_val; \ + } \ + to->size = sizeof(type); \ + return True; \ + } + + +/* ARGSUSED */ +static Boolean +cvtStringToFrameType ( display, args, num_args, from, to, converter_data) + Display *display; + XrmValuePtr args; + Cardinal *num_args; + XrmValuePtr from; + XrmValuePtr to; + XtPointer *converter_data; +{ + String s = (String) from->addr; + + if (*num_args != 0) + XtAppErrorMsg(XtDisplayToApplicationContext(display), + "cvtStringToFrameType", "wrongParameters", + "XtToolkitError", + "String to frame type conversion needs no arguments", + (String*) NULL, (Cardinal*) NULL); + + if (XmuCompareISOLatin1(s, "raised") == 0) done(XawFrameType, XawRAISED); + if (XmuCompareISOLatin1(s, "sunken") == 0) done(XawFrameType, XawSUNKEN); + if (XmuCompareISOLatin1(s, "chiseled") == 0) done(XawFrameType, XawCHISELED); + if (XmuCompareISOLatin1(s, "ledged") == 0) done(XawFrameType, XawLEDGED); + if (XmuCompareISOLatin1(s, "tack") == 0) done(XawFrameType, XawTACK); + + XtDisplayStringConversionWarning(display, s, XtRFrameType); + printf("SimpleMenu.c"); + + done(XawFrameType, XawRAISED); +} + +/* Function Name: ClassInitialize + * Description: Class Initialize routine, called only once. + * Arguments: none. + * Returns: none. + */ + +static void +ClassInitialize() +{ + XawInitializeWidgetSet(); + XtAddConverter( XtRString, XtRBackingStore, XmuCvtStringToBackingStore, + NULL, 0 ); + XmuAddInitializer( AddPositionAction, NULL); + + XtSetTypeConverter(XtRString, XtRFrameType, cvtStringToFrameType, + NULL, 0, XtCacheNone, NULL); +} + +/* Function Name: ClassPartInitialize + * Description: Class Part Initialize routine, called for every + * subclass. Makes sure that the subclasses pick up + * the extension record. + * Arguments: wc - the widget class of the subclass. + * Returns: none. + */ + +static void +ClassPartInitialize(wc) +WidgetClass wc; +{ + SimpleMenuWidgetClass smwc = (SimpleMenuWidgetClass) wc; + +/* + * Make sure that our subclass gets the extension rec too. + */ + + extension_rec.next_extension = smwc->composite_class.extension; + smwc->composite_class.extension = (XtPointer) &extension_rec; +} + +/* Function Name: Initialize + * Description: Initializes the simple menu widget + * Arguments: request - the widget requested by the argument list. + * new - the new widget with both resource and non + * resource values. + * Returns: none. + */ + +/* ARGSUSED */ +static void +Initialize(request, new) +Widget request, new; +{ + SimpleMenuWidget smw = (SimpleMenuWidget) new; + register SimpleMenuPart* smwp = (SimpleMenuPart*)&smw->simple_menu; + + XmuCallInitializers(XtWidgetToApplicationContext(new)); + + if (smwp->label_class == NULL) + smwp->label_class = smeBSBObjectClass; + + smwp->label = NULL; + smwp->entry_set = NULL; + smwp->recursive_set_values = False; + + if (smwp->label_string != NULL) + CreateLabel(new); + + smwp->menu_width = TRUE; + + if (smw->core.width == 0) + { + smwp->menu_width = False; + smw->core.width = GetMenuWidth(new, NULL); + } + + smwp->menu_height = TRUE; + + if (smw->core.height == 0) + { + smwp->menu_height = False; + smw->core.height = GetMenuHeight(new); + } + + + /* + * Top & Bottom Shadow GCs + */ + + if (smwp->top_shadow_pixmap == UnspecifiedPixmap) + smwp->top_shadow_pixmap = None; + + if (smwp->top_shadow_GC == NULL){ + if (smwp->top_shadow_pixmap != None) + smwp->top_shadow_GC = AllocGCFromPixmap (new, smwp->top_shadow_pixmap); + else + smwp->top_shadow_GC = AllocGCFromPixel (new, smwp->top_shadow_color); + } else if (smwp->top_shadow_GC == UndefinedGC) + smwp->top_shadow_GC = MakeTopShadowGC (new, new->core.background_pixel); + + + if (smwp->bottom_shadow_pixmap == UnspecifiedPixmap) + smwp->bottom_shadow_pixmap = None; + + if (smwp->bottom_shadow_GC == NULL){ + if (smwp->bottom_shadow_pixmap != None) + smwp->bottom_shadow_GC = + AllocGCFromPixmap (new, smwp->bottom_shadow_pixmap); + else + smwp->bottom_shadow_GC = + AllocGCFromPixel (new, smwp->bottom_shadow_color); + } else if (smwp->bottom_shadow_GC == UndefinedGC) + smwp->bottom_shadow_GC = + MakeBottomShadowGC (new, new->core.background_pixel); +} + +/* Function Name: Redisplay + * Description: Redisplays the contents of the widget. + * Arguments: w - the simple menu widget. + * event - the X event that caused this redisplay. + * region - the region the needs to be repainted. + * Returns: none. + */ + +/* ARGSUSED */ +static void Redisplay(w, event, region) + Widget w; + XEvent * event; + Region region; +{ + SimpleMenuWidget smw = (SimpleMenuWidget) w; + SmeObject * entry; + SmeObjectClass class; + + if (region == NULL) + XClearWindow(XtDisplay(w), XtWindow(w)); + + /* + * Check and Paint each of the entries + */ + + ForAllChildren(smw, entry) + if (XtIsManaged ((Widget)*entry)) + { + class = (SmeObjectClass) (*entry)->object.widget_class; + + if (class->rect_class.expose) + (*class->rect_class.expose) ((Widget)*entry, NULL, region); + } + + XawDrawFrame(w, + 0, 0, CORE(w).width, CORE(w).height, + SMW(w).frame_type, + SMW(w).shadow_thickness, + SMW(w).top_shadow_GC, + SMW(w).bottom_shadow_GC); + +} + +/* Function Name: Realize + * Description: Realizes the widget. + * Arguments: w - the simple menu widget. + * mask - value mask for the window to create. + * attrs - attributes for the window to create. + * Returns: none + */ + +static void +Realize(w, mask, attrs) +Widget w; +XtValueMask * mask; +XSetWindowAttributes * attrs; +{ + SimpleMenuWidget smw = (SimpleMenuWidget) w; + + attrs->cursor = smw->simple_menu.cursor; + *mask |= CWCursor; + if ((smw->simple_menu.backing_store == Always) || + (smw->simple_menu.backing_store == NotUseful) || + (smw->simple_menu.backing_store == WhenMapped) ) { + *mask |= CWBackingStore; + attrs->backing_store = smw->simple_menu.backing_store; + } + else + *mask &= ~CWBackingStore; + + *mask |= CWSaveUnder; + attrs->save_under = True; + + (*superclass->core_class.realize) (w, mask, attrs); +} + +/* Function Name: Resize + * Description: Handle the menu being resized bigger. + * Arguments: w - the simple menu widget. + * Returns: none. + */ + +static void Resize(w) + Widget w; +{ + SimpleMenuWidget smw = (SimpleMenuWidget) w; + SmeObject * entry; + + if ( !XtIsRealized(w) ) return; + + ForAllChildren(smw, entry) /* reset width of all entries. */ + if (XtIsManaged( (Widget) *entry)) { + (*entry)->rectangle.width = smw->core.width - + 2 * SMW(w).shadow_thickness; + (*entry)->rectangle.x = SMW(w).shadow_thickness; + } + + XClearWindow(XtDisplay(w), XtWindow(w)); + + Redisplay(w, (XEvent *) NULL, (Region) NULL); + +} + +/* Function Name: SetValues + * Description: Relayout the menu when one of the resources is changed. + * Arguments: current - current state of the widget. + * request - what was requested. + * new - what the widget will become. + * Returns: none + */ + +/* ARGSUSED */ +static Boolean SetValues(current, request, new) + Widget current; + Widget request; + Widget new; +{ + SimpleMenuWidget smw_old = (SimpleMenuWidget) current; + SimpleMenuWidget smw_new = (SimpleMenuWidget) new; + register SimpleMenuPart* smwp = (SimpleMenuPart*)&smw_new->simple_menu; + Boolean ret_val = False; + Boolean layout = False; + Boolean redisplay = False; + +#define NE(name) (smw_old->simple_menu.name != smw_new->simple_menu.name) + + if (!XtIsRealized(current)) + return False; + + if (!smw_new->simple_menu.recursive_set_values) + { + if (smw_new->core.width != smw_old->core.width) + { + smw_new->simple_menu.menu_width = (smw_new->core.width != 0); + layout = TRUE; + } + if (smw_new->core.height != smw_old->core.height) + { + smw_new->simple_menu.menu_height = (smw_new->core.height != 0); + layout = TRUE; + } + } + + if (NE(cursor)) + XDefineCursor(XtDisplay(new), + XtWindow(new), smw_new->simple_menu.cursor); + + if (NE(label_string)) + if (smw_new->simple_menu.label_string == NULL) /* Destroy. */ + XtDestroyWidget((Widget)smw_old->simple_menu.label); + else if (smw_old->simple_menu.label_string == NULL) /* Create. */ + CreateLabel(new); + else /* Change. */ + XtVaSetValues((Widget)smw_new->simple_menu.label, + XtNlabel, smw_new->simple_menu.label_string, + NULL); + + if (NE(label_class)) + XtAppWarning(XtWidgetToApplicationContext(new), + "No Dynamic class change of the SimpleMenu Label."); + + if (NE(top_margin) || NE(bottom_margin)) /* filler................. */ + { + layout = TRUE; + ret_val = TRUE; + } + + if (layout) + Layout(new, NULL, NULL); + { + + if ( NE(shadow_thickness) ) + redisplay = TRUE; + + if (NE(top_shadow_pixmap)) + { + + XtReleaseGC (new, smwp->top_shadow_GC); + smwp->top_shadow_GC = AllocGCFromPixmap (new, smwp->top_shadow_pixmap); + redisplay = True; + + } + else if (NE(top_shadow_color && smwp->top_shadow_pixmap)) + { + + XtReleaseGC (new, smwp->top_shadow_GC); + smwp->top_shadow_GC = AllocGCFromPixel (new, smwp->top_shadow_color); + redisplay = True; + + } + + if (NE(bottom_shadow_pixmap)) + { + + XtReleaseGC (new, smwp->bottom_shadow_GC); + smwp->bottom_shadow_GC = + AllocGCFromPixmap (new, smwp->bottom_shadow_pixmap); + + redisplay = True; + + } + else if (NE(bottom_shadow_color && smwp->bottom_shadow_pixmap)) + { + + XtReleaseGC (new, smwp->bottom_shadow_GC); + smwp->bottom_shadow_GC = + AllocGCFromPixel (new, smwp->bottom_shadow_color); + redisplay = True; + + } + +#undef NE + } + + return(ret_val || redisplay); +} + +/* Function Name: SetValuesHook + * Description: To handle a special case, this is passed the + * actual arguments. + * Arguments: w - the menu widget. + * arglist - the argument list passed to XtSetValues. + * num_args - the number of args. + * Returns: none + */ + +/* + * If the user actually passed a width and height to the widget + * then this MUST be used, rather than our newly calculated width and + * height. + */ + +static Boolean +SetValuesHook(w, arglist, num_args) +Widget w; +ArgList arglist; +Cardinal *num_args; +{ + register Cardinal i; + Dimension width, height; + + width = w->core.width; + height = w->core.height; + + for ( i = 0 ; i < *num_args ; i++) { + if ( streq(arglist[i].name, XtNwidth) ) + width = (Dimension) arglist[i].value; + if ( streq(arglist[i].name, XtNheight) ) + height = (Dimension) arglist[i].value; + } + + if ((width != w->core.width) || (height != w->core.height)) + MakeSetValuesRequest(w, width, height); + return(False); +} + +/************************************************************ + * + * Geometry Management routines. + * + ************************************************************/ + +/* Function Name: GeometryManager + * Description: This is the SimpleMenu Widget's Geometry Manager. + * Arguments: w - the Menu Entry making the request. + * request - requested new geometry. + * reply - the allowed geometry. + * Returns: XtGeometry{Yes, No, Almost}. + */ + +static XtGeometryResult +GeometryManager(w, request, reply) +Widget w; +XtWidgetGeometry * request, * reply; +{ + SimpleMenuWidget smw = (SimpleMenuWidget) XtParent(w); + SmeObject entry = (SmeObject) w; + XtGeometryMask mode = request->request_mode; + XtGeometryResult answer; + Dimension old_height, old_width; + + if ( !(mode & CWWidth) && !(mode & CWHeight) ) + return(XtGeometryNo); + + reply->width = request->width; + reply->height = request->height; + + old_width = entry->rectangle.width; + old_height = entry->rectangle.height; + + Layout(w, &(reply->width), &(reply->height) ); + +/* + * Since we are an override shell and have no parent there is no one to + * ask to see if this geom change is okay, so I am just going to assume + * we can do whatever we want. If you subclass be very careful with this + * assumption, it could bite you. + * + * Chris D. Peterson - Sept. 1989. + */ + + if ( (reply->width == request->width) && + (reply->height == request->height) ) { + + if ( mode & XtCWQueryOnly ) { /* Actually perform the layout. */ + entry->rectangle.width = old_width; + entry->rectangle.height = old_height; + } + else { + Layout(( Widget) smw, NULL, NULL); + } + answer = XtGeometryDone; + } + else { + entry->rectangle.width = old_width; + entry->rectangle.height = old_height; + + if ( ((reply->width == request->width) && !(mode & CWHeight)) || + ((reply->height == request->height) && !(mode & CWWidth)) || + ((reply->width == request->width) && + (reply->height == request->height)) ) + answer = XtGeometryNo; + else { + answer = XtGeometryAlmost; + reply->request_mode = 0; + if (reply->width != request->width) + reply->request_mode |= CWWidth; + if (reply->height != request->height) + reply->request_mode |= CWHeight; + } + } + return(answer); +} + +/* Function Name: ChangeManaged + * Description: called whenever a new child is managed. + * Arguments: w - the simple menu widget. + * Returns: none. + */ + +static void +ChangeManaged(w) +Widget w; +{ + Layout(w, NULL, NULL); +} + +/************************************************************ + * + * Global Action Routines. + * + * These actions routines will be added to the application's + * global action list. + * + ************************************************************/ + +/* Function Name: PositionMenuAction + * Description: Positions the simple menu widget. + * Arguments: w - a widget (no the simple menu widget.) + * event - the event that caused this action. + * params, num_params - parameters passed to the routine. + * we expect the name of the menu here. + * Returns: none + */ + +/* ARGSUSED */ +static void +PositionMenuAction(w, event, params, num_params) +Widget w; +XEvent * event; +String * params; +Cardinal * num_params; +{ + Widget menu; + XPoint loc; + + if (*num_params != 1) { + char error_buf[BUFSIZ]; + sprintf(error_buf, "%s %s", + "Xaw - SimpleMenuWidget: position menu action expects only one", + "parameter which is the name of the menu."); + XtAppWarning(XtWidgetToApplicationContext(w), error_buf); + return; + } + + if ( (menu = FindMenu(w, params[0])) == NULL) { + char error_buf[BUFSIZ]; + sprintf(error_buf, "%s '%s'", + "Xaw - SimpleMenuWidget: could not find menu named: ", params[0]); + XtAppWarning(XtWidgetToApplicationContext(w), error_buf); + return; + } + + switch (event->type) { + case ButtonPress: + case ButtonRelease: + loc.x = event->xbutton.x_root; + loc.y = event->xbutton.y_root; + PositionMenu(menu, &loc); + break; + case EnterNotify: + case LeaveNotify: + loc.x = event->xcrossing.x_root; + loc.y = event->xcrossing.y_root; + PositionMenu(menu, &loc); + break; + case MotionNotify: + loc.x = event->xmotion.x_root; + loc.y = event->xmotion.y_root; + PositionMenu(menu, &loc); + break; + default: + PositionMenu(menu, NULL); + break; + } +} + +/************************************************************ + * + * Widget Action Routines. + * + ************************************************************/ + +/* Function Name: Unhighlight + * Description: Unhighlights current entry. + * Arguments: w - the simple menu widget. + * event - the event that caused this action. + * params, num_params - ** NOT USED ** + * Returns: none + */ + +/* ARGSUSED */ +static void +Unhighlight(w, event, params, num_params) +Widget w; +XEvent * event; +String * params; +Cardinal * num_params; +{ + SimpleMenuWidget smw = (SimpleMenuWidget) w; + SmeObject entry = smw->simple_menu.entry_set; + SmeObjectClass class; + + if ( entry == NULL) return; + + smw->simple_menu.entry_set = NULL; + class = (SmeObjectClass) entry->object.widget_class; + (class->sme_class.unhighlight) ( (Widget) entry); +} + +/* Function Name: Highlight + * Description: Highlights current entry. + * Arguments: w - the simple menu widget. + * event - the event that caused this action. + * params, num_params - ** NOT USED ** + * Returns: none + */ + +/* ARGSUSED */ +static void +Highlight(w, event, params, num_params) +Widget w; +XEvent * event; +String * params; +Cardinal * num_params; +{ + SimpleMenuWidget smw = (SimpleMenuWidget) w; + SmeObject entry; + SmeObjectClass class; + + if ( !XtIsSensitive(w) ) return; + + entry = GetEventEntry(w, event); + + if (entry == smw->simple_menu.entry_set) return; + + Unhighlight(w, event, params, num_params); + + if (entry == NULL) return; + + if ( !XtIsSensitive( (Widget) entry)) { + smw->simple_menu.entry_set = NULL; + return; + } + + smw->simple_menu.entry_set = entry; + class = (SmeObjectClass) entry->object.widget_class; + + (class->sme_class.highlight) ( (Widget) entry); +} + +/* Function Name: Notify + * Description: Notify user of current entry. + * Arguments: w - the simple menu widget. + * event - the event that caused this action. + * params, num_params - ** NOT USED ** + * Returns: none + */ + +/* ARGSUSED */ +static void +Notify(w, event, params, num_params) +Widget w; +XEvent * event; +String * params; +Cardinal * num_params; +{ + SimpleMenuWidget smw = (SimpleMenuWidget) w; + SmeObject entry = smw->simple_menu.entry_set; + SmeObjectClass class; + + if ( (entry == NULL) || !XtIsSensitive((Widget) entry) ) return; + + class = (SmeObjectClass) entry->object.widget_class; + (class->sme_class.notify)( (Widget) entry ); +} + +/************************************************************ + * + * Public Functions. + * + ************************************************************/ + +/* Function Name: XawSimpleMenuAddGlobalActions + * Description: adds the global actions to the simple menu widget. + * Arguments: app_con - the appcontext. + * Returns: none. + */ + +void +XawSimpleMenuAddGlobalActions(app_con) +XtAppContext app_con; +{ + XtInitializeWidgetClass(simpleMenuWidgetClass); + XmuCallInitializers( app_con ); +} + + +/* Function Name: XawSimpleMenuGetActiveEntry + * Description: Gets the currently active (set) entry. + * Arguments: w - the smw widget. + * Returns: the currently set entry or NULL if none is set. + */ + +Widget +XawSimpleMenuGetActiveEntry(w) +Widget w; +{ + SimpleMenuWidget smw = (SimpleMenuWidget) w; + + return( (Widget) smw->simple_menu.entry_set); +} + +/* Function Name: XawSimpleMenuClearActiveEntry + * Description: Unsets the currently active (set) entry. + * Arguments: w - the smw widget. + * Returns: none. + */ + +void +XawSimpleMenuClearActiveEntry(w) +Widget w; +{ + SimpleMenuWidget smw = (SimpleMenuWidget) w; + + smw->simple_menu.entry_set = NULL; +} + +/************************************************************ + * + * Private Functions. + * + ************************************************************/ + +/* Function Name: CreateLabel + * Description: Creates a the menu label. + * Arguments: w - the smw widget. + * Returns: none. + * + * Creates the label object and makes sure it is the first child in + * in the list. + */ + +static void +CreateLabel(w) +Widget w; +{ + SimpleMenuWidget smw = (SimpleMenuWidget) w; + register Widget * child, * next_child; + register int i; + Arg args[2]; + + if ( (smw->simple_menu.label_string == NULL) || + (smw->simple_menu.label != NULL) ) { + char error_buf[BUFSIZ]; + + sprintf(error_buf, "Xaw Simple Menu Widget: %s or %s, %s", + "label string is NULL", "label already exists", + "no label is being created."); + XtAppWarning(XtWidgetToApplicationContext(w), error_buf); + return; + } + + XtSetArg(args[0], XtNlabel, smw->simple_menu.label_string); + XtSetArg(args[1], XtNjustify, XtJustifyCenter); + smw->simple_menu.label = (SmeObject) + XtCreateManagedWidget("menuLabel", + smw->simple_menu.label_class, w, + args, TWO); + + next_child = NULL; + for (child = smw->composite.children + smw->composite.num_children, + i = smw->composite.num_children ; i > 0 ; i--, child--) { + if (next_child != NULL) + *next_child = *child; + next_child = child; + } + *child = (Widget) smw->simple_menu.label; +} + +/* Function Name: Layout + * Description: lays the menu entries out all nice and neat. + * Arguments: w - See below (+++) + * width_ret, height_ret - The returned width and + * height values. + * Returns: none. + * + * if width == NULL || height == NULL then it assumes the you do not care + * about the return values, and just want a relayout. + * + * if this is not the case then it will set width_ret and height_ret + * to be width and height that the child would get if it were layed out + * at this time. + * + * +++ "w" can be the simple menu widget or any of its object children. + */ + +static void +Layout(w, width_ret, height_ret) +Widget w; +Dimension *width_ret, *height_ret; +{ + SmeObject current_entry, *entry; + SimpleMenuWidget smw; + Dimension width, height; + Boolean do_layout = ((height_ret == NULL) || (width_ret == NULL)); + Boolean allow_change_size; + height = 0; + + if ( XtIsSubclass(w, simpleMenuWidgetClass) ) { + smw = (SimpleMenuWidget) w; + current_entry = NULL; + } + else { + smw = (SimpleMenuWidget) XtParent(w); + current_entry = (SmeObject) w; + } + + allow_change_size = (!XtIsRealized((Widget)smw) || + (smw->shell.allow_shell_resize)); + + if ( smw->simple_menu.menu_height ) + height = smw->core.height; + else + if (do_layout) { + height = smw->simple_menu.top_margin; + height += smw->simple_menu.shadow_thickness; + ForAllChildren(smw, entry) { + if (!XtIsManaged( (Widget) *entry)) continue; + + if ( (smw->simple_menu.row_height != 0) && + (*entry != smw->simple_menu.label) ) + (*entry)->rectangle.height = smw->simple_menu.row_height; + + (*entry)->rectangle.y = height; + (*entry)->rectangle.x = smw->simple_menu.shadow_thickness; + height += (*entry)->rectangle.height; + } + height += smw->simple_menu.bottom_margin; + height += smw->simple_menu.shadow_thickness; + } + else { + if ((smw->simple_menu.row_height != 0) && + (current_entry != smw->simple_menu.label) ) + height = smw->simple_menu.row_height; + } + + if (smw->simple_menu.menu_width) + width = smw->core.width; + else if ( allow_change_size ){ + width = GetMenuWidth((Widget) smw, (Widget) current_entry); + width +=2*smw->simple_menu.shadow_thickness; + } + else + width = smw->core.width; + + if (do_layout) { + ForAllChildren(smw, entry) + if (XtIsManaged( (Widget) *entry)) + (*entry)->rectangle.width = width - + 2*smw->simple_menu.shadow_thickness; + + if (allow_change_size) + MakeSetValuesRequest((Widget) smw, width, height); + } + else { + *width_ret = width; + if (height != 0) + *height_ret = height; + } +} + +/* Function Name: AddPositionAction + * Description: Adds the XawPositionSimpleMenu action to the global + * action list for this appcon. + * Arguments: app_con - the application context for this app. + * data - NOT USED. + * Returns: none. + */ + +/* ARGSUSED */ +static void +AddPositionAction(app_con, data) +XtAppContext app_con; +XtPointer data; +{ + static XtActionsRec pos_action[] = { + { "XawPositionSimpleMenu", PositionMenuAction }, + }; + + XtAppAddActions(app_con, pos_action, XtNumber(pos_action)); +} + +/* Function Name: FindMenu + * Description: Find the menu give a name and reference widget. + * Arguments: widget - reference widget. + * name - the menu widget's name. + * Returns: the menu widget or NULL. + */ + +static Widget +FindMenu(widget, name) +Widget widget; +String name; +{ + register Widget w, menu; + + for ( w = widget ; w != NULL ; w = XtParent(w) ) + if ( (menu = XtNameToWidget(w, name)) != NULL ) + return(menu); + return(NULL); +} + +/* Function Name: MoveMenu + * Description: Actually moves the menu, may force it to + * to be fully visable if menu_on_screen is TRUE. + * Arguments: w - the simple menu widget. + * x, y - the current location of the widget. + * Returns: none + */ + +static void +MoveMenu(w, x, y) +Widget w; +Position x, y; +{ + Arg arglist[2]; + Cardinal num_args = 0; + SimpleMenuWidget smw = (SimpleMenuWidget) w; + + if (smw->simple_menu.menu_on_screen) { + int width = w->core.width + 2 * w->core.border_width; + int height = w->core.height + 2 * w->core.border_width; + + if (x < 0) + x = 0; + else { + int scr_width = WidthOfScreen(XtScreen(w)); + if (x + width > scr_width) + x = scr_width - width; + } + + if (y < 0) + y = 0; + else { + int scr_height = HeightOfScreen(XtScreen(w)); + if (y + height > scr_height) + y = scr_height - height; + } + } + + XtSetArg(arglist[num_args], XtNx, x); num_args++; + XtSetArg(arglist[num_args], XtNy, y); num_args++; + XtSetValues(w, arglist, num_args); +} + +/* Function Name: PositionMenu + * Description: Places the menu + * Arguments: w - the simple menu widget. + * location - a pointer the the position or NULL. + * Returns: none. + */ + +static void +PositionMenu(w, location) +Widget w; +XPoint * location; +{ + SimpleMenuWidget smw = (SimpleMenuWidget) w; + SmeObject entry; + XPoint t_point; + + if (location == NULL) { + Window junk1, junk2; + int root_x, root_y, junkX, junkY; + unsigned int junkM; + + location = &t_point; + if (XQueryPointer(XtDisplay(w), XtWindow(w), &junk1, &junk2, + &root_x, &root_y, &junkX, &junkY, &junkM) == False) { + char error_buf[BUFSIZ]; + sprintf(error_buf, "%s %s", "Xaw - SimpleMenuWidget:", + "Could not find location of mouse pointer"); + XtAppWarning(XtWidgetToApplicationContext(w), error_buf); + return; + } + location->x = (short) root_x; + location->y = (short) root_y; + } + + /* + * The width will not be correct unless it is realized. + */ + + XtRealizeWidget(w); + + location->x -= (Position) w->core.width/2; + + if (smw->simple_menu.popup_entry == NULL) + entry = smw->simple_menu.label; + else + entry = smw->simple_menu.popup_entry; + + if (entry != NULL) + location->y -= entry->rectangle.y + entry->rectangle.height/2; + + MoveMenu(w, (Position) location->x, (Position) location->y); +} + +/* Function Name: MakeSetValuesRequest + * Description: Makes a (possibly recursive) call to SetValues, + * I take great pains to not go into an infinite loop. + * Arguments: w - the simple menu widget. + * width, height - the size of the ask for. + * Returns: none + */ + +static void +MakeSetValuesRequest(w, width, height) +Widget w; +Dimension width, height; +{ + SimpleMenuWidget smw = (SimpleMenuWidget) w; + Arg arglist[2]; + Cardinal num_args = (Cardinal) 0; + + if ( !smw->simple_menu.recursive_set_values ) { + if ( (smw->core.width != width) || (smw->core.height != height) ) { + smw->simple_menu.recursive_set_values = TRUE; + XtSetArg(arglist[num_args], XtNwidth, width); num_args++; + XtSetArg(arglist[num_args], XtNheight, height); num_args++; + XtSetValues(w, arglist, num_args); + } + else if (XtIsRealized( (Widget) smw)) + Redisplay((Widget) smw, (XEvent *) NULL, (Region) NULL); + } + smw->simple_menu.recursive_set_values = False; +} + +/* Function Name: GetMenuWidth + * Description: Sets the length of the widest entry in pixels. + * Arguments: w - the simple menu widget. + * Returns: width of menu. + */ + +static Dimension +GetMenuWidth(w, w_ent) +Widget w, w_ent; +{ + SmeObject cur_entry = (SmeObject) w_ent; + SimpleMenuWidget smw = (SimpleMenuWidget) w; + Dimension width, widest = (Dimension) 0; + SmeObject * entry; + + if ( smw->simple_menu.menu_width ) + return(smw->core.width); + + ForAllChildren(smw, entry) { + XtWidgetGeometry preferred; + + if (!XtIsManaged( (Widget) *entry)) continue; + + if (*entry != cur_entry) { + XtQueryGeometry((Widget)*entry, NULL, &preferred); + + if (preferred.request_mode & CWWidth) + width = preferred.width; + else + width = (*entry)->rectangle.width; + } + else + width = (*entry)->rectangle.width; + + if ( width > widest ) + widest = width; + } + + return(widest); +} + +/* Function Name: GetMenuHeight + * Description: Sets the length of the widest entry in pixels. + * Arguments: w - the simple menu widget. + * Returns: width of menu. + */ + +static Dimension +GetMenuHeight(w) +Widget w; +{ + SimpleMenuWidget smw = (SimpleMenuWidget) w; + SmeObject * entry; + Dimension height; + + if (smw->simple_menu.menu_height) + return(smw->core.height); + + height = smw->simple_menu.top_margin + smw->simple_menu.bottom_margin; + + if (smw->simple_menu.row_height == 0) + ForAllChildren(smw, entry) + if (XtIsManaged ((Widget) *entry)) + height += (*entry)->rectangle.height; + else + height += smw->simple_menu.row_height * smw->composite.num_children; + + return(height); +} + +/* Function Name: GetEventEntry + * Description: Gets an entry given an event that has X and Y coords. + * Arguments: w - the simple menu widget. + * event - the event. + * Returns: the entry that this point is in. + */ + +static SmeObject +GetEventEntry(w, event) +Widget w; +XEvent * event; +{ + Position x_loc, y_loc; + SimpleMenuWidget smw = (SimpleMenuWidget) w; + SmeObject * entry; + + switch (event->type) { + case MotionNotify: + x_loc = event->xmotion.x; + y_loc = event->xmotion.y; + break; + case EnterNotify: + case LeaveNotify: + x_loc = event->xcrossing.x; + y_loc = event->xcrossing.y; + break; + case ButtonPress: + case ButtonRelease: + x_loc = event->xbutton.x; + y_loc = event->xbutton.y; + break; + default: + XtAppError(XtWidgetToApplicationContext(w), + "Unknown event type in GetEventEntry()."); + break; + } + + if ( (x_loc < 0) || (x_loc >= smw->core.width) || (y_loc < 0) || + (y_loc >= smw->core.height) ) + return(NULL); + + ForAllChildren(smw, entry) { + if (!XtIsManaged ((Widget) *entry)) continue; + + if ( ((*entry)->rectangle.y <= y_loc) && + ((*entry)->rectangle.y + (*entry)->rectangle.height >= y_loc) ) + if ( *entry == smw->simple_menu.label ) + return(NULL); /* cannot select the label. */ + else + return(*entry); + } + + return(NULL); +} diff --git a/vendor/x11iraf/obm/ObmW/zz/SimpleMenu.h b/vendor/x11iraf/obm/ObmW/zz/SimpleMenu.h new file mode 100644 index 00000000..752be892 --- /dev/null +++ b/vendor/x11iraf/obm/ObmW/zz/SimpleMenu.h @@ -0,0 +1,169 @@ +/* + * $XConsortium: SimpleMenu.h,v 1.17 89/12/11 15:01:55 kit Exp $ + * + * 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. + * + * Author: Chris D. Peterson, MIT X Consortium + */ + +/* + * SimpleMenu.h - Public Header file for SimpleMenu widget. + * + * This is the public header file for the Athena SimpleMenu widget. + * It is intended to provide one pane pulldown and popup menus within + * the framework of the X Toolkit. As the name implies it is a first and + * by no means complete implementation of menu code. It does not attempt to + * fill the needs of all applications, but does allow a resource oriented + * interface to menus. + * + * Date: April 3, 1989 + * + * By: Chris D. Peterson + * MIT X Consortium + * kit@expo.lcs.mit.edu + */ + +#ifndef _SimpleMenu_h +#define _SimpleMenu_h + +#include <X11/Shell.h> +#include <X11/Xmu/Converters.h> + +/**************************************************************** + * + * SimpleMenu widget + * + ****************************************************************/ + +/* SimpleMenu Resources: + + Name Class RepType Default Value + ---- ----- ------- ------------- + background Background Pixel XtDefaultBackground + backgroundPixmap BackgroundPixmap Pixmap None + borderColor BorderColor Pixel XtDefaultForeground + borderPixmap BorderPixmap Pixmap None + borderWidth BorderWidth Dimension 1 + bottomMargin VerticalMargins Dimension VerticalSpace + columnWidth ColumnWidth Dimension Width of widest text + cursor Cursor Cursor None + destroyCallback Callback Pointer NULL + height Height Dimension 0 + label Label String NULL (No label) + labelClass LabelClass Pointer smeBSBObjectClass + mappedWhenManaged MappedWhenManaged Boolean True + rowHeight RowHeight Dimension Height of Font + sensitive Sensitive Boolean True + topMargin VerticalMargins Dimension VerticalSpace + width Width Dimension 0 + x Position Position 0 + y Position Position 0 + +*/ + +typedef struct _SimpleMenuClassRec* SimpleMenuWidgetClass; +typedef struct _SimpleMenuRec* SimpleMenuWidget; + +extern WidgetClass simpleMenuWidgetClass; + +#define XtNcursor "cursor" +#define XtNbottomMargin "bottomMargin" +#define XtNcolumnWidth "columnWidth" +#define XtNlabelClass "labelClass" +#define XtNmenuOnScreen "menuOnScreen" +#define XtNpopupOnEntry "popupOnEntry" +#define XtNrowHeight "rowHeight" +#define XtNtopMargin "topMargin" + +#define XtCColumnWidth "ColumnWidth" +#define XtCLabelClass "LabelClass" +#define XtCMenuOnScreen "MenuOnScreen" +#define XtCPopupOnEntry "PopupOnEntry" +#define XtCRowHeight "RowHeight" +#define XtCVerticalMargins "VerticalMargins" + +/* New fields */ +#define XtNshadowWidth "shadowWidth" +#define XtCShadowWidth "ShadowWidth" +#define XtNbsbShadowWidth "bsbShadowWidth" +#define XtCBsbShadowWidth "BsbShadowWidth" +#define XtNtopShadowPixel "topShadowPixel" +#define XtCTopShadowPixel "TopShadowPixel" +#define XtNbottomShadowPixel "bottomShadowPixel" +#define XtCBottomShadowPixel "BottomShadowPixel" +#define XtNtopShadowContrast "topShadowContrast" +#define XtCTopShadowContrast "TopShadowContrast" +#define XtNbottomShadowContrast "bottomShadowContrast" +#define XtCBottomShadowContrast "BottomShadowContrast" +#define XtNbeNiceToColormap "beNiceToColormap" +#define XtCBeNiceToColormap "BeNiceToColormap" +#define XtNtopShadowPixmap "topShadowPixmap" +#define XtCTopShadowPixmap "TopShadowPixmap" +#define XtNbottomShadowPixmap "bottomShadowPixmap" +#define XtCBottomShadowPixmap "BottomShadowPixmap" +#define XtNuserData "userData" +#define XtCUserData "UserData" +#define XtNframeType "frameType" +#define XtCFrameType "FrameType" +#define XtRFrameType "FrameType" + +/************************************************************ + * + * Public Functions. + * + ************************************************************/ + +/* Function Name: XawSimpleMenuAddGlobalActions + * Description: adds the global actions to the simple menu widget. + * Arguments: app_con - the appcontext. + * Returns: none. + */ + +void +XawSimpleMenuAddGlobalActions(/* app_con */); +/* +XtAppContext app_con; +*/ + +/* Function Name: XawSimpleMenuGetActiveEntry + * Description: Gets the currently active (set) entry. + * Arguments: w - the smw widget. + * Returns: the currently set entry or NULL if none is set. + */ + +Widget +XawSimpleMenuGetActiveEntry( /* w */); +/* +Widget w; +*/ + +/* Function Name: XawSimpleMenuClearActiveEntry + * Description: Unsets the currently active (set) entry. + * Arguments: w - the smw widget. + * Returns: none. + */ + +void +XawSimpleMenuClearActiveEntry(/* w */); +/* +Widget w; +*/ + +#endif /* _SimpleMenu_h */ diff --git a/vendor/x11iraf/obm/ObmW/zz/SimpleP.h b/vendor/x11iraf/obm/ObmW/zz/SimpleP.h new file mode 100644 index 00000000..f4044709 --- /dev/null +++ b/vendor/x11iraf/obm/ObmW/zz/SimpleP.h @@ -0,0 +1,62 @@ +#ifndef _SimpleP_h +#define _SimpleP_h + +#include <X11/IntrinsicP.h> + +#include <X11/Xraw/XawInit.h> +#include <X11/Xraw/Simple.h> + +#define SIMPLE(w) ((SimpleWidget) w)->simple + +typedef Boolean (*XawDisplayRectProc) Xraw_PROTO((Widget, XRectangle * )); +typedef Boolean (*XawChangeSensitive) Xraw_PROTO((Widget)); + +typedef struct { + XawChangeSensitive change_sensitive; + XawDisplayRectProc display_rect; + caddr_t extension; +} SimpleClassPart; + +typedef struct _SimpleClassRec { + CoreClassPart core_class; + SimpleClassPart simple_class; +} SimpleClassRec; + +extern SimpleClassRec simpleClassRec; + +typedef struct { + /* resources */ + Cursor cursor; + Pixmap insensitive_border; + Pixel foreground; + + Dimension shadow_thickness; + Pixel top_shadow_color; + Pixmap top_shadow_pixmap; + Pixel bottom_shadow_color; + Pixmap bottom_shadow_pixmap; + Pixel highlight_color; + Pixmap highlight_pixmap; + Dimension highlight_thickness; + + caddr_t user_data; + + /* private state */ + GC top_shadow_GC; + GC bottom_shadow_GC; + GC highlight_GC; +} SimplePart; + +typedef struct _SimpleRec { + CorePart core; + SimplePart simple; +} SimpleRec; + +#define SIMPLE_MARGIN(w) (((SimpleWidget)w)->simple.highlight_thickness + \ + ((SimpleWidget)w)->simple.shadow_thickness) + +#define XtSimpleClass(w) ((SimpleWidgetClass)XtClass(w)) +#define XtInheritDisplayRectProc ((Boolean (*)())_XtInherit) +#define XtInheritChangeSensitive ((Boolean (*)())_XtInherit) + +#endif /* _SimpleP_h */ diff --git a/vendor/x11iraf/obm/ObmW/zz/Table.c b/vendor/x11iraf/obm/ObmW/zz/Table.c new file mode 100644 index 00000000..a5387810 --- /dev/null +++ b/vendor/x11iraf/obm/ObmW/zz/Table.c @@ -0,0 +1,4529 @@ +/*********************************************************************** + + Table widget + Copyright by Vladimir T. Romanovski + All rights reserved. + +This library is designed for free, non-commercial software creation. +It is changeable and can be improved. The author would greatly appreciate +any advice, new components and patches of the existing programs. +Commercial usage is also possible with participation of the author. + + romsky@hp1.oea.ihep.su (Russia) + romsky@munin.ucsf.edu (USA) + +*************************************************************************/ + +#include <stdio.h> +#include <stdlib.h> +#include <ctype.h> + +#include <X11/Xatom.h> +#include <X11/IntrinsicP.h> +#include <X11/RectObjP.h> +#include <X11/StringDefs.h> +#include <X11/keysym.h> +#include <X11/Xos.h> + +#include <X11/Xmu/Atoms.h> +#include <X11/Xmu/Converters.h> +#include <X11/Xmu/Drawing.h> + +#include <X11/Xraw/XawInit.h> +#include <X11/Xraw/3d.h> +#include <X11/Xraw/TableP.h> +#include <X11/Xraw/Frame.h> +#include <X11/Xraw/AsciiText.h> +#include <X11/Xraw/Viewport.h> +#include <X11/Xraw/Scrollbar.h> +#include <X11/Xraw/ScrolledTable.h> + +#ifdef EBUG_XRAW_MALLOC +#include <dbmalloc/malloc.h> +#endif + +#define MULTI_LINE_TABLE 32767 + + +#undef CELL_IN /* */ + +#ifdef MIN +#undef MIN +#endif +#define MIN(a,b) ((a)<(b) ? (a) : (b)) + +#ifdef MAX +#undef MAX +#endif +#define MAX(a,b) ((a) > (b) ? (a) : (b)) + +#define CALLOC(num,type) (num * sizeof(type) <= 0 ? (type*)NULL : \ + (type*)XtMalloc((Cardinal)(num) * (Cardinal)sizeof(type))) + +#define NOT_A_CUT_BUFFER (-1) + +#define MAXCUT 30000 +#define EDIT(w) (((XawTableWidget) w)->table.edit) +#define InRange(n,a,b) MAX(a,MIN(n,b)) + +#define LEFT_EDGE(tw) (((XawTableWidget)tw)->table.internal_width + \ + ((XawTableWidget)tw)->table.label_shadow_thickness) + +#define TOP_EDGE(tw) (((XawTableWidget)tw)->table.internal_height + \ + ((XawTableWidget)tw)->table.label_shadow_thickness) + +#define CELL(field) cell->field +#define STUFF(w) ((XawTableWidget)w)->table.table_stuff +#define COLUMNS(w) ((XawTableWidget)w)->table.columns +#define ROWS(w) ((XawTableWidget)w)->table.rows +#define GET_CELL_LABEL ((CELL(label) == NULL ? Dummy : CELL(label))) + +#define COLUMN_DATA(tw) ((XawTableColumnRec*)tw->table.column_data) +#define COLUMN_WIDTH(tw,column) \ +(tw->table.literal ? \ + ( \ + (COLUMN_DATA(tw)[column].flag & _CL_width) ?\ + COLUMN_DATA(tw)[column].width : \ + tw->table.column_default_width \ + ) \ + * tw->table.literal_width + \ + 2 * tw->table.internal_width \ + : \ + ( \ + (COLUMN_DATA(tw)[column].flag & _CL_width) ?\ + COLUMN_DATA(tw)[column].width : \ + tw->table.column_default_width \ + ) \ +/* _COLUMN_WIDTH_ */) + + +#define MANAGE_EDIT(tw) \ + if ( ! XtIsManaged(EDIT(tw))) \ + { \ + XtManageChild (EDIT(tw)); \ + XtSetKeyboardFocus ((Widget)tw, EDIT(tw)); \ + } + + +#define UNMANAGE_EDIT(tw) \ + if ( XtIsManaged(EDIT(tw))) \ + { \ + XtUnmanageChild (tw->table.edit); \ + XtSetKeyboardFocus((Widget)tw, (Widget)None); \ + } + + +#define DO_CALLBACK(w,callback,data) \ + if (XtCallbackHasSome == XtHasCallbacks(w, callback)) \ + XtCallCallbacks (w, callback, (XtPointer)&data) + + +#define IsEditInRowColumn(tw, row, column) \ + (XtIsManaged(EDIT(tw)) && (row == tw->table.edit_row) \ + && (column == tw->table.edit_column)) + + + +#define REJECT (-1) +#define ACCEPT (0) + +#define CHECK_TABLE(tw) \ + _check_table ((XtPointer)STUFF(tw), ROWS(tw), COLUMNS(tw)); \ + CheckAllLabels(tw) + + + +typedef struct _XawTableCellRec { + /* Node communication entity */ + XawTableNodeRec node; + /* Cell label entity */ + char *label; + Position label_x; + Dimension label_width; + Dimension label_len; + /* Cell colour entity */ + Boolean highlight; + Boolean special_colour; + Pixel fore; + Pixel back; + GC normal; + GC reverse; + GC top; + GC bottom; + +}XawTableCellRec; + +#define _CL_width (1L<<0) +#define _CL_font (1L<<1) +#define _CL_label (1L<<2) +#define _CL_justify (1L<<3) +#define _CL_background (1L<<4) +#define _CL_foreground (1L<<5) + +typedef struct _XawTableColumnRec { + int flag; + int width; + XFontStruct *font; + char *label; + XtJustify justify; + Pixel background; + Pixel foreground; + GC normal; + GC reverse; + GC top; + GC bottom; +}XawTableColumnRec; + + +#ifdef CRAY +#define WORD64 +#endif + +/**************************************************************** + * + * Full class record constant + * + ****************************************************************/ + +/* Private Data */ + +static void Def_pixel(); +static void Def_scroll(); +static void Def_column_default_width(); +static void Def_literal_width(); +static void Def_shadow_thickness(); + +#define Offset(field) XtOffsetOf(TableRec, field) + +static XtResource resources[] = { + { + XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel), + Offset(table.foreground), XtRString, XtDefaultForeground + }, + { + XtNeditForeground, XtCForeground, XtRPixel, sizeof(Pixel), + Offset(table.edit_fore), XtRCallProc, (XtPointer)Def_pixel + }, + { + XtNeditBackground, XtCBackground, XtRPixel, sizeof(Pixel), + Offset(table.edit_back), XtRCallProc, (XtPointer)Def_pixel + }, + { + XtNrowForeground, XtCForeground, XtRPixel, sizeof(Pixel), + Offset(table.row_fore), XtRCallProc, (XtPointer)Def_pixel + }, + { + XtNcolumnForeground, XtCForeground, XtRPixel, sizeof(Pixel), + Offset(table.column_fore), XtRCallProc, (XtPointer)Def_pixel + }, + { + XtNfont, XtCFont, XtRFontStruct, sizeof(XFontStruct *), + Offset(table.font), XtRString, XtDefaultFont + }, + { + XtNliteral, XtCLiteral, XtRBoolean, sizeof(Boolean), + Offset(table.literal), XtRImmediate, (XtPointer)False + }, + { + XtNrowOriented, XtCRowOriented, XtRBoolean, sizeof(Boolean), + Offset(table.row_oriented), XtRImmediate, (XtPointer)True + }, + { + XtNmaskNumber, XtCMaskNumber, XtRInt, sizeof(int), + Offset(table.mask_number), XtRImmediate, (XtPointer)7 + }, + { + XtNcolumns, XtCColumns, XtRInt, sizeof(int), + Offset(table.columns), XtRImmediate, (XtPointer)0 + }, + { + XtNrows, XtCRows, XtRInt, sizeof(int), + Offset(table.rows), XtRImmediate, (XtPointer)0 + }, + { + XtNtableMargin, XtCTableMargin, XtRDimension, sizeof(Dimension), + Offset(table.tab_margin), XtRImmediate, (XtPointer)2 + }, + { + XtNrowMargin, XtCRowMargin, XtRDimension, sizeof(Dimension), + Offset(table.row_margin), XtRImmediate, (XtPointer)2 + }, + { + XtNcolumnMargin, XtCColumnMargin, XtRDimension, sizeof(Dimension), + Offset(table.col_margin), XtRImmediate, (XtPointer)2 + }, + { + XtNlabelShadowWidth, XtCLabelShadowWidth, XtRDimension, + sizeof(Dimension), Offset(table.label_shadow_thickness), XtRImmediate, + (XtPointer)1 + }, + { + XtNjustify, XtCJustify, XtRJustify, sizeof(XtJustify), + Offset(table.justify), XtRImmediate, (XtPointer)XtJustifyCenter + }, + { + XtNinternalWidth, XtCWidth, XtRDimension, sizeof(Dimension), + Offset(table.internal_width), XtRImmediate, (XtPointer)4 + }, + { + XtNinternalHeight, XtCHeight, XtRDimension, sizeof(Dimension), + Offset(table.internal_height), XtRImmediate, (XtPointer)2 + }, + { + XtNencoding, XtCEncoding, XtRUnsignedChar, sizeof(unsigned char), + Offset(table.encoding), XtRImmediate, (XtPointer)XawTextEncoding8bit + }, + { + XtNshadowWidth, XtCShadowWidth, XtRDimension, sizeof(Dimension), + Offset(container.shadow_thickness), XtRCallProc, + (XtPointer) Def_shadow_thickness + }, + { + XtNvetricalScroll, XtCScroll, XtRWidget, sizeof(Widget), + Offset(table.v_scroll), XtRCallProc, (XtPointer)Def_scroll + }, + { + XtNhorizontalScroll, XtCScroll, XtRWidget, sizeof(Widget), + Offset(table.h_scroll), XtRCallProc, (XtPointer)Def_scroll + }, + { + XtNrowHeight, XtCRowHeight, XtRInt, sizeof(int), + Offset(table.row_height), XtRImmediate, (XtPointer)0 + }, + { + XtNdefaultWidth, XtCDefaultWidth, XtRInt, sizeof(int), + Offset(table.column_default_width), XtRCallProc, + (XtPointer) Def_column_default_width + }, + { + XtNeditable, XtCEditable, XtRBoolean, sizeof(Boolean), + Offset(table.editable), XtRImmediate, (XtPointer) TRUE + }, + { + XtNliteralWidth, XtCLiteralWidth, XtRInt, sizeof(int), + Offset(table.literal_width), XtRCallProc, (XtPointer) Def_literal_width + }, + + /* ALLOWANCE CALLBACKS */ + { + XtNallowAddColumn, XtCCallback, XtRCallback, sizeof(XtPointer), + Offset(table.allow_add_column), XtRCallback, NULL + }, + { + XtNallowAddRow, XtCCallback, XtRCallback, sizeof(XtPointer), + Offset(table.allow_add_row), XtRCallback, NULL + }, + { + XtNallowDeleteColumn, XtCCallback, XtRCallback, sizeof(XtPointer), + Offset(table.allow_delete_column), XtRCallback, NULL + }, + { + XtNallowDeleteRow, XtCCallback, XtRCallback, sizeof(XtPointer), + Offset(table.allow_delete_row), XtRCallback, NULL + }, + { + XtNallowDeleteTable, XtCCallback, XtRCallback, sizeof(XtPointer), + Offset(table.allow_delete_table), XtRCallback, NULL + }, + /* INFORMATION CALLBACKS */ + + { + XtNaddColumn, XtCCallback, XtRCallback, sizeof(XtPointer), + Offset(table.add_column), XtRCallback, NULL + }, + { + XtNaddRow, XtCCallback, XtRCallback, sizeof(XtPointer), + Offset(table.add_row), XtRCallback, NULL + }, + { + XtNcreateTable, XtCCallback, XtRCallback, sizeof(XtPointer), + Offset(table.create_table), XtRCallback, NULL + }, + { + XtNchangedCell, XtCCallback, XtRCallback, sizeof(XtPointer), + Offset(table.changed_cell), XtRCallback, NULL + }, + { + XtNchangedColumnWidth, XtCCallback, XtRCallback, sizeof(XtPointer), + Offset(table.changed_column_width), XtRCallback, NULL + }, + { + XtNchangedRowHeight, XtCCallback, XtRCallback, sizeof(XtPointer), + Offset(table.changed_row_height), XtRCallback, NULL + }, + { + XtNdeleteColumn, XtCCallback, XtRCallback, sizeof(XtPointer), + Offset(table.delete_column), XtRCallback, NULL + }, + { + XtNdeleteRow, XtCCallback, XtRCallback, sizeof(XtPointer), + Offset(table.delete_row), XtRCallback, NULL + }, + { + XtNdeleteTable, XtCCallback, XtRCallback, sizeof(XtPointer), + Offset(table.delete_table), XtRCallback, NULL + }, + { + XtNwhatCell, XtCCallback, XtRCallback, sizeof(XtPointer), + Offset(table.what_cell), XtRCallback, NULL + }, +}; + +#define PRINTF_BOOL(a) ((a) ? "TRUE":"FALSE") +#define PRINTF_NULL(a) ((a)==NULL ? "NULL":"not NULL") + +static void Def_pixel(w, offset, value) + Widget w; + int offset; + XrmValue *value; +{ + XawTableWidget tw = (XawTableWidget)w; + static Pixel pix = 0; + + + if ( offset == (int)Offset(table.edit_fore)) + pix = tw->table.foreground; + else if ( offset == (int)Offset(table.edit_back)) + { + if (!FetchPixel(w, "#d0d000", &pix)) + pix = WhitePixelOfScreen(XtScreen(w)); + } + else + pix = tw->core.background_pixel; + + value->addr = (XtPointer)& pix; +} + +/* ARGSUSED */ +static void Def_scroll(w, offset, value) + Widget w; + int offset; + XrmValue *value; +{ + static Widget view; + + for (view = XtParent(w); + (view != (Widget)NULL) && (!XtIsSubclass(view, viewportWidgetClass)); + view = XtParent(view)) + /* EMPTY */; + + if (view) + { + if (offset == Offset(table.v_scroll)) + { + if (((view = XtNameToWidget(view, "vertical")) == (Widget)NULL) + || !XtIsSubclass(view, scrollbarWidgetClass)) + view = (Widget)NULL; + } + else + if (offset == Offset(table.h_scroll)) + { + if (((view = XtNameToWidget(view, "horizontal")) == (Widget)NULL) + || !XtIsSubclass(view, scrollbarWidgetClass)) + view = (Widget)NULL; + } + } + + value->addr = (XtPointer)&view; +} + +/* ARGSUSED */ +static void Def_column_default_width(w, offset, value) + Widget w; + int offset; + XrmValue *value; +{ + XawTableWidget tw = (XawTableWidget) w; + static int column_default_width; + + if (tw->table.literal) + column_default_width = 10; + else + column_default_width = 60; + + value->addr = (XtPointer)&column_default_width; +} + +#ifndef WORD64 +#define TXT_16 XChar2b +#else +#define TXT_16 char +#endif + +/* ARGSUSED */ +static void Def_literal_width(w, offset, value) + Widget w; + int offset; + XrmValue *value; +{ + XawTableWidget tw = (XawTableWidget) w; + static int literal_width; + + if (tw->table.encoding) + tw->table.literal_width = XTextWidth16(tw->table.font, (TXT_16*)"mmm", 3); + else + tw->table.literal_width = XTextWidth(tw->table.font, "mmm", 3); + + tw->table.literal_width /= 3; + + value->addr = (XtPointer)& literal_width; +} + +/* ARGSUSED */ +static void Def_shadow_thickness(w, offset, value) + Widget w; + int offset; + XrmValue *value; +{ + Widget parent = XtParent (w); + static Dimension shadow_thickness; + + if (XtIsSubclass (parent, scrolledTableWidgetClass) + || + XtIsSubclass (parent, viewportWidgetClass)) + shadow_thickness = 0; + else + shadow_thickness = 2; + + value->addr = (XtPointer)& shadow_thickness; +} + + +#undef offset + +static void MultipleChangeGC(); +static void Initialize(); +static void Realize(); +static void Resize(); +static void Redisplay(); +static void Destroy(); + +static Boolean SetValues(); + +static void WalkForCells(); +static void LoseSelection(); + +static void CallEdit(); +static void InsertSelection(); +static void StoreBuffer(); +static void WhatCell(); +static void KeyReturn(); +static void HighlightCell(); +static void UnhighlightCell(); +static void DoingNothing(); + +static char* DummyString(); + +static Boolean InitCell(); + +static XtGeometryResult QueryGeometry(); +static XtGeometryResult GeometryManager(); + +static XtActionsRec actions[] = { + {"call-edit", (XtActionProc)CallEdit }, + {"insert-selection", (XtActionProc)InsertSelection}, + {"store-in-buffer", (XtActionProc)StoreBuffer }, + {"what_cell", (XtActionProc)WhatCell }, + {"key_return", (XtActionProc)KeyReturn }, + {"highlight", (XtActionProc)HighlightCell }, + {"unhighlight", (XtActionProc)UnhighlightCell}, + {"no-op", (XtActionProc)DoingNothing } +}; + +static char translations[] = + "Ctrl<Btn1Up>: what_cell() \n\ + <Btn1Up>: call-edit() \n\ + <Btn2Up>: insert-selection(PRIMARY, CUT_BUFFER0) \n\ + <Btn3Up>: highlight() store-in-buffer(PRIMARY,CUT_BUFFER0) "; + +static char edit_translations[] = + " <Key>Return: key_return() \n\ + <Key>Linefeed: key_return() \n\ + <Key>Down: no-op(r) \n\ + <Key>Up: no-op(r) "; + +static char* Dummy = ""; + + +#define SuperClass ((ContainerWidgetClass)&containerClassRec) + +TableClassRec tableClassRec = { + { /* core_class fields */ + /* superclass */ (WidgetClass) SuperClass, + /* class_name */ "Table", + /* widget_size */ sizeof(TableRec), + /* classInitialize */ NULL, + /* class_partInitialize */ NULL, + /* class_inited */ FALSE, + /* initialize */ Initialize, + /* initialize_hook */ NULL, + /* realize */ Realize, + /* actions */ actions, + /* num_actions */ XtNumber(actions), + /* resources */ resources, + /* num_resources */ XtNumber(resources), + /* xrm_class */ NULLQUARK, + /* compress_motion */ TRUE, + /* compress_exposure */ FALSE, + /* compress_enterleave */ TRUE, + /* visible_interest */ TRUE, + /* destroy */ Destroy, + /* 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 */ translations, + /* query_geometry */ QueryGeometry, + /* display_accelerator */ XtInheritDisplayAccelerator, + /* extension */ NULL + }, + /* Composite class part */ + { + /* geometry manager */ GeometryManager, + /* change_managed */ XtInheritChangeManaged, + /* insert_child */ XtInheritInsertChild, + /* delete_child */ XtInheritDeleteChild, + /* extension */ NULL, + }, + /* Constraint class part */ + { + /* subresources */ NULL, + /* subresource_count */ 0, + /* constraint_size */ 0, + /* initialize */ NULL, + /* destroy */ NULL, + /* set_values */ NULL, + /* extension */ NULL, + }, + /* Container class part */ + { + /* ignore */ 0, + }, + { /* Table class fields initialization */ + /* ignore */ 0 + } +}; + +WidgetClass tableWidgetClass = (WidgetClass)&tableClassRec; + + +/**************************************************************** + * + * Private procedures + * + ****************************************************************/ +#define NORMAL_INDEX(fore, back) \ + (int)(((int)fore * (int)back) & tw->table.mask_hash_table) + +#define SHADOW_INDEX(back) (int)(((int)back) & tw->table.mask_hash_table) + +#define GET_NORMAL(tw,i) (tw->table.normal_hash_table+(i)) +#define GET_SHADOW(tw,i) (tw->table.shadow_hash_table+(i)) + +#define NEXT(i) (int)((i+1) & tw->table.mask_hash_table) + +static int MaskStaticArray[] = { + 0x1, 0x3, 0x7, 0xF, + 0x1F, 0x3F, 0x7F, 0xFF, + 0x1FF, 0x3FF, 0x7FF, 0xFFF + }; + +static NormalReverseGC* GetNormalGC(w, fore, back, font) + Widget w; + Pixel fore; + Pixel back; + Font font; +{ + register XawTableWidget tw = (XawTableWidget)w; + int i = NORMAL_INDEX(fore, back); + + while (GET_NORMAL(tw,i)->used > 0) + { + + if (GET_NORMAL(tw,i)->fore == fore && GET_NORMAL(tw,i)->back == back) + { + GET_NORMAL(tw,i)->used++; + return GET_NORMAL(tw,i); + } + i = NEXT(i); + } + + if (GET_NORMAL(tw,i)->used == 0) + { + XtGCMask mask; + XGCValues values; + Display *dpy = XtDisplay(w); + Window win = XtIsRealized(w) ? XtWindow(w) : XDefaultRootWindow(dpy); + + + mask = GCForeground | GCBackground | GCFont; + values.foreground = fore; + values.background = back; + values.font = font; + + GET_NORMAL(tw,i)->normal = XCreateGC(dpy, win, mask, &values); + values.foreground = back; + values.background = fore; + GET_NORMAL(tw,i)->reverse = XCreateGC(dpy, win, mask, &values); + + GET_NORMAL(tw,i)->used = 1; + GET_NORMAL(tw,i)->fore = fore; + GET_NORMAL(tw,i)->back = back; + + return GET_NORMAL(tw,i); + } + + return (NormalReverseGC*)NULL; +} + +static void GetGCByForeground(w, gc, fore) + Widget w; + GC *gc; + Pixel fore; +{ + XGCValues values; + + values.foreground = fore; + (*gc) = XtGetGC(w, GCForeground, &values); +} + + +static ShadowGC* GetShadowGC(w, back) + Widget w; + Pixel back; +{ + register XawTableWidget tw = (XawTableWidget)w; + int i = SHADOW_INDEX(back); + + while (GET_SHADOW(tw,i)->used > 0) + { + if (GET_SHADOW(tw,i)->back == back) + { + GET_SHADOW(tw,i)->used++; + return GET_SHADOW(tw,i); + } + i = NEXT(i); + } + + if (GET_SHADOW(tw,i)->used == 0) + { + Pixel top; + Pixel bottom; + + GET_SHADOW(tw,i)->used = 1; + GET_SHADOW(tw,i)->back = back; + + (void)TopShadowColor(w, back, &top); + (void)BottomShadowColor(w, back, &bottom); +#ifdef CELL_IN + GetGCByForeground(w, (GC*)&GET_SHADOW(tw,i)->bottom, top); + GetGCByForeground(w, (GC*)&GET_SHADOW(tw,i)->top, bottom); +#else + GetGCByForeground(w, (GC*)&GET_SHADOW(tw,i)->bottom, bottom); + GetGCByForeground(w, (GC*)&GET_SHADOW(tw,i)->top, top); +#endif + return GET_SHADOW(tw,i); + } + + return (ShadowGC*)NULL; +} + +static void ReleaseNormalGC(w, fore, back) + Widget w; + Pixel fore; + Pixel back; +{ + register XawTableWidget tw = (XawTableWidget)w; + int i = NORMAL_INDEX(fore, back); + + while (GET_NORMAL(tw,i)->used > 0) + { + if ( GET_NORMAL(tw,i)->fore == fore && GET_NORMAL(tw,i)->back == back) + { + if (--GET_NORMAL(tw,i)->used == 0) { + XFreeGC(XtDisplay(w), GET_NORMAL(tw,i)->normal); + XFreeGC(XtDisplay(w), GET_NORMAL(tw,i)->reverse); + } + break; + } + + i = NEXT(i); + } +} + +static void ReleaseShadowGC(w, back) + Widget w; + Pixel back; +{ + register XawTableWidget tw = (XawTableWidget)w; + int i = SHADOW_INDEX(back); + + while (GET_SHADOW(tw,i)->used > 0) + { + if ( GET_SHADOW(tw,i)->back == back) + { + if (--GET_SHADOW(tw,i)->used == 0) + { + XtReleaseGC(w, GET_SHADOW(tw,i)->top); + XtReleaseGC(w, GET_SHADOW(tw,i)->bottom); + } + break; + } + i = NEXT(i); + } +} + +static void MultipleChangeGC(w, fore, back, font, normal, reverse) + Widget w; + Pixel *fore; + Pixel *back; + Font *font; + GC *normal; + GC *reverse; +{ + XtGCMask mask; + XGCValues values; + + if (normal != (GC*)NULL){ + mask = (XtGCMask)0; + if (fore != (Pixel*)NULL) { + mask |= GCForeground; + values.foreground = *fore; + } + if (back != (Pixel*)NULL) { + mask |= GCBackground; + values.background = *back; + } + if (font != (Font*)NULL) { + mask |= GCFont; + values.font = *font; + } + XChangeGC(XtDisplay(w), *normal, mask, &values); + } + + if (reverse != (GC*)NULL){ + mask = (XtGCMask)0; + if (fore != (Pixel*)NULL) { + mask |= GCForeground; + values.foreground = *back; /* reverse */ + } + if (back != (Pixel*)NULL) { + mask |= GCBackground; + values.background = *fore; /* reverse */ + } + if (font != (Font*)NULL) { + mask |= GCFont; + values.font = *font; + } + XChangeGC(XtDisplay(w), *reverse, mask, &values); + } +} + +#ifndef WORD64 + +#define TXT16 XChar2b + +#else + +#define TXT16 char + +static XChar2b *buf2b; +static int buf2blen = 0; + +#define XTextWidth16 _XawTableWidth16 +#define XDrawString16 _XawTableDraw16 + +#endif /* WORD64 */ + + +static void CalculatePreferredSize(w, width, height) + Widget w; + Dimension *width; + Dimension *height; +{ + register XawTableWidget tw = (XawTableWidget)w; + register int wid; + register int hei; + int i; + + /* + * Calculate preferred width + */ + + wid = 2 * (tw->table.tab_margin + tw->container.shadow_thickness); + wid += COLUMNS(tw) ? (COLUMNS(tw) - 1) * tw->table.col_margin : 0; + wid += 2 * COLUMNS(tw) * tw->table.label_shadow_thickness; + + for(i = 0 ; i < COLUMNS(tw); i++) + wid += (Dimension)COLUMN_WIDTH(tw,i); + + /* + * Calculate preferred height + */ + + hei = 2 * (tw->table.tab_margin + tw->container.shadow_thickness); + hei += ROWS(tw) ? (ROWS(tw) - 1) * tw->table.row_margin : 0; + hei += ROWS(tw) * tw->table.row_height; + hei += 2 * ROWS(tw) * tw->table.label_shadow_thickness; + + tw->table.prefer_width = wid; + tw->table.prefer_height = hei; + + if (width) *width = wid; + if (height) *height = hei; + +} + +static Position GetX(tw,j) + register XawTableWidget tw; + int j; +{ + register TablePart* table = (TablePart*)&tw->table; + register Position x; + + x = j * (table->col_margin + 2 * table->label_shadow_thickness) + + (table->tab_margin + tw->container.shadow_thickness); + + for(; j > 0 ; j--) + { + register int tmp = j - 1; + x += (Position)COLUMN_WIDTH(tw, tmp); + } + return x; +} + +static Position GetY(tw,i) + XawTableWidget tw; + int i; +{ + return(i * (tw->table.row_margin + tw->table.row_height + + 2 * tw->table.label_shadow_thickness) + + (tw->table.tab_margin + tw->container.shadow_thickness)); +} + + +/* + * Calculate width and height of displayed text in pixels + */ + +static void SetLabelHeight(tw) + XawTableWidget tw; +{ + register XFontStruct *fs = tw->table.font; + int row_height = tw->table.row_height; + + if (tw->table.row_height < 1) + tw->table.row_height = (fs->max_bounds.ascent + + fs->max_bounds.descent + + 2 * tw->table.internal_height); + if (row_height != tw->table.row_height) + { + XawTableCallbackStruct callback_str; + callback_str.reason = XawTABLE_CHANGED_ROW_HEIGHT; + callback_str.event = (XEvent*)NULL; + callback_str.old_cell = (XawTableCell)NULL; + callback_str.new_cell = (XawTableCell)NULL; + callback_str.row = 0; + callback_str.column = 0; + callback_str.do_it = True; + + DO_CALLBACK((Widget)tw, XtNchangedRowHeight, callback_str); + } +} + +static void SetLiteralWidth(tw) + XawTableWidget tw; +{ + if (tw->table.encoding) + tw->table.literal_width = XTextWidth16(tw->table.font, (TXT16*)"mmm", 3); + else + tw->table.literal_width = XTextWidth(tw->table.font, "mmm", 3); + + tw->table.literal_width /= 3; +} + + +static void SetLabelWidth(tw,i,j) + XawTableWidget tw; + int i,j; +{ + register XFontStruct *fs = tw->table.font; + XawTableCell cell; + + cell = (XawTableCell)get_cell(STUFF(tw),i,j); + + if (CELL(label) == NULL) { + CELL(label_len) = 0; + CELL(label_width) = 0; + } else { + CELL(label_len) = strlen(CELL(label)); + if (tw->table.encoding) + CELL(label_width) = + XTextWidth16(fs, (TXT16*)CELL(label), (int) CELL(label_len)/2); + else + CELL(label_width) = + XTextWidth(fs, CELL(label), (int) CELL(label_len)); + } +} + + +static void CreateTableCellGC(w) + Widget w; +{ + Display *dpy = XtDisplay(w); + Drawable d = XtWindow(w); + XawTableWidget tw = (XawTableWidget)w; + + tw->table.normal = XCreateGC(dpy, d, (XtGCMask)0, (XGCValues*)NULL); + tw->table.reverse = XCreateGC(dpy, d, (XtGCMask)0, (XGCValues*)NULL); + + MultipleChangeGC(w, + (Pixel*)&tw->table.foreground, + (Pixel*)&tw->core.background_pixel, + (Font*)&tw->table.font->fid, + (GC*)&tw->table.normal, + (GC*)&tw->table.reverse); + +} + +static void DrawColumns(tw, b_column, e_column) + XawTableWidget tw; + int b_column, e_column; +{ + int j,y; + + y = (int)GetY(tw,0); + for(j = MAX(b_column,0); j <= MIN(e_column, COLUMNS(tw) - 2); j++) + { + XFillRectangle(XtDisplay((Widget)tw), + XtWindow((Widget)tw), + tw->table.column_gc, + (int) (GetX(tw,j+1) - tw->table.col_margin), + y, + (unsigned int) tw->table.col_margin, + (unsigned int)(tw->table.prefer_height-(2*y))); + + } +} + +static void DrawRows(tw, b_row, e_row) + XawTableWidget tw; + int b_row, e_row; +{ + int i,x; + + x = (int)GetX(tw,0); + for(i = MAX(b_row, 0); i <= MIN(e_row, ROWS(tw) - 2); i++) + { + XFillRectangle(XtDisplay((Widget)tw), + XtWindow((Widget)tw), + tw->table.row_gc, + x, + (int) (GetY(tw,i+1) - tw->table.row_margin), + (unsigned int) (tw->table.prefer_width-(2*x)), + (unsigned int) tw->table.row_margin); + + } +} + +static void DrawCage(tw, b_row, e_row, b_column, e_column) + XawTableWidget tw; + int b_row, e_row, b_column, e_column; +{ + int i,j; + Display* dpy = XtDisplay((Widget)tw); + Window win = XtWindow((Widget)tw); + + if (tw->table.row_oriented) + { + if (tw->table.col_margin > (Dimension)0) + { + DrawRows(tw, b_row - 1, e_row); + + for(i = b_row; i <= MIN(e_row,ROWS(tw) - 1); i++) + { + int y = (int) GetY(tw,i); + + for(j = MAX(b_column - 1, 0); j <= MIN(e_column, COLUMNS(tw) - 2); j++) + { + XFillRectangle (dpy, + win, + tw->table.column_gc, + (int) (GetX(tw, j + 1) - tw->table.col_margin), + y, + (unsigned int) tw->table.col_margin, + (unsigned int) (tw->table.row_height + + 2 * tw->table.label_shadow_thickness)); + + } + } + } + } + else + { + if (tw->table.row_margin > (Dimension)0) + { + DrawColumns(tw, b_column - 1, e_column); + + for(j = b_column; j <= MIN(e_column, COLUMNS(tw) - 1); j++) + { + int x = (int) GetX(tw,j); + + for(i = MAX(b_row - 1, 0); i <= MIN(e_row, ROWS(tw) - 2); i++) + { + XFillRectangle(XtDisplay((Widget)tw), + XtWindow((Widget)tw), + tw->table.row_gc, + x, + (int) (GetY(tw,i+1) - tw->table.row_margin), + (unsigned int) (COLUMN_WIDTH(tw,j) + + 2 * tw->table.label_shadow_thickness), + (unsigned int) tw->table.row_margin); + } + } + } + } +} + +static void Reposition(tw, cell, i, j) + register XawTableWidget tw; + XawTableCell cell; + int i,j; +{ + Position newPos; + XtJustify justify; + + if (cell == NULL) + cell = (XawTableCell)get_cell(STUFF(tw),i,j); + + if (COLUMN_DATA(tw)[j].flag & _CL_justify) + justify = COLUMN_DATA(tw)[j].justify; + else + justify = tw->table.justify; + + switch (justify) { + case XtJustifyLeft : newPos = tw->table.internal_width; + break; + case XtJustifyRight : newPos = (COLUMN_WIDTH(tw,j) - + CELL(label_width) - + tw->table.internal_width); + break; + case XtJustifyCenter : + default : newPos = (COLUMN_WIDTH(tw,j) - + CELL(label_width)) / 2; + break; + } + + CELL(label_x) = MAX(newPos, tw->table.internal_width); +} + +/* ARGSUSED */ +static Boolean DeleteCell(p, i, j, call_data, client_data) + XtPointer p; + int i; /* unused */ + int j; /* unused */ + XtPointer call_data; + XtPointer client_data; /* unused */ +{ + Widget w = (Widget) p; + XawTableCell cell = (XawTableCell)call_data; + + + if (CELL(label) != (char*)NULL) + XtFree(CELL(label)); + + if (CELL(special_colour)) + { + ReleaseNormalGC(w, CELL(fore), CELL(back)); + ReleaseShadowGC(w, CELL(back)); + } + return False; +} + + +static void UpdateTable(tw) + XawTableWidget tw; +{ + Dimension width; + Dimension height; + + if (tw->table.no_refigure > 0) + return; + + CalculatePreferredSize((Widget)tw, &width, &height); + + tw->table.was_resized = False; + + (void)XtMakeResizeRequest((Widget)tw, width, height, + (Dimension*)NULL, (Dimension*)NULL); + if (tw->table.was_resized == False) + { + tw->table.was_resized = True; + (*tableClassRec.core_class.resize) ((Widget)tw); + } +} + + +static int SetTableSize(w, rows, columns) + Widget w; + int rows; + int columns; +{ + XawTableWidget tw = (XawTableWidget)w; + XawTableCallbackStruct callback_str; + int i; + + if (rows < 0 || columns < 0) { + String subs[1]; + Cardinal num_subs = 1; + subs[0] = w->core.name; + XtAppWarningMsg(XtWidgetToApplicationContext(w), + "SetTableSize", "SetTableSize","XawToolkitError", + "rows or columns for a new table in TableWidget '%s' less then zero", + subs, &num_subs); + return REJECT; + } + + if (STUFF(tw)) + { + callback_str.reason = XawTABLE_ALLOW_DELETE_TABLE; + callback_str.event = (XEvent*)NULL; + callback_str.old_cell = STUFF(tw); + callback_str.new_cell = STUFF(tw); + callback_str.row = 0; + callback_str.column = 0; + callback_str.do_it = True; + + DO_CALLBACK(w, XtNallowDeleteTable, callback_str); + + if (callback_str.do_it != True) + return REJECT; + + callback_str.reason = XawTABLE_DELETE_TABLE; + callback_str.event = (XEvent*)NULL; + callback_str.old_cell = STUFF(tw); + callback_str.new_cell = STUFF(tw); + callback_str.row = 0; + callback_str.column = 0; + callback_str.do_it = True; + + DO_CALLBACK (w, XtNdeleteTable, callback_str); + + WalkForCells (w, (XawTableProc)DeleteCell, + 0, ROWS(tw)-1, 0, COLUMNS(tw)-1); + + delete_table ((XtPointer)STUFF(tw)); + + STUFF(tw) = (XawTableCell)NULL; + ROWS(tw) = 0; + COLUMNS(tw) = 0; + } + + if (rows == 0 || columns == 0) + return ACCEPT; + + STUFF(tw) = (XawTableCell) + create_table(rows, columns, sizeof(XawTableCellRec)); + + if (STUFF(tw) == (XawTableCell)NULL) + return ACCEPT; + + ROWS(tw) = rows; + COLUMNS(tw) = columns; + + WalkForCells((Widget)tw, (XawTableProc)InitCell, 0, rows-1, 0, columns-1); + + if (COLUMNS(tw)) { + tw->table.column_data = (XawTableColumn) + XtRealloc((XtPointer)COLUMN_DATA(tw), + (Cardinal)(COLUMNS(tw) * sizeof(XawTableColumnRec))); + for (i = 0; i < COLUMNS(tw); i++) + COLUMN_DATA(tw)[i].flag = 0; + } + else { + XtFree((XtPointer)tw->table.column_data); + tw->table.column_data = NULL; + } + + callback_str.reason = XawTABLE_CREATE_TABLE; + callback_str.event = (XEvent*)NULL; + callback_str.old_cell = (XawTableCell)NULL; + callback_str.new_cell = (XawTableCell)NULL; + callback_str.row = 0; + callback_str.column = 0; + callback_str.do_it = True; + + DO_CALLBACK(w, XtNcreateTable, callback_str); + + return ACCEPT; +} + + +/* ARGSUSED */ +static void Initialize(request, new, args, num_args) + Widget request; + Widget new; + ArgList args; + Cardinal *num_args; +{ + register XawTableWidget tw = (XawTableWidget) new; + Dimension width; + Dimension height; + int i; + + tw->table.no_refigure = 0; + tw->table.no_redraw = 0; + tw->table.num_selections = 0; + tw->table.cell_own = (XawTableCell)NULL; + STUFF(tw) = (XawTableCell)NULL; + tw->table.normal = (GC)NULL; + tw->table.reverse = (GC)NULL; + + COLUMNS(tw) = MAX (COLUMNS(tw), 0); + ROWS(tw) = MAX (ROWS(tw), 0); + + if (COLUMNS(tw)) { + tw->table.column_data = (XawTableColumn) + CALLOC (COLUMNS(tw), XawTableColumnRec); + for (i = 0; i < COLUMNS(tw); i++) + COLUMN_DATA(tw)[i].flag = 0; + } + else + tw->table.column_data = NULL; + + SetLiteralWidth(tw); + + EDIT(tw) = XtVaCreateWidget + ("edit", asciiTextWidgetClass, new, + XtNeditType, XawtextEdit, + XtNforeground, tw->table.edit_fore, + XtNbackground, tw->table.edit_back, + XtNborderWidth, (XtArgVal)0, + XtNleftMargin, 2, + XtNrightMargin, 2, + XtNtopMargin, 0, /* to be fixed in future */ + XtNbottomMargin, 0, /* to be fixed in future */ + XtNuseStringInPlace, False, + XtNfont, tw->table.font, + XtNuserData, (XtArgVal)new, + NULL); + + XtOverrideTranslations(EDIT(tw), XtParseTranslationTable(edit_translations)); + + GetGCByForeground (new, (GC*)&tw->table.row_gc, tw->table.row_fore); + GetGCByForeground (new, (GC*)&tw->table.column_gc, tw->table.column_fore); + + if ((COLUMNS(tw) > 0) && (ROWS(tw) > 0)) + { + if (REJECT == SetTableSize(new, ROWS(tw), COLUMNS(tw))) + { + ROWS(tw) = 0; + COLUMNS(tw) = 0; + STUFF(tw) = (XawTableCell)NULL; + } + } + + if ((tw->table.mask_number < 0) + || (tw->table.mask_number >= XtNumber(MaskStaticArray))) + tw->table.mask_number = 7; + + tw->table.mask_hash_table = MaskStaticArray[tw->table.mask_number]; + + tw->table.normal_hash_table = + CALLOC(tw->table.mask_hash_table, NormalReverseGC); + + tw->table.shadow_hash_table = CALLOC(tw->table.mask_hash_table, ShadowGC); + + for(i = 0; i < tw->table.mask_hash_table; i++) + { + GET_NORMAL(tw,i)->used = 0; + GET_NORMAL(tw,i)->normal = (GC)NULL; + GET_NORMAL(tw,i)->reverse = (GC)NULL; + GET_SHADOW(tw,i)->used = 0; + GET_SHADOW(tw,i)->top = (GC)NULL; + GET_SHADOW(tw,i)->bottom = (GC)NULL; + } + + SetLabelHeight(tw); + + CalculatePreferredSize(new, &width, &height); + + if (new->core.width == 0) new->core.width = width; + if (new->core.height == 0) new->core.height = height; +} + + +static void Realize(w, valueMask, attributes) + Widget w; + XtValueMask *valueMask; + XSetWindowAttributes *attributes; +{ + XawTableWidget tw = (XawTableWidget) w; + ShadowGC *shadow; + + (*SuperClass->core_class.realize) (w, valueMask, attributes); + + CreateTableCellGC(w); + + shadow = GetShadowGC(w, tw->table.edit_back); + tw->table.edit_top = shadow->top; + tw->table.edit_bottom = shadow->bottom; + + shadow = GetShadowGC(w, tw->core.background_pixel); + tw->table.top = shadow->top; + tw->table.bottom = shadow->bottom; + + XtRealizeWidget(EDIT(w)); +} + +/* ARGSUSED */ +static Boolean MatchLabel(w, i, j, call_data, client_data) + Widget w; /* unused */ + int i; /* unused */ + int j; /* unused */ + XtPointer call_data; + XtPointer client_data; +{ + XawTableCell cell = (XawTableCell)call_data; + XrmQuark* templ = (XrmQuark*)client_data; + + return ((*templ) == XrmStringToQuark (GET_CELL_LABEL)); +} + +/* ARGSUSED */ +static Boolean InitCell(p, i, j, call_data, client_data) + XtPointer p; /* unused */ + int i; /* unused */ + int j; /* unused */ + XtPointer call_data; + XtPointer client_data; /* unused */ +{ + XawTableCell cell = (XawTableCell)call_data; + + CELL(label) = DummyString(); + CELL(label_len) = 0; + CELL(label_width) = 0; + CELL(highlight) = False; + CELL(special_colour) = False; + CELL(normal) = (GC)NULL; + CELL(reverse) = (GC)NULL; + CELL(top) = (GC)NULL; + CELL(bottom) = (GC)NULL; + + return False; +} + +/* + * + * Shadow drawing around cell + * + */ +static void PaintShadow(w, i, j, x, y, cell) + Widget w; + int i; + int j; + Position x; + Position y; + XawTableCell cell; +{ + XawTableWidget tw = (XawTableWidget) w; + + if (tw->table.label_shadow_thickness != (Dimension)0) { + GC top,bottom; + + if (IsEditInRowColumn(tw,i,j)) + { + top = tw->table.edit_bottom; + bottom = tw->table.edit_top; + } + else if (CELL(special_colour)) + { + top = CELL(top); + bottom = CELL(bottom); + }else { + top = tw->table.top; + bottom = tw->table.bottom; + } + + XawDrawFrame(w, + x, + y, + (Dimension)(COLUMN_WIDTH(tw,j) + + 2 * tw->table.label_shadow_thickness), + (Dimension)(tw->table.row_height + + 2 * tw->table.label_shadow_thickness), + XawRAISED, + tw->table.label_shadow_thickness, + top, + bottom); + } + +} + +/* ARGSUSED */ +static void PaintLabel(w, i, j, x, y, cell) + Widget w; + int i; + int j; + Position x,y; + XawTableCell cell; +{ + XawTableWidget tw = (XawTableWidget) w; + XRectangle rectangle[1]; + Position label_x; + Position label_y; + unsigned int width = (unsigned int) COLUMN_WIDTH(tw,j); + unsigned int height = (unsigned int) tw->table.row_height; + + x += tw->table.label_shadow_thickness; + y += tw->table.label_shadow_thickness; + + if (CELL(special_colour) || CELL(highlight)) + { + GC gc; + + if (CELL(special_colour)) + gc = CELL(highlight) ? CELL(normal) : CELL(reverse); + else + gc = tw->table.normal ; + + /* Fill background for cell with a special colour */ + XFillRectangle(XtDisplay(w), XtWindow(w), gc, + (int)x, (int)y, width, height); + } + else + { + XClearArea (XtDisplay(w), XtWindow(w), (int)x, (int)y, + width, height, FALSE); + } + + if (CELL(label_len) > 0) + { + GC gc; + register XFontStruct *fs = tw->table.font; + + if (CELL(special_colour)) + gc = CELL(highlight) ? CELL(reverse) : CELL(normal); + else + gc = CELL(highlight) ? tw->table.reverse : tw->table.normal; + + /* Set clip rectangle for label in cell */ + rectangle[0].x = (short)x; + rectangle[0].y = (short)y; + rectangle[0].width = (unsigned short)COLUMN_WIDTH(tw,j); + rectangle[0].height = (unsigned short)tw->table.row_height; + + XSetClipRectangles(XtDisplay(w), gc, 0, 0, rectangle, 1, YSorted); + + /* Drawing label */ + label_x = x + CELL(label_x); + label_y = y + + (tw->table.row_height-(fs->max_bounds.ascent+fs->max_bounds.descent))/2 + /* tw->table.internal_height */ + + fs->max_bounds.ascent; + + if (tw->table.encoding) + XDrawString16(XtDisplay(w), XtWindow(w), gc, + label_x, label_y, (TXT16*)CELL(label), + (int)CELL(label_len)/2); + else + XDrawString(XtDisplay(w), XtWindow(w), gc, + label_x, label_y, CELL(label), (int)CELL(label_len)); + + XSetClipMask(XtDisplay(w), gc, (Pixmap)None); + + } +} + +/* ARGSUSED */ +static Boolean PaintCell(p, i, j, call_data, client_data) + XtPointer p; + int i; + int j; + XtPointer call_data; + XtPointer client_data; /* unused */ +{ + Widget w = (Widget) p; + XawTableWidget tw = (XawTableWidget) w; + XawTableCell cell = (XawTableCell) call_data; + Position x; + Position y; + + x = GetX(tw,j); + y = GetY(tw,i); + + PaintLabel (w, i, j, x, y, cell); + PaintShadow (w, i, j, x, y, cell); + + XFlush(XtDisplay(w)); + return False; +} + +static void WhatCellsToBeDraw(tw, rect, b_row, e_row, b_column , e_column) + XawTableWidget tw; + XRectangle rect; + register int *b_row, *e_row, *b_column , *e_column; +{ + Position x1 = (Position)rect.x, + y1 = (Position)rect.y, + x2 = (Position)(rect.x + rect.width - 1), + y2 = (Position)(rect.y + rect.height - 1); + + for ((*b_column) = 0; (*b_column) < COLUMNS(tw); (*b_column)++) + { + if (x1 < (GetX(tw,(*b_column) + 1) - tw->table.col_margin)) + break; + } + + for ((*e_column) = (*b_column); (*e_column) < COLUMNS(tw); (*e_column)++) + { + if (x2 < (GetX(tw,(*e_column) + 1) - tw->table.col_margin)) + break; + } + + + for ((*b_row) = 0; (*b_row) < ROWS(tw); (*b_row)++) + { + if (y1 < (GetY(tw,(*b_row) + 1) - tw->table.row_margin)) + break; + } + + for ((*e_row) = (*b_row); (*e_row) < ROWS(tw); (*e_row)++) + { + if (y2 < (GetY(tw,(*e_row) + 1) - tw->table.row_margin)) + break; + } +} + + +static void Redisplay(w, event, region) + Widget w; + XEvent *event; + Region region; +{ + XawTableWidget tw = (XawTableWidget) w; + XRectangle rect; + int b_row, e_row, b_column , e_column ; + + if (!XtIsRealized(w) || !w->core.visible || tw->table.no_redraw) + return; + + if (tw->container.shadow_thickness > 0) + (*SuperClass->core_class.expose) (w, event, region); + + if (region != NULL) + { + XClipBox(region, (XRectangle*)&rect); + + WhatCellsToBeDraw(tw, rect, &b_row, &e_row, &b_column , &e_column); + } + else if (event != (XEvent*)NULL) + { + rect.x = (short) event->xexpose.x; + rect.y = (short) event->xexpose.y; + rect.width = (unsigned short) event->xexpose.width; + rect.height = (unsigned short) event->xexpose.height; + + WhatCellsToBeDraw(tw, rect, &b_row, &e_row, &b_column , &e_column); + } + else if (tw->table.v_scroll || tw->table.h_scroll) + { + rect.x = (short) 0; + rect.y = (short) 0; + rect.width = (unsigned short) tw->core.width; + rect.height = (unsigned short) tw->core.height; + + if (tw->table.v_scroll && XtIsManaged(tw->table.v_scroll)) + { + float top; + float shown; + + XtVaGetValues (tw->table.v_scroll, + XtNtopOfThumb, &top, + XtNshown, &shown, + NULL); + + rect.y = (short) ((float)(tw->core.height) * top); + rect.height = (unsigned short) ((float)(tw->core.height) * (top+shown)); + } + + if (tw->table.h_scroll && XtIsManaged(tw->table.h_scroll)) + { + float top; + float shown; + + XtVaGetValues (tw->table.h_scroll, + XtNtopOfThumb, &top, + XtNshown, &shown, + NULL); + + rect.x = (short) ((float)(tw->core.width) * top); + rect.width = (unsigned short) ((float)(tw->core.width) * (top+shown)); + } + + + WhatCellsToBeDraw(tw, rect, &b_row, &e_row, &b_column , &e_column); + } + else + { + b_row = 0; + e_row = ROWS(tw) - 1; + b_column = 0; + e_column = COLUMNS(tw) - 1; + } + + DrawCage(tw, b_row, e_row, b_column, e_column); + + WalkForCells(w, (XawTableProc)PaintCell, b_row, e_row, b_column, e_column); + + XFlush(XtDisplay(w)); +} + +/* ARGSUSED */ +static Boolean SetValues(current, request, new, args, num_args) + Widget current; + Widget request; /* unused */ + Widget new; + ArgList args; /* unused */ + Cardinal *num_args; /* unused */ +{ + XawTableWidget curtw = (XawTableWidget) current; + XawTableWidget newtw = (XawTableWidget) new; + register int i; + int j; + Boolean resize = False; + Boolean redisplay = False; + +#define NE(field) (curtw->table.field != newtw->table.field) + + if (NE(mask_number)) + XtWarning("Resource XtNmaskNumber in Table widget can not changed"); + + newtw->table.mask_number = curtw->table.mask_number; + newtw->table.literal = curtw->table.literal; + + if (NE(font->fid)) + XtVaSetValues (EDIT(newtw), XtNfont, curtw->table.font, NULL); + + if (NE(foreground) || + NE(row_fore) || + NE(column_fore) || + NE(row_oriented) || + NE(font->fid) || + NE(justify) || + NE(tab_margin) || + NE(row_margin) || + NE(col_margin) || + NE(internal_width) || + NE(internal_height) || + NE(label_shadow_thickness) || + NE(encoding)) + redisplay = True; + + if (NE(font->fid) || + NE(columns) || + NE(rows) || + NE(tab_margin) || + NE(row_margin) || + NE(col_margin) || + NE(internal_width) || + NE(internal_height) || + NE(row_height) || + NE(label_shadow_thickness)) + resize = True; + + if (NE(columns) || NE(rows)) + if (REJECT == SetTableSize(new, ROWS(newtw), COLUMNS(newtw))) { + newtw->table.columns = curtw->table.columns; + newtw->table.rows = curtw->table.rows; + } + + if(NE(row_height)) + { + XawTableCallbackStruct callback_str; + callback_str.reason = XawTABLE_CHANGED_ROW_HEIGHT; + callback_str.event = (XEvent*)NULL; + callback_str.old_cell = (XawTableCell)NULL; + callback_str.new_cell = (XawTableCell)NULL; + callback_str.row = 0; + callback_str.column = 0; + callback_str.do_it = True; + + DO_CALLBACK(new, XtNchangedRowHeight, callback_str); + } + + if(NE(font->fid)) + { + for(i = 0; i < ROWS(newtw); i++) + for(j = 0; j < COLUMNS(newtw); j++) + SetLabelWidth(newtw, i, j); + + SetLabelHeight(newtw); + } + + if(NE(font->fid) || NE(encoding)) + { + SetLiteralWidth(newtw); + + for(i = 0; i < ROWS(newtw); i++) + for(j = 0; j < COLUMNS(newtw); j++) + Reposition(newtw, NULL, i, j); + } + else if(NE(internal_width) || NE(label_shadow_thickness)) { + for(i = 0; i < ROWS(newtw); i++) + for(j = 0; j < COLUMNS(newtw); j++) + Reposition(newtw, NULL, i, j); + } + + + if (NE(internal_height) || NE(label_shadow_thickness)) + { + SetLabelHeight(newtw); + } + + if (resize) + CalculatePreferredSize(new, &newtw->core.width, &newtw->core.height); + + if (NE(foreground) || NE(font->fid) || + curtw->core.background_pixel != newtw->core.background_pixel) + { + MultipleChangeGC(new, + (Pixel*)&newtw->table.foreground, + (Pixel*)&newtw->core.background_pixel, + (Font*)&newtw->table.font->fid, + (GC*)&newtw->table.normal, + (GC*)&newtw->table.reverse); + + } + + if (NE(row_fore)) + { + XtReleaseGC(new, curtw->table.row_gc); + GetGCByForeground(new,(GC*)&newtw->table.row_gc, newtw->table.row_fore); + } + + if (NE(column_fore)) + { + XtReleaseGC(new, curtw->table.column_gc); + GetGCByForeground(new, &newtw->table.column_gc,newtw->table.column_fore); + } + + if (resize) + CalculatePreferredSize(new, &(new->core.width), &(new->core.height)); + + return redisplay; +} + + +static void Destroy(w) + Widget w; +{ + XawTableWidget tw = (XawTableWidget)w; + XawTableCallbackStruct callback_str; + + if (STUFF(tw) != (XawTableCell)NULL) + { + callback_str.reason = XawTABLE_DELETE_TABLE; + callback_str.event = (XEvent*)NULL; + callback_str.old_cell = (XawTableCell)NULL; + callback_str.new_cell = (XawTableCell)NULL; + callback_str.row = 0; + callback_str.column = 0; + callback_str.do_it = True; + + DO_CALLBACK(w, XtNdeleteTable, callback_str); + } + + if (tw->table.row_gc != (GC)NULL) { + XtReleaseGC(w, tw->table.row_gc); + tw->table.row_gc = (GC)NULL; + } + if (tw->table.column_gc != (GC)NULL) { + XtReleaseGC(w, tw->table.column_gc); + tw->table.column_gc = (GC)NULL; + } + if (tw->table.normal != (GC)NULL) { + XFreeGC(XtDisplay(w), tw->table.normal); + tw->table.normal = (GC)NULL; + } + + if (tw->table.reverse != (GC)NULL) { + XFreeGC(XtDisplay(w), tw->table.reverse); + tw->table.reverse = (GC)NULL; + } + + WalkForCells(w, (XawTableProc)DeleteCell, 0, ROWS(tw)-1, 0, COLUMNS(tw)-1); + + XtFree((XtPointer)tw->table.normal_hash_table); + XtFree((XtPointer)tw->table.shadow_hash_table); + + delete_table(tw->table.table_stuff); + STUFF(tw) = (XawTableCell)NULL; + + if (tw->table.column_data != NULL) + XtFree((XtPointer)tw->table.column_data); + + if (EDIT(w) != WNULL && !EDIT(w)->core.being_destroyed) + XtDestroyWidget(EDIT(w)); +} + + +static void Resize(w) + Widget w; +{ + XawTableWidget tw = (XawTableWidget)w; + + /* If widget is realized, just redisplay it w/o clearing */ + if (XtIsRealized(w) && tw->table.no_redraw == 0) + { + /* XClearWindow(XtDisplay(w), XtWindow(w)); */ + (*tableClassRec.core_class.expose) (w, (XEvent*)NULL,(Region)NULL); + } + + tw->table.was_resized = True; +} + + +static XtGeometryResult QueryGeometry(w, intended, preferred) + Widget w; + XtWidgetGeometry *intended, *preferred; +{ + preferred->request_mode = CWWidth | CWHeight; + + CalculatePreferredSize(w, &preferred->width, &preferred->height); + +#define Set(bit) (intended->request_mode & bit) + + if (Set(CWWidth) && intended->width == preferred->width && + Set(CWHeight) && intended->height == preferred->height) { + return XtGeometryYes; + } + + if (preferred->width == w->core.width && + preferred->height == w->core.height) { + return XtGeometryNo; + } + + return XtGeometryAlmost; + +#undef Set +} + +/* ARGSUSED */ +static XtGeometryResult GeometryManager(w, desired, allowed) + Widget w; + XtWidgetGeometry *desired; + XtWidgetGeometry *allowed; +{ + return XtGeometryYes; +} + + + +static void ExtractPosition(event, x, y , t) + XEvent *event; + Position *x, *y; /* RETURN */ + Time *t; /* RETURN */ +{ + if (event == NULL) + return; + + switch(event->type) { + case MotionNotify: + *x = event->xmotion.x; + *y = event->xmotion.y; + *t = event->xmotion.time; + break; + case ButtonPress: + case ButtonRelease: + *x = event->xbutton.x; + *y = event->xbutton.y; + *t = event->xbutton.time; + break; + case KeyPress: + case KeyRelease: + *x = event->xkey.x; + *y = event->xkey.y; + *t = event->xkey.time; + break; + case EnterNotify: + case LeaveNotify: + *x = event->xcrossing.x; + *y = event->xcrossing.y; + *t = event->xcrossing.time; + break; + default: + *x = 0; + *y = 0; + *t = XtLastTimestampProcessed(event->xany.display); + } +} + +/* ARGSUSED */ +static Boolean ExtractCell(tw, px, py, row, column) + XawTableWidget tw; + Position px,py; + int *row, *column; /* RETURN */ +{ + Position x; + Position y; +#define SH (tw->table.label_shadow_thickness) + for(*row = 0; *row < ROWS(tw); (*row)++) { + for(*column = 0; *column < COLUMNS(tw); (*column)++) + if ((x=GetX(tw,*column)+SH) <= px) + if ((y=GetY(tw,*row)+SH) <= py) + if ((x+COLUMN_WIDTH(tw,*column)) >= px) + if ((y+tw->table.row_height) >= py) + return False; + } +#undef SH + + return True; +} + + +/* ARGSUSED */ +static void WalkForCells(w, proc, b_r, e_r, b_c, e_c) + Widget w; + XawTableProc proc; + int b_r, e_r, b_c, e_c; +{ + XawTableWidget tw = (XawTableWidget)w; + int i,j; + + (void)go_table((XtPointer)w, proc, STUFF(tw), + b_r, e_r, b_c, e_c, + XawTABLE_RIGHT_DOWN, + &i, &j, (XtPointer)NULL); +} + +static char* DummyString() +{ + return XtNewString(""); +} + +static char* CopyOnlyPrintable(raw) + char* raw; +{ + char* clear; + char *s,*h; + int lenght; + + for(s = raw, lenght = 0; (*s) != '\0';) + { + if (isprint(*s++)) + lenght++; + } + + clear = CALLOC(++lenght, char); + + for(s = raw, h = clear; (*s) != '\0';) + { + if (isprint(*s)) + (*h++) = (*s++); + } + + (*h) = '\0'; + + return clear; +} + +#ifdef EBUG_XRAW_MALLOC +/* ARGSUSED */ +static Boolean CheckLabel(p, i, j, call_data, client_data) + XtPointer p; + int i; + int j; + XtPointer call_data; + XtPointer client_data; /* unused */ +{ + Widget w = (Widget) p; + XawTableWidget tw = (XawTableWidget) p; + XawTableCell cell = (XawTableCell)call_data; + char* label = CELL(label); + + for (label = CELL(label); *label != '\0'; label++) + if (!isprint(*label)) + { + char message[80]; + char *p = NULL; + sprintf(message, "wrong label '%s' in cell (%4d,%4d) in Table widget '%s'", + CELL(label), i, j, w->core.name); + XtWarning(message); + *p = '\0'; + break; + } + + return False; +} +#endif + +#ifdef EBUG_XRAW_MALLOC +static void CheckAllLabels(tw) + XawTableWidget tw; +{ + WalkForCells((Widget)tw, (XawTableProc)CheckLabel, + 0, ROWS(tw)-1, 0, COLUMNS(tw)-1); +} +#endif + +static void MoveEditCell (tw, row, column) + XawTableWidget tw; + int row; + int column; +{ + Position x,y; + + x = GetX(tw,column); + y = GetY(tw,row); + + XtConfigureWidget(EDIT(tw), + (Position)(x + tw->table.label_shadow_thickness), + (Position)(y + tw->table.label_shadow_thickness), + (Dimension) COLUMN_WIDTH(tw, column), + (Dimension) tw->table.row_height, + (Dimension)0); + XawDrawFrame((Widget)tw, + x, + y, + (Dimension)(COLUMN_WIDTH(tw, column) + + 2 * tw->table.label_shadow_thickness), + (Dimension)(tw->table.row_height + + 2 * tw->table.label_shadow_thickness), + XawSUNKEN, + tw->table.label_shadow_thickness, + tw->table.edit_top, + tw->table.edit_bottom); + +} + +/* ARGSUSED */ +static Boolean CompareCells(p, i, j, call_data, client_data) + XtPointer p; + int i; /* unused */ + int j; /* unused */ + XtPointer call_data; + XtPointer client_data; /* unused */ +{ + XawTableCell cell = (XawTableCell)call_data; + XawTableCell test_cell = (XawTableCell)client_data; + + return(cell == test_cell); +} + +/****************************************************************** + * + * CONVENIENCE FUNCTIONS + * + ******************************************************************/ + + +void +#ifdef Xraw_NEED_PROTO +XawTableGetSize (Widget w, + int *rows, + int *columns) +#else +XawTableGetSize (w, rows, columns) + Widget w; + int *rows; + int *columns; +#endif +{ + XawTableWidget tw = (XawTableWidget)w; + + *rows = ROWS(tw); + *columns = COLUMNS(tw); +} + +void +#ifdef Xraw_NEED_PROTO +XawTableDoLayout (Widget w, + Boolean do_layout) +#else +XawTableDoLayout (w, do_layout) + Widget w; + Boolean do_layout; +#endif +{ + XawTableWidget tw = (XawTableWidget)w; + + if (do_layout) + tw->table.no_redraw--; + else + tw->table.no_redraw++; + + tw->table.no_redraw = MAX (tw->table.no_redraw, 0); + + if (tw->table.no_redraw == 0) + Redisplay (w, (XEvent *)NULL, (Region)NULL); +} + +int +#ifdef Xraw_NEED_PROTO +XawTableSetNewSize (Widget w, + int rows, + int columns) +#else +XawTableSetNewSize (w, rows, columns) + Widget w; + int rows; + int columns; +#endif +{ + if (REJECT == SetTableSize(w, rows, columns)) + return REJECT; + + UpdateTable((XawTableWidget)w); + return ACCEPT; +} + +char * +#ifdef Xraw_NEED_PROTO +XawTableGetLabelByCell (XawTableCell cell) +#else +XawTableGetLabelByCell (cell) + XawTableCell cell; +#endif +{ + return GET_CELL_LABEL; +} + +void +#ifdef Xraw_NEED_PROTO +XawTableGetEditPosition (Widget w, int *row, int *column) +#else +XawTableGetEditPosition(w, row, column) + Widget w; + int *row; + int *column; +#endif +{ + XawTableWidget tw = (XawTableWidget)w; + + *row = tw->table.edit_row; + *column = tw->table.edit_column; +} + +Boolean +#ifdef Xraw_NEED_PROTO +XawTableWalk ( + Widget w, + XawTableProc proc, + int b_row, + int e_row, + int b_column, + int e_column, + int direction, + int *i, /* returned */ + int *j, /* returned */ + XtPointer client_data) +#else +XawTableWalk(w, proc, b_row, e_row, b_column, e_column, + direction, i, j, client_data) + Widget w; + XawTableProc proc; + int b_row, e_row, b_column, e_column; + int direction; + int *i; /* returned */ + int *j; /* returned */ + XtPointer client_data; +#endif +{ + return go_table((XtPointer)w, proc, STUFF(w), + b_row, e_row, b_column, e_column, + direction, + i, j, client_data); +} + +Boolean +#ifdef Xraw_NEED_PROTO +XawTableSearchLabel (Widget w, char *name, int *row, int *column) +#else +XawTableSearchLabel (w, name, row, column) + Widget w; + char *name; + int *row, *column; +#endif +{ + int row_start = *row; + int column_start = *column; + XrmQuark templ = XrmStringToQuark (name); + + if (XawTableWalk(w, (XawTableProc)MatchLabel, + row_start, row_start, column_start, COLUMNS(w)-1, + XawTABLE_RIGHT_DOWN, + row, column, (XtPointer)&templ)) { + return (True); + } + if (XawTableWalk(w, (XawTableProc)MatchLabel, + row_start+1, ROWS(w)-1, 0, COLUMNS(w)-1, + XawTABLE_RIGHT_DOWN, + row, column, (XtPointer)&templ)) { + return (True); + } + if (XawTableWalk(w, (XawTableProc)MatchLabel, + 0, row_start-1, 0, COLUMNS(w)-1, + XawTABLE_RIGHT_DOWN, + row, column, (XtPointer)&templ)) { + return (True); + } + if (XawTableWalk(w, (XawTableProc)MatchLabel, + row_start, row_start, 0, column_start, + XawTABLE_RIGHT_DOWN, + row, column, (XtPointer)&templ)) { + return (True); + } + return (False); + +} + +/************************************************************** + * + * + * + * ROW routines + * + * + * + **************************************************************/ + +int +#ifdef Xraw_NEED_PROTO +XawTablePrependRow (Widget w) +#else +XawTablePrependRow(w) + Widget w; +#endif +{ + XawTableWidget tw = (XawTableWidget)w; + XawTableCell cell; + XawTableCallbackStruct callback_str; + + if (STUFF(tw) == NULL) { + String subs[1]; + Cardinal num_subs = 1; + subs[0] = w->core.name; + XtAppWarningMsg(XtWidgetToApplicationContext(w), + "prependRow", "XawTablePrependRow","XawToolkitError", + "An attempt to add a row in empty table in TableWidget '%s'", + subs, &num_subs); + return REJECT; + } + + + /* request for allowance */ + + cell = STUFF(tw); + + callback_str.reason = XawTABLE_ALLOW_ADD_ROW; + callback_str.event = (XEvent*)NULL; + callback_str.old_cell = cell; + callback_str.new_cell = cell; + callback_str.row = 0; + callback_str.column = 0; + callback_str.do_it = True; + + DO_CALLBACK(w, XtNallowAddRow, callback_str); + + if (callback_str.do_it != True) + return REJECT; + + +#ifdef EBUG_XRAW_MALLOC + CHECK_TABLE(tw); +#endif + + row_insert_before(STUFF(tw), sizeof(XawTableCellRec)); + ROWS(tw)++; + + STUFF(tw) = (XawTableCell)get_table(STUFF(tw)); + + WalkForCells(w, (XawTableProc)InitCell, 0, 0, 0, COLUMNS(tw)-1); + + if (XawTableIsEditManaged(w)) + MoveEditCell (tw, ++(tw->table.edit_row), tw->table.edit_column); + + UpdateTable(tw); + + +#ifdef EBUG_XRAW_MALLOC + CHECK_TABLE(tw); +#endif + + if (XtCallbackHasSome == XtHasCallbacks(w, XtNaddRow)) + { + cell = STUFF(tw); + + callback_str.reason = XawTABLE_ADD_ROW; + callback_str.event = (XEvent*)NULL; + callback_str.old_cell = cell; + callback_str.new_cell = cell; + callback_str.row = 0; + callback_str.column = 0; + callback_str.do_it = True; + + XtCallCallbacks (w, XtNaddRow, (XtPointer)&callback_str); + } + + return ACCEPT; +} + +int +#ifdef Xraw_NEED_PROTO +XawTableAppendRow (Widget w) +#else +XawTableAppendRow (w) + Widget w; +#endif +{ + XawTableWidget tw = (XawTableWidget)w; + XawTableCell cell; + XawTableCallbackStruct callback_str; + + if (STUFF(tw) == NULL) + { + String subs[1]; + Cardinal num_subs = 1; + subs[0] = w->core.name; + XtAppWarningMsg(XtWidgetToApplicationContext(w), + "appendRow", "XawTableAppendRow","XawToolkitError", + "An attempt to add a row in empty table in TableWidget '%s'", + subs, &num_subs); + return REJECT; + } + + + /* request for allowance */ + + cell = (XawTableCell)get_cell(STUFF(tw), ROWS(tw)-1, 0); + + callback_str.reason = XawTABLE_ALLOW_ADD_ROW; + callback_str.event = (XEvent*)NULL; + callback_str.old_cell = cell; + callback_str.new_cell = cell; + callback_str.row = 0; + callback_str.column = 0; + callback_str.do_it = True; + + DO_CALLBACK(w, XtNallowAddRow, callback_str); + + if (callback_str.do_it != True) + return REJECT; + + +#ifdef EBUG_XRAW_MALLOC + CHECK_TABLE(tw); +#endif + + row_insert_after(get_cell(STUFF(tw), ROWS(tw) - 1, 0), + sizeof(XawTableCellRec)); + + ROWS(tw)++; + + WalkForCells(w, (XawTableProc)InitCell, + ROWS(tw)-1, ROWS(tw)-1, 0, COLUMNS(tw)-1); + + UpdateTable(tw); + +#ifdef EBUG_XRAW_MALLOC + CHECK_TABLE(tw); +#endif + + if (XtCallbackHasSome == XtHasCallbacks(w, XtNaddRow)) + { + cell = (XawTableCell)get_cell(STUFF(tw), ROWS(tw)-1, 0); + + callback_str.reason = XawTABLE_ADD_ROW; + callback_str.event = (XEvent*)NULL; + callback_str.old_cell = cell; + callback_str.new_cell = cell; + callback_str.row = ROWS(tw)-1; + callback_str.column = 0; + callback_str.do_it = True; + + XtCallCallbacks (w, XtNaddRow, (XtPointer)&callback_str); + } + + return ACCEPT; +} + +int +#ifdef Xraw_NEED_PROTO +XawTableInsertRow (Widget w, int row) +#else +XawTableInsertRow (w, row) + Widget w; + int row; +#endif +{ + XawTableWidget tw = (XawTableWidget)w; + XawTableCell cell; + XawTableCallbackStruct callback_str; + + if (STUFF(tw) == NULL) { + String subs[1]; + Cardinal num_subs = 1; + subs[0] = w->core.name; + XtAppWarningMsg(XtWidgetToApplicationContext(w), + "insertRow", "XawTableInsertRow","XawToolkitError", + "An attempt to add a row in empty table in TableWidget '%s'", + subs, &num_subs); + return REJECT; + } + + if (row != InRange(row, 0, ROWS(tw)-1)) { + String subs[1]; + Cardinal num_subs = 1; + subs[0] = w->core.name; + XtAppWarningMsg(XtWidgetToApplicationContext(w), + "insertRow", "XawTableInsertRow","XawToolkitError", + "Incorrect attempt to insert a row in TableWidget '%s'", + subs, &num_subs); + return REJECT; + } + + /* request for allowance */ + + cell = (XawTableCell)get_cell(STUFF(tw), row, 0); + + callback_str.reason = XawTABLE_ALLOW_ADD_ROW; + callback_str.event = (XEvent*)NULL; + callback_str.old_cell = cell; + callback_str.new_cell = cell; + callback_str.row = 0; + callback_str.column = 0; + callback_str.do_it = True; + + DO_CALLBACK(w, XtNallowAddRow, callback_str); + + if (callback_str.do_it != True) + return REJECT; + + +#ifdef EBUG_XRAW_MALLOC + CHECK_TABLE(tw); +#endif + + row_insert_before(get_cell((XtPointer)STUFF(tw), row, 0), + sizeof(XawTableCellRec)); + + ROWS(tw)++; + + if (row == 0) + STUFF(tw) = (XawTableCell)get_table(STUFF(tw)); + + WalkForCells(w, (XawTableProc)InitCell, row, row, 0, COLUMNS(tw)-1); + +#ifdef EBUG_XRAW_MALLOC + CHECK_TABLE(tw); +#endif + + if (XawTableIsEditManaged(w) && row <= tw->table.edit_row){ + tw->table.no_redraw++; + MoveEditCell (tw, ++(tw->table.edit_row), tw->table.edit_column); + tw->table.no_redraw--; + } + + UpdateTable(tw); + + if (XtCallbackHasSome == XtHasCallbacks(w, XtNaddRow)) + { + cell = (XawTableCell)get_cell(STUFF(tw), row, 0); + + callback_str.reason = XawTABLE_ADD_ROW; + callback_str.event = (XEvent*)NULL; + callback_str.old_cell = cell; + callback_str.new_cell = cell; + callback_str.row = row; + callback_str.column = 0; + callback_str.do_it = True; + + XtCallCallbacks (w, XtNaddRow, (XtPointer)&callback_str); + } + + return ACCEPT; +} + +int +#ifdef Xraw_NEED_PROTO +XawTableDeleteRow (Widget w, int row) +#else +XawTableDeleteRow (w, row) + Widget w; + int row; +#endif +{ + XawTableWidget tw = (XawTableWidget)w; + XawTableCell cell; + XawTableCallbackStruct callback_str; + + if (STUFF(tw) == NULL) { + String subs[1]; + Cardinal num_subs = 1; + subs[0] = w->core.name; + XtAppWarningMsg(XtWidgetToApplicationContext(w), + "deleteRow", "XawTableDeleteRow","XawToolkitError", + "An attempt to delete a row in empty table in TableWidget '%s'", + subs, &num_subs); + return REJECT; + } + + if (row != InRange(row, 0, ROWS(tw)-1)) { + String subs[3]; + Cardinal num_subs = 3; + sprintf(subs[0], "%5d", row); + sprintf(subs[1], "%5d", ROWS(tw)-1); + subs[2] = w->core.name; + XtAppWarningMsg(XtWidgetToApplicationContext(w), + "deleteRow", "XawTableDeleteRow","XawToolkitError", + "Incorrect value of row (%s, max is %s) in TableWidget '%s'", + subs, &num_subs); + return REJECT; + } + + + /* request for allowance */ + + cell = (XawTableCell)get_cell(STUFF(tw), row, 0); + + callback_str.reason = XawTABLE_ALLOW_DELETE_ROW; + callback_str.event = (XEvent*)NULL; + callback_str.old_cell = cell; + callback_str.new_cell = cell; + callback_str.row = 0; + callback_str.column = 0; + callback_str.do_it = True; + + DO_CALLBACK(w, XtNallowDeleteRow, callback_str); + + if (callback_str.do_it != True) + return REJECT; + + +#ifdef EBUG_XRAW_MALLOC + CHECK_TABLE(tw); +#endif + + + if (XtCallbackHasSome == XtHasCallbacks(w, XtNdeleteRow)) + { + cell = (XawTableCell)get_cell(STUFF(tw), row, 0); + + callback_str.reason = XawTABLE_DELETE_ROW; + callback_str.event = (XEvent*)NULL; + callback_str.old_cell = cell; + callback_str.new_cell = cell; + callback_str.row = row; + callback_str.column = 0; + callback_str.do_it = True; + + XtCallCallbacks (w, XtNdeleteRow, (XtPointer)&callback_str); + } + + /* if selections owner locates here, then disown selections */ + + if (tw->table.cell_own != (XawTableCell)NULL) + { + Boolean have_find; + int i, j; + + have_find = go_table((XtPointer)w, CompareCells, STUFF(tw), + row, row, 0, COLUMNS(tw)-1, + XawTABLE_RIGHT_DOWN, &i, &j, + (XtPointer)tw->table.cell_own); + if (have_find) { + for (; 0 < tw->table.num_selections;) + XtDisownSelection (w, + tw->table.selections[--(tw->table.num_selections)], + XtLastTimestampProcessed(XtDisplay(w))); + + tw->table.cell_own = (XawTableCell)NULL; + } + } + + if (row == 0) + STUFF(tw) = (XawTableCell)get_cell(STUFF(tw), 1, 0); + + if (--ROWS(tw) == 0) + STUFF(tw) = (XawTableCell)NULL; + + WalkForCells(w, (XawTableProc)DeleteCell, row, row, 0, COLUMNS(tw)-1); + + row_delete(cell); + + if (XawTableIsEditManaged(w)) + { + tw->table.no_redraw++; + if (row < tw->table.edit_row){ + MoveEditCell (tw, --(tw->table.edit_row), tw->table.edit_column); + } + else if (row == tw->table.edit_row){ + UNMANAGE_EDIT(tw); + tw->table.edit_row = InRange (tw->table.edit_row, 0, ROWS(tw)-1); + XawTableSetEdit (w, tw->table.edit_row, tw->table.edit_column); + } + tw->table.no_redraw--; + } + + UpdateTable(tw); + +#ifdef EBUG_XRAW_MALLOC + CHECK_TABLE(tw); +#endif + + return ACCEPT; +} + + + +/************************************************************** + * + * + * + * COLUMN routines + * + * + * + **************************************************************/ + +int +#ifdef Xraw_NEED_PROTO +XawTablePrependColumn (Widget w, int width) +#else +XawTablePrependColumn (w, width) + Widget w; + int width; +#endif +{ + XawTableWidget tw = (XawTableWidget)w; + int j; + XawTableCell cell; + XawTableCallbackStruct callback_str; + + if (STUFF(tw) == NULL) { + String subs[1]; + Cardinal num_subs = 1; + subs[0] = w->core.name; + XtAppWarningMsg(XtWidgetToApplicationContext(w), + "prependColumn", "XawTablePrependColumn","XawToolkitError", + "An attempt to add a column in empty table in TableWidget '%s'", + subs, &num_subs); + return REJECT; + } + + /* request for allowance */ + + cell = STUFF(tw); + + callback_str.reason = XawTABLE_ALLOW_ADD_COLUMN; + callback_str.event = (XEvent*)NULL; + callback_str.old_cell = cell; + callback_str.new_cell = cell; + callback_str.row = 0; + callback_str.column = 0; + callback_str.do_it = True; + + DO_CALLBACK(w, XtNallowAddColumn, callback_str); + + if (callback_str.do_it != True) + return REJECT; + + +#ifdef EBUG_XRAW_MALLOC + CHECK_TABLE(tw); +#endif + + column_insert_before(STUFF(tw), sizeof(XawTableCellRec)); + COLUMNS(tw)++; + + STUFF(tw) = (XawTableCell)get_table(STUFF(tw)); + + WalkForCells(w, (XawTableProc)InitCell, 0, ROWS(tw)-1, 0, 0); + + /* + * insert new item in `column_data' list + */ + + if (tw->table.column_data) + { + tw->table.column_data = (XawTableColumn) + XtRealloc((XtPointer)tw->table.column_data, + (Cardinal)(COLUMNS(tw) * sizeof(XawTableColumnRec))); + } + else + { + tw->table.column_data = CALLOC(COLUMNS(tw), XawTableColumnRec); + for(j = 0; j < COLUMNS(tw); j++) + COLUMN_DATA(tw)[j].flag = 0; + } + + for(j = COLUMNS(tw)-2; j >= 0; j--) + (void)memcpy((char*)&(COLUMN_DATA(tw)[j+1]), (char*)&(COLUMN_DATA(tw)[j]), + sizeof(XawTableColumnRec)); + + COLUMN_DATA(tw)[0].flag |= _CL_width; + COLUMN_DATA(tw)[0].width = width; + + + if (XawTableIsEditManaged(w)) + MoveEditCell (tw, tw->table.edit_row, ++(tw->table.edit_column)); + + /* Let's look the table which we have made now */ + UpdateTable(tw); + + +#ifdef EBUG_XRAW_MALLOC + CHECK_TABLE(tw); +#endif + + if (XtCallbackHasSome == XtHasCallbacks(w, XtNaddColumn)) + { + cell = STUFF(tw); + + callback_str.reason = XawTABLE_ADD_COLUMN; + callback_str.event = (XEvent*)NULL; + callback_str.old_cell = cell; + callback_str.new_cell = cell; + callback_str.row = 0; + callback_str.column = 0; + callback_str.do_it = True; + + XtCallCallbacks (w, XtNaddColumn, (XtPointer)&callback_str); + } + + return ACCEPT; +} + +int +#ifdef Xraw_NEED_PROTO +XawTableAppendColumn (Widget w, int width) +#else +XawTableAppendColumn (w, width) + Widget w; + int width; +#endif +{ + XawTableWidget tw = (XawTableWidget)w; + int j; + XawTableCell cell; + XawTableCallbackStruct callback_str; + + if (STUFF(tw) == NULL) { + String subs[1]; + Cardinal num_subs = 1; + subs[0] = w->core.name; + XtAppWarningMsg(XtWidgetToApplicationContext(w), + "addingColumn", "XawTableAppendColumn","XawToolkitError", + "An attempt to add a column in empty table in TableWidget '%s'", + subs, &num_subs); + return REJECT; + } + + /* request for allowance */ + + cell = (XawTableCell)get_cell(STUFF(tw), 0, COLUMNS(tw)-1); + + callback_str.reason = XawTABLE_ALLOW_ADD_COLUMN; + callback_str.event = (XEvent*)NULL; + callback_str.old_cell = cell; + callback_str.new_cell = cell; + callback_str.row = 0; + callback_str.column = 0; + callback_str.do_it = True; + + DO_CALLBACK(w, XtNallowAddColumn, callback_str); + + if (callback_str.do_it != True) + return REJECT; + + + +#ifdef EBUG_XRAW_MALLOC + CHECK_TABLE(tw); +#endif + + column_insert_after(get_cell(STUFF(tw), 0, COLUMNS(tw)-1), + sizeof(XawTableCellRec)); + + COLUMNS(tw)++; + + WalkForCells(w, (XawTableProc)InitCell, + 0, ROWS(tw)-1, COLUMNS(tw)-1, COLUMNS(tw)-1); + + + + + /* + * insert new item in `column_data' list + */ + + if (tw->table.column_data) + { + tw->table.column_data = (XawTableColumn) + XtRealloc((XtPointer)tw->table.column_data, + (Cardinal)(COLUMNS(tw) * sizeof(XawTableColumnRec))); + } + else + { + tw->table.column_data = CALLOC(COLUMNS(tw), XawTableColumnRec); + for(j = 0; j < COLUMNS(tw); j++) + COLUMN_DATA(tw)[j].flag = 0; + } + + COLUMN_DATA(tw)[COLUMNS(tw)-1].flag |= _CL_width; + COLUMN_DATA(tw)[COLUMNS(tw)-1].width = width; + + + /* Let's look the table which we have made now */ + UpdateTable(tw); + + +#ifdef EBUG_XRAW_MALLOC + CHECK_TABLE(tw); +#endif + + if (XtCallbackHasSome == XtHasCallbacks(w, XtNaddColumn)) + { + cell = (XawTableCell)get_cell(STUFF(tw), 0, COLUMNS(tw)-1); + + callback_str.reason = XawTABLE_ADD_COLUMN; + callback_str.event = (XEvent*)NULL; + callback_str.old_cell = cell; + callback_str.new_cell = cell; + callback_str.row = 0; + callback_str.column = COLUMNS(tw)-1; + callback_str.do_it = True; + + XtCallCallbacks (w, XtNaddColumn, (XtPointer)&callback_str); + } + + return ACCEPT; +} + +int +#ifdef Xraw_NEED_PROTO +XawTableInsertColumn (Widget w, int column, int width) +#else +XawTableInsertColumn(w, column, width) + Widget w; + int column; + int width; +#endif +{ + XawTableWidget tw = (XawTableWidget)w; + XawTableCell cell; + int j; + XawTableCallbackStruct callback_str; + + if (STUFF(tw) == NULL) { + String subs[1]; + Cardinal num_subs = 1; + subs[0] = w->core.name; + XtAppWarningMsg(XtWidgetToApplicationContext(w), + "insertColumn", "XawTableInsertColumn","XawToolkitError", + "An attempt to add a column in empty table in TableWidget '%s'", + subs, &num_subs); + return REJECT; + } + + if (column != InRange(column, 0, COLUMNS(tw)-1)) { + String subs[1]; + Cardinal num_subs = 1; + subs[0] = w->core.name; + XtAppWarningMsg(XtWidgetToApplicationContext(w), + "insertColumn", "XawTableInsertColumn","XawToolkitError", + "It detected incorrect value of column in TableWidget '%s'", + subs, &num_subs); + return REJECT; + } + + /* request for allowance */ + + cell = (XawTableCell)get_cell(STUFF(tw), 0, column); + + callback_str.reason = XawTABLE_ALLOW_ADD_COLUMN; + callback_str.event = (XEvent*)NULL; + callback_str.old_cell = cell; + callback_str.new_cell = cell; + callback_str.row = 0; + callback_str.column = 0; + callback_str.do_it = True; + + DO_CALLBACK(w, XtNallowAddColumn, callback_str); + + if (callback_str.do_it != True) + return REJECT; + + +#ifdef EBUG_XRAW_MALLOC + CHECK_TABLE(tw); +#endif + + column_insert_before (get_cell ((XtPointer)STUFF(tw), 0, column), + sizeof(XawTableCellRec)); + COLUMNS(tw)++; + + if (column == 0) + STUFF(tw) = (XawTableCell) get_table (STUFF(tw)); + + WalkForCells(w, (XawTableProc)InitCell, 0, ROWS(tw)-1, column, column); + +#ifdef EBUG_XRAW_MALLOC + CHECK_TABLE(tw); +#endif + + /* + * insert new item in `column_data' list + */ + + if (tw->table.column_data) + { + tw->table.column_data = (XawTableColumn) + XtRealloc((XtPointer)tw->table.column_data, + (Cardinal)(COLUMNS(tw) * sizeof(XawTableColumnRec))); + } + else + { + tw->table.column_data = CALLOC(COLUMNS(tw), XawTableColumnRec); + for(j = 0; j < COLUMNS(tw); j++) + COLUMN_DATA(tw)[j].flag = 0; + } + + for(j = COLUMNS(tw)-2; j >= column; j--) + (void)memcpy((char*)&(COLUMN_DATA(tw)[j+1]), (char*)&(COLUMN_DATA(tw)[j]), + sizeof(XawTableColumnRec)); + + COLUMN_DATA(tw)[column].flag |= _CL_width; + COLUMN_DATA(tw)[column].width = width; + + /* + * move the edit cell + */ + + if (XawTableIsEditManaged(w) && column <= tw->table.edit_column){ + tw->table.no_redraw++; + MoveEditCell (tw, tw->table.edit_row, ++(tw->table.edit_column)); + tw->table.no_redraw--; + } + + /* Let's look the table which we have made now */ + UpdateTable(tw); + + if (XtCallbackHasSome == XtHasCallbacks(w, XtNaddColumn)) + { + cell = (XawTableCell)get_cell(STUFF(tw), 0, column); + + callback_str.reason = XawTABLE_ADD_COLUMN; + callback_str.event = (XEvent*)NULL; + callback_str.old_cell = cell; + callback_str.new_cell = cell; + callback_str.row = 0; + callback_str.column = column; + callback_str.do_it = True; + + XtCallCallbacks (w, XtNaddColumn, (XtPointer)&callback_str); + } + + return ACCEPT; +} + +int +#ifdef Xraw_NEED_PROTO +XawTableDeleteColumn (Widget w, int column) +#else +XawTableDeleteColumn(w, column) + Widget w; + int column; +#endif +{ + XawTableWidget tw = (XawTableWidget)w; + XawTableCell cell; + int j; + XawTableCallbackStruct callback_str; + + + if (STUFF(tw) == NULL) { + String subs[1]; + Cardinal num_subs = 1; + subs[0] = w->core.name; + XtAppWarningMsg(XtWidgetToApplicationContext(w), + "deleteColumn", "XawTableDeleteColumn","XawToolkitError", + "An attempt to delete a column in empty table in TableWidget '%s'", + subs, &num_subs); + return REJECT; + } + + if (column != InRange(column, 0, COLUMNS(tw)-1)) { + String subs[1]; + Cardinal num_subs = 1; + subs[0] = w->core.name; + XtAppWarningMsg(XtWidgetToApplicationContext(w), + "deleteColumn", "XawTableDeleteColumn","XawToolkitError", + "It detected incorrect value of column in TableWidget '%s'", + subs, &num_subs); + return REJECT; + } + + /* request for allowance */ + + cell = (XawTableCell)get_cell(STUFF(tw), 0, column); + + callback_str.reason = XawTABLE_ALLOW_DELETE_COLUMN; + callback_str.event = (XEvent*)NULL; + callback_str.old_cell = cell; + callback_str.new_cell = cell; + callback_str.row = 0; + callback_str.column = 0; + callback_str.do_it = True; + + DO_CALLBACK(w, XtNallowDeleteColumn, callback_str); + + if (callback_str.do_it != True) + return REJECT; + + + +#ifdef EBUG_XRAW_MALLOC + CHECK_TABLE(tw); +#endif + + if (XtCallbackHasSome == XtHasCallbacks(w, XtNdeleteColumn)) + { + cell = (XawTableCell)get_cell(STUFF(tw), 0, column); + + callback_str.reason = XawTABLE_DELETE_COLUMN; + callback_str.event = (XEvent*)NULL; + callback_str.old_cell = cell; + callback_str.new_cell = cell; + callback_str.row = 0; + callback_str.column = column; + callback_str.do_it = True; + + XtCallCallbacks (w, XtNdeleteColumn, (XtPointer)&callback_str); + } + + /* if selections owner locates here, then disown selections */ + + if (tw->table.cell_own != (XawTableCell)NULL) + { + Boolean have_find; + int i, j; + + have_find = go_table((XtPointer)w, CompareCells, STUFF(tw), + 0, ROWS(tw)-1, column, column, + XawTABLE_RIGHT_DOWN, &i, &j, + (XtPointer)tw->table.cell_own); + if (have_find) { + for (; 0 < tw->table.num_selections;) + XtDisownSelection (w, + tw->table.selections[--(tw->table.num_selections)], + XtLastTimestampProcessed(XtDisplay(w))); + + tw->table.cell_own = (XawTableCell)NULL; + } + } + + if (column == 0) + STUFF(tw) = (XawTableCell)get_cell(STUFF(tw), 0, 1); + + if (--COLUMNS(tw) == 0) + STUFF(tw) = (XawTableCell)NULL; + + + WalkForCells(w, (XawTableProc)DeleteCell, 0, ROWS(tw)-1, column, column); + + column_delete(cell); + + /* + * shrink column data list + */ + + if (COLUMNS(tw) == 0) { + XtFree((XtPointer)tw->table.column_data); + tw->table.column_data = NULL; + } + else + { + for(j = column; j < COLUMNS(tw); j++) + (void)memcpy((char*)&(COLUMN_DATA(tw)[j]),(char*)&(COLUMN_DATA(tw)[j+1]), + sizeof(XawTableColumnRec)); + + tw->table.column_data = (XawTableColumn) + XtRealloc((XtPointer)tw->table.column_data, + (Cardinal)(COLUMNS(tw) * sizeof(XawTableColumnRec))); + } + + + /* + * shift the edit cell + */ + + if (XawTableIsEditManaged(w)) + { + tw->table.no_redraw++; + if (column < tw->table.edit_column){ + MoveEditCell (tw, tw->table.edit_row, --(tw->table.edit_column)); + } + else if (column == tw->table.edit_column){ + UNMANAGE_EDIT(tw); + tw->table.edit_column = InRange (tw->table.edit_column,0,COLUMNS(tw)-1); + XawTableSetEdit (w, tw->table.edit_row, tw->table.edit_column); + } + tw->table.no_redraw--; + } + + /* Let's look the table which we have made now */ + UpdateTable(tw); + +#ifdef EBUG_XRAW_MALLOC + CHECK_TABLE(tw); +#endif + + return ACCEPT; +} + + +Boolean +#ifdef Xraw_NEED_PROTO +XawTableIsEditManaged (Widget w) +#else +XawTableIsEditManaged (w) + Widget w; +#endif +{ + return XtIsManaged(((XawTableWidget)w)->table.edit); +} + + + +int +#ifdef Xraw_NEED_PROTO +XawTableSetLabel (Widget w, int row, int column, char *raw_label) +#else +XawTableSetLabel(w, row, column, raw_label) + Widget w; + int row; + int column; + char *raw_label; +#endif +{ + register XawTableWidget tw = (XawTableWidget)w; + XawTableCallbackStruct callback_str; + XawTableCell cell; + char* label = NULL; + XawTableCellRec new; + + if ((ROWS(tw) < 1) || (COLUMNS(tw) < 1) || + (row != InRange(row, 0, ROWS(tw)-1)) || + (column != InRange(column, 0, COLUMNS(tw)-1))) + { + String subs[3]; + Cardinal num_subs = 3; + sprintf(subs[0], "%5d", row); + sprintf(subs[1], "%5d", column); + subs[2] = w->core.name; + XtAppWarningMsg(XtWidgetToApplicationContext(w), + "SetLabel", "XawTableSetLabel","XawToolkitError", +"XawTableSetLabel\nIncorrect value of rows or columns (%s,%s) in TableWidget '%s' ", + subs, &num_subs); + return REJECT; + } + + cell = (XawTableCell)get_cell(STUFF(tw), row, column); + + if (raw_label == (char*)NULL) + label = DummyString(); + else + label = CopyOnlyPrintable(raw_label); + + if (streq(label,CELL(label))) { + XtFree(label); /* XtMalloc in CopyOnlyPrintable */ + return ACCEPT; + } + + (void)memcpy((char*)&new, (char*)cell, sizeof(XawTableCellRec)); + new.label = label; + + callback_str.reason = XawTABLE_CHANGED_CELL; + callback_str.event = (XEvent*)NULL; + callback_str.old_cell = cell; + callback_str.new_cell = &new; + callback_str.row = row; + callback_str.column = column; + callback_str.do_it = True; + + DO_CALLBACK(w, XtNchangedCell, callback_str); + + if (callback_str.do_it != True) { + XtFree(label); + return REJECT; + } + + + if (CELL(label)) + XtFree(CELL(label)); + + (void)memcpy((char*)cell, (char*)&new, sizeof(XawTableCellRec)); + + SetLabelWidth (tw, row, column); + Reposition (tw, cell, row, column); + + if (IsEditInRowColumn (tw, row, column)) + { + XtVaSetValues (EDIT(w), "string", CELL(label), NULL); + } + else if (XtIsRealized (w) && w->core.visible && !tw->table.no_redraw) + { + int x = GetX(tw,column); + int y = GetY(tw,row); + unsigned int width = (unsigned int) COLUMN_WIDTH(tw,column); + unsigned int height = (unsigned int) tw->table.row_height; + + XClearArea (XtDisplay(w), XtWindow(w), x, y, width, height, FALSE); + (void) PaintCell (w, row, column, (XtPointer)cell, (XtPointer)NULL); + } + return ACCEPT; +} + + + + +int +#ifdef Xraw_NEED_PROTO +XawTableSetCellColours (Widget w, int row, int column, + Pixel fore, Pixel back) +#else +XawTableSetCellColours (w, row, column, fore, back) + Widget w; + int row; + int column; + Pixel fore; + Pixel back; +#endif +{ + XawTableWidget tw = (XawTableWidget)w; + XawTableCallbackStruct callback_str; + XawTableCell cell; + XawTableCellRec new; + NormalReverseGC* normal; + ShadowGC* shadow; + + + + if ((ROWS(tw) < 1) || (COLUMNS(tw) < 1) || + (row != InRange (row, 0, ROWS(tw)-1)) || + (column != InRange (column, 0, COLUMNS(tw)-1))) + { + String subs[3]; + Cardinal num_subs = 3; + sprintf(subs[0], "%5d", row); + sprintf(subs[1], "%5d", column); + subs[2] = w->core.name; + XtAppWarningMsg(XtWidgetToApplicationContext(w), + "SetCellColours", "XawTableSetCellColours","XawToolkitError", +"XawTableSetCellColours\nIncorrect value of rows or columns (%s,%s) in TableWidget '%s' ", + subs, &num_subs); + return REJECT; + } + cell = (XawTableCell)get_cell(STUFF(tw), row, column); + + if (CELL(special_colour) && fore == CELL(fore) && back == CELL(back)) + return ACCEPT; + + /* + * prepare new cell stuff from old one + */ + (void)memcpy((char*)&new, (char*)cell, sizeof(XawTableCellRec)); + new.special_colour = True; + new.back = back; + new.fore = fore; + + /* normal and reverse GC's */ + normal = GetNormalGC(w, fore, back, tw->table.font->fid); + + new.normal = normal->normal; + new.reverse = normal->reverse; + + + /* shadow GC's */ + shadow = GetShadowGC(w, back); + + new.top = shadow->top; + new.bottom = shadow->bottom; + + + callback_str.reason = XawTABLE_CHANGED_CELL; + callback_str.event = (XEvent*)NULL; + callback_str.old_cell = cell; + callback_str.new_cell = &new; + callback_str.row = row; + callback_str.column = column; + callback_str.do_it = True; + + DO_CALLBACK(w, XtNchangedCell, callback_str); + + if (callback_str.do_it) + { + int x = GetX(tw,column); + int y = GetY(tw,row); + unsigned int width = (unsigned int) COLUMN_WIDTH(tw,column); + unsigned int height = (unsigned int) tw->table.row_height; + + if (XtIsRealized(w) && w->core.visible && + !tw->table.no_redraw && !tw->table.no_refigure) { + XClearArea (XtDisplay(w), XtWindow(w), + x + tw->table.label_shadow_thickness, + y + tw->table.label_shadow_thickness, + width, height, FALSE); + PaintLabel (w, row, column, x, y, &new); + PaintShadow (w, row, column, x, y, &new); + XFlush(XtDisplay(w)); + } + + if (CELL(special_colour)) { + ReleaseNormalGC(w, CELL(fore), CELL(back)); + ReleaseShadowGC(w, CELL(back)); + } + (void)memcpy((char*)cell, (char*)&new, sizeof(XawTableCellRec)); + + return ACCEPT; + } + else + { + ReleaseNormalGC(w, fore, back); + ReleaseShadowGC(w, back); + return REJECT; + } +} + + +int +#ifdef Xraw_NEED_PROTO +XawTableSetCellDefaultColours (Widget w, int row, int column) +#else +XawTableSetCellDefaultColours (w, row, column) + Widget w; + int row; + int column; +#endif +{ + XawTableWidget tw = (XawTableWidget)w; + XawTableCallbackStruct callback_str; + XawTableCell cell; + XawTableCellRec new; + + if ((ROWS(tw) < 1) || (COLUMNS(tw) < 1) || + (row != InRange (row, 0, ROWS(tw)-1)) || + (column != InRange (column, 0, COLUMNS(tw)-1))) + { + String subs[3]; + Cardinal num_subs = 3; + sprintf(subs[0], "%5d", row); + sprintf(subs[1], "%5d", column); + subs[2] = w->core.name; + XtAppWarningMsg(XtWidgetToApplicationContext(w), + "SetCellColours", "XawTableSetCellDefaultColours","XawToolkitError", +"XawTableSetCellDefaultColours\n\ +Incorrect value of row or column (%s,%s) in Table widget '%s'", + subs, &num_subs); + return REJECT; + } + + cell = (XawTableCell)get_cell(STUFF(tw), row, column); + + if (!CELL(special_colour)) + return ACCEPT; + + /* + * prepare new cell stuff from old one + */ + (void)memcpy((char*)&new, (char*)cell, sizeof(XawTableCellRec)); + new.special_colour = False; + new.fore = tw->table.foreground; + new.back = tw->core.background_pixel; + + callback_str.reason = XawTABLE_CHANGED_CELL; + callback_str.event = (XEvent*)NULL; + callback_str.old_cell = cell; + callback_str.new_cell = &new; + callback_str.row = row; + callback_str.column = column; + callback_str.do_it = True; + + DO_CALLBACK(w, XtNchangedCell, callback_str); + + if (callback_str.do_it) + { + int x = GetX(tw,column); + int y = GetY(tw,row); + unsigned int width = (unsigned int) COLUMN_WIDTH(tw,column); + unsigned int height = (unsigned int) tw->table.row_height; + + if (XtIsRealized(w) && w->core.visible && !tw->table.no_redraw) { + XClearArea (XtDisplay(w), XtWindow(w), + x + tw->table.label_shadow_thickness, + y + tw->table.label_shadow_thickness, + width, height, FALSE); + PaintLabel (w, row, column, x, y, &new); + PaintShadow (w, row, column, x, y, &new); + XFlush(XtDisplay(w)); + } + + if (CELL(special_colour)) { + ReleaseNormalGC(w, CELL(fore), CELL(back)); + ReleaseShadowGC(w, CELL(back)); + } + (void)memcpy((char*)cell, (char*)&new, sizeof(XawTableCellRec)); + + return ACCEPT; + } + else + { + return REJECT; + } +} + +int +#ifdef Xraw_NEED_PROTO +XawTableSetCellBackground (Widget w, int row, int column, Pixel back) +#else +XawTableSetCellBackground (w, row, column, back) + Widget w; + int row; + int column; + Pixel back; +#endif +{ + XawTableWidget tw = (XawTableWidget)w; + XawTableCallbackStruct callback_str; + XawTableCell cell; + XawTableCellRec new; + NormalReverseGC* normal; + ShadowGC* shadow; + + if ((ROWS(tw) < 1) || (COLUMNS(tw) < 1) || + (row != InRange (row, 0, ROWS(tw)-1)) || + (column != InRange (column, 0, COLUMNS(tw)-1))) + { + String subs[3]; + Cardinal num_subs = 3; + sprintf(subs[0], "%5d", row); + sprintf(subs[1], "%5d", column); + subs[2] = w->core.name; + XtAppWarningMsg(XtWidgetToApplicationContext(w), + "SetCellColours", "XawTableSetCellBackground","XawToolkitError", +"XawTableSetCellBackground\n\ +Incorrect value of row or column (%s,%s) in Table widget '%s'", + subs, &num_subs); + return REJECT; + } + + cell = (XawTableCell)get_cell(STUFF(tw), row, column); + + if (CELL(special_colour) && back == CELL(back)) + return ACCEPT; + + /* + * prepare new cell stuff from old one + */ + (void)memcpy((char*)&new, (char*)cell, sizeof(XawTableCellRec)); + new.special_colour = True; + new.back = back; + + if (!CELL(special_colour)) + new.fore = tw->table.foreground; + + /* normal and reverse GC's */ + normal = GetNormalGC(w, new.fore, back, tw->table.font->fid); + + new.normal = normal->normal; + new.reverse = normal->reverse; + + + /* shadow GC's */ + shadow = GetShadowGC(w, back); + + new.top = shadow->top; + new.bottom = shadow->bottom; + + + callback_str.reason = XawTABLE_CHANGED_CELL; + callback_str.event = (XEvent*)NULL; + callback_str.old_cell = cell; + callback_str.new_cell = &new; + callback_str.row = row; + callback_str.column = column; + callback_str.do_it = True; + + DO_CALLBACK(w, XtNchangedCell, callback_str); + + if (callback_str.do_it) + { + int x = GetX(tw,column); + int y = GetY(tw,row); + unsigned int width = (unsigned int) COLUMN_WIDTH(tw,column); + unsigned int height = (unsigned int) tw->table.row_height; + + if (XtIsRealized(w) && w->core.visible && !tw->table.no_redraw) { + XClearArea (XtDisplay(w), XtWindow(w), + x + tw->table.label_shadow_thickness, + y + tw->table.label_shadow_thickness, + width, height, FALSE); + PaintLabel (w, row, column, x, y, &new); + PaintShadow (w, row, column, x, y, &new); + XFlush(XtDisplay(w)); + } + + if (CELL(special_colour)) { + ReleaseNormalGC(w, CELL(fore), CELL(back)); + ReleaseShadowGC(w, CELL(back)); + } + (void)memcpy((char*)cell, (char*)&new, sizeof(XawTableCellRec)); + + return ACCEPT; + } + else + { + ReleaseNormalGC(w, new.fore, back); + ReleaseShadowGC(w, back); + return REJECT; + } + +} + +int +#ifdef Xraw_NEED_PROTO +XawTableSetCellForeground (Widget w, int row, int column, Pixel fore) +#else +XawTableSetCellForeground (w, row, column, fore) + Widget w; + int row; + int column; + Pixel fore; +#endif +{ + XawTableWidget tw = (XawTableWidget)w; + XawTableCallbackStruct callback_str; + XawTableCell cell; + XawTableCellRec new; + NormalReverseGC* normal; + ShadowGC* shadow; + + if ((ROWS(tw) < 1) || (COLUMNS(tw) < 1) || + (row != InRange (row, 0, ROWS(tw)-1)) || + (column != InRange (column, 0, COLUMNS(tw)-1))) + { + String subs[3]; + Cardinal num_subs = 3; + sprintf(subs[0], "%5d", row); + sprintf(subs[1], "%5d", column); + subs[2] = w->core.name; + XtAppWarningMsg(XtWidgetToApplicationContext(w), + "SetCellColours", "XawTableSetCellBackground","XawToolkitError", +"XawTableSetCellBackground\n\ +Incorrect value of row or column (%s,%s) in Table widget '%s'", + subs, &num_subs); + return REJECT; + } + + cell = (XawTableCell)get_cell(STUFF(tw), row, column); + + if (CELL(special_colour) && fore == CELL(fore)) + return ACCEPT; + + /* + * prepare new cell stuff from old one + */ + (void)memcpy((char*)&new, (char*)cell, sizeof(XawTableCellRec)); + new.special_colour = True; + new.fore = fore; + + if (!CELL(special_colour)) + new.back = tw->core.background_pixel; + + /* normal and reverse GC's */ + normal = GetNormalGC(w, fore, new.back, tw->table.font->fid); + + new.normal = normal->normal; + new.reverse = normal->reverse; + + + /* shadow GC's */ + shadow = GetShadowGC(w, new.back); + + new.top = shadow->top; + new.bottom = shadow->bottom; + + + callback_str.reason = XawTABLE_CHANGED_CELL; + callback_str.event = (XEvent*)NULL; + callback_str.old_cell = cell; + callback_str.new_cell = &new; + callback_str.row = row; + callback_str.column = column; + callback_str.do_it = True; + + DO_CALLBACK(w, XtNchangedCell, callback_str); + + if (callback_str.do_it) + { + int x = GetX(tw,column); + int y = GetY(tw,row); + unsigned int width = (unsigned int) COLUMN_WIDTH(tw,column); + unsigned int height = (unsigned int) tw->table.row_height; + + if (XtIsRealized(w) && w->core.visible && !tw->table.no_redraw) { + XClearArea (XtDisplay(w), XtWindow(w), + x + tw->table.label_shadow_thickness, + y + tw->table.label_shadow_thickness, + width, height, FALSE); + PaintLabel (w, row, column, x, y, &new); + PaintShadow (w, row, column, x, y, &new); + XFlush(XtDisplay(w)); + } + + if (CELL(special_colour)) { + ReleaseNormalGC(w, CELL(fore), CELL(back)); + ReleaseShadowGC(w, CELL(back)); + } + (void)memcpy((char*)cell, (char*)&new, sizeof(XawTableCellRec)); + + return ACCEPT; + } + else + { + ReleaseNormalGC(w, fore, new.back); + ReleaseShadowGC(w, new.back); + return REJECT; + } +} + +void +#ifdef Xraw_NEED_PROTO +XawTableGetCellColours (Widget w, int row, int column, + Pixel *fore, Pixel *back) +#else +XawTableGetCellColours (w, row, column, fore, back) + Widget w; + int row; + int column; + Pixel *fore; + Pixel *back; +#endif +{ + XawTableWidget tw = (XawTableWidget)w; + XawTableCell cell = (XawTableCell)get_cell(STUFF(tw), row, column); + + + if (cell && cell->special_colour) { + *fore = cell->fore; + *back = cell->back; + } + else { + *fore = tw->table.foreground; + *back = tw->core.background_pixel; + } +} + +void +#ifdef Xraw_NEED_PROTO +XawTableGetCellColoursByCell (Widget w, XawTableCell cell, + Pixel *fore, Pixel *back) +#else +XawTableGetCellColoursByCell (w, cell, fore, back) + Widget w; + XawTableCell cell; + Pixel *fore; + Pixel *back; +#endif +{ + XawTableWidget tw = (XawTableWidget)w; + + if (cell && cell->special_colour) { + *fore = cell->fore; + *back = cell->back; + } + else { + *fore = tw->table.foreground; + *back = tw->core.background_pixel; + } +} + +/*#########################################################################*/ +/*# #*/ +/*# Column Defaults #*/ +/*# #*/ +/*#########################################################################*/ + +#ifdef notdef +/* ARGSUSED */ +static Boolean PaintCellWithClear(p, i, j, call_data, client_data) + XtPointer p; + int i; + int j; + XtPointer call_data; + XtPointer client_data; /* unused */ +{ + Widget w = (Widget) p; + XawTableWidget tw = (XawTableWidget) w; + XawTableCell cell = (XawTableCell) call_data; + unsigned int width = (unsigned int) COLUMN_WIDTH(tw,j); + unsigned int height = (unsigned int) tw->table.row_height; + Position x; + Position y; + + + x = GetX(tw,j); + y = GetY(tw,i); + + XClearArea (XtDisplay(w), XtWindow(w), + x + tw->table.label_shadow_thickness, + y + tw->table.label_shadow_thickness, + width, height, FALSE); + + PaintLabel (w, i, j, x, y, cell); + PaintShadow (w, i, j, x, y, cell); + + XFlush(XtDisplay(w)); + return False; +} +#endif + +void +#ifdef Xraw_NEED_PROTO +XawTableSetColumnJustify (Widget w, int column, XtJustify justify) +#else +XawTableSetColumnJustify (w, column, justify) + Widget w; + int column; + XtJustify justify; +#endif +{ + XawTableWidget tw = (XawTableWidget)w; + int i, j; + + if (column != InRange (column, 0, COLUMNS(tw)-1)) + return; + + COLUMN_DATA(tw)[column].flag |= _CL_justify; + COLUMN_DATA(tw)[column].justify = justify; + + for(i = 0; i < ROWS(tw); i++) + Reposition(tw, NULL, i, column); + + if (XtIsRealized(w) && w->core.visible && + !tw->table.no_redraw && !tw->table.no_refigure) + { + (void)go_table((XtPointer)w, PaintCell, STUFF(tw), + 0, ROWS(tw)-1, column, column, + XawTABLE_DOWN_RIGHT, + &i, &j, (XtPointer)NULL); + XFlush(XtDisplay(w)); + } +} + + +XtJustify +#ifdef Xraw_NEED_PROTO +XawTableGetColumnJustify (Widget w, int column) +#else +XawTableGetColumnJustify (w, column) + Widget w; + int column; +#endif +{ + XawTableWidget tw = (XawTableWidget)w; + + if (column != InRange (column, 0, COLUMNS(tw)-1)) + return XtJustifyCenter; + + if (COLUMN_DATA(tw)[column].flag & _CL_justify) + return COLUMN_DATA(tw)[column].justify; + + return XtJustifyCenter; +} + + +void +#ifdef Xraw_NEED_PROTO +XawTableSetColumnWidth (Widget w, int column, int width) +#else +XawTableSetColumnWidth(w, column, width) + Widget w; + int column; + int width; +#endif +{ + XawTableWidget tw = (XawTableWidget)w; + XawTableCallbackStruct callback_str; + register int row; + + if (column != InRange (column, 0, COLUMNS(tw)-1)) + return; + + if ((COLUMN_DATA(tw)[column].flag & _CL_width) && + COLUMN_DATA(tw)[column].width == width) + return; + + COLUMN_DATA(tw)[column].flag |= _CL_width; + COLUMN_DATA(tw)[column].width = width; + + for(row = 0; row < ROWS(tw); row++) + Reposition(tw, NULL, row, column); + + UpdateTable(tw); + + callback_str.reason = XawTABLE_CHANGED_COLUMN_WIDTH; + callback_str.event = (XEvent*)NULL; + callback_str.old_cell = (XawTableCell)NULL; + callback_str.new_cell = (XawTableCell)NULL; + callback_str.row = 0; + callback_str.column = column; + callback_str.do_it = True; + + DO_CALLBACK(w, XtNchangedColumnWidth, callback_str); +} + + + +int +#ifdef Xraw_NEED_PROTO +XawTableGetColumnWidth (Widget w, int column) +#else +XawTableGetColumnWidth(w, column) + Widget w; + int column; +#endif +{ + XawTableWidget tw = (XawTableWidget)w; + + if (column != InRange (column, 0, COLUMNS(tw)-1)) + return tw->table.column_default_width; + + if ((COLUMN_DATA(tw)[column].flag & _CL_width)) + return COLUMN_DATA(tw)[column].width; + + return tw->table.column_default_width; +} + +int +#ifdef Xraw_NEED_PROTO +XawTableGetColumnPixelWidth (Widget w, int column) +#else +XawTableGetColumnPixelWidth(w, column) + Widget w; + int column; +#endif +{ + XawTableWidget tw = (XawTableWidget)w; + int width; + + if (column != InRange (column, 0, COLUMNS(tw)-1)) + width = tw->table.column_default_width; + else if ((COLUMN_DATA(tw)[column].flag & _CL_width)) + width = COLUMN_DATA(tw)[column].width; + else + width = tw->table.column_default_width; + + if (tw->table.literal) { + width = width * tw->table.literal_width + 2 * tw->table.internal_width; + } + + return width; +} + +char * +#ifdef Xraw_NEED_PROTO +XawTableGetLabelByPosition (Widget w, int i, int j) +#else + XawTableGetLabelByPosition(w,i,j) + Widget w; + int i,j; +#endif +{ + XawTableWidget tw = (XawTableWidget)w; + XawTableCell cell; + + + if ((ROWS(tw) < 1) || (COLUMNS(tw) < 1) || + (i != InRange(i, 0, ROWS(tw)-1)) || + (j != InRange(j, 0, COLUMNS(tw)-1))) + { + String subs[3]; + Cardinal num_subs = 3; + sprintf(subs[0], "%5d", i); + sprintf(subs[1], "%5d", j); + subs[2] = w->core.name; + XtAppWarningMsg(XtWidgetToApplicationContext(w), + "GetLabelByPosition", "XawTableGetLabelByPosition","XawToolkitError", +"XawTableGetLabelByPosition\nIncorrect value of rows or columns (%s,%s) in TableWidget '%s' ", + subs, &num_subs); + return NULL; + } + + cell = (XawTableCell)get_cell(STUFF(tw), i, j); + return GET_CELL_LABEL; +} + +void +#ifdef Xraw_NEED_PROTO +XawTableUnsetEdit (Widget w) +#else + XawTableUnsetEdit(w) + Widget w; +#endif +{ + XawTableWidget tw = (XawTableWidget)w; + char* label; + XawTableCell cell; + + if (XawTableIsEditManaged(w)) + { + tw->table.no_redraw++; + UNMANAGE_EDIT(tw); + tw->table.no_redraw--; + + XtVaGetValues(EDIT(w), "string", &label, NULL); + + label = CopyOnlyPrintable(label); + + cell = (XawTableCell) + get_cell(STUFF(tw),tw->table.edit_row, tw->table.edit_column); + + if (!streq(label,CELL(label))) + XawTableSetLabel(w, tw->table.edit_row, tw->table.edit_column, label); + + XtFree(label); /* XtMalloc in CopyOnlyPrintable */ + } +} + +void +#ifdef Xraw_NEED_PROTO +XawTableSetEdit (Widget w, int row, int column) +#else + XawTableSetEdit(w, row, column) + Widget w; + int row; + int column; +#endif +{ + XawTableWidget tw = (XawTableWidget)w; + XawTableCell cell; + + if (IsEditInRowColumn(tw, row, column) || STUFF(tw) == NULL) + return; + + if ((ROWS(tw) < 1) || (COLUMNS(tw) < 1) || + (row != InRange(row, 0, ROWS(tw)-1)) || + (column != InRange(column, 0, COLUMNS(tw)-1))) + { + String subs[3]; + Cardinal num_subs = 3; + sprintf(subs[0], "%5d", row); + sprintf(subs[1], "%5d", column); + subs[2] = w->core.name; + XtAppWarningMsg(XtWidgetToApplicationContext(w), + "SetEdit", "XawTableSetEdit","XawToolkitError", +"XawTableSetEdit\nIncorrect value of rows or columns (%s,%s) in TableWidget '%s' ", + subs, &num_subs); + return; + } + + XawTableUnsetEdit(w); + + cell = (XawTableCell)get_cell(STUFF(tw), row, column); + + if (CELL(label) == NULL) + XtVaSetValues(EDIT(tw), "string", Dummy, NULL); + else + XtVaSetValues(EDIT(tw), "string", CELL(label), NULL); + + tw->table.edit_row = row; + tw->table.edit_column = column; + + MoveEditCell (tw, tw->table.edit_row, tw->table.edit_column); + + MANAGE_EDIT(tw); +} + +/****************************************************************** + * + * Actions + * + ******************************************************************/ + +static void HighlightCell(w,event,params,num_params) + Widget w; + XEvent *event; + String *params; + Cardinal *num_params; +{ + XawTableWidget tw = (XawTableWidget)w; + XawTableCell cell; + int row, column; + Position x,y; + Time tm; + + if (!tw->table.editable) + return; + + if (*num_params == 2) + { + row = atoi(params[0]); + column = atoi(params[1]); + } + else if (event != (XEvent*)NULL) + { + ExtractPosition(event, &x, &y , &tm); + if (ExtractCell(tw, x, y, &row, &column)) + return ; + } + else + { + return; + } + + cell = (XawTableCell) get_cell (STUFF(tw), row, column); + + if (CELL(highlight)) + return ; + + CELL(highlight) = True; + + x = GetX(tw,column); + y = GetY(tw,row); + + PaintLabel(w, row, column, x, y, cell); + XFlush(XtDisplay(w)); +} + +/* ARGSUSED */ +static void UnhighlightCell(w,event,params,num_params) + Widget w; + XEvent *event; + String *params; /* unused */ + Cardinal *num_params; +{ + XawTableWidget tw = (XawTableWidget)w; + XawTableCell cell; + int row, column; + Position x,y; + Time tm; + unsigned int width; + unsigned int height; + + if (!tw->table.editable) + return; + + if (*num_params == 2) + { + row = atoi(params[0]); + column = atoi(params[1]); + } + else if (event != (XEvent*)NULL) + { + ExtractPosition(event, &x, &y , &tm); + if (ExtractCell(tw, x, y, &row, &column)) + return ; + } + else + { + return; + } + + cell = (XawTableCell)get_cell(STUFF(tw), row, column); + + if (!CELL(highlight)) + return ; + + CELL(highlight) = False; + + width = (unsigned int) COLUMN_WIDTH(tw, column) + + 2 * tw->table.label_shadow_thickness; + height = (unsigned int) tw->table.row_height + + 2 * tw->table.label_shadow_thickness; + + XClearArea(XtDisplay(w), XtWindow(w), + (int)GetX(tw,column), + (int)GetY(tw,row), + width, height, FALSE); + + PaintLabel(w, row, column, x, y, cell); + + XFlush(XtDisplay(w)); + +} + +/* ARGSUSED */ +static void WhatCell(w,event,params,num_params) + Widget w; + XEvent *event; + String *params; /* unused */ + Cardinal *num_params; +{ + XawTableWidget tw = (XawTableWidget)w; + Position x,y; + int row, column; + XawTableCallbackStruct callback_str; + XawTableCell cell; + Time tm; + + if (event->type != ButtonPress && event->type != ButtonRelease) + return; + + ExtractPosition(event, &x, &y , &tm); + + if (ExtractCell(tw, x, y, &row, &column)) + return ; + + cell = (XawTableCell) get_cell (STUFF(tw), row, column); + + callback_str.reason = XawTABLE_WHAT_CELL; + callback_str.event = event; + callback_str.old_cell = cell; + callback_str.new_cell = cell; + callback_str.row = row; + callback_str.column = column; + callback_str.do_it = True; + + DO_CALLBACK(w, XtNwhatCell, callback_str); +} + +/* ARGSUSED */ +static void KeyReturn(w, event, params, num_params) + Widget w; + XEvent *event; + String *params; /* unused */ + Cardinal *num_params; /* unused */ +{ + Widget tw; + KeySym ksSymbol; + + ksSymbol = XtGetActionKeysym(event, (Modifiers*)NULL); + + if (ksSymbol == XK_Return || ksSymbol == XK_Linefeed) + { + XtVaGetValues(w, XtNuserData, &tw, NULL); + XawTableUnsetEdit(tw); + } + +} + +static Atom FetchAtom(w, name) + Widget w; + String name; +{ + Atom a; + XrmValue source, dest; + + source.size = strlen(name)+1; + source.addr = name; + dest.size = sizeof(Atom); + dest.addr = (XtPointer) &a; + + (void) XtConvertAndStore(w, XtRString, &source, XtRAtom, &dest); + return a; +} + +/* ARGSUSED */ +static Boolean DeliverSelection(w, selection, target, + type, value, length, format) + Widget w; + Atom *selection, *target, *type; + XtPointer *value; + unsigned long *length; + int *format; +{ + XawTableWidget tw = (XawTableWidget) w; + static Atom targets = 0; + + if (targets == 0) { + targets = FetchAtom(w, "TARGETS"); + } + + if (*target == targets) { + *type = XA_ATOM; + *value = (XtPointer) CALLOC(1, Atom); + *(Atom *) *value = XA_STRING; + *length = 1; + *format = 32; + return TRUE; + } + + if (*target == XA_STRING) { + *type = XA_STRING; + *value = (XtPointer) XtNewString(tw->table.cell_own->label); + *length = tw->table.cell_own->label_len; + *format = 8; + return TRUE; + } + + return FALSE; +} + +/* ARGSUSED */ +static void LoseSelection(w, selection) + Widget w; + Atom *selection; +{ + XawTableWidget tw = (XawTableWidget) w; + XawTableCell cell; + int row, column; + int x,y; + unsigned int width, height; + + cell = tw->table.cell_own; + tw->table.cell_own = (XawTableCell)NULL; + + if (!CELL(highlight)) + return ; + + get_cell_positions(cell, &row, &column); + + CELL(highlight) = False; + + x = GetX(tw,column) + tw->table.label_shadow_thickness; + y = GetY(tw,row) + tw->table.label_shadow_thickness; + width = (unsigned int) COLUMN_WIDTH(tw, column); + height = (unsigned int) tw->table.row_height; + + XClearArea(XtDisplay(w), XtWindow(w), x, y, width, height, FALSE); + (void)PaintCell(w, row, column, (XtPointer)cell, (XtPointer)NULL); + + XFlush(XtDisplay(w)); +} + +static int GetCutBufferNumber(); + +static void StoreBuffer(w, event, params, num_params) + Widget w; + XEvent *event; + String *params; /* selections in precedence order */ + Cardinal *num_params; +{ + XawTableWidget tw = (XawTableWidget)w; + Position x, y; + int row, column; + int i, buffer; + Time tm; + Atom selection; + + if (!tw->table.editable) + return; + + if (event->type != ButtonPress && event->type != ButtonRelease) + return; + + ExtractPosition(event, &x, &y ,&tm); + + if (ExtractCell(tw, x, y, &row, &column)) + return ; + + if (tw->table.cell_own != (XawTableCell)NULL) + LoseSelection(w, (Atom*)NULL); + + tw->table.cell_own = (XawTableCell)get_cell(STUFF(tw), row, column); + + for(i=0; i<(int)*num_params; i++) { + selection = FetchAtom(w, *(String *)(params+i)); + + buffer = GetCutBufferNumber(selection); + + if (buffer >= 0) { + if (buffer == 0) { + +#define Create(buffer) \ + XChangeProperty(XtDisplay(w), DefaultRootWindow(XtDisplay(w)),\ + buffer,XA_STRING, 8,PropModeAppend, NULL, 0) + + Create(XA_CUT_BUFFER0); + Create(XA_CUT_BUFFER1); + Create(XA_CUT_BUFFER2); + Create(XA_CUT_BUFFER3); + Create(XA_CUT_BUFFER4); + Create(XA_CUT_BUFFER5); + Create(XA_CUT_BUFFER6); + Create(XA_CUT_BUFFER7); +#undef Create + + XRotateBuffers(XtDisplay(w), 1); + } + + XStoreBuffer(XtDisplay(w), tw->table.cell_own->label, + (int)MIN(tw->table.cell_own->label_len, MAXCUT), buffer); + + } else { + tw->table.selections[tw->table.num_selections++] = selection; + + XtOwnSelection (w, selection, tm, + DeliverSelection, LoseSelection, + (XtSelectionDoneProc) NULL); + } + } +} + + +/* ARGSUSED */ +static void CallEdit(w,event,params,num_params) + Widget w; + XEvent *event; + String *params; /* unused */ + Cardinal *num_params; +{ + XawTableWidget tw = (XawTableWidget)w; + Position x,y; + int row, column; + Time tm; + + if (!tw->table.editable) + return; + + ExtractPosition(event, &x, &y , &tm); + + if (ExtractCell(tw, x, y, &row, &column)) + return ; + + XawTableSetEdit(w, row, column); +} + + + +typedef struct { + Widget w; + Atom *selections; + Time time; + int row; + int column; + int count; + int num; +}RowColumn; + +static void GetProc(); + +static void GetSelection (rc) + RowColumn *rc; +{ + Atom selection; + int buffer; + int nbytes; + char *label; + + selection = *(rc->selections + rc->num); + + if (rc->num < rc->count){ + + buffer = GetCutBufferNumber(selection); + + if (buffer >= 0) { + label = XFetchBuffer(XtDisplay(rc->w), &nbytes, buffer); + XawTableSetLabel(rc->w, rc->row, rc->column, label); + XtFree((XtPointer)rc->selections); + XtFree((XtPointer)rc); + }else { + XtGetSelectionValue(rc->w, selection, XA_STRING, GetProc, + (XtPointer)rc, rc->time); + rc->num++; + } + } +} + +/* ARGSUSED */ +static void GetProc(w, client_data, selection, + type, value, length, format) + Widget w; + XtPointer client_data; + Atom *selection; + Atom *type; + XtPointer value; + unsigned long *length; + int *format; +{ + RowColumn *rc = (RowColumn*)client_data; + + if ((*type == XA_STRING) && (value != NULL)) { + XawTableSetLabel(w, rc->row, rc->column, (char*)value); + XtFree((XtPointer)value); + XtFree((XtPointer)client_data); + }else { + GetSelection(rc); + } + +} + +static void InsertSelection(w, event, params, num_params) + Widget w; + XEvent *event; + String *params; /* selections in precedence order */ + Cardinal *num_params; +{ + XawTableWidget tw = (XawTableWidget)w; + Position x,y; + int row, column; + RowColumn *rc; + Time tm; + + if (!tw->table.editable) + return; + + if (event->type != ButtonPress && event->type != ButtonRelease) + return; + + ExtractPosition(event, &x, &y ,&tm); + + if (ExtractCell(tw, x, y, &row, &column)) + return ; + + if (*num_params > 0) { + + rc = XtNew(RowColumn); + + rc->time = tm; + rc->w = w; + rc->row = row; + rc->column = column; + rc->count = (int)*num_params; + rc->num = 0; + + if (*num_params > (Cardinal)0) { + rc->selections = CALLOC(*num_params, Atom); + XmuInternStrings(XtDisplay(w), params, *num_params, rc->selections); + } else { + rc->selections = XtNew(Atom); + *rc->selections = FetchAtom(w, "PRIMARY"); + } + GetSelection(rc); + } +} + + +static int GetCutBufferNumber(atom) + register Atom atom; +{ + if (atom == XA_CUT_BUFFER0) return(0); + if (atom == XA_CUT_BUFFER1) return(1); + if (atom == XA_CUT_BUFFER2) return(2); + if (atom == XA_CUT_BUFFER3) return(3); + if (atom == XA_CUT_BUFFER4) return(4); + if (atom == XA_CUT_BUFFER5) return(5); + if (atom == XA_CUT_BUFFER6) return(6); + if (atom == XA_CUT_BUFFER7) return(7); + return(-1); +} + + +/* ARGSUSED */ +static void DoingNothing(w, event, params, num_params) + Widget w; + XEvent *event; + String *params; + Cardinal *num_params; +{ + /* doing nothing */ +} + diff --git a/vendor/x11iraf/obm/ObmW/zz/Table.h b/vendor/x11iraf/obm/ObmW/zz/Table.h new file mode 100644 index 00000000..4c7ab5cf --- /dev/null +++ b/vendor/x11iraf/obm/ObmW/zz/Table.h @@ -0,0 +1,539 @@ +/*********************************************************************** + + Table widget + Copyright by Vladimir T. Romanovski + All rights reserved. + +This library is designed for free, non-commercial software creation. +It is changeable and can be improved. The author would greatly appreciate +any advice, new components and patches of the existing programs. +Commercial usage is also possible with participation of the author. + + romsky@hp1.oea.ihep.su (Russia) + romsky@munin.ucsf.edu (USA) + +*************************************************************************/ + +#ifndef _XawTable_h +#define _XawTable_h + +#include <X11/Xmu/Converters.h> + +#include <X11/Xraw/Simple.h> +#include <X11/Xraw/XawInit.h> + + + + +/*#########################################################################*/ +/*# #*/ +/*# New Resources #*/ +/*# #*/ +/*#########################################################################*/ +#ifndef XawTextEncoding8bit +#define XawTextEncoding8bit 0 +#endif +#ifndef XawTextEncodingChar2b +#define XawTextEncodingChar2b 1 +#endif + +#ifndef XtNliteral +#define XtNliteral "literal" +#endif + +#ifndef XtNrows +#define XtNrows "rows" +#endif + +#ifndef XtNcolumns +#define XtNcolumns "columns" +#endif + + +#ifndef XtNmaskNumber +#define XtNmaskNumber "maskNumber" +#endif + +#ifndef XtNrowOriented +#define XtNrowOriented "rowOriented" +#endif + +#ifndef XtNeditForeground +#define XtNeditForeground "editForeground" +#endif + +#ifndef XtNeditBackground +#define XtNeditBackground "editBackground" +#endif + +#ifndef XtNcolumnForeground +#define XtNcolumnForeground "columnForeground" +#endif + +#ifndef XtNrowForeground +#define XtNrowForeground "rowForeground" +#endif + +#ifndef XtNvetricalScroll +#define XtNvetricalScroll "vetricalScroll" +#endif + +#ifndef XtNhorizontalScroll +#define XtNhorizontalScroll "horizontalScroll" +#endif + +#ifndef XtNcolumnsWidth +#define XtNcolumnsWidth "columnsWidth" +#endif + +#ifndef XtNrowHeight +#define XtNrowHeight "rowHeight" +#endif + +#ifndef XtNdefaultWidth +#define XtNdefaultWidth "defaultWidth" +#endif + +#ifndef XtNeditable +#define XtNeditable "editable" +#endif + +#ifndef XtNliteralWidth +#define XtNliteralWidth "literalWidth" +#endif + +#ifndef XtNtableMargin +#define XtNtableMargin "tableMargin" +#endif + +#ifndef XtNrowMargin +#define XtNrowMargin "rowMargin" +#endif + +#ifndef XtNcolumnMargin +#define XtNcolumnMargin "columnMargin" +#endif + +#ifndef XtNlabelShadowWidth +#define XtNlabelShadowWidth "labelShadowWidth" +#endif + +#ifndef XtNencoding +#define XtNencoding "encoding" +#endif + + + + + + +/*#########################################################################*/ +/*# #*/ +/*# New Resource Classes #*/ +/*# #*/ +/*#########################################################################*/ +#ifndef XtCLiteral +#define XtCLiteral "Literal" +#endif + +#ifndef XtCColumns +#define XtCColumns "Columns" +#endif + +#ifndef XtCMaskNumber +#define XtCMaskNumber "MaskNumber" +#endif + +#ifndef XtCScroll +#define XtCScroll "Scroll" +#endif + +#ifndef XtCColumnsWidth +#define XtCColumnsWidth "ColumnsWidth" +#endif + +#ifndef XtCRowHeight +#define XtCRowHeight "RowHeight" +#endif + +#ifndef XtCDefaultWidth +#define XtCDefaultWidth "DefaultWidth" +#endif + +#ifndef XtCEditable +#define XtCEditable "Editable" +#endif + +#ifndef XtCLiteralWidth +#define XtCLiteralWidth "LiteralWidth" +#endif + +#ifndef XtCRows +#define XtCRows "Rows" +#endif + +#ifndef XtCTableMargin +#define XtCTableMargin "TableMargin" +#endif + +#ifndef XtCRowMargin +#define XtCRowMargin "RowMargin" +#endif + +#ifndef XtCColumnMargin +#define XtCColumnMargin "ColumnMargin" +#endif + +#ifndef XtCLabelShadowWidth +#define XtCLabelShadowWidth "LabelShadowWidth" +#endif + +#ifndef XtCEncoding +#define XtCEncoding "Encoding" +#endif + + + + + + +/*#########################################################################*/ +/*# #*/ +/*# New Resource Types #*/ +/*# #*/ +/*#########################################################################*/ +#ifndef XtRColumnsWidth +#define XtRColumnsWidth "ColumnsWidth" +#endif + +#ifndef XtCRowOriented +#define XtCRowOriented "RowOriented" +#endif + + +/*#########################################################################*/ +/*# #*/ +/*# Allowance Callbacks #*/ +/*# #*/ +/*#########################################################################*/ +#ifndef XtNallowAddColumn +#define XtNallowAddColumn "allowAddColumn" +#endif + +#ifndef XtNallowAddRow +#define XtNallowAddRow "allowAddRow" +#endif + +#ifndef XtNallowDeleteColumn +#define XtNallowDeleteColumn "allowDeleteColumn" +#endif + +#ifndef XtNallowDeleteRow +#define XtNallowDeleteRow "allowDeleteRow" +#endif + +#ifndef XtNallowDeleteTable +#define XtNallowDeleteTable "allowDeleteTable" +#endif + + +/*#########################################################################*/ +/*# #*/ +/*# Information Callbacks #*/ +/*# #*/ +/*#########################################################################*/ +#ifndef XtNaddColumn +#define XtNaddColumn "addColumn" +#endif + +#ifndef XtNaddRow +#define XtNaddRow "addRow" +#endif + +#ifndef XtNchangedCell +#define XtNchangedCell "changedCell" +#endif + +#ifndef XtNchangedColumnWidth +#define XtNchangedColumnWidth "changedColumnWidth" +#endif + +#ifndef XtNchangedRowHeight +#define XtNchangedRowHeight "changedRowHeight" +#endif + +#ifndef XtNcreateTable +#define XtNcreateTable "createTable" +#endif + +#ifndef XtNdeleteColumn +#define XtNdeleteColumn "deleteColumn" +#endif + +#ifndef XtNdeleteRow +#define XtNdeleteRow "deleteRow" +#endif + +#ifndef XtNdeleteTable +#define XtNdeleteTable "deleteTable" +#endif + +#ifndef XtNwhatCell +#define XtNwhatCell "whatCell" +#endif + + + +/*#########################################################################*/ +/*# #*/ +/*# XawTableCell & XawTableColumn #*/ +/*# #*/ +/*#########################################################################*/ +typedef struct _XawTableCellRec *XawTableCell; /* opaque to outside */ + +typedef struct _XawTableColumnRec *XawTableColumn; /* opaque to outside */ + + + +/*#########################################################################*/ +/*# #*/ +/*# Bypass Routine and Direction Types #*/ +/*# #*/ +/*#########################################################################*/ +typedef Boolean (*XawTableProc) Xraw_PROTO((Widget, + int, + int, + XawTableCell, + XtPointer)); +enum XawTableBypassDirection{ + XawTABLE_RIGHT_DOWN, + XawTABLE_DOWN_RIGHT +}; + + +/*#########################################################################*/ +/*# #*/ +/*# Callback Reasons #*/ +/*# #*/ +/*#########################################################################*/ +enum XawTableReasons{ + XawTABLE_ALLOW_ADD_COLUMN = Xraw_TABLE, + XawTABLE_ALLOW_ADD_ROW, + XawTABLE_ALLOW_CREATE_TABLE, + XawTABLE_ALLOW_DELETE_COLUMN, + XawTABLE_ALLOW_DELETE_ROW, + XawTABLE_ALLOW_DELETE_TABLE, + + XawTABLE_ADD_COLUMN, + XawTABLE_ADD_ROW, + XawTABLE_CHANGED_CELL, + XawTABLE_CHANGED_COLUMN_WIDTH, + XawTABLE_CHANGED_ROW_HEIGHT, + XawTABLE_CREATE_TABLE, + XawTABLE_DELETE_COLUMN, + XawTABLE_DELETE_ROW, + XawTABLE_DELETE_TABLE, + XawTABLE_WHAT_CELL +}; + + +/*#########################################################################*/ +/*# #*/ +/*# Callback Structure #*/ +/*# #*/ +/*#########################################################################*/ +typedef struct { + int reason; + XEvent *event; + XawTableCell old_cell; + XawTableCell new_cell; + int row; + int column; + Boolean do_it; +}XawTableCallbackStruct; + + +/*#########################################################################*/ +/*# #*/ +/*# Layout Control Routine #*/ +/*# #*/ +/*#########################################################################*/ +extern void XawTableDoLayout Xraw_PROTO((Widget w, + Boolean do_layout)); + + +/*#########################################################################*/ +/*# #*/ +/*# Stuff Routines #*/ +/*# #*/ +/*#########################################################################*/ +extern int XawTableSetNewSize Xraw_PROTO((Widget w, + int rows, + int columns)); + +extern void XawTableGetSize Xraw_PROTO((Widget w, + int *rows, + int *columns)); + + +/*#########################################################################*/ +/*# #*/ +/*# Row Routines #*/ +/*# #*/ +/*#########################################################################*/ +extern int XawTablePrependRow Xraw_PROTO((Widget w)); + +extern int XawTableAppendRow Xraw_PROTO((Widget w)); + +extern int XawTableInsertRow Xraw_PROTO((Widget w, int row)); + +extern int XawTableDeleteRow Xraw_PROTO((Widget w, int row)); + + +/*#########################################################################*/ +/*# #*/ +/*# Column Routines #*/ +/*# #*/ +/*#########################################################################*/ +extern int XawTablePrependColumn Xraw_PROTO((Widget w, int width)); + +extern int XawTableAppendColumn Xraw_PROTO((Widget w, int width)); + +extern int XawTableInsertColumn Xraw_PROTO((Widget w, + int column, + int width)); + +extern int XawTableDeleteColumn Xraw_PROTO((Widget w, int column)); + + +/*#########################################################################*/ +/*# #*/ +/*# Set Label Routines #*/ +/*# #*/ +/*#########################################################################*/ +extern char *XawTableGetLabelByCell Xraw_PROTO((XawTableCell cell)); + +extern char *XawTableGetLabelByPosition Xraw_PROTO((Widget w, + int row, + int column)); + +extern int XawTableSetLabel Xraw_PROTO((Widget w, + int row, + int column, + char *label)); + + +/*#########################################################################*/ +/*# #*/ +/*# Bypass Routines #*/ +/*# #*/ +/*#########################################################################*/ +extern Boolean XawTableWalk Xraw_PROTO((Widget w, + XawTableProc proc, + int b_row, + int e_row, + int b_column, + int e_column, + int direction, + int *row, int *column, + XtPointer client_data)); + +extern Boolean XawTableSearchLabel Xraw_PROTO((Widget w, + char *name, + int *row, + int *column)); + + +/*#########################################################################*/ +/*# #*/ +/*# Edit Cell Routines #*/ +/*# #*/ +/*#########################################################################*/ +extern Boolean XawTableIsEditManaged Xraw_PROTO((Widget w)); + +extern void XawTableGetEditPosition Xraw_PROTO((Widget w, + int *row, + int *column)); + +extern void XawTableUnsetEdit Xraw_PROTO((Widget w)); + +extern void XawTableSetEdit Xraw_PROTO((Widget w, + int row, + int column)); + + +/*#########################################################################*/ +/*# #*/ +/*# Set Colour Routines #*/ +/*# #*/ +/*#########################################################################*/ +extern int XawTableSetCellBackground Xraw_PROTO((Widget w, + int row, + int column, + Pixel background)); + +extern int XawTableSetCellForeground Xraw_PROTO((Widget w, + int row, + int column, + Pixel foreground)); + +extern int XawTableSetCellDefaultColours Xraw_PROTO((Widget w, + int row, + int column)); + +extern int XawTableSetCellColours Xraw_PROTO((Widget w, + int row, + int column, + Pixel foreground, + Pixel background)); + + +extern void XawTableGetCellColours Xraw_PROTO((Widget w, + int row, + int column, + Pixel *foreground, + Pixel *background)); + +extern void XawTableGetCellColoursByCell Xraw_PROTO((Widget w, + XawTableCell cell, + Pixel *foreground, + Pixel *background)); + + +/*#########################################################################*/ +/*# #*/ +/*# Column Deta #*/ +/*# #*/ +/*#########################################################################*/ +extern void XawTableSetColumnJustify Xraw_PROTO((Widget w, + int column, + XtJustify justify)); + +extern XtJustify XawTableGetColumnJustify Xraw_PROTO((Widget w, + int column)); + +extern void XawTableSetColumnWidth Xraw_PROTO((Widget w, + int column, + int width)); + +extern int XawTableGetColumnWidth Xraw_PROTO((Widget w, + int column)); + +extern int XawTableGetColumnPixelWidth Xraw_PROTO((Widget w, + int column)); + + + +/*#########################################################################*/ +/*# #*/ +/*# Widget Class Pointer #*/ +/*# #*/ +/*#########################################################################*/ +extern WidgetClass tableWidgetClass; + +typedef struct _TableClassRec *XawTableWidgetClass; +typedef struct _TableRec *XawTableWidget; + + +#endif /* _XawTable_h */ +/* DON'T ADD STUFF AFTER THIS #endif */ diff --git a/vendor/x11iraf/obm/ObmW/zz/Table3d.c b/vendor/x11iraf/obm/ObmW/zz/Table3d.c new file mode 100644 index 00000000..085b2cac --- /dev/null +++ b/vendor/x11iraf/obm/ObmW/zz/Table3d.c @@ -0,0 +1,924 @@ +#include <X11/Xraw/3d.h> +#include <X11/Xraw/color.h> + +#define WHITE WhitePixelOfScreen +#define BLACK BlackPixelOfScreen +#define SWITCH(a,b) (top_or_bottom == TOP ? a : b) + +#define DEPTH_SCREEN(w) DefaultDepthOfScreen(XtScreen(w)) + +#ifdef MIN +#undef MIN +#endif +#define MIN(a,b) ((a)<(b) ? (a) : (b)) + +#ifdef MAX +#undef MAX +#endif +#define MAX(a,b) ((a) > (b) ? (a) : (b)) + +#define TOP_VALUE_RATIO (1.3) +#define BOT_VALUE_RATIO (0.6) +#define ARM_VALUE_RATIO (0.85) + +#define Top_Cash (1<<0L) +#define Bot_Cash (1<<1L) +#define Arm_Cash (1<<2L) + +typedef struct _ColorCashRec { + struct _ColorCashRec* nxt; + XColor col; + RGB rgb[1]; + HSV hsv[1]; + RGB top[1]; + RGB bot[1]; + RGB arm[1]; + unsigned int set; +}ColorCashRec, *ColorCash; + +static ColorCashRec* color_cash = NULL; +static void GetTopShadow(); + + +static void GetTopShadow(trom ,to) + XColor* trom; + XColor* to; +{ + ColorCashRec* cash; + float save; + + for (cash = color_cash; cash != NULL; cash = cash->nxt) + { + if (cash->col.red == trom->red && + cash->col.green == trom->green && + cash->col.blue == trom->blue) + { + if (cash->set & Top_Cash) + { + to->red = cash->top[0].r; + to->green = cash->top[0].g; + to->blue = cash->top[0].b; + } + else + { + save = cash->hsv[0].v; + cash->hsv[0].v *= TOP_VALUE_RATIO; + cash->hsv[0].v = MIN(cash->hsv[0].v, 1.0); + + HSVToRGB((HSV*)cash->hsv, (RGB*)cash->top); + + cash->hsv[0].v = save; + + to->red = cash->top[0].r; + to->green = cash->top[0].g; + to->blue = cash->top[0].b; + + cash->set |= Top_Cash; + } + + return; + } + } + + cash = XtNew (ColorCashRec); + + cash->col.red = cash->rgb[0].r = trom->red; + cash->col.green = cash->rgb[0].g = trom->green; + cash->col.blue = cash->rgb[0].b = trom->blue; + + RGBToHSV((RGB*)cash->rgb, (HSV*)cash->hsv); + + save = cash->hsv[0].v; + cash->hsv[0].v *= TOP_VALUE_RATIO; + cash->hsv[0].v = MIN(cash->hsv[0].v, 1.0); + + HSVToRGB((HSV*)cash->hsv, (RGB*)cash->top); + + cash->hsv[0].v = save; + + to->red = cash->top[0].r; + to->green = cash->top[0].g; + to->blue = cash->top[0].b; + + cash->set = Top_Cash; + + cash->nxt = color_cash; + color_cash = cash; +} + +static void GetBotShadow(trom ,to) + XColor* trom; + XColor* to; +{ + ColorCashRec* cash; + float save; + + for (cash = color_cash; cash != NULL; cash = cash->nxt) + { + if (cash->col.red == trom->red && + cash->col.green == trom->green && + cash->col.blue == trom->blue) + { + if (cash->set & Bot_Cash) + { + to->red = cash->bot[0].r; + to->green = cash->bot[0].g; + to->blue = cash->bot[0].b; + } + else + { + save = cash->hsv[0].v; + cash->hsv[0].v *= BOT_VALUE_RATIO; + + HSVToRGB((HSV*)cash->hsv, (RGB*)cash->bot); + + cash->hsv[0].v = save; + + to->red = cash->bot[0].r; + to->green = cash->bot[0].g; + to->blue = cash->bot[0].b; + + cash->set |= Bot_Cash; + } + + return; + } + } + + cash = XtNew (ColorCashRec); + + cash->col.red = cash->rgb[0].r = trom->red; + cash->col.green = cash->rgb[0].g = trom->green; + cash->col.blue = cash->rgb[0].b = trom->blue; + + RGBToHSV((RGB*)cash->rgb, (HSV*)cash->hsv); + + save = cash->hsv[0].v; + cash->hsv[0].v *= BOT_VALUE_RATIO; + + HSVToRGB((HSV*)cash->hsv, (RGB*)cash->bot); + + cash->hsv[0].v = save; + + to->red = cash->bot[0].r; + to->green = cash->bot[0].g; + to->blue = cash->bot[0].b; + + cash->set = Bot_Cash; + + cash->nxt = color_cash; + color_cash = cash; +} + +static void GetArmShadow(trom ,to) + XColor* trom; + XColor* to; +{ + ColorCashRec* cash; + float save; + + for (cash = color_cash; cash != NULL; cash = cash->nxt) + { + if (cash->col.red == trom->red && + cash->col.green == trom->green && + cash->col.blue == trom->blue) + { + if (cash->set & Arm_Cash) + { + to->red = cash->arm[0].r; + to->green = cash->arm[0].g; + to->blue = cash->arm[0].b; + } + else + { + save = cash->hsv[0].v; + cash->hsv[0].v *= ARM_VALUE_RATIO; + + HSVToRGB((HSV*)cash->hsv, (RGB*)cash->arm); + + cash->hsv[0].v = save; + + to->red = cash->arm[0].r; + to->green = cash->arm[0].g; + to->blue = cash->arm[0].b; + + cash->set |= Arm_Cash; + } + + return; + } + } + + cash = XtNew (ColorCashRec); + + cash->col.red = cash->rgb[0].r = trom->red; + cash->col.green = cash->rgb[0].g = trom->green; + cash->col.blue = cash->rgb[0].b = trom->blue; + + RGBToHSV((RGB*)cash->rgb, (HSV*)cash->hsv); + + save = cash->hsv[0].v; + cash->hsv[0].v *= ARM_VALUE_RATIO; + + HSVToRGB((HSV*)cash->hsv, (RGB*)cash->arm); + + cash->hsv[0].v = save; + + to->red = cash->arm[0].r; + to->green = cash->arm[0].g; + to->blue = cash->arm[0].b; + + cash->set = Arm_Cash; + + cash->nxt = color_cash; + color_cash = cash; +} + +unsigned int shadowpm_width = 8; +unsigned int shadowpm_height= 8; + +static char shadow_bits[] = { + 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55}; + +static char mtshadowpm_bits[] = { + 0x92, 0x24, 0x49, 0x92, 0x24, 0x49, 0x92, 0x24}; + +static char mbshadowpm_bits[] = { + 0x6d, 0xdb, 0xb6, 0x6d, 0xdb, 0xb6, 0x6d, 0xdb}; + + +GC +#ifdef Xraw_NEED_PROTO +AllocGCFromPixmap (Widget w, Pixmap pixmap) +#else +AllocGCFromPixmap(w, pixmap) + Widget w; + Pixmap pixmap; +#endif +{ + XGCValues values; + + if (pixmap != None) { + values.tile = pixmap; + values.fill_style = FillTiled; + return XtGetGC(w, (XtGCMask)(GCTile | GCFillStyle), &values); + } + + return XtGetGC(w, (XtGCMask)0, (XGCValues *)NULL); +} + +GC +#ifdef Xraw_NEED_PROTO +AllocGCFromPixel (Widget w, Pixel fore) +#else +AllocGCFromPixel(w, fore) + Widget w; + Pixel fore; +#endif +{ + XGCValues values; + + values.foreground = fore; + return XtGetGC(w, GCForeground, &values); +} + +static Pixmap Depth_1_ShadowPixmap (w, top_or_bottom) + Widget w; + int top_or_bottom; +{ + Screen *scn = XtScreen (w); + + if (DEPTH_SCREEN(w) == 1) + return XCreatePixmapFromBitmapData (XtDisplay (w), + RootWindowOfScreen (scn), + shadow_bits, + shadowpm_width, + shadowpm_height, + SWITCH(BLACK (scn), WHITE (scn)), + SWITCH(WHITE (scn), BLACK (scn)), + 1); + else + return None; +} + +static Pixmap Depth_NOT_1_ShadowPixmap (w, colour, top_or_bottom) + Widget w; + Pixel colour; + int top_or_bottom; +{ + Display *dpy = XtDisplay (w); + Screen *scn = XtScreen (w); + unsigned long fore; + unsigned long back; + char *pm_data; + int depth = DEPTH_SCREEN(w); + + if (depth == 1) + return None; + + if (colour == WHITE (scn) || colour == BLACK (scn)) { + fore = WHITE (scn); + back = BLACK (scn); + pm_data = SWITCH(mtshadowpm_bits, mbshadowpm_bits); + } else { + fore = colour; + back = SWITCH (WHITE (scn), BLACK (scn)); + pm_data = shadow_bits; + } + + return XCreatePixmapFromBitmapData (dpy, + RootWindowOfScreen (scn), + pm_data, + shadowpm_width, + shadowpm_height, + fore, + back, + depth); +} + +Pixmap +#ifdef Xraw_NEED_PROTO +CreateShadowPixmap (Widget w, Pixel colour, int top_or_bottom) +#else +CreateShadowPixmap (w, colour, top_or_bottom) + Widget w; + Pixel colour; + int top_or_bottom; +#endif +{ + if (DEPTH_SCREEN(w) == 1) + return Depth_1_ShadowPixmap (w, top_or_bottom); + else + return Depth_NOT_1_ShadowPixmap (w, colour, top_or_bottom); +} + +#define _MIN(x,y) (unsigned short) ((x) < (y)) ? (x) : (y) +#define _MAX(x,y) (unsigned short) ((x) < (y)) ? (y) : (x) + + +Boolean +#ifdef Xraw_NEED_PROTO +AllocShadowPixel ( + Widget w, + Pixel base, + int brightness, + Pixel *result) +#else +AllocShadowPixel (w, base, brightness, result) + Widget w; + Pixel base; + int brightness; + Pixel *result; /* RETURN */ +#endif +{ + XColor set; + XColor get; + double mult; + Colormap cmap= ((CoreWidget)w)->core.colormap; + unsigned short red; + unsigned short green; + unsigned short blue; + + get.pixel = base; + XQueryColor (XtDisplay (w), cmap, &get); + mult = (double)(100 + brightness) / ((double) 100.0); + + red = mult * (double)get.red; + green = mult * (double)get.green; + blue = mult * (double)get.blue; + + set.red = _MAX(0,_MIN (65535, red)); + set.green = _MAX(0,_MIN (65535, green)); + set.blue = _MAX(0,_MIN (65535, blue)); + +#define EQ(field) (set.field == get.field) + if (EQ(red) && EQ(green) && EQ(blue)) +#undef EQ + return False; + + if (XAllocColor (XtDisplay (w), cmap, &set) != 0) { + *result = set.pixel; + return True; + } else + return False; +} + +GC +#ifdef Xraw_NEED_PROTO +MakeGC (Widget w, + Pixel base, + int brightness, + Boolean pseudo, + int top_or_bottom) +#else +MakeGC(w, base, brightness, pseudo, top_or_bottom) + Widget w; + Pixel base; + int brightness; + Boolean pseudo; + int top_or_bottom; +#endif +{ + Pixel fore; + Pixmap tile; + + if (DEPTH_SCREEN(w) > 1) { + if (pseudo) { + tile = Depth_NOT_1_ShadowPixmap (w, base, top_or_bottom); + return AllocGCFromPixmap(w, tile); + } else { + if (AllocShadowPixel(w, base, brightness, &fore)) { + return AllocGCFromPixel(w, fore); + } else { + tile = Depth_NOT_1_ShadowPixmap (w, base, top_or_bottom); + return AllocGCFromPixmap(w, tile); + } + } + } else { + tile = Depth_1_ShadowPixmap (w, top_or_bottom); + return AllocGCFromPixmap(w, tile); + } +} + +GC +#ifdef Xraw_NEED_PROTO +MakeTopShadowGC (Widget w, Pixel base) +#else +MakeTopShadowGC(w, base) + Widget w; + Pixel base; +#endif +{ + Pixel fore; + Pixmap tile; + + if (DEPTH_SCREEN(w) > 1) { + if (TopShadowColor(w, base, &fore)) { + return AllocGCFromPixel(w, fore); + } else { + tile = Depth_NOT_1_ShadowPixmap (w, base, TOP); + return AllocGCFromPixmap(w, tile); + } + } else { + tile = Depth_1_ShadowPixmap (w, TOP); + return AllocGCFromPixmap(w, tile); + } +} + + +GC +#ifdef Xraw_NEED_PROTO +MakeBottomShadowGC (Widget w, Pixel base) +#else +MakeBottomShadowGC(w, base) + Widget w; + Pixel base; +#endif +{ + Pixel fore; + Pixmap tile; + + if (DEPTH_SCREEN(w) > 1) { + if (BottomShadowColor(w, base, &fore)) { + return AllocGCFromPixel(w, fore); + } else { + tile = Depth_NOT_1_ShadowPixmap (w, base, BOTTOM); + return AllocGCFromPixmap(w, tile); + } + } else { + tile = Depth_1_ShadowPixmap (w, BOTTOM); + return AllocGCFromPixmap(w, tile); + } +} + +GC +#ifdef Xraw_NEED_PROTO +MakeArmedGC (Widget w, Pixel base) +#else +MakeArmedGC(w, base) + Widget w; + Pixel base; +#endif +{ + Pixel fore; + Pixmap tile; + + if (DEPTH_SCREEN(w) > 1) { + if (ArmedColor(w, base, &fore)) { + return AllocGCFromPixel(w, fore); + } else { + tile = Depth_NOT_1_ShadowPixmap (w, base, BOTTOM); + return AllocGCFromPixmap(w, tile); + } + } else { + tile = Depth_1_ShadowPixmap (w, BOTTOM); + return AllocGCFromPixmap(w, tile); + } +} + +void +#ifdef Xraw_NEED_PROTO +XawDrawFrame (Widget gw, + Position x, + Position y, + Dimension w, + Dimension h, + XawFrameType frame_type, + Dimension t, + GC lightgc, + GC darkgc) +#else +XawDrawFrame (gw, x, y, w, h, frame_type, t, lightgc, darkgc) + Widget gw; + Position x; + Position y; + Dimension w; + Dimension h; + XawFrameType frame_type; + Dimension t; + GC lightgc; + GC darkgc; +#endif +{ + XPoint top_polygon[6]; + XPoint bottom_polygon[6]; + XPoint points[3]; + + + if (t == 0 || w == 0 || h == 0) + return; + + if( lightgc == (GC)NULL ){ + XtWarning("XawDrawFrame: lightgc is NULL in XawDrawFrame."); + return; + } + + if( darkgc == (GC)NULL ){ + XtWarning("XawDrawFrame: darkgc is NULL in XawDrawFrame."); + return; + } + + if (!XtIsRealized(gw)) { + XtWarning("XawDrawFrame: widget is not realized!!!"); + return; + } + +#define topPolygon(i,xx,yy) \ + top_polygon[i].x = (short) (xx); \ + top_polygon[i].y = (short) (yy) + +#define bottomPolygon(i,xx,yy) \ + bottom_polygon[i].x = (short) (xx); \ + bottom_polygon[i].y = (short) (yy) + + + if (frame_type == XawTACK && t <= 2) + frame_type = XawLEDGED; + + switch (frame_type) { + + case XawRAISED : + case XawSUNKEN : + + topPolygon (0,x ,y ); bottomPolygon (0,x+w ,y+h ); + topPolygon (1,x+w ,y ); bottomPolygon (1,x ,y+h ); + topPolygon (2,x+w-t,y+t ); bottomPolygon (2,x+t ,y+h-t); + topPolygon (3,x+t ,y+t ); bottomPolygon (3,x+w-t,y+h-t); + topPolygon (4,x+t ,y+h-t); bottomPolygon (4,x+w-t,y+t ); + topPolygon (5,x ,y+h ); bottomPolygon (5,x+w ,y ); + + if (frame_type == XawSUNKEN) + { + XFillPolygon(XtDisplayOfObject(gw), XtWindowOfObject(gw), darkgc, + top_polygon, 6, Nonconvex, CoordModeOrigin); + + XFillPolygon(XtDisplayOfObject(gw), XtWindowOfObject(gw), lightgc, + bottom_polygon, 6, Nonconvex, CoordModeOrigin); + } + else if (frame_type == XawRAISED) + { + XFillPolygon(XtDisplayOfObject(gw), XtWindowOfObject(gw), lightgc, + top_polygon, 6, Nonconvex, CoordModeOrigin); + XFillPolygon(XtDisplayOfObject(gw), XtWindowOfObject(gw), darkgc, + bottom_polygon, 6, Nonconvex, CoordModeOrigin); + } + + break; + + case XawTACK : + + t -= 2; + + topPolygon (0,x ,y ); bottomPolygon (0,x+w ,y+h ); + topPolygon (1,x+w ,y ); bottomPolygon (1,x ,y+h ); + topPolygon (2,x+w-t,y+t ); bottomPolygon (2,x+t ,y+h-t); + topPolygon (3,x+t ,y+t ); bottomPolygon (3,x+w-t,y+h-t); + topPolygon (4,x+t ,y+h-t); bottomPolygon (4,x+w-t,y+t ); + topPolygon (5,x ,y+h ); bottomPolygon (5,x+w ,y ); + + XFillPolygon(XtDisplayOfObject(gw), XtWindowOfObject(gw), lightgc, + top_polygon, 6, Nonconvex, CoordModeOrigin); + XFillPolygon(XtDisplayOfObject(gw), XtWindowOfObject(gw), darkgc, + bottom_polygon, 6, Nonconvex, CoordModeOrigin); + + points[0].x = x + t + 1; points[0].y = y + h - t - 2; + points[1].x = x + t + 1; points[1].y = y + t + 1; + points[2].x = x + w - t - 2; points[2].y = y + t + 1; + + XDrawLines (XtDisplayOfObject(gw), XtWindowOfObject(gw), darkgc, + points, 3, CoordModeOrigin); + + /* points[0].x = x + t + 1; points[0].y = y + h -t - 1; */ + points[1].x = x + w - t - 2; points[1].y = y + h - t - 2; + /* points[2].x = x + w - t - 1; points[2].y = y + t + 1; */ + + XDrawLines (XtDisplayOfObject(gw), XtWindowOfObject(gw), lightgc, + points, 3, CoordModeOrigin); + + break; + + case XawLEDGED : + + XawDrawFrame(gw, x, y, w, h, XawRAISED, t/2, lightgc, darkgc); + XawDrawFrame(gw, (Position)(x + t/2), (Position)(y + t/2), + (Dimension)(w - 2 * (t/2)), (Dimension)(h - 2 * (t/2)), + XawSUNKEN, t/2, lightgc, darkgc); + break; + + case XawCHISELED : + + XawDrawFrame(gw, x, y, w, h, XawSUNKEN, t/2, lightgc, darkgc); + XawDrawFrame(gw, (Position)(x + t/2),(Position)(y + t/2), + (Dimension)(w - 2 * (t/2)), (Dimension)(h - 2 * (t/2)), + XawRAISED, t/2, lightgc, darkgc); + break; + + default : + break; + + } + +#undef topPolygon +#undef bottomPolygon +} + + +Boolean +#ifdef Xraw_NEED_PROTO +BottomShadowColor( Widget widget, + Pixel base, + Pixel *result) +#else +BottomShadowColor(widget, base, result) + Widget widget; + Pixel base; + Pixel *result; +#endif +{ + Colormap colormap; + XColor color; + + if (XtIsWidget(widget)) + colormap = widget->core.colormap; + else + colormap = (XtParent(widget))->core.colormap; + + color.pixel = base; + + XQueryColor(XtDisplay(widget), colormap, &color); + + GetBotShadow(&color, &color); + + if (XAllocColor (XtDisplay(widget), colormap, &color) != 0) + { + *result = color.pixel; + return True; + } + else + { + HSV hsv; + RGB rgb; + + rgb.r = color.red; + rgb.g = color.green; + rgb.b = color.blue; + + RGBToHSV ((RGB*)&rgb, (HSV*)&hsv); + + if (hsv.v > 0.5) + *result = WhitePixelOfScreen(XtScreen (widget)); + else + *result = BlackPixelOfScreen(XtScreen (widget)); + return True; + } + +} + +Boolean +#ifdef Xraw_NEED_PROTO +TopShadowColor( Widget widget, + Pixel base, + Pixel *result) +#else +TopShadowColor(widget, base, result) + Widget widget; + Pixel base; + Pixel *result; +#endif +{ + Colormap colormap; + XColor color; + + if (XtIsWidget(widget)) + colormap = widget->core.colormap; + else + colormap = (XtParent(widget))->core.colormap; + + color.pixel = base; + + XQueryColor(XtDisplay(widget), colormap, &color); + + GetTopShadow(&color, &color); + + if (XAllocColor (XtDisplay(widget), colormap, &color) != 0) + { + *result = color.pixel; + return True; + } + else + { + HSV hsv; + RGB rgb; + + rgb.r = color.red; + rgb.g = color.green; + rgb.b = color.blue; + + RGBToHSV ((RGB*)&rgb, (HSV*)&hsv); + + if (hsv.v > 0.5) + *result = WhitePixelOfScreen(XtScreen (widget)); + else + *result = BlackPixelOfScreen(XtScreen (widget)); + return True; + } + +} + +Boolean +#ifdef Xraw_NEED_PROTO +ArmedColor( Widget widget, + Pixel base, + Pixel *result) +#else +ArmedColor(widget, base, result) + Widget widget; + Pixel base; + Pixel *result; +#endif +{ + Colormap colormap; + XColor color; + + if (XtIsWidget(widget)) + colormap = widget->core.colormap; + else + colormap = (XtParent(widget))->core.colormap; + + color.pixel = base; + + XQueryColor(XtDisplay(widget), colormap, &color); + + GetArmShadow(&color, &color); + + if (XAllocColor (XtDisplay(widget), colormap, &color) != 0) + { + *result = color.pixel; + return True; + } + else + { + HSV hsv; + RGB rgb; + + rgb.r = color.red; + rgb.g = color.green; + rgb.b = color.blue; + + RGBToHSV ((RGB*)&rgb, (HSV*)&hsv); + + if (hsv.v > 0.5) + *result = WhitePixelOfScreen(XtScreen (widget)); + else + *result = BlackPixelOfScreen(XtScreen (widget)); + return True; + } + +} + + + +#undef assign_max +#undef assign_min + + +void +#ifdef Xraw_NEED_PROTO +DrawRhombus ( + Widget w, + short x, + short y, + short g, + short t, + GC top_shadow_GC, + GC foreground_gc, + GC bottom_shadow_GC, + Boolean state ) +#else +DrawRhombus(w, x, y, g, t, + top_shadow_GC, foreground_gc, bottom_shadow_GC, state) + Widget w; + short x; + short y; + short g; + short t; + GC top_shadow_GC; + GC foreground_gc; + GC bottom_shadow_GC; + Boolean state; +#endif +{ + XPoint top_shade[6]; + XPoint bot_shade[6]; + XPoint center[4]; + +#define topPolygon(i,a,b) top_shade[i].x = a; top_shade[i].y = b +#define bottomPolygon(i,a,b) bot_shade[i].x = a; bot_shade[i].y = b +#define centerPolygon(i,a,b) center[i].x = a; center[i].y = b + + topPolygon(0, x-g , y ); bottomPolygon(0, x-g , y ); + topPolygon(1, x-g+t, y ); bottomPolygon(1, x-g+t, y ); + topPolygon(2, x , y-g+t); bottomPolygon(2, x , y+g-t); + topPolygon(3, x+g-t, y ); bottomPolygon(3, x+g-t, y ); + topPolygon(4, x+g , y ); bottomPolygon(4, x+g , y ); + topPolygon(5, x , y-g ); bottomPolygon(5, x , y+g ); + + if (state) + { + if (foreground_gc) + { + centerPolygon(0, x-g+t, y ); + centerPolygon(1, x , y-g+t); + centerPolygon(2, x+g-t, y ); + centerPolygon(3, x , y+g-t); + + XFillPolygon(XtDisplayOfObject(w), XtWindowOfObject(w), foreground_gc, + center, XtNumber(center), + Convex, CoordModeOrigin); + } + + if (bottom_shadow_GC) + XFillPolygon(XtDisplayOfObject(w), XtWindowOfObject(w), bottom_shadow_GC, + top_shade, XtNumber(top_shade), Nonconvex, CoordModeOrigin); + + if (top_shadow_GC) + XFillPolygon(XtDisplayOfObject(w), XtWindowOfObject(w), top_shadow_GC, + bot_shade, XtNumber(bot_shade), Nonconvex, CoordModeOrigin); + }else{ + + if (top_shadow_GC) + XFillPolygon(XtDisplayOfObject(w), XtWindowOfObject(w), top_shadow_GC, + top_shade, XtNumber(top_shade), + Nonconvex, CoordModeOrigin); + + if (bottom_shadow_GC) + XFillPolygon(XtDisplayOfObject(w), XtWindowOfObject(w), bottom_shadow_GC, + bot_shade, XtNumber(bot_shade), + Nonconvex, CoordModeOrigin); + } + +#undef topPolygon +#undef bottomPolygon +#undef centerPolygon + +} + +Boolean +#ifdef Xraw_NEED_PROTO +FetchPixel (Widget w, String name, Pixel* pixel) +#else +FetchPixel(w, name, pixel) + Widget w; + String name; + Pixel* pixel; +#endif +{ + XrmValue source, dest; + + source.size = strlen(name)+1; + source.addr = name; + dest.size = sizeof(Pixel); + dest.addr = (caddr_t) pixel; + + return XtConvertAndStore(w, XtRString, &source, XtRPixel, &dest); +} diff --git a/vendor/x11iraf/obm/ObmW/zz/Table3d.h b/vendor/x11iraf/obm/ObmW/zz/Table3d.h new file mode 100644 index 00000000..8d09dddf --- /dev/null +++ b/vendor/x11iraf/obm/ObmW/zz/Table3d.h @@ -0,0 +1,145 @@ +#ifndef _3d_h_ +#define _3d_h_ + +#include <stdio.h> +#include <X11/IntrinsicP.h> +#include <X11/StringDefs.h> +#include <X11/Xraw/XawInit.h> + +typedef enum { + XawRAISED = Xraw_3d, + XawSUNKEN, + XawCHISELED, + XawLEDGED, + XawTACK +} XawFrameType; + +#define TOP (1) +#define BOTTOM (2) + +extern GC AllocGCFromPixmap Xraw_PROTO((Widget , Pixmap )); +extern GC AllocGCFromPixel Xraw_PROTO((Widget , Pixel )); + +extern void RGBtoHLS Xraw_PROTO((double , + double , + double , + double * , + double * , + double * )); + +extern void HLStoRGB Xraw_PROTO((double * , + double * , + double * , + double , + double , + double )); + +extern Boolean TopShadowColor Xraw_PROTO((Widget /* self */, + Pixel /* base */, + Pixel* /* result */)); + +extern Boolean BottomShadowColor Xraw_PROTO((Widget /* self */, + Pixel /* base */, + Pixel* /* result */)); + +extern Boolean ArmedColor Xraw_PROTO((Widget /* self */, + Pixel /* base */, + Pixel* /* result */)); + +extern GC MakeTopShadowGC Xraw_PROTO((Widget , Pixel )); +extern GC MakeBottomShadowGC Xraw_PROTO((Widget , Pixel )); +extern GC MakeArmedGC Xraw_PROTO((Widget , Pixel )); + + +extern GC AllocGCFromPixmap Xraw_PROTO((Widget , Pixmap )); + + +extern GC AllocGCFromPixel Xraw_PROTO((Widget , Pixel )); + + +extern Pixmap CreateShadowPixmap Xraw_PROTO((Widget , + Pixel , + int )); + + +extern Boolean AllocShadowPixel Xraw_PROTO((Widget , + Pixel , + int , + Pixel * )); + + +extern GC MakeGC Xraw_PROTO((Widget , + Pixel , + int , + Boolean , + int )); + + +extern GC MakeTopShadowGC Xraw_PROTO((Widget , Pixel )); + + +extern GC MakeBottomShadowGC Xraw_PROTO((Widget , Pixel )); + + +extern GC MakeArmedGC Xraw_PROTO((Widget , Pixel )); + + +extern void XawDrawFrame Xraw_PROTO((Widget , + Position , + Position , + Dimension , + Dimension , + XawFrameType , + Dimension , + GC , + GC )); + + +extern void RGBtoHLS Xraw_PROTO((double , + double , + double , + double * , + double * , + double * )); + +extern void HLStoRGB Xraw_PROTO((double * , + double * , + double * , + double , + double , + double )); + +extern Boolean BottomShadowColor Xraw_PROTO((Widget , + Pixel , + Pixel * )); + + +extern Boolean TopShadowColor Xraw_PROTO((Widget , + Pixel , + Pixel * )); + + +extern Boolean ArmedColor Xraw_PROTO((Widget , + Pixel , + Pixel * )); + + +extern void DrawRhombus Xraw_PROTO((Widget , + short , + short , + short , + short , + GC , + GC , + GC , + Boolean )); + +extern Boolean FetchPixel Xraw_PROTO((Widget , + String name , + Pixel* )); + +#endif /* _3d_h_ */ + + + + diff --git a/vendor/x11iraf/obm/ObmW/zz/TableP.h b/vendor/x11iraf/obm/ObmW/zz/TableP.h new file mode 100644 index 00000000..7daa38f8 --- /dev/null +++ b/vendor/x11iraf/obm/ObmW/zz/TableP.h @@ -0,0 +1,166 @@ +/*********************************************************************** + + Table widget + Copyright by Vladimir T. Romanovski + All rights reserved. + +This library is desined for free, non-commercial software creation. +It is changeable and can be improved. The author would greatly appreciate +any advises, new components and patches of the existing programs. +Commercial usage is also possible with participation of it's author. + +*************************************************************************/ + +#ifndef _XawTableP_h +#define _XawTableP_h + +/*********************************************************************** + * + * Table Widget Private Data + * + ***********************************************************************/ + + +#include <X11/Xraw/ContainerP.h> +#include <X11/Xraw/Table.h> +#include <X11/Xraw/table.h> + +/* New fields for the Table widget class record */ + +typedef struct {int foo;} TableClassPart; + +/* Full class record declaration */ +typedef struct _TableClassRec { + CoreClassPart core_class; + CompositeClassPart composite_class; + ConstraintClassPart constraint_class; + ContainerClassPart container_class; + TableClassPart table_class; +} TableClassRec; + +#define MAX_ROWS 50 + +typedef struct _NormalReverseGC { + int used; + Pixel fore; + Pixel back; + GC normal; + GC reverse; +}NormalReverseGC; + +typedef struct _ShadowGC { + int used; + Pixel back; + GC top; + GC bottom; +}ShadowGC; + + + +/* New fields for the Table widget record */ +typedef struct { + /* ------------------------ resources -----------------------*/ + Pixel row_fore; + Pixel column_fore; + Pixel edit_fore; + Pixel edit_back; + Boolean row_oriented; + Boolean editable; + Boolean literal; + + int mask_number; + int columns; + int rows; + Dimension tab_margin; + Dimension row_margin; + Dimension col_margin; + Dimension internal_width; + Dimension internal_height; + Dimension label_shadow_thickness; + unsigned char encoding; + + /* Default Values */ + Pixel foreground; + XtJustify justify; + XFontStruct *font; + int width; + + /* Allowance CallbackList */ + XtCallbackList allow_add_row; + XtCallbackList allow_add_column; + XtCallbackList allow_delete_column; + XtCallbackList allow_delete_row; + XtCallbackList allow_delete_table; + + /* Information CallbackList */ + XtCallbackList add_row; + XtCallbackList add_column; + XtCallbackList changed_cell; + XtCallbackList create_table; + XtCallbackList delete_column; + XtCallbackList delete_row; + XtCallbackList delete_table; + XtCallbackList what_cell; + XtCallbackList changed_column_width; + XtCallbackList changed_row_height; + + Widget v_scroll; + Widget h_scroll; + + int row_height; + int column_default_width; + int literal_width; + + /* ------------------------ private state -----------------------*/ + + int no_refigure; /* no re-layout while > 0 */ + int no_redraw; /* no re-draw while > 0 */ + Boolean was_resized; + + + XawTableColumn column_data; + + Dimension prefer_width; + Dimension prefer_height; + Widget edit; + int edit_row; + int edit_column; + XawTableCell cell_own; + XawTableCell table_stuff; + + GC row_gc; /* Intrinsics sharedable GC */ + GC column_gc; /* Intrinsics sharedable GC */ + + GC normal; /* Table sharedable GC */ + GC reverse; /* Table sharedable GC */ + GC top; + GC bottom; + + GC edit_top; + GC edit_bottom; + + NormalReverseGC *normal_hash_table; + ShadowGC *shadow_hash_table; + int mask_hash_table; + + Atom selections[30]; + int num_selections; +} TablePart; + +/**************************************************************** + * + * Full instance record declaration + * + ****************************************************************/ + +typedef struct _TableRec { + CorePart core; + CompositePart composite; + ConstraintPart constraint; + ContainerPart container; + TablePart table; +} TableRec; + +extern TableClassRec tableClassRec; + +#endif /* _XawTableP_h */ diff --git a/vendor/x11iraf/obm/ObmW/zz/TableUtil.c b/vendor/x11iraf/obm/ObmW/zz/TableUtil.c new file mode 100644 index 00000000..ec2582be --- /dev/null +++ b/vendor/x11iraf/obm/ObmW/zz/TableUtil.c @@ -0,0 +1,918 @@ +/*********************************************************************** + + Table widget + Copyright by Vladimir T. Romanovski + All rights reserved. + +This library is designed for free, non-commercial software creation. +It is changeable and can be improved. The author would greatly appreciate +any advice, new components and patches of the existing programs. +Commercial usage is also possible with participation of the author. + + romsky@hp1.oea.ihep.su (Russia) + romsky@munin.ucsf.edu (USA) + +*************************************************************************/ + +#include <X11/Xraw/table.h> + +#ifdef EBUG_XRAW_MALLOC +#include <dbmalloc/malloc.h> +#endif + +/************************************************************************ + * + * TABLE IS A GRID OF POINTER BINDED NODES + * + ************************************************************************/ + +#define null (XawTableNode)NULL +#define FREE(t) if((t) != null)XtFree((char*)(t)) + +static void vert_tab_node_insert(f,s,p) + register XawTableNode f; /* insert after */ + register XawTableNode s; /* insert before */ + register XawTableNode p; /* to be inserted */ +{ + if (f != null) f->b = p; + if (s != null) s->t = p; + if (p != null) {p->t = f; p->b = s;} +} + +static void horiz_tab_node_insert(f,s,p) + register XawTableNode f; /* insert after */ + register XawTableNode s; /* insert before */ + register XawTableNode p; /* to be inserted */ +{ + if (f != null) f->r = p; + if (s != null) s->l = p; + if (p != null) {p->l = f; p->r = s;} +} + +static void vert_tab_node_reject(p) + register XawTableNode p; +{ + if (p == null) return; + + if (p->t != null) p->t->b = p->b; + if (p->b != null) p->b->t = p->t; +} + +static void horiz_tab_node_reject(p) + register XawTableNode p; +{ + if (p == null) return; + + if (p->r != null) p->r->l = p->l; + if (p->l != null) p->l->r = p->r; +} + +/* ARGSUSED */ +static XawTableProc del_cell (w, i, j, call_data, client_data) + XtPointer w; + int i; + int j; + XtPointer call_data; + XtPointer client_data; +{ + XtFree((char*)call_data); + return False; +} + +/* +** Function name : row_delete +** +** Description : delete row which the node belongs to +** Input : pointer to the node +** Output : void +*/ + +void +#if NeedFunctionPrototypes +row_delete (XtPointer f) +#else +row_delete(f) + XtPointer f; +#endif +{ + register XawTableNode p = (XawTableNode) f; + + if (p == null) + return; + + /* Go to left edge */ + for(; p->l != null; p=p->l ) + /*EMPTY*/; + + /* Go to right with dettaching cell */ + for(; p->r != null; p=p->r){ + vert_tab_node_reject(p->l); + FREE(p->l); + } + + /* Detach last but one cell in the row */ + if (p->l != null){ + vert_tab_node_reject(p->l); + FREE(p->l); + } + + /* Detach very last cell in the row */ + vert_tab_node_reject(p); + FREE(p); +} + +/* +** Function name : column_delete +** +** Description : delete column which the node belongs to +** Input : pointer to the node +** Output : void +*/ + +void +#if NeedFunctionPrototypes +column_delete (XtPointer f) +#else +column_delete(f) + XtPointer f; +#endif +{ + register XawTableNode p = (XawTableNode) f; + + if (p == null) + return; + + /* Go up to the edge */ + for(; p->t != null; p=p->t ) + /*EMPTY*/; + + /* Go down with dettaching cell */ + for(; p->b != null; p=p->b){ + horiz_tab_node_reject(p->t); + FREE(p->t); + } + + /* Detach bottom but one cell in the column */ + if (p->t != null){ + horiz_tab_node_reject(p->t); + FREE(p->t); + } + + /* Detach very bottom cell in the column */ + horiz_tab_node_reject(p); + FREE(p); +} + + + +/* +** Function name : row_insert_after +** +** Description : insert row down to the row which the node belongs to +** Input : poiter to the node, size of node +** Output : True if successful +*/ + +Boolean +#if NeedFunctionPrototypes +row_insert_after (XtPointer d, int node_size) +#else +row_insert_after(d, node_size) + XtPointer d; + int node_size; +#endif +{ + register XawTableNode f = (XawTableNode) d; + register XawTableNode p; + XawTableNode left; + + if (f == null) + return False; + + /* go left till row edge */ + for(; f->l != null; f=f->l ) + /*EMPTY*/; + + /* save very left node */ + left = f; + + /* go right and attach new cells via vertical ponters */ + for(; f->r != null; f=f->r){ + if( (p = (XawTableNode) XtMalloc (node_size)) == null){ + for(; left != f; left = left->r){ + vert_tab_node_reject(left->b); + FREE(left->b); + } + return False; + } + vert_tab_node_insert(f, f->b, p); + } + + /* attach vertically very right cell */ + if( (p = (XawTableNode) XtMalloc (node_size)) == null){ + for(; left != f; left = left->r){ + vert_tab_node_reject(left->b); + FREE(left->b); + } + return False; + } + vert_tab_node_insert(f, f->b, p); + + /* if only one column */ + if ( f->l == null ) { + f->b->l = f->b->r = null; + return True; + } + + /* attach horizontally very right cell */ + horiz_tab_node_insert(f->l->b,null,f->b); + + /* bind via horizontal ponters */ + for(f=f->l; f->l != null; f=f->l ) + horiz_tab_node_insert(f->l->b,f->r->b,f->b); + + /* attach horizontally very left cell */ + horiz_tab_node_insert(null,f->r->b,f->b); + + return True; +} + +/* +** Function name : row_insert_before +** +** Description : the same as previous, but only on top from row +** Input : pointer to the node, size of node +** Output : True if successful +*/ + +Boolean +#if NeedFunctionPrototypes +row_insert_before (XtPointer d, int node_size) +#else +row_insert_before(d, node_size) + XtPointer d; + int node_size; +#endif +{ + register XawTableNode f = (XawTableNode) d; + register XawTableNode p; + XawTableNode left; + + if (f == null) + return False; + + /* go left till row edge */ + for(; f->l != null; f=f->l ) + /*EMPTY*/; + + /* save very left node */ + left = f; + + /* go right and attach new cells via vertical ponters */ + for(; f->r != null; f=f->r){ + if( (p = (XawTableNode) XtMalloc (node_size)) == null){ + for(; left != f; left = left->r){ + vert_tab_node_reject(left->t); + FREE(left->t); + } + return False; + } + vert_tab_node_insert(f->t, f, p); + } + + /* attach vertically very right cell */ + if( (p = (XawTableNode) XtMalloc (node_size)) == null){ + for(; left != f; left = left->r){ + vert_tab_node_reject(left->t); + FREE(left->t); + } + return False; + } + vert_tab_node_insert(f->t, f, p); + + /* if only one column */ + if ( f->l == null ) { + f->t->l = f->t->r = null; + return True; + } + + /* attach horizontally very right cell */ + horiz_tab_node_insert(f->l->t,null,f->t); + + /* bind via horizontal ponters */ + for(f=f->l; f->l != null; f=f->l ) + horiz_tab_node_insert(f->l->t,f->r->t,f->t); + + /* attach horizontally very left cell */ + horiz_tab_node_insert(null,f->r->t,f->t); + + return True; +} + +/* +** Function name : column_insert_after +** +** Description : insert column right to the column which the node belongs to +** Input : pointer to the node, size of node +** Output : True if successful +[<*/ + +Boolean +#if NeedFunctionPrototypes +column_insert_after (XtPointer d, int node_size) +#else +column_insert_after(d, node_size) + XtPointer d; + int node_size; +#endif +{ + register XawTableNode f = (XawTableNode) d; + register XawTableNode p; + XawTableNode top; + + if (f == null) + return False; + + /* go top till column edge */ + for(; f->t != null; f=f->t ) + /*EMPTY*/; + + /* save very top node */ + top = f; + + /* go down and attach new cells via horizontal ponters */ + for(; f->b != null; f=f->b){ + if( (p = (XawTableNode) XtMalloc (node_size)) == null){ + for(; top != f; top = top->b){ + horiz_tab_node_reject(top->r); + FREE(top->r); + } + return False; + } + horiz_tab_node_insert(f, f->r, p); + } + + /* attach horizontally very down cell */ + if( (p = (XawTableNode) XtMalloc (node_size)) == null){ + for(; top != f; top = top->b){ + horiz_tab_node_reject(top->r); + FREE(top->r); + } + return False; + } + + horiz_tab_node_insert(f, f->r, p); + + /* if only one row */ + if ( f->t == null ) { + f->r->t = f->r->b = null; + return True; + } + + /* attach vertically very down cell */ + vert_tab_node_insert(f->t->r,null,f->r); + + /* bind via vertical ponters */ + for(f=f->t; f->t != null; f=f->t ) + vert_tab_node_insert(f->t->r,f->b->r,f->r); + + /* attach vertically very top cell */ + vert_tab_node_insert(null,f->b->r,f->r); + + return True; +} + +/* +** Function name : column_insert_before +** +** Description : the same as previous, but only to left from column +** Input : pointer to node, size of node +** Output : True if successful +*/ + +Boolean +#if NeedFunctionPrototypes +column_insert_before (XtPointer d, int node_size) +#else +column_insert_before(d, node_size) + XtPointer d; + int node_size; +#endif +{ + register XawTableNode f = (XawTableNode)d; + register XawTableNode p; + XawTableNode top; + + if (f == null) + return False; + + /* go top till column top */ + for(; f->t != null; f=f->t ) + /*EMPTY*/; + + /* save very top node */ + top = f; + + /* go down and attach new cells via horizontal ponters */ + for(; f->b != null; f=f->b){ + if( (p = (XawTableNode) XtMalloc (node_size)) == null){ + for(; top != f; top = top->b){ + horiz_tab_node_reject(top->l); + FREE(top->l); + } + return False; + } + horiz_tab_node_insert(f->l, f, p); + } + + /* attach horizontally very down cell */ + if( (p = (XawTableNode) XtMalloc (node_size)) == null){ + for(; top != f; top = top->b){ + horiz_tab_node_reject(top->l); + FREE(top->l); + } + return False; + } + horiz_tab_node_insert(f->l, f, p); + + /* if only one row */ + if ( f->t == null ) { + f->l->t = f->l->b = null; + return True; + } + + /* attach vertically very down cell */ + vert_tab_node_insert(f->t->l, null, f->l); + + /* bind via vertical ponters */ + for(f=f->t; f->t != null; f=f->t ) + vert_tab_node_insert(f->t->l, f->b->l, f->l); + + /* attach vertically very top cell */ + vert_tab_node_insert(null, f->b->l, f->l); + + return True; +} + +/* +** Function name : get_table +** +** Description : spot the node (0,0) in the table +** Input : pointer to any node in table +** Output : pointer to the node (0,0) +*/ + +XtPointer +#if NeedFunctionPrototypes +get_table (XtPointer f) +#else +get_table(f) + XtPointer f; +#endif +{ + register XawTableNode p = (XawTableNode) f; + + if (p == null) + return (XtPointer)NULL; + + for(; p->t != null; p=p->t) + /*EMPTY*/; + + for(; p->l != null; p=p->l) + /*EMPTY*/; + + return (XtPointer)p; +} + +/* +** Function name : get_cell +** +** Description : spot the node (i,j) regarding to given node +** Input : pointer to the node, column, row (may be negative) +** Output : pointer to the node or NULL +*/ + +XtPointer +#if NeedFunctionPrototypes +get_cell (XtPointer f, register int i, register int j) +#else +get_cell (f, i, j) + XtPointer f; + register int i; + register int j; +#endif +{ + register XawTableNode p = (XawTableNode) f; + + if (p == null) + return (XtPointer)NULL; + + if (i > 0) { + for(; i>0; i--) + if (p != null) p = p->b; + else return (XtPointer)NULL; + } else { + for(; i<0; i++) + if (p != null) p = p->t; + else return (XtPointer)NULL; + } + + if (j > 0) { + for(; j>0; j--) + if (p != null) p = p->r; + else return (XtPointer)NULL; + } else { + for(; j<0; j++) + if (p != null) p = p->l; + else return (XtPointer)NULL; + } + + return (XtPointer)p; +} + +#if 0 +static Boolean go_row(w, proc, p, begin_column, end_column, i, j, client_data) + XtPointer w; + XawTableProc proc; + XawTableNode p; /* p == get_cell(table, ... , begin_column) */ + int begin_column; + int end_column; + int *i; /* returned */ + int *j; /* returned */ + XtPointer client_data; +{ + for ((*j) = begin_column; ((*j) <= end_column) && (p != null); (*j)++) + { + XawTableProc sp = p; + p = p->r; + + if (proc(w, *i, *j, (XtPointer)sp, client_data)) + return True; + } + + return False; +} +#endif + +/* +** Function name : go_table +** +** Description : invoke given rutine for every node in given region +** Input : rutine, begin/end rows, begin/end columns... +** Output : True if given rutine returned True for a node, +** numbers of row and column for that node + */ + +Boolean +#if NeedFunctionPrototypes +go_table ( + XtPointer w, + XawTableProc proc, + XtPointer table, + int begin_row, + int end_row, + int begin_column, + int end_column, + int direction, + register int *i, /* returned */ + register int *j, /* returned */ + XtPointer client_data) +#else +go_table(w, proc, table, begin_row, end_row, begin_column, end_column, + direction, i, j, client_data) + XtPointer w; + XawTableProc proc; + XtPointer table; + int begin_row; + int end_row; + int begin_column; + int end_column; + int direction; + register int *i; /* returned */ + register int *j; /* returned */ + XtPointer client_data; +#endif +{ + register XawTableNode p; + register XawTableNode n; + + table = get_table(table); + + switch (direction) { + case XawTABLE_DOWN_RIGHT : + p = (XawTableNode)get_cell(table, begin_row, begin_column); + + for (*j = begin_column; *j <= end_column && p != null; (*j)++) + { + register XawTableNode sp = p; /* protect against deallocated node !! */ + p = p->r; + + for (*i = begin_row, n = sp; *i <= end_row && n != null; (*i)++) + { + register XawTableNode sn = n; /* protect against deallocated node !! */ + n = n->b; + + if (proc(w, *i, *j, (XtPointer)sn, client_data)) + return True; + } + } + break; + case XawTABLE_RIGHT_DOWN : + default : + p = (XawTableNode)get_cell(table, begin_row, begin_column); + + for (*i = begin_row; *i <= end_row && p != null; (*i)++) + { + register XawTableNode sp = p; /* protect against deallocated node !! */ + p = p->b; + + for (*j = begin_column, n = sp; *j <= end_column && n != null; (*j)++) + { + register XawTableNode sn = n; /* protect against deallocated node !! */ + n = n->r; + + if (proc(w, *i, *j, (XtPointer)sn, client_data)) + return True; + } + } + break; + } + return False; +} + +/* +** Function name : get_table_size +** +** Description : define dimention on the table +** Input : pointer to any node in the table +** Output : void +*/ + +void +#if NeedFunctionPrototypes +get_table_size (XtPointer f, + register int *i, /* returned */ + register int *j) /* returned */ +#else +get_table_size(f,i,j) + XtPointer f; + register int *i; /* returned */ + register int *j; /* returned */ +#endif +{ + register XawTableNode p = (XawTableNode)f; + if (p == null){ + *i = 0; + *j = 0; + } + + p = (XawTableNode)get_table(f); + + for (*i = 1; p->b != null; p = p->b, (*i)++) + /*EMPTY*/; + + for (*j = 1; p->r != null; p = p->r, (*j)++) + /*EMPTY*/; +} + +/* +** Function name : delete_table +** +** Description : destroy table +** Input : pointer to any node in the table +** Output : void +*/ + +void +#if NeedFunctionPrototypes +delete_table (XtPointer f) +#else +delete_table(f) + XtPointer f; +#endif +{ + register XawTableNode p = (XawTableNode)f; + int i,j; + int end_row, end_column; + + if (p == null) + return; + + p = (XawTableNode)get_table(f); + get_table_size((XtPointer)p, (int*)&end_row, (int*)&end_column); + (void)go_table(NULL, (XawTableProc)del_cell, (XtPointer)p, + 0, (int)(end_row-1), 0, (int)(end_column-1), + XawTABLE_RIGHT_DOWN, + (int*)&i, (int*)&j, NULL); +} + +/* +** Function name : get_cell_positions +** +** Description : define number of row & column for node +** Input : pointer to the node +** Output : void +*/ + +void +#if NeedFunctionPrototypes +get_cell_positions (XtPointer f, + register int *i, /* returned */ + register int *j) /* returned */ +#else +get_cell_positions(f, i, j) + XtPointer f; + register int *i; /* returned */ + register int *j; /* returned */ +#endif +{ + register XawTableNode p = (XawTableNode)f; + if ( p == null ) + return; + + if ( i != (int*)NULL ) { + for (*i = 0; p->t != null; p = p->t, (*i)++) + /*EMPTY*/; + } + + if ( j != (int*)NULL ) { + for (*j = 0; p->l != null; p = p->l, (*j)++) + /*EMPTY*/; + } +} + +/* +** Function name : create_table +** +** Description : create the table +** Input : row & column dimestions, size of node +** Output : pointer to the node (0,0) +*/ + +XtPointer +#if NeedFunctionPrototypes +create_table ( int rows, int columns, int node_size) +#else +create_table(rows, columns, node_size) + int rows; + int columns; + int node_size; +#endif +{ + register XawTableNode *area; + register XawTableNode p; + register int i,j; + XawTableNode table; + + if (rows == 0 || columns == 0) + return (XtPointer)NULL; + else{ + register XawTableNode *s; + + /* allocate temporary two-dimension array to make first node's binding */ + if ( (s = area = (XawTableNode*) + XtCalloc ((unsigned)(rows * columns), sizeof(XawTableNode))) == NULL) + return (XtPointer)NULL; + + /* allocate nodes */ + for (i = 0, j = rows*columns; i < j; i++) + if((*s++ = (XawTableNode) XtMalloc (node_size)) == NULL){ + int h; + for (h = 0, s = area; h < i; h++) + XtFree((char*)*s++); + + XtFree((char*)area); + return (XtPointer)NULL; + } + } + +#define a(i,j) (XawTableNode)*(area + (i)*columns + (j)) + + /* initialize the boundary nodes */ + for (i = 0; i < rows; i++) { + p = a(i,0); p->l = null; + p = a(i,columns-1); p->r = null; + } + for (j = 0; j < columns; j++) { + p = a(0,j); p->t = null; + p = a(rows-1,j); p->b = null; + } + +#undef a +#define a(i,j) (( (i)>=0 && (i)<rows ) && ( (j)>=0 && (j)<columns ) ? \ + (XawTableNode)*(area + (i)*columns + (j)) : null) + + /* make internode's binding */ + for (i = 0; i < rows; i++) { + for (j = i % 2; j < columns; j += 2) { + horiz_tab_node_insert(a(i,j-1), a(i,j+1), a(i,j)); + vert_tab_node_insert (a(i-1,j), a(i+1,j), a(i,j)); + } + } + +#undef a + + table = *area; + XtFree((char*)area); + return (XtPointer)table; +} + + +#ifdef EBUG_XRAW_MALLOC +/* ARGSUSED */ +static Boolean check_cell (w, row, column, call_data, client_data) + XtPointer w; /* unused */ + int row; + int column; + XtPointer call_data; + XtPointer client_data; +{ + register XawTableNode p = (XawTableNode)call_data; + int real_row, real_column; + char *halt = NULL;; + + get_cell_positions(p, &real_row, &real_column); + + if (real_row != row){ + XtWarning("check_table: wrong initial table row size"); + *halt = '\0'; + } + + if (real_column != column){ + XtWarning("check_table: wrong initial table column size"); + *halt = '\0'; + } + + if (p->l != null) + if (p->l->r != p) { + XtWarning("check_table: wrong cell"); + *halt = '\0'; + } + if (p->r != null) + if (p->r->l != p) { + XtWarning("check_table: wrong cell"); + *halt = '\0'; + } + if (p->t != null) + if (p->t->b != p) { + XtWarning("check_table: wrong cell"); + *halt = '\0'; + } + if (p->b != null) + if (p->b->t != p) { + XtWarning("check_table: wrong cell"); + *halt = '\0'; + } + + return False; +} + + + +void +#if NeedFunctionPrototypes +_check_table (XtPointer f, int rows, int columns) +#else +_check_table (f, rows, columns) + XtPointer f; + int rows; + int columns; +#endif +{ + register XawTableNode table = (XawTableNode)f; + int real_rows, real_columns; + register int i,j; + char *halt = NULL; + + if (f == NULL && (rows == 0 || columns == 0)) + return; + + if (table != get_table(f)){ + XtWarning("check_table: wrong initial table cell"); + *halt = '\0'; + } + + get_table_size (f, &real_rows, &real_columns); + + if (real_rows != rows){ + XtWarning("check_table: wrong initial table row size"); + *halt = '\0'; + } + + if (real_columns != columns){ + XtWarning("check_table: wrong initial table column size"); + *halt = '\0'; + } + + + (void) go_table (NULL, check_cell, table, + 0, rows-1, 0, columns-1, + XawTABLE_RIGHT_DOWN, + &real_rows, &real_columns, (XtPointer)NULL); + +} +#endif /* EBUG_XRAW_MALLOC */ + +#undef null +#undef FREE + diff --git a/vendor/x11iraf/obm/ObmW/zz/TableUtil.h b/vendor/x11iraf/obm/ObmW/zz/TableUtil.h new file mode 100644 index 00000000..a8262f75 --- /dev/null +++ b/vendor/x11iraf/obm/ObmW/zz/TableUtil.h @@ -0,0 +1,94 @@ +/*********************************************************************** + + Table widget + Copyright by Vladimir T. Romanovski + All rights reserved. + +This library is designed for free, non-commercial software creation. +It is changeable and can be improved. The author would greatly appreciate +any advice, new components and patches of the existing programs. +Commercial usage is also possible with participation of the author. + + romsky@hp1.oea.ihep.su (Russia) + romsky@munin.ucsf.edu (USA) + +*************************************************************************/ + +#ifndef _table_h_ +#define _table_h_ + +#include <stdio.h> +#include <X11/Intrinsic.h> +#include <X11/Xraw/Table.h> + +#if __STDC__ || defined(__cplusplus) +#define F_PROTO(s) s +#else +#define F_PROTO(s) () +#endif + +typedef struct _XawTableNodeRec { /* Node of table grid */ + struct _XawTableNodeRec *l; + struct _XawTableNodeRec *r; + struct _XawTableNodeRec *t; + struct _XawTableNodeRec *b; +}XawTableNodeRec, *XawTableNode; + + +extern XtPointer create_table F_PROTO((int rows, + int columns, + int node_size)); + +extern Boolean row_insert_after F_PROTO((XtPointer d, + int node_size)); + +extern Boolean row_insert_before F_PROTO((XtPointer f, + int node_size)); + +extern Boolean column_insert_after F_PROTO((XtPointer d, + int node_size)); + +extern Boolean column_insert_before F_PROTO((XtPointer f, + int node_size)); + +extern XtPointer get_table F_PROTO((XtPointer f)); + +extern XtPointer get_cell F_PROTO((XtPointer p, + int i, + int j)); + +extern void get_table_size F_PROTO((XtPointer p, + int *i, + int *j)); + +extern void get_cell_positions F_PROTO((XtPointer p, + int *i, + int *j)); + +extern void row_delete F_PROTO((XtPointer p)); + +extern void column_delete F_PROTO((XtPointer p)); + +extern void delete_table F_PROTO((XtPointer p)); + +extern Boolean go_table F_PROTO((XtPointer w, + XawTableProc proc, + XtPointer table, + int begin_row, + int end_row, + int begin_column, + int end_column, + int direction, + register int *row, + register int *column, + XtPointer client_data)); + +#ifdef EBUG_XRAW_MALLOC +extern void _check_table F_PROTO((XtPointer table, + int rows, + int columns)); +#endif + +#undef F_PROTO + +#endif /* _table_h_ */ diff --git a/vendor/x11iraf/obm/ObmW/zz/XrawInit.h b/vendor/x11iraf/obm/ObmW/zz/XrawInit.h new file mode 100644 index 00000000..cf6bcbc8 --- /dev/null +++ b/vendor/x11iraf/obm/ObmW/zz/XrawInit.h @@ -0,0 +1,60 @@ +/* $XConsortium: XawInit.h,v 1.4 91/07/22 19:05:25 converse Exp $ + * + * 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. + */ +#ifndef _XawInit_ +#define _XawInit_ + +#if !(defined(__STDC__) && __STDC__) && !defined(__cplusplus) && !defined(c_plusplus) && !defined(FUNCPROTO) && !defined(XTFUNCPROTO) && !defined(XAWFUNCPROTO) && !(defined(NeedFunctionPrototypes) && NeedFunctionPrototypes) +#define Xraw_NO_PROTO +#else +#define Xraw_NEED_PROTO +#endif /* __STDC__ */ + + +#ifdef Xraw_NEED_PROTO +#define Xraw_PROTO(args) args +#else +#define Xraw_PROTO(args) () +#endif + +#define Xraw_VERSION 1 +#define Xraw_REVISION 2 + +#define Xraw_3d 1 +#define Xraw_SCROLLBAR 20 +#define Xraw_TABLE 40 +#define Xraw_SEPARATOR 60 +#define Xraw_FRAME 80 + +#define streq(a,b) (XrmStringToQuark(a) == XrmStringToQuark(b)) + +#define FULL_WIDTH(w) ((w)->core.width + ((w)->core.border_width << 1)) +#define FULL_HEIGHT(w) ((w)->core.height + ((w)->core.border_width << 1)) +#define WNULL (Widget)NULL + +/* called from ClassInit procs */ +extern void XawInitializeWidgetSet Xraw_PROTO((void)); + +#if defined(XtSpecificationRelease) && XtSpecificationRelease < 5 +#define XPointer XtPointer +#endif + +#endif /* _XawInit_ */ |