Back to index

plt-scheme  4.2.1
Defines | Functions | Variables
xwGroup.c File Reference
#include <X11/IntrinsicP.h>
#include <X11/StringDefs.h>
#include <stdio.h>
#include <X11/Xmu/Converters.h>
#include <X11/Xmu/CharSet.h>
#include <xwToggle.h>
#include <./xwGroupP.h>

Go to the source code of this file.

Defines

#define done(type, value)

Functions

static void _resolve_inheritance ()
static void class_initialize ()
static void initialize ()
static void destroy ()
static Boolean set_values ()
static void _expose ()
static void insert_child ()
static void make_textgc ()
static void on_cb ()
static void off_cb ()
static void set_toggles ()
static Boolean cvtStringToSelectionType ()
static Boolean cvtSelectionTypeToString ()
static void make_textgc (Widget self)
static void on_cb (Widget toggle, XtPointer client_data, XtPointer call_data)
static void off_cb (Widget toggle, XtPointer client_data, XtPointer call_data)
static void set_toggles (Widget self)
static Boolean cvtStringToSelectionType (Display *display, XrmValuePtr args, Cardinal *num_args, XrmValuePtr from, XrmValuePtr to, XtPointer *converter_data)
static Boolean cvtSelectionTypeToString (Display *display, XrmValuePtr args, Cardinal *num_args, XrmValuePtr from, XrmValuePtr to, XtPointer *converter_data)
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 insert_child (Widget child)

Variables

static XtResource resources []
XfwfGroupClassRec xfwfGroupClassRec
WidgetClass xfwfGroupWidgetClass = (WidgetClass) &xfwfGroupClassRec

Define Documentation

#define done (   type,
  value 
)
Value:
do {\
      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;\
  }while (0 )

Definition at line 66 of file xwGroup.c.


Function Documentation

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

Definition at line 423 of file xwGroup.c.

