fltk::GSave Class Reference

List of all members.


Detailed Description

The constructor does a "gsave" and the destructor does a "grestore", and this object provides the memory to store the current graphics state. You must surround any calls to make_current() with this.

To improve speed on some backends this may not preserve the font, color, path, or line settings, since these are usually changed afterwards anyway. GSave may also clear the clip, though it will be restored by the destructor.

  if (!image.drawn()) {
    GSave gsave;
    image->make_current();
    draw_graphics_for_image();
    // destructor of the GSave happens here
  }
  // we can now draw our image into the window:
  image.draw(x,y,w,h);

Warning: I ran into a C++ misfeature. If you write "GSave gsave()" it will compile into nothing, with no warning (on both GCC and VisualStudio) and your graphics state will end up destroyed.


The documentation for this class was generated from the following files: