Back to index

plt-scheme  4.2.1
Functions | Variables
xwToggle.c File Reference
#include <X11/IntrinsicP.h>
#include <X11/StringDefs.h>
#include <xwTools3d.h>
#include <xwTabString.h>
#include <./xwToggleP.h>

Go to the source code of this file.

Functions

static void toggle ()
static void switch_on ()
static void switch_off ()
static void _resolve_inheritance ()
static void initialize ()
static void destroy ()
static void realize ()
static Boolean set_values ()
static void _expose ()
static void create_ex_gc ()
static void create_indicator_gc ()
static void create_center_gc ()
static void compute_indicatorcolor ()
static void create_ex_gc (Widget self)
static void create_indicator_gc (Widget self)
static void create_center_gc (Widget self)
static void compute_indicatorcolor (Widget self, int offset, XrmValue *value)
static void toggle (Widget self, XEvent *event, String *params, Cardinal *num_params)
static void switch_on (Widget self, XEvent *event, String *params, Cardinal *num_params)
static void switch_off (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 void realize (Widget self, XtValueMask *mask, XSetWindowAttributes *attributes)
static Boolean set_values (Widget old, Widget request, Widget self, ArgList args, Cardinal *num_args)
static void _expose (Widget self, XEvent *event, Region region)

Variables

static XtActionsRec actionsList []
static char defaultTranslations []
static XtResource resources []
XfwfToggleClassRec xfwfToggleClassRec
WidgetClass xfwfToggleWidgetClass = (WidgetClass) &xfwfToggleClassRec

Function Documentation

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

Definition at line 382 of file xwToggle.c.

{
    Position x, y;
    int w, h;

    if (! XtIsRealized(self)) return;
    xfwfButtonClassRec.xfwfCommon_class._expose(self, event, region);
    ((XfwfToggleWidgetClass)self->core.widget_class)->xfwfCommon_class.compute_inside(self, &x, &y, &w, &h);
    x += ((XfwfToggleWidget)self)->xfwfToggle.saveLeftMargin;
    y += (h - ((XfwfToggleWidget)self)->xfwfToggle.indicatorSize) / 2;
    switch (((XfwfToggleWidget)self)->xfwfToggle.indicatorType) {
    default:
       XtWarning("XfwfToggle has wrong indicatorType, using square!");
    case XfwfSquareIndicator:
       Xaw3dDrawToggle(XtDisplay(self), XtWindow(self),
                      ((XfwfToggleWidget)self)->xfwfFrame.lightgc, ((XfwfToggleWidget)self)->xfwfFrame.darkgc, ((XfwfToggleWidget)self)->xfwfToggle.indicator_gc, NULL, ((XfwfToggleWidget)self)->xfwfToggle.ex_gc,
                      x, y, ((XfwfToggleWidget)self)->xfwfToggle.indicatorSize, 2, ((XfwfToggleWidget)self)->xfwfToggle.on);
       break;
    case XfwfDiamondIndicator:
       Xaw3dDrawRadio(XtDisplay(self), XtWindow(self),
                     ((XfwfToggleWidget)self)->xfwfFrame.lightgc, ((XfwfToggleWidget)self)->xfwfFrame.darkgc, ((XfwfToggleWidget)self)->xfwfToggle.indicator_gc, ((XfwfToggleWidget)self)->xfwfToggle.center_gc, ((XfwfToggleWidget)self)->xfwfToggle.ex_gc,
                     x, y, ((XfwfToggleWidget)self)->xfwfToggle.indicatorSize, 2, ((XfwfToggleWidget)self)->xfwfToggle.on);
       break;
    }
}

Here is the call graph for this function:

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

Definition at line 283 of file xwToggle.c.

{
  XfwfToggleWidgetClass c = (XfwfToggleWidgetClass) class;
  XfwfToggleWidgetClass 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 == xfwfToggleWidgetClass) return;
  super = (XfwfToggleWidgetClass)class->core_class.superclass;
}

Here is the call graph for this function:

static void compute_indicatorcolor ( ) [static]
static void compute_indicatorcolor ( Widget  self,
int  offset,
XrmValue *  value 
) [static]

Definition at line 161 of file xwToggle.c.

