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

Linux Cross Reference
Tina5/tina-tools/tinatool/wdgts/xv/wdgtsXv_tw_button.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_button.c,v $
 37  * Date    :  $Date: 2003/10/01 16:02:48 $
 38  * Version :  $Revision: 1.2 $
 39  * CVS Id  :  $Id: wdgtsXv_tw_button.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_button.h"
 49 
 50 #if HAVE_CONFIG_H
 51 #   include <config.h>
 52 #endif
 53 
 54 #include <stdio.h>
 55 
 56 #include <xview/xview.h>
 57 #include <xview/frame.h>
 58 #include <xview/panel.h>
 59 #include <xview/textsw.h>
 60 #include <xview/font.h>
 61 #include <xview/canvas.h>
 62 #include <xview/cms.h>
 63 #include <xview/xv_xrect.h>
 64 #include <xview/openmenu.h>
 65 
 66 
 67 #include <tina/sys/sysDef.h>
 68 #include <tina/math/mathDef.h>
 69 
 70 #include <tinatool/wdgts/xv/wdgts_XvDef.h>
 71 #include <tinatool/wdgts/xv/wdgtsXv_tw_tool.h>
 72 #include <tinatool/wdgts/xv/wdgtsXv_tw_command.h>
 73 
 74 #include <tinatool/gphx/gphxDef.h>
 75 #include <tinatool/gphx/gphxPro.h>
 76 
 77 static void button_call(Tw_callback * twc)
 78 {
 79     tw_set_tool((Frame) twc->data2);
 80     (*twc->func) (twc->data1);
 81 }
 82 
 83 static void button_cmnd(Tw_callback * twc)
 84 {
 85     tw_set_tool((Frame) twc->data2);
 86     (*twc->func) (twc->data1);
 87 }
 88 
 89 static void button_prnt(FILE * fp, Tw_callback * twc)
 90 {
 91     (void) fprintf(fp, "%s\n", twc->name);
 92 }
 93 
 94 void    tw_button(char *name, void (*func) ( /* ??? */ ), void * data)
 95 {
 96     int     row;
 97     Tw_callback *twc;
 98     Panel_item button;
 99     Frame   tool = tw_get_tool();
100     Panel   panel = tw_get_panel();
101     Bool    newrow = tw_get_newrow();
102     char   *fullname = tw_extend_fullname(tw_get_toolname(), name);
103 
104     button = (Panel_item) xv_create(panel, PANEL_BUTTON,
105                                     PANEL_LABEL_STRING, name,
106                                     NULL);
107     twc = tw_callback_make(fullname, button,
108                            button_call, button_cmnd, button_prnt, func, data, (void *) tool);
109     xv_set(button,
110            PANEL_NOTIFY_PROC, tw_button_callback,
111            PANEL_CLIENT_DATA, twc,
112            NULL);
113 
114     if (newrow)
115     {
116         row = tw_get_row();
117         xv_set(button,
118                XV_X, xv_col(panel, 0),
119                XV_Y, xv_row(panel, row),
120                NULL);
121         tw_set_newrow(false);
122     }
123 }
124 
125 Panel_item tw_icon_button(char *name, int w, int h,short *image_bits,
126                        void (*func) ( /* ??? */ ), int data)
127 
128 {
129     int     row;
130     Tw_callback *twc;
131     Panel_item button;
132     Frame   tool = tw_get_tool();
133     Panel   panel = tw_get_panel();
134     Server_image image;
135     Bool    newrow = tw_get_newrow();
136     char   *fullname = tw_extend_fullname(tw_get_toolname(), name);
137 
138     image=(Server_image)xv_create((Frame)NULL,SERVER_IMAGE,
139                                   XV_WIDTH, w,
140                                   XV_HEIGHT, h,
141                                   SERVER_IMAGE_BITS,image_bits,
142                                   NULL);
143     button = (Panel_item) xv_create(panel, PANEL_BUTTON,
144                                     PANEL_LABEL_IMAGE, image,
145                                     NULL);
146     twc = tw_callback_make(fullname, button,
147                            button_call, button_cmnd, button_prnt, func, (void *) data, (void *) tool);
148     xv_set(button,
149            PANEL_NOTIFY_PROC, tw_button_callback,
150            PANEL_CLIENT_DATA, twc,
151            NULL);
152 
153     if (newrow)
154     {
155         row = tw_get_row();
156         xv_set(button,
157                XV_X, xv_col(panel, 0),
158                XV_Y, xv_row(panel, row),
159                NULL);
160         tw_set_newrow(false);
161     }
162     return button;
163 }
164 void tw_button_reset_image(Panel_item button,int w, int h,
165                          short *image_bits)
166 {
167   Server_image image,old_image;
168   image=(Server_image)xv_create((Frame)NULL,SERVER_IMAGE,
169                                   XV_WIDTH, w,
170                                   XV_HEIGHT, h,
171                                   SERVER_IMAGE_BITS,image_bits,
172                                   NULL);
173   old_image=xv_get(button,PANEL_LABEL_IMAGE,NULL);
174   xv_set(button,PANEL_LABEL_IMAGE,image,NULL);
175   xv_destroy_safe(old_image);
176 }
177 #ifdef INTERRUPT_BUTTON
178 static void interrupt_calc_proc(void)
179 {
180     format("Interrupted!\n");
181 }
182 
183 void    tw_interrupt_button(void)
184 {
185     (void) printf("tw_interrupt_button: NOT implemented in Xview.\n");
186     /****
187         int             row;
188         Tw_callback    *twc;
189         Panel_item      interrupt_button;
190         Frame           tool = tw_get_tool();
191         Panel           panel = tw_get_panel();
192         Bool            newrow = tw_get_newrow();
193         char            name[] = "Interrupt";
194 
195 
196         interrupt_button = (Panel_item) xv_create(panel, PANEL_BUTTON,
197             PANEL_LABEL_STRING, name,
198             NULL);
199 
200         xv_set(interrupt_button,
201             PANEL_NOTIFY_PROC, interrupt_calc_proc,
202             NULL);
203 
204         if (newrow)
205         {
206             row = tw_get_row();
207             xv_set(interrupt_button,
208                 XV_X, xv_col(panel, 0),
209                 XV_Y, xv_row(panel, row),
210                 NULL);
211             tw_set_newrow(false);
212         }
213         interrupt_button_set(//display of interrupt_button//,
214     //window of interrupt_button. NB in current Xview, buttons are not windows//);
215     ****/
216 }
217 
218 /* NB can't handle interrupts in Xview */
219 void    interrupt_button_data_get(Display ** display, Window * window)
220 {
221     *display = NULL;
222     *window = None;
223 }
224 #endif /*INTERRUPT_BUTTON*/
225 

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