Back to index

plt-scheme  4.2.1
Functions | Variables
xwArrow.c File Reference
#include <X11/IntrinsicP.h>
#include <X11/StringDefs.h>
#include "xwGray.h"
#include <stdio.h>
#include <assert.h>
#include <wxtimeout.h>
#include "xwTools3d.h"
#include "xwTabString.h"
#include <./xwArrowP.h>

Go to the source code of this file.

Functions

static void activate_and_start_timer ()
static void stop_timer ()
static void push_up ()
static void push_down ()
static void _resolve_inheritance ()
static void initialize ()
static void destroy ()
static Boolean set_values ()
static void _expose ()
static void draw_arrow ()
static void timer_callback ()
static void create_arrowgc ()
static void create_arrowlightgc ()
static void create_arrowdarkgc ()
static void timer_callback (XtPointer client_data, XtIntervalId *timer)
static void create_arrowgc (Widget self)
static void create_arrowlightgc (Widget self)
static void create_arrowdarkgc (Widget self)
static void activate_and_start_timer (Widget self, XEvent *event, String *params, Cardinal *num_params)
static void stop_timer (Widget self, XEvent *event, String *params, Cardinal *num_params)
static void push_up (Widget self, XEvent *event, String *params, Cardinal *num_params)
static void push_down (Widget self, XEvent *event, String *params, Cardinal *num_params)
static void _resolve_inheritance (WidgetClass class)
static void initialize (Widget request, Widget self, ArgList args, Cardinal *num_args)
static void destroy (Widget self)
static Boolean set_values (Widget old, Widget request, Widget self, ArgList args, Cardinal *num_args)
static void _expose (Widget self, XEvent *event, Region region)
static void draw_arrow (Widget self, int on)

Variables

static XtActionsRec actionsList []
static char defaultTranslations []
static XtResource resources []
XfwfArrowClassRec xfwfArrowClassRec
WidgetClass xfwfArrowWidgetClass = (WidgetClass) &xfwfArrowClassRec

Function Documentation

static void _expose ( ) [static]
static void _expose ( Widget  self,
XEvent *  event,
Region  region 
) [static]

Definition at line 439 of file xwArrow.c.

{
    assert(((XfwfArrowWidget)self)->xfwfArrow.direction == XfwfTop || ((XfwfArrowWidget)self)->xfwfArrow.direction == XfwfLeft
          || ((XfwfArrowWidget)self)->xfwfArrow.direction == XfwfRight || ((XfwfArrowWidget)self)->xfwfArrow.direction == XfwfBottom);

    if (! XtIsRealized(self)) return;

    xfwfBoardClassRec.xfwfCommon_class._expose(self, event, region);

    if (region != NULL) {
       XSetRegion(XtDisplay(self), ((XfwfArrowWidget)self)->xfwfArrow.arrowgc, region);
       XSetRegion(XtDisplay(self), ((XfwfArrowWidget)self)->xfwfArrow.arrowlightgc, region);
       XSetRegion(XtDisplay(self), ((XfwfArrowWidget)self)->xfwfArrow.arrowdarkgc, region);
    }
       
    draw_arrow(self, 0);

    if (region != NULL) {
       XSetClipMask(XtDisplay(self), ((XfwfArrowWidget)self)->xfwfArrow.arrowgc, None);
       XSetClipMask(XtDisplay(self), ((XfwfArrowWidget)self)->xfwfArrow.arrowlightgc, None);
       XSetClipMask(XtDisplay(self), ((XfwfArrowWidget)self)->xfwfArrow.arrowdarkgc, None);
    }
}

Here is the call graph for this function:

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

Definition at line 334 of file xwArrow.c.

{
  XfwfArrowWidgetClass c = (XfwfArrowWidgetClass) class;
  XfwfArrowWidgetClass 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 == xfwfArrowWidgetClass) return;
  super = (XfwfArrowWidgetClass)class->core_class.superclass;
  if (c->xfwfArrow_class.draw_arrow == XtInherit_draw_arrow)
    c->xfwfArrow_class.draw_arrow = super->xfwfArrow_class.draw_arrow;
}

Here is the call graph for this function:

