Back to index

plt-scheme  4.2.1
Defines | Functions | Variables
xwBoard.c File Reference
#include <X11/IntrinsicP.h>
#include <X11/StringDefs.h>
#include <stdio.h>
#include <X11/Shell.h>
#include <ctype.h>
#include <./xwBoardP.h>

Go to the source code of this file.

Defines

#define ceil(r)   (-(int )(-(r )))
#define skip_blanks(s)   while (isspace (*s ))s ++
#define strtonum(t, n)
#define strtofrac(t, n, factor)   for ((factor )=1.0 ,(n )=0 ,(t )++;isdigit (*(t ));(t )++,(factor )/=10.0 )(n )=10 *(n )+*(t )-'0'

Functions

static void _resolve_inheritance ()
static Boolean set_values ()
static void initialize ()
static void set_abs_location ()
static void resize ()
static XtGeometryResult query_geometry ()
static XtGeometryResult geometry_manager ()
static void change_managed ()
static void generate_location ()
static void get_core_geometry ()
static void set_location ()
static String scan ()
static void interpret_location ()
static void generate_location (Widget self)
static void get_core_geometry (Widget self, Position *x, Position *y, Dimension *width, Dimension *height)
static void set_location (Widget self, unsignedint flags)
static String scan (String s, Position *absval, float *relval)
static void interpret_location (Widget self)
static void _resolve_inheritance (WidgetClass class)
static Boolean set_values (Widget old, Widget request, Widget self, ArgList args, Cardinal *num_args)
static void initialize (Widget request, Widget self, ArgList args, Cardinal *num_args)
static void set_abs_location (Widget self, unsignedint flags, int x, int y, int w, int h)
static void resize (Widget self)
static XtGeometryResult query_geometry (Widget self, XtWidgetGeometry *request, XtWidgetGeometry *reply)
static XtGeometryResult geometry_manager (Widget child, XtWidgetGeometry *request, XtWidgetGeometry *reply)
static void change_managed (Widget self)

Variables

static XtResource resources []
XfwfBoardClassRec xfwfBoardClassRec
WidgetClass xfwfBoardWidgetClass = (WidgetClass) &xfwfBoardClassRec

Define Documentation

#define ceil (   r)    (-(int )(-(r )))

Definition at line 50 of file xwBoard.c.

#define skip_blanks (   s)    while (isspace (*s ))s ++

Definition at line 68 of file xwBoard.c.

#define strtofrac (   t,
  n,
  factor 
)    for ((factor )=1.0 ,(n )=0 ,(t )++;isdigit (*(t ));(t )++,(factor )/=10.0 )(n )=10 *(n )+*(t )-'0'

Definition at line 78 of file xwBoard.c.

#define strtonum (   t,
 
)
Value:
do {\
        while ((*(t)) && !isdigit(*(t)) && *(t) != '.') (t)++;\
        for ((n) = 0; isdigit(*t); (t)++)\
            (n) = 10 * (n) + *(t) - '0';\
    }while (0 )

Definition at line 71 of file xwBoard.c.


Function Documentation

static void _resolve_inheritance ( ) [static]
static void _resolve_inheritance ( WidgetClass  class) [static]

Definition at line 316 of file xwBoard.c.

{
  XfwfBoardWidgetClass c = (XfwfBoardWidgetClass) class;
  XfwfBoardWidgetClass super;
  static CompositeClassExtensionRec extension_rec = {
    NULL, NULLQUARK, XtCompositeExtensionVersion,
    sizeof(CompositeClassExtensionRec), True};
  CompositeClassExtensionRec *ext;
  ext = (XtPointer)XtMalloc(sizeof(*ext));
  *ext = extension_rec;
  ext->next_extension = c->composite_class.extension;
  c->composite_class.extension = ext;
  if (class == xfwfBoardWidgetClass) return;
  super = (XfwfBoardWidgetClass)class->core_class.superclass;
  if (c->xfwfBoard_class.set_abs_location == XtInherit_set_abs_location)
    c->xfwfBoard_class.set_abs_location = super->xfwfBoard_class.set_abs_location;
}

Here is the call graph for this function:

static void change_managed ( ) [static]

Here is the caller graph for this function:

static void change_managed ( Widget  self) [static]

