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

Linux Cross Reference
Tina4/src/Xm/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.  Motif version
  4 */
  5 
  6 #include <tina/sys.h>
  7 #include <tina/math.h>
  8 #include <tina/tv.h>
  9 #include <tina/tvfuncs.h>
 10 #include <tina/tv_screen.h>
 11 #include <tina/mtw.h>
 12 
 13 #include <Xm/Xm.h>
 14 #include <Xm/Text.h>
 15 #include <Xm/Label.h>
 16 #include <Xm/DrawingA.h>
 17 #include <Xm/Form.h>
 18 #include <Xm/RowColumn.h>
 19 #include <Xm/PushB.h>
 20 
 21 /* FORWARD REFS */
 22 static void repaint_proc(Widget w, Tv_screen * tv_screen, XmAnyCallbackStruct * xcallback);
 23 static void resize_proc(Widget w, Tv_screen * tv_screen, XmAnyCallbackStruct * xcallback);
 24 static void tv_screen_activity_proc(Widget w, Tv_screen * tv_screen, XEvent * event);
 25 
 26 /* EXTERNS */
 27 void    tv_screen_erase();
 28 
 29 /* ARGSUSED quieten lint */
 30 static void tv_screen_install_cmap_proc(Widget window, Tv_screen * tv_screen, XEvent event)
 31 {
 32     /* Install colormap (window manager fails to do  this) */
 33     tv_screen_cmap_install(tv_screen, tv_screen->colormap);
 34 }
 35 
 36 void    canvas_upgrade(Widget canvas, Widget owner, Tv_screen * tv_screen)
 37 {
 38     XWindowAttributes xwindowattributes;
 39 
 40     if (canvas == NULL || tv_screen == NULL)
 41         return;
 42 
 43     tv_screen->tv = NULL;
 44     tv_screen->owner = (void *) owner;
 45     tv_screen->canvas = (void *) canvas;
 46 
 47     tv_screen->display = XtDisplay(canvas);
 48     tv_screen->window = XtWindow(canvas);
 49     tv_screen->gc = XCreateGC(tv_screen->display, tv_screen->window, 0, NULL);
 50     tv_screen->oldgc = XCreateGC(tv_screen->display, tv_screen->window, 0, NULL);
 51 
 52     XGetWindowAttributes(tv_screen->display, tv_screen->window,
 53                          &xwindowattributes);
 54 
 55     tv_screen->colormap = xwindowattributes.colormap;
 56 
 57     tv_screen->visual = xwindowattributes.visual;
 58 
 59 
 60 
 61     XtAddCallback(canvas, XmNresizeCallback, resize_proc, (XtPointer) tv_screen);
 62     XtAddCallback(canvas, XmNexposeCallback, repaint_proc, (XtPointer) tv_screen);
 63 
 64     XtAddEventHandler(canvas,
 65                ButtonPressMask | ButtonMotionMask | ButtonReleaseMask,
 66                       FALSE, tv_screen_activity_proc, tv_screen);
 67     XtAddEventHandler(canvas,
 68                       EnterWindowMask,
 69                       FALSE, tv_screen_install_cmap_proc, tv_screen);
 70 
 71     XGrabButton(tv_screen->display, AnyButton, AnyModifier,
 72                 tv_screen->window, TRUE,
 73                 ButtonPressMask | ButtonMotionMask | ButtonReleaseMask,
 74                 GrabModeAsync, GrabModeAsync,
 75                 tv_screen->window,
 76                 NULL);
 77 
 78     tv_screen_save_size(tv_screen);
 79 }
 80 
 81 
 82 /* ARGSUSED quieten lint */
 83 static void tv_screen_activity_proc(Widget w, Tv_screen * tv_screen, XEvent * event)
 84 {
 85     Tv     *tv;
 86     Ipos    pos = {Ipos_id};
 87 
 88     if (tv_screen && (tv = tv_screen->tv))
 89     {
 90         int     state = mouse_get_state(event, &pos);
 91 
 92         if (state != BAD_STATE)
 93             tv_activity_proc(tv, state, pos);
 94     }
 95 }
 96 
 97 /* ARGSUSED: w quieten lint */
 98 static void repaint_proc(Widget w, Tv_screen * tv_screen, XmAnyCallbackStruct * xcallback)
 99 {
100     Display *display;
101     Window  window;
102     XEvent  ahead;
103     XEvent  event;
104 
105     event = *(xcallback->event);
106 
107     display = event.xany.display;
108     window = event.xany.window;
109 
110     /* Compress Expose events */
111     while ((XEventsQueued(display, QueuedAfterReading) > 0) &&
112            (XPeekEvent(display, &ahead),
113             ((ahead.type == Expose) && (ahead.xany.window == window))))
114     {
115         XNextEvent(display, &event);
116     }
117 
118     if (tv_screen && tv_screen->tv && (event.xexpose.count == 0))
119     {
120         tv_repaint(tv_screen->tv);
121     }
122 }
123 
124 
125 
126 /* ARGSUSED quieten lint */
127 static void resize_proc(Widget w, Tv_screen * tv_screen, XmAnyCallbackStruct * xcallback)
128 {
129     if (tv_screen == NULL)
130         return;
131 
132     tv_resize(tv_screen->tv, TV_SCREEN_REPAINT_IF_SMALLER);
133 }
134 
135 /** size Tv_screen really is **/
136 
137 /** superseded by pure X version in X11
138 
139 int             tv_screen_check_width(tv_screen)
140 Tv_screen        *tv_screen;
141 {
142     Dimension       width;
143     Arg             wargs[1];
144 
145     XtSetArg(wargs[0], XtNwidth, &width);
146     XtGetValues(tv_screen->canvas, wargs, 1);
147     return ((int) width);
148 }
149 
150 int             tv_screen_check_height(tv_screen)
151 Tv_screen        *tv_screen;
152 {
153     Dimension       height;
154     Arg             wargs[1];
155 
156     XtSetArg(wargs[0], XtNheight, &height);
157     XtGetValues(tv_screen->canvas, wargs, 1);
158     return ((int) height);
159 }
160 **/
161 
162 
163 void    tv_screen_set_size(Tv_screen * tv_screen, int width, int height)
164 {
165     Dimension w, h;
166     Arg     wargs[2];
167     int     dw, dh;
168 
169     if (tv_screen == NULL)
170         return;
171 
172     if (width == tv_screen->width && height == tv_screen->height)
173         return;
174 
175     dw = width - tv_screen->width;
176     dh = height - tv_screen->height;
177 
178     XtSetArg(wargs[0], XtNwidth, &w);
179     XtSetArg(wargs[1], XtNheight, &h);
180     XtGetValues((Widget) tv_screen->owner, wargs, 2);
181 
182     w += dw;
183     h += dh;
184 
185     XtSetArg(wargs[0], XtNwidth, w);
186     XtSetArg(wargs[1], XtNheight, h);
187     XtSetValues((Widget) tv_screen->owner, wargs, 2);
188 
189     tv_screen_save_size(tv_screen);
190     tv_resize(tv_screen->tv, TV_SCREEN_REPAINT_IF_SMALLER);
191 }
192 

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