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

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

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