static void activate_and_start_timer ( ) [static]
static void activate_and_start_timer ( Widget  self,
XEvent*  event,
String*  params,
Cardinal*  num_params 
) [static]

Definition at line 295 of file xwArrow.c.

{
    if (event->type != ButtonPress) {
        XtWarning("The Arrow activate action isn't bound to a BtnDown event");
       return;
    }
    stop_timer(self, event, params, num_params);
    ((XfwfArrowWidget)self)->xfwfArrow.timer = 0x1; /* During callback, a stop_timer may be evaluated */
    XtCallCallbackList(self, ((XfwfArrowWidget)self)->xfwfArrow.callback, NULL);
    if (((XfwfArrowWidget)self)->xfwfArrow.repeat) {
      if (((XfwfArrowWidget)self)->xfwfArrow.timer) {
        stop_timer(self, event, params, num_params);
       ((XfwfArrowWidget)self)->xfwfArrow.timer = wxAppAddTimeOut(XtWidgetToApplicationContext(self),
                             ((XfwfArrowWidget)self)->xfwfArrow.initialDelay, timer_callback, self, self);
      }
    } else
       push_up(self, event, params, num_params);
}

Here is the call graph for this function:

static void create_arrowdarkgc ( ) [static]

Here is the caller graph for this function:

static void create_arrowdarkgc ( Widget  self) [static]

Definition at line 174 of file xwArrow.c.

{
    XtGCMask mask=0;
    XGCValues values;

    if (((XfwfArrowWidget)self)->xfwfArrow.arrowdarkgc != NULL) XtReleaseGC(self, ((XfwfArrowWidget)self)->xfwfArrow.arrowdarkgc);
    switch (((XfwfArrowWidget)self)->xfwfFrame.shadowScheme) {
    case XfwfColor:
       mask = GCForeground;
       values.foreground = ((XfwfArrowWidget)self)->xfwfFrame.bottomShadowColor;
       break;
    case XfwfStipple:
       mask = GCFillStyle | GCStipple | GCForeground | GCBackground;
       values.fill_style = FillOpaqueStippled;
       values.stipple = ((XfwfArrowWidget)self)->xfwfFrame.bottomShadowStipple;
       values.foreground = BlackPixelOfScreen(XtScreen(self));
       values.background = ((XfwfArrowWidget)self)->core.background_pixel;
       break;
    case XfwfBlack:
    case XfwfAuto:
       if (DefaultDepthOfScreen(XtScreen(self)) > 4
           && ((XfwfArrowWidgetClass)self->core.widget_class)->xfwfCommon_class.darker_color(self, ((XfwfArrowWidget)self)->core.background_pixel, &values.foreground)) {
           mask = GCForeground;
       } else {
           mask = GCFillStyle | GCBackground | GCForeground | GCStipple;
           values.fill_style = FillOpaqueStippled;
           /* values.background = $foreground; */
           values.background = BlackPixelOfScreen(XtScreen(self));
           values.foreground = WhitePixelOfScreen(XtScreen(self));
           values.stipple =
              XCreateBitmapFromData(XtDisplay(self),
                                  RootWindowOfScreen(XtScreen(self)),
                                  wx_gray_bits, wx_gray_width, wx_gray_height);
       }
       break;
    }
    ((XfwfArrowWidget)self)->xfwfArrow.arrowdarkgc = XtGetGC(self, mask, &values);
}
static void create_arrowgc ( ) [static]

Here is the caller graph for this function:

static void create_arrowgc ( Widget  self) [static]

Definition at line 116 of file xwArrow.c.

{
    XtGCMask mask;
    XGCValues values;

    if (((XfwfArrowWidget)self)->xfwfArrow.arrowgc != NULL) XtReleaseGC(self, ((XfwfArrowWidget)self)->xfwfArrow.arrowgc);
    mask = GCForeground;
    values.foreground = ((XfwfArrowWidget)self)->xfwfArrow.foreground;
    ((XfwfArrowWidget)self)->xfwfArrow.arrowgc = XtGetGC(self, mask, &values);
}
static void create_arrowlightgc ( ) [static]

Here is the caller graph for this function:

static void create_arrowlightgc ( Widget  self) [static]

Definition at line 131 of file xwArrow.c.

{
    XtGCMask mask=0;
    XGCValues values;

    if (((XfwfArrowWidget)self)->xfwfArrow.arrowlightgc != NULL) XtReleaseGC(self, ((XfwfArrowWidget)self)->xfwfArrow.arrowlightgc);
    switch (((XfwfArrowWidget)self)->xfwfFrame.shadowScheme) {
    case XfwfColor:
       mask = GCForeground;
       values.foreground = ((XfwfArrowWidget)self)->xfwfFrame.topShadowColor;
       break;
    case XfwfStipple:
       mask = GCFillStyle | GCStipple | GCForeground | GCBackground;
       values.fill_style = FillOpaqueStippled;
       values.background = ((XfwfArrowWidget)self)->core.background_pixel;
       values.stipple = ((XfwfArrowWidget)self)->xfwfFrame.topShadowStipple;
       values.foreground = WhitePixelOfScreen(XtScreen(self));
       break;
    case XfwfBlack:
    case XfwfAuto:
       if (DefaultDepthOfScreen(XtScreen(self)) > 4
           && ((XfwfArrowWidgetClass)self->core.widget_class)->xfwfCommon_class.lighter_color(self, ((XfwfArrowWidget)self)->core.background_pixel, &values.foreground)) {
           mask = GCForeground;
       } else {
           mask = GCFillStyle | GCBackground | GCForeground | GCStipple;
           values.fill_style = FillOpaqueStippled;
           /* values.background = $foreground; */
           values.background = BlackPixelOfScreen(XtScreen(self));
           values.foreground = WhitePixelOfScreen(XtScreen(self));
           values.stipple =
              XCreateBitmapFromData(XtDisplay(self),
                                  RootWindowOfScreen(XtScreen(self)),
                                  wx_gray_bits, wx_gray_width, wx_gray_height);
       }
       break;
    }
    ((XfwfArrowWidget)self)->xfwfArrow.arrowlightgc = XtGetGC(self, mask, &values);
}
static void destroy ( ) [static]
static void destroy ( Widget  self) [static]

Definition at line 373 of file xwArrow.c.

{
   if (((XfwfArrowWidget)self)->xfwfArrow.timer) {
      if (((XfwfArrowWidget)self)->xfwfArrow.timer != 0x1)
        wxRemoveTimeOut(((XfwfArrowWidget)self)->xfwfArrow.timer);
      ((XfwfArrowWidget)self)->xfwfArrow.timer = 0;
   }
   if (((XfwfArrowWidget)self)->xfwfArrow.arrowgc) XtReleaseGC(self, ((XfwfArrowWidget)self)->xfwfArrow.arrowgc); ((XfwfArrowWidget)self)->xfwfArrow.arrowgc = NULL;
   if (((XfwfArrowWidget)self)->xfwfArrow.arrowlightgc) XtReleaseGC(self, ((XfwfArrowWidget)self)->xfwfArrow.arrowlightgc); ((XfwfArrowWidget)self)->xfwfArrow.arrowlightgc = NULL;
   if (((XfwfArrowWidget)self)->xfwfArrow.arrowdarkgc) XtReleaseGC(self, ((XfwfArrowWidget)self)->xfwfArrow.arrowdarkgc); ((XfwfArrowWidget)self)->xfwfArrow.arrowdarkgc = NULL;   
}

Here is the call graph for this function:

static void draw_arrow ( ) [static]

Here is the caller graph for this function:

static void draw_arrow ( Widget  self,
int  on 
) [static]

Definition at line 467 of file xwArrow.c.

