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

Linux Cross Reference
Tina5/tina-tools/tinatool/wdgts/xm/wdgtsXm_tw_toggle.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_toggle.c,v $
 37  * Date    :  $Date: 2007/02/15 01:55:50 $
 38  * Version :  $Revision: 1.3 $
 39  * CVS Id  :  $Id: wdgtsXm_tw_toggle.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_toggle.h"
 49 
 50 #if HAVE_CONFIG_H
 51 #   include <config.h>
 52 #endif
 53 
 54 #include <stdio.h>
 55 
 56 #include <Xm/Xm.h>
 57 #include <Xm/ToggleB.h>
 58 
 59 #include <tina/sys/sysDef.h>
 60 #include <tinatool/wdgts/xm/wdgts_XmDef.h>
 61 #include <tinatool/wdgts/xm/wdgtsXm_tw_tool.h>
 62 #include <tinatool/wdgts/xm/wdgtsXm_tw_command.h>
 63 
 64 
 65 static void toggle_call(Tw_callback * twc)
 66 {
 67     int     set = (int) twc->data1;
 68 
 69     set = !set;
 70     (*twc->func) (set);
 71     twc->data1 = (void *) set;
 72 }
 73 
 74 static void toggle_cmnd(Tw_callback * twc, char *args)
 75 {
 76     int     set;
 77     int     nargs;
 78     Arg     wargs[1];
 79 
 80     (void) sscanf(args, "%*s %d", &set);
 81     (*twc->func) (set);
 82     twc->data1 = (void *) set;
 83 
 84     nargs = 0;
 85     XtSetArg(wargs[nargs], XmNset, set);
 86     nargs++;
 87     XtSetValues(twc->widget, wargs, nargs);
 88 }
 89 
 90 static void toggle_prnt(FILE * fp, Tw_callback * twc)
 91 {
 92     (void) fprintf(fp, "%s %d\n", twc->name, twc->data1);
 93 }
 94 
 95 Widget  tw_toggle(char *name, void (*func) ( /* ??? */ ), Bool set)
 96 {
 97     Widget  panel = tw_get_panel(), toggle;
 98     XmString xmstring;
 99     int     nargs;
100     Arg     wargs[2];
101     int     w, h;
102     Tw_callback *twc;
103     char   *fullname = tw_extend_fullname(tw_get_toolname(), name);
104 
105     nargs = 0;
106     xmstring = XmStringCreate(name, XmSTRING_DEFAULT_CHARSET);
107     XtSetArg(wargs[nargs], XmNlabelString, xmstring);
108     nargs++;
109     XtSetArg(wargs[nargs], XmNset, set);
110     nargs++;
111     toggle = XtCreateManagedWidget("twtoggle", xmToggleButtonWidgetClass,
112                                    panel, wargs, nargs);
113     XmStringFree(xmstring);
114 
115     twc = tw_callback_make(fullname, tw_get_tool(), toggle,
116      toggle_call, toggle_cmnd, toggle_prnt, func, (void *) set, NULL);
117     /* warning: argument #3 is incompatible with prototype:
118         prototype: pointer to function(pointer to struct _WidgetRec {}, pointer to void, pointer to void) returning void : "/usr/include/X11/Intrinsic.h", line 1528
119         argument : pointer to void */
120     XtAddCallback(toggle, XmNvalueChangedCallback, (void *) tw_callback, (XtPointer) twc);
121 
122     w = tw_charwidth(5.0 + strlen(name));
123     h = tw_charheight(2.0);
124     tw_set_entry(toggle, w, h);
125 
126     func(set);
127 
128     return (toggle);
129 }
130 

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