DRC | 2ff39b8 | 2011-07-28 08:38:59 +0000 | [diff] [blame] | 1 | // |
| 2 | // "$Id: Fl_Device.H 8529 2011-03-23 12:49:30Z AlbrechtS $" |
| 3 | // |
| 4 | // Definition of classes Fl_Device, Fl_Graphics_Driver, Fl_Surface_Device, Fl_Display_Device |
| 5 | // for the Fast Light Tool Kit (FLTK). |
| 6 | // |
| 7 | // Copyright 2010-2011 by Bill Spitzak and others. |
| 8 | // |
| 9 | // This library is free software; you can redistribute it and/or |
| 10 | // modify it under the terms of the GNU Library General Public |
| 11 | // License as published by the Free Software Foundation; either |
| 12 | // version 2 of the License, or (at your option) any later version. |
| 13 | // |
| 14 | // This library is distributed in the hope that it will be useful, |
| 15 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 17 | // Library General Public License for more details. |
| 18 | // |
| 19 | // You should have received a copy of the GNU Library General Public |
| 20 | // License along with this library; if not, write to the Free Software |
| 21 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
| 22 | // USA. |
| 23 | // |
| 24 | // Please report all bugs and problems on the following page: |
| 25 | // |
| 26 | // http://www.fltk.org/str.php |
| 27 | // |
| 28 | /** \file Fl_Device.H |
| 29 | \brief declaration of classes Fl_Device, Fl_Graphics_Driver, Fl_Surface_Device, |
| 30 | Fl_Display_Device, Fl_Device_Plugin. |
| 31 | */ |
| 32 | |
| 33 | #ifndef Fl_Device_H |
| 34 | #define Fl_Device_H |
| 35 | |
| 36 | #include <FL/x.H> |
| 37 | #include <FL/Fl_Plugin.H> |
| 38 | #include <FL/Fl_Image.H> |
| 39 | #include <FL/Fl_Bitmap.H> |
| 40 | #include <FL/Fl_Pixmap.H> |
| 41 | #include <FL/Fl_RGB_Image.H> |
| 42 | |
| 43 | class Fl_Graphics_Driver; |
| 44 | class Fl_Font_Descriptor; |
| 45 | /** \brief Points to the driver that currently receives all graphics requests */ |
| 46 | FL_EXPORT extern Fl_Graphics_Driver *fl_graphics_driver; |
| 47 | |
| 48 | /** |
| 49 | signature of image generation callback function. |
| 50 | \param[in] data user data passed to function |
| 51 | \param[in] x,y,w position and width of scan line in image |
| 52 | \param[out] buf buffer for generated image data. You must copy \p w |
| 53 | pixels from scanline \p y, starting at pixel \p x |
| 54 | to this buffer. |
| 55 | */ |
| 56 | typedef void (*Fl_Draw_Image_Cb)(void* data,int x,int y,int w,uchar* buf); |
| 57 | |
| 58 | // typedef what the x,y fields in a point are: |
| 59 | #ifdef WIN32 |
| 60 | typedef int COORD_T; |
| 61 | # define XPOINT XPoint |
| 62 | #elif defined(__APPLE__) |
| 63 | typedef float COORD_T; |
| 64 | typedef struct { float x; float y; } QPoint; |
| 65 | # define XPOINT QPoint |
| 66 | extern float fl_quartz_line_width_; |
| 67 | #else |
| 68 | typedef short COORD_T; |
| 69 | # define XPOINT XPoint |
| 70 | #endif |
| 71 | |
| 72 | /** |
| 73 | \brief All graphical output devices and all graphics systems. |
| 74 | */ |
| 75 | class FL_EXPORT Fl_Device { |
| 76 | public: |
| 77 | /** A string that identifies each subclass of Fl_Device. |
| 78 | Function class_name() applied to a device of this class returns this string. |
| 79 | */ |
| 80 | static const char *class_id; |
| 81 | /** |
| 82 | Returns the name of the class of this object. |
| 83 | The class of an instance of an Fl_Device subclass can be checked with code such as: |
| 84 | \code |
| 85 | if ( instance->class_name() == Fl_Printer::class_id ) { ... } |
| 86 | \endcode |
| 87 | */ |
| 88 | virtual const char *class_name() {return class_id;}; |
| 89 | /** |
| 90 | Virtual destructor. |
| 91 | |
| 92 | The destructor of Fl_Device must be virtual to make the destructors of |
| 93 | derived classes being called correctly on destruction. |
| 94 | */ |
| 95 | virtual ~Fl_Device() {}; |
| 96 | }; |
| 97 | |
| 98 | #define FL_REGION_STACK_SIZE 10 |
| 99 | #define FL_MATRIX_STACK_SIZE 32 |
| 100 | /** |
| 101 | \brief A virtual class subclassed for each graphics driver FLTK uses. |
| 102 | * |
| 103 | The virtual methods of this class are those that a graphics driver should implement to |
| 104 | support all of FLTK drawing functions. |
| 105 | <br> The public API for drawing operations is functionally presented in \ref drawing and as function lists |
| 106 | in the \ref fl_drawings and \ref fl_attributes modules. |
| 107 | */ |
| 108 | class FL_EXPORT Fl_Graphics_Driver : public Fl_Device { |
| 109 | public: |
| 110 | /** A 2D coordinate transformation matrix |
| 111 | */ |
| 112 | struct matrix {double a, b, c, d, x, y;}; |
| 113 | private: |
| 114 | static const matrix m0; |
| 115 | Fl_Font font_; // current font |
| 116 | Fl_Fontsize size_; // current font size |
| 117 | Fl_Color color_; // current color |
| 118 | enum {LINE, LOOP, POLYGON, POINT_}; |
| 119 | int sptr; |
| 120 | static const int matrix_stack_size = FL_MATRIX_STACK_SIZE; |
| 121 | matrix stack[FL_MATRIX_STACK_SIZE]; |
| 122 | matrix m; |
| 123 | int n, p_size, gap_; |
| 124 | XPOINT *p; |
| 125 | int what; |
| 126 | int fl_clip_state_number; |
| 127 | int rstackptr; |
| 128 | static const int region_stack_max = FL_REGION_STACK_SIZE - 1; |
| 129 | Fl_Region rstack[FL_REGION_STACK_SIZE]; |
| 130 | #ifdef WIN32 |
| 131 | int numcount; |
| 132 | int counts[20]; |
| 133 | #endif |
| 134 | Fl_Font_Descriptor *font_descriptor_; |
| 135 | void transformed_vertex0(COORD_T x, COORD_T y); |
| 136 | void fixloop(); |
| 137 | |
| 138 | protected: |
| 139 | /* ** \brief red color for background and/or mixing if device does not support masking or alpha * |
| 140 | uchar bg_r_; |
| 141 | ** \brief green color for background and/or mixing if device does not support masking or alpha * |
| 142 | uchar bg_g_; |
| 143 | ** \brief blue color for background and/or mixing if device does not support masking or alpha * |
| 144 | uchar bg_b_; */ |
| 145 | friend class Fl_Pixmap; |
| 146 | friend class Fl_Bitmap; |
| 147 | friend class Fl_RGB_Image; |
| 148 | friend void fl_rect(int x, int y, int w, int h); |
| 149 | friend void fl_rectf(int x, int y, int w, int h); |
| 150 | friend void fl_line_style(int style, int width, char* dashes); |
| 151 | friend void fl_xyline(int x, int y, int x1); |
| 152 | friend void fl_xyline(int x, int y, int x1, int y2); |
| 153 | friend void fl_xyline(int x, int y, int x1, int y2, int x3); |
| 154 | friend void fl_yxline(int x, int y, int y1); |
| 155 | friend void fl_yxline(int x, int y, int y1, int x2); |
| 156 | friend void fl_yxline(int x, int y, int y1, int x2, int y3); |
| 157 | friend void fl_line(int x, int y, int x1, int y1); |
| 158 | friend void fl_line(int x, int y, int x1, int y1, int x2, int y2); |
| 159 | friend void fl_draw(const char *str, int n, int x, int y); |
| 160 | #ifdef __APPLE__ |
| 161 | friend void fl_draw(const char *str, int n, float x, float y); |
| 162 | #endif |
| 163 | friend void fl_draw(int angle, const char *str, int n, int x, int y); |
| 164 | friend void fl_rtl_draw(const char *str, int n, int x, int y); |
| 165 | friend void fl_font(Fl_Font face, Fl_Fontsize size); |
| 166 | friend void fl_color(Fl_Color c); |
| 167 | friend void fl_color(uchar r, uchar g, uchar b); |
| 168 | friend void fl_point(int x, int y); |
| 169 | friend void fl_loop(int x0, int y0, int x1, int y1, int x2, int y2); |
| 170 | friend void fl_loop(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3); |
| 171 | friend void fl_polygon(int x0, int y0, int x1, int y1, int x2, int y2); |
| 172 | friend void fl_polygon(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3); |
| 173 | friend void fl_begin_points(); |
| 174 | friend void fl_begin_line(); |
| 175 | friend void fl_begin_loop(); |
| 176 | friend void fl_begin_polygon(); |
| 177 | friend void fl_vertex(double x, double y); |
| 178 | friend void fl_curve(double X0, double Y0, double X1, double Y1, double X2, double Y2, double X3, double Y3); |
| 179 | friend void fl_circle(double x, double y, double r); |
| 180 | friend void fl_arc(double x, double y, double r, double start, double end); |
| 181 | friend void fl_arc(int x, int y, int w, int h, double a1, double a2); |
| 182 | friend void fl_pie(int x, int y, int w, int h, double a1, double a2); |
| 183 | friend void fl_end_points(); |
| 184 | friend void fl_end_line(); |
| 185 | friend void fl_end_loop(); |
| 186 | friend void fl_end_polygon(); |
| 187 | friend void fl_transformed_vertex(double xf, double yf); |
| 188 | friend void fl_push_clip(int x, int y, int w, int h); |
| 189 | friend int fl_clip_box(int x, int y, int w, int h, int &X, int &Y, int &W, int &H); |
| 190 | friend int fl_not_clipped(int x, int y, int w, int h); |
| 191 | friend void fl_push_no_clip(); |
| 192 | friend void fl_pop_clip(); |
| 193 | friend void fl_begin_complex_polygon(); |
| 194 | friend void fl_gap(); |
| 195 | friend void fl_end_complex_polygon(); |
| 196 | friend void fl_push_matrix(); |
| 197 | friend void fl_pop_matrix(); |
| 198 | friend void fl_mult_matrix(double a, double b, double c, double d, double x, double y); |
| 199 | friend void fl_scale(double x, double y); |
| 200 | friend void fl_scale(double x); |
| 201 | friend void fl_translate(double x, double y); |
| 202 | friend void fl_rotate(double d); |
| 203 | friend double fl_transform_x(double x, double y); |
| 204 | friend double fl_transform_y(double x, double y); |
| 205 | friend double fl_transform_dx(double x, double y); |
| 206 | friend double fl_transform_dy(double x, double y); |
| 207 | friend Fl_Region fl_clip_region(); |
| 208 | friend void fl_clip_region(Fl_Region r); |
| 209 | friend void fl_restore_clip(); |
| 210 | |
| 211 | friend void fl_draw_image(const uchar* buf, int X,int Y,int W,int H, int D, int L); |
| 212 | friend void fl_draw_image_mono(const uchar* buf, int X,int Y,int W,int H, int D, int L); |
| 213 | friend void fl_draw_image(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D); |
| 214 | friend FL_EXPORT void fl_draw_image_mono(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D); |
| 215 | friend FL_EXPORT void gl_start(); |
| 216 | |
| 217 | matrix *fl_matrix; /**< Points to the current coordinate transformation matrix */ |
| 218 | |
| 219 | /** \brief The constructor. */ |
| 220 | Fl_Graphics_Driver(); |
| 221 | /** \brief see fl_rect(int x, int y, int w, int h). */ |
| 222 | virtual void rect(int x, int y, int w, int h); |
| 223 | /** \brief see fl_rectf(int x, int y, int w, int h). */ |
| 224 | virtual void rectf(int x, int y, int w, int h); |
| 225 | /** \brief see fl_line_style(int style, int width, char* dashes). */ |
| 226 | virtual void line_style(int style, int width=0, char* dashes=0); |
| 227 | /** \brief see fl_xyline(int x, int y, int x1). */ |
| 228 | virtual void xyline(int x, int y, int x1); |
| 229 | /** \brief see fl_xyline(int x, int y, int x1, int y2). */ |
| 230 | virtual void xyline(int x, int y, int x1, int y2); |
| 231 | /** \brief see fl_xyline(int x, int y, int x1, int y2, int x3). */ |
| 232 | virtual void xyline(int x, int y, int x1, int y2, int x3); |
| 233 | /** \brief see fl_yxline(int x, int y, int y1). */ |
| 234 | virtual void yxline(int x, int y, int y1); |
| 235 | /** \brief see fl_yxline(int x, int y, int y1, int x2). */ |
| 236 | virtual void yxline(int x, int y, int y1, int x2); |
| 237 | /** \brief see fl_yxline(int x, int y, int y1, int x2, int y3). */ |
| 238 | virtual void yxline(int x, int y, int y1, int x2, int y3); |
| 239 | /** \brief see fl_line(int x, int y, int x1, int y1). */ |
| 240 | virtual void line(int x, int y, int x1, int y1); |
| 241 | /** \brief see fl_line(int x, int y, int x1, int y1, int x2, int y2). */ |
| 242 | virtual void line(int x, int y, int x1, int y1, int x2, int y2); |
| 243 | /** \brief see fl_draw(const char *str, int n, int x, int y). */ |
| 244 | virtual void draw(const char *str, int n, int x, int y) = 0; |
| 245 | #ifdef __APPLE__ |
| 246 | virtual void draw(const char *str, int n, float x, float y) = 0; |
| 247 | #endif |
| 248 | /** \brief see fl_draw(int angle, const char *str, int n, int x, int y). */ |
| 249 | virtual void draw(int angle, const char *str, int n, int x, int y) = 0; |
| 250 | /** \brief see fl_rtl_draw(const char *str, int n, int x, int y). */ |
| 251 | virtual void rtl_draw(const char *str, int n, int x, int y) = 0; |
| 252 | /** \brief see fl_color(Fl_Color c). */ |
| 253 | virtual void color(Fl_Color c) {color_ = c;} |
| 254 | /** \brief see fl_color(uchar r, uchar g, uchar b). */ |
| 255 | virtual void color(uchar r, uchar g, uchar b) = 0; |
| 256 | /** \brief see fl_point(int x, int y). */ |
| 257 | virtual void point(int x, int y); |
| 258 | /** \brief see fl_loop(int x0, int y0, int x1, int y1, int x2, int y2). */ |
| 259 | virtual void loop(int x0, int y0, int x1, int y1, int x2, int y2); |
| 260 | /** \brief see fl_loop(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3). */ |
| 261 | virtual void loop(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3); |
| 262 | /** \brief see fl_polygon(int x0, int y0, int x1, int y1, int x2, int y2). */ |
| 263 | virtual void polygon(int x0, int y0, int x1, int y1, int x2, int y2); |
| 264 | /** \brief see fl_polygon(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3). */ |
| 265 | virtual void polygon(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3); |
| 266 | /** \brief see fl_begin_points(). */ |
| 267 | virtual void begin_points(); |
| 268 | /** \brief see fl_begin_line(). */ |
| 269 | virtual void begin_line(); |
| 270 | /** \brief see fl_begin_loop(). */ |
| 271 | virtual void begin_loop(); |
| 272 | /** \brief see fl_begin_polygon(). */ |
| 273 | virtual void begin_polygon(); |
| 274 | /** \brief see fl_vertex(double x, double y). */ |
| 275 | virtual void vertex(double x, double y); |
| 276 | /** \brief see fl_curve(double X0, double Y0, double X1, double Y1, double X2, double Y2, double X3, double Y3). */ |
| 277 | virtual void curve(double X0, double Y0, double X1, double Y1, double X2, double Y2, double X3, double Y3); |
| 278 | /** \brief see fl_circle(double x, double y, double r). */ |
| 279 | virtual void circle(double x, double y, double r); |
| 280 | /** \brief see fl_arc(double x, double y, double r, double start, double end). */ |
| 281 | virtual void arc(double x, double y, double r, double start, double end); |
| 282 | /** \brief see fl_arc(int x, int y, int w, int h, double a1, double a2). */ |
| 283 | virtual void arc(int x, int y, int w, int h, double a1, double a2); |
| 284 | /** \brief see fl_pie(int x, int y, int w, int h, double a1, double a2). */ |
| 285 | virtual void pie(int x, int y, int w, int h, double a1, double a2); |
| 286 | /** \brief see fl_end_points(). */ |
| 287 | virtual void end_points(); |
| 288 | /** \brief see fl_end_line(). */ |
| 289 | virtual void end_line(); |
| 290 | /** \brief see fl_end_loop(). */ |
| 291 | virtual void end_loop(); |
| 292 | /** \brief see fl_end_polygon(). */ |
| 293 | virtual void end_polygon(); |
| 294 | /** \brief see fl_begin_complex_polygon(). */ |
| 295 | virtual void begin_complex_polygon(); |
| 296 | /** \brief see fl_gap(). */ |
| 297 | virtual void gap(); |
| 298 | /** \brief see fl_end_complex_polygon(). */ |
| 299 | virtual void end_complex_polygon(); |
| 300 | /** \brief see fl_transformed_vertex(double xf, double yf). */ |
| 301 | virtual void transformed_vertex(double xf, double yf); |
| 302 | /** \brief see fl_push_clip(int x, int y, int w, int h). */ |
| 303 | virtual void push_clip(int x, int y, int w, int h); |
| 304 | /** \brief see fl_clip_box(int x, int y, int w, int h, int &X, int &Y, int &W, int &H). */ |
| 305 | virtual int clip_box(int x, int y, int w, int h, int &X, int &Y, int &W, int &H); |
| 306 | /** \brief see fl_not_clipped(int x, int y, int w, int h). */ |
| 307 | virtual int not_clipped(int x, int y, int w, int h); |
| 308 | /** \brief see fl_push_no_clip(). */ |
| 309 | virtual void push_no_clip(); |
| 310 | /** \brief see fl_pop_clip(). */ |
| 311 | virtual void pop_clip(); |
| 312 | |
| 313 | /** \brief see fl_push_matrix(). */ |
| 314 | void push_matrix(); |
| 315 | /** \brief see fl_pop_matrix(). */ |
| 316 | void pop_matrix(); |
| 317 | /** \brief see fl_mult_matrix(double a, double b, double c, double d, double x, double y). */ |
| 318 | void mult_matrix(double a, double b, double c, double d, double x, double y); |
| 319 | /** \brief see fl_scale(double x, double y). */ |
| 320 | inline void scale(double x, double y) { mult_matrix(x,0,0,y,0,0); } |
| 321 | /** \brief see fl_scale(double x). */ |
| 322 | inline void scale(double x) { mult_matrix(x,0,0,x,0,0); } |
| 323 | /** \brief see fl_translate(double x, double y). */ |
| 324 | inline void translate(double x,double y) { mult_matrix(1,0,0,1,x,y); } |
| 325 | /** \brief see fl_rotate(double d). */ |
| 326 | void rotate(double d); |
| 327 | /** \brief see fl_transform_x(double x, double y). */ |
| 328 | double transform_x(double x, double y); |
| 329 | /** \brief see fl_transform_y(double x, double y). */ |
| 330 | double transform_y(double x, double y); |
| 331 | /** \brief see fl_transform_dx(double x, double y). */ |
| 332 | double transform_dx(double x, double y); |
| 333 | /** \brief see fl_transform_dy(double x, double y). */ |
| 334 | double transform_dy(double x, double y); |
| 335 | /** \brief see fl_clip_region(). */ |
| 336 | Fl_Region clip_region(); |
| 337 | /** \brief see fl_clip_region(Fl_Region r). */ |
| 338 | void clip_region(Fl_Region r); |
| 339 | /** \brief see fl_restore_clip(). */ |
| 340 | void restore_clip(); |
| 341 | |
| 342 | // Images |
| 343 | /** \brief see fl_draw_image(const uchar* buf, int X,int Y,int W,int H, int D, int L). */ |
| 344 | virtual void draw_image(const uchar* buf, int X,int Y,int W,int H, int D=3, int L=0) = 0; |
| 345 | /** \brief see fl_draw_image_mono(const uchar* buf, int X,int Y,int W,int H, int D, int L). */ |
| 346 | virtual void draw_image_mono(const uchar* buf, int X,int Y,int W,int H, int D=1, int L=0) = 0; |
| 347 | /** \brief see fl_draw_image(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D). */ |
| 348 | virtual void draw_image(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=3) = 0; |
| 349 | /** \brief see fl_draw_image_mono(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D). */ |
| 350 | virtual void draw_image_mono(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=1) = 0; |
| 351 | // Image classes |
| 352 | /** \brief Draws an Fl_RGB_Image object to the device. |
| 353 | * |
| 354 | Specifies a bounding box for the image, with the origin (upper left-hand corner) of |
| 355 | the image offset by the cx and cy arguments. |
| 356 | */ |
| 357 | virtual void draw(Fl_RGB_Image * rgb,int XP, int YP, int WP, int HP, int cx, int cy) = 0; |
| 358 | /** \brief Draws an Fl_Pixmap object to the device. |
| 359 | * |
| 360 | Specifies a bounding box for the image, with the origin (upper left-hand corner) of |
| 361 | the image offset by the cx and cy arguments. |
| 362 | */ |
| 363 | virtual void draw(Fl_Pixmap * pxm,int XP, int YP, int WP, int HP, int cx, int cy) = 0; |
| 364 | /** \brief Draws an Fl_Bitmap object to the device. |
| 365 | * |
| 366 | Specifies a bounding box for the image, with the origin (upper left-hand corner) of |
| 367 | the image offset by the cx and cy arguments. |
| 368 | */ |
| 369 | virtual void draw(Fl_Bitmap *bm, int XP, int YP, int WP, int HP, int cx, int cy) = 0; |
| 370 | |
| 371 | public: |
| 372 | static const char *class_id; |
| 373 | virtual const char *class_name() {return class_id;}; |
| 374 | /** \brief see fl_font(Fl_Font face, Fl_Fontsize size). */ |
| 375 | virtual void font(Fl_Font face, Fl_Fontsize size) {font_ = face; size_ = size;} |
| 376 | /** \brief see fl_font(void). */ |
| 377 | Fl_Font font() {return font_; } |
| 378 | /** \brief see fl_size(). */ |
| 379 | Fl_Fontsize size() {return size_; } |
| 380 | /** \brief see fl_width(const char *str, int n). */ |
| 381 | virtual double width(const char *str, int n) = 0; |
| 382 | /** \brief see fl_width(unsigned int n). */ |
| 383 | virtual inline double width(unsigned int c) { char ch = (char)c; return width(&ch, 1); } |
| 384 | /** \brief see fl_text_extents(const char*, int n, int& dx, int& dy, int& w, int& h). */ |
| 385 | virtual void text_extents(const char*, int n, int& dx, int& dy, int& w, int& h); |
| 386 | /** \brief see fl_height(). */ |
| 387 | virtual int height() = 0; |
| 388 | /** \brief see fl_descent(). */ |
| 389 | virtual int descent() = 0; |
| 390 | /** \brief see fl_color(void). */ |
| 391 | Fl_Color color() {return color_;} |
| 392 | /** Returns a pointer to the current Fl_Font_Descriptor for the graphics driver */ |
| 393 | inline Fl_Font_Descriptor *font_descriptor() { return font_descriptor_;} |
| 394 | /** Sets the current Fl_Font_Descriptor for the graphics driver */ |
| 395 | inline void font_descriptor(Fl_Font_Descriptor *d) { font_descriptor_ = d;} |
| 396 | /** \brief The destructor */ |
| 397 | virtual ~Fl_Graphics_Driver() {}; |
| 398 | }; |
| 399 | |
| 400 | #if defined(__APPLE__) || defined(FL_DOXYGEN) |
| 401 | /** |
| 402 | \brief The Mac OS X-specific graphics class. |
| 403 | * |
| 404 | This class is implemented only on the Mac OS X platform. |
| 405 | */ |
| 406 | class FL_EXPORT Fl_Quartz_Graphics_Driver : public Fl_Graphics_Driver { |
| 407 | public: |
| 408 | static const char *class_id; |
| 409 | const char *class_name() {return class_id;}; |
| 410 | void color(Fl_Color c); |
| 411 | void color(uchar r, uchar g, uchar b); |
| 412 | void draw(const char* str, int n, int x, int y); |
| 413 | #ifdef __APPLE__ |
| 414 | void draw(const char *str, int n, float x, float y); |
| 415 | #endif |
| 416 | void draw(int angle, const char *str, int n, int x, int y); |
| 417 | void rtl_draw(const char* str, int n, int x, int y); |
| 418 | void font(Fl_Font face, Fl_Fontsize size); |
| 419 | void draw(Fl_Pixmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy); |
| 420 | void draw(Fl_Bitmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy); |
| 421 | void draw(Fl_RGB_Image *img, int XP, int YP, int WP, int HP, int cx, int cy); |
| 422 | void draw_image(const uchar* buf, int X,int Y,int W,int H, int D=3, int L=0); |
| 423 | void draw_image(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=3); |
| 424 | void draw_image_mono(const uchar* buf, int X,int Y,int W,int H, int D=1, int L=0); |
| 425 | void draw_image_mono(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=1); |
| 426 | double width(const char *str, int n); |
| 427 | double width(unsigned int c); |
| 428 | void text_extents(const char*, int n, int& dx, int& dy, int& w, int& h); |
| 429 | int height(); |
| 430 | int descent(); |
| 431 | }; |
| 432 | #endif |
| 433 | #if defined(WIN32) || defined(FL_DOXYGEN) |
| 434 | /** |
| 435 | \brief The MSWindows-specific graphics class. |
| 436 | * |
| 437 | This class is implemented only on the MSWindows platform. |
| 438 | */ |
| 439 | class FL_EXPORT Fl_GDI_Graphics_Driver : public Fl_Graphics_Driver { |
| 440 | public: |
| 441 | static const char *class_id; |
| 442 | const char *class_name() {return class_id;}; |
| 443 | void color(Fl_Color c); |
| 444 | void color(uchar r, uchar g, uchar b); |
| 445 | void draw(const char* str, int n, int x, int y); |
| 446 | void draw(int angle, const char *str, int n, int x, int y); |
| 447 | void rtl_draw(const char* str, int n, int x, int y); |
| 448 | void font(Fl_Font face, Fl_Fontsize size); |
| 449 | void draw(Fl_Pixmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy); |
| 450 | void draw(Fl_Bitmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy); |
| 451 | void draw(Fl_RGB_Image *img, int XP, int YP, int WP, int HP, int cx, int cy); |
| 452 | void draw_image(const uchar* buf, int X,int Y,int W,int H, int D=3, int L=0); |
| 453 | void draw_image(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=3); |
| 454 | void draw_image_mono(const uchar* buf, int X,int Y,int W,int H, int D=1, int L=0); |
| 455 | void draw_image_mono(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=1); |
| 456 | double width(const char *str, int n); |
| 457 | double width(unsigned int c); |
| 458 | void text_extents(const char*, int n, int& dx, int& dy, int& w, int& h); |
| 459 | int height(); |
| 460 | int descent(); |
| 461 | }; |
| 462 | #endif |
| 463 | #if !(defined(__APPLE__) || defined(WIN32)) |
| 464 | /** |
| 465 | \brief The Xlib-specific graphics class. |
| 466 | * |
| 467 | This class is implemented only on the Xlib platform. |
| 468 | */ |
| 469 | class Fl_Xlib_Graphics_Driver : public Fl_Graphics_Driver { |
| 470 | public: |
| 471 | static const char *class_id; |
| 472 | const char *class_name() {return class_id;}; |
| 473 | void color(Fl_Color c); |
| 474 | void color(uchar r, uchar g, uchar b); |
| 475 | void draw(const char* str, int n, int x, int y); |
| 476 | void draw(int angle, const char *str, int n, int x, int y); |
| 477 | void rtl_draw(const char* str, int n, int x, int y); |
| 478 | void font(Fl_Font face, Fl_Fontsize size); |
| 479 | void draw(Fl_Pixmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy); |
| 480 | void draw(Fl_Bitmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy); |
| 481 | void draw(Fl_RGB_Image *img, int XP, int YP, int WP, int HP, int cx, int cy); |
| 482 | void draw_image(const uchar* buf, int X,int Y,int W,int H, int D=3, int L=0); |
| 483 | void draw_image(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=3); |
| 484 | void draw_image_mono(const uchar* buf, int X,int Y,int W,int H, int D=1, int L=0); |
| 485 | void draw_image_mono(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=1); |
| 486 | double width(const char *str, int n); |
| 487 | double width(unsigned int c); |
| 488 | void text_extents(const char*, int n, int& dx, int& dy, int& w, int& h); |
| 489 | int height(); |
| 490 | int descent(); |
| 491 | }; |
| 492 | #endif |
| 493 | |
| 494 | /** |
| 495 | \brief A surface that's susceptible to receive graphical output. |
| 496 | */ |
| 497 | class FL_EXPORT Fl_Surface_Device : public Fl_Device { |
| 498 | /** \brief The graphics driver in use by this surface. */ |
| 499 | Fl_Graphics_Driver *_driver; |
| 500 | static Fl_Surface_Device *_surface; // the surface that currently receives graphics output |
| 501 | protected: |
| 502 | /** \brief Constructor that sets the graphics driver to use for the created surface. */ |
| 503 | Fl_Surface_Device(Fl_Graphics_Driver *graphics_driver) {_driver = graphics_driver; }; |
| 504 | public: |
| 505 | static const char *class_id; |
| 506 | const char *class_name() {return class_id;}; |
| 507 | virtual void set_current(void); |
| 508 | /** \brief Sets the graphics driver of this drawing surface. */ |
| 509 | inline void driver(Fl_Graphics_Driver *graphics_driver) {_driver = graphics_driver;}; |
| 510 | /** \brief Returns the graphics driver of this drawing surface. */ |
| 511 | inline Fl_Graphics_Driver *driver() {return _driver; }; |
| 512 | /** \brief the surface that currently receives graphics output */ |
| 513 | static inline Fl_Surface_Device *surface() {return _surface; }; |
| 514 | /** \brief The destructor. */ |
| 515 | virtual ~Fl_Surface_Device() {} |
| 516 | }; |
| 517 | |
| 518 | /** |
| 519 | \brief A display to which the computer can draw. |
| 520 | */ |
| 521 | class FL_EXPORT Fl_Display_Device : public Fl_Surface_Device { |
| 522 | static Fl_Display_Device *_display; // the platform display device |
| 523 | public: |
| 524 | static const char *class_id; |
| 525 | const char *class_name() {return class_id;}; |
| 526 | /** \brief A constructor that sets the graphics driver used by the display */ |
| 527 | Fl_Display_Device(Fl_Graphics_Driver *graphics_driver); |
| 528 | /** Returns the platform display device. */ |
| 529 | static inline Fl_Display_Device *display_device() {return _display;}; |
| 530 | }; |
| 531 | |
| 532 | /** |
| 533 | This plugin socket allows the integration of new device drivers for special |
| 534 | window or screen types. It is currently used to provide an automated printing |
| 535 | service for OpenGL windows, if linked with fltk_gl. |
| 536 | */ |
| 537 | class FL_EXPORT Fl_Device_Plugin : public Fl_Plugin { |
| 538 | public: |
| 539 | /** \brief The constructor */ |
| 540 | Fl_Device_Plugin(const char *name) |
| 541 | : Fl_Plugin(klass(), name) { } |
| 542 | /** \brief Returns the class name */ |
| 543 | virtual const char *klass() { return "fltk:device"; } |
| 544 | /** \brief Returns the plugin name */ |
| 545 | virtual const char *name() = 0; |
| 546 | /** \brief Prints a widget |
| 547 | \param w the widget |
| 548 | \param x,y offsets where to print relatively to coordinates origin |
| 549 | \param height height of the current drawing area |
| 550 | */ |
| 551 | virtual int print(Fl_Widget* w, int x, int y, int height) = 0; |
| 552 | }; |
| 553 | |
| 554 | #endif // Fl_Device_H |
| 555 | |
| 556 | // |
| 557 | // End of "$Id: Fl_Device.H 8529 2011-03-23 12:49:30Z AlbrechtS $". |
| 558 | // |