ezgl  1.0.1
An Easy Graphics & GUI Library
Functions
basic_application.cpp File Reference

This example shows you how to create an application using the EZGL library. More...

#include <iostream>
#include <chrono>
#include <thread>
#include <vector>
#include "ezgl/application.hpp"
#include "ezgl/graphics.hpp"

Functions

void draw_main_canvas (ezgl::renderer *g)
 Draw to the main canvas using the provided graphics object. More...
 
void initial_setup (ezgl::application *application, bool new_window)
 Initial Setup is a mandatory function for any EZGL application, and is run whenever a window is opened. More...
 
void draw_rectangle_example (ezgl::renderer *g)
 DRAWING HELPER FUNCTIONS. More...
 
void draw_arc_example (ezgl::renderer *g)
 Draw some example lines, shapes, and arcs.
 
void rotated_text_example (ezgl::renderer *g)
 Draw some rotated text.
 
void draw_poly_example (ezgl::renderer *g)
 Draw some Polygons.
 
void draw_text_example (ezgl::renderer *g)
 Draw some example text, with the bounding box functions.
 
void draw_line_example (ezgl::renderer *g)
 Draw wide lines with different end shapes.
 
void screen_coordinates_example (ezgl::renderer *g)
 Draw to screen coordinates where (0,0) is the top-left corner of the window These coordinates are not transformed so the object will not pan or zoom.
 
void draw_png_example (ezgl::renderer *g)
 Draw a small PNG.
 
void animate_button_cbk (GtkWidget *widget, ezgl::application *application)
 UI CALLBACK FUNCTIONS. More...
 
void test_button_cbk (GtkWidget *, ezgl::application *application)
 A callback function to test the Test button. More...
 
void combo_box_cbk (GtkComboBoxText *self, ezgl::application *app)
 Callback function for the example combo box. More...
 
void delete_combo_box_cbk (GtkWidget *widget, ezgl::application *app)
 Callback function for the delete combo box button. More...
 
void create_dialog_button_cbk (GtkWidget *, ezgl::application *application)
 Callback function for the create dialog button. More...
 
void create_mssg_button_cbk (GtkWidget *, ezgl::application *app)
 Callback function for the create message button. More...
 
void dialog_cbk (GtkDialog *self, gint response_id, ezgl::application *app)
 Callback function for dialog window created by "Create Dialog Window" button. More...
 
void act_on_mouse_press (ezgl::application *application, GdkEventButton *event, double x, double y)
 EVENT CALLBACK FUNCTIONS. More...
 
void act_on_mouse_move (ezgl::application *, GdkEventButton *, double x, double y)
 Function to handle mouse move event The current mouse position in the main canvas' world coordinate system is returned A pointer to the application and the entire GDK event are also returned.
 
void act_on_key_press (ezgl::application *application, GdkEventKey *, char *key_name)
 Function to handle keyboard press event The name of the key pressed is returned (0-9, a-z, A-Z, Up, Down, Left, Right, Shift_R, Control_L, space, Tab, ...) A pointer to the application and the entire GDK event are also returned.
 
int main (int, char **)
 The start point of the program. More...
 

Detailed Description

This example shows you how to create an application using the EZGL library.

Function Documentation

◆ act_on_mouse_press()

void act_on_mouse_press ( ezgl::application application,
GdkEventButton *  event,
double  x,
double  y 
)

EVENT CALLBACK FUNCTIONS.

Function to handle mouse press event The current mouse position in the main canvas' world coordinate system is returned A pointer to the application and the entire GDK event are also returned.

These functions run whenever their corresponding event (key press, mouse move, or mouse click) occurs.

◆ animate_button_cbk()

void animate_button_cbk ( GtkWidget *  widget,
ezgl::application application 
)

UI CALLBACK FUNCTIONS.

A callback function to the Animate button.

These are example callback functions for the UI elements

Creates an Animation in the main wundow

◆ combo_box_cbk()

void combo_box_cbk ( GtkComboBoxText *  self,
ezgl::application app 
)

Callback function for the example combo box.

Sets message to currently active option. Function trigerred when currently selected option changes.

◆ create_dialog_button_cbk()

void create_dialog_button_cbk ( GtkWidget *  ,
ezgl::application application 
)

Callback function for the create dialog button.

Creates a dialog window and connects it to the dialog_cbk function

◆ create_mssg_button_cbk()

void create_mssg_button_cbk ( GtkWidget *  ,
ezgl::application app 
)

Callback function for the create message button.

Creates a popup message

◆ delete_combo_box_cbk()

void delete_combo_box_cbk ( GtkWidget *  widget,
ezgl::application app 
)

Callback function for the delete combo box button.

Deletes combo box.

◆ dialog_cbk()

void dialog_cbk ( GtkDialog *  self,
gint  response_id,
ezgl::application app 
)

Callback function for dialog window created by "Create Dialog Window" button.

Updates application message to reflect user answer to dialog window.

◆ draw_main_canvas()

void draw_main_canvas ( ezgl::renderer g)

Draw to the main canvas using the provided graphics object.

The redrawing function for still pictures.

Runs every time graphics are refreshed/image zooms or pans

The graphics object expects that x and y values will be in the main canvas' world coordinate system.

◆ draw_rectangle_example()

void draw_rectangle_example ( ezgl::renderer g)

DRAWING HELPER FUNCTIONS.

Draw some rectangles with different colors.

draw_main_canvas helper functions. Example functions that draw different things.

◆ initial_setup()

void initial_setup ( ezgl::application application,
bool  new_window 
)

Initial Setup is a mandatory function for any EZGL application, and is run whenever a window is opened.

Function called before the activation of the application Can be used to create additional buttons, initialize the status message, or connect added widgets to their callback functions.

◆ main()

int main ( int  ,
char **   
)

The start point of the program.

This function initializes an ezgl application and runs it.

Parameters
argcThe number of arguments provided.
argvThe arguments as an array of c-strings.
Returns
the exit status of the application run.

◆ test_button_cbk()

void test_button_cbk ( GtkWidget *  ,
ezgl::application application 
)

A callback function to test the Test button.

Changes application message when button is pressed