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

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

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

  1 /**@(#)
  2 **/
  3 #include <tina/tv.h>
  4 #include  <tina/mtw.h>
  5 #include  <tina/tv_screen.h>
  6 #include <tina/Xmfuncs.h>
  7 
  8 static void button_call(Tw_callback * twc)
  9 {
 10     (*twc->func) (twc->data1);
 11 }
 12 
 13 static void button_cmnd(Tw_callback * twc)
 14 {
 15     (*twc->func) (twc->data1);
 16 }
 17 
 18 static void button_prnt(FILE * fp, Tw_callback * twc)
 19 {
 20     (void) fprintf(fp, "%s\n", twc->name);
 21 }
 22 
 23 /* UNFINISHED */
 24 static void tw_submenu_add(Widget menubar, char *menubarname, char *name,
 25                                    double *width, va_list * ptr)
 26 {
 27     Widget  submenu;
 28     XmString xmstring;
 29     int     nargs;
 30     Arg     wargs[2];
 31     char   *menuname;
 32 
 33     menuname = tw_extend_fullname(menubarname, name);
 34 
 35     submenu = XmCreatePulldownMenu(menubar, "twmenubar", NULL, 0);
 36     nargs = 0;
 37     xmstring = XmStringCreate(name, XmSTRING_DEFAULT_CHARSET);
 38     XtSetArg(wargs[nargs], XmNlabelString, xmstring);
 39     nargs++;
 40     XtSetArg(wargs[nargs], XmNsubMenuId, submenu);
 41     nargs++;
 42     XtCreateManagedWidget("twmenubar",
 43                           xmCascadeButtonWidgetClass,
 44                           menubar, wargs, nargs);
 45     XmStringFree(xmstring);
 46 
 47     *width += strlen(name) + 2.0;
 48 
 49     while ((name = va_arg(*ptr, char *)) != NULL)
 50     {
 51         void    (*func) () = (void (*) ()) va_arg(*ptr, void *);
 52         void   *data = va_arg(*ptr, void *);
 53         Tw_callback *twc;
 54         Widget  button;
 55         char   *fullname;
 56 
 57         fullname = tw_extend_fullname(menuname, name);
 58 
 59         nargs = 0;
 60         xmstring = XmStringCreate(name, XmSTRING_DEFAULT_CHARSET);
 61         XtSetArg(wargs[nargs], XmNlabelString, xmstring);
 62         nargs++;
 63         button = XtCreateManagedWidget("twmenubutton", xmPushButtonWidgetClass,
 64                                        submenu, wargs, nargs);
 65         XmStringFree(xmstring);
 66         twc = tw_callback_make(fullname, tw_get_tool(), button,
 67              button_call, button_cmnd, button_prnt, func, data, NULL);
 68 
 69         XtAddCallback(button, XmNactivateCallback, (void *) tw_callback, (XtPointer) twc);
 70     }
 71 
 72     rfree((void *) menuname);
 73 }
 74 
 75 void    tw_menubar(char *name,...)
 76 {
 77     va_list ap;
 78     Widget  menubar, panel = tw_get_panel();
 79     char   *menubarname;
 80     double  width = 0.0;
 81     int     w, h;
 82 
 83     va_start(ap, name);
 84 
 85     if (name != NULL)
 86         (void) tw_label(name);
 87 
 88     menubarname = tw_extend_fullname(tw_get_toolname(), name);
 89 
 90     menubar = XmCreateMenuBar(panel, "twmenubar", NULL, 0);
 91     XtManageChild(menubar);
 92 
 93     while ((name = va_arg(ap, char *)) != NULL)
 94         tw_submenu_add(menubar, menubarname, name, &width, &ap);
 95     va_end(ap);
 96 
 97     w = tw_charwidth(width);
 98     h = tw_charheight(3.0);
 99     tw_set_entry(menubar, w, h);
100 
101     rfree((void *) menubarname);
102 }
103 

~ [ 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.