source: NonGTP/FLTK/include/fltk/draw.h @ 773

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

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

Line 
1// "$Id: draw.h 4408 2005-07-09 06:41:56Z spitzak $"
2//
3// Copyright 1998-2005 by Bill Spitzak and others.
4//
5// This library is free software; you can redistribute it and/or
6// modify it under the terms of the GNU Library General Public
7// License as published by the Free Software Foundation; either
8// version 2 of the License, or (at your option) any later version.
9//
10// This library is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13// Library General Public License for more details.
14//
15// You should have received a copy of the GNU Library General Public
16// License along with this library; if not, write to the Free Software
17// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
18// USA.
19//
20// Please report all bugs and problems to "fltk-bugs@fltk.org".
21
22#ifndef fltk_draw_h
23#define fltk_draw_h
24
25#include "Flags.h" // for alignment values
26#include "Color.h"
27#include "Rectangle.h"
28#include "PixelType.h"
29
30namespace fltk {
31
32struct Font;
33class Style;
34
35class FL_API GSave {
36  void* data[4]; // hopefully big enough for everybody...
37 public:
38  GSave();
39  ~GSave();
40};
41
42/*! \addtogroup transformation
43  \{ */
44FL_API void push_matrix();
45FL_API void pop_matrix();
46FL_API void scale(float x, float y);
47FL_API void scale(float x);
48FL_API void translate(float x, float y);
49FL_API void translate(int x, int y);
50FL_API void rotate(float d);
51FL_API void concat(float, float, float, float, float, float);
52FL_API void load_identity();
53
54// get and use transformed positions:
55FL_API void transform(float& x, float& y);
56FL_API void transform_distance(float& x, float& y);
57FL_API void transform(int& x, int& y);
58FL_API void transform(Rectangle&);
59
60/*! \} */
61
62/*! \addtogroup clipping
63  \{ */
64FL_API void push_clip(const Rectangle&);
65FL_API void clipout(const Rectangle&);
66FL_API void pop_clip();
67FL_API void push_no_clip();
68FL_API bool not_clipped(const Rectangle&);
69FL_API int intersect_with_clip(Rectangle&);
70/*! \} */
71
72/*! \addtogroup color
73  \{ */
74FL_API void setcolor(Color);
75extern FL_API Color current_color_;
76inline Color getcolor() {return current_color_;}
77extern FL_API Color current_bgcolor_;
78inline void setbgcolor(Color c) {current_bgcolor_ = c;}
79inline Color getbgcolor() {return current_bgcolor_;}
80
81extern const Style* drawstyle_;
82void FL_API drawstyle(const Style* s, Flags);
83inline const Style* drawstyle() {return drawstyle_;}
84
85extern Flags drawflags_;
86inline void setdrawflags(Flags f) {drawflags_ = f;}
87inline Flags drawflags() {return drawflags_;}
88inline Flags drawflags(Flags f) {return drawflags_ & f;}
89
90// line type:
91FL_API void line_style(int, int width=0, char* dashes=0);
92enum {
93  SOLID = 0,
94  DASH  = 1,
95  DOT   = 2,
96  DASHDOT       = 3,
97  DASHDOTDOT    = 4,
98
99  CAP_FLAT      = 0x100,
100  CAP_ROUND     = 0x200,
101  CAP_SQUARE    = 0x300,
102
103  JOIN_MITER    = 0x1000,
104  JOIN_ROUND    = 0x2000,
105  JOIN_BEVEL    = 0x3000
106};
107/*! \} */
108
109/*! \addtogroup path
110  \{ */
111FL_API void newpath();
112FL_API void addvertex(float x, float y);
113FL_API void addvertex(int x, int y);
114FL_API void addvertices(int n, const float v[][2]);
115FL_API void addvertices(int n, const int v[][2]);
116FL_API void addvertices_transformed(int n, const float v[][2]);
117FL_API void addcurve(float,float, float,float, float,float, float,float);
118FL_API void addarc(float x,float y,float w,float h, float a1, float a2);
119FL_API void addpie(const Rectangle& r, float a, float a2);
120FL_API void addchord(const Rectangle& r,float a,float a2);
121FL_API void closepath();
122
123FL_API void drawpoints();
124FL_API void strokepath();
125FL_API void fillpath();
126FL_API void fillstrokepath(Color);
127/*! \} */
128
129/*! \addtogroup rectangle
130  \{ */
131FL_API void fillrect(const Rectangle&);
132FL_API void strokerect(const Rectangle&);
133FL_API void drawpoint(int x, int y);
134FL_API void drawpoint(float x, float y);
135FL_API void drawline(int x0, int y0, int x1, int y1);
136FL_API void drawline(float x0, float y0, float x1, float y1);
137/*! \} */
138
139/*! \addtogroup font
140  \{ */
141FL_API void setfont(Font*, float size);
142FL_API void setfont(const char*, float size);
143FL_API void setfont(const char*, int attributes, float size);
144
145// change the encoding used to draw bytes (depreciated)
146extern FL_API const char* encoding_;
147inline const char* get_encoding() {return encoding_;}
148FL_API void set_encoding(const char*);
149
150// information you can get about the current font+size+encoding:
151extern FL_API Font* current_font_;
152extern FL_API float current_size_; // should be 2x2 transformation matrix
153inline Font* getfont() {return current_font_;}
154inline float getsize() {return current_size_;}
155
156// measure things in the current font:
157FL_API float getwidth(const char*);
158FL_API float getwidth(const char*, int length);
159FL_API float getascent();
160FL_API float getdescent();
161
162// draw using current font:
163FL_API void drawtext_transformed(const char*, int n, float x, float y);
164FL_API void drawtext(const char*, float x, float y);
165FL_API void drawtext(const char*, int length, float x, float y);
166
167// the label text formatter:
168FL_API void measure(const char*, int& w, int& h, Flags = 0);
169FL_API void measure(const char*, int length, int& w, int& h, Flags);
170FL_API void drawtext(const char*, const Rectangle&, Flags);
171FL_API void drawtext(const char*, int length, const Rectangle&, Flags);
172// set where \t characters go in label text formatter:
173extern FL_API const int* column_widths_;
174inline const int* column_widths() {return column_widths_;}
175inline void column_widths(const int* i) {column_widths_ = i;}
176// see also Symbol.h for @-sign commands
177/*! \} */
178
179/*! \addtogroup images
180  \{ */
181FL_API void drawimage(const uchar*, PixelType, const Rectangle&);
182FL_API void drawimage(const uchar*, PixelType, const Rectangle&, int linedelta);
183
184typedef const uchar* (*DrawImageCallback)(void* data, int x, int y, int w, uchar* buffer);
185FL_API void drawimage(DrawImageCallback, void*, PixelType, const Rectangle&);
186
187FL_API uchar *readimage(uchar *p, PixelType, const Rectangle&);
188FL_API uchar *readimage(uchar *p, PixelType, const Rectangle&, int linedelta);
189/*! \} */
190
191FL_API void scrollrect(const Rectangle&, int dx, int dy,
192                       void (*draw_area)(void*, const Rectangle&), void*);
193
194// depreciated:
195FL_API int draw_xpm(const char*const* data, int x, int y);
196FL_API int measure_xpm(const char*const* data, int &w, int &h);
197FL_API void overlay_rect(int,int,int,int);
198FL_API void overlay_clear();
199//FL_API int draw_symbol(const char* label, int x,int y,int w,int h, Color);
200
201}
202
203#endif
204
205//
206// End of "$Id: draw.h 4408 2005-07-09 06:41:56Z spitzak $".
207//
Note: See TracBrowser for help on using the repository browser.