TGUI  1.2.0
Loading...
Searching...
No Matches
tgui::DefaultBackendWindow Class Referenceabstract

This class abstracts the backend-specific window and gui creation code. More...

#include <TGUI/DefaultBackendWindow.hpp>

Public Member Functions

 DefaultBackendWindow ()=default
 Default constructor.
 
virtual ~DefaultBackendWindow ()=default
 Virtual destructor.
 
virtual TGUI_NODISCARD BackendGuigetGui () const =0
 Returns the gui object that is created and destroyed by this class.
 
virtual TGUI_NODISCARD bool isOpen () const =0
 Returns whether the window is still open.
 
virtual void close ()=0
 Closes the window.
 
virtual TGUI_NODISCARD bool pollEvent (Event &event)=0
 Retrieves an event from the window if there is one.
 
virtual void draw ()=0
 Draws the gui to the window.
 
virtual void mainLoop (Color clearColor={240, 240, 240})=0
 Pass control of the main loop to TGUI, if the backend supports it.
 
virtual void setIcon (const String &filename)=0
 Changes the icon of the window.
 

Static Public Member Functions

static TGUI_NODISCARD std::shared_ptr< DefaultBackendWindowcreate (unsigned int width, unsigned int height, const String &title)
 Creates the backend window and the gui.
 

Detailed Description

This class abstracts the backend-specific window and gui creation code.

Normally you don't need this class as you know what the backend is and can write backend-specific code. This class is required by e.g. the Gui Builder to work independently from the backend.

Member Function Documentation

◆ close()

virtual void tgui::DefaultBackendWindow::close ( )
pure virtual

Closes the window.

See also
isOpen

◆ create()

static TGUI_NODISCARD std::shared_ptr< DefaultBackendWindow > tgui::DefaultBackendWindow::create ( unsigned int width,
unsigned int height,
const String & title )
static

Creates the backend window and the gui.

Parameters
widthWidth of the window
heightHeight of the window
titleTitle of the window
Warning
If TGUI contains multiple backends, an arbitrary one will be used
This function will assert when TGUI was built without a backend

◆ getGui()

virtual TGUI_NODISCARD BackendGui * tgui::DefaultBackendWindow::getGui ( ) const
pure virtual

Returns the gui object that is created and destroyed by this class.

Returns
Pointer to the gui that is owned by this class
Warning
You can't access the gui after this backend window is destroyed

◆ isOpen()

virtual TGUI_NODISCARD bool tgui::DefaultBackendWindow::isOpen ( ) const
pure virtual

Returns whether the window is still open.

Returns
Is the window still open?
Warning
You must call close() on this object to close the window, it does NOT happen automatically when the user presses the close button of the window (in which case you receive an event of type Event::Type::Closed from pollEvent).

◆ pollEvent()

virtual TGUI_NODISCARD bool tgui::DefaultBackendWindow::pollEvent ( Event & event)
pure virtual

Retrieves an event from the window if there is one.

Parameters
eventReference to event structure that will filled in by this function if there is an event
Returns
True if the window had an unprocessed event. If false is returned, the event parameter is untouched.

◆ setIcon()

virtual void tgui::DefaultBackendWindow::setIcon ( const String & filename)
pure virtual

Changes the icon of the window.

Parameters
filenameFilename of the icon to load

The documentation for this class was generated from the following file: