Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell98 |
Documentation
class (SFResource a, SFDisplayable a) => SFWindow a where Source
Close the window.
After calling this function, the window object remains
valid; you must call destroy
to actually delete it.
isWindowOpen :: a -> IO Bool Source
Tell whether or not a window is opened
This function returns whether or not the window exists.
Note that a hidden window (setWindowVisible False
) will return
True
.
getWindowSettings :: a -> IO ContextSettings Source
Get the settings of the OpenGL context of a window.
Note that these settings may be different from what was passed to the window create function, if one or more settings were not supported. In this case, SFML chose the closest match.
pollEvent :: a -> IO (Maybe SFEvent) Source
Pop the event on top of events stack, if any, and return it.
This function is not blocking: if there's no pending event then it will return false and leave a event unmodified. Note that more than one event may be present in the events stack, thus you should always call this function in a loop to make sure that you process every pending event.
waitEvent :: a -> IO (Maybe SFEvent) Source
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.
getWindowPosition :: a -> IO Vec2i Source
Get the position of a window.
setWindowPosition :: a -> Vec2i -> IO () Source
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).
getWindowSize :: a -> IO Vec2u Source
Get the size of the rendering region of a window.
The size doesn't include the titlebar and borders of the window.
setWindowSize :: a -> Vec2u -> IO () Source
Change the size of the rendering region of a window.
setWindowTitle :: a -> String -> IO () Source
Change the title of a window.
Change a window's icon.
Pixels must be an array of width x height pixels in 32-bits RGBA format.
setWindowVisible :: a -> Bool -> IO () Source
Show or hide a window.
setMouseVisible :: a -> Bool -> IO () Source
Show or hide the mouse cursor.
setVSync :: a -> Bool -> IO () Source
Enable or disable vertical synchronization. Activating vertical synchronization will limit the number of frames displayed to the refresh rate of the monitor.
This can avoid some visual artifacts, and limit the framerate to a good value (but not constant across different computers).
setKeyRepeat :: a -> Bool -> IO () Source
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.
setWindowActive :: a -> Bool -> IO () Source
Activate or deactivate a window as the current target for OpenGL rendering.
A window is active only on the current thread, if you want to make it active on another thread you have to deactivate it on the previous thread first if it was active.
Only one window can be active on a thread at a time, thus the window previously active (if any) automatically gets deactivated.
requestFocus :: a -> IO () Source
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.
This is not to be confused with setWindowActive
.
hasFocus :: a -> IO Bool Source
Check whether the render 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.
setFramerateLimit :: a -> Int -> IO () Source
Limit the framerate to a maximum fixed frequency.
If a limit is set, the window will use a small delay after
each call to display
to ensure that the current frame
lasted long enough to match the framerate limit.
setJoystickThreshold :: a -> Float -> IO () Source
Change the joystick threshold.
The joystick threshold is the value below which no JoyMoved event will be generated.
getSystemHandle :: a -> IO WindowHandle Source
Get the OS-specific handle of the window.
The type of the returned handle is WindowHandle
,
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.
getMousePosition :: Maybe a -> IO Vec2i Source
Get the current position of the mouse
This function returns the current position of the mouse
cursor relative to the given window, or desktop if Nothing
is passed.
setMousePosition :: Vec2i -> Maybe a -> IO () Source
Set the current position of the mouse
This function sets the current position of the mouse
cursor relative to the given window, or desktop if Nothing
is passed.