StanfordCPPLib
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
GWindow Class Reference

This class represents a graphics window that supports simple graphics. More...

#include "gwindow.h"

Inheritance diagram for GWindow:
GObservable

Public Types

enum  CloseOperation { CLOSE_DO_NOTHING, CLOSE_HIDE, CLOSE_DISPOSE, CLOSE_EXIT }
 The various actions that can occur when a window closes. More...
 
enum  Region { REGION_CENTER = GContainer::REGION_CENTER, REGION_EAST = GContainer::REGION_EAST, REGION_NORTH = GContainer::REGION_NORTH, REGION_SOUTH = GContainer::REGION_SOUTH, REGION_WEST = GContainer::REGION_WEST }
 The five regions of window border layouts. More...
 

Public Member Functions

 GWindow(bool visible=true)
 Creates a new window of a default width and height. More...
 
 GWindow(double width, double height, bool visible=true)
 Creates a new window of the given width and height. More...
 
 GWindow(double x, double y, double width, double height, bool visible=true)
 Creates a new window of the given location and size. More...
 
~GWindow()
 Frees memory allocated internally by the window. More...
 
void _autograder_setIsAutograderWindow(bool isAutograderWindow)
 An internal function that sets whether the current window is part of an autograder program. More...
 
void add(GInteractor *interactor)
 Adds the given interactor to the center region of the window. More...
 
void add(GInteractor *interactor, double x, double y)
 Adds the given interactor to the center region of the window and moves it to the given x/y location. More...
 
void add(GInteractor &interactor)
 Adds the given interactor to the center region of the window. More...
 
void add(GInteractor &interactor, double x, double y)
 Adds the given interactor to the center region of the window and moves it to the given x/y location. More...
 
void add(GObject *obj)
 Adds the given graphical object to the window's canvas. More...
 
void add(GObject *obj, double x, double y)
 Adds the given graphical object to the window's canvas and moves it to the given x/y location. More...
 
void add(GObject &obj)
 Adds the given graphical object to the window's canvas. More...
 
void add(GObject &obj, double x, double y)
 Adds the given graphical object to the window's canvas and moves it to the given x/y location. More...
 
QMenu * addMenu(string text)
 Adds a menu with the given text to the window's top menu bar. More...
 
QAction * addMenuItem(string menu, string item, string icon="")
 Adds a new menu item to the given menu. More...
 
QAction * addMenuItem(string menu, string item, string icon, GEventListenerVoid func)
 Adds a new menu item to the given menu. More...
 
QAction * addMenuItem(string menu, string item, const QIcon &icon, GEventListenerVoid func)
 Adds a new menu item to the given menu. More...
 
QAction * addMenuItemCheckBox(string menu, string item, bool checked=false, string icon="")
 Adds a new checkbox menu item to the given menu. More...
 
QAction * addMenuItemCheckBox(string menu, string item, bool checked, string icon, GEventListenerVoid func)
 Adds a new checkbox menu item to the given menu. More...
 
QAction * addMenuSeparator(string menu)
 Adds a horizontal line separator to the end of the given menu. More...
 
QMenu * addSubMenu(string menu, string submenu)
 Adds a sub-menu within an existing menu. More...
 
void addToolbar(string title="")
 Adds a toolbar to this window where action buttons can be placed. More...
 
QAction * addToolbarItem(string item, string icon="")
 Adds a new item to the window's toolbar. More...
 
QAction * addToolbarItem(string item, string icon, GEventListenerVoid func)
 Adds a new item to the window's toolbar. More...
 
QAction * addToolbarItem(string item, const QIcon &icon, GEventListenerVoid func)
 Adds a new item to the window's toolbar. More...
 
QAction * addToolbarSeparator()
 Adds a separator to the window's toolbar. More...
 
void addToRegion(GInteractor *interactor, Region region)
 Adds the given interactor to the given region in this window. More...
 
void addToRegion(GInteractor *interactor, string region="Center")
 Adds the given interactor to the given region in this window. More...
 
void addToRegion(GInteractor &interactor, Region region)
 Adds the given interactor to the given region in this window. More...
 
void addToRegion(GInteractor &interactor, string region="Center")
 Adds the given interactor to the given region in this window. More...
 
void center()
 Relocates the window to the exact center of the current screen. More...
 
void clear()
 Removes all interactors from all regionss of the window. More...
 
void clearCanvas()
 Removes all graphical objects from the graphical canvas in this window and resets the background layer to the window's background color. More...
 
void clearCanvasObjects()
 Removes all graphical objects from the graphical canvas in this window. More...
 
void clearCanvasPixels()
 Resets the background layer of pixels in the window's canvas to the window's background color. More...
 
void clearRegion(Region region)
 Removes all interactors from the given region of this window. More...
 
void clearRegion(string region)
 Removes all interactors from the given region of this window. More...
 
void clearToolbarItems()
 Removes all items from the window's toolbar, if present. More...
 
void close()
 Closes the window. More...
 
void conditionalRepaint()
 Repaints the interactor only if its contents have changed. More...
 
void conditionalRepaintRegion(int x, int y, int width, int height)
 Repaints the given region of the interactor only if its contents have changed. More...
 
void conditionalRepaintRegion(const GRectangle &bounds)
 Repaints the given region of the interactor only if its contents have changed. More...
 
void draw (GObject *gobj)
 
void draw (GObject *gobj, double x, double y)
 
void draw (GObject &gobj)
 
void draw (GObject &gobj, double x, double y)
 
void draw (QPainter *painter)
 
void drawArc(double x, double y, double width, double height, double start, double sweep)
 Draws an unfilled arc with the given attributes onto the background pixel layer of this interactor in the current color. More...
 
void drawImage(string filename, double x=0, double y=0)
 Draws an image loaded from the given file name onto the background pixel layer of this interactor at the given x/y location. More...
 
void drawLine(const GPoint &p0, const GPoint &p1)
 Draws a line between the given two points onto the background pixel layer of this interactor at the given x/y location in the current color. More...
 
void drawLine(double x0, double y0, double x1, double y1)
 Draws a line between the given two points onto the background pixel layer of this interactor at the given x/y location in the current color. More...
 
void drawOval(const GRectangle &bounds)
 Draws an unfilled oval with the given bounding box onto the background pixel layer of this interactor at the given x/y location in the current color. More...
 
void drawOval(double x, double y, double width, double height)
 Draws an unfilled oval with the given bounding box onto the background pixel layer of this interactor at the given x/y location in the current color. More...
 
void drawPixel(double x, double y)
 Colors the given x/y pixel of the background layer of this interactor using the interactor's current color. More...
 
void drawPixel(double x, double y, int color)
 Colors the given x/y pixel of the background layer of this interactor using the given color. More...
 
void drawPixel(double x, double y, string color)
 Colors the given x/y pixel of the background layer of this interactor using the given color. More...
 
GPoint drawPolarLine(const GPoint &p0, double r, double theta)
 Draws a line using polar coordinates onto the background pixel layer of this interactor in the current color. More...
 
GPoint drawPolarLine(double x0, double y0, double r, double theta)
 Draws a line using polar coordinates onto the background pixel layer of this interactor in the current color. More...
 
void drawPolygon(std::initializer_list< double > coords)
 Draws an unfilled polygon containing the given points onto the background pixel layer of this interactor in the current color. More...
 
void drawPolygon(std::initializer_list< GPoint > points)
 Draws an unfilled polygon containing the given points onto the background pixel layer of this interactor in the current color. More...
 
void drawRect(const GRectangle &bounds)
 Draws an unfilled rectangle of the given dimensions onto the background pixel layer of this interactor in the current color. More...
 
void drawRect(double x, double y, double width, double height)
 Draws an unfilled rectangle of the given dimensions onto the background pixel layer of this interactor in the current color. More...
 
void drawString(string text, double x, double y)
 Draws a text string onto the background pixel layer of this interactor at the given x/y location in the current font and color. More...
 
void fillArc(double x, double y, double width, double height, double start, double sweep)
 Draws a filled arc with the given attributes onto the background pixel layer of this interactor in the current color and fill color. More...
 
void fillOval(const GRectangle &bounds)
 Draws a filled oval with the given bounding box onto the background pixel layer of this interactor at the given x/y location in the current color and fill color. More...
 
void fillOval(double x, double y, double width, double height)
 Draws a filled oval with the given bounding box onto the background pixel layer of this interactor at the given x/y location in the current color and fill color. More...
 
void fillPolygon(std::initializer_list< double > coords)
 Draws a filled polygon containing the given points onto the background pixel layer of this interactor in the current color and fill color. More...
 
void fillRect(const GRectangle &bounds)
 Draws a filled rectangle of the given dimensions onto the background pixel layer of this interactor in the current color and fill color. More...
 
void fillRect(double x, double y, double width, double height)
 Draws a filled rectangle of the given dimensions onto the background pixel layer of this interactor in the current color and fill color. More...
 
int getARGB(double x, double y) const
 Returns the pixel color data at the given x/y location, retaining alpha-channel transparency in the top 8 bits. More...
 
string getBackground() const
 Returns the current background color of the interactor as a string. More...
 
int getBackgroundInt() const
 Returns the current background color of the interactor as an RGB integer. More...
 
GCanvasgetCanvas() const
 Returns a direct pointer to the window's internal graphical canvas on which shapes and objects are drawn. More...
 
double getCanvasHeight() const
 Returns the height of the window's central canvas area in pixels. More...
 
GDimension getCanvasSize() const
 Returns the width and height of the window's central canvas area in pixels. More...
 
double getCanvasWidth() const
 Returns the width of the window's central canvas area in pixels. More...
 
CloseOperation getCloseOperation() const
 Returns a constant representing the action that will be taken when the user closes the window. More...
 
string getColor() const
 Returns the current foreground outline color of the interactor as a string. More...
 
int getColorInt() const
 Returns the current foreground outline color of the interactor as an RGB integer. More...
 
string getFillColor() const
 Returns the current fill color of the interactor as a string. More...
 
int getFillColorInt() const
 Returns the current fill color of the interactor as an RGB integer. More...
 
string getFont() const
 Returns the current text font of the interactor as a font string. More...
 
string getForeground() const
 Returns the current foreground outline color of the interactor as a string. More...
 
int getForegroundInt() const
 Returns the current foreground outline color of the interactor as an RGB integer. More...
 
GObjectgetGObject(int index) const
 Returns the graphical object at the given 0-based index in the window's graphical canvas. More...
 
GObjectgetGObjectAt(double x, double y) const
 Returns the top-most graphical object in the z-ordering in the window's graphical canvas that touches the given x/y pixel location. More...
 
