• Main Page
  • Related Pages
  • Modules
  • Classes
  • Files
  • File List
  • File Members

fl_draw.H

Go to the documentation of this file.
00001 //
00002 // "$Id$"
00003 //
00004 // Portable drawing function header file for the Fast Light Tool Kit (FLTK).
00005 //
00006 // Copyright 1998-2016 by Bill Spitzak and others.
00007 //
00008 // This library is free software. Distribution and use rights are outlined in
00009 // the file "COPYING" which should have been included with this file.  If this
00010 // file is missing or damaged, see the license at:
00011 //
00012 //     http://www.fltk.org/COPYING.php
00013 //
00014 // Please report all bugs and problems on the following page:
00015 //
00016 //     http://www.fltk.org/str.php
00017 //
00018 
00024 #ifndef fl_draw_H
00025 #define fl_draw_H
00026 
00027 #include <FL/x.H>             // for Fl_Region
00028 #include <FL/Enumerations.H>  // for the color names
00029 #include <FL/Fl_Window.H>     // for fl_set_spot()
00030 #include <FL/Fl_Device.H>     // for fl_graphics_driver
00031 
00032 // Image class...
00033 class Fl_Image;
00034 
00035 // Label flags...
00036 FL_EXPORT extern char fl_draw_shortcut;
00037 
00042 // Colors:
00052 inline void     fl_color(Fl_Color c) {fl_graphics_driver->color(c); } // select indexed color
00054 inline void fl_color(int c) {fl_color((Fl_Color)c);}
00065 inline void     fl_color(uchar r, uchar g, uchar b) {fl_graphics_driver->color(r,g,b); } // select actual color
00070 inline Fl_Color fl_color() {return fl_graphics_driver->color();}
00076 // clip:
00082 inline void fl_push_clip(int x, int y, int w, int h) {fl_graphics_driver->push_clip(x,y,w,h); }
00091 #define fl_clip fl_push_clip
00092 
00095 inline void fl_push_no_clip() {fl_graphics_driver->push_no_clip(); }
00103 inline void fl_pop_clip() {fl_graphics_driver->pop_clip(); }
00114 inline int fl_not_clipped(int x, int y, int w, int h) {return fl_graphics_driver->not_clipped(x,y,w,h); }
00126 inline int fl_clip_box(int x , int y, int w, int h, int& X, int& Y, int& W, int& H) 
00127   {return fl_graphics_driver->clip_box(x,y,w,h,X,Y,W,H); }
00129 inline void fl_restore_clip() { fl_graphics_driver->restore_clip(); }
00136 inline void fl_clip_region(Fl_Region r) { fl_graphics_driver->clip_region(r); }
00140 inline Fl_Region fl_clip_region() { return fl_graphics_driver->clip_region(); }
00141 
00142 
00143 // points:
00147 inline void fl_point(int x, int y) { fl_graphics_driver->point(x,y); }
00148 
00149 // line type:
00177 inline void fl_line_style(int style, int width=0, char* dashes=0) {fl_graphics_driver->line_style(style,width,dashes); }
00178 enum {
00179   FL_SOLID      = 0,            
00180   FL_DASH       = 1,            
00181   FL_DOT        = 2,            
00182   FL_DASHDOT    = 3,            
00183   FL_DASHDOTDOT = 4,            
00184 
00185   FL_CAP_FLAT   = 0x100,        
00186   FL_CAP_ROUND  = 0x200,        
00187   FL_CAP_SQUARE = 0x300,        
00188 
00189   FL_JOIN_MITER = 0x1000,       
00190   FL_JOIN_ROUND = 0x2000,       
00191   FL_JOIN_BEVEL = 0x3000        
00192 };
00193 
00194 // rectangles tweaked to exactly fill the pixel rectangle:
00195 
00201 inline void fl_rect(int x, int y, int w, int h) { fl_graphics_driver->rect(x,y,w,h); }
00202 
00204 inline void fl_rect(int x, int y, int w, int h, Fl_Color c) {fl_color(c); fl_rect(x,y,w,h);}
00206 inline void fl_rectf(int x, int y, int w, int h) { fl_graphics_driver->rectf(x,y,w,h); }
00208 inline void fl_rectf(int x, int y, int w, int h, Fl_Color c) {fl_color(c); fl_rectf(x,y,w,h);}
00209 
00216 /* note: doxygen comment here to avoid triplication in os-speciic files */
00217 FL_EXPORT void fl_rectf(int x, int y, int w, int h, uchar r, uchar g, uchar b);
00218 
00219 // line segments:
00223 inline void fl_line(int x, int y, int x1, int y1) {fl_graphics_driver->line(x,y,x1,y1); }
00227 inline void fl_line(int x, int y, int x1, int y1, int x2, int y2) {fl_graphics_driver->line(x,y,x1,y1,x2,y2); }
00228 
00229 // closed line segments:
00233 inline void fl_loop(int x, int y, int x1, int y1, int x2, int y2) {fl_graphics_driver->loop(x,y,x1,y1,x2,y2); }
00237 inline void fl_loop(int x, int y, int x1, int y1, int x2, int y2, int x3, int y3) 
00238   {fl_graphics_driver->loop(x,y,x1,y1,x2,y2,x3,y3); }
00239 
00240 // filled polygons
00244 inline void fl_polygon(int x, int y, int x1, int y1, int x2, int y2) {fl_graphics_driver->polygon(x,y,x1,y1,x2,y2); }
00248 inline void fl_polygon(int x, int y, int x1, int y1, int x2, int y2, int x3, int y3) 
00249   { fl_graphics_driver->polygon(x,y,x1,y1,x2,y2,x3,y3); }
00250 
00251 // draw rectilinear lines, horizontal segment first:
00255 inline void fl_xyline(int x, int y, int x1) {fl_graphics_driver->xyline(x,y,x1);}
00259 inline void fl_xyline(int x, int y, int x1, int y2) {fl_graphics_driver->xyline(x,y,x1,y2);}
00264 inline void fl_xyline(int x, int y, int x1, int y2, int x3) {fl_graphics_driver->xyline(x,y,x1,y2,x3);}
00265 
00266 // draw rectilinear lines, vertical segment first:
00270 inline void fl_yxline(int x, int y, int y1) {fl_graphics_driver->yxline(x,y,y1);}
00274 inline void fl_yxline(int x, int y, int y1, int x2) {fl_graphics_driver->yxline(x,y,y1,x2);}
00279 inline void fl_yxline(int x, int y, int y1, int x2, int y3) {fl_graphics_driver->yxline(x,y,y1,x2,y3);}
00280 
00281 // circular lines and pie slices (code in fl_arci.C):
00304 inline void fl_arc(int x, int y, int w, int h, double a1, double a2) {fl_graphics_driver->arc(x,y,w,h,a1,a2); }
00317 inline void fl_pie(int x, int y, int w, int h, double a1, double a2) {fl_graphics_driver->pie(x,y,w,h,a1,a2); }
00319 FL_EXPORT void fl_chord(int x, int y, int w, int h, double a1, double a2); // nyi
00320 
00321 // scalable drawing code (code in fl_vertex.C and fl_arc.C):
00326 inline void fl_push_matrix() { fl_graphics_driver->push_matrix(); }
00330 inline void fl_pop_matrix() { fl_graphics_driver->pop_matrix(); }
00335 inline void fl_scale(double x, double y) { fl_graphics_driver->scale(x, y); }
00340 inline void fl_scale(double x) { fl_graphics_driver->scale(x, x); }
00345 inline void fl_translate(double x, double y) { fl_graphics_driver->translate(x, y); }
00350 inline void fl_rotate(double d) { fl_graphics_driver->rotate(d); }
00357 inline void fl_mult_matrix(double a, double b, double c, double d, double x,double y) 
00358         { fl_graphics_driver->mult_matrix(a, b, c, d, x, y); }
00362 inline void fl_begin_points() {fl_graphics_driver->begin_points(); }
00366 inline void fl_begin_line() {fl_graphics_driver->begin_line(); }
00370 inline void fl_begin_loop() {fl_graphics_driver->begin_loop(); }
00374 inline void fl_begin_polygon() {fl_graphics_driver->begin_polygon(); }
00379 inline void fl_vertex(double x, double y) {fl_graphics_driver->vertex(x,y); }
00388 inline void fl_curve(double X0, double Y0, double X1, double Y1, double X2, double Y2, double X3, double Y3)
00389   {fl_graphics_driver->curve(X0,Y0,X1,Y1,X2,Y2,X3,Y3); }
00416 inline void fl_arc(double x, double y, double r, double start, double end) {fl_graphics_driver->arc(x,y,r,start,end); }
00424 inline void fl_circle(double x, double y, double r) {fl_graphics_driver->circle(x,y,r); }
00428 inline void fl_end_points() {fl_graphics_driver->end_points(); }
00432 inline void fl_end_line() {fl_graphics_driver->end_line(); }
00436 inline void fl_end_loop() {fl_graphics_driver->end_loop(); }
00440 inline void fl_end_polygon() {fl_graphics_driver->end_polygon(); }
00455 inline void fl_begin_complex_polygon() {fl_graphics_driver->begin_complex_polygon(); }
00462 inline void fl_gap() {fl_graphics_driver->gap(); }
00466 inline void fl_end_complex_polygon() {fl_graphics_driver->end_complex_polygon(); }
00467 // get and use transformed positions:
00472 inline double fl_transform_x(double x, double y) {return fl_graphics_driver->transform_x(x, y); }
00477 inline double fl_transform_y(double x, double y) {return fl_graphics_driver->transform_y(x, y); }
00482 inline double fl_transform_dx(double x, double y) {return fl_graphics_driver->transform_dx(x, y); }
00487 inline double fl_transform_dy(double x, double y) {return fl_graphics_driver->transform_dy(x, y); }
00492 inline void fl_transformed_vertex(double xf, double yf) {fl_graphics_driver->transformed_vertex(xf,yf); }
00497 /* NOTE: doxygen comments here to avoid triplication in os-specific sources */
00498 
00499 // Fonts:
00509 inline void fl_font(Fl_Font face, Fl_Fontsize fsize) { fl_graphics_driver->font(face,fsize); }
00510 
00515 inline Fl_Font fl_font() {return fl_graphics_driver->font();}
00520 inline Fl_Fontsize fl_size() {return fl_graphics_driver->size();}
00521 
00522 // information you can get about the current font:
00527 inline int fl_height() {return fl_graphics_driver->height();}
00528 FL_EXPORT int fl_height(int font, int size);
00533 inline int  fl_descent() {return fl_graphics_driver->descent();}
00536 FL_EXPORT double fl_width(const char* txt);
00539 inline double fl_width(const char* txt, int n) {return fl_graphics_driver->width(txt, n);}
00544 inline double fl_width(unsigned int c)  {return fl_graphics_driver->width(c);}
00555 FL_EXPORT void fl_text_extents(const char*, int& dx, int& dy, int& w, int& h); // NO fltk symbol expansion will be performed
00559 inline void fl_text_extents(const char *t, int n, int& dx, int& dy, int& w, int& h)
00560   {fl_graphics_driver->text_extents(t, n, dx, dy, w, h);}
00561 
00562 // font encoding:
00563 // Note: doxygen comments here to avoid duplication for os-sepecific cases
00570 FL_EXPORT const char *fl_latin1_to_local(const char *t, int n=-1);
00577 FL_EXPORT const char *fl_local_to_latin1(const char *t, int n=-1);
00584 FL_EXPORT const char *fl_mac_roman_to_local(const char *t, int n=-1);
00591 FL_EXPORT const char *fl_local_to_mac_roman(const char *t, int n=-1);
00606 FL_EXPORT void fl_draw(const char* str, int x, int y);
00614 FL_EXPORT void fl_draw(int angle, const char* str, int x, int y);
00618 inline void fl_draw(const char* str, int n, int x, int y) {fl_graphics_driver->draw(str,n,x,y); }
00628 inline void fl_draw(int angle, const char* str, int n, int x, int y) {fl_graphics_driver->draw(angle,str,n,x,y); }
00632 inline void fl_rtl_draw(const char* str, int n, int x, int y) {fl_graphics_driver->rtl_draw(str,n,x,y); }
00633 FL_EXPORT void fl_measure(const char* str, int& x, int& y,
00634                           int draw_symbols = 1);
00635 FL_EXPORT void fl_draw(const char* str, int x, int y, int w, int h,
00636                        Fl_Align align,
00637                        Fl_Image* img=0, int draw_symbols = 1);
00638 FL_EXPORT void fl_draw(const char* str, int x, int y, int w, int h,
00639                        Fl_Align align,
00640                        void (*callthis)(const char *,int,int,int),
00641                        Fl_Image* img=0, int draw_symbols = 1);
00642 
00643 // boxtypes:
00644 FL_EXPORT void fl_frame(const char* s, int x, int y, int w, int h);
00645 FL_EXPORT void fl_frame2(const char* s, int x, int y, int w, int h);
00646 FL_EXPORT void fl_draw_box(Fl_Boxtype, int x, int y, int w, int h, Fl_Color);
00647 
00648 // images:
00649 
00685 inline void fl_draw_image(const uchar* buf, int X,int Y,int W,int H, int D=3, int L=0)
00686   { fl_graphics_driver->draw_image(buf, X, Y, W, H, D, L); }
00687 
00692 inline void fl_draw_image_mono(const uchar* buf, int X,int Y,int W,int H, int D=1, int L=0)
00693   { fl_graphics_driver->draw_image_mono(buf, X, Y, W, H, D, L); }
00694 
00728 inline void fl_draw_image(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=3)
00729   { fl_graphics_driver->draw_image(cb, data, X, Y, W, H, D); }
00730 
00735 inline void fl_draw_image_mono(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=1)
00736   { fl_graphics_driver->draw_image_mono(cb, data, X, Y, W, H, D); }
00737 
00743 /* note: doxygen comment here to avoid triplication in os-speciic files */
00744 FL_EXPORT char fl_can_do_alpha_blending();
00745 
00763 /* note: doxygen comment here to avoid triplication in os-speciic files */
00764 FL_EXPORT uchar *fl_read_image(uchar *p,int X,int Y,int W,int H,int alpha=0);
00765 
00766 // pixmaps:
00767 FL_EXPORT int fl_draw_pixmap(/*const*/ char* const* data, int x,int y,Fl_Color=FL_GRAY);
00768 FL_EXPORT int fl_draw_pixmap(const char* const* cdata, int x,int y,Fl_Color=FL_GRAY);
00769 FL_EXPORT int fl_measure_pixmap(/*const*/ char* const* data, int &w, int &h);
00770 FL_EXPORT int fl_measure_pixmap(const char* const* cdata, int &w, int &h);
00771 
00772 // other:
00773 FL_EXPORT void fl_scroll(int X, int Y, int W, int H, int dx, int dy,
00774                          void (*draw_area)(void*, int,int,int,int), void* data);
00775 FL_EXPORT const char* fl_shortcut_label(unsigned int shortcut);
00776 FL_EXPORT const char* fl_shortcut_label(unsigned int shortcut, const char **eom);
00777 FL_EXPORT unsigned int fl_old_shortcut(const char* s);
00778 FL_EXPORT void fl_overlay_rect(int x,int y,int w,int h);
00779 FL_EXPORT void fl_overlay_clear();
00780 FL_EXPORT void fl_cursor(Fl_Cursor);
00781 FL_EXPORT void fl_cursor(Fl_Cursor, Fl_Color fg, Fl_Color bg=FL_WHITE);
00782 FL_EXPORT const char* fl_expand_text(const char* from, char* buf, int maxbuf,
00783                                      double maxw, int& n, double &width,
00784                                      int wrap, int draw_symbols = 0);
00785 
00786 // XIM:
00788 FL_EXPORT void fl_set_status(int X, int Y, int W, int H);
00790 FL_EXPORT void fl_set_spot(int font, int size, int X, int Y, int W, int H, Fl_Window *win=0);
00792 FL_EXPORT void fl_reset_spot(void);
00793 
00794 
00795 
00796 // XForms symbols:
00797 FL_EXPORT int fl_draw_symbol(const char* label,int x,int y,int w,int h, Fl_Color);
00798 FL_EXPORT int fl_add_symbol(const char* name, void (*drawit)(Fl_Color), int scalable);
00801 #endif
00802 
00803 //
00804 // End of "$Id$".
00805 //
  • © 1998-2016 by Bill Spitzak and others.     FLTK

  • © 1998-2016 by Bill Spitzak and others.     FLTK

    Permission is granted to reproduce this manual or any portion for any purpose, provided this copyright and permission notice are preserved.