Simple Graphics Library
0.9.5
SGL API
|
#include <sgl.h>
Public Member Functions | |
ObjectWindow (const std::string &title, int left, int top, int width, int height, double min_x, double max_x, double min_y, double max_y) | |
ObjectWindow (const std::string &title, int width, int height) | |
ObjectWindow (const std::string &title, double min_x, double max_x, double min_y, double max_y) | |
ObjectWindow () | |
~ObjectWindow () | |
void | prepaint () override |
void | postpaint () override |
void | mouse_pressed (double x, double y, MouseButton button) override |
void | mouse_released (double x, double y, MouseButton button) override |
void | mouse_moved (double x, double y) override |
void | mouse_dragged (double x, double y) override |
void | key_pressed (int k, double x, double y) override |
void | internal_add (GraphicalObject *obj) |
template<typename T , typename... Args> | |
T * | add (Args &&... args) |
void | remove (GraphicalObject *obj) |
void | remove_all () |
GraphicalObject * | hit (double x, double y) const |
std::vector< GraphicalObject * >::iterator | begin () |
std::vector< GraphicalObject * >::iterator | end () |
![]() | |
Window (const std::string &title, int left, int top, int width, int height, double min_x, double max_x, double min_y, double max_y) | |
Window (const std::string &title, int width, int height) | |
Window (const std::string &title, double min_x, double max_x, double min_y, double max_y) | |
Window () | |
virtual | ~Window () |
virtual void | clear () |
virtual void | set_title (const std::string &str) |
virtual void | set_background_color (const Color &color) |
virtual void | set_position (int x, int y) |
virtual void | set_size (int width, int height) |
virtual void | set_viewport (double left, double right, double bottom, double top) |
virtual void | set_visible (bool visible) |
virtual CursorShape | set_cursor (CursorShape cursor) |
virtual CursorShape | get_cursor () |
virtual void | run () |
virtual void | repaint () |
virtual void | paint ()=0 |
virtual void | paint_all () |
virtual int | get_x () const |
virtual int | get_y () const |
virtual int | get_width () const |
virtual int | get_height () const |
virtual void | set_window_size (int w, int h) |
virtual void | resized (int w, int h) |
virtual double | get_min_x () const |
virtual double | get_max_x () const |
virtual double | get_min_y () const |
virtual double | get_max_y () const |
virtual void | draw_axes (double x_inc, double y_inc) const |
virtual void | mouse_entered () |
virtual void | mouse_exited () |
KeyModifier | get_key_modifiers () const |
void | set_key_modifiers (KeyModifier mod) |
virtual void | start_timer (int msec) |
virtual void | timer_expired () |
Protected Attributes | |
std::vector< GraphicalObject * > | object_list |
GraphicalObject * | active_object |
![]() | |
double | min_x |
double | max_x |
double | min_y |
double | max_y |
CursorShape | normal_cursor |
KeyModifier | key_mods |
Additional Inherited Members | |
![]() | |
void | initialize (const std::string &title, int left, int top, int width, int height, double min_x, double max_x, double min_y, double max_y) |
The class representing window objects that can contain graphical objects that the user can manipulate.
sgl::ObjectWindow::ObjectWindow | ( | const std::string & | title, |
int | left, | ||
int | top, | ||
int | width, | ||
int | height, | ||
double | min_x, | ||
double | max_x, | ||
double | min_y, | ||
double | max_y | ||
) |
Constructor that provides the most control to the client. Creates a window with detailed information.
title | the text to appear within the window's titlebar |
left | the x coordinate in screen coordinates of the window's left-top corner |
top | the y coordinate in screen coordinates of the window's left-top corner |
width | the width in screen coordinates of the window |
height | the height in screen coordinates of the window |
min_x | the smallest x value representing the left-most position within the viewport |
max_x | the largest x value representing the right-most position within the viewport |
min_y | the smallest y value representing the bottom-most position within the viewport |
max_y | the largest y value representing the top-most position within the viewport |
sgl::ObjectWindow::ObjectWindow | ( | const std::string & | title, |
int | width, | ||
int | height | ||
) |
Creates a window of a specified width and height
title | the text to appear within the window's titlebar |
width | the width in screen coordinates of the window |
height | the height in screen coordinates of the window |
sgl::ObjectWindow::ObjectWindow | ( | const std::string & | title, |
double | min_x, | ||
double | max_x, | ||
double | min_y, | ||
double | max_y | ||
) |
Creates a window with a default position and size.
title | the text to appear within the window's titlebar |
min_x | the smallest x value representing the left-most position within the viewport |
max_x | the largest x value representing the right-most position within the viewport |
min_y | the smallest y value representing the bottom-most position within the viewport |
max_y | the largest y value representing the top-most position within the viewport |
sgl::ObjectWindow::ObjectWindow | ( | ) |
Create a default, plain window
sgl::ObjectWindow::~ObjectWindow | ( | ) |
Destroys an object window object.
|
inline |
Creates and adds a graphical object to the window. Clients specify the exact type of the graphical object as the template parameter and pass any arguments required by that object's constructor in the parameter list.
T | the type of graphical object to add to this window |
args | forwards the method parameters to the graphical object's constructor |
std::vector< GraphicalObject * >::iterator sgl::ObjectWindow::begin | ( | ) |
Returns an iterator to the begining of the vector of graphical objects this window contains.
std::vector< GraphicalObject * >::iterator sgl::ObjectWindow::end | ( | ) |
Returns an iterator just past the end of the vector of graphical objects this window contains.
GraphicalObject * sgl::ObjectWindow::hit | ( | double | x, |
double | y | ||
) | const |
Returns the first graphical object in the list of graphical objects with a bounding box that intersects the given viewport coordinates.
x | the x coordinate in viewport coordinates of a location within the viewport |
y | the y coordinate in viewport coordinates of a location within the viewport |
void sgl::ObjectWindow::internal_add | ( | GraphicalObject * | obj | ) |
Adds a graphical object to the window. Clients generally call the add method (which calls this method indirectly) rather than calling this method directly. That way the the window is responsible for managing the Graphical object's memory.
obj | the graphical object to add to this window |
|
overridevirtual |
Called by the event manager when the user types a key when the window has keyboard focus. The key pressed and the location of the mouse pointer in viewport coordinates is reported.
k | the key typed by the user |
x | the x coordinate in viewport coordinates of the location of the mouse pointer within the window |
y | the y coordinate in viewport coordinates of the location of the mouse pointer within the window |
Reimplemented from sgl::Window.
Reimplemented in sgl::ProceduralWindow.
|
overridevirtual |
Called by the event manager when the user drags the mouse (moves the mouse while holding down a mouse button) when the mouse pointer is within the window. The location reported is given in viewport coordinates.
x | the x coordinate in viewport coordinates of the location of the mouse pointer within the window during the most recent mouse event. |
y | the y coordinate in viewport coordinates of the location of the mouse pointer within the window during the most recent mouse event. |
Reimplemented from sgl::Window.
Reimplemented in sgl::ProceduralWindow.
|
overridevirtual |
Called by the event manager when the user moves the mouse when the mouse pointer is within the window. The location reported is given in viewport coordinates.
x | the x coordinate in viewport coordinates of the location of the mouse pointer within the window during the most recent mouse event. |
y | the y coordinate in viewport coordinates of the location of the mouse pointer within the window during the most recent mouse event. |
Reimplemented from sgl::Window.
Reimplemented in sgl::ProceduralWindow.
|
overridevirtual |
Called by the event loop when the user depresses any mouse button when the mouse pointer is within the window.
x | the x coordinate in viewport coordinates of the mouse pointer location within the window during the current mouse event. |
y | the y coordinate in viewport coordinates of the mouse pointer location within the window during the current mouse event. |
button | the button that was depressed, left (LEFT_BUTTON) or right (RIGHT_BUTTON) during the current mouse event. |
Reimplemented from sgl::Window.
Reimplemented in sgl::ProceduralWindow.
|
overridevirtual |
Called by the event manager when the user releases any mouse button when the mouse pointer is within the window.
x | the x coordinate in viewport coordinates of the mouse pointer location within the window during the current mouse event. |
y | the y coordinate in viewport coordinates of the mouse pointer location within the window during the current mouse event. |
button | the button that was released, left (LEFT_BUTTON) or right (RIGHT_BUTTON) during the current mouse event. |
Reimplemented from sgl::Window.
Reimplemented in sgl::ProceduralWindow.
|
overridevirtual |
|
overridevirtual |
void sgl::ObjectWindow::remove | ( | GraphicalObject * | obj | ) |
Removes a graphical object from the window. Frees up the memory held by the graphical object.
obj | the graphical object to remove from the window. |
void sgl::ObjectWindow::remove_all | ( | ) |
Removes all the graphical objects from the list of contained graphical objects. Frees up the memory allocated for the graphical objects.
|
protected |
The list of graphical objects contained in this window.