replaced all crappy spaces with proper tabs

kept this in its own changeset so it doesn't interfere with real changes

git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1334 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
trass3r 2010-01-06 20:37:29 +00:00
parent 8431753ba3
commit 2f2fc5d4fa
56 changed files with 8094 additions and 8094 deletions

View file

@ -1,33 +1,33 @@
/*
* DSFML - SFML Library wrapper for the D programming language.
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
* Copyright (C) 2010 Andreas Hollandt
* DSFML - SFML Library wrapper for the D programming language.
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
* Copyright (C) 2010 Andreas Hollandt
*
* This software is provided 'as-is', without any express or
* implied warranty. In no event will the authors be held
* liable for any damages arising from the use of this software.
* This software is provided 'as-is', without any express or
* implied warranty. In no event will the authors be held
* liable for any damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute
* it freely, subject to the following restrictions:
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute
* it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented;
* you must not claim that you wrote the original software.
* If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but
* is not required.
* 1. The origin of this software must not be misrepresented;
* you must not claim that you wrote the original software.
* If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but
* is not required.
*
* 2. Altered source versions must be plainly marked as such,
* and must not be misrepresented as being the original software.
* 2. Altered source versions must be plainly marked as such,
* and must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any
* source distribution.
* 3. This notice may not be removed or altered from any
* source distribution.
*/
module dsfml.window.all;
public import
dsfml.window.event,
dsfml.window.event,
dsfml.window.input,
dsfml.window.videomode,
dsfml.window.window,

View file

@ -1,27 +1,27 @@
/*
* DSFML - SFML Library wrapper for the D programming language.
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
* Copyright (C) 2010 Andreas Hollandt
* DSFML - SFML Library wrapper for the D programming language.
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
* Copyright (C) 2010 Andreas Hollandt
*
* This software is provided 'as-is', without any express or
* implied warranty. In no event will the authors be held
* liable for any damages arising from the use of this software.
* This software is provided 'as-is', without any express or
* implied warranty. In no event will the authors be held
* liable for any damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute
* it freely, subject to the following restrictions:
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute
* it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented;
* you must not claim that you wrote the original software.
* If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but
* is not required.
* 1. The origin of this software must not be misrepresented;
* you must not claim that you wrote the original software.
* If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but
* is not required.
*
* 2. Altered source versions must be plainly marked as such,
* and must not be misrepresented as being the original software.
* 2. Altered source versions must be plainly marked as such,
* and must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any
* source distribution.
* 3. This notice may not be removed or altered from any
* source distribution.
*/
module dsfml.window.common;

View file