Definition at line 471 of file xwBoard.c.

{
#if 1
    Widget top = self, w;

    while (!XtIsSubclass(top, shellWidgetClass)) top = XtParent(top) ;
    for (w = self; w != top; w = XtParent(w)) XtInstallAllAccelerators(w, top);
#endif
}
static void generate_location ( ) [static]

Here is the caller graph for this function:

static void generate_location ( Widget  self) [static]

Definition at line 95 of file xwBoard.c.

{
    char tmp[100];

    (void) sprintf(tmp, "%d+%f %d+%f %d+%f %d+%f",
                   ((XfwfBoardWidget)self)->xfwfBoard.abs_x, ((XfwfBoardWidget)self)->xfwfBoard.rel_x, ((XfwfBoardWidget)self)->xfwfBoard.abs_y, ((XfwfBoardWidget)self)->xfwfBoard.rel_y, ((XfwfBoardWidget)self)->xfwfBoard.abs_width, ((XfwfBoardWidget)self)->xfwfBoard.rel_width,
                   ((XfwfBoardWidget)self)->xfwfBoard.abs_height, ((XfwfBoardWidget)self)->xfwfBoard.rel_height);
    XtFree(((XfwfBoardWidget)self)->xfwfBoard.location);
    ((XfwfBoardWidget)self)->xfwfBoard.location = XtNewString(tmp);
}

Here is the call graph for this function:

static XtGeometryResult geometry_manager ( ) [static]
static XtGeometryResult geometry_manager ( Widget  child,
XtWidgetGeometry *  request,
XtWidgetGeometry *  reply 
) [static]

Definition at line 447 of file xwBoard.c.

{ Widget self = XtParent(child); {
    /* Widget $ = XtParent(child); */
    Dimension wd, ht, bw;
    Position x, y;

    /* Get complete geometry, from request or current value */
    x = request->request_mode & CWX ? request->x : ((XfwfBoardWidget)child)->core.x;
    y = request->request_mode & CWY ? request->y : ((XfwfBoardWidget)child)->core.y;
    wd = request->request_mode & CWWidth ? request->width : ((XfwfBoardWidget)child)->core.width;
    ht = request->request_mode & CWHeight ? request->height : ((XfwfBoardWidget)child)->core.height;
    bw = request->request_mode & CWBorderWidth ? request->border_width
        : ((XfwfBoardWidget)child)->core.border_width;

    if (wd <= 0) wd = 1; if (ht <= 0) ht = 1; /* MATTHEW: [5] */
    XtConfigureWidget(child, x, y, wd, ht, bw);
    return XtGeometryDone;
}
}
static void get_core_geometry ( ) [static]

Here is the caller graph for this function:

static void get_core_geometry ( Widget  self,
Position *  x,
Position *  y,
Dimension *  width,
Dimension *  height 
) [static]

Definition at line 110 of file xwBoard.c.

{
    Widget parent;
    Position px, py;
    int pw, ph, minsize;
    float h;

    parent = ((XfwfBoardWidget)self)->core.parent;
    if (XtIsSubclass(((XfwfBoardWidget)self)->core.parent, xfwfBoardWidgetClass))
        ((XfwfBoardWidgetClass)parent->core.widget_class)->xfwfCommon_class.compute_inside(parent, &px, &py, &pw, &ph);
    else {
        px = 0;
        py = 0;
        pw = ((XfwfBoardWidget)parent)->core.width;
        ph = ((XfwfBoardWidget)parent)->core.height;
    }
    pw = max(0, pw);
    ph = max(0, ph);

    *x = ceil(((XfwfBoardWidget)self)->xfwfBoard.rel_x * pw + ((XfwfBoardWidget)self)->xfwfBoard.abs_x * ((XfwfBoardWidget)self)->xfwfBoard.hunit) + px;
    *y = ceil(((XfwfBoardWidget)self)->xfwfBoard.rel_y * ph + ((XfwfBoardWidget)self)->xfwfBoard.abs_y * ((XfwfBoardWidget)self)->xfwfBoard.vunit) + py;
    minsize = 2 * ((XfwfBoardWidgetClass)self->core.widget_class)->xfwfCommon_class.total_frame_width(self);
    minsize = max(1, minsize);
    h = ceil(((XfwfBoardWidget)self)->xfwfBoard.rel_width * pw + ((XfwfBoardWidget)self)->xfwfBoard.abs_width * ((XfwfBoardWidget)self)->xfwfBoard.hunit);
    *width = h < minsize ? minsize : h;
    h = ceil(((XfwfBoardWidget)self)->xfwfBoard.rel_height * ph + ((XfwfBoardWidget)self)->xfwfBoard.abs_height * ((XfwfBoardWidget)self)->xfwfBoard.vunit);
    *height = h < minsize ? minsize : h;
}
static void initialize ( ) [static]
static void initialize ( Widget  request,
Widget  self,
ArgList  args,
Cardinal *  num_args 
) [static]

Definition at line 382 of file xwBoard.c.

{
    if (((XfwfBoardWidget)self)->xfwfBoard.location != NULL) {
        ((XfwfBoardWidget)self)->xfwfBoard.location = XtNewString(((XfwfBoardWidget)self)->xfwfBoard.location);
        interpret_location(self);
        get_core_geometry(self, &((XfwfBoardWidget)self)->core.x, &((XfwfBoardWidget)self)->core.y, &((XfwfBoardWidget)self)->core.width, &((XfwfBoardWidget)self)->core.height);
    } else if (((XfwfBoardWidget)self)->core.x != MAGICNUM || ((XfwfBoardWidget)self)->core.y != MAGICNUM
               || ((XfwfBoardWidget)self)->core.width != MAGICNUM || ((XfwfBoardWidget)self)->core.height != MAGICNUM) {
        set_location(self, CWX | CWY | CWWidth | CWHeight);
        generate_location(self);
    } else {
        generate_location(self);
        get_core_geometry(self, &((XfwfBoardWidget)self)->core.x, &((XfwfBoardWidget)self)->core.y, &((XfwfBoardWidget)self)->core.width, &((XfwfBoardWidget)self)->core.height);
    }
}

Here is the call graph for this function:

static void interpret_location ( ) [static]

Here is the caller graph for this function:

static void interpret_location ( Widget  self) [static]

Definition at line 220 of file xwBoard.c.

{
    char *s;

    s = ((XfwfBoardWidget)self)->xfwfBoard.location;
    s = scan(s, &((XfwfBoardWidget)self)->xfwfBoard.abs_x, &((XfwfBoardWidget)self)->xfwfBoard.rel_x);
    s = scan(s, &((XfwfBoardWidget)self)->xfwfBoard.abs_y, &((XfwfBoardWidget)self)->xfwfBoard.rel_y);
    s = scan(s, &((XfwfBoardWidget)self)->xfwfBoard.abs_width, &((XfwfBoardWidget)self)->xfwfBoard.rel_width);
    s = scan(s, &((XfwfBoardWidget)self)->xfwfBoard.abs_height, &((XfwfBoardWidget)self)->xfwfBoard.rel_height);
}

Here is the call graph for this function:

static XtGeometryResult query_geometry ( ) [static]
static XtGeometryResult query_geometry ( Widget  self,
XtWidgetGeometry *  request,
XtWidgetGeometry *  reply 
) [static]

Definition at line 435 of file xwBoard.c.

{
    reply->request_mode = CWX | CWY | CWWidth | CWHeight;
    get_core_geometry(self, &reply->x, &reply->y,
                      &reply->width, &reply->height);
    return XtGeometryAlmost;
}

Here is the call graph for this function:

static void resize ( ) [static]
static void resize ( Widget  self) [static]

Definition at line 417 of file xwBoard.c.

{
    int i;
    XtWidgetGeometry reply;
    Widget child;

    for (i = 0; i < ((XfwfBoardWidget)self)->composite.num_children; i++) {
        child = ((XfwfBoardWidget)self)->composite.children[i];
        (void) XtQueryGeometry(child, NULL, &reply);
        XtConfigureWidget(child, reply.x, reply.y, reply.width,
                          reply.height, reply.border_width);
    }
}

Here is the call graph for this function:

static String scan ( ) [static]

Here is the caller graph for this function:

static String scan ( String  s,
Position *  absval,
float *  relval 
) [static]

Definition at line 182 of file xwBoard.c.

{
    String p;
    char c;
    long n;
    float fract, factor;

    *absval = 0;
    *relval = 0.0;
    p = s;
    strtonum(p, n);
    if (*p != '.') {                            /* 1st number is integer */
        *absval = n;
        skip_blanks(p);
        c = *p;
        if (c != '+' && c != '-') return p;     /* No second number */
        s = p;
        strtonum(p, n);
        if (*p != '.') return s;                /* This is an error... */
        strtofrac(p, fract, factor);
        *relval = c == '-' ? -fract * factor - n : fract * factor + n;
        return p;
    } else {                                    /* 1st number is float */
        strtofrac(p, fract, factor);
        *relval = fract * factor + n;
        skip_blanks(p);
        c = *p;
        if (c != '+' && c != '-') return p;     /* No second number */
        strtonum(p, n);
        *absval = c == '-' ? -n : n;
        return p;
    }
}
static void set_abs_location ( ) [static]
static void set_abs_location ( Widget  self,
unsigned int  flags,
int  x,
int  y,
int  w,
int  h 
) [static]

Definition at line 402 of file xwBoard.c.

{
    if ((flags & (CWX | CWY | CWWidth | CWHeight)) == 0) return;
    if (flags & CWX) ((XfwfBoardWidget)self)->core.x = x;
    if (flags & CWY) ((XfwfBoardWidget)self)->core.y = y;
    if (flags & CWWidth) ((XfwfBoardWidget)self)->core.width = max(1, w);
    if (flags & CWHeight) ((XfwfBoardWidget)self)->core.height = max(1, h);
    set_location(self, flags);
    generate_location(self);
}

Here is the call graph for this function:

static void set_location ( ) [static]

Here is the caller graph for this function:

static void set_location ( Widget  self,
unsigned int  flags 
) [static]

Definition at line 143 of file xwBoard.c.

{
    Widget parent;
    Position px, py;
    int pw, ph;

    parent = ((XfwfBoardWidget)self)->core.parent;
    if (XtIsSubclass(((XfwfBoardWidget)self)->core.parent, xfwfBoardWidgetClass))
        ((XfwfBoardWidgetClass)parent->core.widget_class)->xfwfCommon_class.compute_inside(parent, &px, &py, &pw, &ph);
    else {
        px = 0;
        py = 0;
        pw = ((XfwfBoardWidget)parent)->core.width;
        ph = ((XfwfBoardWidget)parent)->core.height;
    }
    pw = max(0, pw);
    ph = max(0, ph);
    if (flags & CWX) {
        ((XfwfBoardWidget)self)->xfwfBoard.rel_x = 0.0;
        ((XfwfBoardWidget)self)->xfwfBoard.abs_x = ceil((((XfwfBoardWidget)self)->core.x - px)/((XfwfBoardWidget)self)->xfwfBoard.hunit);
    }
    if (flags & CWY) {
        ((XfwfBoardWidget)self)->xfwfBoard.rel_y = 0.0;
        ((XfwfBoardWidget)self)->xfwfBoard.abs_y = ceil((((XfwfBoardWidget)self)->core.y - py)/((XfwfBoardWidget)self)->xfwfBoard.vunit);
    }
    if (flags & CWWidth) {
        ((XfwfBoardWidget)self)->xfwfBoard.rel_width = 0.0;
        ((XfwfBoardWidget)self)->xfwfBoard.abs_width = ceil(((XfwfBoardWidget)self)->core.width/((XfwfBoardWidget)self)->xfwfBoard.hunit);
    }
    if (flags & CWHeight) {
        ((XfwfBoardWidget)self)->xfwfBoard.rel_height = 0.0;
        ((XfwfBoardWidget)self)->xfwfBoard.abs_height = ceil(((XfwfBoardWidget)self)->core.height/((XfwfBoardWidget)self)->xfwfBoard.vunit);
    }
}
static Boolean set_values ( ) [static]
static Boolean set_values ( Widget  old,
Widget  request,
Widget  self,
ArgList  args,
Cardinal *  num_args 
) [static]

Definition at line 338 of file xwBoard.c.