{
    Position x, y;
    int  width, height, dir, grayed;

    ((XfwfArrowWidgetClass)self->core.widget_class)->xfwfCommon_class.compute_inside(self, &x, &y, &width, &height);

    if (((XfwfArrowWidget)self)->xfwfArrow.arrowShadow) {
      XDrawLine(XtDisplay(self), XtWindow(self),
              (on ? ((XfwfArrowWidget)self)->xfwfArrow.arrowdarkgc : ((XfwfArrowWidget)self)->xfwfArrow.arrowlightgc),
              x, y, x + width, y);
      XDrawLine(XtDisplay(self), XtWindow(self),
              (on ? ((XfwfArrowWidget)self)->xfwfArrow.arrowdarkgc : ((XfwfArrowWidget)self)->xfwfArrow.arrowlightgc),
              x, y, x, y + height);
      XDrawLine(XtDisplay(self), XtWindow(self),
              (on ? ((XfwfArrowWidget)self)->xfwfArrow.arrowlightgc : ((XfwfArrowWidget)self)->xfwfArrow.arrowdarkgc),
              x + width - 1, y, x + width - 1, y + height);
      XDrawLine(XtDisplay(self), XtWindow(self),
              (on ? ((XfwfArrowWidget)self)->xfwfArrow.arrowlightgc : ((XfwfArrowWidget)self)->xfwfArrow.arrowdarkgc),
              x, y + height - 1, x + width, y + height - 1);
      width--;
      height--;
    }

    switch (((XfwfArrowWidget)self)->xfwfArrow.direction) {
    case XfwfTop:
      dir = UP;
      --y;
      break;
    case XfwfBottom:
      dir = DOWN;
      y++;
      break;
    case XfwfLeft:
      dir = LEFT;
      break;
    default:
    case XfwfRight:
      dir = RIGHT;
      break;
    }

    x += ((XfwfArrowWidget)self)->xfwfArrow.arrowShadow;
    y += ((XfwfArrowWidget)self)->xfwfArrow.arrowShadow;
    width -= 2 * ((XfwfArrowWidget)self)->xfwfArrow.arrowShadow;
    height -= 2 * ((XfwfArrowWidget)self)->xfwfArrow.arrowShadow;
    width = max(1, width);
    height = max(1, height);

    grayed = ((!((XfwfArrowWidget)self)->core.sensitive || ((XfwfArrowWidget)self)->xfwfArrow.drawgrayArrow) && wx_enough_colors(XtScreen(self)));

    Xaw3dDrawArrow(XtDisplay(self), XtWindow(self),
                 ((XfwfArrowWidget)self)->xfwfArrow.arrowlightgc, ((XfwfArrowWidget)self)->xfwfArrow.arrowdarkgc,
                 (grayed ? ((XfwfArrowWidget)self)->xfwfArrow.arrowdarkgc : ((XfwfArrowWidget)self)->xfwfArrow.arrowgc), (grayed ? ((XfwfArrowWidget)self)->xfwfArrow.arrowdarkgc : ((XfwfArrowWidget)self)->xfwfArrow.arrowgc),
                 x, y, width, height,
                 0, dir, on);
}

Here is the call graph for this function:

static void initialize ( ) [static]

Here is the caller graph for this function:

static void initialize ( Widget  request,
Widget  self,
ArgList  args,
Cardinal *  num_args 
) [static]

Definition at line 356 of file xwArrow.c.

{
    if (((XfwfArrowWidget)self)->xfwfArrow.direction != XfwfTop && ((XfwfArrowWidget)self)->xfwfArrow.direction != XfwfLeft
       && ((XfwfArrowWidget)self)->xfwfArrow.direction != XfwfRight && ((XfwfArrowWidget)self)->xfwfArrow.direction != XfwfBottom) {
       XtWarning("direction of Arrow widget incorrect; set to `top'");
       ((XfwfArrowWidget)self)->xfwfArrow.direction = XfwfTop;
    }
    ((XfwfArrowWidget)self)->xfwfArrow.arrowgc = NULL; create_arrowgc(self);
    ((XfwfArrowWidget)self)->xfwfArrow.arrowlightgc = NULL; create_arrowlightgc(self);
    ((XfwfArrowWidget)self)->xfwfArrow.arrowdarkgc = NULL; create_arrowdarkgc(self);
    ((XfwfArrowWidget)self)->xfwfArrow.timer = 0;
}

Here is the call graph for this function:

static void push_down ( ) [static]
static void push_down ( Widget  self,
XEvent*  event,
String*  params,
Cardinal*  num_params 
) [static]

Definition at line 329 of file xwArrow.c.

{
  draw_arrow(self, 1);
}