@ -1,26 +1,26 @@
/*
* DSFML - SFML Library wrapper for the D programming language.
* Copyright (C) 2010 Andreas Hollandt
* DSFML - SFML Library wrapper for the D programming language.
* Copyright (C) 2010 Andreas Hollandt
*
* This software is provided 'as-is', without any express or
* implied warranty. In no event will the authors be held
* liable for any damages arising from the use of this software.
* This software is provided 'as-is', without any express or
* implied warranty. In no event will the authors be held
* liable for any damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute
* it freely, subject to the following restrictions:
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute
* it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented;
* you must not claim that you wrote the original software.
* If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but
* is not required.
* 1. The origin of this software must not be misrepresented;
* you must not claim that you wrote the original software.
* If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but
* is not required.
*
* 2. Altered source versions must be plainly marked as such,
* and must not be misrepresented as being the original software.
* 2. Altered source versions must be plainly marked as such,
* and must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any
* source distribution.
* 3. This notice may not be removed or altered from any
* source distribution.
*/
module dsfml.window.context;
@ -49,7 +49,7 @@ class Context : DSFMLObject
/**
*
* Params:
* active =
* active =
*/
void setActive(bool active)
{

View file

@ -1,329 +1,329 @@
/*
* DSFML - SFML Library wrapper for the D programming language.
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
* Copyright (C) 2010 Andreas Hollandt
* DSFML - SFML Library wrapper for the D programming language.
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
* Copyright (C) 2010 Andreas Hollandt
*
* This software is provided 'as-is', without any express or
* implied warranty. In no event will the authors be held
* liable for any damages arising from the use of this software.
* This software is provided 'as-is', without any express or
* implied warranty. In no event will the authors be held
* liable for any damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute
* it freely, subject to the following restrictions:
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute
* it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented;
* you must not claim that you wrote the original software.
* If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but
* is not required.
* 1. The origin of this software must not be misrepresented;
* you must not claim that you wrote the original software.
* If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but
* is not required.
*
* 2. Altered source versions must be plainly marked as such,
* and must not be misrepresented as being the original software.
* 2. Altered source versions must be plainly marked as such,
* and must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any
* source distribution.
* 3. This notice may not be removed or altered from any
* source distribution.
*/
module dsfml.window.event;
/**
* Definition of key codes for keyboard events
*
* $(B Possibles values:)$(BR)
* Except letters and numbers, you can use :$(BR)
* * LCONTROL, LSHIFT, LALT, LSYSTEM, RCONTROL, RSHIFT, RALT, RSYSTEM.$(BR)
* * LBRACKET, RBRACKET, SEMICOLON, COMMA, PERIOD, QUOTE, SLASH, BACKSLASH, TILDE, EQUAL, DASH.$(BR)
* * SPACE, RETURN, BACK, TAB, PAGEUP, PAGEDOWN, END, HOME, INSERT, DELETE.$(BR)
* * ADD, SUBTRACT, MULTIPLY, DIVIDE, LEFT, RIGHT, UP, DOWN.$(BR)
* * NUMPAD0, NUMPAD1, NUMPAD2, NUMPAD3, NUMPAD4, NUMPAD5, NUMPAD6, NUMPAD7, NUMPAD8, NUMPAD9.$(BR)
* * F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15.$(BR)
* Definition of key codes for keyboard events
*
* $(B Possibles values:)$(BR)
* Except letters and numbers, you can use :$(BR)
* * LCONTROL, LSHIFT, LALT, LSYSTEM, RCONTROL, RSHIFT, RALT, RSYSTEM.$(BR)
* * LBRACKET, RBRACKET, SEMICOLON, COMMA, PERIOD, QUOTE, SLASH, BACKSLASH, TILDE, EQUAL, DASH.$(BR)
* * SPACE, RETURN, BACK, TAB, PAGEUP, PAGEDOWN, END, HOME, INSERT, DELETE.$(BR)
* * ADD, SUBTRACT, MULTIPLY, DIVIDE, LEFT, RIGHT, UP, DOWN.$(BR)
* * NUMPAD0, NUMPAD1, NUMPAD2, NUMPAD3, NUMPAD4, NUMPAD5, NUMPAD6, NUMPAD7, NUMPAD8, NUMPAD9.$(BR)
* * F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15.$(BR)
*/
enum KeyCode
{
A = 'a',
B = 'b',
C = 'c',
D = 'd',
E = 'e',
F = 'f',
G = 'g',
H = 'h',
I = 'i',
J = 'j',
K = 'k',
L = 'l',
M = 'm',
N = 'n',
O = 'o',
P = 'p',
Q = 'q',
R = 'r',
S = 's',
T = 't',
U = 'u',
V = 'v',
W = 'w',
X = 'x',
Y = 'y',
Z = 'z',
NUM0 = '0',
NUM1 = '1',
NUM2 = '2',
NUM3 = '3',
NUM4 = '4',
NUM5 = '5',
NUM6 = '6',
NUM7 = '7',
NUM8 = '8',
NUM9 = '9',
ESCAPE = 256,
LCONTROL,
LSHIFT,
LALT,
LSYSTEM,
RCONTROL,
RSHIFT,
RALT,
RSYSTEM,
MENU,
LBRACKET,
RBRACKET,
SEMICOLON,
COMMA,
PERIOD,
QUOTE,
SLASH,
BACKSLASH,
TILDE,
EQUAL,
DASH,
SPACE,
RETURN,
BACK,
TAB,
PAGEUP,
PAGEDOWN,
END,
HOME,
INSERT,
DELETE,
ADD,
SUBTRACT,
MULTIPLY,
DIVIDE,
LEFT,
RIGHT,
UP,
DOWN,
NUMPAD0,
NUMPAD1,
NUMPAD2,
NUMPAD3,
NUMPAD4,
NUMPAD5,
NUMPAD6,
NUMPAD7,
NUMPAD8,
NUMPAD9,
F1,
F2,
F3,
F4,
F5,
F6,
F7,
F8,
F9,
F10,
F11,
F12,
F13,
F14,
F15,
PAUSE,
A = 'a',
B = 'b',
C = 'c',
D = 'd',
E = 'e',
F = 'f',
G = 'g',
H = 'h',
I = 'i',
J = 'j',
K = 'k',
L = 'l',
M = 'm',
N = 'n',
O = 'o',
P = 'p',
Q = 'q',
R = 'r',
S = 's',
T = 't',
U = 'u',
V = 'v',
W = 'w',
X = 'x',
Y = 'y',
Z = 'z',
NUM0 = '0',
NUM1 = '1',
NUM2 = '2',
NUM3 = '3',
NUM4 = '4',
NUM5 = '5',
NUM6 = '6',
NUM7 = '7',
NUM8 = '8',
NUM9 = '9',
ESCAPE = 256,
LCONTROL,
LSHIFT,
LALT,
LSYSTEM,
RCONTROL,
RSHIFT,
RALT,
RSYSTEM,
MENU,
LBRACKET,
RBRACKET,
SEMICOLON,
COMMA,
PERIOD,
QUOTE,
SLASH,
BACKSLASH,
TILDE,
EQUAL,
DASH,
SPACE,
RETURN,
BACK,
TAB,
PAGEUP,
PAGEDOWN,
END,
HOME,
INSERT,
DELETE,
ADD,
SUBTRACT,
MULTIPLY,
DIVIDE,
LEFT,
RIGHT,
UP,
DOWN,
NUMPAD0,
NUMPAD1,
NUMPAD2,
NUMPAD3,
NUMPAD4,
NUMPAD5,
NUMPAD6,
NUMPAD7,
NUMPAD8,
NUMPAD9,
F1,
F2,
F3,
F4,
F5,
F6,
F7,
F8,
F9,
F10,
F11,
F12,
F13,
F14,
F15,
PAUSE,
}
/**
* Definition of button codes for mouse events
* Definition of button codes for mouse events
*/
enum MouseButtons
{
LEFT, ///
RIGHT, ///
MIDDLE, ///
XBUTTON1, ///
XBUTTON2 ///
LEFT, ///
RIGHT, ///
MIDDLE, ///
XBUTTON1, ///
XBUTTON2 ///
}
/**
* Definition of joystick axis for joystick events
* Definition of joystick axis for joystick events
*/
enum JoyAxis
{
AXISX, ///
AXISY, ///
AXISZ, ///
AXISR, ///
AXISU, ///
AXISV, ///
AXISPOV ///
AXISX, ///
AXISY, ///
AXISZ, ///
AXISR, ///
AXISU, ///
AXISV, ///
AXISPOV ///
}
/**
* Event defines a system event and its parameters
* Event defines a system event and its parameters
*/
align(1) struct Event
{
enum EventType
{
CLOSED,
RESIZED,
LOSTFOCUS,
GAINEDFOCUS,
TEXTENTERED,
KEYPRESSED,
KEYRELEASED,
MOUSEWHEELMOVED,
MOUSEBUTTONPRESSED,
MOUSEBUTTONRELEASED,
MOUSEMOVED,
MOUSEENTERED,
MOUSELEFT,
JOYBUTTONPRESSED,
JOYBUTTONRELEASED,
JOYMOVED
}
enum EventType
{
CLOSED,
RESIZED,
LOSTFOCUS,
GAINEDFOCUS,
TEXTENTERED,
KEYPRESSED,
KEYRELEASED,
MOUSEWHEELMOVED,
MOUSEBUTTONPRESSED,
MOUSEBUTTONRELEASED,
MOUSEMOVED,
MOUSEENTERED,
MOUSELEFT,
JOYBUTTONPRESSED,
JOYBUTTONRELEASED,
JOYMOVED
}
/**
* Enumeration of the different types of events. Accessing a value of another event that the one received (e.g. Event.Size.Width when receiving an KEYPRESSED event) will result in undefined behavior.
* $(UL
* $(LI CLOSED)
* $(LI LOSTFOCUS)
* $(LI GAINEDFOCUS)
* $(LI RESIZED
* $(UL
* $(LI Event.Size.Width : new Width, in pixels.)
* $(LI Event.Size.Height : new height, in pixels.)
* )
* )
* $(LI TEXTENTERED
* $(UL
* $(LI Event.Text.Unicode : dchar entered.)
* )
* )
* $(LI KEYPRESSED, KEYRELEASED
* $(UL
* $(LI Event.Key.Code : Key code of the key.)
* $(LI Event.Key.Alt : Alt pressed ?)
* $(LI Event.Key.Control : Control pressed ?)
* $(LI Event.Key.Shift : Shift pressed ?)
* )
* )
* $(LI MOUSEWHEELMOVED
* $(UL
* $(LI Event.MouseWheel.Delta : Wheel move (positive if forward, negative else.) )
* )
* )
* $(LI MOUSEBUTTONPRESSED, MOUSEBUTTONRELEASED
* $(UL
* $(LI Event.MouseButton.Button : Mouse button pressed.)
* $(LI Event.MouseButton.X : Cursor X position.)
* $(LI Event.MouseButton.Y : Cursor X position.)
* )
* )
* $(LI MOUSEMOVED
* $(UL
* $(LI Event.MouseMove.X : Cursor X position. Local coordinates.)
* $(LI Event.MouseMove.Y : Cursor Y position. Local coordinates.)
* )
* )
* $(LI MOUSEENTERED)
* $(LI MOUSELEFT)
* $(LI JOYBUTTONPRESSED, JOYBUTTONRELEASED
* $(UL
* $(LI Event.JoyButton.JoystickId : Id of the joystick.)
* $(LI Event.JoyButton.Button : Joystick button pressed.)
* )
* )
* $(LI JOYMOVED
* $(UL
* $(LI Event.JoyMove.JoystickId : Id of the joystick.)
* $(LI Event.JoyMove.Axis : Moved axis.)
* $(LI Event.JoyMove.Position : Actual position of the axis [-100, 100], except for POV [0, 360].)
* )
* )
* )
*/
EventType Type;
union
{
struct SText
{
dchar Unicode;
}
SText Text;
struct SKey
{
KeyCode Code;
bool Alt;
byte[3] Filler1;
bool Control;
byte[3] Filler2;
bool Shift;
byte[3] Filler3;
}
SKey Key;
struct SMouseMove
{
int X;
int Y;
}
SMouseMove MouseMove;
struct SMouseButton
{
MouseButtons Button;
int X;
int Y;
}
SMouseButton MouseButton;
struct SMouseWheel
{
int Delta;
}
SMouseWheel MouseWheel;
struct SJoyMove
{
uint JoystickId;
JoyAxis Axis;
float Position;
}
SJoyMove JoyMove;
struct SJoyButton
{
uint JoystickId;
uint Button;
}
SJoyButton JoyButton;
struct SSize
{
uint Width;
uint Height;
}
SSize Size;
}
/**
* Enumeration of the different types of events. Accessing a value of another event that the one received (e.g. Event.Size.Width when receiving an KEYPRESSED event) will result in undefined behavior.
* $(UL
* $(LI CLOSED)
* $(LI LOSTFOCUS)
* $(LI GAINEDFOCUS)
* $(LI RESIZED
* $(UL
* $(LI Event.Size.Width : new Width, in pixels.)
* $(LI Event.Size.Height : new height, in pixels.)
* )
* )
* $(LI TEXTENTERED
* $(UL
* $(LI Event.Text.Unicode : dchar entered.)
* )
* )
* $(LI KEYPRESSED, KEYRELEASED
* $(UL
* $(LI Event.Key.Code : Key code of the key.)
* $(LI Event.Key.Alt : Alt pressed ?)
* $(LI Event.Key.Control : Control pressed ?)
* $(LI Event.Key.Shift : Shift pressed ?)
* )
* )
* $(LI MOUSEWHEELMOVED
* $(UL
* $(LI Event.MouseWheel.Delta : Wheel move (positive if forward, negative else.) )
* )
* )
* $(LI MOUSEBUTTONPRESSED, MOUSEBUTTONRELEASED
* $(UL
* $(LI Event.MouseButton.Button : Mouse button pressed.)
* $(LI Event.MouseButton.X : Cursor X position.)
* $(LI Event.MouseButton.Y : Cursor X position.)
* )
* )
* $(LI MOUSEMOVED
* $(UL
* $(LI Event.MouseMove.X : Cursor X position. Local coordinates.)
* $(LI Event.MouseMove.Y : Cursor Y position. Local coordinates.)
* )
* )
* $(LI MOUSEENTERED)
* $(LI MOUSELEFT)
* $(LI JOYBUTTONPRESSED, JOYBUTTONRELEASED
* $(UL
* $(LI Event.JoyButton.JoystickId : Id of the joystick.)
* $(LI Event.JoyButton.Button : Joystick button pressed.)
* )
* )
* $(LI JOYMOVED
* $(UL
* $(LI Event.JoyMove.JoystickId : Id of the joystick.)
* $(LI Event.JoyMove.Axis : Moved axis.)
* $(LI Event.JoyMove.Position : Actual position of the axis [-100, 100], except for POV [0, 360].)
* )
* )
* )
*/
EventType Type;
union
{
struct SText
{
dchar Unicode;
}
SText Text;
struct SKey
{
KeyCode Code;
bool Alt;
byte[3] Filler1;
bool Control;
byte[3] Filler2;
bool Shift;
byte[3] Filler3;
}
SKey Key;
struct SMouseMove
{
int X;
int Y;
}
SMouseMove MouseMove;
struct SMouseButton
{
MouseButtons Button;
int X;
int Y;
}
SMouseButton MouseButton;
struct SMouseWheel
{
int Delta;
}
SMouseWheel MouseWheel;
struct SJoyMove
{
uint JoystickId;
JoyAxis Axis;
float Position;
}
SJoyMove JoyMove;
struct SJoyButton
{
uint JoystickId;
uint Button;
}
SJoyButton JoyButton;
struct SSize
{
uint Width;
uint Height;
}
SSize Size;
}
}

View file

@ -1,27 +1,27 @@
/*
* DSFML - SFML Library wrapper for the D programming language.
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
* Copyright (C) 2010 Andreas Hollandt
* DSFML - SFML Library wrapper for the D programming language.
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
* Copyright (C) 2010 Andreas Hollandt
*
* This software is provided 'as-is', without any express or
* implied warranty. In no event will the authors be held
* liable for any damages arising from the use of this software.
* This software is provided 'as-is', without any express or
* implied warranty. In no event will the authors be held
* liable for any damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute
* it freely, subject to the following restrictions:
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute
* it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented;
* you must not claim that you wrote the original software.
* If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but
* is not required.
* 1. The origin of this software must not be misrepresented;
* you must not claim that you wrote the original software.
* If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but
* is not required.
*
* 2. Altered source versions must be plainly marked as such,
* and must not be misrepresented as being the original software.
* 2. Altered source versions must be plainly marked as such,
* and must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any
* source distribution.
* 3. This notice may not be removed or altered from any
* source distribution.
*/
module dsfml.window.input;
@ -31,136 +31,136 @@ import dsfml.system.common;
import dsfml.window.event;
/**
* Input handles real-time input from keyboard and mouse.
* Use it instead of events to handle continuous moves and more
* game-friendly inputs
* Input handles real-time input from keyboard and mouse.
* Use it instead of events to handle continuous moves and more
* game-friendly inputs
*/
class Input : DSFMLObject
{
/**
* Get the state of a key
*
* Params:
* key = Key to check
*
* Returns:
* True if key is down, false if key is up
*/
bool isKeyDown(KeyCode key)
/**
* Get the state of a key
*
* Params:
* key = Key to check
*
* Returns:
* True if key is down, false if key is up
*/
bool isKeyDown(KeyCode key)
{
return cast(bool)sfInput_IsKeyDown(m_ptr, key);
}
/**
* Get the state of a mouse button
*
* Params:
* button = Button to check
*
* Returns:
* True if button is down, false if button is up
*/
bool isMouseButtonDown(MouseButtons button)
/**
* Get the state of a mouse button
*
* Params:
* button = Button to check
*
* Returns:
* True if button is down, false if button is up
*/
bool isMouseButtonDown(MouseButtons button)
{
return cast(bool)sfInput_IsMouseButtonDown(m_ptr, button);
}
/**
* Get the state of a joystick button
*
* Params:
* joyId = Identifier of the joystick to check (0 or 1)
* button = Button to check
*
* Returns:
* True if button is down, false if button is up
*/
bool isJoystickButtonDown(uint joyId, uint button)
/**
* Get the state of a joystick button
*
* Params:
* joyId = Identifier of the joystick to check (0 or 1)
* button = Button to check
*
* Returns:
* True if button is down, false if button is up
*/
bool isJoystickButtonDown(uint joyId, uint button)
{
return cast(bool)sfInput_IsJoystickButtonDown(m_ptr, joyId, button);
}
/*
* Get the mouse X position
*
* Returns:
* Current mouse left position, relative to owner window
*/
int getMouseX()
/*
* Get the mouse X position
*
* Returns:
* Current mouse left position, relative to owner window
*/
int getMouseX()
{
return sfInput_GetMouseX(m_ptr);
}
/**
* Get the mouse Y position
*
* Returns:
* Current mouse top position, relative to owner window
*
*/
int getMouseY()
/**
* Get the mouse Y position
*
* Returns:
* Current mouse top position, relative to owner window
*
*/
int getMouseY()
{
return sfInput_GetMouseY(m_ptr);
}
/**
* Get a joystick axis position
*
* Params:
* joyId = Identifier of the joystick to check (0 or 1)
* axis = Axis to get
*
* Returns:
* Current axis position, in the range [-100, 100] (except for POV, which is [0, 360])
*/
float getJoystickAxis(uint joyId, JoyAxis axis)
/**
* Get a joystick axis position
*
* Params:
* joyId = Identifier of the joystick to check (0 or 1)
* axis = Axis to get
*
* Returns:
* Current axis position, in the range [-100, 100] (except for POV, which is [0, 360])
*/
float getJoystickAxis(uint joyId, JoyAxis axis)
{
return sfInput_GetJoystickAxis(m_ptr, joyId, axis);
}
this(void* input)
this(void* input)
{
super(input, true);
}
override void dispose()
{
// nothing to do
}
override void dispose()
{
// nothing to do
}
private:
// External ====================================================================
extern (C)
{
typedef int function(void*, KeyCode) pf_sfInput_IsKeyDown;
typedef int function(void*, MouseButtons) pf_sfInput_IsMouseButtonDown;
typedef int function(void*, uint, uint) pf_sfInput_IsJoystickButtonDown;
typedef uint function (void*) pf_sfInput_GetMouseX;
typedef uint function(void*) pf_sfInput_GetMouseY;
typedef float function(void*, uint, JoyAxis) pf_sfInput_GetJoystickAxis;
static pf_sfInput_IsKeyDown sfInput_IsKeyDown;
static pf_sfInput_IsMouseButtonDown sfInput_IsMouseButtonDown;
static pf_sfInput_IsJoystickButtonDown sfInput_IsJoystickButtonDown;
static pf_sfInput_GetMouseX sfInput_GetMouseX;
static pf_sfInput_GetMouseY sfInput_GetMouseY;
static pf_sfInput_GetJoystickAxis sfInput_GetJoystickAxis;
}
extern (C)
{
typedef int function(void*, KeyCode) pf_sfInput_IsKeyDown;
typedef int function(void*, MouseButtons) pf_sfInput_IsMouseButtonDown;
typedef int function(void*, uint, uint) pf_sfInput_IsJoystickButtonDown;
typedef uint function (void*) pf_sfInput_GetMouseX;
typedef uint function(void*) pf_sfInput_GetMouseY;
typedef float function(void*, uint, JoyAxis) pf_sfInput_GetJoystickAxis;
static pf_sfInput_IsKeyDown sfInput_IsKeyDown;
static pf_sfInput_IsMouseButtonDown sfInput_IsMouseButtonDown;
static pf_sfInput_IsJoystickButtonDown sfInput_IsJoystickButtonDown;
static pf_sfInput_GetMouseX sfInput_GetMouseX;
static pf_sfInput_GetMouseY sfInput_GetMouseY;
static pf_sfInput_GetJoystickAxis sfInput_GetJoystickAxis;
}
static this()
{
static this()
{
debug
DllLoader dll = DllLoader.load("csfml-window-d");
else
DllLoader dll = DllLoader.load("csfml-window");
sfInput_IsKeyDown = cast(pf_sfInput_IsKeyDown)dll.getSymbol("sfInput_IsKeyDown");
sfInput_IsMouseButtonDown = cast(pf_sfInput_IsMouseButtonDown)dll.getSymbol("sfInput_IsMouseButtonDown");
sfInput_IsJoystickButtonDown = cast(pf_sfInput_IsJoystickButtonDown)dll.getSymbol("sfInput_IsJoystickButtonDown");
sfInput_GetMouseX = cast(pf_sfInput_GetMouseX)dll.getSymbol("sfInput_GetMouseX");
sfInput_GetMouseY = cast(pf_sfInput_GetMouseY)dll.getSymbol("sfInput_GetMouseY");
sfInput_GetJoystickAxis = cast(pf_sfInput_GetJoystickAxis)dll.getSymbol("sfInput_GetJoystickAxis");
}
sfInput_IsKeyDown = cast(pf_sfInput_IsKeyDown)dll.getSymbol("sfInput_IsKeyDown");
sfInput_IsMouseButtonDown = cast(pf_sfInput_IsMouseButtonDown)dll.getSymbol("sfInput_IsMouseButtonDown");
sfInput_IsJoystickButtonDown = cast(pf_sfInput_IsJoystickButtonDown)dll.getSymbol("sfInput_IsJoystickButtonDown");
sfInput_GetMouseX = cast(pf_sfInput_GetMouseX)dll.getSymbol("sfInput_GetMouseX");
sfInput_GetMouseY = cast(pf_sfInput_GetMouseY)dll.getSymbol("sfInput_GetMouseY");
sfInput_GetJoystickAxis = cast(pf_sfInput_GetJoystickAxis)dll.getSymbol("sfInput_GetJoystickAxis");
}
}

View file

@ -1,27 +1,27 @@
/*
* DSFML - SFML Library wrapper for the D programming language.
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
* Copyright (C) 2010 Andreas Hollandt
* DSFML - SFML Library wrapper for the D programming language.
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
* Copyright (C) 2010 Andreas Hollandt
*
* This software is provided 'as-is', without any express or
* implied warranty. In no event will the authors be held
* liable for any damages arising from the use of this software.
* This software is provided 'as-is', without any express or
* implied warranty. In no event will the authors be held
* liable for any damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute
* it freely, subject to the following restrictions:
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute
* it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented;
* you must not claim that you wrote the original software.
* If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but
* is not required.
* 1. The origin of this software must not be misrepresented;
* you must not claim that you wrote the original software.
* If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but
* is not required.
*
* 2. Altered source versions must be plainly marked as such,
* and must not be misrepresented as being the original software.
* 2. Altered source versions must be plainly marked as such,
* and must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any
* source distribution.
* 3. This notice may not be removed or altered from any
* source distribution.
*/
module dsfml.window.videomode;
@ -29,9 +29,9 @@ module dsfml.window.videomode;
import dsfml.system.common;
/**
* VideoMode defines a video mode (width, height, bpp, frequency)
* and provides static functions for getting modes supported
* by the display device
* VideoMode defines a video mode (width, height, bpp, frequency)
* and provides static functions for getting modes supported
* by the display device
*/
align(1) struct VideoMode
{
@ -39,81 +39,81 @@ align(1) struct VideoMode
uint Height; /// Video mode height, in pixels
uint BitsPerPixel = 32; /// Video mode pixel depth, in bits per pixels
/**
* Get the current desktop video mode
*
* Returns:
* Current desktop video mode
*/
static VideoMode getDesktopMode()
{
return sfVideoMode_GetDesktopMode();
}
/**
* Get the current desktop video mode
*
* Returns:
* Current desktop video mode
*/
static VideoMode getDesktopMode()
{
return sfVideoMode_GetDesktopMode();
}
/**
* Get a valid video mode
* Index must be in range [0, GetModesCount()[
* Modes are sorted from best to worst
*
* Params:
* index = Index of video mode to get
*
* Returns:
* Corresponding video mode (invalid mode if index is out of range)
*/
static VideoMode getMode(size_t index)
{
return sfVideoMode_GetMode(index);
}
/**
* Get a valid video mode
* Index must be in range [0, GetModesCount()[
* Modes are sorted from best to worst
*
* Params:
* index = Index of video mode to get
*
* Returns:
* Corresponding video mode (invalid mode if index is out of range)
*/
static VideoMode getMode(size_t index)
{
return sfVideoMode_GetMode(index);
}
/**
* Get valid video modes count
*
* Returns:
* Number of valid video modes available
*/
static size_t getModesCount()
{
return sfVideoMode_GetModesCount();
}
/**
* Get valid video modes count
*
* Returns:
* Number of valid video modes available
*/
static size_t getModesCount()
{
return sfVideoMode_GetModesCount();
}
/**
* Tell whether or not the video mode is supported
*
* Returns:
* True if video mode is supported, false otherwise
*/
bool isValid()
{
return cast(bool)sfVideoMode_IsValid(this);
}
/**
* Tell whether or not the video mode is supported
*
* Returns:
* True if video mode is supported, false otherwise
*/
bool isValid()
{
return cast(bool)sfVideoMode_IsValid(this);
}
/**
* Comparison operator overload -- tell if two video modes are equal
*
* Params:
* Other : Video mode to compare
*
* Returns:
* True if modes are equal
*/
const bool opEquals(ref const(VideoMode) other)
{
return ((other.Width == Width) && (other.Height == Height) && (other.BitsPerPixel == BitsPerPixel));
}
/**
* Comparison operator overload -- tell if two video modes are equal
*
* Params:
* Other : Video mode to compare
*
* Returns:
* True if modes are equal
*/
const bool opEquals(ref const(VideoMode) other)
{
return ((other.Width == Width) && (other.Height == Height) && (other.BitsPerPixel == BitsPerPixel));
}
}
extern (C)
{
typedef VideoMode function() pf_sfVideoMode_GetDesktopMode;
typedef VideoMode function(size_t) pf_sfVideoMode_GetMode;
typedef size_t function() pf_sfVideoMode_GetModesCount;
typedef int function(VideoMode) pf_sfVideoMode_IsValid;
pf_sfVideoMode_GetDesktopMode sfVideoMode_GetDesktopMode;
pf_sfVideoMode_GetMode sfVideoMode_GetMode;
pf_sfVideoMode_GetModesCount sfVideoMode_GetModesCount;
pf_sfVideoMode_IsValid sfVideoMode_IsValid;
typedef VideoMode function() pf_sfVideoMode_GetDesktopMode;
typedef VideoMode function(size_t) pf_sfVideoMode_GetMode;
typedef size_t function() pf_sfVideoMode_GetModesCount;
typedef int function(VideoMode) pf_sfVideoMode_IsValid;
pf_sfVideoMode_GetDesktopMode sfVideoMode_GetDesktopMode;
pf_sfVideoMode_GetMode sfVideoMode_GetMode;
pf_sfVideoMode_GetModesCount sfVideoMode_GetModesCount;
pf_sfVideoMode_IsValid sfVideoMode_IsValid;
}
static this()
@ -122,11 +122,11 @@ static this()
DllLoader dll = DllLoader.load("csfml-window-d");
else
DllLoader dll = DllLoader.load("csfml-window");
sfVideoMode_GetDesktopMode = cast(pf_sfVideoMode_GetDesktopMode)dll.getSymbol("sfVideoMode_GetDesktopMode");
sfVideoMode_GetMode = cast(pf_sfVideoMode_GetMode)dll.getSymbol("sfVideoMode_GetMode");
sfVideoMode_GetModesCount = cast(pf_sfVideoMode_GetModesCount)dll.getSymbol("sfVideoMode_GetModesCount");
sfVideoMode_IsValid = cast(pf_sfVideoMode_IsValid)dll.getSymbol("sfVideoMode_IsValid");
sfVideoMode_GetDesktopMode = cast(pf_sfVideoMode_GetDesktopMode)dll.getSymbol("sfVideoMode_GetDesktopMode");
sfVideoMode_GetMode = cast(pf_sfVideoMode_GetMode)dll.getSymbol("sfVideoMode_GetMode");
sfVideoMode_GetModesCount = cast(pf_sfVideoMode_GetModesCount)dll.getSymbol("sfVideoMode_GetModesCount");
sfVideoMode_IsValid = cast(pf_sfVideoMode_IsValid)dll.getSymbol("sfVideoMode_IsValid");
}

