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

Linux Cross Reference
Tina5/tina-tools/tinatool/wdgts/xm/wdgtsXm_tw_menubar.c

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

  1 /**********
  2  * 
  3  * Copyright (c) 2003, Division of Imaging Science and Biomedical Engineering,
  4  * University of Manchester, UK.  All rights reserved.
  5  * 
  6  * Redistribution and use in source and binary forms, with or without modification, 
  7  * are permitted provided that the following conditions are met:
  8  * 
  9  *   . Redistributions of source code must retain the above copyright notice, 
 10  *     this list of conditions and the following disclaimer.
 11  *    
 12  *   . Redistributions in binary form must reproduce the above copyright notice,
 13  *     this list of conditions and the following disclaimer in the documentation 
 14  *     and/or other materials provided with the distribution.
 15  * 
 16  *   . Neither the name of the University of Manchester nor the names of its
 17  *     contributors may be used to endorse or promote products derived from this 
 18  *     software without specific prior written permission.
 19  * 
 20  * 
 21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
 22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
 23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
 24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
 25  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
 26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
 27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
 29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
 30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
 31  * POSSIBILITY OF SUCH DAMAGE.
 32  *
 33  **********
 34  * 
 35  * Program :    TINA
 36  * File    :  $Source: /home/tina/cvs/tina-tools/tinatool/wdgts/xm/wdgtsXm_tw_menubar.c,v $
 37  * Date    :  $Date: 2007/02/15 01:55:50 $
 38  * Version :  $Revision: 1.3 $
 39  * CVS Id  :  $Id: wdgtsXm_tw_menubar.c,v 1.3 2007/02/15 01:55:50 paul Exp $
 40  *
 41  * Author  :  Legacy TINA
 42  *
 43  * Notes :
 44  *
 45  *********
 46 */
 47 
 48 #include "wdgtsXm_tw_menubar.h"
 49 
 50 #if HAVE_CONFIG_H
 51 #   include <config.h>
 52 #endif
 53 
 54 #include <stdio.h>
 55 
 56 #if !HAVE_STDARG_H
 57   error Motif demands stdarg.h
 58 #else
 59   #include <stdarg.h>
 60 #endif /* !HAVE_STDARG_H */
 61 
 62 #include <Xm/Xm.h>
 63 #include <Xm/CascadeB.h>
 64 #include <Xm/PushB.h>
 65 #include <Xm/RowColumn.h>
 66         
 67 #include <tina/sys/sysDef.h>
 68 #include <tina/sys/sysPro.h>
 69 #include <tinatool/wdgts/xm/wdgts_XmDef.h>
 70 #include <tinatool/wdgts/xm/wdgtsXm_tw_tool.h>
 71 #include <tinatool/wdgts/xm/wdgtsXm_tw_command.h>
 72 #include <tinatool/wdgts/xm/wdgtsXm_tw_label.h>
 73 
 74 static void button_call(Tw_callback * twc)
 75 {
 76     (*twc->func) (twc->data1);
 77 }
 78 
 79 static void button_cmnd(Tw_callback * twc)
 80 {
 81     (*twc->func) (twc->data1);
 82 }
 83 
 84 static void button_prnt(FILE * fp, Tw_callback * twc)
 85 {
 86     (void) fprintf(fp, "%s\n", twc->name);
 87 }
 88 
 89 /* UNFINISHED */
 90 static void tw_submenu_add(Widget menubar, char *menubarname, char *name,
 91                                    double *width, va_list * ptr)
 92 {
 93     Widget  submenu;
 94     XmString xmstring;
 95     int     nargs;
 96     Arg     wargs[2];
 97     char   *menuname;
 98 
 99     menuname = tw_extend_fullname(menubarname, name);
100 
101     submenu = XmCreatePulldownMenu(menubar, "twmenubar", NULL, 0);
102     nargs = 0;
103     xmstring = XmStringCreate(name, XmSTRING_DEFAULT_CHARSET);
104     XtSetArg(wargs[nargs], XmNlabelString, xmstring);
105     nargs++;
106     XtSetArg(wargs[nargs], XmNsubMenuId, submenu);
107     nargs++;
108     XtCreateManagedWidget("twmenubar",
109                           xmCascadeButtonWidgetClass,
110                           menubar, wargs, nargs);
111     XmStringFree(xmstring);
112 
113     *width += strlen(name) + 2.0;
114 
115     while ((name = va_arg(*ptr, char *)) != NULL)
116     {
117         void    (*func) () = (void (*) ()) va_arg(*ptr, void *);
118         void   *data = va_arg(*ptr, void *);
119         Tw_callback *twc;
120         Widget  button;
121         char   *fullname;
122 
123         fullname = tw_extend_fullname(menuname, name);
124 
125         nargs = 0;
126         xmstring = XmStringCreate(name, XmSTRING_DEFAULT_CHARSET);
127         XtSetArg(wargs[nargs], XmNlabelString, xmstring);
128         nargs++;
129         button = XtCreateManagedWidget("twmenubutton", xmPushButtonWidgetClass,
130                                        submenu, wargs, nargs);
131         XmStringFree(xmstring);
132         twc = tw_callback_make(fullname, tw_get_tool(), button,
133              button_call, button_cmnd, button_prnt, func, data, NULL);
134 
135         /* warning: argument #3 is incompatible with prototype:
136         prototype: pointer to function(pointer to struct _WidgetRec {}, pointer to void, pointer to void) returning void : "/usr/include/X11/Intrinsic.h", line 1528
137         argument : pointer to void */
138         XtAddCallback(button, XmNactivateCallback, (void *) tw_callback, (XtPointer) twc);
139     }
140 
141     rfree((void *) menuname);
142 }
143 
144 void    tw_menubar(char *name,...)
145 {
146     va_list ap;
147     Widget  menubar, panel = tw_get_panel();
148     char   *menubarname;
149     double  width = 0.0;
150     int     w, h;
151 
152     va_start(ap, name);
153 
154     if (name != NULL)
155         (void) tw_label(name);
156 
157     menubarname = tw_extend_fullname(tw_get_toolname(), name);
158 
159     menubar = XmCreateMenuBar(panel, "twmenubar", NULL, 0);
160     XtManageChild(menubar);
161 
162     while ((name = va_arg(ap, char *)) != NULL)
163         tw_submenu_add(menubar, menubarname, name, &width, &ap);
164     va_end(ap);
165 
166     w = tw_charwidth(width);
167     h = tw_charheight(3.0);
168     tw_set_entry(menubar, w, h);
169 
170     rfree((void *) menubarname);
171 }
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.