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

Linux Cross Reference
Tina4/src/Xv/tw_screen.c

Version: ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /** @(#)tv_screen ('physical' display device) creation
  2 @(#)Upgrade X canvas to 'tv_screen' which handles repaints & mouse events.
  3 @(#)Can be installed on a Tina tv.  XView version
  4 */
  5 
  6 #include <stdio.h>
  7 #include <tina/sys.h>
  8 #include <tina/math.h>
  9 #include <tina/tw.h>
 10 #include <tina/tv.h>
 11 #include <tina/tvfuncs.h>
 12 #include <tina/tv_screen.h>
 13 #include <xview/xview.h>
 14 #include <xview/frame.h>
 15 #include <xview/panel.h>
 16 #include <xview/textsw.h>
 17 #include <xview/font.h>
 18 #include <xview/canvas.h>
 19 #include <xview/cms.h>
 20 #include <xview/xv_xrect.h>
 21 #include <xview/openmenu.h>
 22 #include <tina/Xvfuncs.h>
 23 #include <tina/X11funcs.h>
 24 
 25 #define TOOL_KEY 1
 26 
 27 /* FORWARD REFS */
 28 static void repaint_proc(Canvas canvas, Xv_window window, Rectlist * repaint_area);
 29 static void resize_proc(Canvas canvas, int width, int height);
 30 static void tv_screen_activity_proc(Xv_window window, Event * event, Notify_arg arg);
 31 
 32 
 33 /* Takes: XView canvas, its owner (a window) and an empty tv_screen
 34  * structure. Fills in the tv_screen fields.  See Vol. 7 p 80 for
 35  * model. */
 36 void    canvas_upgrade(int canvas_int, int owner_int, Tv_screen * tv_screen)
 37 {
 38     Frame   owner = (Frame) owner_int;
 39     Canvas  canvas = (Canvas) canvas_int;
 40     XWindowAttributes xwindowattributes;
 41 
 42     if (canvas == (Canvas)NULL || tv_screen == NULL)
 43         return;
 44 
 45     tv_screen->tv = NULL;
 46     tv_screen->owner = (void *) owner;
 47 
 48     /* Fill in cmap fields (use access fns because canvas may be
 49      * created by  devguide etc (display structure has info on
 50      * workstation) */
 51     tv_screen->display = (Display *) xv_get(canvas, XV_DISPLAY);
 52 
 53     /* canvas_paint_window is an XView call returns 'view'in an XView
 54      * canvas */
 55     tv_screen->canvas = (void *) canvas_paint_window(canvas);
 56 
 57     /* Get X window.  See vol 7 p 83 */
 58     tv_screen->window = (Window) xv_get(canvas_paint_window(canvas), XV_XID);
 59 
 60     XGetWindowAttributes(tv_screen->display, tv_screen->window,
 61                          &xwindowattributes);
 62     tv_screen->colormap = xwindowattributes.colormap;
 63     tv_screen->visual = xwindowattributes.visual;
 64 
 65     /* Graphics contexts: current and previous */
 66     tv_screen->gc = XCreateGC(tv_screen->display, tv_screen->window, 0, NULL);
 67 /*
 68     tv_screen->oldgc = XCreateGC(tv_screen->display, tv_screen->window, 0, NULL);
 69 
 70 */
 71     tv_screen->screen = (int) 0;/* xv_get(canvas_paint_window(canvas),
 72                                  * SCREEN_NUMBER); */
 73     /* Tell XView how to repaint canvas on expose events etc */
 74     xv_set(canvas,
 75            CANVAS_X_PAINT_WINDOW, FALSE,        /* set by tw_canvas but
 76                                                  * not by devguide */
 77            CANVAS_REPAINT_PROC, repaint_proc,
 78            CANVAS_RESIZE_PROC, resize_proc,
 79            XV_KEY_DATA, TOOL_KEY, tv_screen,    /* Used by
 80                                                  * tv_screen_activity_pro
 81                                                  * c_xv */
 82            NULL);
 83 
 84     /* Solicit mouse events (button presses & mouse drags) in the
 85      * canvas */
 86     xv_set((int) tv_screen->canvas,
 87            WIN_EVENT_PROC, tv_screen_activity_proc,
 88            WIN_CONSUME_EVENTS,
 89            LOC_DRAG, WIN_MOUSE_BUTTONS, LOC_WINENTER, NULL,
 90            XV_KEY_DATA, TOOL_KEY, tv_screen,    /* Used by
 91                                                  * tv_screen_activity_pro
 92                                                  * c_xv */
 93            NULL);
 94 
 95     tv_screen_save_size(tv_screen);     /* Fill width, height & depth
 96                                          * fields in tv_screen */
 97 }
 98 
 99 
100 /* Called by XView on expose event.  Parameter list is XView specific */
101 /* ARGSUSED quieten lint  */
102 static void repaint_proc(Canvas canvas, Xv_window window, Rectlist * repaint_area)
103 {
104     Tv_screen *tv_screen = (Tv_screen *) xv_get(canvas, XV_KEY_DATA, TOOL_KEY);
105 
106     if (tv_screen && tv_screen->tv)
107     {
108         tv_repaint(tv_screen->tv);
109     }
110 }
111 
112 
113 /* Called by XView on resize event.  Parameter list is XView specific */
114 /* ARGSUSED quieten lint  */
115 static void resize_proc(Canvas canvas, int width, int height)
116 {
117     Tv_screen *tv_screen = (Tv_screen *) xv_get(canvas, XV_KEY_DATA, TOOL_KEY);
118 
119     if (tv_screen)
120     {
121         tv_resize(tv_screen->tv, TV_SCREEN_REPAINT_IF_SMALLER);
122         /* Repaint event generated if canvas gets BIGGER, calls
123          * tv_repaint, so don't need to call tv_repaint here if bigger */
124     }
125 }
126 
127 
128 /* Handle mouse events (not keyboard) in tv_screen.  Meaning of an
129  * event (eg mouse SELECT) depends on the tv->activity (zoom, roi, pick
130  * mouse). */
131 /* ARGSUSED quieten lint */
132 static void tv_screen_activity_proc(Xv_window window, Event * event, Notify_arg arg)
133 {
134     Tv_screen *tv_screen = (Tv_screen *) xv_get(window, XV_KEY_DATA, TOOL_KEY);
135     Tv     *tv;
136     int     state;              /* Could be Mouse_state mouse_state; */
137     Ipos    pos = {Ipos_id};
138 
139     if (tv_screen)
140     {
141         if (event_id(event) == LOC_WINENTER)
142         {
143             /* Install colormap (window manager fails to do this) */
144             tv_screen_cmap_install(tv_screen, tv_screen->colormap);
145         }
146         if ((tv = tv_screen->tv) &&
147         (state = mouse_get_state(event->ie_xevent, &pos)) != BAD_STATE)
148         {
149             tv_activity_proc(tv, state, pos);
150         }
151     }
152 }
153 
154 void    tv_screen_set_size(Tv_screen * tv_screen, int width, int height)
155 {
156     int     x, y, w, h;
157     int     dw, dh;
158 
159     if (tv_screen == NULL)
160         return;
161 
162     tv_screen_save_size(tv_screen);
163     tw_get_geom((Frame) tv_screen->owner, &x, &y, &w, &h);
164     dw = w - tv_screen->width;
165     dh = h - tv_screen->height;
166     tw_set_geom((Frame) tv_screen->owner, x, y, width + dw, height + dh);
167 }
168 

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