{
    static Pixel color;
#if 1
    ((XfwfToggleWidgetClass)self->core.widget_class)->xfwfCommon_class.set_color(self, ((XfwfToggleWidget)self)->core.background_pixel, &color);
#else
    (void) choose_color(self, 0.85, ((XfwfToggleWidget)self)->core.background_pixel, &color);
#endif
    value->addr = (XtPointer) &color;
}

Here is the call graph for this function:

static void create_center_gc ( ) [static]

Here is the caller graph for this function:

static void create_center_gc ( Widget  self) [static]

Definition at line 143 of file xwToggle.c.

{
  XtGCMask mask = 0;
  XGCValues values;

  if (((XfwfToggleWidget)self)->xfwfToggle.center_gc != NULL) XtReleaseGC(self, ((XfwfToggleWidget)self)->xfwfToggle.center_gc);
  if (((XfwfToggleWidget)self)->xfwfToggle.indicatorType == XfwfDiamondIndicator) {
    mask = GCForeground;
    values.foreground = ((XfwfToggleWidget)self)->core.background_pixel;
    ((XfwfToggleWidget)self)->xfwfToggle.center_gc = XtGetGC(self, mask, &values);
  } else
    ((XfwfToggleWidget)self)->xfwfToggle.center_gc = NULL;
}
static void create_ex_gc ( ) [static]

Here is the caller graph for this function:

static void create_ex_gc ( Widget  self) [static]

Definition at line 89 of file xwToggle.c.

{
    XtGCMask mask = 0;
    XGCValues values;

    if (((XfwfToggleWidget)self)->xfwfToggle.ex_gc != NULL) XtReleaseGC(self, ((XfwfToggleWidget)self)->xfwfToggle.ex_gc);
    mask = GCForeground;
    values.foreground = ((XfwfToggleWidget)self)->xfwfCommon.highlightColor;
    ((XfwfToggleWidget)self)->xfwfToggle.ex_gc = XtGetGC(self, mask, &values);
}
static void create_indicator_gc ( ) [static]

Here is the caller graph for this function:

static void create_indicator_gc ( Widget  self) [static]

Definition at line 104 of file xwToggle.c.

{
    XtGCMask mask = 0;
    XGCValues values;

    if (((XfwfToggleWidget)self)->xfwfToggle.indicator_gc != NULL) XtReleaseGC(self, ((XfwfToggleWidget)self)->xfwfToggle.indicator_gc);
    switch (((XfwfToggleWidget)self)->xfwfFrame.shadowScheme) {
    case XfwfColor:
        mask = GCForeground;
        values.foreground = ((XfwfToggleWidget)self)->xfwfFrame.topShadowColor;
        break;
    case XfwfStipple:
        mask = GCFillStyle | GCStipple | GCForeground | GCBackground;
        values.fill_style = FillOpaqueStippled;
        values.background = BlackPixelOfScreen(XtScreen(self));
        values.foreground = WhitePixelOfScreen(XtScreen(self));
        values.stipple    = GetGray(self);
        break;
    case XfwfBlack:
    case XfwfAuto:
        if (DefaultDepthOfScreen(XtScreen(self)) > 4
            && ((XfwfToggleWidgetClass)self->core.widget_class)->xfwfCommon_class.set_color(self, ((XfwfToggleWidget)self)->core.background_pixel, &values.foreground)) {
            mask = GCForeground;
        } else {
            mask = GCFillStyle | GCBackground | GCForeground | GCStipple;
            values.fill_style = FillOpaqueStippled;
            values.background = BlackPixelOfScreen(XtScreen(self));
            values.foreground = WhitePixelOfScreen(XtScreen(self));
            values.stipple    = GetGray(self);
        }
        break;
    }
    ((XfwfToggleWidget)self)->xfwfToggle.indicator_gc = XtGetGC(self, mask, &values);
}

Here is the call graph for this function:

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

Definition at line 326 of file xwToggle.c.

