ezgl  1.0.1
An Easy Graphics & GUI Library
Classes | Typedefs | Enumerations | Functions | Variables
ezgl Namespace Reference

A library for creating a graphical user interface. More...

Classes

class  application
 The core application. More...
 
class  camera
 Manages the transformations between coordinate systems. More...
 
class  canvas
 Responsible for creating, destroying, and maintaining the rendering context of a GtkWidget. More...
 
struct  color
 Represents a color as a mixture or red, green, and blue as well as the transparency level. More...
 
class  renderer
 Provides functions to draw primitives (e.g., lines, shapes) to a rendering context (the MainCanvas). More...
 
class  point2d
 Represents a two-dimensional point. More...
 
class  rectangle
 Represents a rectangle as two diagonally opposite points. More...
 

Typedefs

using connect_g_objects_fn = void(*)(application *app)
 The signature of a function that connects GObject to functions via signals. More...
 
using setup_callback_fn = void(*)(application *app, bool new_window)
 The signature of a setup callback function.
 
using button_callback_fn = void(*)(GtkWidget *widget, application *app)
 The signature of a button callback function.
 
using mouse_callback_fn = void(*)(application *app, GdkEventButton *event, double x, double y)
 The signature of a user-defined callback function for mouse events.
 
using key_callback_fn = void(*)(application *app, GdkEventKey *event, char *key_name)
 The signature of a user-defined callback function for keyboard events.
 
using combo_box_callback_fn = void(*)(GtkComboBoxText *self, application *app)
 The signature of a user-defined callback function for the combo-box "changed" signal.
 
using dialog_callback_fn = void(*)(GtkDialog *self, gint response_id, application *app)
 The signature of a user-defined callback function for a dialog window.
 
using draw_canvas_fn = void(*)(renderer *)
 The signature of a function that draws to an ezgl::canvas.
 
typedef cairo_surface_t surface
 define ezgl::surface type used for drawing png bitmaps
 

Enumerations

enum  t_coordinate_system { WORLD , SCREEN }
 Available coordinate systems. More...
 
enum class  justification {
  center , left , right , top ,
  bottom
}
 Justification options used for text and surfaces. More...
 
enum class  font_slant : int { normal = CAIRO_FONT_SLANT_NORMAL , italic = CAIRO_FONT_SLANT_ITALIC , oblique = CAIRO_FONT_SLANT_OBLIQUE }
 The slant of the font. More...
 
enum class  font_weight : int { normal = CAIRO_FONT_WEIGHT_NORMAL , bold = CAIRO_FONT_WEIGHT_BOLD }
 The weight of the font. More...
 
enum class  line_cap : int { butt = CAIRO_LINE_CAP_BUTT , round = CAIRO_LINE_CAP_ROUND }
 The shape of a line's start and end point. More...
 
enum class  line_dash : int { none , asymmetric_5_3 }
 The dash style of a line. More...
 

Functions

void set_disable_event_loop (bool new_setting)
 Set the disable_event_loop flag to new_setting Call with new_setting == true to make the event_loop immediately return. More...
 
gboolean press_key (GtkWidget *widget, GdkEventKey *event, gpointer data)
 React to a keyboard press event. More...
 
gboolean press_mouse (GtkWidget *widget, GdkEventButton *event, gpointer data)
 React to mouse click event More...
 
gboolean release_mouse (GtkWidget *widget, GdkEventButton *event, gpointer data)
 React to mouse release event More...
 
gboolean move_mouse (GtkWidget *widget, GdkEventButton *event, gpointer data)
 React to mouse release event More...
 
gboolean scroll_mouse (GtkWidget *widget, GdkEvent *event, gpointer data)
 React to scroll_event event More...
 
gboolean press_zoom_fit (GtkWidget *widget, gpointer data)
 React to the clicked zoom_fit button. More...
 
gboolean press_zoom_in (GtkWidget *widget, gpointer data)
 React to the clicked zoom_in button. More...
 
gboolean press_zoom_out (GtkWidget *widget, gpointer data)
 React to the clicked zoom_out button. More...
 
gboolean press_up (GtkWidget *widget, gpointer data)
 React to the clicked up button. More...
 
gboolean press_down (GtkWidget *widget, gpointer data)
 React to the clicked up button. More...
 
