This class represents a graphics window that supports simple graphics. More...
#include "gwindow.h"
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() override | |
Frees memory allocated internally by the window. 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 * | addMenuItem(string menu, string item, const QPixmap &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 * | addToolbarItem(string item, const QPixmap &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() override |
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) override |
void | draw (GObject *gobj, double x, double y) override |
void | draw (GObject &gobj) override |
void | draw (GObject &gobj, double x, double y) override |
void | draw (QPainter *painter) override |
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 | fillPolygon(std::initializer_list< GPoint > 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... | |
GCanvas * | getCanvas() 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... | |
GObject * | getGObject(int index) const |
Returns the graphical object at the given 0-based index in the window's graphical canvas. More... | |
GObject * | getGObjectAt(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, excluding its title bar and borders. 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 interior of the window on screen, excluding any onscreen window title bar and frame. More... | |
int | getPixel (double x, double y) const override |
int | getPixelARGB (double x, double y) const override |
Grid< int > | getPixels () const override |
Grid< int > | getPixelsARGB () const override |
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, excluding its title bar and borders. More... | |
string | getTitle() const |
Returns the title bar text for the window. More... | |
string | getType() const override |
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, excluding its title bar and borders. More... | |
double | getX() const |
Returns the x location of the left edge of the interior of the window on screen, excluding any onscreen window title bar and frame. More... | |
double | getY() const |
Returns the y location of the top edge of the interior of the window on screen, excluding any onscreen window title bar and frame. 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 override |
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 override |
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 () override |
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) override |
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) override |
void | setBackground(int color) override |
Sets the current background color of the interactor as an RGB integer. More... | |
void | setBackground(string color) override |
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) override |
void | setColor (string color) override |
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) override |
void | setFillColor (string color) override |
void | setFont (const QFont &font) override |
void | setFont (string font) override |
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) override |
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 | 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) override |
void | setPixel (double x, double y, int r, int g, int b) override |
void | setPixelARGB (double x, double y, int argb) override |
void | setPixelARGB (double x, double y, int a, int r, int g, int b) override |
void | setPixels (const Grid< int > &pixels) override |
void | setPixelsARGB (const Grid< int > &pixelsARGB) override |
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) override |
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 string | chooseLightDarkModeColor(string lightColor, string darkColor) |
Returns which color to use depending on whether the user's computer is in light or dark mode. More... | |
static int | chooseLightDarkModeColorInt(int lightColor, int darkColor) |
Returns which color to use depending on whether the user's computer is in light or dark mode. More... | |
static string | getDefaultInteractorBackgroundColor() |
Returns the default color for backgrounds of interactors as a string. More... | |
static int | getDefaultInteractorBackgroundColorInt() |
Returns the default color for text on interactors as an RGB integer. More... | |
static string | getDefaultInteractorTextColor() |
Returns the default color for text on interactors as a string. More... | |
static int | getDefaultInteractorTextColorInt() |
Returns the default color for text on interactors as an RGB integer. 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 | isDarkMode() |
Returns true if the user's computer is in "dark mode." This is a popular dark color scheme mostly used on recent Macs. 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 |
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.
enum CloseOperation |
enum Region |
GWindow | ( | bool | visible = true | ) |
Creates a new window of a default width and height.
GWindow | ( | double | width, |
double | height, | ||
bool | visible = true |
||
) |
Creates a new window of the given width and height.
GWindow | ( | double | x, |
double | y, | ||
double | width, | ||
double | height, | ||
bool | visible = true |
||
) |
Creates a new window of the given location and size.
|
override |
Frees memory allocated internally by the window.
|
virtual |
Adds the given interactor to the center region of the window.
This replaces the graphical canvas and causes the canvas to be hidden.
ErrorException | if the interactor is null |
|
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.
ErrorException | if the interactor is null |
|
virtual |
Adds the given interactor to the center region of the window.
This replaces the graphical canvas and causes the canvas to be hidden.
|
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.
|
virtual |
Adds the given graphical object to the window's canvas.
This causes the graphical canvas to appear if it was not already showing.
ErrorException | if the interactor is null |
|
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.
ErrorException | if the interactor is null |
|
virtual |
Adds the given graphical object to the window's canvas.
This causes the graphical canvas to appear if it was not already showing.
|
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.
|
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.
|
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.
ErrorException | if the given menu does not exist |
|
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.
ErrorException | if the given menu does not exist |
|
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.
ErrorException | if the given menu does not exist |
|
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.
ErrorException | if the given menu does not exist |
|
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.
ErrorException | if the given menu does not exist |
|
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.
ErrorException | if the given menu does not exist |
|
virtual |
Adds a horizontal line separator to the end of the given menu.
ErrorException | if the given menu does not exist |
|
virtual |
Adds a sub-menu within an existing menu.
You can later add items to this sub-menu using:
myWindow->addMenuItem(menu + "/" + submenu, item);
ErrorException | if the given menu does not exist |
|
virtual |
Adds a toolbar to this window where action buttons can be placed.
|
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.
|
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.
|
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.
|
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.
|
virtual |
Adds a separator to the window's toolbar.
If the window does not have a toolbar, one is added.
|
virtual |
Adds the given interactor to the given region in this window.
ErrorException | if the interactor is null |
|
virtual |
Adds the given interactor to the given region in this window.
ErrorException | if the interactor is null |
|
virtual |
Adds the given interactor to the given region in this window.
|
virtual |
Adds the given interactor to the given region in this window.
|
virtual |
Relocates the window to the exact center of the current screen.
|
protectedinherited |
Throws an error if the given x/y values are out of bounds.
|
protectedinherited |
Throws an error if the given rgb value is not a valid color.
|
protectedinherited |
Throws an error if the given width/height values are out of bounds.
|
static |
Returns which color to use depending on whether the user's computer is in light or dark mode.
If in light mode, returns lightColor; else returns darkColor.
|
static |
Returns which color to use depending on whether the user's computer is in light or dark mode.
If in light mode, returns lightColor; else returns darkColor.
|
overridevirtual |
Removes all interactors from all regionss of the window.
Implements GDrawingSurface.
|
virtual |
Removes all graphical objects from the graphical canvas in this window and resets the background layer to the window's background color.
|
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.
|
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.
|
protectedvirtualinherited |
Removes all event listeners from this object.
|
virtual |
Removes all interactors from the given region of this window.
|
virtual |
Removes all interactors from the given region of this window.
|
virtual |
Removes all items from the window's toolbar, if present.
|
virtual |
Closes the window.
If a window listener has been set, a WINDOW_CLOSING and then WINDOW_CLOSED event is sent to it.
|
virtualinherited |
Repaints the interactor only if its contents have changed.
|
virtualinherited |
Repaints the given region of the interactor only if its contents have changed.
|
virtualinherited |
Repaints the given region of the interactor only if its contents have changed.
|
overrideinherited |
|
overrideinherited |
|
overrideinherited |
|
overrideinherited |
|
overrideinherited |
|
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.
|
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.
ErrorException | if the given file is not found or cannot be loaded as a valid image file |
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.
|
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.
|
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.
|
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.
|
virtualinherited |
Colors the given x/y pixel of the background layer of this interactor using the interactor's current color.
|
virtualinherited |
Colors the given x/y pixel of the background layer of this interactor using the given color.
|
virtualinherited |
Colors the given x/y pixel of the background layer of this interactor using the given color.
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
protectedvirtualinherited |
|
protectedvirtualinherited |
Ensures that we are currently in the Qt GUI thread.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
protectedvirtualinherited |
Sends out the given event to any attached listeners.
|
protectedvirtualinherited |
Creates an event of the given type, then sends it out to any attached listeners.
|
protectedvirtualinherited |
Creates an event of the given type, then sends it out to any attached listeners.
|
protectedvirtualinherited |
Creates an event of the given type, then sends it out to any attached listeners.
|
protectedvirtualinherited |
Creates an event of the given type, then sends it out to any attached listeners.
|
protectedvirtualinherited |
Creates an event of the given type, then sends it out to any attached listeners.
|
protectedvirtualinherited |
Creates an event of the given type, then sends it out to any attached listeners.
|
protectedvirtualinherited |
Creates an event of the given type, then sends it out to any attached listeners.
|
protectedvirtualinherited |
Creates an event of the given type, then sends it out to any attached listeners.
|
virtualinherited |
Returns the pixel color data at the given x/y location, retaining alpha-channel transparency in the top 8 bits.
|
virtualinherited |
|
virtualinherited |
|
virtual |
Returns a direct pointer to the window's internal graphical canvas on which shapes and objects are drawn.
Use with care!
|
virtual |
Returns the height of the window's central canvas area in pixels.
|
virtual |
Returns the width and height of the window's central canvas area in pixels.
|
virtual |
Returns the width of the window's central canvas area in pixels.
|
virtual |
Returns a constant representing the action that will be taken when the user closes the window.
|
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.
|
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.
|
static |
Returns the default color for backgrounds of interactors as a string.
This is normally a light-grayish color, depending on the user's system settings. On some systems that are in "dark mode" this may be a color closer to black.
|
static |
Returns the default color for text on interactors as an RGB integer.
This is normally a light-grayish color, depending on the user's system settings. On some systems that are in "dark mode" this may be a color closer to black.
|
static |
Returns the default color for text on interactors as a string.
This is normally black or a nearly-black color, depending on the user's system settings. On some systems that are in "dark mode" this may be a color closer to white.
|
static |
Returns the default color for text on interactors as an RGB integer.
This is normally black or a nearly-black color, depending on the user's system settings. On some systems that are in "dark mode" this may be a color closer to white.
|
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.
|
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.
|
virtualinherited |
|
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.
|
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.
|
virtual |
Returns the graphical object at the given 0-based index in the window's graphical canvas.
ErrorException | if the index is out of bounds |
|
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.
|
virtual |
Returns the total number of graphical objects in the window's canvas.
|
virtual |
Returns the total height of the window in pixels, excluding its title bar and borders.
|
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).
|
virtualinherited |
Returns the thickness used when drawing outlines of shapes and lines.
The default thickness is 1.
|
virtual |
Returns the x/y location of the top-left corner of the interior of the window on screen, excluding any onscreen window title bar and frame.
|
overrideinherited |
|
overrideinherited |
|
overrideinherited |
|
overrideinherited |
|
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.
|
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().
|
virtual |
Returns the height of the given region of the window in pixels.
|
virtual |
Returns the height of the given region of the window in pixels.
|
virtual |
Returns the width and height of the given region of the window in pixels.
|
virtual |
Returns the width and height of the given region of the window in pixels.
|
virtual |
Returns the width of the given region of the window in pixels.
|
virtual |
Returns the width of the given region of the window in pixels.
|
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.
ErrorException | if the given x/y values are out of bounds. |
|
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.
ErrorException | if the given x/y values are out of bounds. |
|
static |
Returns the dots-per-inch of the screen.
This is used when accounting for high-density screens.
|
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.
|
static |
Returns the height of the entire screen in pixels.
|
static |
Returns the width and height of the entire screen in pixels.
|
static |
Returns the width of the entire screen in pixels.
|
virtual |
Returns the total width and height of the window in pixels, excluding its title bar and borders.
|
virtual |
Returns the title bar text for the window.
|
overridevirtual |
Returns the concrete type of the object as a string, such as "GButton"
or "GWindow"
.
Each GObservable subtype must override this method.
Implements GObservable.
|
virtual |
Returns the total width of the window in pixels, excluding its title bar and borders.
|
virtual |
Returns the x location of the left edge of the interior of the window on screen, excluding any onscreen window title bar and frame.
|
virtual |
Returns the y location of the top edge of the interior of the window on screen, excluding any onscreen window title bar and frame.
|
protectedvirtualinherited |
Returns true if the observable object has a listener for the given type of event.
|
virtual |
Returns true if this window has a toolbar.
|
virtual |
Makes the window be not visible on the screen.
Equivalent to setVisible(false).
|
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.
|
virtual |
Returns true if the given x/y location is within the bounds of the central canvas area of the window.
|
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.
|
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.
|
protectedvirtualinherited |
Returns true if the observable object has a listener for the given type of event.
See gevent.h for event types and masks.
|
protectedvirtualinherited |
Returns true if the observable object has a listener for the given type of event.
|
protectedvirtualinherited |
Returns true if the observable object has a listener for the given type of event.
|
overrideinherited |
|
static |
Returns true if the user's computer is in "dark mode." This is a popular dark color scheme mostly used on recent Macs.
Our checking is imperfect and basically just creates a dummy widget and checks whether it has bright text and a dark background.
|
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
|
static |
Returns whether we should scale some windows when run on high-density screens.
|
virtual |
Returns true if the window is in a maximized state, occupying the entire screen.
|
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.
|
virtual |
Returns true if the window is currently open and visible on the screen.
|
overridevirtual |
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.
|
virtual |
Returns true if the window allows itself to be resized.
This is initially true but can be changed by calling setResizable(false).
|
virtual |
Returns true if the window is visible on the screen.
|
virtual |
Reads pixel data from the file with the given name and loads it into the window's canvas area.
ErrorException | if the file is not found or cannot be loaded as an image |
|
virtual |
Puts the window in a maximized state, occupying the entire screen.
|
virtual |
Puts the window in a minimized (iconified) state, which often displays as the window being hidden except for a task bar icon.
|
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.
|
virtual |
Causes the current thread to pause itself for the given number of milliseconds.
Equivalent to sleep().
ErrorException | if ms is negative |
|
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.
ErrorException | if the interactor is null |
|
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.
|
virtual |
Removes the given graphical object from the canvas of this window, if it was present.
ErrorException | if the graphical object is null |
|
virtual |
Removes the given graphical object from the canvas of this window, if it was present.
|
virtual |
Removes the click listener from this window so that it will no longer call it when events occur.
|
protectedvirtualinherited |
Removes any event listener from this observable object that would respond to the given type of event, such as "click" or "keydown".
|
protectedvirtualinherited |
Removes any event listener from this observable object that would respond to the given types of events, such as "click" or "keydown".
|
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.
ErrorException | if the interactor is null |
|
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.
ErrorException | if the interactor is null |
|
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.
|
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.
|
virtual |
Removes the key listener from this window so that it will no longer call it when events occur.
|
virtual |
Removes the menu listener from this window so that it will no longer call it when events occur.
|
virtual |
Removes the mouse listener from this window so that it will no longer call it when events occur.
|
virtual |
Removes the timer listener from this window so that it will no longer call it when events occur.
|
virtual |
Removes the toolbar from this window, if one was present.
|
virtual |
Removes the window listener from this window so that it will no longer call it when events occur.
|
overrideinherited |
|
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.
|
overrideinherited |
|
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.
|
virtual |
Puts the window in a normal state, neither minimized or maximized.
|
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.
ErrorException | if the file cannot be saved |
|
overrideinherited |
|
overridevirtual |
Sets the current background color of the interactor as an RGB integer.
See gcolor.h for more detail about colors.
Reimplemented from GDrawingSurface.
|
overridevirtual |
Sets the current background color of the interactor as a string.
See gcolor.h for more detail about color strings.
Reimplemented from GDrawingSurface.
|
virtual |
Resizes the window so that its central canvas region will occupy exactly the given height in pixels, without changing its width.
|
virtual |
Resizes the window so that its central canvas region will occupy exactly the given width and height in pixels.
|
virtual |
Resizes the window so that its central canvas region will occupy exactly the given width and height in pixels.
|
virtual |
Resizes the window so that its central canvas region will occupy exactly the given width in pixels, without changing its height.
|
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.
|
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.
|
virtual |
Sets what should happen when the window is closed.
|
overrideinherited |
|
overrideinherited |
|
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.
|
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.
|
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.
|
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.
|
virtualinherited |
Sets whether the object is currently allowing itself to fire events.
Initially this is true.
|
virtual |
Sets whether the library's GUI system should shut down when the window is closed.
|
overrideinherited |
|
overrideinherited |
|
overrideinherited |
|
overrideinherited |
|
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.
|
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.
|
virtual |
Sets the window's total height in pixels.
|
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.
|
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.
|
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).
|
overrideinherited |
|
virtual |
Sets the window's top-left x/y location on the screen to the given coordinates.
|
virtual |
Sets the window's top-left x/y location on the screen to the given point.
|
virtual |
Sets whether the given item in the given menu is enabled or disabled.
ErrorException | if the menu and/or item does not exist |
|
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.
|
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.
|
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.
|
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.
|
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.
ErrorException | if x/y is out of range |
|
overrideinherited |
|
overrideinherited |
|
overrideinherited |
|
overrideinherited |
|
overrideinherited |
|
overrideinherited |
|
virtual |
Sets the horizontal alignment of interactors in the given region of the window.
|
virtual |
Sets the vertical alignment of interactors in the given region of the window.
|
virtual |
Sets the horizontal and vertical alignment of interactors in the given region of the window.
|
virtual |
Sets the horizontal and/or vertical alignment of interactors in the given region of the window.
|
virtual |
Sets the horizontal and vertical alignment of interactors in the given region of the window.
|
virtual |
Sets the horizontal alignment of interactors in the given region of the window.
|
virtual |
Sets the horizontal alignment of interactors in the given region of the window.
|
virtual |
Sets the vertical alignment of interactors in the given region of the window.
|
virtual |
Sets the vertical alignment of interactors in the given region of the window.
|
overrideinherited |
|
virtual |
Sets whether the window allows itself to be resized.
Initially true.
|
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.
ErrorException | if x/y is out of range or rgb is an invalid color |
|
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.
ErrorException | if x/y is out of range or r,g,b are not between 0-255 |
|
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.
ErrorException | if x/y is out of range |
|
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.
|
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.
|
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.
|
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.
|
virtual |
Sets the window's title bar text to the given string.
Equivalent to setWindowTitle.
|
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.
|
virtual |
Sets the window's total width in pixels.
|
virtual |
Sets the window to use the.
|
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.
|
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.
|
virtual |
Sets the window's title bar text to the given string.
Equivalent to setWindowTitle.
|
virtual |
Sets the window's left x location on the screen to the given coordinate.
|
virtual |
Sets the window's top y location on the screen to the given coordinate.
|
virtual |
Sets the window to be visible on the screen.
Equivalent to setVisible(true).
|
virtual |
Causes the current thread to pause itself for the given number of milliseconds.
Equivalent to pause().
ErrorException | if ms is negative |
|
virtual |
Moves the window to the back of the z-ordering in the operating system, underneath any other windows that occupy the same pixels.
|
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.
|
virtualinherited |
Returns a string representation of this observable object's state.
Primarily used for debugging purposes.
|
friend |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
static |
The default height of a newly created window in pixels if its height is not explicitly specified.
|
static |
The default file name used to load a GWindow's initial title bar icon.
|
static |
The default width of a newly created window in pixels if its width is not explicitly specified.
|
static |
The minimum number of dots per inch before a screen is considered to be high-density or high-DPI.
|
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.