{
    XtWidgetGeometry reply;
    int i;

    if (((XfwfBoardWidget)self)->xfwfBoard.location != ((XfwfBoardWidget)old)->xfwfBoard.location) {
        XtFree(((XfwfBoardWidget)old)->xfwfBoard.location);
        ((XfwfBoardWidget)self)->xfwfBoard.location = XtNewString(((XfwfBoardWidget)self)->xfwfBoard.location);
        interpret_location(self);
        get_core_geometry(self, &((XfwfBoardWidget)self)->core.x, &((XfwfBoardWidget)self)->core.y, &((XfwfBoardWidget)self)->core.width, &((XfwfBoardWidget)self)->core.height);
    } else if (ceil(((XfwfBoardWidget)self)->xfwfBoard.abs_x*((XfwfBoardWidget)self)->xfwfBoard.hunit) != ceil(((XfwfBoardWidget)old)->xfwfBoard.abs_x*((XfwfBoardWidget)old)->xfwfBoard.hunit)
               || ceil(((XfwfBoardWidget)self)->xfwfBoard.abs_width*((XfwfBoardWidget)self)->xfwfBoard.hunit) != ceil(((XfwfBoardWidget)old)->xfwfBoard.abs_width*((XfwfBoardWidget)old)->xfwfBoard.hunit)
               || ceil(((XfwfBoardWidget)self)->xfwfBoard.abs_y*((XfwfBoardWidget)self)->xfwfBoard.vunit) != ceil(((XfwfBoardWidget)old)->xfwfBoard.abs_y*((XfwfBoardWidget)old)->xfwfBoard.vunit)
               || ceil(((XfwfBoardWidget)self)->xfwfBoard.abs_height*((XfwfBoardWidget)self)->xfwfBoard.vunit) != ceil(((XfwfBoardWidget)old)->xfwfBoard.abs_height*((XfwfBoardWidget)old)->xfwfBoard.vunit)
               || ((XfwfBoardWidget)self)->xfwfBoard.rel_x != ((XfwfBoardWidget)old)->xfwfBoard.rel_x
               || ((XfwfBoardWidget)self)->xfwfBoard.rel_y != ((XfwfBoardWidget)old)->xfwfBoard.rel_y
               || ((XfwfBoardWidget)self)->xfwfBoard.rel_width != ((XfwfBoardWidget)old)->xfwfBoard.rel_width
               || ((XfwfBoardWidget)self)->xfwfBoard.rel_height != ((XfwfBoardWidget)old)->xfwfBoard.rel_height) {
        get_core_geometry(self, &((XfwfBoardWidget)self)->core.x, &((XfwfBoardWidget)self)->core.y, &((XfwfBoardWidget)self)->core.width, &((XfwfBoardWidget)self)->core.height);
        generate_location(self);
    } else if (((XfwfBoardWidget)self)->core.x != ((XfwfBoardWidget)old)->core.x
               || ((XfwfBoardWidget)self)->core.y != ((XfwfBoardWidget)old)->core.y
               || ((XfwfBoardWidget)self)->core.width != ((XfwfBoardWidget)old)->core.width
               || ((XfwfBoardWidget)self)->core.height != ((XfwfBoardWidget)old)->core.height) {
      set_location(self, (((((XfwfBoardWidget)self)->core.x != ((XfwfBoardWidget)old)->core.x) ? CWX : 0)
                     | ((((XfwfBoardWidget)self)->core.y != ((XfwfBoardWidget)old)->core.y) ? CWY : 0)
                     | ((((XfwfBoardWidget)self)->core.width != ((XfwfBoardWidget)old)->core.width) ? CWWidth : 0)
                     | ((((XfwfBoardWidget)self)->core.height != ((XfwfBoardWidget)old)->core.height) ? CWHeight : 0)));
      generate_location(self);
    }
    if (((XfwfBoardWidgetClass)self->core.widget_class)->xfwfCommon_class.total_frame_width(old) != ((XfwfBoardWidgetClass)self->core.widget_class)->xfwfCommon_class.total_frame_width(self)) {
        for (i = 0; i < ((XfwfBoardWidget)self)->composite.num_children; i++) {
            (void) XtQueryGeometry(((XfwfBoardWidget)self)->composite.children[i], NULL, &reply);
            XtConfigureWidget(((XfwfBoardWidget)self)->composite.children[i], reply.x, reply.y, reply.width,
                              reply.height, reply.border_width);
        }
    }
    return False;
}

Here is the call graph for this function:


Variable Documentation

