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

Linux Cross Reference
Tina5/tina-tools/tinatool/wdgts/xv/wdgtsXv_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/xv/wdgtsXv_tw_iglobal.c,v $
 37  * Date    :  $Date: 2003/10/01 16:02:48 $
 38  * Version :  $Revision: 1.2 $
 39  * CVS Id  :  $Id: wdgtsXv_tw_iglobal.c,v 1.2 2003/10/01 16:02:48 tony Exp $
 40  *
 41  * Author  :  Legacy TINA
 42  *
 43  * Notes :
 44  *
 45  *********
 46 */
 47 
 48 #include "wdgtsXv_tw_iglobal.h"
 49 
 50 #if HAVE_CONFIG_H
 51 #   include <config.h>
 52 #endif
 53 
 54 #include <stdio.h>
 55 
 56 #include <xview/panel.h>
 57 #include <xview/generic.h>
 58 
 59 #include <tina/sys/sysDef.h>
 60 #include <tinatool/wdgts/xv/wdgts_XvDef.h>
 61 #include <tinatool/wdgts/xv/wdgtsXv_tw_tool.h>
 62 #include <tinatool/wdgts/xv/wdgtsXv_tw_command.h>
 63 
 64 static void iglobal_call(Tw_callback * twc)
 65 {
 66     int     x, *ptr = (int *) twc->data1;
 67     char   *string = (char *) xv_get(twc->window, PANEL_VALUE);
 68 
 69     if (sscanf(string, "%d", &x) == 1)
 70         *ptr = x;
 71 }
 72 
 73 static void iglobal_cmnd(Tw_callback * twc, char *args)
 74 {
 75     int    *ptr = (int *) twc->data1;
 76     char    string[64];
 77 
 78     (void) sscanf(args, "%*s %d", ptr);
 79     (void) sscanf(args, "%*s %s", string);
 80     xv_set(twc->window, PANEL_VALUE, string, NULL);
 81 }
 82 
 83 static void iglobal_prnt(FILE * fp, Tw_callback * twc)
 84 {
 85     int     x = *(int *) twc->data1;
 86 
 87     (void) fprintf(fp, "%s %d\n", twc->name, x);
 88 }
 89 
 90 Tw_callback *tw_iglobal(char *name, int *ptr, int nchars)
 91 {
 92     Panel_item text;
 93     Panel   panel = tw_get_panel();
 94     Bool    newrow = tw_get_newrow();
 95     int     row;
 96     char    string[32];
 97     int     value;
 98     Tw_callback *twc;
 99     char   *fullname = tw_extend_fullname(tw_get_toolname(), name);
100 
101     value = *ptr;
102     (void) sprintf(string, "%d", value);
103 
104     text = xv_create(panel, PANEL_TEXT,
105                      PANEL_LABEL_STRING, name,
106                      PANEL_VALUE_DISPLAY_LENGTH, nchars,
107                      PANEL_VALUE, string,
108                      PANEL_NOTIFY_LEVEL, PANEL_ALL,
109                      NULL);
110 
111     twc = tw_callback_make(fullname, text,
112                            iglobal_call, iglobal_cmnd, iglobal_prnt, (void (*) ()) NULL, (void *) ptr, NULL);
113 
114     xv_set(text,
115            PANEL_NOTIFY_PROC, tw_text_callback,
116            PANEL_CLIENT_DATA, twc,
117            NULL);
118 
119     if (newrow)
120     {
121         row = tw_get_row();
122         xv_set(text,
123                XV_X, xv_col(panel, 0),
124                XV_Y, xv_row(panel, row),
125                NULL);
126         tw_set_newrow(false);
127     }
128     return (twc);
129 }
130 
131 /* Update an integer input field (pointed to by twc) to the value of
132  * the variable in the program. */
133 void    tw_iglobal_reset(Tw_callback * twc)
134 {
135     int    *val;
136     char    string[64];
137 
138     if (twc == NULL)
139         return;
140 
141     val = (int *) twc->data1;
142     (void) sprintf(string, "%d", *val);
143     xv_set(twc->window, PANEL_VALUE, string, NULL);
144 }
145 

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