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

Linux Cross Reference
Tina4/src/Xv/tv_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 == 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     tv_screen->oldgc = XCreateGC(tv_screen->display, tv_screen->window, 0, NULL);
 68 
 69     tv_screen->screen = (int) 0;/* xv_get(canvas_paint_window(canvas),
 70                                  * SCREEN_NUMBER); */
 71     /* Tell XView how to repaint canvas on expose events etc */
 72     xv_set(canvas,
 73            CANVAS_X_PAINT_WINDOW, FALSE,        /* set by tw_canvas but
 74                                                  * not by devguide */
 75            CANVAS_REPAINT_PROC, repaint_proc,
 76            CANVAS_RESIZE_PROC, resize_proc,
 77            XV_KEY_DATA, TOOL_KEY, tv_screen,    /* Used by
 78                                                  * tv_screen_activity_pro
 79                                                  * c_xv */
 80            NULL);
 81 
 82     /* Solicit mouse events (button presses & mouse drags) in the
 83      * canvas */
 84     xv_set((int) tv_screen->canvas,
 85            WIN_EVENT_PROC, tv_screen_activity_proc,
 86            WIN_CONSUME_EVENTS,
 87            LOC_DRAG, WIN_MOUSE_BUTTONS, LOC_WINENTER, NULL,
 88            XV_KEY_DATA, TOOL_KEY, tv_screen,    /* Used by
 89                                                  * tv_screen_activity_pro
 90                                                  * c_xv */
 91            NULL);
 92 
 93     tv_screen_save_size(tv_screen);     /* Fill width, height & depth
 94                                          * fields in tv_screen */
 95 }
 96 
 97 
 98 /* Called by XView on expose event.  Parameter list is XView specific */
 99 /* ARGSUSED quieten lint  */
100 static void repaint_proc(Canvas canvas, Xv_window window, Rectlist * repaint_area)
101 {
102     Tv_screen *tv_screen = (Tv_screen *) xv_get(canvas, XV_KEY_DATA, TOOL_KEY);
103 
104     if (tv_screen && tv_screen->tv)
105     {
106         tv_repaint(tv_screen->tv);
107     }
108 }
109 
110 
111 /* Called by XView on resize event.  Parameter list is XView specific */
112 /* ARGSUSED quieten lint  */
113 static void resize_proc(Canvas canvas, int width, int height)
114 {
115     Tv_screen *tv_screen = (Tv_screen *) xv_get(canvas, XV_KEY_DATA, TOOL_KEY);
116 
117     if (tv_screen)
118     {
119         tv_resize(tv_screen->tv, TV_SCREEN_REPAINT_IF_SMALLER);
120         /* Repaint event generated if canvas gets BIGGER, calls
121          * tv_repaint, so don't need to call tv_repaint here if bigger */
122     }
123 }
124 
125 
126 /* Handle mouse events (not keyboard) in tv_screen.  Meaning of an
127  * event (eg mouse SELECT) depends on the tv->activity (zoom, roi, pick
128  * mouse). */
129 /* ARGSUSED quieten lint */
130 static void tv_screen_activity_proc(Xv_window window, Event * event, Notify_arg arg)
131 {
132     Tv_screen *tv_screen = (Tv_screen *) xv_get(window, XV_KEY_DATA, TOOL_KEY);
133     Tv     *tv;
134     int     state;              /* Could be Mouse_state mouse_state; */
135     Ipos    pos = {Ipos_id};
136 
137     if (tv_screen)
138     {
139         if (event_id(event) == LOC_WINENTER)
140         {
141             /* Install colormap (window manager fails to do this) */
142             tv_screen_cmap_install(tv_screen, tv_screen->colormap);
143         }
144         if ((tv = tv_screen->tv) &&
145         (state = mouse_get_state(event->ie_xevent, &pos)) != BAD_STATE)
146         {
147             tv_activity_proc(tv, state, pos);
148         }
149     }
150 }
151 
152 void    tv_screen_set_size(Tv_screen * tv_screen, int width, int height)
153 {
154     int     x, y, w, h;
155     int     dw, dh;
156 
157     if (tv_screen == NULL)
158         return;
159 
160     tv_screen_save_size(tv_screen);
161     tw_get_geom((Frame) tv_screen->owner, &x, &y, &w, &h);
162     dw = w - tv_screen->width;
163     dh = h - tv_screen->height;
164     tw_set_geom((Frame) tv_screen->owner, x, y, width + dw, height + dh);
165 }
166 

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