int getGObjectCount() const
 Returns the total number of graphical objects in the window's canvas. More...
 
double getHeight() const
 Returns the total height of the window in pixels, including its title bar, menus, borders, etc. More...
 
GObject::LineStyle getLineStyle() const
 Returns the current line style which will be used to draw outlines of shapes and lines. More...
 
double getLineWidth() const
 Returns the thickness used when drawing outlines of shapes and lines. More...
 
GPoint getLocation() const
 Returns the x/y location of the top-left corner of the window on screen. More...
 
int getPixel (double x, double y) const
 
int getPixelARGB (double x, double y) const
 
Grid< int > getPixels () const
 
Grid< int > getPixelsARGB () const
 
string getPixelString(double x, double y) const
 Returns the color of the pixel at the given x/y coordinates of the image as a string such as "#ff00cc". More...
 
GDimension getPreferredSize() const
 Returns the size that the window would prefer to be. More...
 
double getRegionHeight(Region region) const
 Returns the height of the given region of the window in pixels. More...
 
double getRegionHeight(string region) const
 Returns the height of the given region of the window in pixels. More...
 
GDimension getRegionSize(Region region) const
 Returns the width and height of the given region of the window in pixels. More...
 
GDimension getRegionSize(string region) const
 Returns the width and height of the given region of the window in pixels. More...
 
double getRegionWidth(Region region) const
 Returns the width of the given region of the window in pixels. More...
 
double getRegionWidth(string region) const
 Returns the width of the given region of the window in pixels. More...
 
int getRGB(double x, double y) const
 Returns the color of the pixel at the given x/y coordinates of the background layer of the interactor as an integer such as 0xff00cc. More...
 
string getRGBString(double x, double y) const
 Returns the color of the pixel at the given x/y coordinates of the background layer of the interactor as a color string such as "#ff00cc". More...
 
GDimension getSize() const
 Returns the total width and height of the window in pixels, including its title bar, menus, borders, etc. More...
 
string getTitle() const
 Returns the title bar text for the window. More...
 
string getType() const
 Returns the concrete type of the object as a string, such as "GButton" or "GWindow". More...
 
double getWidth() const
 Returns the total width of the window in pixels, including its title bar, menus, borders, etc. More...
 
double getX() const
 Returns the x location of the left edge of the window on screen. More...
 
double getY() const
 Returns the y location of the top edge of the window on screen. More...
 
bool hasToolbar() const
 Returns true if this window has a toolbar. More...
 
void hide()
 Makes the window be not visible on the screen. More...
 
bool inBounds(double x, double y) const
 Returns true if the given x/y location is within the bounds of the entire window. More...
 
bool inCanvasBounds(double x, double y) const
 Returns true if the given x/y location is within the bounds of the central canvas area of the window. More...
 
bool isAutoRepaint () const
 
bool isMaximized() const
 Returns true if the window is in a maximized state, occupying the entire screen. More...
 
bool isMinimized() const
 Returns true if the window is in a minimized (iconified) state, which often displays as the window being hidden except for a task bar icon. More...
 
bool isOpen() const
 Returns true if the window is currently open and visible on the screen. More...
 
bool isRepaintImmediately() const
 Returns true if the interactor should repaint itself automatically whenever any change is made to its graphical data. More...
 
bool isResizable() const
 Returns true if the window allows itself to be resized. More...
 
bool isVisible() const
 Returns true if the window is visible on the screen. More...
 
void loadCanvasPixels(string filename)
 Reads pixel data from the file with the given name and loads it into the window's canvas area. More...
 
void maximize()
 Puts the window in a maximized state, occupying the entire screen. More...
 
void minimize()
 Puts the window in a minimized (iconified) state, which often displays as the window being hidden except for a task bar icon. More...
 
void pack()
 Resizes the window to its preferred size. More...
 
void pause(double ms)
 Causes the current thread to pause itself for the given number of milliseconds. More...
 
void remove(GInteractor *interactor)
 Removes the given interactor from the window. More...
 
void remove(GInteractor &interactor)
 Removes the given interactor from the window. More...
 
void remove(GObject *obj)
 Removes the given graphical object from the canvas of this window, if it was present. More...
 
void remove(GObject &obj)
 Removes the given graphical object from the canvas of this window, if it was present. More...
 
void removeClickListener()
 Removes the click listener from this window so that it will no longer call it when events occur. More...
 
void removeFromRegion(GInteractor *interactor, Region region)
 Removes the given interactor from the given region within this window. More...
 
void removeFromRegion(GInteractor *interactor, string region)
 Removes the given interactor from the given region within this window. More...
 
void removeFromRegion(GInteractor &interactor, Region region)
 Removes the given interactor from the given region within this window. More...
 
void removeFromRegion(GInteractor &interactor, string region)
 Removes the given interactor from the given region within this window. More...
 
void removeKeyListener()
 Removes the key listener from this window so that it will no longer call it when events occur. More...
 
void removeMenuListener()
 Removes the menu listener from this window so that it will no longer call it when events occur. More...
 
void removeMouseListener()
 Removes the mouse listener from this window so that it will no longer call it when events occur. More...
 
void removeTimerListener()
 Removes the timer listener from this window so that it will no longer call it when events occur. More...
 
void removeToolbar()
 Removes the toolbar from this window, if one was present. More...
 
void removeWindowListener()
 Removes the window listener from this window so that it will no longer call it when events occur. More...
 
void repaint ()
 
void repaintRegion(const GRectangle &bounds)
 Instructs the interactor to repaint the given region of pixel data. More...
 
void repaintRegion (int x, int y, int width, int height)
 
void requestFocus()
 Asks the system to assign the keyboard focus to the window, which brings it to the top and ensures that key events are delivered to the window. More...
 
void restore()
 Puts the window in a normal state, neither minimized or maximized. More...
 
void saveCanvasPixels(string filename)
 Writes the contents of the window's graphical canvas to the given output filename. More...
 
void setAutoRepaint (bool autoRepaint)
 
void setBackground(int color)
 Sets the current background color of the interactor as an RGB integer. More...
 
void setBackground(string color)
 Sets the current background color of the interactor as a string. More...
 
void setCanvasHeight(double height)
 Resizes the window so that its central canvas region will occupy exactly the given height in pixels, without changing its width. More...
 
void setCanvasSize(double width, double height)
 Resizes the window so that its central canvas region will occupy exactly the given width and height in pixels. More...
 
void setCanvasSize(const GDimension &size)
 Resizes the window so that its central canvas region will occupy exactly the given width and height in pixels. More...
 
void setCanvasWidth(double width)
 Resizes the window so that its central canvas region will occupy exactly the given width in pixels, without changing its height. More...
 
void setClickListener(GEventListener func)
 Sets a mouse listener on this window so that it will be called when the mouse is clicked on the window's canvas. More...
 
void setClickListener(GEventListenerVoid func)
 Sets a mouse listener on this window so that it will be called when the mouse is clicked on the window's canvas. More...
 
void setCloseOperation(CloseOperation op)
 Sets what should happen when the window is closed. More...
 
void setColor (int color)
 
void setColor (string color)
 
void setEventsEnabled(bool eventsEnabled)
 Sets whether the object is currently allowing itself to fire events. More...
 
void setExitOnClose(bool exitOnClose)
 Sets whether the library's GUI system should shut down when the window is closed. More...
 
void setFillColor (int color)
 
void setFillColor (string color)
 
void setFont (const QFont &font)
 
void setFont (string font)
 
void setForeground(int color)
 Sets the current foreground outline color of the interactor as an RGB integer. More...
 
void setForeground(string color)
 Sets the current foreground outline color of the interactor as a string. More...
 
void setHeight(double width)
 Sets the window's total height in pixels. More...
 
void setKeyListener(GEventListener func)
 Sets a key listener on this window so that it will be called when the user presses any key. More...
 
void setKeyListener(GEventListenerVoid func)
 Sets a key listener on this window so that it will be called when the user presses any key. More...
 
void setLineStyle(GObject::LineStyle lineStyle)
 Sets the current line style which will be used to draw outlines of shapes and lines. More...
 
void setLineWidth (double lineWidth)
 
void setLocation(double x, double y)
 Sets the window's top-left x/y location on the screen to the given coordinates. More...
 
void setLocation(const GPoint &p)
 Sets the window's top-left x/y location on the screen to the given point. More...
 
void setLocation(const Point &p)
 Sets the window's top-left x/y location on the screen to the given point. More...
 
void setMenuItemEnabled(string menu, string item, bool enabled)
 Sets whether the given item in the given menu is enabled or disabled. More...
 
void setMenuListener(GEventListener func)
 Sets a menu listener on this window so that it will be called when menu items are clicked, sending an ACTION_MENU action event. More...
 
void setMenuListener(GEventListenerVoid func)
 Sets a menu listener on this window so that it will be called when menu items are clicked. More...
 
void setMouseListener(GEventListener func)
 Sets a mouse listener on the window's canvas so that it will be called when the user moves or clicks the mouse on the canvas. More...
 
void setMouseListener(GEventListenerVoid func)
 Sets a mouse listener on the window's canvas so that it will be called when the user moves or clicks the mouse on the canvas. More...
 
void setPixel(double x, double y, string color)
 Sets the color of the given x/y pixel in the background layer of the interactor to the given color. More...
 
void setPixel (double x, double y, int rgb)
 
void setPixel (double x, double y, int r, int g, int b)
 
void setPixelARGB (double x, double y, int argb)
 
void setPixelARGB (double x, double y, int a, int r, int g, int b)
 
void setPixels (const Grid< int > &pixels)
 
void setPixelsARGB (const Grid< int > &pixelsARGB)
 
void setRegionAlignment(Region region, HorizontalAlignment halign)
 Sets the horizontal alignment of interactors in the given region of the window. More...
 
void setRegionAlignment(Region region, VerticalAlignment valign)
 Sets the vertical alignment of interactors in the given region of the window. More...
 
void setRegionAlignment(Region region, HorizontalAlignment halign, VerticalAlignment valign)
 Sets the horizontal and vertical alignment of interactors in the given region of the window. More...
 
void setRegionAlignment(string region, string align)
 Sets the horizontal and/or vertical alignment of interactors in the given region of the window. More...
 
void setRegionAlignment(string region, string halign, string valign)
 Sets the horizontal and vertical alignment of interactors in the given region of the window. More...
 
void setRegionHorizontalAlignment(Region region, HorizontalAlignment halign)
 Sets the horizontal alignment of interactors in the given region of the window. More...
 
void setRegionHorizontalAlignment(string region, string halign)
 Sets the horizontal alignment of interactors in the given region of the window. More...
 
