mirror of
https://github.com/SFML/SFML.git
synced 2024-11-25 04:41:05 +08:00
FS#162 - Add a function to retrieve the system specific handle of a window
git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1530 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
parent
028c4d5a96
commit
ef8a2700fe
@ -287,6 +287,16 @@ CSFML_API float sfRenderWindow_GetFrameTime(const sfRenderWindow* renderWindow);
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
CSFML_API void sfRenderWindow_SetJoystickThreshold(sfRenderWindow* renderWindow, float threshold);
|
CSFML_API void sfRenderWindow_SetJoystickThreshold(sfRenderWindow* renderWindow, float threshold);
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
/// Retrieve the Os-specific handle of a window
|
||||||
|
///
|
||||||
|
/// \param renderWindow : Renderwindow object
|
||||||
|
///
|
||||||
|
/// \return Window handle
|
||||||
|
///
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
CSFML_API sfWindowHandle sfRenderWindow_GetSystemHandle(const sfRenderWindow* renderWindow);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// Draw something on a renderwindow
|
/// Draw something on a renderwindow
|
||||||
///
|
///
|
||||||
|
@ -296,5 +296,15 @@ CSFML_API float sfWindow_GetFrameTime(const sfWindow* window);
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
CSFML_API void sfWindow_SetJoystickThreshold(sfWindow* window, float threshold);
|
CSFML_API void sfWindow_SetJoystickThreshold(sfWindow* window, float threshold);
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
/// Retrieve the Os-specific handle of a window
|
||||||
|
///
|
||||||
|
/// \param window : Window object
|
||||||
|
///
|
||||||
|
/// \return Window handle
|
||||||
|
///
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
CSFML_API sfWindowHandle sfWindow_GetSystemHandle(const sfWindow* window);
|
||||||
|
|
||||||
|
|
||||||
#endif // SFML_WINDOW_H
|
#endif // SFML_WINDOW_H
|
||||||
|
@ -350,6 +350,15 @@ void sfRenderWindow_SetJoystickThreshold(sfRenderWindow* renderWindow, float thr
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
/// Retrieve the Os-specific handle of a window
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
sfWindowHandle sfRenderWindow_GetSystemHandle(const sfRenderWindow* renderWindow)
|
||||||
|
{
|
||||||
|
CSFML_CALL_RETURN(renderWindow, GetSystemHandle(), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// Draw something on a renderwindow
|
/// Draw something on a renderwindow
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
@ -223,6 +223,7 @@ EXPORTS
|
|||||||
sfRenderWindow_SetFramerateLimit
|
sfRenderWindow_SetFramerateLimit
|
||||||
sfRenderWindow_GetFrameTime
|
sfRenderWindow_GetFrameTime
|
||||||
sfRenderWindow_SetJoystickThreshold
|
sfRenderWindow_SetJoystickThreshold
|
||||||
|
sfRenderWindow_GetSystemHandle
|
||||||
sfRenderWindow_DrawSprite
|
sfRenderWindow_DrawSprite
|
||||||
sfRenderWindow_DrawText
|
sfRenderWindow_DrawText
|
||||||
sfRenderWindow_DrawShape
|
sfRenderWindow_DrawShape
|
||||||
|
@ -223,6 +223,7 @@ EXPORTS
|
|||||||
sfRenderWindow_SetFramerateLimit
|
sfRenderWindow_SetFramerateLimit
|
||||||
sfRenderWindow_GetFrameTime
|
sfRenderWindow_GetFrameTime
|
||||||
sfRenderWindow_SetJoystickThreshold
|
sfRenderWindow_SetJoystickThreshold
|
||||||
|
sfRenderWindow_GetSystemHandle
|
||||||
sfRenderWindow_DrawSprite
|
sfRenderWindow_DrawSprite
|
||||||
sfRenderWindow_DrawText
|
sfRenderWindow_DrawText
|
||||||
sfRenderWindow_DrawShape
|
sfRenderWindow_DrawShape
|
||||||
|
@ -313,6 +313,7 @@ float sfWindow_GetFrameTime(const sfWindow* window)
|
|||||||
CSFML_CALL_RETURN(window, GetFrameTime(), 0.f)
|
CSFML_CALL_RETURN(window, GetFrameTime(), 0.f)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// Change the joystick threshold, ie. the value below which
|
/// Change the joystick threshold, ie. the value below which
|
||||||
/// no move event will be generated
|
/// no move event will be generated
|
||||||
@ -321,3 +322,12 @@ void sfWindow_SetJoystickThreshold(sfWindow* window, float threshold)
|
|||||||
{
|
{
|
||||||
CSFML_CALL(window, SetJoystickThreshold(threshold))
|
CSFML_CALL(window, SetJoystickThreshold(threshold))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
/// Retrieve the Os-specific handle of a window
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
sfWindowHandle sfWindow_GetSystemHandle(const sfWindow* window)
|
||||||
|
{
|
||||||
|
CSFML_CALL_RETURN(window, GetSystemHandle(), 0);
|
||||||
|
}
|
||||||
|
@ -33,6 +33,7 @@ EXPORTS
|
|||||||
sfWindow_SetFramerateLimit
|
sfWindow_SetFramerateLimit
|
||||||
sfWindow_GetFrameTime
|
sfWindow_GetFrameTime
|
||||||
sfWindow_SetJoystickThreshold
|
sfWindow_SetJoystickThreshold
|
||||||
|
sfWindow_GetSystemHandle
|
||||||
sfContext_Create
|
sfContext_Create
|
||||||
sfContext_Destroy
|
sfContext_Destroy
|
||||||
sfContext_SetActive
|
sfContext_SetActive
|
||||||
|
@ -33,6 +33,7 @@ EXPORTS
|
|||||||
sfWindow_SetFramerateLimit
|
sfWindow_SetFramerateLimit
|
||||||
sfWindow_GetFrameTime
|
sfWindow_GetFrameTime
|
||||||
sfWindow_SetJoystickThreshold
|
sfWindow_SetJoystickThreshold
|
||||||
|
sfWindow_GetSystemHandle
|
||||||
sfContext_Create
|
sfContext_Create
|
||||||
sfContext_Destroy
|
sfContext_Destroy
|
||||||
sfContext_SetActive
|
sfContext_SetActive
|
||||||
|
4
doc/build/Doxygen.hpp
vendored
4
doc/build/Doxygen.hpp
vendored
@ -27,11 +27,11 @@
|
|||||||
/// return EXIT_FAILURE;
|
/// return EXIT_FAILURE;
|
||||||
/// sf::Sprite sprite(image);
|
/// sf::Sprite sprite(image);
|
||||||
///
|
///
|
||||||
/// // Create a graphical string to display
|
/// // Create a graphical text to display
|
||||||
/// sf::Font font;
|
/// sf::Font font;
|
||||||
/// if (!font.LoadFromFile("arial.ttf"))
|
/// if (!font.LoadFromFile("arial.ttf"))
|
||||||
/// return EXIT_FAILURE;
|
/// return EXIT_FAILURE;
|
||||||
/// sf::String text("Hello SFML", font, 50);
|
/// sf::Text text("Hello SFML", font, 50);
|
||||||
///
|
///
|
||||||
/// // Load a music to play
|
/// // Load a music to play
|
||||||
/// sf::Music music;
|
/// sf::Music music;
|
||||||
|
Binary file not shown.
Binary file not shown.
@ -294,6 +294,16 @@ namespace SFML
|
|||||||
sfRenderWindow_SetJoystickThreshold(This, threshold);
|
sfRenderWindow_SetJoystickThreshold(This, threshold);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
/// <summary>
|
||||||
|
/// OS-specific handle of the window
|
||||||
|
/// </summary>
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
public override IntPtr SystemHandle
|
||||||
|
{
|
||||||
|
get {return sfRenderWindow_GetSystemHandle(This);}
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Default view of the window
|
/// Default view of the window
|
||||||
@ -592,6 +602,9 @@ namespace SFML
|
|||||||
[DllImport("csfml-graphics", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
|
[DllImport("csfml-graphics", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
|
||||||
static extern void sfRenderWindow_ConvertCoords(IntPtr This, uint WindowX, uint WindowY, out float ViewX, out float ViewY, IntPtr TargetView);
|
static extern void sfRenderWindow_ConvertCoords(IntPtr This, uint WindowX, uint WindowY, out float ViewX, out float ViewY, IntPtr TargetView);
|
||||||
|
|
||||||
|
[DllImport("csfml-graphics", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
|
||||||
|
static extern IntPtr sfRenderWindow_GetSystemHandle(IntPtr This);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -341,6 +341,16 @@ namespace SFML
|
|||||||
sfWindow_SetJoystickThreshold(This, threshold);
|
sfWindow_SetJoystickThreshold(This, threshold);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
/// <summary>
|
||||||
|
/// OS-specific handle of the window
|
||||||
|
/// </summary>
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
public virtual IntPtr SystemHandle
|
||||||
|
{
|
||||||
|
get {return sfWindow_GetSystemHandle(This);}
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Wait for a new event and dispatch it to the corresponding
|
/// Wait for a new event and dispatch it to the corresponding
|
||||||
@ -642,6 +652,9 @@ namespace SFML
|
|||||||
|
|
||||||
[DllImport("csfml-window", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
|
[DllImport("csfml-window", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
|
||||||
static extern void sfWindow_SetJoystickThreshold(IntPtr This, float Threshold);
|
static extern void sfWindow_SetJoystickThreshold(IntPtr This, float Threshold);
|
||||||
|
|
||||||
|
[DllImport("csfml-window", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
|
||||||
|
static extern IntPtr sfWindow_GetSystemHandle(IntPtr This);
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -279,7 +279,7 @@ public :
|
|||||||
void Bind() const;
|
void Bind() const;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Bind the shader (deactivate it)
|
/// \brief Unbind the shader (deactivate it)
|
||||||
///
|
///
|
||||||
/// This function is normally for internal use only, unless
|
/// This function is normally for internal use only, unless
|
||||||
/// you want to use the shader with a custom OpenGL rendering
|
/// you want to use the shader with a custom OpenGL rendering
|
||||||
|
@ -277,9 +277,9 @@ private :
|
|||||||
///
|
///
|
||||||
/// // Create a sprite
|
/// // Create a sprite
|
||||||
/// sf::Sprite sprite;
|
/// sf::Sprite sprite;
|
||||||
/// text.SetImage(image);
|
/// sprite.SetImage(image);
|
||||||
/// text.SetSubRect(sf::IntRect(10, 10, 50, 30));
|
/// sprite.SetSubRect(sf::IntRect(10, 10, 50, 30));
|
||||||
/// text.Resize(100, 60);
|
/// sprite.Resize(100, 60);
|
||||||
///
|
///
|
||||||
/// // Display it
|
/// // Display it
|
||||||
/// window.Draw(sprite); // window is a sf::RenderWindow
|
/// window.Draw(sprite); // window is a sf::RenderWindow
|
||||||
|
@ -144,13 +144,6 @@ public :
|
|||||||
/// \brief Reset the view to the given rectangle
|
/// \brief Reset the view to the given rectangle
|
||||||
///
|
///
|
||||||
/// Note that this function resets the rotation angle to 0.
|
/// Note that this function resets the rotation angle to 0.
|
||||||
/// It is a function provided for convenience, equivalent to the
|
|
||||||
/// following calls:
|
|
||||||
/// \code
|
|
||||||
/// view.SetCenter(rectangle.GetCenter());
|
|
||||||
/// view.SetSize(rectangle.GetSize());
|
|
||||||
/// view.SetRotation(0);
|
|
||||||
/// \endcode
|
|
||||||
///
|
///
|
||||||
/// \param rectangle Rectangle defining the zone to display
|
/// \param rectangle Rectangle defining the zone to display
|
||||||
///
|
///
|
||||||
|
@ -409,7 +409,7 @@ public :
|
|||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Specialization of the Utf template for UTF-16
|
/// \brief Specialization of the Utf template for UTF-32
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
template <>
|
template <>
|
||||||
|
@ -433,6 +433,20 @@ public :
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void SetJoystickThreshold(float threshold);
|
void SetJoystickThreshold(float threshold);
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
/// \brief Get the OS-specific handle of the window
|
||||||
|
///
|
||||||
|
/// The type of the returned handle is sf::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.
|
||||||
|
///
|
||||||
|
/// \return System handle of the window
|
||||||
|
///
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
WindowHandle GetSystemHandle() const;
|
||||||
|
|
||||||
private :
|
private :
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
@ -76,7 +76,7 @@ myOwnsWindow(false)
|
|||||||
myDisplay = static_cast<const WindowImplX11*>(owner)->GetDisplay();
|
myDisplay = static_cast<const WindowImplX11*>(owner)->GetDisplay();
|
||||||
|
|
||||||
// Get the owner window and its device context
|
// Get the owner window and its device context
|
||||||
myWindow = static_cast<Window>(owner->GetHandle());
|
myWindow = static_cast<Window>(owner->GetSystemHandle());
|
||||||
|
|
||||||
// Create the context
|
// Create the context
|
||||||
if (myWindow)
|
if (myWindow)
|
||||||
|
@ -277,7 +277,7 @@ WindowImplX11::~WindowImplX11()
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
WindowHandle WindowImplX11::GetHandle() const
|
WindowHandle WindowImplX11::GetSystemHandle() const
|
||||||
{
|
{
|
||||||
return myWindow;
|
return myWindow;
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ private :
|
|||||||
/// \return Handle of the window
|
/// \return Handle of the window
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
virtual WindowHandle GetHandle() const;
|
virtual WindowHandle GetSystemHandle() const;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Process incoming events from the operating system
|
/// \brief Process incoming events from the operating system
|
||||||
|
@ -71,7 +71,7 @@ myContext (NULL),
|
|||||||
myOwnsWindow (false)
|
myOwnsWindow (false)
|
||||||
{
|
{
|
||||||
// Get the owner window and its device context
|
// Get the owner window and its device context
|
||||||
myWindow = static_cast<HWND>(owner->GetHandle());
|
myWindow = static_cast<HWND>(owner->GetSystemHandle());
|
||||||
myDeviceContext = GetDC(myWindow);
|
myDeviceContext = GetDC(myWindow);
|
||||||
|
|
||||||
// Create the context
|
// Create the context
|
||||||
|
@ -200,7 +200,7 @@ WindowImplWin32::~WindowImplWin32()
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
WindowHandle WindowImplWin32::GetHandle() const
|
WindowHandle WindowImplWin32::GetSystemHandle() const
|
||||||
{
|
{
|
||||||
return myHandle;
|
return myHandle;
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ private :
|
|||||||
/// \return Handle of the window
|
/// \return Handle of the window
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
virtual WindowHandle GetHandle() const;
|
virtual WindowHandle GetSystemHandle() const;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Process incoming events from the operating system
|
/// \brief Process incoming events from the operating system
|
||||||
|
@ -384,6 +384,13 @@ void Window::SetJoystickThreshold(float threshold)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
WindowHandle Window::GetSystemHandle() const
|
||||||
|
{
|
||||||
|
return myWindow ? myWindow->GetSystemHandle() : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void Window::OnCreate()
|
void Window::OnCreate()
|
||||||
{
|
{
|
||||||
|
@ -130,7 +130,7 @@ public :
|
|||||||
/// \return Handle of the window
|
/// \return Handle of the window
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
virtual WindowHandle GetHandle() const = 0;
|
virtual WindowHandle GetSystemHandle() const = 0;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Show or hide the mouse cursor
|
/// \brief Show or hide the mouse cursor
|
||||||
|
Loading…
Reference in New Issue
Block a user