{
   if (((XfwfToggleWidget)self)->xfwfToggle.center_gc) XtReleaseGC(self, ((XfwfToggleWidget)self)->xfwfToggle.center_gc); ((XfwfToggleWidget)self)->xfwfToggle.center_gc = NULL;
   if (((XfwfToggleWidget)self)->xfwfToggle.indicator_gc) XtReleaseGC(self, ((XfwfToggleWidget)self)->xfwfToggle.indicator_gc); ((XfwfToggleWidget)self)->xfwfToggle.indicator_gc = NULL;
   if (((XfwfToggleWidget)self)->xfwfToggle.ex_gc) XtReleaseGC(self, ((XfwfToggleWidget)self)->xfwfToggle.ex_gc); ((XfwfToggleWidget)self)->xfwfToggle.ex_gc = NULL;
}
static void initialize ( ) [static]
static void initialize ( Widget  request,
Widget  self,
ArgList  args,
Cardinal *  num_args 
) [static]

Definition at line 303 of file xwToggle.c.

{
    ((XfwfToggleWidget)self)->xfwfToggle.saveLeftMargin = ((XfwfToggleWidget)self)->xfwfLabel.leftMargin;

    if (((XfwfToggleWidget)self)->xfwfLabel.xfont) {
      if (!((XfwfToggleWidget)self)->xfwfToggle.indicatorSize || ((XfwfToggleWidget)self)->xfwfToggle.indicatorSize > wx_ASCENT(((XfwfToggleWidget)self)->xfwfLabel.font, ((wxExtFont)((XfwfToggleWidget)self)->xfwfLabel.xfont)))
       ((XfwfToggleWidget)self)->xfwfToggle.indicatorSize = wx_ASCENT(((XfwfToggleWidget)self)->xfwfLabel.font, ((wxExtFont)((XfwfToggleWidget)self)->xfwfLabel.xfont));
    } else {
      if (!((XfwfToggleWidget)self)->xfwfToggle.indicatorSize || ((XfwfToggleWidget)self)->xfwfToggle.indicatorSize > (((XfwfToggleWidget)self)->xfwfLabel.font ? ((XfwfToggleWidget)self)->xfwfLabel.font->ascent : 10))
       ((XfwfToggleWidget)self)->xfwfToggle.indicatorSize = (((XfwfToggleWidget)self)->xfwfLabel.font ? ((XfwfToggleWidget)self)->xfwfLabel.font->ascent : 10) + 2;
    }

    ((XfwfToggleWidget)self)->xfwfToggle.indicator_gc = NULL;
    ((XfwfToggleWidget)self)->xfwfToggle.center_gc = NULL;
    ((XfwfToggleWidget)self)->xfwfToggle.ex_gc = NULL;

    XtVaSetValues(self, XtNleftMargin, 2 * ((XfwfToggleWidget)self)->xfwfLabel.leftMargin + ((XfwfToggleWidget)self)->xfwfToggle.indicatorSize, NULL);
}
static void realize ( ) [static]
static void realize ( Widget  self,
XtValueMask *  mask,
XSetWindowAttributes *  attributes 
) [static]

Definition at line 337 of file xwToggle.c.

{
    xfwfButtonClassRec.core_class.realize(self, mask, attributes);
    create_indicator_gc(self);
    create_center_gc(self);
    create_ex_gc(self);
}

Here is the call graph for this function:

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

Definition at line 349 of file xwToggle.c.

{
    Boolean redraw = False;

    if (!XtIsRealized(self))
       return False;

    if (((XfwfToggleWidget)self)->xfwfToggle.on != ((XfwfToggleWidget)old)->xfwfToggle.on
    ||  ((XfwfToggleWidget)self)->xfwfToggle.indicatorType != ((XfwfToggleWidget)old)->xfwfToggle.indicatorType) {
        redraw = True;
    }
    if (((XfwfToggleWidget)self)->xfwfFrame.shadowScheme != ((XfwfToggleWidget)old)->xfwfFrame.shadowScheme) {
        create_indicator_gc(self);
        redraw = True;
    } else if (((XfwfToggleWidget)self)->xfwfFrame.shadowScheme == XfwfColor
           &&  ((XfwfToggleWidget)self)->xfwfToggle.indicatorColor != ((XfwfToggleWidget)old)->xfwfToggle.indicatorColor) {
       create_indicator_gc(self);
        redraw = True;
    }
    if (((XfwfToggleWidget)self)->xfwfToggle.indicatorSize != ((XfwfToggleWidget)old)->xfwfToggle.indicatorSize) {
       /* Compute new left margin */
       Dimension w = ((XfwfToggleWidget)self)->xfwfLabel.leftMargin + 2 * ((XfwfToggleWidget)self)->xfwfToggle.saveLeftMargin;
       /* change left margin */
       XtVaSetValues(self, XtNleftMargin, w, NULL);
       redraw = True;
    }
    return redraw;
}

