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

Linux Cross Reference
Tina5/tina-tools/tinatool/wdgts/xv/wdgtsXv_tw_tool.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_tool.c,v $
 37  * Date    :  $Date: 2007/02/15 01:55:50 $
 38  * Version :  $Revision: 1.3 $
 39  * CVS Id  :  $Id: wdgtsXv_tw_tool.c,v 1.3 2007/02/15 01:55:50 paul Exp $
 40  *
 41  * Author  :  Legacy TINA
 42  *
 43  * Notes : Tina windows top level tool
 44  *
 45  *********
 46 */
 47 
 48 #include "wdgtsXv_tw_tool.h"
 49 
 50 #if HAVE_CONFIG_H
 51 #   include <config.h>
 52 #endif
 53 
 54 
 55 #include <stdio.h>
 56 
 57 #include <xview/window.h>
 58 #include <xview/frame.h>
 59 #include <xview/generic.h>
 60 #include <xview/panel.h>
 61 #include <xview/sun.h>
 62 #include <xview/icon.h>
 63 #include <tina/sys/sysDef.h>
 64 #include <tina/sys/sysPro.h>
 65 #include <tinatool/wdgts/xv/wdgts_XvDef.h>
 66 #include <tinatool/wdgts/xv/wdgtsXv_tw_command.h>
 67 #include <tinatool/wdgts/xv/wdgtsXv_tw_init.h>
 68 
 69 #include <setjmp.h>             /* Unused in Xview.  Used in libtinaX11.a */
 70 
 71 /* STATIC GLOBALS */
 72 static Bool newrow;
 73 static Display *active_display = NULL;
 74 static Frame tool, toptool = (int)NULL;
 75 static Panel panel;
 76 static Window active_window = (int)NULL;
 77 static Window lowest;
 78 static char *toolname;
 79 static int row;
 80 static int width;
 81 static int xpos, ypos;
 82 
 83 /* GLOBALS */
 84 jmp_buf interrupt_reentry_point;/* Unused in Xview.  Used in
 85                                  * libtinaX11.a */
 86 
 87 /* Set display & window of latest button press BEING PROCESSED (ie
 88  * whose callback has been called.)  Used by tw_callback to reset
 89  * cursor on interrupt */
 90 void    tw_active_tool_data_set(Display * display, Window window)
 91 {
 92     active_display = display;
 93     active_window = window;
 94 }
 95 
 96 /* Get display & window of latest button press BEING PROCESSED (ie
 97  * whose callback has been called.)  Used by tw_callback to reset
 98  * cursor on interrupt */
 99 void    tw_active_tool_data_get(Display ** display, Window * window)