void setRegionVerticalAlignment(string region, string valign)
 Sets the vertical alignment of interactors in the given region of the window. More...
 
void setRegionVerticalAlignment(Region region, VerticalAlignment valign)
 Sets the vertical alignment of interactors in the given region of the window. More...
 
void setRepaintImmediately (bool repaintImmediately)
 
void setResizable(bool resizable)
 Sets whether the window allows itself to be resized. More...
 
void setRGB(double x, double y, int rgb)
 Sets the color of the given x/y pixel in the background layer of the interactor to the given RGB values. More...
 
void setRGB(double x, double y, int r, int g, int b)
 Sets the color of the given x/y pixel in the background layer of the interactor to the given RGB values. More...
 
void setRGB(double x, double y, string color)
 Sets the color of the given x/y pixel in the background layer of the interactor to the given color. More...
 
void setSize(double width, double height)
 Sets the window's total width and height in pixels. More...
 
void setSize(const GDimension &size)
 Sets the window's width and height in pixels. More...
 
void setTimerListener(double ms, GEventListener func)
 Sets a menu listener on this window so that it will be called when timer delays elapse, sending a timer event. More...
 
void setTimerListener(double ms, GEventListenerVoid func)
 Sets a menu listener on this window so that it will be called when timer delays elapse, sending a timer event. More...
 
void setTitle(string title)
 Sets the window's title bar text to the given string. More...
 
void setVisible(bool visible)
 Sets whether the window can be seen on the screen. More...
 
void setWidth(double width)
 Sets the window's total width in pixels. More...
 
void setWindowIcon(string iconFile)
 Sets the window to use the. More...
 
void setWindowListener(GEventListener func)
 Sets a window listener on this window so that it will be called when window events occur, such as resizing or closing the window. More...
 
void setWindowListener(GEventListenerVoid func)
 Sets a window listener on this window so that it will be called when window events occur, such as resizing or closing the window. More...
 
void setWindowTitle(string title)
 Sets the window's title bar text to the given string. More...
 
void setX(double x)
 Sets the window's left x location on the screen to the given coordinate. More...
 
void setY(double y)
 Sets the window's top y location on the screen to the given coordinate. More...
 
void show()
 Sets the window to be visible on the screen. More...
 
void sleep(double ms)
 Causes the current thread to pause itself for the given number of milliseconds. More...
 
void toBack()
 Moves the window to the back of the z-ordering in the operating system, underneath any other windows that occupy the same pixels. More...
 
void toFront()
 Moves the window to the front of the z-ordering in the operating system, in front of any other windows that occupy the same pixels. More...
 
string toString() const
 Returns a string representation of this observable object's state. More...
 

Static Public Member Functions

static void _autograder_setExitGraphicsEnabled(bool enabled)
 An internal function that disables the exitGraphics function so that students cannot exit their programs during autograding. More...
 
static void _autograder_setPauseEnabled(bool enabled)
 An internal function that disables the pause function so that students cannot pausetheir programs during autograding. More...
 
static int getScreenDpi()
 Returns the dots-per-inch of the screen. More...
 
static double getScreenDpiScaleRatio()
 Returns the ratio of this screen's DPI compared to a normal low-DPI screen. More...
 
static double getScreenHeight()
 Returns the height of the entire screen in pixels. More...
 
static GDimension getScreenSize()
 Returns the width and height of the entire screen in pixels. More...
 
static double getScreenWidth()
 Returns the width of the entire screen in pixels. More...
 
static bool isHighDensityScreen()
 Returns whether the dots-per-inch of the screen are high enough to consider it a "high-density" screen for which scaling should be used. More...
 
static bool isHighDpiScalingEnabled()
 Returns whether we should scale some windows when run on high-density screens. More...
 

Static Public Attributes

static const int DEFAULT_HEIGHT = 300
 The default height of a newly created window in pixels if its height is not explicitly specified. More...
 
static const string DEFAULT_ICON_FILENAME = "splicon-large.png"
 The default file name used to load a GWindow's initial title bar icon. More...
 
static const int DEFAULT_WIDTH = 500
 The default width of a newly created window in pixels if its width is not explicitly specified. More...
 
static const int HIGH_DPI_SCREEN_THRESHOLD = 200
 The minimum number of dots per inch before a screen is considered to be high-density or high-DPI. More...
 
static const int STANDARD_SCREEN_DPI = 96
 The minimum number of dots per inch on a "normal" low-DPI screen. More...
 

Protected Member Functions

void checkBounds(string member, double x, double y, double width, double height) const
 Throws an error if the given x/y values are out of bounds. More...
 
void checkColor(string member, int rgb) const
 Throws an error if the given rgb value is not a valid color. More...
 
void checkSize(string member, double width, double height) const
 Throws an error if the given width/height values are out of bounds. More...
 
void clearEventListeners()
 Removes all event listeners from this object. More...
 
void ensureForwardTargetConstHack () const
 
void ensureThreadSafety(string memberName="")
 Ensures that we are currently in the Qt GUI thread. More...
 
void fireEvent(GEvent &event)
 Sends out the given event to any attached listeners. More...
 
void fireGEvent(QEvent *event, EventType eventType, string eventName)
 Creates an event of the given type, then sends it out to any attached listeners. More...
 
void fireGEvent(QCloseEvent *event, EventType eventType, string eventName)
 Creates an event of the given type, then sends it out to any attached listeners. More...
 
void fireGEvent(QKeyEvent *event, EventType eventType, string eventName)
 Creates an event of the given type, then sends it out to any attached listeners. More...
 
void fireGEvent(QMouseEvent *event, EventType eventType, string eventName, string actionCommand="")
 Creates an event of the given type, then sends it out to any attached listeners. More...
 
void fireGEvent(QResizeEvent *event, EventType eventType, string eventName)
 Creates an event of the given type, then sends it out to any attached listeners. More...
 
void fireGEvent(QTimerEvent *event, EventType eventType, string eventName)
 Creates an event of the given type, then sends it out to any attached listeners. More...
 
void fireGEvent(QWheelEvent *event, EventType eventType, string eventName)
 Creates an event of the given type, then sends it out to any attached listeners. More...
 
void fireGEvent(QWindowStateChangeEvent *event, EventType eventType, string eventName)
 Creates an event of the given type, then sends it out to any attached listeners. More...
 
bool hasEventListener(string eventName) const
 Returns true if the observable object has a listener for the given type of event. More...
 
void initializeGObject(GObject &obj, bool filled=false)
 Initializes a new graphical object to be drawn. More...
 
void initializeGObject(GObject *obj, bool filled=false)
 Initializes a new graphical object to be drawn. More...
 
bool isAcceptingEvent(int eventMask) const
 Returns true if the observable object has a listener for the given type of event. More...
 
bool isAcceptingEvent(const GEvent &event) const
 Returns true if the observable object has a listener for the given type of event. More...
 
bool isAcceptingEvent(string eventType) const
 Returns true if the observable object has a listener for the given type of event. More...
 
void removeEventListener(string eventName)
 Removes any event listener from this observable object that would respond to the given type of event, such as "click" or "keydown". More...
 
void removeEventListeners(std::initializer_list< string > eventNames)
 Removes any event listener from this observable object that would respond to the given types of events, such as "click" or "keydown". More...
 
void setEventListener(string eventName, GEventListener func)
 Adds an event listener from this observable object to respond to the given type of event, such as "click" or "keydown". More...
 
void setEventListener(string eventName, GEventListenerVoid func)
 Adds an event listener from this observable object to respond to the given type of event, such as "click" or "keydown". More...
 
void setEventListeners(std::initializer_list< string > eventNames, GEventListener func)
 Adds an event listener from this observable object to respond to the given types of events, such as "click" or "keydown". More...
 
void setEventListeners(std::initializer_list< string > eventNames, GEventListenerVoid func)
 Adds an event listener from this observable object to respond to the given types of events, such as "click" or "keydown". More...
 

Protected Attributes

bool _autoRepaint
 
string _backgroundColor
 
int _backgroundColorInt
 
string _color
 
int _colorInt
 
string _fillColor
 
int _fillColorInt
 
string _font
 
GDrawingSurface_forwardTarget
 
GObject::LineStyle _lineStyle
 
double _lineWidth
 

Detailed Description

This class represents a graphics window that supports simple graphics.

A GWindow is a first-class citizen in our GUI subsystem; all graphical programs will create at least one GWindow to hold other interactors and graphical objects for display on the screen.

A GWindow simultaneously serves two major graphical purposes:

1) A top-level container for interactors. You can call the addToRegion and add methods to add interactors to the north, south, west, east, and center regions of the window. The center region holds at most one interactor that expands in both dimensions to fill pixels not occupied by the other four regions. This is analogous to Java AWT/Swing's BorderLayout system. The window uses an internal GContainer that we call its "content pane" to layout the positions and sizes of these interactors. See gcontainer.h for more detail about layout and containers.

2) A graphical canvas for drawing shapes, lines, and colors. A GWindow contains a central graphical canvas that is implemented as an object of type GCanvas. The canvas will appear on the window the moment you call any drawing method on the window.

The graphical canvas consists of two layers. The background layer provides a surface for drawing static pictures that involve no animation, or for 2D pixel-based drawing algorithms. See gcanvas.h and gobjects.h for more detail about drawing shapes, objects, and pixels.

The GWindow class includes several drawXxx and fillXxx methods that draw lines, rectangles, and ovals on the background layer without the client needing to directly create objects from the gobjects.h hierarchy.

The foreground layer provides an abstraction for adding stateful shapes and graphical objects onto the canvas. The add() methods that accept GObject parameters place these objects onto the foreground layer. The advantage of the foreground layer is that you can manipulate the object over time, such as moving it, changing its color, size, or other properties, and see these changes immediately on the screen. This makes the foreground layer most appropriate for animations or moving sprites.

You can use the two GWindow paradigms together in the same window. For example, you can place a row of buttons in the north or south while drawing shapes onto the canvas in the center of the window.

If you add() a GInteractor to the center region of the window, we will assume that you do not want the graphical canvas and will replace it with the added interactor.

Member Enumeration Documentation

◆ CloseOperation

The various actions that can occur when a window closes.

Enumerator
CLOSE_DO_NOTHING 
CLOSE_HIDE 
CLOSE_DISPOSE 
CLOSE_EXIT 

◆ Region

enum Region

The five regions of window border layouts.

Enumerator
REGION_CENTER 
REGION_EAST 
REGION_NORTH 
REGION_SOUTH 
REGION_WEST 

Constructor & Destructor Documentation

◆ GWindow() [1/3]

GWindow ( bool  visible = true)

Creates a new window of a default width and height.

◆ GWindow() [2/3]

GWindow ( double  width,
double  height,
bool  visible = true 
)

Creates a new window of the given width and height.

◆ GWindow() [3/3]

GWindow ( double  x,
double  y,
double  width,
double  height,
bool  visible = true 
)

Creates a new window of the given location and size.

◆ ~GWindow()

~GWindow ( )
virtual

Frees memory allocated internally by the window.

Member Function Documentation

◆ _autograder_setExitGraphicsEnabled()

void _autograder_setExitGraphicsEnabled ( bool  enabled)
static

An internal function that disables the exitGraphics function so that students cannot exit their programs during autograding.

This function is effectively private and should not be called by students.

◆ _autograder_setIsAutograderWindow()

void _autograder_setIsAutograderWindow ( bool  isAutograderWindow)
virtual

An internal function that sets whether the current window is part of an autograder program.

This function is effectively private and should not be called by students.

◆ _autograder_setPauseEnabled()

void _autograder_setPauseEnabled ( bool  enabled)
static

An internal function that disables the pause function so that students cannot pausetheir programs during autograding.

This function is effectively private and should not be called by students.

◆ add() [1/8]

void add ( GInteractor interactor)
virtual

Adds the given interactor to the center region of the window.

This replaces the graphical canvas and causes the canvas to be hidden.

Exceptions
ErrorExceptionif the interactor is null

◆ add() [2/8]

void add ( GInteractor interactor,
double  x,
double  y 
)
virtual

Adds the given interactor to the center region of the window and moves it to the given x/y location.

This replaces the graphical canvas and causes the canvas to be hidden.

Exceptions
ErrorExceptionif the interactor is null

◆ add() [3/8]

void add ( GInteractor interactor)
virtual

Adds the given interactor to the center region of the window.

This replaces the graphical canvas and causes the canvas to be hidden.

◆ add() [4/8]

void add ( GInteractor interactor,
double  x,
double  y 
)
virtual

Adds the given interactor to the center region of the window and moves it to the given x/y location.

This replaces the graphical canvas and causes the canvas to be hidden.

◆ add() [5/8]

void add ( GObject obj)
virtual

Adds the given graphical object to the window's canvas.

This causes the graphical canvas to appear if it was not already showing.

Exceptions
ErrorExceptionif the interactor is null

◆ add() [6/8]

void add ( GObject obj,
double  x,
double  y 
)
virtual

Adds the given graphical object to the window's canvas and moves it to the given x/y location.

This causes the graphical canvas to appear if it was not already showing.

Exceptions
ErrorExceptionif the interactor is null

◆ add() [7/8]

void add ( GObject obj)
virtual

Adds the given graphical object to the window's canvas.

This causes the graphical canvas to appear if it was not already showing.

◆ add() [8/8]

void add ( GObject obj,
double  x,
double  y 
)
virtual

Adds the given graphical object to the window's canvas and moves it to the given x/y location.

This causes the graphical canvas to appear if it was not already showing.

◆ addMenu()

QMenu * addMenu ( string   text)
virtual

Adds a menu with the given text to the window's top menu bar.

If the given menu already exists, returns it without adding it again.

◆ addMenuItem() [1/3]

QAction * addMenuItem ( string   menu,
string   item,
string   icon = "" 
)
virtual

Adds a new menu item to the given menu.

If the given menu item already exists in this menu, returns it without adding it again. You can supply an optional icon to show next to the menu item. When the menu item is clicked, an ACTION_MENU action event will occur.

Exceptions
ErrorExceptionif the given menu does not exist

◆ addMenuItem() [2/3]

QAction * addMenuItem ( string   menu,
string   item,
string   icon,
GEventListenerVoid  func 
)
virtual

Adds a new menu item to the given menu.

If the given menu item already exists in this menu, returns it without adding it again. You can supply an optional icon to show next to the menu item. When the menu item is clicked, the given listener function will be called.

Exceptions
ErrorExceptionif the given menu does not exist

◆ addMenuItem() [3/3]

QAction * addMenuItem ( string   menu,
string   item,
const QIcon &  icon,
GEventListenerVoid  func 
)
virtual

Adds a new menu item to the given menu.

If the given menu item already exists in this menu, returns it without adding it again. You can supply an optional icon to show next to the menu item. When the menu item is clicked, the given listener function will be called.

Exceptions
ErrorExceptionif the given menu does not exist

◆ addMenuItemCheckBox() [1/2]

QAction * addMenuItemCheckBox ( string   menu,
string   item,
bool  checked = false,
string   icon = "" 
)
virtual

Adds a new checkbox menu item to the given menu.

If the given menu item already exists in this menu, returns it without adding it again. You can supply an optional icon to show next to the menu item. When the menu item is clicked, an ACTION_MENU action event will occur.

Exceptions
ErrorExceptionif the given menu does not exist

◆ addMenuItemCheckBox() [2/2]

QAction * addMenuItemCheckBox ( string   menu,
string   item,
bool  checked,
string   icon,
GEventListenerVoid  func 
)
virtual

Adds a new checkbox menu item to the given menu.

If the given menu item already exists in this menu, returns it without adding it again. You can supply an optional icon to show next to the menu item. When the menu item is clicked, the given listener function will be called.

Exceptions
ErrorExceptionif the given menu does not exist

◆ addMenuSeparator()

QAction * addMenuSeparator ( string   menu)
virtual

Adds a horizontal line separator to the end of the given menu.

Exceptions
ErrorExceptionif the given menu does not exist

◆ addSubMenu()

QMenu * addSubMenu ( string   menu,
string   submenu 
)
virtual

Adds a sub-menu within an existing menu.

You can later add items to this sub-menu using:

myWindow->addMenuItem(menu + "/" + submenu, item);

Exceptions
ErrorExceptionif the given menu does not exist

◆ addToolbar()

void addToolbar ( string   title = "")
virtual

Adds a toolbar to this window where action buttons can be placed.

◆ addToolbarItem() [1/3]

QAction * addToolbarItem ( string   item,
string   icon = "" 
)
virtual

Adds a new item to the window's toolbar.

If the window does not have a toolbar, one is added. You can supply an optional icon to show next to the menu item. When the menu item is clicked, an ACTION_MENU action event will occur.

◆ addToolbarItem() [2/3]

QAction * addToolbarItem ( string   item,
string   icon,
GEventListenerVoid  func 
)
virtual

Adds a new item to the window's toolbar.

If the window does not have a toolbar, one is added. You can supply an optional icon to show next to the menu item. When the menu item is clicked, the given listener function will be called.

◆ addToolbarItem() [3/3]

QAction * addToolbarItem ( string   item,
const QIcon &  icon,
GEventListenerVoid  func 
)
virtual

Adds a new item to the window's toolbar.

If the window does not have a toolbar, one is added. You can supply an optional icon to show next to the menu item. When the menu item is clicked, the given listener function will be called.

◆ addToolbarSeparator()

QAction * addToolbarSeparator ( )
virtual

Adds a separator to the window's toolbar.

If the window does not have a toolbar, one is added.

◆ addToRegion() [1/4]

void addToRegion ( GInteractor interactor,
Region  region 
)
virtual

Adds the given interactor to the given region in this window.

Exceptions
ErrorExceptionif the interactor is null

◆ addToRegion() [2/4]

void addToRegion ( GInteractor interactor,
string   region = "Center" 
)
virtual

Adds the given interactor to the given region in this window.

Exceptions
ErrorExceptionif the interactor is null

◆ addToRegion() [3/4]

void addToRegion ( GInteractor interactor,
Region  region 
)
virtual

Adds the given interactor to the given region in this window.

◆ addToRegion() [4/4]

void addToRegion ( GInteractor interactor,
string   region = "Center" 
)
virtual

Adds the given interactor to the given region in this window.

◆ center()

void center ( )
virtual

Relocates the window to the exact center of the current screen.

◆ checkBounds()

void checkBounds ( string   member,
double  x,
double  y,
double  width,
double  height 
) const
protectedinherited

Throws an error if the given x/y values are out of bounds.

◆ checkColor()

void checkColor ( string   member,
int  rgb 
) const
protectedinherited

Throws an error if the given rgb value is not a valid color.

◆ checkSize()

void checkSize ( string   member,
double  width,
double  height 
) const
protectedinherited

Throws an error if the given width/height values are out of bounds.

◆ clear()

void clear ( )
virtual

Removes all interactors from all regionss of the window.

Implements GDrawingSurface.

◆ clearCanvas()

void clearCanvas ( )
virtual

Removes all graphical objects from the graphical canvas in this window and resets the background layer to the window's background color.

◆ clearCanvasObjects()

void clearCanvasObjects ( )
virtual

Removes all graphical objects from the graphical canvas in this window.

This means that any shapes added using the add() methods, such as GRect, GOval, etc. will be removed, while any shapes drawn directly onto the window's background pixel layer by calling the drawXxx() methods will be retained. To clear the background layer as well, call clearCanvasPixels or clearCanvas instead.

◆ clearCanvasPixels()

void clearCanvasPixels ( )
virtual

Resets the background layer of pixels in the window's canvas to the window's background color.

This means that any shapes added using the add() methods, such as GRect, GOval, etc. will remain, while any shapes drawn directly onto the window's background pixel layer by calling the drawXxx() methods will be wiped out. To clear the shapes added to the foreground layer as well, call clearCanvasObjects or clearCanvas instead.

◆ clearEventListeners()

void clearEventListeners ( )
protectedvirtualinherited

Removes all event listeners from this object.

◆ clearRegion() [1/2]

void clearRegion ( Region  region)
virtual

Removes all interactors from the given region of this window.

◆ clearRegion() [2/2]

void clearRegion ( string   region)
virtual

Removes all interactors from the given region of this window.

◆ clearToolbarItems()

void clearToolbarItems ( )
virtual

Removes all items from the window's toolbar, if present.

◆ close()

void close ( )
virtual

Closes the window.

If a window listener has been set, a WINDOW_CLOSING and then WINDOW_CLOSED event is sent to it.

◆ conditionalRepaint()

void conditionalRepaint ( )
virtualinherited

Repaints the interactor only if its contents have changed.

◆ conditionalRepaintRegion() [1/2]

void conditionalRepaintRegion ( int  x,
int  y,
int  width,
int  height 
)
virtualinherited

Repaints the given region of the interactor only if its contents have changed.

◆ conditionalRepaintRegion() [2/2]

void conditionalRepaintRegion ( const GRectangle bounds)
virtualinherited

Repaints the given region of the interactor only if its contents have changed.

◆ draw() [1/5]

void draw ( GObject gobj)
virtualinherited

