ezgl
1.0.1
An Easy Graphics & GUI Library
|
Responsible for creating, destroying, and maintaining the rendering context of a GtkWidget. More...
#include <canvas.hpp>
Public Member Functions | |
~canvas () | |
Destructor. | |
char const * | id () const |
Get the name (identifier) of the canvas. | |
int | width () const |
Get the width of the canvas in pixels. | |
int | height () const |
Get the height of the canvas in pixels. | |
void | redraw () |
Force the canvas to redraw itself. More... | |
camera const & | get_camera () const |
Get an immutable reference to this canvas' camera. | |
camera & | get_camera () |
Get a mutable reference to this canvas' camera. | |
renderer * | create_animation_renderer () |
Create an animation renderer that can be used to draw on top of the current canvas. | |
bool | print_pdf (const char *file_name, int width=0, int height=0) |
print_pdf, print_svg, and print_png generate a PDF, SVG, or PNG output file showing all the graphical content of the current canvas. More... | |
bool | print_svg (const char *file_name, int width=0, int height=0) |
bool | print_png (const char *file_name, int width=0, int height=0) |
Protected Member Functions | |
canvas (std::string canvas_id, draw_canvas_fn draw_callback, rectangle coordinate_system, color background_color) | |
Create a canvas that can be drawn to. | |
void | initialize (GtkWidget *drawing_area) |
Lazy initialization of the canvas class. More... | |
Friends | |
class | application |
Responsible for creating, destroying, and maintaining the rendering context of a GtkWidget.
Underneath, the class relies on a GtkDrawingArea as its GUI widget along with cairo to provide the rendering context. The class connects to the relevant GTK signals, namely configure and draw events, to remain responsive.
Each canvas is double-buffered. A draw callback (see: ezgl::draw_canvas_fn) is invoked each time the canvas needs to be redrawn. This may be caused by the user (e.g., resizing the screen), but can also be forced by the programmer.
|
protected |
Lazy initialization of the canvas class.
This function is required because GTK will not send activate/startup signals to an ezgl::application until control of the program has been reliquished. The GUI is not built until ezgl::application receives an activate signal.
bool ezgl::canvas::print_pdf | ( | const char * | file_name, |
int | width = 0 , |
||
int | height = 0 |
||
) |
print_pdf, print_svg, and print_png generate a PDF, SVG, or PNG output file showing all the graphical content of the current canvas.
file_name | name of the output file |
void ezgl::canvas::redraw | ( | ) |
Force the canvas to redraw itself.
This will invoke the ezgl::draw_canvas_fn callback and queue a redraw of the GtkWidget.