~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Tina4/src/Xm/tw_toggle.c

Version: ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /**@(#)
  2 **/
  3 #include <stdio.h>
  4 #include <tina/sys.h>
  5 #include <tina/math.h>
  6 #include <tina/tv.h>
  7 #include  <tina/mtw.h>
  8 #include  <tina/tv_screen.h>
  9 #include <tina/Xmfuncs.h>
 10 
 11 static void toggle_call(Tw_callback * twc)
 12 {
 13     int     set = (int) twc->data1;
 14 
 15     set = !set;
 16     (*twc->func) (set);
 17     twc->data1 = (void *) set;
 18 }
 19 
 20 static void toggle_cmnd(Tw_callback * twc, char *args)
 21 {
 22     int     set;
 23     int     nargs;
 24     Arg     wargs[1];
 25 
 26     (void) sscanf(args, "%*s %d", &set);
 27     (*twc->func) (set);
 28     twc->data1 = (void *) set;
 29 
 30     nargs = 0;
 31     XtSetArg(wargs[nargs], XmNset, set);
 32     nargs++;
 33     XtSetValues(twc->widget, wargs, nargs);
 34 }
 35 
 36 static void toggle_prnt(FILE * fp, Tw_callback * twc)
 37 {
 38     (void) fprintf(fp, "%s %d\n", twc->name, twc->data1);
 39 }
 40 
 41 Widget  tw_toggle(char *name, void (*func) ( /* ??? */ ), Bool set)
 42 {
 43     Widget  panel = tw_get_panel(), toggle;
 44     XmString xmstring;
 45     int     nargs;
 46     Arg     wargs[2];
 47     int     w, h;
 48     Tw_callback *twc;
 49     char   *fullname = tw_extend_fullname(tw_get_toolname(), name);
 50 
 51     nargs = 0;
 52     xmstring = XmStringCreate(name, XmSTRING_DEFAULT_CHARSET);
 53     XtSetArg(wargs[nargs], XmNlabelString, xmstring);
 54     nargs++;
 55     XtSetArg(wargs[nargs], XmNset, set);
 56     nargs++;
 57     toggle = XtCreateManagedWidget("twtoggle", xmToggleButtonWidgetClass,
 58                                    panel, wargs, nargs);
 59     XmStringFree(xmstring);
 60 
 61     twc = tw_callback_make(fullname, tw_get_tool(), toggle,
 62      toggle_call, toggle_cmnd, toggle_prnt, func, (void *) set, NULL);
 63     XtAddCallback(toggle, XmNvalueChangedCallback, (void *) tw_callback, (XtPointer) twc);
 64 
 65     w = tw_charwidth(5.0 + strlen(name));
 66     h = tw_charheight(2.0);
 67     tw_set_entry(toggle, w, h);
 68 
 69     func(set);
 70 
 71     return (toggle);
 72 }
 73 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.