◆ draw() [2/5]

void draw ( GObject gobj,
double  x,
double  y 
)
virtualinherited

◆ draw() [3/5]

void draw ( GObject gobj)
virtualinherited

◆ draw() [4/5]

void draw ( GObject gobj,
double  x,
double  y 
)
virtualinherited

◆ draw() [5/5]

void draw ( QPainter *  painter)
virtualinherited

◆ drawArc()

void drawArc ( double  x,
double  y,
double  width,
double  height,
double  start,
double  sweep 
)
virtualinherited

Draws an unfilled arc with the given attributes onto the background pixel layer of this interactor in the current color.

See gobjects.h for explanation of GArc parameters.

◆ drawImage()

void drawImage ( string   filename,
double  x = 0,
double  y = 0 
)
virtualinherited

Draws an image loaded from the given file name onto the background pixel layer of this interactor at the given x/y location.

See gobjects.h for explanation of GImage parameters.

Exceptions
ErrorExceptionif the given file is not found or cannot be loaded as a valid image file

◆ drawLine() [1/2]

void drawLine ( const GPoint p0,
const GPoint p1 
)
virtualinherited

Draws a line between the given two points onto the background pixel layer of this interactor at the given x/y location in the current color.

See gobjects.h for explanation of GLine parameters.

◆ drawLine() [2/2]

void drawLine ( double  x0,
double  y0,
double  x1,
double  y1 
)
virtualinherited

Draws a line between the given two points onto the background pixel layer of this interactor at the given x/y location in the current color.

See gobjects.h for explanation of GLine parameters.

◆ drawOval() [1/2]

void drawOval ( const GRectangle bounds)
virtualinherited

Draws an unfilled oval with the given bounding box onto the background pixel layer of this interactor at the given x/y location in the current color.

See gobjects.h for explanation of GOval parameters.

◆ drawOval() [2/2]

void drawOval ( double  x,
double  y,
double  width,
double  height 
)
virtualinherited

Draws an unfilled oval with the given bounding box onto the background pixel layer of this interactor at the given x/y location in the current color.

See gobjects.h for explanation of GOval parameters.

◆ drawPixel() [1/3]

void drawPixel ( double  x,
double  y 
)
virtualinherited

Colors the given x/y pixel of the background layer of this interactor using the interactor's current color.

◆ drawPixel() [2/3]

void drawPixel ( double  x,
double  y,
int  color 
)
virtualinherited

Colors the given x/y pixel of the background layer of this interactor using the given color.

◆ drawPixel() [3/3]

void drawPixel ( double  x,
double  y,
string   color 
)
virtualinherited

Colors the given x/y pixel of the background layer of this interactor using the given color.

◆ drawPolarLine() [1/2]

GPoint drawPolarLine ( const GPoint p0,
double  r,
double  theta 
)
virtualinherited

Draws a line using polar coordinates onto the background pixel layer of this interactor in the current color.

The line begins at the given x/y point and extends from there by the given angle and radius. Returns the end point opposite p0 where the line ends. See gobjects.h for explanation of GLine parameters.

◆ drawPolarLine() [2/2]

GPoint drawPolarLine ( double  x0,
double  y0,
double  r,
double  theta 
)
virtualinherited

Draws a line using polar coordinates onto the background pixel layer of this interactor in the current color.

The line begins at the given x/y point and extends from there by the given angle and radius. Returns the end point where the line ends. See gobjects.h for explanation of GLine parameters.

◆ drawPolygon() [1/2]

void drawPolygon ( std::initializer_list< double >  coords)
virtualinherited

Draws an unfilled polygon containing the given points onto the background pixel layer of this interactor in the current color.

See gobjects.h for explanation of GPolygon parameters.

◆ drawPolygon() [2/2]

void drawPolygon ( std::initializer_list< GPoint points)
virtualinherited

Draws an unfilled polygon containing the given points onto the background pixel layer of this interactor in the current color.

See gobjects.h for explanation of GPolygon parameters.

◆ drawRect() [1/2]

void drawRect ( const GRectangle bounds)
virtualinherited

Draws an unfilled rectangle of the given dimensions onto the background pixel layer of this interactor in the current color.

See gobjects.h for explanation of GRect parameters.

◆ drawRect() [2/2]

void drawRect ( double  x,
double  y,
double  width,
double  height 
)
virtualinherited

Draws an unfilled rectangle of the given dimensions onto the background pixel layer of this interactor in the current color.

See gobjects.h for explanation of GRect parameters.

◆ drawString()

void drawString ( string   text,
double  x,
double  y 
)
virtualinherited

Draws a text string onto the background pixel layer of this interactor at the given x/y location in the current font and color.

See gobjects.h for explanation of GText parameters.

◆ ensureForwardTargetConstHack()

void ensureForwardTargetConstHack ( ) const
protectedvirtualinherited

◆ ensureThreadSafety()

void ensureThreadSafety ( string   memberName = "")
protectedvirtualinherited

Ensures that we are currently in the Qt GUI thread.

◆ fillArc()

void fillArc ( double  x,
double  y,
double  width,
double  height,
double  start,
double  sweep 
)
virtualinherited

Draws a filled arc with the given attributes onto the background pixel layer of this interactor in the current color and fill color.

See gobjects.h for explanation of GArc parameters.

◆ fillOval() [1/2]

void fillOval ( const GRectangle bounds)
virtualinherited

Draws a filled oval with the given bounding box onto the background pixel layer of this interactor at the given x/y location in the current color and fill color.

See gobjects.h for explanation of GOval parameters.

◆ fillOval() [2/2]

void fillOval ( double  x,
double  y,
double  width,
double  height 
)
virtualinherited

Draws a filled oval with the given bounding box onto the background pixel layer of this interactor at the given x/y location in the current color and fill color.

See gobjects.h for explanation of GOval parameters.

◆ fillPolygon()

void fillPolygon ( std::initializer_list< double >  coords)
virtualinherited

Draws a filled polygon containing the given points onto the background pixel layer of this interactor in the current color and fill color.

See gobjects.h for explanation of GPolygon parameters.

◆ fillRect() [1/2]

void fillRect ( const GRectangle bounds)
virtualinherited

Draws a filled rectangle of the given dimensions onto the background pixel layer of this interactor in the current color and fill color.

See gobjects.h for explanation of GRect parameters.

◆ fillRect() [2/2]

void fillRect ( double  x,
double  y,
double  width,
double  height 
)
virtualinherited

Draws a filled rectangle of the given dimensions onto the background pixel layer of this interactor in the current color and fill color.

See gobjects.h for explanation of GRect parameters.

◆ fireEvent()

void fireEvent ( GEvent event)
protectedvirtualinherited

Sends out the given event to any attached listeners.

◆ fireGEvent() [1/8]

void fireGEvent ( QEvent *  event,
EventType  eventType,
string   eventName 
)
protectedvirtualinherited

Creates an event of the given type, then sends it out to any attached listeners.

◆ fireGEvent() [2/8]

void fireGEvent ( QCloseEvent *  event,
EventType  eventType,
string   eventName 
)
protectedvirtualinherited

Creates an event of the given type, then sends it out to any attached listeners.

◆ fireGEvent() [3/8]

void fireGEvent ( QKeyEvent *  event,
EventType  eventType,
string   eventName 
)
protectedvirtualinherited

Creates an event of the given type, then sends it out to any attached listeners.

◆ fireGEvent() [4/8]

void fireGEvent ( QMouseEvent *  event,
EventType  eventType,
string   eventName,
string   actionCommand = "" 
)
protectedvirtualinherited

Creates an event of the given type, then sends it out to any attached listeners.

◆ fireGEvent() [5/8]

void fireGEvent ( QResizeEvent *  event,
EventType  eventType,
string   eventName 
)
protectedvirtualinherited

Creates an event of the given type, then sends it out to any attached listeners.

◆ fireGEvent() [6/8]

void fireGEvent ( QTimerEvent *  event,
EventType  eventType,
string   eventName 
)
protectedvirtualinherited

Creates an event of the given type, then sends it out to any attached listeners.

◆ fireGEvent() [7/8]

void fireGEvent ( QWheelEvent *  event,
EventType  eventType,
string   eventName 
)
protectedvirtualinherited

Creates an event of the given type, then sends it out to any attached listeners.

◆ fireGEvent() [8/8]

void fireGEvent ( QWindowStateChangeEvent *  event,
EventType  eventType,
string   eventName 
)
protectedvirtualinherited

Creates an event of the given type, then sends it out to any attached listeners.

◆ getARGB()

int getARGB ( double  x,
double  y 
) const
virtualinherited

Returns the pixel color data at the given x/y location, retaining alpha-channel transparency in the top 8 bits.

◆ getBackground()

string getBackground ( ) const
virtualinherited

Returns the current background color of the interactor as a string.

See gcolor.h for more detail about color strings.

Reimplemented in GCanvas.

◆ getBackgroundInt()

int getBackgroundInt ( ) const
virtualinherited

Returns the current background color of the interactor as an RGB integer.

See gcolor.h for more detail about colors.

Reimplemented in GCanvas.

◆ getCanvas()

GCanvas * getCanvas ( ) const
virtual

Returns a direct pointer to the window's internal graphical canvas on which shapes and objects are drawn.

Use with care!

◆ getCanvasHeight()

double getCanvasHeight ( ) const
virtual

Returns the height of the window's central canvas area in pixels.

◆ getCanvasSize()

GDimension getCanvasSize ( ) const
virtual

Returns the width and height of the window's central canvas area in pixels.

◆ getCanvasWidth()

double getCanvasWidth ( ) const
virtual

Returns the width of the window's central canvas area in pixels.

◆ getCloseOperation()

GWindow::CloseOperation getCloseOperation ( ) const
virtual

Returns a constant representing the action that will be taken when the user closes the window.

◆ getColor()

string getColor ( ) const
virtualinherited

Returns the current foreground outline color of the interactor as a string.

This color will be used to draw the outlines of shapes drawn using the drawXxx and fillXxx methods, as well as being the default color used when calling setPixel or setRGB. See gcolor.h for more detail about color strings. Equivalent to getForeground.

◆ getColorInt()

int getColorInt ( ) const
virtualinherited

Returns the current foreground outline color of the interactor as an RGB integer.

This color will be used to draw the outlines of shapes drawn using the drawXxx and fillXxx methods, as well as being the default color used when calling setPixel or setRGB. See gcolor.h for more detail about colors. Equivalent to getForegroundInt.

◆ getFillColor()

string getFillColor ( ) const
virtualinherited

Returns the current fill color of the interactor as a string.

