#include <sgl.h>
|
| 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 | prepaint () |
|
virtual void | postpaint () |
|
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_pressed (double x, double y, MouseButton button) |
|
virtual void | mouse_released (double x, double y, MouseButton button) |
|
virtual void | mouse_moved (double x, double y) |
|
virtual void | mouse_dragged (double x, double y) |
|
virtual void | mouse_entered () |
|
virtual void | mouse_exited () |
|
virtual void | key_pressed (int k, double x, double y) |
|
KeyModifier | get_key_modifiers () const |
|
void | set_key_modifiers (KeyModifier mod) |
|
virtual void | start_timer (int msec) |
|
virtual void | timer_expired () |
|
The class representing basic graphical window objects. This simple window class does not support contained graphical objects, but the derived class ObjectWindow does.
◆ Window() [1/4]
sgl::Window::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 constructor that provides the most control to the client. Creates a window with detailed information. After intializing instrance variables, the constructor defers the actual work to the initialize method.
- Parameters
-
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 |
◆ Window() [2/4]
sgl::Window::Window |
( |
const std::string & |
title, |
|
|
int |
width, |
|
|
int |
height |
|
) |
| |
Creates a window with a default position. After intializing instrance variables, the constructor defers the actual work to the initialize method. The virtual viewport's range is 0.0...width by 0.0...height.
- Parameters
-
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 |
◆ Window() [3/4]
sgl::Window::Window |
( |
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. After intializing instrance variables, the constructor defers the actual work to the initialize method.
- Parameters
-
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 |
◆ Window() [4/4]
Create a default, plain window
◆ ~Window()
Destroys a graphical window object.
◆ clear()
void sgl::Window::clear |
( |
| ) |
|
|
virtual |
Erase all the drawing within the window. Does not remove any added graphical objects.
- Returns
- nothing
◆ draw_axes()
void sgl::Window::draw_axes |
( |
double |
x_inc, |
|
|
double |
y_inc |
|
) |
| const |
|
virtual |
Draws the x and y axes for the viewport. Draws grid lines at the specified intervals. To avoid drawing grid lines, clients should specify x_inc and/or y_inc values greater than the range of viewport coordinates.
◆ get_cursor()
Gets the window's curent cursor shape
- Returns
- the window's current cursor shape
◆ get_height()
int sgl::Window::get_height |
( |
| ) |
const |
|
virtual |
Returns the height in screen coordinates of the physical window.
- Returns
- the height in screen coordinates of the window
◆ get_key_modifiers()
Returns the active key modifier: SHIFT, CTRL, and/or ALT, if any. The return value is the bitwise ORed combination of active key modifiers.
- Returns
- the active key modifier
◆ get_max_x()
double sgl::Window::get_max_x |
( |
| ) |
const |
|
virtual |
Returns the viewport's right-most (highest) x value in viewport coordinates.
- Returns
- the viewport's right-most (highest) x value in viewport coordinates
◆ get_max_y()
double sgl::Window::get_max_y |
( |
| ) |
const |
|
virtual |
Returns the viewport's top-most (highest) y value in viewport coordinates.
- Returns
- the viewport's top-most (highest) y value in viewport coordinates
◆ get_min_x()
double sgl::Window::get_min_x |
( |
| ) |
const |
|
virtual |
Returns the viewport's left-most (lowest) x value in viewport coordinates.
- Returns
- the viewport's left-most (lowest) x value in viewport coordinates
◆ get_min_y()
double sgl::Window::get_min_y |
( |
| ) |
const |
|
virtual |
Returns the viewport's bottom-most (lowest) y value in viewport coordinates.
- Returns
- the viewport's bottom-most (lowest) y value in viewport coordinates
◆ get_width()
int sgl::Window::get_width |
( |
| ) |
const |
|
virtual |
Returns the width in screen coordinates of the physical window.
- Returns
- the width in screen coordinates of the window
◆ get_x()
int sgl::Window::get_x |
( |
| ) |
const |
|
virtual |
Returns the x value in screen coordinates of the left-top corner of the physical window.
- Returns
- the x value in screen coordinates of the left-top corner of the window
◆ get_y()
int sgl::Window::get_y |
( |
| ) |
const |
|
virtual |
Returns the y value in screen coordinates of the left-top corner of the physical window.
- Returns
- the y value in screen coordinates of the left-top corner of the window
◆ initialize()
void sgl::Window::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 |
|
) |
| |
|
protected |
Initialization routine used by the window constructors.
- Parameters
-
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 |
- Returns
- nothing
◆ key_pressed()
void sgl::Window::key_pressed |
( |
int |
k, |
|
|
double |
x, |
|
|
double |
y |
|
) |
| |
|
virtual |
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.
- Parameters
-
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 |
- Returns
- nothing
Reimplemented in sgl::ProceduralWindow, and sgl::ObjectWindow.
◆ mouse_dragged()
void sgl::Window::mouse_dragged |
( |
double |
x, |
|
|
double |
y |
|
) |
| |
|
virtual |
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.
- Parameters
-
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. |
- Returns
- nothing
Reimplemented in sgl::ProceduralWindow, and sgl::ObjectWindow.
◆ mouse_entered()
void sgl::Window::mouse_entered |
( |
| ) |
|
|
virtual |
Called by the event manager when the mouse pointer enters the window.
- Returns
- nothing
◆ mouse_exited()
void sgl::Window::mouse_exited |
( |
| ) |
|
|
virtual |
Called by the event manager when the mouse pointer exits the window.
- Returns
- nothing
◆ mouse_moved()
void sgl::Window::mouse_moved |
( |
double |
x, |
|
|
double |
y |
|
) |
| |
|
virtual |
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.
- Parameters
-
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. |
- Returns
- nothing
Reimplemented in sgl::ProceduralWindow, and sgl::ObjectWindow.
◆ mouse_pressed()
void sgl::Window::mouse_pressed |
( |
double |
x, |
|
|
double |
y, |
|
|
MouseButton |
button |
|
) |
| |
|
virtual |
Called by the event loop when the user depresses any mouse button when the mouse pointer is within the window.
- Parameters
-
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. |
- Returns
- nothing
Reimplemented in sgl::ProceduralWindow, and sgl::ObjectWindow.
◆ mouse_released()
void sgl::Window::mouse_released |
( |
double |
x, |
|
|
double |
y, |
|
|
MouseButton |
button |
|
) |
| |
|
virtual |
Called by the event manager when the user releases any mouse button when the mouse pointer is within the window.
- Parameters
-
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. |
- Returns
- nothing
Reimplemented in sgl::ProceduralWindow, and sgl::ObjectWindow.
◆ paint()
virtual void sgl::Window::paint |
( |
| ) |
|
|
pure virtual |
Responsible for rendering the image in the window's viewport. This method is abstract, so concrete derived classes must provide a concrete implementation.
- Returns
- nothing.
Implemented in sgl::ProceduralWindow.
◆ paint_all()
void sgl::Window::paint_all |
( |
| ) |
|
|
virtual |
Called automatically by the event loop. Calls prepaint, paint, and postpaint. Called when the window is repainted.
- Returns
- nothing
◆ postpaint()
void sgl::Window::postpaint |
( |
| ) |
|
|
virtual |
◆ prepaint()
void sgl::Window::prepaint |
( |
| ) |
|
|
virtual |
◆ repaint()
void sgl::Window::repaint |
( |
| ) |
|
|
virtual |
Request the window to be redrawn.
- Returns
- nothing
◆ resized()
void sgl::Window::resized |
( |
int |
w, |
|
|
int |
h |
|
) |
| |
|
virtual |
Responds to a change in the width and/or height of the physical window. The event loop calls this method when the user resizes the window.
- Parameters
-
w | the window's new width in screen coordinates |
h | the window's new height in screen coordinates |
- Returns
- nothing
◆ set_background_color()
void sgl::Window::set_background_color |
( |
const Color & |
color | ) |
|
|
virtual |
Sets the background color of the window's viewport.
- Parameters
-
color | a reference to a Color object specifying the window's background color. |
- Returns
- nothing
◆ set_cursor()
Sets the window's cursor shape
- Parameters
-
cursor | one of several CursorShape values |
- Returns
- the previous cursor shape that was replaced by this call
Sets the window's cursor shape
- Parameters
-
cursor | one of several CursorShape values |
- Returns
- nothing
◆ set_key_modifiers()
Sets the key modifiers instance variable. This method is ordinarily used by SGL internally for preprocessing calls from the event manager; clients typically will not call this method directly.
- Parameters
-
mod | the bitwise ORed combination of key modifiers (SHIFT_KEY, CTRL_KEY, ALT_KEY) |
- Returns
- nothing
◆ set_position()
void sgl::Window::set_position |
( |
int |
x, |
|
|
int |
y |
|
) |
| |
|
virtual |
Sets the location of the left-top corner of the window's client area to (x,y).
- Parameters
-
x | the x coordinate of the window's left-top corner |
y | the y coordinate of the window's left-top corner |
- Returns
- nothing
◆ set_size()
void sgl::Window::set_size |
( |
int |
width, |
|
|
int |
height |
|
) |
| |
|
virtual |
Sets the physical window's hoizontal and vertical dimensions.
- Parameters
-
width | the new width of the window |
height | the new height of the window |
- Returns
- nothing
◆ set_title()
void sgl::Window::set_title |
( |
const std::string & |
str | ) |
|
|
virtual |
Sets the title of the window.
- Parameters
-
str | the text of the new title |
- Returns
- nothing
◆ set_viewport()
void sgl::Window::set_viewport |
( |
double |
left, |
|
|
double |
right, |
|
|
double |
bottom, |
|
|
double |
top |
|
) |
| |
|
virtual |
Sets the horizontal and vertical ranges of the window's virtual viewport. Values given are in viewport's coordinates. the left-most (lowest) x value in viewport coordinates. the right-most (highest) x value in viewport coordinates. the bottom-most (lowest) y value in viewport coordinates. the top-most (highest) y value in viewport coordinates.
- Returns
- nothing
◆ set_visible()
void sgl::Window::set_visible |
( |
bool |
visible | ) |
|
|
virtual |
Shows or hides the window. viewport. Values given are in viewport's coordinates.
- Parameters
-
visible | if true, the window is visible; otherwise, the window is invisible. |
- Returns
- nothing
◆ set_window_size()
void sgl::Window::set_window_size |
( |
int |
w, |
|
|
int |
h |
|
) |
| |
|
virtual |
Sets the size of the physical window.
- Parameters
-
w | the window's new width in screen coordinates |
h | the window's new height in screen coordinates |
- Returns
- nothing
◆ start_timer()
void sgl::Window::start_timer |
( |
int |
msec | ) |
|
|
virtual |
Starts a countdown timer for this window. The event manager calls timer_expired when the timer expires.
- Parameters
-
msec | the number of milliseconds to count |
- Returns
- nothing
◆ timer_expired()
void sgl::Window::timer_expired |
( |
| ) |
|
|
virtual |
Called by the event manager when the current timer expires. The timer is not automatically reset, so clients such as animations that require continuous periodic notification must call start_timer after processing each timer_expired message.
- Returns
- nothing
◆ key_mods
Records the status of the SHIFT, ALT, and CTRL keys during the the latest key press, mouse pressed, or mouse released event within the window.
◆ max_x
double sgl::Window::max_x |
|
protected |
The largest x value representing the right-most position within the viewport.
◆ max_y
double sgl::Window::max_y |
|
protected |
The largest y value representing the top-most position within the viewport.
◆ min_x
double sgl::Window::min_x |
|
protected |
The smallest x value representing the left-most position within the viewport.
◆ min_y
double sgl::Window::min_y |
|
protected |
The smallest y value representing the bottom-most position within the viewport.
◆ normal_cursor
The standard cursor for this window.
The documentation for this class was generated from the following files: