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

Linux Cross Reference
Tina5/tina-tools/tinatool/wdgts/xv/wdgtsXv_tw_screen.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_screen.c,v $
 37  * Date    :  $Date: 2007/02/15 01:55:50 $
 38  * Version :  $Revision: 1.3 $
 39  * CVS Id  :  $Id: wdgtsXv_tw_screen.c,v 1.3 2007/02/15 01:55:50 paul Exp $
 40  *
 41  * Author  :  Legacy TINA
 42  *
 43  * Notes : tv_screen ('physical' display device) creation
 44  *         Upgrade X canvas to 'tv_screen' which handles repaints & mouse events.
 45  *         Can be installed on a Tina tv.  XView version
 46  *
 47  *********
 48 */
 49 
 50 #include "wdgtsXv_tw_screen.h"
 51 
 52 #if HAVE_CONFIG_H
 53 #   include <config.h>
 54 #endif
 55 
 56 #include <stdio.h>
 57 
 58 #include <xview/frame.h>
 59 #include <xview/canvas.h>
 60 #include <xview/rectlist.h>
 61 #include <xview/win_input.h>
 62 #include <xview/window.h>
 63 
 64 #include <tinatool/gphx/gphxDef.h>
 65 #include <tinatool/gphx/gphxPro.h>
 66 #include <tina/math/mathDef.h>
 67 #include <tinatool/draw/drawTv_tv.h>
 68 #include <tinatool/draw/drawTv_size.h>
 69 #include <tinatool/draw/drawTv_activity.h>
 70 #include <tinatool/wdgts/xv/wdgtsXv_tw_tool.h>
 71 
 72 #define TOOL_KEY 1
 73 
 74 /* FORWARD REFS */
 75 static void repaint_proc(Canvas canvas, Xv_window window, Rectlist * repaint_area);
 76 static void resize_proc(Canvas canvas, int width, int height);
 77 static void tv_screen_activity_proc(Xv_window window, Event * event, Notify_arg arg);
 78 
 79 
 80 /* Takes: XView canvas, its owner (a window) and an empty tv_screen
 81  * structure. Fills in the tv_screen fields.  See Vol. 7 p 80 for
 82  * model. */
 83 void    canvas_upgrade(int canvas_int, int owner_int, Tv_screen * tv_screen)
 84 {
 85     Frame   owner = (Frame) owner_int;
 86     Canvas  canvas = (Canvas) canvas_int;
 87     XWindowAttributes xwindowattributes;
 88 
 89     if (canvas == (Canvas)NULL || tv_screen == NULL)
 90         return;
 91 
 92     tv_screen->tv = NULL;
 93     tv_screen->owner = (void *) owner;
 94 
 95     /* Fill in cmap fields (use access fns because canvas may be
 96      * created by  devguide etc (display structure has info on
 97      * workstation) */
 98     tv_screen->display = (Display *) xv_get(canvas, XV_DISPLAY);
 99 
100     /* canvas_paint_window is an XView call returns 'view'in an XView
101      * canvas */
102     tv_screen->canvas = (void *) canvas_paint_window(canvas);
103 
104     /* Get X window.  See vol 7 p 83 */
105     tv_screen->window = (Window) xv_get(canvas_paint_window(canvas), XV_XID);
106 
107     XGetWindowAttributes(tv_screen->display, tv_screen->window,
108                          &xwindowattributes);
109     tv_screen->colormap = xwindowattributes.colormap;
110     tv_screen->visual = xwindowattributes.visual;
111 
112     /* Graphics contexts: current and previous */
113     tv_screen->gc = XCreateGC(tv_screen->display, tv_screen->window, 0, NULL);
114 /*
115     tv_screen->oldgc = XCreateGC(tv_screen->display, tv_screen->window, 0, NULL);
116 
117 */
118     tv_screen->screen = (int) 0;/* xv_get(canvas_paint_window(canvas),
119                                  * SCREEN_NUMBER); */
120     /* Tell XView how to repaint canvas on expose events etc */
121     xv_set(canvas,
122            CANVAS_X_PAINT_WINDOW, FALSE,        /* set by tw_canvas but
123                                                  * not by devguide */
124            CANVAS_REPAINT_PROC, repaint_proc,
125            CANVAS_RESIZE_PROC, resize_proc,
126            XV_KEY_DATA, TOOL_KEY, tv_screen,    /* Used by
127                                                  * tv_screen_activity_pro
128                                                  * c_xv */
129            NULL);
130 
131     /* Solicit mouse events (button presses & mouse drags) in the
132      * canvas */
133     xv_set((int) tv_screen->canvas,
134            WIN_EVENT_PROC, tv_screen_activity_proc,
135            WIN_CONSUME_EVENTS,
136            LOC_DRAG, WIN_MOUSE_BUTTONS, LOC_WINENTER, NULL,
137            XV_KEY_DATA, TOOL_KEY, tv_screen,    /* Used by
138                                                  * tv_screen_activity_pro
139                                                  * c_xv */
140            NULL);
141 
142     tv_screen_save_size(tv_screen);     /* Fill width, height & depth
143                                          * fields in tv_screen */
144 }
145 
146 
147 /* Called by XView on expose event.  Parameter list is XView specific */
148 /* ARGSUSED quieten lint  */
149 static void repaint_proc(Canvas canvas, Xv_window window, Rectlist * repaint_area)
150 {
151     Tv_screen *tv_screen = (Tv_screen *) xv_get(canvas, XV_KEY_DATA, TOOL_KEY);
152 
153     if (tv_screen && tv_screen->tv)
154     {
155         tv_repaint(tv_screen->tv);
156     }
157 }
158 
159 
160 /* Called by XView on resize event.  Parameter list is XView specific */
161 /* ARGSUSED quieten lint  */
162 static void resize_proc(Canvas canvas, int width, int height)
163 {
164     Tv_screen *tv_screen = (Tv_screen *) xv_get(canvas, XV_KEY_DATA, TOOL_KEY);
165 
166     if (tv_screen)
167     {
168         tv_resize(tv_screen->tv, TV_SCREEN_REPAINT_IF_SMALLER);
169         /* Repaint event generated if canvas gets BIGGER, calls
170          * tv_repaint, so don't need to call tv_repaint here if bigger */
171     }
172 }
173 
174 
175 /* Handle mouse events (not keyboard) in tv_screen.  Meaning of an
176  * event (eg mouse SELECT) depends on the tv->activity (zoom, roi, pick
177  * mouse). */
178 /* ARGSUSED quieten lint */
179 static void tv_screen_activity_proc(Xv_window window, Event * event, Notify_arg arg)
180 {
181     Tv_screen *tv_screen = (Tv_screen *) xv_get(window, XV_KEY_DATA, TOOL_KEY);
182     Tv     *tv;
183     int     state;              /* Could be Mouse_state mouse_state; */
184     Ipos    pos = {Ipos_id};
185 
186     if (tv_screen)
187     {
188         if (event_id(event) == LOC_WINENTER)
189         {
190             /* Install colormap (window manager fails to do this) */
191             tv_screen_cmap_install(tv_screen, tv_screen->colormap);
192         }
193         if ((tv = tv_screen->tv) &&
194         (state = mouse_get_state(event->ie_xevent, &pos)) != BAD_STATE)
195         {
196             tv_activity_proc(tv, state, pos);
197         }
198     }
199 }
200 
201 void    tv_screen_set_size(Tv_screen * tv_screen, int width, int height)
202 {
203     int     x, y, w, h;
204     int     dw, dh;
205 
206     if (tv_screen == NULL)
207         return;
208 
209     tv_screen_save_size(tv_screen);
210     tw_get_geom((Frame) tv_screen->owner, &x, &y, &w, &h);
211     dw = w - tv_screen->width;
212     dh = h - tv_screen->height;
213     tw_set_geom((Frame) tv_screen->owner, x, y, width + dw, height + dh);
214 }
215 

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