{
    int w, h;
    Position x, y;

    if (! XtIsRealized(self)) return;
    xfwfRowColClassRec.xfwfCommon_class._expose(self, event, region);
    if (((XfwfGroupWidget)self)->xfwfGroup.label) {
       ((XfwfGroupWidgetClass)self->core.widget_class)->xfwfCommon_class.compute_inside(self, &x, &y, &w, &h);

       XDrawImageString(XtDisplay(self), XtWindow(self), ((XfwfGroupWidget)self)->xfwfGroup.textgc, x + 3,
                      y - ((XfwfGroupWidget)self)->xfwfFrame.innerOffset, ((XfwfGroupWidget)self)->xfwfGroup.label, strlen(((XfwfGroupWidget)self)->xfwfGroup.label));
    }

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

Definition at line 336 of file xwGroup.c.

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

Here is the call graph for this function:

static void class_initialize ( ) [static]

Definition at line 356 of file xwGroup.c.

{
    XtAddConverter(XtRString, XtRLong, XmuCvtStringToLong, NULL, 0);
    XtSetTypeConverter(XtRString, XtRSelectionType, cvtStringToSelectionType,
                     NULL, 0, XtCacheNone, NULL);
    XtSetTypeConverter(XtRSelectionType, XtRString, cvtSelectionTypeToString,
                     NULL, 0, XtCacheNone, NULL);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static Boolean cvtSelectionTypeToString ( ) [static]

Here is the caller graph for this function:

static Boolean cvtSelectionTypeToString ( Display *  display,
XrmValuePtr  args,
Cardinal *  num_args,
XrmValuePtr  from,
XrmValuePtr  to,
XtPointer *  converter_data 
) [static]

Definition at line 232 of file xwGroup.c.

{
    char s[30];

    if (*num_args != 0)
       XtAppErrorMsg(XtDisplayToApplicationContext(display),
                    "cvtStringToSelectionStyle", "wrongParameters",
                    "XtToolkitError",
                    "String to SelectionStyle conversion needs no arguments",
                    (String*) NULL, (Cardinal*) NULL);
    switch (*((SelectionType*) from->addr)) {
    case XfwfNoSelection: done(String, "none");
    case XfwfSingleSelection: done(String, "single");
    case XfwfOneSelection: done(String, "one");
    case XfwfMultipleSelection: done(String, "multiple");
    }
    XtDisplayStringConversionWarning(display, s, XtRSelectionType);
    done(String, "none");
}
static Boolean cvtStringToSelectionType ( ) [static]

Here is the caller graph for this function:

static Boolean cvtStringToSelectionType ( Display *  display,
XrmValuePtr  args,
Cardinal *  num_args,
XrmValuePtr  from,
XrmValuePtr  to,
XtPointer *  converter_data 
) [static]

Definition at line 200 of file xwGroup.c.

{
    String s = (String) from->addr;

    if (*num_args != 0)
       XtAppErrorMsg(XtDisplayToApplicationContext(display),
                    "cvtStringToSelectionType", "wrongParameters",
                    "XtToolkitError",
                    "String to SelectionType conversion needs no arguments",
                    (String*) NULL, (Cardinal*) NULL);

    if (XmuCompareISOLatin1(s, "no") == 0)
       done(SelectionType, XfwfNoSelection);
    if (XmuCompareISOLatin1(s, "none") == 0)
       done(SelectionType, XfwfNoSelection);
    if (XmuCompareISOLatin1(s, "single") == 0)
       done(SelectionType, XfwfSingleSelection);
    if (XmuCompareISOLatin1(s, "one") == 0)
       done(SelectionType, XfwfOneSelection);
    if (XmuCompareISOLatin1(s, "multi") == 0)
       done(SelectionType, XfwfMultipleSelection);
    if (XmuCompareISOLatin1(s, "multiple") == 0)
       done(SelectionType, XfwfMultipleSelection);

    XtDisplayStringConversionWarning(display, s, XtRSelectionType);
    done(SelectionType, XfwfSingleSelection);
}

Here is the call graph for this function:

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

Definition at line 387 of file xwGroup.c.

{
   if (((XfwfGroupWidget)self)->xfwfGroup.textgc) XtReleaseGC(self, ((XfwfGroupWidget)self)->xfwfGroup.textgc); ((XfwfGroupWidget)self)->xfwfGroup.textgc = NULL;
}
static void initialize ( ) [static]
static void initialize ( Widget  request,
Widget  self,
ArgList  args,
Cardinal *  num_args 
) [static]

Definition at line 369 of file xwGroup.c.

{
    ((XfwfGroupWidget)self)->xfwfGroup.toggle_ord = 0;
    ((XfwfGroupWidget)self)->xfwfGroup.textgc = NULL;
    make_textgc(self);
    if (((XfwfGroupWidget)self)->xfwfGroup.label)
     ((XfwfGroupWidget)self)->xfwfGroup.label = XtNewString(((XfwfGroupWidget)self)->xfwfGroup.label);
    if (((XfwfGroupWidget)self)->xfwfGroup.selectionStyle == XfwfOneSelection && ((XfwfGroupWidget)self)->xfwfGroup.selection == -1L) {
       XtWarning
           ("Illegal combination of selectionStyle and selection resources");
       ((XfwfGroupWidget)self)->xfwfGroup.selection = 0;
    }
}

Here is the call graph for this function:

static void insert_child ( ) [static]
static void insert_child ( Widget  child) [static]

Definition at line 444 of file xwGroup.c.

{ Widget self = XtParent(child); {
    xfwfRowColClassRec.composite_class.insert_child(child);
    if (((XfwfGroupWidget)self)->xfwfGroup.selectionStyle != XfwfNoSelection
       && XtIsSubclass(child, xfwfToggleWidgetClass)) {
       XtAddCallback(child, XtNonCallback, on_cb, (XtPointer) ((XfwfGroupWidget)self)->xfwfGroup.toggle_ord);
       XtAddCallback(child, XtNoffCallback, off_cb, (XtPointer) ((XfwfGroupWidget)self)->xfwfGroup.toggle_ord);
       switch (((XfwfGroupWidget)self)->xfwfGroup.selectionStyle) {
       case XfwfOneSelection:
       case XfwfSingleSelection:
           XtVaSetValues(child, XtNon, ((XfwfGroupWidget)self)->xfwfGroup.toggle_ord == ((XfwfGroupWidget)self)->xfwfGroup.selection,
                             XtNindicatorType, XfwfDiamondIndicator, NULL);
           break;
       case XfwfMultipleSelection:
           XtVaSetValues(child, XtNon, (((XfwfGroupWidget)self)->xfwfGroup.selection & (1L<<((XfwfGroupWidget)self)->xfwfGroup.toggle_ord)) != 0,
                             XtNindicatorType, XfwfSquareIndicator, NULL);
           break;
       default: ;
       }
       ((XfwfGroupWidget)self)->xfwfGroup.toggle_ord++;
    }
}
}

Here is the call graph for this function:

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

Definition at line 97 of file xwGroup.c.

{
    XtGCMask mask;
    XGCValues values;

    if (((XfwfGroupWidget)self)->xfwfGroup.textgc != NULL) XtReleaseGC(self, ((XfwfGroupWidget)self)->xfwfGroup.textgc);
    values.background = ((XfwfGroupWidget)self)->core.background_pixel;
    values.foreground = ((XfwfGroupWidget)self)->xfwfGroup.foreground;
    mask = GCBackground | GCForeground;
    if (((XfwfGroupWidget)self)->xfwfGroup.font) {
      values.font = ((XfwfGroupWidget)self)->xfwfGroup.font->fid;
      mask |= GCFont;
    }
    ((XfwfGroupWidget)self)->xfwfGroup.textgc = XtGetGC(self, mask, &values);
}
static void off_cb ( ) [static]

Here is the caller graph for this function:

static void off_cb ( Widget  toggle,
XtPointer  client_data,
XtPointer  call_data 
) [static]

Definition at line 149 of file xwGroup.c.

{
    Widget self = XtParent(toggle);
    Cardinal toggle_ord = (Cardinal) client_data;
    Cardinal bits = sizeof(((XfwfGroupWidget)self)->xfwfGroup.selection) * 8;

    switch (((XfwfGroupWidget)self)->xfwfGroup.selectionStyle) {
    case XfwfOneSelection:
       XtVaSetValues(toggle, XtNon, True, NULL); /* Undo */
       break;
    case XfwfSingleSelection:
       ((XfwfGroupWidget)self)->xfwfGroup.selection = -1L;                   /* Nothing selected */
       break;
    case XfwfMultipleSelection:
       if (toggle_ord < bits) ((XfwfGroupWidget)self)->xfwfGroup.selection &= ~(1L << toggle_ord);
       break;
    default: ;
    }
    XtCallCallbackList(self, ((XfwfGroupWidget)self)->xfwfGroup.activate, (XtPointer) ((XfwfGroupWidget)self)->xfwfGroup.selection);
}
static void on_cb ( ) [static]

Here is the caller graph for this function:

static void on_cb ( Widget  toggle,
XtPointer  client_data,
XtPointer  call_data 
) [static]

Definition at line 117 of file xwGroup.c.

{
    Widget self = XtParent(toggle);
    Cardinal toggle_ord = (Cardinal) client_data;
    Cardinal t, i, bits = sizeof(((XfwfGroupWidget)self)->xfwfGroup.selection) * 8;

    switch (((XfwfGroupWidget)self)->xfwfGroup.selectionStyle) {
    case XfwfMultipleSelection:
       if (toggle_ord < bits) ((XfwfGroupWidget)self)->xfwfGroup.selection |= 1L << toggle_ord;
       break;
    case XfwfSingleSelection:
    case XfwfOneSelection:
       if (((XfwfGroupWidget)self)->xfwfGroup.selection != -1L)
           for (t = 0, i = 0; i < ((XfwfGroupWidget)self)->composite.num_children; i++)
              if (XtIsSubclass(((XfwfGroupWidget)self)->composite.children[i], xfwfToggleWidgetClass)) {
                  if (((XfwfGroupWidget)self)->xfwfGroup.selection == t) {
                     XtVaSetValues(((XfwfGroupWidget)self)->composite.children[i], XtNon, False, NULL);
                     break;
                  }
                  t++;
              }
       ((XfwfGroupWidget)self)->xfwfGroup.selection = toggle_ord;
       break;
    default: ;
    }
    XtCallCallbackList(self, ((XfwfGroupWidget)self)->xfwfGroup.activate, (XtPointer) ((XfwfGroupWidget)self)->xfwfGroup.selection);
}
static void set_toggles ( ) [static]

Here is the caller graph for this function:

static void set_toggles ( Widget  self) [static]

Definition at line 174 of file xwGroup.c.

{
    Cardinal i, t;

    for (t = 0, i = 0; i < ((XfwfGroupWidget)self)->composite.num_children; i++)
       if (XtIsSubclass(((XfwfGroupWidget)self)->composite.children[i], xfwfToggleWidgetClass)) {
           switch (((XfwfGroupWidget)self)->xfwfGroup.selectionStyle) {
           case XfwfNoSelection:
              break;
           case XfwfSingleSelection:
           case XfwfOneSelection:
              XtVaSetValues(((XfwfGroupWidget)self)->composite.children[i], XtNon, t == ((XfwfGroupWidget)self)->xfwfGroup.selection, NULL);
              break;
           case XfwfMultipleSelection:
              XtVaSetValues(((XfwfGroupWidget)self)->composite.children[i],
                           XtNon, (((XfwfGroupWidget)self)->xfwfGroup.selection & (1L<<t)) != 0, NULL);
              break;
           }
           t++;
       }
}
static Boolean set_values ( ) [static]
static Boolean set_values ( Widget  old,
Widget  request,
Widget  self,
ArgList  args,
Cardinal *  num_args 
) [static]

Definition at line 396 of file xwGroup.c.

{
    Boolean need_redraw = False;

    if (((XfwfGroupWidget)old)->xfwfGroup.label != ((XfwfGroupWidget)self)->xfwfGroup.label) {
       XtFree(((XfwfGroupWidget)old)->xfwfGroup.label);
       ((XfwfGroupWidget)self)->xfwfGroup.label = XtNewString(((XfwfGroupWidget)self)->xfwfGroup.label);
       need_redraw = True;
    }
    if (((XfwfGroupWidget)self)->xfwfGroup.font != ((XfwfGroupWidget)old)->xfwfGroup.font) {
       make_textgc(self);
       if (((XfwfGroupWidget)self)->xfwfGroup.label != NULL) need_redraw = True;
    }
    if (((XfwfGroupWidget)old)->xfwfGroup.selection != ((XfwfGroupWidget)self)->xfwfGroup.selection
       || ((XfwfGroupWidget)old)->xfwfGroup.selectionStyle != ((XfwfGroupWidget)self)->xfwfGroup.selectionStyle) {
       if (((XfwfGroupWidget)self)->xfwfGroup.selectionStyle == XfwfOneSelection && ((XfwfGroupWidget)self)->xfwfGroup.selection == -1L)
           ((XfwfGroupWidget)self)->xfwfGroup.selection = 0;
       set_toggles(self);
    }

    return need_redraw;
}

Here is the call graph for this function:


Variable Documentation

XtResource resources[] [static]
Initial value:
 {
{XtNlabel,XtCLabel,XtRString,sizeof(((XfwfGroupRec*)NULL)->xfwfGroup.label),XtOffsetOf(XfwfGroupRec,xfwfGroup.label),XtRImmediate,(XtPointer)NULL },
{XtNfont,XtCFont,XtRFontStruct,sizeof(((XfwfGroupRec*)NULL)->xfwfGroup.font),XtOffsetOf(XfwfGroupRec,xfwfGroup.font),XtRString,(XtPointer)XtDefaultFont },
{XtNforeground,XtCForeground,XtRPixel,sizeof(((XfwfGroupRec*)NULL)->xfwfGroup.foreground),XtOffsetOf(XfwfGroupRec,xfwfGroup.foreground),XtRString,(XtPointer)XtDefaultForeground },
{XtNselectionStyle,XtCSelectionStyle,XtRSelectionType,sizeof(((XfwfGroupRec*)NULL)->xfwfGroup.selectionStyle),XtOffsetOf(XfwfGroupRec,xfwfGroup.selectionStyle),XtRImmediate,(XtPointer)XfwfSingleSelection },
{XtNselection,XtCSelection,XtRLong,sizeof(((XfwfGroupRec*)NULL)->xfwfGroup.selection),XtOffsetOf(XfwfGroupRec,xfwfGroup.selection),XtRImmediate,(XtPointer)0 },
{XtNactivate,XtCActivate,XtRCallback,sizeof(((XfwfGroupRec*)NULL)->xfwfGroup.activate),XtOffsetOf(XfwfGroupRec,xfwfGroup.activate),XtRImmediate,(XtPointer)NULL },
{XtNframeType,XtCFrameType,XtRFrameType,sizeof(((XfwfGroupRec*)NULL)->xfwfFrame.frameType),XtOffsetOf(XfwfGroupRec,xfwfFrame.frameType),XtRImmediate,(XtPointer)XfwfChiseled },
{XtNinnerOffset,XtCInnerOffset,XtRDimension,sizeof(((XfwfGroupRec*)NULL)->xfwfFrame.innerOffset),XtOffsetOf(XfwfGroupRec,xfwfFrame.innerOffset),XtRImmediate,(XtPointer)0 },
}

Definition at line 253 of file xwGroup.c.

Definition at line 264 of file xwGroup.c.

WidgetClass xfwfGroupWidgetClass = (WidgetClass) &xfwfGroupClassRec

Definition at line 335 of file xwGroup.c.