This color will appear in shapes drawn using the fillXxx methods. See gcolor.h for more detail about color strings.

◆ getFillColorInt()

int getFillColorInt ( ) const
virtualinherited

Returns the current fill color of the interactor as an RGB integer.

This color will appear in shapes drawn using the fillXxx methods. See gcolor.h for more detail about color strings.

◆ getFont()

string getFont ( ) const
virtualinherited

Returns the current text font of the interactor as a font string.

This font will be used when drawing text strings using drawString. See gfont.h for more detail about font strings.

Reimplemented in GCanvas.

◆ getForeground()

string getForeground ( ) const
virtualinherited

Returns the current foreground outline color of the interactor as a string.

This color will be used to draw the outlines of shapes drawn using the drawXxx and fillXxx methods, as well as being the default color used when calling setPixel or setRGB. See gcolor.h for more detail about color strings. Equivalent to getColor.

◆ getForegroundInt()

int getForegroundInt ( ) const
virtualinherited

Returns the current foreground outline color of the interactor as an RGB integer.

This color will be used to draw the outlines of shapes drawn using the drawXxx and fillXxx methods, as well as being the default color used when calling setPixel or setRGB. See gcolor.h for more detail about colors. Equivalent to getColor.

◆ getGObject()

GObject * getGObject ( int  index) const
virtual

Returns the graphical object at the given 0-based index in the window's graphical canvas.

Exceptions
ErrorExceptionif the index is out of bounds

◆ getGObjectAt()

GObject * getGObjectAt ( double  x,
double  y 
) const
virtual

Returns the top-most graphical object in the z-ordering in the window's graphical canvas that touches the given x/y pixel location.

If no object touches the given location, returns nullptr.

◆ getGObjectCount()

int getGObjectCount ( ) const
virtual

Returns the total number of graphical objects in the window's canvas.

◆ getHeight()

double getHeight ( ) const
virtual

Returns the total height of the window in pixels, including its title bar, menus, borders, etc.

◆ getLineStyle()

GObject::LineStyle getLineStyle ( ) const
virtualinherited

Returns the current line style which will be used to draw outlines of shapes and lines.

The default line style is a solid line (GObject::LINE_SOLID).

◆ getLineWidth()

double getLineWidth ( ) const
virtualinherited

Returns the thickness used when drawing outlines of shapes and lines.

The default thickness is 1.

◆ getLocation()

GPoint getLocation ( ) const
virtual

Returns the x/y location of the top-left corner of the window on screen.

◆ getPixel()

int getPixel ( double  x,
double  y 
) const
virtualinherited

◆ getPixelARGB()

int getPixelARGB ( double  x,
double  y 
) const
virtualinherited

◆ getPixels()

Grid< int > getPixels ( ) const
virtualinherited

◆ getPixelsARGB()

Grid< int > getPixelsARGB ( ) const
virtualinherited

◆ getPixelString()

string getPixelString ( double  x,
double  y 
) const
virtualinherited

Returns the color of the pixel at the given x/y coordinates of the image as a string such as "#ff00cc".

The string that is returned comes from the GWindow function convertRGBToColor; see documentation of that function. Throws an error if the given x/y values are out of bounds.

◆ getPreferredSize()

GDimension getPreferredSize ( ) const
virtual

Returns the size that the window would prefer to be.

The window prefers to be exactly the right size to fit the interactors placed inside it at their own preferred sizes without stretching. This is the size that the window will be set to if you call pack().

◆ getRegionHeight() [1/2]

double getRegionHeight ( Region  region) const
virtual

Returns the height of the given region of the window in pixels.

◆ getRegionHeight() [2/2]

double getRegionHeight ( string   region) const
virtual

Returns the height of the given region of the window in pixels.

◆ getRegionSize() [1/2]

GDimension getRegionSize ( Region  region) const
virtual

Returns the width and height of the given region of the window in pixels.

◆ getRegionSize() [2/2]

GDimension getRegionSize ( string   region) const
virtual

Returns the width and height of the given region of the window in pixels.

◆ getRegionWidth() [1/2]

double getRegionWidth ( Region  region) const
virtual

Returns the width of the given region of the window in pixels.

◆ getRegionWidth() [2/2]

double getRegionWidth ( string   region) const
virtual

Returns the width of the given region of the window in pixels.

◆ getRGB()

int getRGB ( double  x,
double  y 
) const
virtualinherited

Returns the color of the pixel at the given x/y coordinates of the background layer of the interactor as an integer such as 0xff00cc.

Note that if you are planning to set many pixels in the background and want maximum performance, you should instead call getPixels to extract all pixels into a Grid, then manipulate all desired pixels in that Grid, then call setPixels to submit all of your changes.

Equivalent to getPixel.

Exceptions
ErrorExceptionif the given x/y values are out of bounds.

◆ getRGBString()

string getRGBString ( double  x,
double  y 
) const
virtualinherited

Returns the color of the pixel at the given x/y coordinates of the background layer of the interactor as a color string such as "#ff00cc".

Note that if you are planning to set many pixels in the background and want maximum performance, you should instead call getPixels to extract all pixels into a Grid, then manipulate all desired pixels in that Grid, then call setPixels to submit all of your changes.

Exceptions
ErrorExceptionif the given x/y values are out of bounds.

◆ getScreenDpi()

int getScreenDpi ( )
static

Returns the dots-per-inch of the screen.

This is used when accounting for high-density screens.

◆ getScreenDpiScaleRatio()

double getScreenDpiScaleRatio ( )
static

Returns the ratio of this screen's DPI compared to a normal low-DPI screen.

This can be used to scale up graphics on high-density screens.

◆ getScreenHeight()

double getScreenHeight ( )
static

Returns the height of the entire screen in pixels.

◆ getScreenSize()

GDimension getScreenSize ( )
static

Returns the width and height of the entire screen in pixels.

◆ getScreenWidth()

double getScreenWidth ( )
static

Returns the width of the entire screen in pixels.

◆ getSize()

GDimension getSize ( ) const
virtual

Returns the total width and height of the window in pixels, including its title bar, menus, borders, etc.

◆ getTitle()

string getTitle ( ) const
virtual

Returns the title bar text for the window.

◆ getType()

string getType ( ) const
virtual

Returns the concrete type of the object as a string, such as "GButton" or "GWindow".

Each GObservable subtype must override this method.

Implements GObservable.

◆ getWidth()

double getWidth ( ) const
virtual

Returns the total width of the window in pixels, including its title bar, menus, borders, etc.

◆ getX()

double getX ( ) const
virtual

Returns the x location of the left edge of the window on screen.

◆ getY()

double getY ( ) const
virtual

Returns the y location of the top edge of the window on screen.

◆ hasEventListener()

bool hasEventListener ( string   eventName) const
protectedvirtualinherited

Returns true if the observable object has a listener for the given type of event.

◆ hasToolbar()

bool hasToolbar ( ) const
virtual

Returns true if this window has a toolbar.

◆ hide()

void hide ( )
virtual

Makes the window be not visible on the screen.

Equivalent to setVisible(false).

◆ inBounds()

bool inBounds ( double  x,
double  y 
) const
virtual

Returns true if the given x/y location is within the bounds of the entire window.

Note that this is based on the entire window size including its title bar, menus, borders, etc. If you are trying to test for bounds for shapes in the window canvas area, use the inCanvasBounds method instead.

◆ inCanvasBounds()

bool inCanvasBounds ( double  x,
double  y 
) const
virtual

Returns true if the given x/y location is within the bounds of the central canvas area of the window.

◆ initializeGObject() [1/2]

void initializeGObject ( GObject obj,
bool  filled = false 
)
protectedvirtualinherited

Initializes a new graphical object to be drawn.

Used as a convenience method to set the color, fill color, outline style, font, and other settings of graphical objects based on the settings of the drawing surface.

◆ initializeGObject() [2/2]

void initializeGObject ( GObject obj,
bool  filled = false 
)
protectedvirtualinherited

Initializes a new graphical object to be drawn.

Used as a convenience method to set the color, fill color, outline style, font, and other settings of graphical objects based on the settings of the drawing surface.

◆ isAcceptingEvent() [1/3]

bool isAcceptingEvent ( int  eventMask) const
protectedvirtualinherited

Returns true if the observable object has a listener for the given type of event.

See gevent.h for event types and masks.

◆ isAcceptingEvent() [2/3]

bool isAcceptingEvent ( const GEvent event) const
protectedvirtualinherited

Returns true if the observable object has a listener for the given type of event.

◆ isAcceptingEvent() [3/3]

bool isAcceptingEvent ( string   eventType) const
protectedvirtualinherited

Returns true if the observable object has a listener for the given type of event.

◆ isAutoRepaint()

bool isAutoRepaint ( ) const
virtualinherited

◆ isHighDensityScreen()

bool isHighDensityScreen ( )
static

Returns whether the dots-per-inch of the screen are high enough to consider it a "high-density" screen for which scaling should be used.

The threshold for this is given by the constant

◆ isHighDpiScalingEnabled()

bool isHighDpiScalingEnabled ( )
static

Returns whether we should scale some windows when run on high-density screens.

◆ isMaximized()

bool isMaximized ( ) const
virtual

Returns true if the window is in a maximized state, occupying the entire screen.

◆ isMinimized()

bool isMinimized ( ) const
virtual

Returns true if the window is in a minimized (iconified) state, which often displays as the window being hidden except for a task bar icon.

◆ isOpen()

bool isOpen ( ) const
virtual

Returns true if the window is currently open and visible on the screen.

◆ isRepaintImmediately()

bool isRepaintImmediately ( ) const
virtual

Returns true if the interactor should repaint itself automatically whenever any change is made to its graphical data.

But if you call setAutoRepaint(false), you must manually repaint the interactor to see any changes. This can be desirable if you plan to make a large batch of changes and want to repaint only after all of them are done. Equivalent to isAutoRepaint.

Reimplemented from GDrawingSurface.

◆ isResizable()

bool isResizable ( ) const
virtual

Returns true if the window allows itself to be resized.

This is initially true but can be changed by calling setResizable(false).

◆ isVisible()

bool isVisible ( ) const
virtual

Returns true if the window is visible on the screen.

◆ loadCanvasPixels()

void loadCanvasPixels ( string   filename)
virtual

Reads pixel data from the file with the given name and loads it into the window's canvas area.

Exceptions
ErrorExceptionif the file is not found or cannot be loaded as an image

◆ maximize()

void maximize ( )
virtual

Puts the window in a maximized state, occupying the entire screen.

◆ minimize()

void minimize ( )
virtual

Puts the window in a minimized (iconified) state, which often displays as the window being hidden except for a task bar icon.