gboolean press_left (GtkWidget *widget, gpointer data)
 React to the clicked up button. More...
 
gboolean press_right (GtkWidget *widget, gpointer data)
 React to the clicked up button. More...
 
gboolean press_proceed (GtkWidget *widget, gpointer data)
 React to the clicked proceed button. More...
 
void zoom_in (canvas *cnv, double zoom_factor)
 Zoom in on the center of the currently visible world.
 
void zoom_out (canvas *cnv, double zoom_factor)
 Zoom out from the center of the currently visible world.
 
void zoom_in (canvas *cnv, point2d zoom_point, double zoom_factor)
 Zoom in on a specific point in the GTK widget.
 
void zoom_out (canvas *cnv, point2d zoom_point, double zoom_factor)
 Zoom out from a specific point in GTK widget.
 
void zoom_fit (canvas *cnv, rectangle region)
 Zoom in or out to fit an exact region of the world.
 
void translate (canvas *cnv, double dx, double dy)
 Translate by delta x and delta y (dx, dy)
 
void translate_up (canvas *cnv, double translate_factor)
 Translate up.
 
void translate_down (canvas *cnv, double translate_factor)
 Translate down.
 
void translate_left (canvas *cnv, double translate_factor)
 Translate left.
 
void translate_right (canvas *cnv, double translate_factor)
 Translate right.
 

Variables

const bool build_ui_from_file = false
 

Detailed Description

A library for creating a graphical user interface.

Typedef Documentation

◆ connect_g_objects_fn

using ezgl::connect_g_objects_fn = typedef void (*)(application *app)

The signature of a function that connects GObject to functions via signals.

See also
application::get_object.

Enumeration Type Documentation

◆ font_slant

enum ezgl::font_slant : int
strong

The slant of the font.

This enum is setup to match with the cairo graphics library and should not be changed.

Enumerator
normal 

No slant.

italic 

Slant is more calligraphic.

Make sure the font you're using has an italic design, otherwise it may look ugly.

oblique 

Slanted to the right.

◆ font_weight

enum ezgl::font_weight : int
strong

The weight of the font.

Enumerator
normal 

No additional weight.

bold 

Bold font weight.

◆ justification

enum ezgl::justification
strong

Justification options used for text and surfaces.

Enumerator
center 

Center Justification: used for both vertical and horizontal justification.

left 

Left justification: used for horizontal justification.

right 

Right justification: used for horizontal justification.

top 

Top justification: used for vertical justification.

bottom 

Bottom justification: used for vertical justification.

◆ line_cap

enum ezgl::line_cap : int
strong

The shape of a line's start and end point.

Enumerator
butt 

Start and stop the line exactly where it begins/ends.

round 

Each end of the line has circles.

This is useful to ensure polylines formed of multiple line segments do not have gaps in them.

◆ line_dash

enum ezgl::line_dash : int
strong

The dash style of a line.

Enumerator
none 

No dashes in the line (i.e., solid).

asymmetric_5_3 

Dash to whitespace ratio is 5:3.

◆ t_coordinate_system

Available coordinate systems.

Enumerator
WORLD 

Default coordinate system; specified by the user as any desired range.

Graphics drawn in world coordinates will be transformed to screen pixels by ezgl. Panning and zooming change the transformation from world to screen coordinates, so they automatically work for any graphics drawn in wrld coordinates.

SCREEN 

Screen (pixel) coordinate system.

Screen Coordinates are not transformed so the drawn objects do not pan or zoom.

Function Documentation

◆ move_mouse()

gboolean ezgl::move_mouse ( GtkWidget *  widget,
GdkEventButton *  event,
gpointer  data 
)

React to mouse release event

Parameters
widgetThe GUI widget where this event came from.
eventThe click event.
dataA pointer to any user-specified data you passed in.
Returns
FALSE to allow other handlers to see this event, too. TRUE otherwise.

◆ press_down()

gboolean ezgl::press_down ( GtkWidget *  widget,
gpointer  data 
)

React to the clicked up button.

Parameters
widgetThe GUI widget where this event came from.
dataA pointer to any user-specified data you passed in.
Returns
FALSE to allow other handlers to see this event, too. TRUE otherwise.

◆ press_key()

gboolean ezgl::press_key ( GtkWidget *  widget,
GdkEventKey *  event,
gpointer  data 
)

React to a keyboard press event.

Parameters
widgetThe GUI widget where this event came from.
eventThe keyboard event.
dataA pointer to any user-specified data you passed in.
Returns
FALSE to allow other handlers to see this event, too. TRUE otherwise.

◆ press_left()

gboolean ezgl::press_left ( GtkWidget *  widget,
gpointer  data 
)

React to the clicked up button.

Parameters
widgetThe GUI widget where this event came from.
dataA pointer to any user-specified data you passed in.
Returns
FALSE to allow other handlers to see this event, too. TRUE otherwise.

◆ press_mouse()

gboolean ezgl::press_mouse ( GtkWidget *  widget,
GdkEventButton *  event,
gpointer  data 
)

React to mouse click event

Parameters
widgetThe GUI widget where this event came from.
eventThe click event.
dataA pointer to any user-specified data you passed in.
Returns
FALSE to allow other handlers to see this event, too. TRUE otherwise.

◆ press_proceed()

gboolean ezgl::press_proceed ( GtkWidget *  widget,
gpointer  data 
)

React to the clicked proceed button.

Parameters
widgetThe GUI widget where this event came from.
dataA pointer to any user-specified data you passed in.
Returns
FALSE to allow other handlers to see this event, too. TRUE otherwise.

◆ press_right()

gboolean ezgl::press_right ( GtkWidget *  widget,
gpointer  data 
)

React to the clicked up button.

Parameters
widgetThe GUI widget where this event came from.
dataA pointer to any user-specified data you passed in.
Returns
FALSE to allow other handlers to see this event, too. TRUE otherwise.

◆ press_up()

gboolean ezgl::press_up ( GtkWidget *  widget,
gpointer  data 
)

React to the clicked up button.

Parameters
widgetThe GUI widget where this event came from.
dataA pointer to any user-specified data you passed in.
Returns
FALSE to allow other handlers to see this event, too. TRUE otherwise.

◆ press_zoom_fit()

gboolean ezgl::press_zoom_fit ( GtkWidget *  widget,
gpointer  data 
)

React to the clicked zoom_fit button.

Parameters
widgetThe GUI widget where this event came from.
dataA pointer to any user-specified data you passed in.
Returns
FALSE to allow other handlers to see this event, too. TRUE otherwise.

◆ press_zoom_in()

gboolean ezgl::press_zoom_in ( GtkWidget *  widget,
gpointer  data 
)

React to the clicked zoom_in button.

Parameters
widgetThe GUI widget where this event came from.
dataA pointer to any user-specified data you passed in.
Returns
FALSE to allow other handlers to see this event, too. TRUE otherwise.

◆ press_zoom_out()

gboolean ezgl::press_zoom_out ( GtkWidget *  widget,
gpointer  data 
)

React to the clicked zoom_out button.

Parameters
widgetThe GUI widget where this event came from.
dataA pointer to any user-specified data you passed in.
Returns
FALSE to allow other handlers to see this event, too. TRUE otherwise.

◆ release_mouse()

gboolean ezgl::release_mouse ( GtkWidget *  widget,
GdkEventButton *  event,
gpointer  data 
)

React to mouse release event

Parameters
widgetThe GUI widget where this event came from.
eventThe click event.
dataA pointer to any user-specified data you passed in.
Returns
FALSE to allow other handlers to see this event, too. TRUE otherwise.

◆ scroll_mouse()

gboolean ezgl::scroll_mouse ( GtkWidget *  widget,
GdkEvent *  event,
gpointer  data 
)

React to scroll_event event

Parameters
widgetThe GUI widget where this event came from.
eventThe click event.
dataA pointer to any user-specified data you passed in.
Returns
FALSE to allow other handlers to see this event, too. TRUE otherwise.

◆ set_disable_event_loop()

void ezgl::set_disable_event_loop ( bool  new_setting)

Set the disable_event_loop flag to new_setting Call with new_setting == true to make the event_loop immediately return.

This is useful for unit tests, to ensure the GUI doesn't wait for user input in an automatic test.

Parameters
new_settingThe new state of disable_event_loop flag