source: NonGTP/FLTK/include/FL/fl_draw.H @ 773

Revision 773, 8.3 KB checked in by gumbau, 19 years ago (diff)

FLTK imported to SVN repository to be linked agains the GeoTool? application

Line 
1#ifndef fl_draw_H
2#define fl_draw_H
3
4#include "Enumerations.H"
5#include <fltk/draw.h>
6
7inline void fl_color(fltk::Color c) {fltk::setcolor(c);}
8inline void fl_color(uchar r, uchar g, uchar b) {fltk::setcolor(fltk::color(r,g,b));}
9inline fltk::Color fl_color() {return fltk::getcolor();}
10
11// clip:
12inline void fl_push_clip(int x, int y, int w, int h) {fltk::push_clip(fltk::Rectangle(x,y,w,h));}
13#define fl_clip         fl_push_clip
14#define fl_pop_clip     fltk::pop_clip
15inline int fl_not_clipped(int x, int y, int w, int h) {return fltk::not_clipped(fltk::Rectangle(x,y,w,h));}
16inline int fl_clip_box(int X, int Y, int W, int H, int& x, int& y, int& w, int& h) {
17  fltk::Rectangle r(X,Y,W,H);
18  int i = intersect_with_clip(r);
19  x = r.x(); y = r.y(); w = r.w(); h = r.h();
20  return i;
21}
22
23// points:
24inline void fl_point(int x, int y) {fltk::addvertex(x,y); fltk::drawpoints();}
25
26// line type:
27#define fl_line_style   fltk::line_style
28enum {
29  FL_SOLID      = fltk::SOLID,
30  FL_DASH       = fltk::DASH,
31  FL_DOT        = fltk::DOT,
32  FL_DASHDOT    = fltk::DASHDOT,
33  FL_DASHDOTDOT = fltk::DASHDOTDOT,
34  FL_CAP_FLAT   = fltk::CAP_FLAT,
35  FL_CAP_ROUND  = fltk::CAP_ROUND,
36  FL_CAP_SQUARE = fltk::CAP_SQUARE,
37  FL_JOIN_MITER = fltk::JOIN_MITER,
38  FL_JOIN_ROUND = fltk::JOIN_ROUND,
39  FL_JOIN_BEVEL = fltk::JOIN_BEVEL
40};
41
42// rectangles tweaked to exactly fill the pixel rectangle:
43inline void fl_rect(int x, int y, int w, int h) {fltk::strokerect(fltk::Rectangle(x,y,w,h));}
44inline void fl_rect(int x, int y, int w, int h, fltk::Color c) {fltk::setcolor(c); fltk::strokerect(fltk::Rectangle(x,y,w,h));}
45inline void fl_rectf(int x, int y, int w, int h) {fltk::fillrect(fltk::Rectangle(x,y,w,h));}
46inline void fl_rectf(int x, int y, int w, int h, fltk::Color c) {fltk::setcolor(c); fltk::fillrect(fltk::Rectangle(x,y,w,h));}
47
48// line segments:
49inline void fl_line(int x0,int y0, int x1,int y1) {fltk::drawline(x0,y0,x1,y1);}
50inline void fl_line(int x0,int y0, int x1,int y1, int x2,int y2) {
51  fltk::addvertex(x0,y0);
52  fltk::addvertex(x1,y1);
53  fltk::addvertex(x2,y2);
54  fltk::strokepath();
55}
56
57// closed line segments:
58inline void fl_loop(int x0,int y0, int x1,int y1, int x2,int y2) {
59  fltk::addvertex(x0,y0);
60  fltk::addvertex(x1,y1);
61  fltk::addvertex(x2,y2);
62  fltk::closepath();
63  fltk::strokepath();
64}
65inline void fl_loop(int x0,int y0, int x1,int y1, int x2,int y2, int x3,int y3) {
66  fltk::addvertex(x0,y0);
67  fltk::addvertex(x1,y1);
68  fltk::addvertex(x2,y2);
69  fltk::addvertex(x3,y3);
70  fltk::closepath();
71  fltk::strokepath();
72}
73
74// filled polygons
75inline void fl_polygon(int x0,int y0, int x1,int y1, int x2,int y2) {
76  fltk::addvertex(x0,y0);
77  fltk::addvertex(x1,y1);
78  fltk::addvertex(x2,y2);
79  fltk::closepath();
80  fltk::fillpath();
81}
82inline void fl_polygon(int x0,int y0, int x1,int y1, int x2,int y2, int x3,int y3) {
83  fltk::addvertex(x0,y0);
84  fltk::addvertex(x1,y1);
85  fltk::addvertex(x2,y2);
86  fltk::addvertex(x3,y3);
87  fltk::closepath();
88  fltk::fillpath();
89}
90
91// draw rectilinear lines, horizontal segment first:
92inline void fl_xyline(int x, int y, int x1) {
93  fltk::drawline(x,y,x1,y);
94}
95inline void fl_xyline(int x, int y, int x1, int y2) {
96  fltk::addvertex(x,y);
97  fltk::addvertex(x1,y);
98  fltk::addvertex(x1,y2);
99  fltk::strokepath();
100}
101inline void fl_xyline(int x, int y, int x1, int y2, int x3) {
102  fltk::addvertex(x,y);
103  fltk::addvertex(x1,y);
104  fltk::addvertex(x1,y2);
105  fltk::addvertex(x3,y2);
106  fltk::strokepath();
107}
108
109// draw rectilinear lines, vertical segment first:
110inline void fl_yxline(int x, int y, int y1) {
111  fltk::drawline(x,y,x,y1);
112}
113inline void fl_yxline(int x, int y, int y1, int x2) {
114  fltk::addvertex(x,y);
115  fltk::addvertex(x,y1);
116  fltk::addvertex(x2,y1);
117  fltk::strokepath();
118}
119inline void fl_yxline(int x, int y, int y1, int x2, int y3) {
120  fltk::addvertex(x,y);
121  fltk::addvertex(x,y1);
122  fltk::addvertex(x2,y1);
123  fltk::addvertex(x2,y3);
124  fltk::strokepath();
125}
126
127inline void fl_arc(int x,int y,int w,int h,float a,float a2) {fltk::addchord(fltk::Rectangle(x,y,w,h),a,a2); fltk::strokepath();}
128inline void fl_pie(int x,int y,int w,int h,float a,float a2) {fltk::addpie(fltk::Rectangle(x,y,w,h),a,a2); fltk::fillpath();}
129inline void fl_chord(int x,int y,int w,int h,float a,float a2) {fltk::addchord(fltk::Rectangle(x,y,w,h),a,a2); fltk::fillpath();}
130
131// scalable drawing code (code in fl_vertex.C and fl_arc.C):
132#define fl_push_matrix  fltk::push_matrix
133#define fl_pop_matrix   fltk::pop_matrix
134#define fl_scale        fltk::scale
135#define fl_translate    fltk::translate
136#define fl_rotate       fltk::rotate
137#define fl_mult_matrix  fltk::concat
138#define fl_begin_points fltk::newpath
139#define fl_begin_line   fltk::newpath
140#define fl_begin_loop   fltk::newpath
141#define fl_begin_polygon fltk::newpath
142#define fl_vertex       fltk::addvertex
143#define fl_curve        fltk::addcurve
144inline void fl_arc(float x,float y,float r, float a1, float a2) {fltk::addarc(x-r,y-r,2*r,2*r,a1,a2);}
145#define fl_circle       fltk::addcircle
146#define fl_end_points   fltk::drawpoints
147#define fl_end_line     fltk::strokepath
148inline void fl_end_loop() {fltk::closepath();fltk::strokepath();}
149#define fl_end_polygon  fltk::fillpath
150#define fl_begin_complex_polygon fltk::newpath
151#define fl_gap          fltk::closepath
152#define fl_end_complex_polygon  fltk::fillpath
153
154// current font: (size was an int in fltk1.1)
155inline void fl_font(fltk::Font* f, float size) {fltk::setfont(f,size);}
156inline void fl_font(int f, float size) {fltk::setfont(fltk::font(f),size);}
157inline fltk::Font* fl_font() {return fltk::getfont();}
158inline float fl_size() {return fltk::getsize();}
159
160// information you can get about the current font:
161inline float fl_height() {return fltk::getascent()+fltk::getdescent();}
162inline float fl_height(int, float size) {return size;}
163inline float fl_descent() {return fltk::getdescent();}
164inline float fl_width(const char* c) {return fltk::getwidth(c);}
165inline float fl_width(const char* c, int n) {return fltk::getwidth(c,n);}
166inline float fl_width(char c) {return fltk::getwidth(&c,1);}
167
168// draw using current font:
169inline void fl_draw(const char* s, int x, int y) {fltk::drawtext(s,x,y);}
170inline void fl_draw(const char* s, int n, int x, int y) {fltk::drawtext(s,n,x,y);}
171inline void fl_measure(const char* s, int& x, int& y) {fltk::measure(s,x,y);}
172inline void fl_draw(const char* s, int x,int y,int w,int h, fltk::Flags f) {fltk::drawtext(s,fltk::Rectangle(x,y,w,h),f);}
173
174// boxtypes:
175//void fl_frame(const char* s, int x, int y, int w, int h);
176//void fl_frame2(const char* s, int x, int y, int w, int h);
177// This no longer works because boxes take a style, not a color:
178//  #include <fltk/Box.h>
179//  inline void fl_draw_box(fltk::Box* b, int x, int y, int w, int h, fltk::Color c) {b->draw(x,y,w,h,c);}
180
181// images:
182static inline fltk::PixelType fromdelta(int d) {return d==1?fltk::MONO:d==3?fltk::RGB:fltk::RGBx;}
183inline void fl_draw_image(const uchar* p, int x,int y,int w,int h, int delta, int ldelta) {fltk::drawimage(p,fromdelta(delta),fltk::Rectangle(x,y,w,h),ldelta);}
184inline void fl_draw_image(const uchar* p, int x,int y,int w,int h, int delta) {fltk::drawimage(p,fromdelta(delta),fltk::Rectangle(x,y,w,h));}
185
186inline void fl_draw_image_mono(const uchar* p, int x,int y,int w,int h, int delta, int ldelta) {fltk::drawimage(p,fltk::MONO,fltk::Rectangle(x,y,w,h),ldelta);}
187inline void fl_draw_image_mono(const uchar* p, int x,int y,int w,int h, int delta=1) {fltk::drawimage(p,fltk::MONO,fltk::Rectangle(x,y,w,h));}
188
189typedef fltk::DrawImageCallback Fl_Draw_Image_Cb;
190inline void fl_draw_image(Fl_Draw_Image_Cb cb, void* p, int x,int y,int w,int h, int delta=3) {fltk::drawimage(cb,p,fromdelta(delta),fltk::Rectangle(x,y,w,h));}
191inline void fl_draw_image_mono(Fl_Draw_Image_Cb cb, void* p, int x,int y,int w,int h, int delta=1) {fltk::drawimage(cb,p,fltk::MONO,fltk::Rectangle(x,y,w,h));}
192
193inline uchar *fl_read_image(uchar *p, int x,int y, int w, int h, int alpha=0) {return fltk::readimage(p, alpha?fltk::RGBA:fltk::RGB, fltk::Rectangle(x,y,w,h));}
194
195inline void fl_rectf(int x, int y, int w, int h, uchar r, uchar g, uchar b) {fltk::setcolor(fltk::color(r,g,b)); fltk::fillrect(fltk::Rectangle(x,y,w,h));}
196
197#define fl_draw_pixmap          fltk::draw_xpm
198#define fl_measure_pixmap       fltk::measure_xpm
199#define fl_scroll               fltk::scrollrect
200#define fl_shortcut_label       fltk::key_name
201#define fl_overlay_rect         fltk::overlay_rect
202#define fl_overlay_clear        fltk::overlay_clear
203#define fl_draw_symbol          fltk::draw_symbol
204#define fl_add_symbol           fltk::add_symbol
205
206#endif
207
208//
209// End of "$Id: fl_draw.H 4408 2005-07-09 06:41:56Z spitzak $".
210//
Note: See TracBrowser for help on using the repository browser.