XtResource resources[] [static]
Initial value:
 {
{XtNabs_x,XtCAbs_x,XtRPosition,sizeof(((XfwfBoardRec*)NULL)->xfwfBoard.abs_x),XtOffsetOf(XfwfBoardRec,xfwfBoard.abs_x),XtRImmediate,(XtPointer)0 },
{XtNrel_x,XtCRel_x,XtRFloat,sizeof(((XfwfBoardRec*)NULL)->xfwfBoard.rel_x),XtOffsetOf(XfwfBoardRec,xfwfBoard.rel_x),XtRString,(XtPointer)"0.0"},
{XtNabs_y,XtCAbs_y,XtRPosition,sizeof(((XfwfBoardRec*)NULL)->xfwfBoard.abs_y),XtOffsetOf(XfwfBoardRec,xfwfBoard.abs_y),XtRImmediate,(XtPointer)0 },
{XtNrel_y,XtCRel_y,XtRFloat,sizeof(((XfwfBoardRec*)NULL)->xfwfBoard.rel_y),XtOffsetOf(XfwfBoardRec,xfwfBoard.rel_y),XtRString,(XtPointer)"0.0"},
{XtNx,XtCX,XtRPosition,sizeof(((XfwfBoardRec*)NULL)->core.x),XtOffsetOf(XfwfBoardRec,core.x),XtRImmediate,(XtPointer)MAGICNUM },
{XtNy,XtCY,XtRPosition,sizeof(((XfwfBoardRec*)NULL)->core.y),XtOffsetOf(XfwfBoardRec,core.y),XtRImmediate,(XtPointer)MAGICNUM },
{XtNabs_width,XtCAbs_width,XtRPosition,sizeof(((XfwfBoardRec*)NULL)->xfwfBoard.abs_width),XtOffsetOf(XfwfBoardRec,xfwfBoard.abs_width),XtRImmediate,(XtPointer)0 },
{XtNrel_width,XtCRel_width,XtRFloat,sizeof(((XfwfBoardRec*)NULL)->xfwfBoard.rel_width),XtOffsetOf(XfwfBoardRec,xfwfBoard.rel_width),XtRString,(XtPointer)"1.0"},
{XtNabs_height,XtCAbs_height,XtRPosition,sizeof(((XfwfBoardRec*)NULL)->xfwfBoard.abs_height),XtOffsetOf(XfwfBoardRec,xfwfBoard.abs_height),XtRImmediate,(XtPointer)0 },
{XtNrel_height,XtCRel_height,XtRFloat,sizeof(((XfwfBoardRec*)NULL)->xfwfBoard.rel_height),XtOffsetOf(XfwfBoardRec,xfwfBoard.rel_height),XtRString,(XtPointer)"1.0"},
{XtNwidth,XtCWidth,XtRDimension,sizeof(((XfwfBoardRec*)NULL)->core.width),XtOffsetOf(XfwfBoardRec,core.width),XtRImmediate,(XtPointer)MAGICNUM },
{XtNheight,XtCHeight,XtRDimension,sizeof(((XfwfBoardRec*)NULL)->core.height),XtOffsetOf(XfwfBoardRec,core.height),XtRImmediate,(XtPointer)MAGICNUM },
{XtNhunit,XtCHunit,XtRFloat,sizeof(((XfwfBoardRec*)NULL)->xfwfBoard.hunit),XtOffsetOf(XfwfBoardRec,xfwfBoard.hunit),XtRString,(XtPointer)"1.0"},
{XtNvunit,XtCVunit,XtRFloat,sizeof(((XfwfBoardRec*)NULL)->xfwfBoard.vunit),XtOffsetOf(XfwfBoardRec,xfwfBoard.vunit),XtRString,(XtPointer)"1.0"},
{XtNlocation,XtCLocation,XtRString,sizeof(((XfwfBoardRec*)NULL)->xfwfBoard.location),XtOffsetOf(XfwfBoardRec,xfwfBoard.location),XtRImmediate,(XtPointer)NULL },
}

Definition at line 232 of file xwBoard.c.

Definition at line 250 of file xwBoard.c.

WidgetClass xfwfBoardWidgetClass = (WidgetClass) &xfwfBoardClassRec

Definition at line 315 of file xwBoard.c.