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

Linux Cross Reference
Tina5/tina-tools/tinatool/gphx/x11/gphxX11_draw.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/gphx/x11/gphxX11_draw.c,v $
 37  * Date    :  $Date: 2009/03/23 15:41:27 $
 38  * Version :  $Revision: 1.3 $
 39  * CVS Id  :  $Id: gphxX11_draw.c,v 1.3 2009/03/23 15:41:27 paul Exp $
 40  *
 41  * Author  :  Legacy TINA
 42  *
 43  * Notes   :
 44  * 
 45  *
 46  *********
 47 */
 48 
 49 #include "gphxX11_draw.h"
 50 
 51 #if HAVE_CONFIG_H
 52   #include <config.h>
 53 #endif
 54 
 55 
 56 void    tv_screen_flush(Tv_screen * tv_screen)
 57 {
 58     if (tv_screen == NULL)
 59         return;
 60 
 61     /* flushes whole display not just current tv_screen */
 62     XFlush(tv_screen->display);
 63 }
 64 
 65 void    tv_screen_erase(Tv_screen * tv_screen)
 66 {
 67     if (tv_screen)
 68     {
 69         XClearWindow(tv_screen->display, tv_screen->window);
 70     }
 71 }
 72 
 73 
 74 void    tv_screen_point(Tv_screen * tv_screen, Ipos pos)
 75 {
 76     if (tv_screen == NULL)
 77         return;
 78 
 79     XDrawPoint(tv_screen->display, tv_screen->window, tv_screen->gc, pos.x, pos.y);
 80 }
 81 
 82 void    tv_screen_dot(Tv_screen * tv_screen, Ipos pos)
 83 {
 84     int     x0, x1, x2;
 85     int     y0, y1, y2;
 86 
 87     if (tv_screen == NULL)
 88         return;
 89 
 90     x1 = pos.x;
 91     y1 = pos.y;
 92     x0 = x1 - 1;
 93     y0 = y1 - 1;
 94     x2 = x1 + 1;
 95     y2 = y1 + 1;
 96     XDrawLine(tv_screen->display, tv_screen->window, tv_screen->gc, x0, y0, x2, y0);
 97     XDrawLine(tv_screen->display, tv_screen->window, tv_screen->gc, x0, y1, x2, y1);
 98     XDrawLine(tv_screen->display, tv_screen->window, tv_screen->gc, x0, y2, x2, y2);
 99 }
