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

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

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

  1 /**@(#)
  2 **/
  3 #include <stdio.h>              /* required by xview */
  4 #include <stdio.h>
  5 #include <math.h>
  6 #include <tina/sys.h>
  7 #include <tina/math.h>
  8 #include <tina/tw.h>
  9 #include <tina/tv.h>
 10 #include <tina/tvfuncs.h>
 11 #include <tina/tv_screen.h>
 12 #include <xview/xview.h>
 13 #include <xview/frame.h>
 14 #include <xview/panel.h>
 15 #include <xview/textsw.h>
 16 #include <xview/font.h>
 17 #include <xview/canvas.h>
 18 #include <xview/cms.h>
 19 #include <xview/xv_xrect.h>
 20 #include <xview/openmenu.h>
 21 #include <tina/Xvfuncs.h>
 22 #include <tina/X11funcs.h>
 23 
 24 
 25 static void menu_call(Tw_callback * twc)
 26 {
 27     (*twc->func) (twc->data1);
 28 }
 29 
 30 static void menu_cmnd(Tw_callback * twc)
 31 {
 32     (*twc->func) (twc->data1);
 33 }
 34 
 35 static void menu_prnt(FILE * fp, Tw_callback * twc)
 36 {
 37     (void) fprintf(fp, "%s\n", twc->name);
 38 }
 39 
 40 void    tw_submenu_add(char *menubarname, char *name, va_list * ptr)
 41 {
 42     Tw_callback **twc;
 43     va_list va;
 44     Panel_item button;
 45     Bool    tw_get_newrow();
 46     Panel   panel, tw_get_panel();
 47     Frame   tool, tw_get_tool();
 48     Menu    menu;
 49     int     i, n;
 50     char   *menuname = tw_extend_fullname(menubarname, name);
 51 
 52     va = *ptr;
 53 
 54     /* count no of menu items and allocate callbacks */
 55 
 56     for (n = 0; va_arg(*ptr, char *) !=NULL; n++)
 57     {
 58         va_arg(*ptr, void *);
 59         va_arg(*ptr, void *);
 60     }
 61 
 62     /* allocate callbacks for each menu item */
 63     twc = (Tw_callback **) ralloc((unsigned) n * sizeof(Tw_callback *));
 64 
 65     panel = tw_get_panel();
 66     tool = tw_get_tool();
 67 
 68     /* add button to call menu */
 69 
 70     menu = xv_create((int)NULL, MENU_CHOICE_MENU, NULL);
 71     button = xv_create(panel, PANEL_BUTTON,
 72                        PANEL_LABEL_STRING, name,
 73                        PANEL_ITEM_MENU, menu,
 74                        NULL);
 75 
 76     for (i = 0; i < n; i++)
 77     {
 78         Menu_item mi;
 79         char   *item_name = va_arg(va, char *);
 80         void    (*func) () = (void (*) ()) va_arg(va, void *);
 81         void   *data = va_arg(va, void *);
 82         char   *fullname;
 83 
 84         fullname = tw_extend_fullname(menubarname, item_name);
 85 
 86         /** read name off arglist **/
 87         mi = (Menu_item) xv_create((int)NULL, MENUITEM,
 88                                    MENU_STRING, item_name,
 89                                    MENU_VALUE, i,
 90                                    MENU_NOTIFY_PROC, tw_menu_callback,  /* for pin up */
 91                                    NULL);
 92         xv_set(menu, MENU_APPEND_ITEM, mi, NULL);
 93 
 94         twc[i] = tw_callback_make(fullname, mi,
 95                    menu_call, menu_cmnd, menu_prnt, func, data, NULL);
 96     }
 97 
 98     xv_set(menu,
 99            MENU_GEN_PIN_WINDOW, tool, "",
100            MENU_NOTIFY_PROC, tw_menu_callback,
101            MENU_CLIENT_DATA, twc,
102            NULL);
103 
104     if (tw_get_newrow())
105     {
106         xv_set(button,
107                XV_X, xv_col(panel, 0),
108                XV_Y, xv_row(panel, tw_get_row()),
109                NULL);
110         tw_set_newrow(false);
111     }
112     rfree((void *) menuname);
113 }
114 
115 #ifndef ANSIFYING
116 #ifdef __STRICT_ANSI__
117 
118 void    tw_menubar(char *name,...)
119 {
120     va_list ap;
121     char   *menubarname;
122     Panel   panel = tw_get_panel();
123     int     gap;
124 
125     va_start(ap, name);
126 
127     if (name != NULL)
128         (void) tw_label(name);
129     menubarname = tw_extend_fullname(tw_get_toolname(), name);
130 
131     gap = (int) xv_get(panel, PANEL_ITEM_X_GAP);
132     xv_set(panel, PANEL_ITEM_X_GAP, 2, NULL);
133 
134     while ((name = va_arg(ap, char *)) != NULL)
135         tw_submenu_add(menubarname, name, &ap);
136     va_end(ap);
137 
138     xv_set(panel, PANEL_ITEM_X_GAP, gap, NULL);
139 
140     rfree((void *) menubarname);
141 }
142 
143 #else
144 
145 void    tw_menubar(va_alist) va_dcl
146 {
147     va_list ap;
148     char   *menubarname, *name;
149     Panel   panel = tw_get_panel();
150     int     gap;
151 
152     va_start(ap);
153     name = va_arg(ap, char *);
154     if (name != NULL)
155         (void) tw_label(name);
156     menubarname = tw_extend_fullname(tw_get_toolname(), name);
157 
158     gap = (int) xv_get(panel, PANEL_ITEM_X_GAP);
159     xv_set(panel, PANEL_ITEM_X_GAP, 2, NULL);
160 
161     while ((name = va_arg(ap, char *)) != NULL)
162         tw_submenu_add(menubarname, name, &ap);
163     va_end(ap);
164 
165     xv_set(panel, PANEL_ITEM_X_GAP, gap, NULL);
166 
167     rfree((void *) menubarname);
168 }
169 
170 #endif                          /* __STRICT_ANSI__ */
171 #endif                          /* ANSIFYING */
172 

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