~ubuntu-branches/ubuntu/karmic/fltk1.1/karmic

« back to all changes in this revision

Viewing changes to src/fl_vertex.cxx

  • Committer: Bazaar Package Importer
  • Author(s): Aaron M. Ucko
  • Date: 2005-05-22 13:57:06 UTC
  • mfrom: (2.1.1 hoary)
  • Revision ID: james.westby@ubuntu.com-20050522135706-mchag24yf42lu7bu
Tags: 1.1.6-5
* Revert previous change, which seems to have been ineffective for some
  reason, in favor of commenting out the problematic Makefile rule
  altogether.  (Closes: #310151.)
* debian/control: Go back to specifying the URL as part of the
  description rather than via a non-standard field that doesn't seem to
  have caught on.  (Closes: #310240.)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
//
2
 
// "$Id: fl_vertex.cxx,v 1.5.2.3.2.8 2004/04/11 04:39:00 easysw Exp $"
 
2
// "$Id: fl_vertex.cxx,v 1.5.2.3.2.12 2004/08/31 22:00:49 matthiaswm Exp $"
3
3
//
4
4
// Portable drawing routines for the Fast Light Tool Kit (FLTK).
5
5
//
26
26
// Portable drawing code for drawing arbitrary shapes with
27
27
// simple 2D transformations.  See also fl_arc.cxx
28
28
 
 
29
// matt: the Quartz implementation purposly doesn't use the Quartz matrix
 
30
//       operations for reasons of compatibility and maintainability
 
31
 
 
32
#include <config.h>
29
33
#include <FL/fl_draw.H>
30
34
#include <FL/x.H>
31
35
#include <FL/math.h>
71
75
  }
72
76
}
73
77
 
74
 
static XPoint *p = (XPoint *)0;
75
78
// typedef what the x,y fields in a point are:
76
79
#ifdef WIN32
77
80
typedef int COORD_T;
 
81
#  define XPOINT XPoint
 
82
#elif defined(__APPLE_QUARTZ__)
 
83
typedef float COORD_T;
 
84
typedef struct { float x; float y; } QPoint;
 
85
#  define XPOINT QPoint
 
86
extern float fl_quartz_line_width_;
78
87
#else
79
88
typedef short COORD_T;
 
89
#  define XPOINT XPoint
80
90
#endif
81
91
 
 
92
static XPOINT *p = (XPOINT *)0;
 
93
 
82
94
static int p_size;
83
95
static int n;
84
96
static int what;
104
116
  if (!n || x != p[n-1].x || y != p[n-1].y) {
105
117
    if (n >= p_size) {
106
118
      p_size = p ? 2*p_size : 16;
107
 
      p = (XPoint *)realloc((void*)p, p_size*sizeof(*p));
 
119
      p = (XPOINT*)realloc((void*)p, p_size*sizeof(*p));
108
120
    }
109
121
    p[n].x = x;
110
122
    p[n].y = y;
113
125
}
114
126
 
115
127
void fl_transformed_vertex(double xf, double yf) {
 
128
#ifdef __APPLE_QUARTZ__
 
129
  fl_transformed_vertex(COORD_T(xf), COORD_T(yf));
 
130
#else
116
131
  fl_transformed_vertex(COORD_T(rint(xf)), COORD_T(rint(yf)));
 
132
#endif
117
133
}
118
134
 
119
135
void fl_vertex(double x,double y) {
123
139
void fl_end_points() {
124
140
#ifdef WIN32
125
141
  for (int i=0; i<n; i++) SetPixel(fl_gc, p[i].x, p[i].y, fl_RGB());
126
 
#elif defined(__APPLE__)
 
142
#elif defined(__APPLE_QD__)
127
143
  for (int i=0; i<n; i++) { MoveTo(p[i].x, p[i].y); Line(0, 0); } 
 
144
#elif defined(__APPLE_QUARTZ__)
 
145
  if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, false);
 
146
  for (int i=0; i<n; i++) { 
 
147
    CGContextMoveToPoint(fl_gc, p[i].x, p[i].y);
 
148
    CGContextAddLineToPoint(fl_gc, p[i].x, p[i].y);
 
149
    CGContextStrokePath(fl_gc);
 
150
  }
 
151
  if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, false);
128
152
#else
129
153
  if (n>1) XDrawPoints(fl_display, fl_window, fl_gc, p, n, 0);
130
154
#endif
137
161
  }
138
162
#ifdef WIN32
139
163
  if (n>1) Polyline(fl_gc, p, n);
