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

Linux Cross Reference
Tina5/tina-tools/tinatool/wdgts/xm/wdgtsXm_tw_iglobal.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_iglobal.c,v $
 37  * Date    :  $Date: 2007/02/15 01:55:50 $
 38  * Version :  $Revision: 1.3 $
 39  * CVS Id  :  $Id: wdgtsXm_tw_iglobal.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_iglobal.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/Label.h>
 58 #include <Xm/Text.h>
 59 
 60 #include <tina/sys/sysDef.h>
 61 #include <tinatool/wdgts/xm/wdgts_XmDef.h>
 62 #include <tinatool/wdgts/xm/wdgtsXm_tw_tool.h>
 63 #include <tinatool/wdgts/xm/wdgtsXm_tw_command.h>
 64 #include <tinatool/wdgts/xm/wdgtsXm_tw_textsw.h>
 65 
 66 static void iglobal_call(Tw_callback * twc)
 67 {
 68     int     x, *ptr = (int *) twc->data1;
 69     char   *string = XmTextGetString(twc->widget);
 70 
 71     if (sscanf(string, "%d", &x) == 1)
 72         *ptr = x;
 73     XtFree(string);
 74 }
 75 
 76 static void iglobal_cmnd(Tw_callback * twc, char *args)
 77 {
 78     int    *ptr = (int *) twc->data1;
 79     char    string[64];
 80 
 81     (void) sscanf(args, "%*s %d", ptr);
 82     (void) sscanf(args, "%*s %s", string);
 83     tw_text_set(twc->widget, string);
 84 }
 85 
 86 static void iglobal_prnt(FILE * fp, Tw_callback * twc)
 87 {
 88     int     i = *(int *) twc->data1;
 89 
 90     (void) fprintf(fp, "%s %d\n", twc->name, i);
 91 }
 92 
 93 void *tw_iglobal(char *name, int *ptr, int nchars)
 94 {
 95     char    string[64];
 96     XmString xmstring;
 97     int     nargs;
 98     Arg     wargs[1];
 99     int     w, h;
100     Tw_callback *twc;
101     Widget  panel = tw_get_panel(), label, text;
102     char   *fullname = tw_extend_fullname(tw_get_toolname(), name);
103 
104     xmstring = XmStringCreate(name, XmSTRING_DEFAULT_CHARSET);
105     nargs = 0;
106     XtSetArg(wargs[nargs], XmNlabelString, xmstring);
107     nargs++;
108     label = XtCreateManagedWidget("twlabel", xmLabelWidgetClass,
109                                   panel, wargs, nargs);
110     XmStringFree(xmstring);
111 
112     w = tw_charwidth(2.0 + strlen(name));
113     h = tw_charheight(1.0);
114     tw_set_entry(label, w, h);
115 
116     nargs = 0;
117     XtSetArg(wargs[nargs], XmNcolumns, nchars);
118     nargs++;
119     text = XtCreateManagedWidget("twtext", xmTextWidgetClass,
120                                  panel, wargs, nargs);
121     (void) sprintf(string, "%d", *ptr);
122     XmTextSetString(text, string);
123 
124     twc = tw_callback_make(fullname, tw_get_tool(), text,
125          iglobal_call, iglobal_cmnd, iglobal_prnt, (void (*) ()) NULL,
126                            (void *) ptr, NULL);
127     /* warning: argument #3 is incompatible with prototype:
128         prototype: pointer to function(pointer to struct _WidgetRec {}, pointer to void, pointer to void) returning void : "/usr/include/X11/Intrinsic.h", line 1528
129         argument : pointer to void */
130     XtAddCallback(text, XmNvalueChangedCallback, (void *) tw_callback, (XtPointer) twc);
131 
132     w = tw_charwidth(4.0 + nchars);
133     h = tw_charheight(2.5);
134     tw_set_entry(text, w, h);
135     return (twc);
136 }
137 
138 void    tw_iglobal_reset(void *ptwc)
139 {
140     Tw_callback *twc;
141     int x;
142     char string[64];
143 
144     if(!ptwc)
145       return;
146     
147     twc = ptwc;
148     x = *(int *) twc->data1;
149     
150     sprintf(string, "%d", x);
151     XmTextSetString(twc->widget, string);
152 }
153 

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