Here is the call graph for this function:

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

Definition at line 275 of file xwToggle.c.

{
    if (((XfwfToggleWidget)self)->xfwfToggle.on) {
        XtVaSetValues(self, "on", False, NULL);
        XtCallCallbackList(self, ((XfwfToggleWidget)self)->xfwfToggle.offCallback, event);
    }
}
static void switch_on ( ) [static]
static void switch_on ( Widget  self,
XEvent*  event,
String*  params,
Cardinal*  num_params 
) [static]

Definition at line 266 of file xwToggle.c.

{
    if (! ((XfwfToggleWidget)self)->xfwfToggle.on) {
        XtVaSetValues(self, "on", True, NULL);
        XtCallCallbackList(self, ((XfwfToggleWidget)self)->xfwfToggle.onCallback, event);
    }
}
static void toggle ( ) [static]
static void toggle ( Widget  self,
XEvent*  event,
String*  params,
Cardinal*  num_params 
) [static]

Definition at line 259 of file xwToggle.c.

{
    XtVaSetValues(self, "on", !((XfwfToggleWidget)self)->xfwfToggle.on, NULL);
    XtCallCallbackList(self, ((XfwfToggleWidget)self)->xfwfToggle.on ? ((XfwfToggleWidget)self)->xfwfToggle.onCallback : ((XfwfToggleWidget)self)->xfwfToggle.offCallback, event);
}

Variable Documentation

XtActionsRec actionsList[] [static]
Initial value:
 {
{"toggle", toggle},
{"switch_on", switch_on},
{"switch_off", switch_off},
}

Definition at line 25 of file xwToggle.c.

char defaultTranslations[] [static]
Initial value:
"\
<Btn1Up>: toggle() \n\
<Key>Return: toggle() \n\
"

Definition at line 31 of file xwToggle.c.

XtResource resources[] [static]
Initial value:
 {
{XtNonCallback,XtCOnCallback,XtRCallback,sizeof(((XfwfToggleRec*)NULL)->xfwfToggle.onCallback),XtOffsetOf(XfwfToggleRec,xfwfToggle.onCallback),XtRImmediate,(XtPointer)NULL },
{XtNoffCallback,XtCOffCallback,XtRCallback,sizeof(((XfwfToggleRec*)NULL)->xfwfToggle.offCallback),XtOffsetOf(XfwfToggleRec,xfwfToggle.offCallback),XtRImmediate,(XtPointer)NULL },
{XtNon,XtCOn,XtRBoolean,sizeof(((XfwfToggleRec*)NULL)->xfwfToggle.on),XtOffsetOf(XfwfToggleRec,xfwfToggle.on),XtRImmediate,(XtPointer)False },
{XtNindicatorSize,XtCIndicatorSize,XtRDimension,sizeof(((XfwfToggleRec*)NULL)->xfwfToggle.indicatorSize),XtOffsetOf(XfwfToggleRec,xfwfToggle.indicatorSize),XtRImmediate,(XtPointer)0 },
{XtNindicatorType,XtCIndicatorType,XtRIndicatorType,sizeof(((XfwfToggleRec*)NULL)->xfwfToggle.indicatorType),XtOffsetOf(XfwfToggleRec,xfwfToggle.indicatorType),XtRImmediate,(XtPointer)XfwfSquareIndicator },
{XtNindicatorColor,XtCIndicatorColor,XtRPixel,sizeof(((XfwfToggleRec*)NULL)->xfwfToggle.indicatorColor),XtOffsetOf(XfwfToggleRec,xfwfToggle.indicatorColor),XtRCallProc,(XtPointer)compute_indicatorcolor },
{XtNframeWidth,XtCFrameWidth,XtRDimension,sizeof(((XfwfToggleRec*)NULL)->xfwfFrame.frameWidth),XtOffsetOf(XfwfToggleRec,xfwfFrame.frameWidth),XtRImmediate,(XtPointer)0 },
}

Definition at line 173 of file xwToggle.c.

Definition at line 183 of file xwToggle.c.

WidgetClass xfwfToggleWidgetClass = (WidgetClass) &xfwfToggleClassRec

Definition at line 257 of file xwToggle.c.