Here is the call graph for this function:

static void push_up ( ) [static]

Here is the caller graph for this function:

static void push_up ( Widget  self,
XEvent*  event,
String*  params,
Cardinal*  num_params 
) [static]

Definition at line 323 of file xwArrow.c.

{
  draw_arrow(self, 0);
}

Here is the call graph for this function:

static Boolean set_values ( ) [static]

Here is the caller graph for this function:

static Boolean set_values ( Widget  old,
Widget  request,
Widget  self,
ArgList  args,
Cardinal *  num_args 
) [static]

Definition at line 389 of file xwArrow.c.

{
    Boolean need_redisplay = False;

    if (((XfwfArrowWidget)self)->xfwfArrow.direction != XfwfTop && ((XfwfArrowWidget)self)->xfwfArrow.direction != XfwfLeft
       && ((XfwfArrowWidget)self)->xfwfArrow.direction != XfwfRight && ((XfwfArrowWidget)self)->xfwfArrow.direction != XfwfBottom) {
       XtWarning("direction of Arrow widget incorrect; set to `top'");
       ((XfwfArrowWidget)self)->xfwfArrow.direction = XfwfTop;
    }
    if (((XfwfArrowWidget)old)->xfwfArrow.direction != ((XfwfArrowWidget)self)->xfwfArrow.direction)
       need_redisplay = True;
    if (((XfwfArrowWidget)old)->xfwfArrow.foreground != ((XfwfArrowWidget)self)->xfwfArrow.foreground) {
       create_arrowgc(self);
       need_redisplay = True;
    }
    if (((XfwfArrowWidget)old)->xfwfArrow.arrowShadow != ((XfwfArrowWidget)self)->xfwfArrow.arrowShadow)
       need_redisplay = True;
    if (((XfwfArrowWidget)self)->xfwfFrame.shadowScheme != ((XfwfArrowWidget)old)->xfwfFrame.shadowScheme) {
       create_arrowdarkgc(self);
       create_arrowlightgc(self);
       need_redisplay = True;
    } else if (((XfwfArrowWidget)self)->xfwfFrame.shadowScheme == XfwfColor) {
       if (((XfwfArrowWidget)self)->xfwfFrame.topShadowColor != ((XfwfArrowWidget)old)->xfwfFrame.topShadowColor) {
           create_arrowlightgc(self);
           need_redisplay = True;
       }
       if (((XfwfArrowWidget)self)->xfwfFrame.bottomShadowColor != ((XfwfArrowWidget)old)->xfwfFrame.bottomShadowColor) {
           create_arrowdarkgc(self);
           need_redisplay = True;
       }
    } else if (((XfwfArrowWidget)self)->xfwfFrame.shadowScheme == XfwfStipple) {
       if (((XfwfArrowWidget)self)->xfwfFrame.topShadowStipple != ((XfwfArrowWidget)old)->xfwfFrame.topShadowStipple) {
           create_arrowlightgc(self);
           need_redisplay = True;
       }
       if (((XfwfArrowWidget)self)->xfwfFrame.bottomShadowStipple != ((XfwfArrowWidget)old)->xfwfFrame.bottomShadowStipple) {
           create_arrowdarkgc(self);
           need_redisplay = True;
       }
    }
    if (((XfwfArrowWidget)old)->xfwfArrow.drawgrayArrow != ((XfwfArrowWidget)self)->xfwfArrow.drawgrayArrow) {
      need_redisplay = TRUE;
    }
    return need_redisplay;
}

Here is the call graph for this function:

static void stop_timer ( ) [static]

Here is the caller graph for this function:

static void stop_timer ( Widget  self,
XEvent*  event,
String*  params,
Cardinal*  num_params 
) [static]

Definition at line 315 of file xwArrow.c.

{
    if (((XfwfArrowWidget)self)->xfwfArrow.timer && ((XfwfArrowWidget)self)->xfwfArrow.timer != 0x1)
       wxRemoveTimeOut(((XfwfArrowWidget)self)->xfwfArrow.timer);
    ((XfwfArrowWidget)self)->xfwfArrow.timer = 0;
}

Here is the call graph for this function:

static void timer_callback ( ) [static]

Here is the caller graph for this function:

static void timer_callback ( XtPointer  client_data,
XtIntervalId *  timer 
) [static]

Definition at line 99 of file xwArrow.c.

{
    Widget self = (Widget) client_data;

    XtCallCallbackList(self, ((XfwfArrowWidget)self)->xfwfArrow.callback, NULL);
    if (((XfwfArrowWidget)self)->xfwfArrow.timer) { /* i.e., no stop issued by callback */
      if (((XfwfArrowWidget)self)->xfwfArrow.timer != 0x1)
        wxRemoveTimeOut(((XfwfArrowWidget)self)->xfwfArrow.timer);
      ((XfwfArrowWidget)self)->xfwfArrow.timer = wxAppAddTimeOut(XtWidgetToApplicationContext(self),
                                 ((XfwfArrowWidget)self)->xfwfArrow.repeatDelay, timer_callback, self, self);
    }
}

Here is the call graph for this function:


Variable Documentation

XtActionsRec actionsList[] [static]
Initial value:
 {
{"activate_and_start_timer", activate_and_start_timer},
{"stop_timer", stop_timer},
{"push_up", push_up},
{"push_down", push_down},
}

Definition at line 34 of file xwArrow.c.

char defaultTranslations[] [static]
Initial value:
"\
<Btn1Down>: push_down() activate_and_start_timer() \n\
<Btn1Up>: push_up() stop_timer() \n\
"

Definition at line 41 of file xwArrow.c.

XtResource resources[] [static]
Initial value:
 {
{XtNdirection,XtCDirection,XtRAlignment,sizeof(((XfwfArrowRec*)NULL)->xfwfArrow.direction),XtOffsetOf(XfwfArrowRec,xfwfArrow.direction),XtRImmediate,(XtPointer)XfwfTop },
{XtNforeground,XtCForeground,XtRPixel,sizeof(((XfwfArrowRec*)NULL)->xfwfArrow.foreground),XtOffsetOf(XfwfArrowRec,xfwfArrow.foreground),XtRString,(XtPointer)XtDefaultBackground },
{XtNarrowShadow,XtCArrowShadow,XtRDimension,sizeof(((XfwfArrowRec*)NULL)->xfwfArrow.arrowShadow),XtOffsetOf(XfwfArrowRec,xfwfArrow.arrowShadow),XtRImmediate,(XtPointer)2 },
{XtNrepeat,XtCRepeat,XtRBoolean,sizeof(((XfwfArrowRec*)NULL)->xfwfArrow.repeat),XtOffsetOf(XfwfArrowRec,xfwfArrow.repeat),XtRImmediate,(XtPointer)TRUE },
{XtNinitialDelay,XtCInitialDelay,XtRCardinal,sizeof(((XfwfArrowRec*)NULL)->xfwfArrow.initialDelay),XtOffsetOf(XfwfArrowRec,xfwfArrow.initialDelay),XtRImmediate,(XtPointer)500 },
{XtNrepeatDelay,XtCRepeatDelay,XtRCardinal,sizeof(((XfwfArrowRec*)NULL)->xfwfArrow.repeatDelay),XtOffsetOf(XfwfArrowRec,xfwfArrow.repeatDelay),XtRImmediate,(XtPointer)200 },
{XtNcallback,XtCCallback,XtRCallback,sizeof(((XfwfArrowRec*)NULL)->xfwfArrow.callback),XtOffsetOf(XfwfArrowRec,xfwfArrow.callback),XtRImmediate,(XtPointer)NULL },
{XtNdrawgrayArrow,XtCDrawgrayArrow,XtRBoolean,sizeof(((XfwfArrowRec*)NULL)->xfwfArrow.drawgrayArrow),XtOffsetOf(XfwfArrowRec,xfwfArrow.drawgrayArrow),XtRImmediate,(XtPointer)FALSE },
}

Definition at line 214 of file xwArrow.c.

Definition at line 225 of file xwArrow.c.

WidgetClass xfwfArrowWidgetClass = (WidgetClass) &xfwfArrowClassRec

Definition at line 293 of file xwArrow.c.