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

Linux Cross Reference
Tina5/tina-tools/tinatool/wdgts/xv/wdgtsXv_tw_check.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_check.c,v $
 37  * Date    :  $Date: 2009/03/25 13:37:03 $
 38  * Version :  $Revision: 1.3 $
 39  * CVS Id  :  $Id: wdgtsXv_tw_check.c,v 1.3 2009/03/25 13:37:03 paul Exp $
 40  *
 41  * Author  :  Legacy TINA
 42  *
 43  * Notes :
 44  *
 45  *********
 46 */
 47 
 48 #include "wdgtsXv_tw_check.h"
 49 
 50 #if HAVE_CONFIG_H
 51 #   include <config.h>
 52 #endif
 53 
 54 #include <stdio.h>
 55 #include <math.h>
 56 
 57 #if !HAVE_STDARG_H
 58   error Xview demands stdarg.h
 59 #else
 60   #include <stdarg.h>
 61 #endif /* !HAVE_STDARG_H */
 62 
 63 #include <xview/panel.h>
 64 #include <xview/window.h>
 65 #include <tina/sys/sysDef.h>
 66 #include <tinatool/wdgts/xv/wdgts_XvDef.h>
 67 #include <tinatool/wdgts/xv/wdgtsXv_tw_tool.h>
 68 #include <tinatool/wdgts/xv/wdgtsXv_tw_command.h>
 69 
 70 
 71 void tw_check_list_style_select(int style)
 72 {
 73   /* Required for GTK: not used in other widget sets */
 74 }
 75 
 76 
 77 static void check_call(Tw_callback * twc)
 78 {
 79     int     value = (int) twc->data1;
 80 
 81     (*twc->func) (value);
 82 }
 83 
 84 static void check_cmnd(Tw_callback * twc, char *args)
 85 {
 86     int     value;
 87 
 88     (void) sscanf(args, "%*s %d", &value);
 89     twc->data1 = (void *) value;
 90     (*twc->func) (value);
 91 
 92     xv_set(twc->window, PANEL_VALUE, value, NULL);
 93 }
 94 
 95 static void check_prnt(FILE * fp, Tw_callback * twc)
 96 {
 97     int     value = (int) twc->data1;
 98 
 99     (void) fprintf(fp, "%s %d %d\n", twc->name, value);
100 }
101 
102 
103 void tw_check(char *name,...)
104 {
105                 va_list ap;
106     void    (*func) ();
107     int     value;
108     char   *names[10];
109     Panel_item check;
110     Panel   panel = tw_get_panel();
111     Bool    newrow = tw_get_newrow();
112     int     i, row;
113     Tw_callback *twc;
114     char   *fullname;
115 
116     panel = tw_get_panel();
117     newrow = tw_get_newrow();
118 
119     for (i = 0; i < 10; i++)
120         names[i] = NULL;
121 
122     va_start(ap, name);
123     func = (void (*) ()) va_arg(ap, void *);
124     value = va_arg(ap, int);
125 
126     for (i = 0; (names[i] = va_arg(ap, char *)) != NULL; i++);
127     va_end(ap);
128 
129     check = (Panel_item) xv_create(panel, PANEL_CHOICE,
130                                    PANEL_CHOOSE_ONE, FALSE,
131                                    PANEL_VALUE, value,
132                                    PANEL_LABEL_STRING, name,
133                                    PANEL_CHOICE_STRINGS,
134                      names[0], names[1], names[2], names[3], names[4],
135                names[5], names[6], names[7], names[8], names[9], NULL,
136                                    NULL);
137 
138     fullname = tw_extend_fullname(tw_get_toolname(), name);
139     twc = tw_callback_make(fullname, check,
140       check_call, check_cmnd, check_prnt, func, (void *) value, NULL);
141 
142     xv_set(check,
143            PANEL_NOTIFY_PROC, tw_panel_callback,
144            PANEL_CLIENT_DATA, twc,
145            NULL);
146 
147     if (newrow)
148     {
149         row = tw_get_row();
150         xv_set(check,
151                XV_X, xv_col(panel, 0),
152                XV_Y, xv_row(panel, row),
153                NULL);
154         tw_set_newrow(false);
155     }
156     (*func) (value);
157 }
158 
159 

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