Loading...
Searching...
No Matches
WindowBase.h File Reference

Go to the source code of this file.

Enumerations

enum  sfWindowStyle {
  sfNone = 0 , sfTitlebar = 1 << 0 , sfResize = 1 << 1 , sfClose = 1 << 2 ,
  sfFullscreen = 1 << 3 , sfDefaultStyle = sfTitlebar | sfResize | sfClose
}
 Enumeration of window creation styles. More...
 

Functions

sfWindowBasesfWindowBase_create (sfVideoMode mode, const char *title, sfUint32 style)
 Construct a new window.
 
sfWindowBasesfWindowBase_createUnicode (sfVideoMode mode, const sfUint32 *title, sfUint32 style)
 Construct a new window (with a UTF-32 title)
 
sfWindowBasesfWindowBase_createFromHandle (sfWindowHandle handle)
 Construct a window from an existing control.
 
void sfWindowBase_destroy (sfWindowBase *windowBase)
 Destroy a window.
 
void sfWindowBase_close (sfWindowBase *windowBase)
 Close a window and destroy all the attached resources.
 
sfBool sfWindowBase_isOpen (const sfWindowBase *windowBase)
 Tell whether or not a window is opened.
 
sfBool sfWindowBase_pollEvent (sfWindowBase *windowBase, sfEvent *event)
 Pop the event on top of event queue, if any, and return it.
 
sfBool sfWindowBase_waitEvent (sfWindowBase *windowBase, sfEvent *event)
 Wait for an event and return it.
 
sfVector2i sfWindowBase_getPosition (const sfWindowBase *windowBase)
 Get the position of a window.
 
void sfWindowBase_setPosition (sfWindowBase *windowBase, sfVector2i position)
 Change the position of a window on screen.
 
sfVector2u sfWindowBase_getSize (const sfWindowBase *windowBase)
 Get the size of the rendering region of a window.
 
void sfWindowBase_setSize (sfWindowBase *windowBase, sfVector2u size)
 Change the size of the rendering region of a window.
 
void sfWindowBase_setTitle (sfWindowBase *windowBase, const char *title)
 Change the title of a window.
 
void sfWindowBase_setUnicodeTitle (sfWindowBase *windowBase, const sfUint32 *title)
 Change the title of a window (with a UTF-32 string)
 
void sfWindowBase_setIcon (sfWindowBase *windowBase, unsigned int width, unsigned int height, const sfUint8 *pixels)
 Change a window's icon.
 
void sfWindowBase_setVisible (sfWindowBase *windowBase, sfBool visible)
 Show or hide a window.
 
void sfWindowBase_setMouseCursorVisible (sfWindowBase *windowBase, sfBool visible)
 Show or hide the mouse cursor.
 
void sfWindowBase_setMouseCursorGrabbed (sfWindowBase *windowBase, sfBool grabbed)
 Grab or release the mouse cursor.
 
void sfWindowBase_setMouseCursor (sfWindowBase *windowBase, const sfCursor *cursor)
 Set the displayed cursor to a native system cursor.
 
void sfWindowBase_setKeyRepeatEnabled (sfWindowBase *windowBase, sfBool enabled)
 Enable or disable automatic key-repeat.
 
void sfWindowBase_setJoystickThreshold (sfWindowBase *windowBase, float threshold)
 Change the joystick threshold.
 
void sfWindowBase_requestFocus (sfWindowBase *windowBase)
 Request the current window to be made the active foreground window.
 
sfBool sfWindowBase_hasFocus (const sfWindowBase *windowBase)
 Check whether the window has the input focus.
 
sfWindowHandle sfWindowBase_getSystemHandle (const sfWindowBase *windowBase)
 Get the OS-specific handle of the window.
 
sfBool sfWindowBase_createVulkanSurface (sfWindowBase *windowBase, const VkInstance *instance, VkSurfaceKHR *surface, const VkAllocationCallbacks *allocator)
 Create a Vulkan rendering surface.
 

Enumeration Type Documentation

◆ sfWindowStyle

Enumeration of window creation styles.

Enumerator
sfNone 

No border / title bar (this flag and all others are mutually exclusive)

sfTitlebar 

Title bar + fixed border.

sfResize 

Titlebar + resizable border + maximize button.

sfClose 

Titlebar + close button.

sfFullscreen 

Fullscreen mode (this flag and all others are mutually exclusive)

sfDefaultStyle 

Default window style.

Definition at line 44 of file WindowBase.h.

Function Documentation

◆ sfWindowBase_close()

void sfWindowBase_close ( sfWindowBase windowBase)

Close a window and destroy all the attached resources.

