1 | #ifndef fl_draw_H |
---|
2 | #define fl_draw_H |
---|
3 | |
---|
4 | #include "Enumerations.H" |
---|
5 | #include <fltk/draw.h> |
---|
6 | |
---|
7 | inline void fl_color(fltk::Color c) {fltk::setcolor(c);} |
---|
8 | inline void fl_color(uchar r, uchar g, uchar b) {fltk::setcolor(fltk::color(r,g,b));} |
---|
9 | inline fltk::Color fl_color() {return fltk::getcolor();} |
---|
10 | |
---|
11 | // clip: |
---|
12 | inline 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 |
---|
15 | inline int fl_not_clipped(int x, int y, int w, int h) {return fltk::not_clipped(fltk::Rectangle(x,y,w,h));} |
---|
16 | inline 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: |
---|
24 | inline 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 |
---|
28 | enum { |
---|
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: |
---|
43 | inline void fl_rect(int x, int y, int w, int h) {fltk::strokerect(fltk::Rectangle(x,y,w,h));} |
---|
44 | inline 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));} |
---|
45 | inline void fl_rectf(int x, int y, int w, int h) {fltk::fillrect(fltk::Rectangle(x,y,w,h));} |
---|
46 | inline 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: |
---|
49 | inline void fl_line(int x0,int y0, int x1,int y1) {fltk::drawline(x0,y0,x1,y1);} |
---|
50 | inline 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: |
---|
58 | inline 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 | } |
---|
65 | inline 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 |
---|
75 | inline 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 | } |
---|
82 | inline 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: |
---|
92 | inline void fl_xyline(int x, int y, int x1) { |
---|
93 | fltk::drawline(x,y,x1,y); |
---|
94 | } |
---|
95 | inline 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 | } |
---|
101 | inline 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: |
---|
110 | inline void fl_yxline(int x, int y, int y1) { |
---|
111 | fltk::drawline(x,y,x,y1); |
---|
112 | } |
---|
113 | inline 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 | } |
---|
119 | inline 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 | |
---|
127 | inline 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();} |
---|
128 | inline 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();} |
---|
129 | inline 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 |
---|
144 | inline 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 |
---|
148 | inline 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) |
---|
155 | inline void fl_font(fltk::Font* f, float size) {fltk::setfont(f,size);} |
---|
156 | inline void fl_font(int f, float size) {fltk::setfont(fltk::font(f),size);} |
---|
157 | inline fltk::Font* fl_font() {return fltk::getfont();} |
---|
158 | inline float fl_size() {return fltk::getsize();} |
---|
159 | |
---|
160 | // information you can get about the current font: |
---|
161 | inline float fl_height() {return fltk::getascent()+fltk::getdescent();} |
---|
162 | inline float fl_height(int, float size) {return size;} |
---|
163 | inline float fl_descent() {return fltk::getdescent();} |
---|
164 | inline float fl_width(const char* c) {return fltk::getwidth(c);} |
---|
165 | inline float fl_width(const char* c, int n) {return fltk::getwidth(c,n);} |
---|
166 | inline float fl_width(char c) {return fltk::getwidth(&c,1);} |
---|
167 | |
---|
168 | // draw using current font: |
---|
169 | inline void fl_draw(const char* s, int x, int y) {fltk::drawtext(s,x,y);} |
---|
170 | inline void fl_draw(const char* s, int n, int x, int y) {fltk::drawtext(s,n,x,y);} |
---|
171 | inline void fl_measure(const char* s, int& x, int& y) {fltk::measure(s,x,y);} |
---|
172 | inline 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: |
---|
182 | static inline fltk::PixelType fromdelta(int d) {return d==1?fltk::MONO:d==3?fltk::RGB:fltk::RGBx;} |
---|
183 | inline 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);} |
---|
184 | inline 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 | |
---|
186 | inline 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);} |
---|
187 | inline 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 | |
---|
189 | typedef fltk::DrawImageCallback Fl_Draw_Image_Cb; |
---|
190 | inline 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));} |
---|
191 | inline 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 | |
---|
193 | inline 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 | |
---|
195 | inline 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 | // |
---|