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

Linux Cross Reference
Tina5/tina-tools/tinatool/wdgts/xm/wdgtsXm_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/xm/wdgtsXm_tw_screen.c,v $
 37  * Date    :  $Date: 2007/02/15 01:55:50 $
 38  * Version :  $Revision: 1.3 $
 39  * CVS Id  :  $Id: wdgtsXm_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 "wdgtsXm_tw_screen.h"
 51 
 52 #if HAVE_CONFIG_H
 53 #   include <config.h>
 54 #endif
 55 
 56 #include <stdio.h>
 57 
 58 #include <Xm/Xm.h>
 59 #include <Xm/Text.h>
 60 #include <Xm/Label.h>
 61 #include <Xm/DrawingA.h>
 62 #include <Xm/Form.h>
 63 #include <Xm/RowColumn.h>
 64 #include <Xm/PushB.h>
 65 #include <X11/Intrinsic.h>
 66 
 67 #include <tinatool/gphx/gphxDef.h>
 68 #include <tinatool/gphx/gphxPro.h>
 69 #include <tina/math/mathDef.h>
 70 #include <tinatool/draw/drawTv_activity.h>
 71 #include <tinatool/draw/drawTv_tv.h>
 72 #include <tinatool/draw/drawTv_size.h>
 73 
 74 /* FORWARD REFS */
 75 static void repaint_proc(Widget w, Tv_screen * tv_screen, XmAnyCallbackStruct * xcallback);
 76 static void resize_proc(Widget w, Tv_screen * tv_screen, XmAnyCallbackStruct * xcallback);
 77 static void tv_screen_activity_proc(Widget w, Tv_screen * tv_screen, XEvent * event);
 78 
 79 /* EXTERNS */
 80 void    tv_screen_erase();
 81 
 82 /* ARGSUSED quieten lint */
 83 static void tv_screen_install_cmap_proc(Widget window, Tv_screen * tv_screen, XEvent event)
 84 {
 85     /* Install colormap (window manager fails to do  this) */
 86     tv_screen_cmap_install(tv_screen, tv_screen->colormap);
 87 }
 88 
 89 void    canvas_upgrade(Widget canvas, Widget owner, Tv_screen * tv_screen)
 90 {
 91     XWindowAttributes xwindowattributes;
 92 
 93     if (canvas == NULL || tv_screen == NULL)
 94         return;
 95 
 96     tv_screen->tv = NULL;
 97     tv_screen->owner = (void *) owner;
 98     tv_screen->canvas = (void *) canvas;
 99 
100     tv_screen->display = XtDisplay(canvas);
101     tv_screen->window = XtWindow(canvas);
102     tv_screen->gc = XCreateGC(tv_screen->display, tv_screen->window, 0, NULL);
103     tv_screen->oldgc = XCreateGC(tv_screen->display, tv_screen->window, 0, NULL);
104 
105     XGetWindowAttributes(tv_screen->display, tv_screen->window,
106                          &xwindowattributes);
107 
108     tv_screen->colormap = xwindowattributes.colormap;
109 
110     tv_screen->visual = xwindowattributes.visual;
111 
112 
113 
114     /* warning: passing argument 3 of 'XtAddCallback' from incompatible pointer type */
115     XtAddCallback(canvas, XmNresizeCallback, resize_proc, (XtPointer) tv_screen);
116     XtAddCallback(canvas, XmNexposeCallback, repaint_proc, (XtPointer) tv_screen);
117 
118     XtAddEventHandler(canvas,
119                ButtonPressMask | ButtonMotionMask | ButtonReleaseMask,
120                       /* warning: passing argument 4 of 'XtAddEventHandler' from incompatible pointer type */
121                       FALSE, tv_screen_activity_proc, tv_screen);
122     XtAddEventHandler(canvas,
123                       EnterWindowMask,
124                       /* warning: passing argument 4 of 'XtAddEventHandler' from incompatible pointer type */
125                       FALSE, tv_screen_install_cmap_proc, tv_screen);
126 
127     XGrabButton(tv_screen->display, AnyButton, AnyModifier,
128                 tv_screen->window, TRUE,
129                 ButtonPressMask | ButtonMotionMask | ButtonReleaseMask,
130                 GrabModeAsync, GrabModeAsync,
131                 tv_screen->window,
132                 None);
133 
134     tv_screen_save_size(tv_screen);
135 }
136 
137 
138 /* ARGSUSED quieten lint */
139 static void tv_screen_activity_proc(Widget w, Tv_screen * tv_screen, XEvent * event)
140 {
141     Tv     *tv;
142     Ipos    pos = {Ipos_id};
143 
144     if (tv_screen && (tv = tv_screen->tv))
145     {
146         int     state = mouse_get_state(event, &pos);
147 
148         if (state != BAD_STATE)
149             tv_activity_proc(tv, state, pos);
150     }
151 }
152 
153 /* ARGSUSED: w quieten lint */
154 static void repaint_proc(Widget w, Tv_screen * tv_screen, XmAnyCallbackStruct * xcallback)
155 {
156     Display *display;
157     Window  window;
158     XEvent  ahead;
159     XEvent  event;
160 
161     event = *(xcallback->event);
162 
163     display = event.xany.display;
164     window = event.xany.window;
165 
166     /* Compress Expose events */
167     while ((XEventsQueued(display, QueuedAfterReading) > 0) &&
168            (XPeekEvent(display, &ahead),
169             ((ahead.type == Expose) && (ahead.xany.window == window))))
170     {
171         XNextEvent(display, &event);
172     }
173 
174     if (tv_screen && tv_screen->tv && (event.xexpose.count == 0))
175     {
176         tv_repaint(tv_screen->tv);
177     }
178 }
179 
180 
181 
182 /* ARGSUSED quieten lint */
183 static void resize_proc(Widget w, Tv_screen * tv_screen, XmAnyCallbackStruct * xcallback)
184 {
185     if (tv_screen == NULL)
186         return;
187 
188     tv_resize(tv_screen->tv, TV_SCREEN_REPAINT_IF_SMALLER);
189 }
190 
191 /** size Tv_screen really is **/
192 
193 /** superseded by pure X version in X11
194 
195 int             tv_screen_check_width(tv_screen)
196 Tv_screen        *tv_screen;
197 {
198     Dimension       width;
199     Arg             wargs[1];
200 
201     XtSetArg(wargs[0], XtNwidth, &width);
202     XtGetValues(tv_screen->canvas, wargs, 1);
203     return ((int) width);
204 }
205 
206 int             tv_screen_check_height(tv_screen)
207 Tv_screen        *tv_screen;
208 {
209     Dimension       height;
210     Arg             wargs[1];
211 
212     XtSetArg(wargs[0], XtNheight, &height);
213     XtGetValues(tv_screen->canvas, wargs, 1);
214     return ((int) height);
215 }
216 **/
217 
218 
219 void    tv_screen_set_size(Tv_screen * tv_screen, int width, int height)
220 {
221     Dimension w, h;
222     Arg     wargs[2];
223     int     dw, dh;
224 
225     if (tv_screen == NULL)
226         return;
227 
228     if (width == tv_screen->width && height == tv_screen->height)
229         return;
230 
231     dw = width - tv_screen->width;
232     dh = height - tv_screen->height;
233 
234     XtSetArg(wargs[0], XtNwidth, &w);
235     XtSetArg(wargs[1], XtNheight, &h);
236     XtGetValues((Widget) tv_screen->owner, wargs, 2);
237 
238     w += dw;
239     h += dh;
240 
241     XtSetArg(wargs[0], XtNwidth, w);
242     XtSetArg(wargs[1], XtNheight, h);
243     XtSetValues((Widget) tv_screen->owner, wargs, 2);
244 
245     tv_screen_save_size(tv_screen);
246     tv_resize(tv_screen->tv, TV_SCREEN_REPAINT_IF_SMALLER);
247 }
248 

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