After calling this function, the sfWindow object remains valid, you must call sfWindowBase_destroy to actually delete it. All other functions such as sfWindowBase_pollEvent or sfWindowBase_display will still work (i.e. you don't have to test sfWindowBase_isOpen every time), and will have no effect on closed windows.

Parameters
windowBaseWindow object

◆ sfWindowBase_create()

sfWindowBase * sfWindowBase_create ( sfVideoMode  mode,
const char *  title,
sfUint32  style 
)

Construct a new window.

This function creates the window with the size and pixel depth defined in mode. An optional style can be passed to customize the look and behaviour of the window (borders, title bar, resizable, closable, ...). If style contains sfFullscreen, then mode must be a valid video mode.

Parameters
modeVideo mode to use (defines the width, height and depth of the rendering area of the windowBase)
titleTitle of the window
styleWindow style
Returns
A new sfWindow object

◆ sfWindowBase_createFromHandle()

sfWindowBase * sfWindowBase_createFromHandle ( sfWindowHandle  handle)

Construct a window from an existing control.

Parameters
handlePlatform-specific handle of the control
Returns
A new sfWindow object

◆ sfWindowBase_createUnicode()

sfWindowBase * sfWindowBase_createUnicode ( sfVideoMode  mode,
const sfUint32 title,
sfUint32  style 
)

Construct a new window (with a UTF-32 title)

This function creates the window with the size and pixel depth defined in mode. An optional style can be passed to customize the look and behaviour of the window (borders, title bar, resizable, closable, ...). If style contains sfFullscreen, then mode must be a valid video mode.

Parameters
modeVideo mode to use (defines the width, height and depth of the rendering area of the windowBase)
titleTitle of the window (UTF-32)
styleWindow style
Returns
A new sfWindow object

◆ sfWindowBase_createVulkanSurface()

sfBool sfWindowBase_createVulkanSurface ( sfWindowBase windowBase,
const VkInstance instance,
VkSurfaceKHR surface,
const VkAllocationCallbacks allocator 
)

Create a Vulkan rendering surface.

Parameters
windowBaseWindow object
instanceVulkan instance
surfaceCreated surface
allocatorAllocator to use
Returns
True if surface creation was successful, false otherwise

◆ sfWindowBase_destroy()

void sfWindowBase_destroy ( sfWindowBase windowBase)

Destroy a window.

Parameters
windowBaseWindow to destroy

◆ sfWindowBase_getPosition()

sfVector2i sfWindowBase_getPosition ( const sfWindowBase windowBase)

Get the position of a window.

Parameters
windowBaseWindow object
Returns
Position in pixels

◆ sfWindowBase_getSize()

sfVector2u sfWindowBase_getSize ( const sfWindowBase windowBase)

Get the size of the rendering region of a window.

The size doesn't include the titlebar and borders of the window.

Parameters
windowBaseWindow object
Returns
Size in pixels

◆ sfWindowBase_getSystemHandle()

sfWindowHandle sfWindowBase_getSystemHandle ( const sfWindowBase windowBase)

Get the OS-specific handle of the window.

The type of the returned handle is sfWindowHandle, which is a typedef to the handle type defined by the OS. You shouldn't need to use this function, unless you have very specific stuff to implement that SFML doesn't support, or implement a temporary workaround until a bug is fixed.

Parameters
windowBaseWindow object
Returns
System handle of the window

◆ sfWindowBase_hasFocus()

sfBool sfWindowBase_hasFocus ( const sfWindowBase windowBase)

Check whether the window has the input focus.

At any given time, only one window may have the input focus to receive input events such as keystrokes or most mouse events.

Returns
True if window has focus, false otherwise

◆ sfWindowBase_isOpen()

sfBool sfWindowBase_isOpen ( const sfWindowBase windowBase)

Tell whether or not a window is opened.

This function returns whether or not the window exists. Note that a hidden window (sfWindowBase_setVisible(sfFalse)) will return sfTrue.

Parameters
windowBaseWindow object
Returns
sfTrue if the window is opened, sfFalse if it has been closed

◆ sfWindowBase_pollEvent()

sfBool sfWindowBase_pollEvent ( sfWindowBase windowBase,
sfEvent event 
)

Pop the event on top of event queue, if any, and return it.

This function is not blocking: if there's no pending event then it will return false and leave event unmodified. Note that more than one event may be present in the event queue, thus you should always call this function in a loop to make sure that you process every pending event.

Parameters
windowBaseWindow object
eventEvent to be returned
Returns
sfTrue if an event was returned, or sfFalse if the event queue was empty

◆ sfWindowBase_requestFocus()

void sfWindowBase_requestFocus ( sfWindowBase windowBase)

Request the current window to be made the active foreground window.

At any given time, only one window may have the input focus to receive input events such as keystrokes or mouse events. If a window requests focus, it only hints to the operating system, that it would like to be focused. The operating system is free to deny the request.

◆ sfWindowBase_setIcon()

void sfWindowBase_setIcon ( sfWindowBase windowBase,
unsigned int  width,
unsigned int  height,
const sfUint8 pixels 
)

Change a window's icon.

pixels must be an array of width x height pixels in 32-bits RGBA format.

Parameters
windowBaseWindow object
widthIcon's width, in pixels
heightIcon's height, in pixels
pixelsPointer to the array of pixels in memory

◆ sfWindowBase_setJoystickThreshold()

void sfWindowBase_setJoystickThreshold ( sfWindowBase windowBase,
float  threshold 
)

Change the joystick threshold.

The joystick threshold is the value below which no JoystickMoved event will be generated.

Parameters
windowBaseWindow object
thresholdNew threshold, in the range [0, 100]

◆ sfWindowBase_setKeyRepeatEnabled()

void sfWindowBase_setKeyRepeatEnabled ( sfWindowBase windowBase,
sfBool  enabled 
)

Enable or disable automatic key-repeat.

If key repeat is enabled, you will receive repeated KeyPress events while keeping a key pressed. If it is disabled, you will only get a single event when the key is pressed.

Key repeat is enabled by default.

Parameters
windowBaseWindow object
enabledsfTrue to enable, sfFalse to disable

◆ sfWindowBase_setMouseCursor()

void sfWindowBase_setMouseCursor ( sfWindowBase windowBase,
const sfCursor cursor 
)

Set the displayed cursor to a native system cursor.

Upon window creation, the arrow cursor is used by default.

Warning
The cursor must not be destroyed while in use by the window.
Features related to Cursor are not supported on iOS and Android.
Parameters
windowBaseWindow object
cursorNative system cursor type to display
See also
sfCursor_createFromSystem
sfCursor_createFromPixels

◆ sfWindowBase_setMouseCursorGrabbed()

void sfWindowBase_setMouseCursorGrabbed ( sfWindowBase windowBase,
sfBool  grabbed 
)

Grab or release the mouse cursor.

If set, grabs the mouse cursor inside this window's client area so it may no longer be moved outside its bounds. Note that grabbing is only active while the window has focus and calling this function for fullscreen windows won't have any effect (fullscreen windows always grab the cursor).

Parameters
grabbedsfTrue to enable, sfFalse to disable

◆ sfWindowBase_setMouseCursorVisible()

void sfWindowBase_setMouseCursorVisible ( sfWindowBase windowBase,
sfBool  visible 
)

Show or hide the mouse cursor.

Parameters
windowBaseWindow object
visiblesfTrue to show, sfFalse to hide

◆ sfWindowBase_setPosition()

void sfWindowBase_setPosition ( sfWindowBase windowBase,
sfVector2i  position 
)

Change the position of a window on screen.

This function only works for top-level windows (i.e. it will be ignored for windows created from the handle of a child window/control).

Parameters
windowBaseWindow object
positionNew position of the windowBase, in pixels

◆ sfWindowBase_setSize()

void sfWindowBase_setSize ( sfWindowBase windowBase,
sfVector2u  size 
)

Change the size of the rendering region of a window.

Parameters
windowBaseWindow object
sizeNew size, in pixels

◆ sfWindowBase_setTitle()

void sfWindowBase_setTitle ( sfWindowBase windowBase,
const char *  title 
)

Change the title of a window.

Parameters
windowBaseWindow object
titleNew title

◆ sfWindowBase_setUnicodeTitle()

void sfWindowBase_setUnicodeTitle ( sfWindowBase windowBase,
const sfUint32 title 
)

Change the title of a window (with a UTF-32 string)

Parameters
windowBaseWindow object
titleNew title

◆ sfWindowBase_setVisible()

void sfWindowBase_setVisible ( sfWindowBase windowBase,
sfBool  visible 
)

Show or hide a window.

Parameters
windowBaseWindow object
visiblesfTrue to show the windowBase, sfFalse to hide it

◆ sfWindowBase_waitEvent()

sfBool sfWindowBase_waitEvent ( sfWindowBase windowBase,
sfEvent event 
)

Wait for an event and return it.

This function is blocking: if there's no pending event then it will wait until an event is received. After this function returns (and no error occured), the event object is always valid and filled properly. This function is typically used when you have a thread that is dedicated to events handling: you want to make this thread sleep as long as no new event is received.

Parameters
windowBaseWindow object
eventEvent to be returned
Returns
sfFalse if any error occured