100 /* NB pointer to pointer */
101 
102 {
103     *display = active_display;
104     *window = active_window;
105 }
106 
107 int     tw_get_width(void)
108 {
109     return (width);
110 }
111 
112 void    tw_set_width(int w)
113 {
114     width = w;
115 }
116 
117 void    tw_get_pos(Frame tool, int *x, int *y)
118 {
119     *x = xv_get(tool, XV_X);
120     *y = xv_get(tool, XV_Y);
121 }
122 
123 void    tw_correct_pos(Frame tool, int *x, int *y)
124 {
125     int     dx, dy;
126     Frame   owner = (Frame) xv_get(tool, XV_OWNER);
127 
128     if (owner == (int)NULL)
129         return;
130     tw_get_pos(owner, &dx, &dy);
131     *x += dx;
132     *y += dy;
133     tw_correct_pos(owner, x, y);
134 }
135 
136 void    tw_set_pos(Frame tool, int x, int y)
137 {
138     /** Open windows bug fix **/
139     tw_correct_pos(tool, &x, &y);
140     xv_set(tool,
141            XV_X, x, XV_Y, y,
142            NULL);
143 }
144 int tw_get_closed(Frame tool)
145 {
146   return xv_get(tool,FRAME_CLOSED, NULL);
147 }
148  
149 void tw_set_closed(Frame tool, int closed)
150 {
151   xv_set(tool,FRAME_CLOSED,closed,NULL);
152 }
153 
154 void    tw_get_geom(Frame tool, int *x, int *y, int *w, int *h)
155 {
156     *x = xv_get(tool, XV_X);
157     *y = xv_get(tool, XV_Y);
158     *w = xv_get(tool, XV_WIDTH);
159     *h = xv_get(tool, XV_HEIGHT);
160 }
161 
162 void    tw_set_geom(Frame tool, int x, int y, int w, int h)
163 {
164     /** Open windows bug fix **/
165     tw_correct_pos(tool, &x, &y);
166     xv_set(tool,
167            XV_X, x, XV_Y, y,
168            XV_WIDTH, w, XV_HEIGHT, h,
169            NULL);
170 }
171 
172 static void tool_cmnd(Tw_callback * twc, char *args)
173 {
174     int     x, y, w, h, closed;
175 
176     (void) sscanf(args, "%*s %d %d %d %d %d",
177                   &x, &y, &w, &h, &closed);
178     tw_set_geom((Frame) twc->window, x, y, w, h);
179     xv_set(twc->window, FRAME_CLOSED, closed, NULL);
180 }
181 
182 static void tool_prnt(FILE * fp, Tw_callback * twc)
183 {
184     int     x, y, w, h, closed;
185     int    x_top, y_top;
186 
187     tw_get_geom(toptool, &x_top, &y_top, &w, &h);
188     tw_get_geom((Frame) twc->window, &x, &y, &w, &h);
189     if (x_top+x == 0 && y_top+y == 0)
190     {
191         format("poorly defined location from xv_get() for %s \n",twc->name);
192         format("append macro and reposition \n");
193         x = 0;
194         y = 0;
195     }
196     closed = (int) xv_get((Frame)twc->window, FRAME_CLOSED);
197     (void) fprintf(fp, "%s %d %d %d %d %d\n",
198                    twc->name, x, y, w, h, closed);
199 }
200 
201 /**
202 tool & panel handling
203 **/
204 
205 Frame   tw_get_toptool(void)
206 {
207     return (toptool);
208 }
209 
210 Frame   tw_get_tool(void)
211 {
212     return (tool);
213 }
214 
215 void    tw_set_tool(Frame newtool)
216 {
217     tool = newtool;
218 }
219 
220 int     tw_get_row(void)
221 {
222     return (row);
223 }
224 
225 void    tw_firstrow(void)
226 {
227     newrow = false;
228     row = 0;
229 }
230 
231 void    tw_newrow(void)
232 {
233     newrow = true;
234     row++;
235 }
236 
237 Bool    tw_get_newrow(void)
238 {
239     return (newrow);
240 }
241 
242 void    tw_set_newrow(Bool val)
243 {
244     newrow = val;
245 }
246 
247 Panel   tw_get_panel(void)
248 {
249     return (panel);
250 }
251 
252 void    tw_set_panel(Panel newpanel)
253 {
254     panel = newpanel;
255 }
256 
257 Window  tw_get_lowest(void)
258 {
259     return (lowest);
260 }
261 
262 void    tw_set_lowest(Window newlowest)
263 {
264     lowest = newlowest;
265 }
266 
267 void    tw_set_toolname(char *name)
268 {
269     toolname = name;
270 }
271 
272 char   *tw_get_toolname(void)
273 {
274     return (toolname);
275 }
276 
277 void    tw_show_tool(Frame tool)
278 {
279     xv_set(tool,
280            XV_SHOW, TRUE,
281            NULL);
282     xv_set(tool,
283            FRAME_CLOSED, FALSE,
284            NULL);
285 }
286 
287 
288 /* NB Unable to implement remote display in XView. */
289 /* ARGSUSED quieten lint.  */
290 Frame   tw_tool_remote(char *name, int x, int y, char *display_string)
291 {
292     Xv_font font;
293     Tw_callback *twc;
294 
295     tw_set_width(0);
296 
297     tool = (Frame) xv_create(toptool, FRAME,
298                              FRAME_LABEL, name,
299                              XV_SHOW, FALSE,
300                              NULL);
301     xpos = x;
302     ypos = y;
303 
304     if (toptool == (int)NULL)
305         toptool = tool;
306 
307     panel = (Panel) xv_create(tool, PANEL,
308                               PANEL_ITEM_X_GAP, 3,
309                               WIN_ROW_GAP, 7,
310                               NULL);
311 
312     row = 0;
313     newrow = false;
314 
315     if (toptool == (int)NULL)
316         toptool = tool;
317 
318     font = (Xv_font) xv_find((int)NULL, FONT, FONT_NAME, "6x13", NULL);
319     if (font != (int) NULL)
320         xv_set(tool, XV_FONT, font, NULL);
321 
322     toolname = tw_extend_fullname(name, (char *) NULL);
323     twc = tw_callback_make(toolname, tool,
324     (void (*) ()) NULL, tool_cmnd, tool_prnt, (void (*) ()) NULL, NULL,
325                            NULL);
326     tw_register_callfrom(twc);
327 
328     tw_set_lowest(panel);
329 
330     return (tool);
331 }
332 
333 void    tw_no_panel(void)
334 {
335     /** motif function **/
336 }
337 
338 /* v6*/
339 Frame   tw_tool(char *name, int x, int y)
340 {
341     return tw_tool_remote(name, x, y, (char *) NULL);
342 }
343 
344 void    tw_tool_title_reset(Frame tool, char *name)
345 {
346     if (tool == (int)NULL)
347         return;
348     xv_set(tool, FRAME_LABEL, name, NULL);
349     
350 }
351 void tw_tool_icon_title(Frame tool, char *name)
352 {
353   Icon icon;
354   if ((int)tool == (int)NULL)
355     return;
356   icon=xv_get(tool, FRAME_ICON,NULL);
357   xv_set(icon, XV_LABEL,name,NULL);
358 }
359 
360 void    tw_end_tool(void)
361 {
362     if (width == 0)
363         window_fit(panel);
364     else
365         xv_set(panel, WIN_WIDTH, width, NULL);
366     window_fit(tool);
367     tw_set_pos(tool, xpos, ypos);
368     xv_set(tool, XV_SHOW, TRUE, NULL);
369 }
370 
371 int tw_next_event(void)
372 {
373   notify_dispatch();
374   tw_flush();
375   return 1;
376 }
377 
378 
379 void    tw_main_loop(void)
380 {
381     char   *tw_get_progname();
382     if ((int) tw_recover() & (int) tw_save())
383     {
384         tw_read_call_file(tw_get_progname());
385         tw_open_call_file(tw_get_progname(),"a");
386     } else if (tw_recover())
387         tw_read_call_file(tw_get_progname());
388     else if (tw_save())
389         tw_open_call_file(tw_get_progname(),"w");
390 
391     window_main_loop(tool);
392 }
393 
394 void    tw_flush(void)
395 {
396     if (toptool)
397     {
398         XFlush((Display *) xv_get(toptool, XV_DISPLAY));
399     }
400 }
401 
402 
403 
404 Display *tw_get_display(void)
405 {
406     return (Display *) xv_get(toptool, XV_DISPLAY);
407 }
408 
409 int tw_tool_destroy(void *item)
410 {
411   int val;
412   
413   val=xv_destroy_safe((int)item);
414   if(val==XV_ERROR)
415     {
416       printf("Unable to destroy that frame item\n");
417       val=0;                    /* error */
418     }
419   else
420     val=1;                      /* OK */
421   return val;
422 }
423 
424 int tw_dialog_destroy(void *item)
425 {
426   return tw_tool_destroy(item);
427 }
428 

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