◆ pack()

void pack ( )
virtual

Resizes the window to its preferred size.

The window prefers to be exactly the right size to fit the interactors placed inside it at their own preferred sizes without stretching. This is the size that the window would return from a call to getPreferredSize.

◆ pause()

void pause ( double  ms)
virtual

Causes the current thread to pause itself for the given number of milliseconds.

Equivalent to sleep().

Exceptions
ErrorExceptionif ms is negative

◆ remove() [1/4]

void remove ( GInteractor interactor)
virtual

Removes the given interactor from the window.

This will work regardless of which region you added the interactor to. If the given interactor is not found in this container, has no effect.

Exceptions
ErrorExceptionif the interactor is null

◆ remove() [2/4]

void remove ( GInteractor interactor)
virtual

Removes the given interactor from the window.

This will work regardless of which region you added the interactor to. If the given interactor is not found in this container, has no effect.

◆ remove() [3/4]

void remove ( GObject obj)
virtual

Removes the given graphical object from the canvas of this window, if it was present.

Exceptions
ErrorExceptionif the graphical object is null

◆ remove() [4/4]

void remove ( GObject obj)
virtual

Removes the given graphical object from the canvas of this window, if it was present.

◆ removeClickListener()

void removeClickListener ( )
virtual

Removes the click listener from this window so that it will no longer call it when events occur.

◆ removeEventListener()

void removeEventListener ( string   eventName)
protectedvirtualinherited

Removes any event listener from this observable object that would respond to the given type of event, such as "click" or "keydown".

◆ removeEventListeners()

void removeEventListeners ( std::initializer_list< string >  eventNames)
protectedvirtualinherited

Removes any event listener from this observable object that would respond to the given types of events, such as "click" or "keydown".

◆ removeFromRegion() [1/4]

void removeFromRegion ( GInteractor interactor,
Region  region 
)
virtual

Removes the given interactor from the given region within this window.

If the given interactor is not found in the given region, has no effect.

Exceptions
ErrorExceptionif the interactor is null

◆ removeFromRegion() [2/4]

void removeFromRegion ( GInteractor interactor,
string   region 
)
virtual

Removes the given interactor from the given region within this window.

If the given interactor is not found in the given region, has no effect.

Exceptions
ErrorExceptionif the interactor is null

◆ removeFromRegion() [3/4]

void removeFromRegion ( GInteractor interactor,
Region  region 
)
virtual

Removes the given interactor from the given region within this window.

If the given interactor is not found in the given region, has no effect.

◆ removeFromRegion() [4/4]

void removeFromRegion ( GInteractor interactor,
string   region 
)
virtual

Removes the given interactor from the given region within this window.

If the given interactor is not found in the given region, has no effect.

◆ removeKeyListener()

void removeKeyListener ( )
virtual

Removes the key listener from this window so that it will no longer call it when events occur.

◆ removeMenuListener()

void removeMenuListener ( )
virtual

Removes the menu listener from this window so that it will no longer call it when events occur.

◆ removeMouseListener()

void removeMouseListener ( )
virtual

Removes the mouse listener from this window so that it will no longer call it when events occur.

◆ removeTimerListener()

void removeTimerListener ( )
virtual

Removes the timer listener from this window so that it will no longer call it when events occur.

◆ removeToolbar()

void removeToolbar ( )
virtual

Removes the toolbar from this window, if one was present.

◆ removeWindowListener()

void removeWindowListener ( )
virtual

Removes the window listener from this window so that it will no longer call it when events occur.

◆ repaint()

void repaint ( )
virtualinherited

◆ repaintRegion() [1/2]

void repaintRegion ( const GRectangle bounds)
virtualinherited

Instructs the interactor to repaint the given region of pixel data.

This can be preferable to repaint() for performance purposes if you have made a small change that affects only the given rectangular region of the interactor.

◆ repaintRegion() [2/2]

void repaintRegion ( int  x,
int  y,
int  width,
int  height 
)
virtualinherited

◆ requestFocus()

void requestFocus ( )
virtual

Asks the system to assign the keyboard focus to the window, which brings it to the top and ensures that key events are delivered to the window.

Clicking in the window automatically requests the focus.

◆ restore()

void restore ( )
virtual

Puts the window in a normal state, neither minimized or maximized.

◆ saveCanvasPixels()

void saveCanvasPixels ( string   filename)
virtual

Writes the contents of the window's graphical canvas to the given output filename.

This will write all shapes from the foreground layer as well as all pixels from the background layer.

Exceptions
ErrorExceptionif the file cannot be saved

◆ setAutoRepaint()

void setAutoRepaint ( bool  autoRepaint)
virtualinherited

◆ setBackground() [1/2]

void setBackground ( int  color)
virtual

Sets the current background color of the interactor as an RGB integer.

See gcolor.h for more detail about colors.

Reimplemented from GDrawingSurface.

◆ setBackground() [2/2]

void setBackground ( string   color)
virtual

Sets the current background color of the interactor as a string.

See gcolor.h for more detail about color strings.

Reimplemented from GDrawingSurface.

◆ setCanvasHeight()

void setCanvasHeight ( double  height)
virtual

Resizes the window so that its central canvas region will occupy exactly the given height in pixels, without changing its width.

◆ setCanvasSize() [1/2]

void setCanvasSize ( double  width,
double  height 
)
virtual

Resizes the window so that its central canvas region will occupy exactly the given width and height in pixels.

◆ setCanvasSize() [2/2]

void setCanvasSize ( const GDimension size)
virtual

Resizes the window so that its central canvas region will occupy exactly the given width and height in pixels.

◆ setCanvasWidth()

void setCanvasWidth ( double  width)
virtual

Resizes the window so that its central canvas region will occupy exactly the given width in pixels, without changing its height.

◆ setClickListener() [1/2]

void setClickListener ( GEventListener  func)
virtual

Sets a mouse listener on this window so that it will be called when the mouse is clicked on the window's canvas.

Any existing click listener will be replaced. Note that this method is not how you listen to clicks on individual buttons and other interactors inside the window; to do that, call setActionListener and other such methods on those interactors individually.

◆ setClickListener() [2/2]

void setClickListener ( GEventListenerVoid  func)
virtual

Sets a mouse listener on this window so that it will be called when the mouse is clicked on the window's canvas.

Any existing click listener will be replaced. Note that this method is not how you listen to clicks on individual buttons and other interactors inside the window; to do that, call setActionListener and other such methods on those interactors individually.

◆ setCloseOperation()

void setCloseOperation ( CloseOperation  op)
virtual

Sets what should happen when the window is closed.

◆ setColor() [1/2]

void setColor ( int  color)
virtualinherited

◆ setColor() [2/2]

void setColor ( string   color)
virtualinherited

◆ setEventListener() [1/2]

void setEventListener ( string   eventName,
GEventListener  func 
)
protectedvirtualinherited

Adds an event listener from this observable object to respond to the given type of event, such as "click" or "keydown".

Any prior listener for that type of event is replaced.

◆ setEventListener() [2/2]

void setEventListener ( string   eventName,
GEventListenerVoid  func 
)
protectedvirtualinherited

Adds an event listener from this observable object to respond to the given type of event, such as "click" or "keydown".

Any prior listener for that type of event is replaced.

◆ setEventListeners() [1/2]

void setEventListeners ( std::initializer_list< string >  eventNames,
GEventListener  func 
)
protectedvirtualinherited

Adds an event listener from this observable object to respond to the given types of events, such as "click" or "keydown".

Any prior listener for those types of event are replaced.

◆ setEventListeners() [2/2]

void setEventListeners ( std::initializer_list< string >  eventNames,
GEventListenerVoid  func 
)
protectedvirtualinherited

Adds an event listener from this observable object to respond to the given types of events, such as "click" or "keydown".

Any prior listener for those types of event are replaced.

◆ setEventsEnabled()

void setEventsEnabled ( bool  eventsEnabled)
virtualinherited

Sets whether the object is currently allowing itself to fire events.

Initially this is true.

◆ setExitOnClose()

void setExitOnClose ( bool  exitOnClose)
virtual

Sets whether the library's GUI system should shut down when the window is closed.

◆ setFillColor() [1/2]

void setFillColor ( int  color)
virtualinherited

◆ setFillColor() [2/2]

void setFillColor ( string   color)
virtualinherited

◆ setFont() [1/2]

void setFont ( const QFont &  font)
virtualinherited

◆ setFont() [2/2]

void setFont ( string   font)
virtualinherited

◆ setForeground() [1/2]

void setForeground ( int  color)
virtualinherited

Sets the current foreground outline color of the interactor as an RGB integer.

This color will be used to draw the outlines of shapes drawn using the drawXxx and fillXxx methods, as well as being the default color used when calling setPixel or setRGB. See gcolor.h for more detail about color strings. Equivalent to setColor.

Reimplemented in GCanvas.

◆ setForeground() [2/2]

void setForeground ( string   color)
virtualinherited

Sets the current foreground outline color of the interactor as a string.

This color will be used to draw the outlines of shapes drawn using the drawXxx and fillXxx methods, as well as being the default color used when calling setPixel or setRGB. See gcolor.h for more detail about color strings. Equivalent to setColor.

Reimplemented in GCanvas.

◆ setHeight()

void setHeight ( double  width)
virtual

Sets the window's total height in pixels.

◆ setKeyListener() [1/2]

void setKeyListener ( GEventListener  func)
virtual

Sets a key listener on this window so that it will be called when the user presses any key.

Any existing key listener will be replaced.

◆ setKeyListener() [2/2]

void setKeyListener ( GEventListenerVoid  func)
virtual

Sets a key listener on this window so that it will be called when the user presses any key.

Any existing key listener will be replaced.

◆ setLineStyle()

void setLineStyle ( GObject::LineStyle  lineStyle)
virtualinherited

Sets the current line style which will be used to draw outlines of shapes and lines.

The default line style is a solid line (GObject::LINE_SOLID).

◆ setLineWidth()

void setLineWidth ( double  lineWidth)
virtualinherited

◆ setLocation() [1/3]

void setLocation ( double  x,
double  y 
)
virtual

Sets the window's top-left x/y location on the screen to the given coordinates.

◆ setLocation() [2/3]

void setLocation ( const GPoint p)
virtual

Sets the window's top-left x/y location on the screen to the given point.

◆ setLocation() [3/3]

void setLocation ( const Point p)
virtual

Sets the window's top-left x/y location on the screen to the given point.

◆ setMenuItemEnabled()

void setMenuItemEnabled ( string   menu,
string   item,
bool  enabled 
)
virtual

Sets whether the given item in the given menu is enabled or disabled.

