Fl_Cairo.H 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. //
  2. // "$Id: Fl_Cairo.H 11168 2016-02-13 18:02:17Z AlbrechtS $"
  3. //
  4. // Main header file for the Fast Light Tool Kit (FLTK).
  5. //
  6. // Copyright 1998-2016 by Bill Spitzak and others.
  7. //
  8. // This library is free software. Distribution and use rights are outlined in
  9. // the file "COPYING" which should have been included with this file. If this
  10. // file is missing or damaged, see the license at:
  11. //
  12. // http://www.fltk.org/COPYING.php
  13. //
  14. // Please report all bugs and problems on the following page:
  15. //
  16. // http://www.fltk.org/str.php
  17. //
  18. /* \file
  19. Handling transparently platform dependent cairo include files
  20. */
  21. #ifndef FL_CAIRO_H
  22. # define FL_CAIRO_H
  23. # ifdef FLTK_HAVE_CAIRO
  24. // Cairo is currently supported for the following platforms:
  25. // Win32, Apple Quartz, X11
  26. # include <FL/Fl_Export.H>
  27. # include <cairo.h>
  28. /**
  29. \addtogroup group_cairo
  30. @{
  31. */
  32. /**
  33. Contains all the necessary info on the current cairo context.
  34. A private internal & unique corresponding object is created to
  35. permit cairo context state handling while keeping it opaque.
  36. For internal use only.
  37. \note Only available when configure has the --enable-cairo option
  38. */
  39. class FL_EXPORT Fl_Cairo_State {
  40. public:
  41. Fl_Cairo_State() : cc_(0), own_cc_(false), autolink_(false), window_(0), gc_(0) {}
  42. // access attributes
  43. cairo_t* cc() const {return cc_;} ///< Gets the current cairo context
  44. bool autolink() const {return autolink_;} ///< Gets the autolink option. See Fl::cairo_autolink_context(bool)
  45. /** Sets the current cairo context.
  46. \p own == \e true (the default) indicates that the cairo context \p c
  47. will be deleted by FLTK internally when another cc is set later.
  48. \p own == \e false indicates cc deletion is handled externally
  49. by the user program.
  50. */
  51. void cc(cairo_t* c, bool own=true) {
  52. if (cc_ && own_cc_) cairo_destroy(cc_);
  53. cc_=c;
  54. if (!cc_) window_=0;
  55. own_cc_=own;
  56. }
  57. void autolink(bool b); ///< Sets the autolink option, only available with --enable-cairoext
  58. void window(void* w) {window_=w;} ///< Sets the window \p w to keep track on
  59. void* window() const {return window_;} ///< Gets the last window attached to a cc
  60. void gc(void* c) {gc_=c;} ///< Sets the gc \p c to keep track on
  61. void* gc() const {return gc_;} ///< Gets the last gc attached to a cc
  62. private:
  63. cairo_t * cc_; // contains the unique autoupdated cairo context
  64. bool own_cc_; // indicates whether we must delete the cc, useful for internal cleanup
  65. bool autolink_; // false by default, prevents the automatic cairo mapping on fltk windows
  66. // for custom cairo implementations.
  67. void* window_, *gc_; // for keeping track internally of last win+gc treated
  68. };
  69. /** @} */
  70. # endif // FLTK_HAVE_CAIRO
  71. #endif // FL_CAIRO_H
  72. //
  73. // End of "$Id: Fl_Cairo.H 11168 2016-02-13 18:02:17Z AlbrechtS $" .
  74. //