140
 
#elif defined(__APPLE__)
 
164
#elif defined(__APPLE_QD__)
141
165
  if (n<=1) return;
142
166
  MoveTo(p[0].x, p[0].y);
143
167
  for (int i=1; i<n; i++) LineTo(p[i].x, p[i].y);
 
168
#elif defined(__APPLE_QUARTZ__)
 
169
  if (n<=1) return;
 
170
  CGContextMoveToPoint(fl_gc, p[0].x, p[0].y);
 
171
  for (int i=1; i<n; i++)
 
172
    CGContextAddLineToPoint(fl_gc, p[i].x, p[i].y);
 
173
  CGContextStrokePath(fl_gc);
144
174
#else
145
175
  if (n>1) XDrawLines(fl_display, fl_window, fl_gc, p, n, 0);
146
176
#endif
167
197
    SelectObject(fl_gc, fl_brush());
168
198
    Polygon(fl_gc, p, n);
169
199
  }
170
 
#elif defined(__APPLE__)
 
200
#elif defined(__APPLE_QD__)
171
201
  if (n<=1) return;
172
202
  PolyHandle ph = OpenPoly();
173
203
  MoveTo(p[0].x, p[0].y);
175
205
  ClosePoly();
176
206
  PaintPoly(ph);
177
207
  KillPoly(ph);
 
208
#elif defined(__APPLE_QUARTZ__)
 
209
  if (n<=1) return;
 
210
  CGContextMoveToPoint(fl_gc, p[0].x, p[0].y);
 
211
  for (int i=1; i<n; i++) 
 
212
    CGContextAddLineToPoint(fl_gc, p[i].x, p[i].y);
 
213
  CGContextClosePath(fl_gc);
 
214
  CGContextFillPath(fl_gc);
178
215
#else
179
216
  if (n>2) XFillPolygon(fl_display, fl_window, fl_gc, p, n, Convex, 0);
180
217
#endif
218
255
    SelectObject(fl_gc, fl_brush());
219
256
    PolyPolygon(fl_gc, p, counts, numcount);
220
257
  }
221
 
#elif defined(__APPLE__)
 
258
#elif defined(__APPLE_QD__)
222
259
  if (n<=1) return;
223
260
  PolyHandle ph = OpenPoly();
224
261
  MoveTo(p[0].x, p[0].y);
226
263
  ClosePoly();
227
264
  PaintPoly(ph);
228
265
  KillPoly(ph);
 
266
#elif defined(__APPLE_QUARTZ__)
 
267
  if (n<=1) return;
 
268
  CGContextMoveToPoint(fl_gc, p[0].x, p[0].y);
 
269
  for (int i=1; i<n; i++)
 
270
    CGContextAddLineToPoint(fl_gc, p[i].x, p[i].y);
 
271
  CGContextClosePath(fl_gc);
 
272
  CGContextFillPath(fl_gc);
229
273
#else
230
274
  if (n>2) XFillPolygon(fl_display, fl_window, fl_gc, p, n, 0, 0);
231
275
#endif
250
294
    Pie(fl_gc, llx, lly, llx+w, lly+h, 0,0, 0,0); 
251
295
  } else
252
296
    Arc(fl_gc, llx, lly, llx+w, lly+h, 0,0, 0,0); 
253
 
#elif defined(__APPLE__)
 
297
#elif defined(__APPLE_QD__)
254
298
  Rect rt; rt.left=llx; rt.right=llx+w; rt.top=lly; rt.bottom=lly+h;
255
299
  (what == POLYGON ? PaintOval : FrameOval)(&rt);
 
300
#elif defined(__APPLE_QUARTZ__)
 
301
  // Quartz warning : circle won't scale to current matrix!
 
302
  CGContextAddArc(fl_gc, xt, yt, (w+h)*0.25f, 0, 2.0f*M_PI, 1);
 
303
  (what == POLYGON ? CGContextFillPath : CGContextStrokePath)(fl_gc);
256
304
#else
257
305
  (what == POLYGON ? XFillArc : XDrawArc)
258
306
    (fl_display, fl_window, fl_gc, llx, lly, w, h, 0, 360*64);
260
308
}
261
309
 
262
310
//
263
 
// End of "$Id: fl_vertex.cxx,v 1.5.2.3.2.8 2004/04/11 04:39:00 easysw Exp $".
 
311
// End of "$Id: fl_vertex.cxx,v 1.5.2.3.2.12 2004/08/31 22:00:49 matthiaswm Exp $".
264
312
//