Exceptions
ErrorExceptionif the menu and/or item does not exist

◆ setMenuListener() [1/2]

void setMenuListener ( GEventListener  func)
virtual

Sets a menu listener on this window so that it will be called when menu items are clicked, sending an ACTION_MENU action event.

Any existing menu listener will be replaced.

◆ setMenuListener() [2/2]

void setMenuListener ( GEventListenerVoid  func)
virtual

Sets a menu listener on this window so that it will be called when menu items are clicked.

Any existing menu listener will be replaced.

◆ setMouseListener() [1/2]

void setMouseListener ( GEventListener  func)
virtual

Sets a mouse listener on the window's canvas so that it will be called when the user moves or clicks the mouse on the canvas.

Any existing mouse listener will be replaced.

◆ setMouseListener() [2/2]

void setMouseListener ( GEventListenerVoid  func)
virtual

Sets a mouse listener on the window's canvas so that it will be called when the user moves or clicks the mouse on the canvas.

Any existing mouse listener will be replaced.

◆ setPixel() [1/3]

void setPixel ( double  x,
double  y,
string   color 
)
virtualinherited

Sets the color of the given x/y pixel in the background layer of the interactor to the given color.

Note that if you are planning to set many pixels in the background and want maximum performance, you should instead call getPixels to extract all pixels into a Grid, then manipulate all desired pixels in that Grid, then call setPixels to submit all of your changes. Equivalent to setRGB.

Exceptions
ErrorExceptionif x/y is out of range

◆ setPixel() [2/3]

void setPixel ( double  x,
double  y,
int  rgb 
)
virtualinherited

◆ setPixel() [3/3]

void setPixel ( double  x,
double  y,
int  r,
int  g,
int  b 
)
virtualinherited

◆ setPixelARGB() [1/2]

void setPixelARGB ( double  x,
double  y,
int  argb 
)
virtualinherited

◆ setPixelARGB() [2/2]

void setPixelARGB ( double  x,
double  y,
int  a,
int  r,
int  g,
int  b 
)
virtualinherited

◆ setPixels()

void setPixels ( const Grid< int > &  pixels)
virtualinherited

◆ setPixelsARGB()

void setPixelsARGB ( const Grid< int > &  pixelsARGB)
virtualinherited

◆ setRegionAlignment() [1/5]

void setRegionAlignment ( Region  region,
HorizontalAlignment  halign 
)
virtual

Sets the horizontal alignment of interactors in the given region of the window.

◆ setRegionAlignment() [2/5]

void setRegionAlignment ( Region  region,
VerticalAlignment  valign 
)
virtual

Sets the vertical alignment of interactors in the given region of the window.

◆ setRegionAlignment() [3/5]

void setRegionAlignment ( Region  region,
HorizontalAlignment  halign,
VerticalAlignment  valign 
)
virtual

Sets the horizontal and vertical alignment of interactors in the given region of the window.

◆ setRegionAlignment() [4/5]

void setRegionAlignment ( string   region,
string   align 
)
virtual

Sets the horizontal and/or vertical alignment of interactors in the given region of the window.

◆ setRegionAlignment() [5/5]

void setRegionAlignment ( string   region,
string   halign,
string   valign 
)
virtual

Sets the horizontal and vertical alignment of interactors in the given region of the window.

◆ setRegionHorizontalAlignment() [1/2]

void setRegionHorizontalAlignment ( Region  region,
HorizontalAlignment  halign 
)
virtual

Sets the horizontal alignment of interactors in the given region of the window.

◆ setRegionHorizontalAlignment() [2/2]

void setRegionHorizontalAlignment ( string   region,
string   halign 
)
virtual

Sets the horizontal alignment of interactors in the given region of the window.

◆ setRegionVerticalAlignment() [1/2]

void setRegionVerticalAlignment ( string   region,
string   valign 
)
virtual

Sets the vertical alignment of interactors in the given region of the window.

◆ setRegionVerticalAlignment() [2/2]

void setRegionVerticalAlignment ( Region  region,
VerticalAlignment  valign 
)
virtual

Sets the vertical alignment of interactors in the given region of the window.

◆ setRepaintImmediately()

void setRepaintImmediately ( bool  repaintImmediately)
virtualinherited

◆ setResizable()

void setResizable ( bool  resizable)
virtual

Sets whether the window allows itself to be resized.

Initially true.

◆ setRGB() [1/3]

void setRGB ( double  x,
double  y,
int  rgb 
)
virtualinherited

Sets the color of the given x/y pixel in the background layer of the interactor to the given RGB values.

Note that if you are planning to set many pixels in the background and want maximum performance, you should instead call getPixels to extract all pixels into a Grid, then manipulate all desired pixels in that Grid, then call setPixels to submit all of your changes. Equivalent to setPixel.

Exceptions
ErrorExceptionif x/y is out of range or rgb is an invalid color

◆ setRGB() [2/3]

void setRGB ( double  x,
double  y,
int  r,
int  g,
int  b 
)
virtualinherited

Sets the color of the given x/y pixel in the background layer of the interactor to the given RGB values.

Note that if you are planning to set many pixels in the background and want maximum performance, you should instead call getPixels to extract all pixels into a Grid, then manipulate all desired pixels in that Grid, then call setPixels to submit all of your changes. Equivalent to setPixel.

Exceptions
ErrorExceptionif x/y is out of range or r,g,b are not between 0-255

◆ setRGB() [3/3]

void setRGB ( double  x,
double  y,
string   color 
)
virtualinherited

Sets the color of the given x/y pixel in the background layer of the interactor to the given color.

Note that if you are planning to set many pixels in the background and want maximum performance, you should instead call getPixels to extract all pixels into a Grid, then manipulate all desired pixels in that Grid, then call setPixels to submit all of your changes. Equivalent to setPixel.

Exceptions
ErrorExceptionif x/y is out of range

◆ setSize() [1/2]

void setSize ( double  width,
double  height 
)
virtual

Sets the window's total width and height in pixels.

Note that this size includes the window's title bar, border, etc. as added by your operating system. If you actually want to draw shapes over a given width and height of pixels, you should instead use the setCanvasSize method.

◆ setSize() [2/2]

void setSize ( const GDimension size)
virtual

Sets the window's width and height in pixels.

Note that this size includes the window's title bar, border, etc. as added by your operating system. If you actually want to draw shapes over a given width and height of pixels, you should instead use the setCanvasSize method.

◆ setTimerListener() [1/2]

void setTimerListener ( double  ms,
GEventListener  func 
)
virtual

Sets a menu listener on this window so that it will be called when timer delays elapse, sending a timer event.

Any existing timer listener will be replaced.

◆ setTimerListener() [2/2]

void setTimerListener ( double  ms,
GEventListenerVoid  func 
)
virtual

Sets a menu listener on this window so that it will be called when timer delays elapse, sending a timer event.

Any existing timer listener will be replaced.

◆ setTitle()

void setTitle ( string   title)
virtual

Sets the window's title bar text to the given string.

Equivalent to setWindowTitle.

◆ setVisible()

void setVisible ( bool  visible)
virtual

Sets whether the window can be seen on the screen.

Initially true unless a visible value of false was passed to the window's constructor.

◆ setWidth()

void setWidth ( double  width)
virtual

Sets the window's total width in pixels.

◆ setWindowIcon()

void setWindowIcon ( string   iconFile)
virtual

Sets the window to use the.

◆ setWindowListener() [1/2]

void setWindowListener ( GEventListener  func)
virtual

Sets a window listener on this window so that it will be called when window events occur, such as resizing or closing the window.

Any existing action listener will be replaced.

◆ setWindowListener() [2/2]

void setWindowListener ( GEventListenerVoid  func)
virtual

Sets a window listener on this window so that it will be called when window events occur, such as resizing or closing the window.

Any existing action listener will be replaced.

◆ setWindowTitle()

void setWindowTitle ( string   title)
virtual

Sets the window's title bar text to the given string.

Equivalent to setWindowTitle.

◆ setX()

void setX ( double  x)
virtual

Sets the window's left x location on the screen to the given coordinate.

◆ setY()

void setY ( double  y)
virtual

Sets the window's top y location on the screen to the given coordinate.

◆ show()

void show ( )
virtual

Sets the window to be visible on the screen.

Equivalent to setVisible(true).

◆ sleep()

void sleep ( double  ms)
virtual

Causes the current thread to pause itself for the given number of milliseconds.

Equivalent to pause().

Exceptions
ErrorExceptionif ms is negative

◆ toBack()

void toBack ( )
virtual

Moves the window to the back of the z-ordering in the operating system, underneath any other windows that occupy the same pixels.

◆ toFront()

void toFront ( )
virtual

Moves the window to the front of the z-ordering in the operating system, in front of any other windows that occupy the same pixels.

◆ toString()

string toString ( ) const
virtualinherited

Returns a string representation of this observable object's state.

Primarily used for debugging purposes.

Friends And Related Function Documentation

◆ GInteractor

friend class GInteractor
friend

Member Data Documentation

◆ _autoRepaint

bool _autoRepaint
protectedinherited

◆ _backgroundColor

string _backgroundColor
protectedinherited

◆ _backgroundColorInt

int _backgroundColorInt
protectedinherited

◆ _color

string _color
protectedinherited

◆ _colorInt

int _colorInt
protectedinherited

◆ _fillColor

string _fillColor
protectedinherited

◆ _fillColorInt

int _fillColorInt
protectedinherited

◆ _font

string _font
protectedinherited

◆ _forwardTarget

GDrawingSurface* _forwardTarget
protectedinherited

◆ _lineStyle

GObject::LineStyle _lineStyle
protectedinherited

◆ _lineWidth

double _lineWidth
protectedinherited

◆ DEFAULT_HEIGHT

const int DEFAULT_HEIGHT = 300
static

The default height of a newly created window in pixels if its height is not explicitly specified.

◆ DEFAULT_ICON_FILENAME

const string DEFAULT_ICON_FILENAME = "splicon-large.png"
static

The default file name used to load a GWindow's initial title bar icon.

◆ DEFAULT_WIDTH

const int DEFAULT_WIDTH = 500
static

The default width of a newly created window in pixels if its width is not explicitly specified.

◆ HIGH_DPI_SCREEN_THRESHOLD

const int HIGH_DPI_SCREEN_THRESHOLD = 200
static

The minimum number of dots per inch before a screen is considered to be high-density or high-DPI.

◆ STANDARD_SCREEN_DPI

const int STANDARD_SCREEN_DPI = 96
static

The minimum number of dots per inch on a "normal" low-DPI screen.

Used to figure out how much to scale up on high-DPI screens.