View file

@ -1,27 +1,27 @@
/*
* DSFML - SFML Library wrapper for the D programming language.
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
* Copyright (C) 2010 Andreas Hollandt
* DSFML - SFML Library wrapper for the D programming language.
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
* Copyright (C) 2010 Andreas Hollandt
*
* This software is provided 'as-is', without any express or
* implied warranty. In no event will the authors be held
* liable for any damages arising from the use of this software.
* This software is provided 'as-is', without any express or
* implied warranty. In no event will the authors be held
* liable for any damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute
* it freely, subject to the following restrictions:
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute
* it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented;
* you must not claim that you wrote the original software.
* If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but
* is not required.
* 1. The origin of this software must not be misrepresented;
* you must not claim that you wrote the original software.
* If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but
* is not required.
*
* 2. Altered source versions must be plainly marked as such,
* and must not be misrepresented as being the original software.
* 2. Altered source versions must be plainly marked as such,
* and must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any
* source distribution.
* 3. This notice may not be removed or altered from any
* source distribution.
*/
module dsfml.window.window;
@ -36,15 +36,15 @@ import dsfml.system.stringutil;
/**
* Window style
* Window style
*/
enum Style
{
NONE = 0, /// No border / title bar (this flag and all others are mutually exclusive)
TITLEBAR = 1 << 0, /// Title bar + fixed border
RESIZE = 1 << 1, /// Titlebar + resizable border + maximize button
CLOSE = 1 << 2, /// Titlebar + close button
FULLSCREEN = 1 << 3 /// Fullscreen mode (this flag and all others are mutually exclusive)
NONE = 0, /// No border / title bar (this flag and all others are mutually exclusive)
TITLEBAR = 1 << 0, /// Title bar + fixed border
RESIZE = 1 << 1, /// Titlebar + resizable border + maximize button
CLOSE = 1 << 2, /// Titlebar + close button
FULLSCREEN = 1 << 3 /// Fullscreen mode (this flag and all others are mutually exclusive)
}
@ -53,412 +53,412 @@ enum Style
*/
struct ContextSettings
{
uint DepthBits = 24; /// Bits of the depth buffer
uint StencilBits = 8; /// Bits of the stencil buffer
uint AntialiasingLevel = 0; /// Level of antialiasing
uint DepthBits = 24; /// Bits of the depth buffer
uint StencilBits = 8; /// Bits of the stencil buffer
uint AntialiasingLevel = 0; /// Level of antialiasing
uint MajorVersion = 3; /// Major number of the context version to create
uint MinorVersion = 0; /// Minor number of the context version to create
}
/**
* Window is a rendering window ; it can create a new window
* or connect to an existing one
* Window is a rendering window ; it can create a new window
* or connect to an existing one
*/
class Window : DSFMLObject
{
/**
* Construct a new window
*
* Params:
* mode = Video mode to use
* title = Title of the window
* windowStyle = Window style (Resize | Close by default)
* settings = Context settings (default is default ContextSettings values)
*/
this(VideoMode mode, string title, Style windowStyle = Style.RESIZE | Style.CLOSE, ContextSettings settings = ContextSettings())
{
super(sfWindow_Create(mode, toStringz(title), windowStyle, settings));
}
{
/**
* Construct a new window
*
* Params:
* mode = Video mode to use
* title = Title of the window
* windowStyle = Window style (Resize | Close by default)
* settings = Context settings (default is default ContextSettings values)
*/
this(VideoMode mode, string title, Style windowStyle = Style.RESIZE | Style.CLOSE, ContextSettings settings = ContextSettings())
{
super(sfWindow_Create(mode, toStringz(title), windowStyle, settings));
}
/**
* Construct the window from an existing control
*
* Params:
* handle = Platform-specific handle of the control
* settings = Context settings (default is default ContextSettings values)
*/
this(WindowHandle handle, ContextSettings settings = ContextSettings())
{
super(sfWindow_CreateFromHandle(handle, settings));
}
/**
* Construct the window from an existing control
*
* Params:
* handle = Platform-specific handle of the control
* settings = Context settings (default is default ContextSettings values)
*/
this(WindowHandle handle, ContextSettings settings = ContextSettings())
{
super(sfWindow_CreateFromHandle(handle, settings));
}
override void dispose()
{
m_input = null;
sfWindow_Destroy(m_ptr);
}
override void dispose()
{
m_input = null;
sfWindow_Destroy(m_ptr);
}
/**
* Create (or recreate) the window
*
* Input created with getInput becomes invalid.
*
* Params:
* mode = Video mode to use
* title = Title of the window
* windowStyle = Window style (Resize | Close by default)
* settings = Context settings (default is default ContextSettings values)
*/
void create(VideoMode mode, string title, Style windowStyle = Style.RESIZE | Style.CLOSE, ContextSettings settings = ContextSettings())
{
if (m_ptr !is null)
dispose();
/**
* Create (or recreate) the window
*
* Input created with getInput becomes invalid.
*
* Params:
* mode = Video mode to use
* title = Title of the window
* windowStyle = Window style (Resize | Close by default)
* settings = Context settings (default is default ContextSettings values)
*/
void create(VideoMode mode, string title, Style windowStyle = Style.RESIZE | Style.CLOSE, ContextSettings settings = ContextSettings())
{
if (m_ptr !is null)
dispose();
m_ptr = sfWindow_Create(mode, toStringz(title), windowStyle, settings);
}
m_ptr = sfWindow_Create(mode, toStringz(title), windowStyle, settings);
}
/**
* Create (or recreate) the window from an existing control
*
* Input created with getInput becomes invalid.
*
* Params:
* handle = Platform-specific handle of the control
* settings = Context settings (default is default ContextSettings values)
*/
void create(WindowHandle handle, ContextSettings settings = ContextSettings())
{
if (m_ptr !is null)
dispose();
/**
* Create (or recreate) the window from an existing control
*
* Input created with getInput becomes invalid.
*
* Params:
* handle = Platform-specific handle of the control
* settings = Context settings (default is default ContextSettings values)
*/
void create(WindowHandle handle, ContextSettings settings = ContextSettings())
{
if (m_ptr !is null)
dispose();
m_ptr = sfWindow_CreateFromHandle(handle, settings);
}
m_ptr = sfWindow_CreateFromHandle(handle, settings);
}
/**
* Close (destroy) the window.
* You can call create to recreate a valid window
*/
void close()
{
sfWindow_Close(m_ptr);
}
/**
* Close (destroy) the window.
* You can call create to recreate a valid window
*/
void close()
{
sfWindow_Close(m_ptr);
}
/**
* Tell whether or not a window is opened
*
* Returns:
* True if window is currently open.
*/
bool isOpened()
{
return cast(bool) sfWindow_IsOpened(m_ptr);
}
/**
* Get the width of the rendering region of the window
*
* Returns:
* Width in pixels
*/
uint getWidth()
{
return sfWindow_GetWidth(m_ptr);
}
/**
* Tell whether or not a window is opened
*
* Returns:
* True if window is currently open.
*/
bool isOpened()
{
return cast(bool) sfWindow_IsOpened(m_ptr);
}
/**
* Get the width of the rendering region of the window
*
* Returns:
* Width in pixels
*/
uint getWidth()
{
return sfWindow_GetWidth(m_ptr);
}
/**
* Get the height of the rendering region of the window
*
* Returns:
* Height in pixels
*/
uint getHeight()
{
return sfWindow_GetHeight(m_ptr);
}
/**
* Get the height of the rendering region of the window
*
* Returns:
* Height in pixels
*/
uint getHeight()
{
return sfWindow_GetHeight(m_ptr);
}
/**
* Get the creation settings of a window
*
* Returns:
* Settings used to create the window
*/
ContextSettings getSettings()
{
return sfWindow_GetSettings(m_ptr);
}
/**
* Get the creation settings of a window
*
* Returns:
* Settings used to create the window
*/
ContextSettings getSettings()
{
return sfWindow_GetSettings(m_ptr);
}
/**
* Get the event on top of events stack, if any, and pop it
*
* Params:
* eventReceived = Event to fill, if any
*
* Returns:
* True if an event was returned, false if events stack was empty
*/
bool getEvent(ref Event eventReceived)
{
return cast(bool)sfWindow_GetEvent(m_ptr, &eventReceived);
}
/**
* Get the event on top of events stack, if any, and pop it
*
* Params:
* eventReceived = Event to fill, if any
*
* Returns:
* True if an event was returned, false if events stack was empty
*/
bool getEvent(ref Event eventReceived)
{
return cast(bool)sfWindow_GetEvent(m_ptr, &eventReceived);
}
/**
* Enable / disable vertical synchronization
*
* Params:
* enabled : True to enable v-sync, false to deactivate
*/
void useVerticalSync(bool enabled)
{
sfWindow_UseVerticalSync(m_ptr, enabled);
}
/**
* Enable / disable vertical synchronization
*
* Params:
* enabled : True to enable v-sync, false to deactivate
*/
void useVerticalSync(bool enabled)
{
sfWindow_UseVerticalSync(m_ptr, enabled);
}
/**
* Show or hide the mouse cursor
*
* Params:
* show : True to show, false to hide
*/
void showMouseCursor(bool show)
{
sfWindow_ShowMouseCursor(m_ptr, show);
}
/**
* Show or hide the mouse cursor
*
* Params:
* show : True to show, false to hide
*/
void showMouseCursor(bool show)
{
sfWindow_ShowMouseCursor(m_ptr, show);
}
/**
* Change the position of the mouse cursor
*
* Params:
* left = Left coordinate of the cursor, relative to the window
* top = Top coordinate of the cursor, relative to the window
*/
void setCursorPosition(uint left, uint top)
{
sfWindow_SetCursorPosition(m_ptr, left, top);
}
/**
* Change the position of the mouse cursor
*
* Params:
* left = Left coordinate of the cursor, relative to the window
* top = Top coordinate of the cursor, relative to the window
*/
void setCursorPosition(uint left, uint top)
{
sfWindow_SetCursorPosition(m_ptr, left, top);
}
/**
* Change the position of the window on screen.
* Only works for top-level windows
*
* Params:
* left = Left position
* top = Top position
*/
void setPosition(int left, int top)
{
sfWindow_SetPosition(m_ptr, left, top);
}
/**
* change the size of the rendering region of the window
*
* Params:
* width : new width
* height : new height
*/
void setSize(uint width, uint height)
{
sfWindow_SetSize(m_ptr, width, height);
}
/**
* Change the position of the window on screen.
* Only works for top-level windows
*
* Params:
* left = Left position
* top = Top position
*/
void setPosition(int left, int top)
{
sfWindow_SetPosition(m_ptr, left, top);
}
/**
* change the size of the rendering region of the window
*
* Params:
* width : new width
* height : new height
*/
void setSize(uint width, uint height)
{
sfWindow_SetSize(m_ptr, width, height);
}
/**
* Show or hide the window
*
* Params:
* state = True to show, false to hide
*
*/
void show(bool state)
{
sfWindow_Show(m_ptr, state);
}
/**
* Show or hide the window
*
* Params:
* state = True to show, false to hide
*
*/
void show(bool state)
{
sfWindow_Show(m_ptr, state);
}
/**
* Enable or disable automatic key-repeat for keydown events.
* Automatic key-repeat is enabled by default.
*
* Params:
* enabled = true to enable, false to disable
*/
void enableKeyRepeat(bool enabled)
{
sfWindow_EnableKeyRepeat(m_ptr, enabled);
}
/**
* Change the window's icon
*
* Params:
* width = Icon's width, in pixels
* height = Icon's height, in pixels
* data = array of pixels in memory, format must be RGBA 32 bits
*
*/
void setIcon(size_t width, size_t height, ubyte[] data)
{
sfWindow_SetIcon(m_ptr, width, height, data.ptr);
}
/**
* Enable or disable automatic key-repeat for keydown events.
* Automatic key-repeat is enabled by default.
*
* Params:
* enabled = true to enable, false to disable
*/
void enableKeyRepeat(bool enabled)
{
sfWindow_EnableKeyRepeat(m_ptr, enabled);
}
/**
* Change the window's icon
*
* Params:
* width = Icon's width, in pixels
* height = Icon's height, in pixels
* data = array of pixels in memory, format must be RGBA 32 bits
*
*/
void setIcon(size_t width, size_t height, ubyte[] data)
{
sfWindow_SetIcon(m_ptr, width, height, data.ptr);
}
/**
* Set the window as the current target for rendering
*
* Params:
* active = True to activate, false to deactivate
* Returns:
* True if operation was successful, false otherwise
*/
bool setActive(bool active = true)
{
return cast(bool)sfWindow_SetActive(m_ptr, active);
}
/**
* Set the window as the current target for rendering
*
* Params:
* active = True to activate, false to deactivate
* Returns:
* True if operation was successful, false otherwise
*/
bool setActive(bool active = true)
{
return cast(bool)sfWindow_SetActive(m_ptr, active);
}
/**
* Display the window on screen
*/
void display()
{
sfWindow_Display(m_ptr);
}
/**
* Display the window on screen
*/
void display()
{
sfWindow_Display(m_ptr);
}
/**
* Get the input manager of the window
*
* Returns:
* An input manager
* See_Also :
* Input
*/
Input getInput()
{
if (m_input is null)
m_input = new Input(sfWindow_GetInput(m_ptr));
return m_input;
}
/**
* Get the input manager of the window
*
* Returns:
* An input manager
* See_Also :
* Input
*/
Input getInput()
{
if (m_input is null)
m_input = new Input(sfWindow_GetInput(m_ptr));
return m_input;
}
/**
* Limit the framerate to a maximum fixed frequency
*
* Params:
* limit : Framerate limit, in frames per seconds (use 0 to disable limit)
*/
void setFramerateLimit(uint limit)
{
sfWindow_SetFramerateLimit(m_ptr, limit);
}
/**
* Limit the framerate to a maximum fixed frequency
*
* Params:
* limit : Framerate limit, in frames per seconds (use 0 to disable limit)
*/
void setFramerateLimit(uint limit)
{
sfWindow_SetFramerateLimit(m_ptr, limit);
}
/**
* Get time elapsed since last frame
*
* Returns:
* Time elapsed, in seconds
*/
float getFrameTime()
{
return sfWindow_GetFrameTime(m_ptr);
}
/**
* Get time elapsed since last frame
*
* Returns:
* Time elapsed, in seconds
*/
float getFrameTime()
{
return sfWindow_GetFrameTime(m_ptr);
}
/**
* Change the joystick threshold, ie. the value below which
* no move event will be generated
*
* Params:
* threshold : New threshold, in range [0, 100]
*/
void setJoystickThreshold(float threshold)
{
sfWindow_SetJoystickThreshold(m_ptr, threshold);
}
/**
* Change the joystick threshold, ie. the value below which
* no move event will be generated
*
* Params:
* threshold : New threshold, in range [0, 100]
*/
void setJoystickThreshold(float threshold)
{
sfWindow_SetJoystickThreshold(m_ptr, threshold);
}
protected:
this(void* ptr)
{
super(ptr);
}
this(void* ptr)
{
super(ptr);
}
Input m_input;
Input m_input;
private:
// External ====================================================================
extern (C)
{
typedef void* function(VideoMode, cchar*, uint, ContextSettings) pf_sfWindow_Create;
typedef void* function(WindowHandle, ContextSettings) pf_sfWindow_CreateFromHandle;
typedef void function(void*) pf_sfWindow_Destroy;
typedef void function(void*) pf_sfWindow_Close;
typedef int function(void*) pf_sfWindow_IsOpened;
typedef uint function(void*) pf_sfWindow_GetWidth;
typedef uint function(void*) pf_sfWindow_GetHeight;
typedef ContextSettings function(void* Window) pf_sfWindow_GetSettings;
typedef int function(void*, Event*) pf_sfWindow_GetEvent;
typedef void function(void*, int) pf_sfWindow_UseVerticalSync;
typedef void function(void*, int) pf_sfWindow_ShowMouseCursor;
typedef void function(void*, uint, uint) pf_sfWindow_SetCursorPosition;
typedef void function(void*, int, int) pf_sfWindow_SetPosition;
typedef void function(void*, uint, uint) pf_sfWindow_SetSize;
typedef void function(void*, int) pf_sfWindow_Show;
typedef void function(void*, int) pf_sfWindow_EnableKeyRepeat;
typedef void function(void*, size_t, size_t, ubyte*) pf_sfWindow_SetIcon;
typedef int function(void*, int) pf_sfWindow_SetActive;
typedef void function(void*) pf_sfWindow_Display;
typedef void* function(void*) pf_sfWindow_GetInput;
typedef void function(void*, uint) pf_sfWindow_SetFramerateLimit;
typedef float function(void*) pf_sfWindow_GetFrameTime;
typedef void function(void*, float) pf_sfWindow_SetJoystickThreshold;
static pf_sfWindow_Create sfWindow_Create;
static pf_sfWindow_CreateFromHandle sfWindow_CreateFromHandle;
static pf_sfWindow_Destroy sfWindow_Destroy;
static pf_sfWindow_Close sfWindow_Close;
static pf_sfWindow_IsOpened sfWindow_IsOpened;
static pf_sfWindow_GetWidth sfWindow_GetWidth;
static pf_sfWindow_GetHeight sfWindow_GetHeight;
static pf_sfWindow_GetSettings sfWindow_GetSettings;
static pf_sfWindow_GetEvent sfWindow_GetEvent;
static pf_sfWindow_UseVerticalSync sfWindow_UseVerticalSync;
static pf_sfWindow_ShowMouseCursor sfWindow_ShowMouseCursor;
static pf_sfWindow_SetCursorPosition sfWindow_SetCursorPosition;
static pf_sfWindow_SetPosition sfWindow_SetPosition;
static pf_sfWindow_SetSize sfWindow_SetSize;
static pf_sfWindow_Show sfWindow_Show;
static pf_sfWindow_EnableKeyRepeat sfWindow_EnableKeyRepeat;
static pf_sfWindow_SetIcon sfWindow_SetIcon;
static pf_sfWindow_SetActive sfWindow_SetActive;
static pf_sfWindow_Display sfWindow_Display;
static pf_sfWindow_GetInput sfWindow_GetInput;
static pf_sfWindow_SetFramerateLimit sfWindow_SetFramerateLimit;
static pf_sfWindow_GetFrameTime sfWindow_GetFrameTime;
static pf_sfWindow_SetJoystickThreshold sfWindow_SetJoystickThreshold;
}
extern (C)
{
typedef void* function(VideoMode, cchar*, uint, ContextSettings) pf_sfWindow_Create;
typedef void* function(WindowHandle, ContextSettings) pf_sfWindow_CreateFromHandle;
typedef void function(void*) pf_sfWindow_Destroy;
typedef void function(void*) pf_sfWindow_Close;
typedef int function(void*) pf_sfWindow_IsOpened;
typedef uint function(void*) pf_sfWindow_GetWidth;
typedef uint function(void*) pf_sfWindow_GetHeight;
typedef ContextSettings function(void* Window) pf_sfWindow_GetSettings;
typedef int function(void*, Event*) pf_sfWindow_GetEvent;
typedef void function(void*, int) pf_sfWindow_UseVerticalSync;
typedef void function(void*, int) pf_sfWindow_ShowMouseCursor;
typedef void function(void*, uint, uint) pf_sfWindow_SetCursorPosition;
typedef void function(void*, int, int) pf_sfWindow_SetPosition;
typedef void function(void*, uint, uint) pf_sfWindow_SetSize;
typedef void function(void*, int) pf_sfWindow_Show;
typedef void function(void*, int) pf_sfWindow_EnableKeyRepeat;
typedef void function(void*, size_t, size_t, ubyte*) pf_sfWindow_SetIcon;
typedef int function(void*, int) pf_sfWindow_SetActive;
typedef void function(void*) pf_sfWindow_Display;
typedef void* function(void*) pf_sfWindow_GetInput;
typedef void function(void*, uint) pf_sfWindow_SetFramerateLimit;
typedef float function(void*) pf_sfWindow_GetFrameTime;
typedef void function(void*, float) pf_sfWindow_SetJoystickThreshold;
static pf_sfWindow_Create sfWindow_Create;
static pf_sfWindow_CreateFromHandle sfWindow_CreateFromHandle;
static pf_sfWindow_Destroy sfWindow_Destroy;
static pf_sfWindow_Close sfWindow_Close;
static pf_sfWindow_IsOpened sfWindow_IsOpened;
static pf_sfWindow_GetWidth sfWindow_GetWidth;
static pf_sfWindow_GetHeight sfWindow_GetHeight;
static pf_sfWindow_GetSettings sfWindow_GetSettings;
static pf_sfWindow_GetEvent sfWindow_GetEvent;
static pf_sfWindow_UseVerticalSync sfWindow_UseVerticalSync;
static pf_sfWindow_ShowMouseCursor sfWindow_ShowMouseCursor;
static pf_sfWindow_SetCursorPosition sfWindow_SetCursorPosition;
static pf_sfWindow_SetPosition sfWindow_SetPosition;
static pf_sfWindow_SetSize sfWindow_SetSize;
static pf_sfWindow_Show sfWindow_Show;
static pf_sfWindow_EnableKeyRepeat sfWindow_EnableKeyRepeat;
static pf_sfWindow_SetIcon sfWindow_SetIcon;
static pf_sfWindow_SetActive sfWindow_SetActive;
static pf_sfWindow_Display sfWindow_Display;
static pf_sfWindow_GetInput sfWindow_GetInput;
static pf_sfWindow_SetFramerateLimit sfWindow_SetFramerateLimit;
static pf_sfWindow_GetFrameTime sfWindow_GetFrameTime;
static pf_sfWindow_SetJoystickThreshold sfWindow_SetJoystickThreshold;
}
static this()
{
debug
static this()
{
debug
DllLoader dll = DllLoader.load("csfml-window-d");
else
DllLoader dll = DllLoader.load("csfml-window");
sfWindow_Create = cast(pf_sfWindow_Create)dll.getSymbol("sfWindow_Create");
sfWindow_CreateFromHandle = cast(pf_sfWindow_CreateFromHandle)dll.getSymbol("sfWindow_CreateFromHandle");
sfWindow_Destroy = cast(pf_sfWindow_Destroy)dll.getSymbol("sfWindow_Destroy");
sfWindow_Close = cast(pf_sfWindow_Close)dll.getSymbol("sfWindow_Close");
sfWindow_IsOpened = cast(pf_sfWindow_IsOpened)dll.getSymbol("sfWindow_IsOpened");
sfWindow_GetWidth = cast(pf_sfWindow_GetWidth)dll.getSymbol("sfWindow_GetWidth");
sfWindow_GetHeight = cast(pf_sfWindow_GetHeight)dll.getSymbol("sfWindow_GetHeight");
sfWindow_GetSettings = cast(pf_sfWindow_GetSettings)dll.getSymbol("sfWindow_GetSettings");
sfWindow_GetEvent = cast(pf_sfWindow_GetEvent)dll.getSymbol("sfWindow_GetEvent");
sfWindow_UseVerticalSync = cast(pf_sfWindow_UseVerticalSync)dll.getSymbol("sfWindow_UseVerticalSync");
sfWindow_ShowMouseCursor = cast(pf_sfWindow_ShowMouseCursor)dll.getSymbol("sfWindow_ShowMouseCursor");
sfWindow_SetCursorPosition = cast(pf_sfWindow_SetCursorPosition)dll.getSymbol("sfWindow_SetCursorPosition");
sfWindow_SetPosition = cast(pf_sfWindow_SetPosition)dll.getSymbol("sfWindow_SetPosition");
sfWindow_SetSize = cast(pf_sfWindow_SetSize)dll.getSymbol("sfWindow_SetSize");
sfWindow_Show = cast(pf_sfWindow_Show)dll.getSymbol("sfWindow_Show");
sfWindow_EnableKeyRepeat = cast(pf_sfWindow_EnableKeyRepeat)dll.getSymbol("sfWindow_EnableKeyRepeat");
sfWindow_SetIcon = cast(pf_sfWindow_SetIcon)dll.getSymbol("sfWindow_SetIcon");
sfWindow_SetActive = cast(pf_sfWindow_SetActive)dll.getSymbol("sfWindow_SetActive");
sfWindow_Display = cast(pf_sfWindow_Display)dll.getSymbol("sfWindow_Display");
sfWindow_GetInput = cast(pf_sfWindow_GetInput)dll.getSymbol("sfWindow_GetInput");
sfWindow_SetFramerateLimit = cast(pf_sfWindow_SetFramerateLimit)dll.getSymbol("sfWindow_SetFramerateLimit");
sfWindow_GetFrameTime = cast(pf_sfWindow_GetFrameTime)dll.getSymbol("sfWindow_GetFrameTime");
sfWindow_SetJoystickThreshold = cast(pf_sfWindow_SetJoystickThreshold)dll.getSymbol("sfWindow_SetJoystickThreshold");
}
sfWindow_Create = cast(pf_sfWindow_Create)dll.getSymbol("sfWindow_Create");
sfWindow_CreateFromHandle = cast(pf_sfWindow_CreateFromHandle)dll.getSymbol("sfWindow_CreateFromHandle");
sfWindow_Destroy = cast(pf_sfWindow_Destroy)dll.getSymbol("sfWindow_Destroy");
sfWindow_Close = cast(pf_sfWindow_Close)dll.getSymbol("sfWindow_Close");
sfWindow_IsOpened = cast(pf_sfWindow_IsOpened)dll.getSymbol("sfWindow_IsOpened");
sfWindow_GetWidth = cast(pf_sfWindow_GetWidth)dll.getSymbol("sfWindow_GetWidth");
sfWindow_GetHeight = cast(pf_sfWindow_GetHeight)dll.getSymbol("sfWindow_GetHeight");
sfWindow_GetSettings = cast(pf_sfWindow_GetSettings)dll.getSymbol("sfWindow_GetSettings");
sfWindow_GetEvent = cast(pf_sfWindow_GetEvent)dll.getSymbol("sfWindow_GetEvent");
sfWindow_UseVerticalSync = cast(pf_sfWindow_UseVerticalSync)dll.getSymbol("sfWindow_UseVerticalSync");
sfWindow_ShowMouseCursor = cast(pf_sfWindow_ShowMouseCursor)dll.getSymbol("sfWindow_ShowMouseCursor");
sfWindow_SetCursorPosition = cast(pf_sfWindow_SetCursorPosition)dll.getSymbol("sfWindow_SetCursorPosition");
sfWindow_SetPosition = cast(pf_sfWindow_SetPosition)dll.getSymbol("sfWindow_SetPosition");
sfWindow_SetSize = cast(pf_sfWindow_SetSize)dll.getSymbol("sfWindow_SetSize");
sfWindow_Show = cast(pf_sfWindow_Show)dll.getSymbol("sfWindow_Show");
sfWindow_EnableKeyRepeat = cast(pf_sfWindow_EnableKeyRepeat)dll.getSymbol("sfWindow_EnableKeyRepeat");
sfWindow_SetIcon = cast(pf_sfWindow_SetIcon)dll.getSymbol("sfWindow_SetIcon");
sfWindow_SetActive = cast(pf_sfWindow_SetActive)dll.getSymbol("sfWindow_SetActive");
sfWindow_Display = cast(pf_sfWindow_Display)dll.getSymbol("sfWindow_Display");
sfWindow_GetInput = cast(pf_sfWindow_GetInput)dll.getSymbol("sfWindow_GetInput");
sfWindow_SetFramerateLimit = cast(pf_sfWindow_SetFramerateLimit)dll.getSymbol("sfWindow_SetFramerateLimit");
sfWindow_GetFrameTime = cast(pf_sfWindow_GetFrameTime)dll.getSymbol("sfWindow_GetFrameTime");
sfWindow_SetJoystickThreshold = cast(pf_sfWindow_SetJoystickThreshold)dll.getSymbol("sfWindow_SetJoystickThreshold");
}
}

View file

@ -1,34 +1,34 @@
/*
* DSFML - SFML Library wrapper for the D programming language.
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
* Copyright (C) 2010 Andreas Hollandt
* DSFML - SFML Library wrapper for the D programming language.
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
* Copyright (C) 2010 Andreas Hollandt
*
* This software is provided 'as-is', without any express or
* implied warranty. In no event will the authors be held
* liable for any damages arising from the use of this software.
* This software is provided 'as-is', without any express or
* implied warranty. In no event will the authors be held
* liable for any damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute
* it freely, subject to the following restrictions:
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute
* it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented;
* you must not claim that you wrote the original software.
* If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but
* is not required.
* 1. The origin of this software must not be misrepresented;
* you must not claim that you wrote the original software.
* If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but
* is not required.
*
* 2. Altered source versions must be plainly marked as such,
* and must not be misrepresented as being the original software.
* 2. Altered source versions must be plainly marked as such,
* and must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any
* source distribution.
* 3. This notice may not be removed or altered from any
* source distribution.
*/
module dsfml.window.windowhandle;
/**
* Define a low-level window handle type, specific to
* each platform
* Define a low-level window handle type, specific to
* each platform
*/
version(Windows)
{
@ -37,7 +37,7 @@ version(Windows)
}
else version(linux)
{
// Unix - X11 defines an unsigned integer handle (Window)
typedef ulong WindowHandle;
// Unix - X11 defines an unsigned integer handle (Window)
typedef ulong WindowHandle;
}