100 
101 void    tv_screen_line(Tv_screen * tv_screen, Ipos pos1, Ipos pos2)
102 {
103     if (tv_screen == NULL)
104         return;
105 
106     XDrawLine(tv_screen->display, tv_screen->window, tv_screen->gc,
107               pos1.x, pos1.y, pos2.x, pos2.y);
108 }
109 
110 void    tv_screen_polyline(Tv_screen * tv_screen, List * points)
111 {
112     int     npoints, i;
113     List   *ptr;
114     XPoint *xpoints;
115     Ipos    pos = {Ipos_id};
116 
117     if (tv_screen == NULL)
118         return;
119 
120     npoints = list_length(points);
121     xpoints = (XPoint *) ralloc((unsigned) npoints * sizeof(XPoint));
122     for (ptr = points, i = 0; ptr != NULL; ptr = ptr->next, ++i)
123     {
124         pos = *((Ipos *) ptr->to);
125         xpoints[i].x = pos.x;
126         xpoints[i].y = pos.y;
127     }
128     XDrawLines(tv_screen->display, tv_screen->window, tv_screen->gc,
129                xpoints, npoints, CoordModeOrigin);
130     rfree((void *) xpoints);
131 }
132 
133 void    tv_screen_circle(Tv_screen * tv_screen, Ipos centre, int radius)
134 {
135     int     cx = centre.x;
136     int     cy = centre.y;
137 
138     if (tv_screen == NULL)
139         return;
140 
141     XDrawArc(tv_screen->display, tv_screen->window, tv_screen->gc,
142        cx - radius, cy - radius, 2 * radius, 2 * radius, 0, 64 * 360);
143 }
144 
145 void    tv_screen_rect(Tv_screen * tv_screen, Ipos pos1, Ipos pos2)
146 {
147     int     x1 = pos1.x, y1 = pos1.y;
148     int     x2 = pos2.x, y2 = pos2.y;
149 
150     if (tv_screen == NULL)
151         return;
152 
153     if (x1 == x2 && y1 == y2)
154     {                           /* a single point */
155         XDrawPoint(tv_screen->display, tv_screen->window, tv_screen->gc, x1, y1);
156         return;
157     }
158     ORDER(int, x1, x2);
159     ORDER(int, y1, y2);
160     XDrawLine(tv_screen->display, tv_screen->window, tv_screen->gc, x1, y1, x1, y2 - 1);
161     XDrawLine(tv_screen->display, tv_screen->window, tv_screen->gc, x1, y2, x2 - 1, y2);
162     XDrawLine(tv_screen->display, tv_screen->window, tv_screen->gc, x2, y2, x2, y1 + 1);
163     XDrawLine(tv_screen->display, tv_screen->window, tv_screen->gc, x2, y1, x1 + 1, y1);
164 }
165 
166 void    tv_screen_fillrect(Tv_screen * tv_screen, Ipos pos1, Ipos pos2)
167 {
168     int     x1 = pos1.x, y1 = pos1.y;
169     int     x2 = pos2.x, y2 = pos2.y;
170 
171     if (tv_screen == NULL)
172         return;
173 
174     XFillRectangle(tv_screen->display, tv_screen->window, tv_screen->gc,
175                    x1, y1, x2 - x1, y2 - y1);
176 }
177 
178 void    tv_screen_text(Tv_screen * tv_screen, char *string, Ipos pos)
179 {
180     if (tv_screen == NULL)
181         return;
182 
183     XDrawString(tv_screen->display, tv_screen->window, tv_screen->gc,
184                 pos.x, pos.y, string, strlen(string));
185 }
186 
187 void    tv_screen_raster(Tv_screen * tv_screen, int x1, int x2, int y, char *raster)
188 {
189     /* indexed between 0 and x2-x1 */
190     XImage *xraster;
191     XWindowAttributes attr;
192 
193     if (tv_screen == NULL)
194         return;
195 
196     XGetWindowAttributes(tv_screen->display, tv_screen->window, &attr);
197     xraster = XCreateImage(tv_screen->display, attr.visual,
198               tv_screen->depth, ZPixmap, 0, raster, x2 - x1, 1, 8, 0);
199     XPutImage(tv_screen->display, tv_screen->window, tv_screen->gc,
200               xraster, 0, 0, x1, y, x2 - x1, 1);
201     XFree((char *) xraster);
202 }
203 
204 void    tv_screen_image(Tv_screen * tv_screen, int x, int y, int w, int h, char *data)
205 /* height and  width */
206 {
207     XImage *xim;
208     XWindowAttributes attr;
209 
210     if (tv_screen == NULL)
211         return;
212 
213     XGetWindowAttributes(tv_screen->display, tv_screen->window, &attr);
214     xim = XCreateImage(tv_screen->display, attr.visual,
215                        tv_screen->depth, ZPixmap, 0, data, w, h, 8, 0);
216     XPutImage(tv_screen->display, tv_screen->window, tv_screen->gc,
217               xim, 0, 0, x, y, w, h);
218     XFree((char *) xim);
219 }
220 
221 void    tv_screen_show_picture(Tv_screen * tv_screen, Tv_picture * picture)
222 {
223     XCopyArea(tv_screen->display, picture->pixmap, tv_screen->window,
224       tv_screen->gc, 0, 0, tv_screen->width, tv_screen->height, 0, 0);
225 }
226 
227 void tv_screen_double_buffer_start(Tv_screen *tv_screen)
228 {
229   /* Not implemented in the Xview/Motif wrappers. */
230 }
231 
232 void tv_screen_double_buffer_end(Tv_screen *tv_screen)
233 {
234   /* Not implemented in the Xview/Motif wrappers. */
235 }
236 

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