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:
LaurentGom 2010-07-15 21:13:55 +00:00
parent 028c4d5a96
commit ef8a2700fe
26 changed files with 104 additions and 21 deletions

View File

@ -287,6 +287,16 @@ CSFML_API float sfRenderWindow_GetFrameTime(const sfRenderWindow* renderWindow);
////////////////////////////////////////////////////////////
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
///

View File

@ -296,5 +296,15 @@ CSFML_API float sfWindow_GetFrameTime(const sfWindow* window);
////////////////////////////////////////////////////////////
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

View File

@ -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
////////////////////////////////////////////////////////////

View File

@ -223,6 +223,7 @@ EXPORTS
sfRenderWindow_SetFramerateLimit
sfRenderWindow_GetFrameTime
sfRenderWindow_SetJoystickThreshold
sfRenderWindow_GetSystemHandle
sfRenderWindow_DrawSprite
sfRenderWindow_DrawText
sfRenderWindow_DrawShape

View File

@ -223,6 +223,7 @@ EXPORTS
sfRenderWindow_SetFramerateLimit
sfRenderWindow_GetFrameTime
sfRenderWindow_SetJoystickThreshold
sfRenderWindow_GetSystemHandle
sfRenderWindow_DrawSprite
sfRenderWindow_DrawText
sfRenderWindow_DrawShape

View File

@ -313,6 +313,7 @@ float sfWindow_GetFrameTime(const sfWindow* window)
CSFML_CALL_RETURN(window, GetFrameTime(), 0.f)
}
////////////////////////////////////////////////////////////
/// Change the joystick threshold, ie. the value below which
/// no move event will be generated
@ -321,3 +322,12 @@ void sfWindow_SetJoystickThreshold(sfWindow* window, float 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);
}

View File

@ -33,6 +33,7 @@ EXPORTS
sfWindow_SetFramerateLimit
sfWindow_GetFrameTime
sfWindow_SetJoystickThreshold
sfWindow_GetSystemHandle
sfContext_Create
sfContext_Destroy
sfContext_SetActive

View File

@ -33,6 +33,7 @@ EXPORTS
sfWindow_SetFramerateLimit
sfWindow_GetFrameTime
sfWindow_SetJoystickThreshold
sfWindow_GetSystemHandle
sfContext_Create
sfContext_Destroy
sfContext_SetActive

View File

@ -27,11 +27,11 @@
/// return EXIT_FAILURE;
/// sf::Sprite sprite(image);
///
/// // Create a graphical string to display
/// // Create a graphical text to display
/// sf::Font font;
/// if (!font.LoadFromFile("arial.ttf"))
/// return EXIT_FAILURE;
/// sf::String text("Hello SFML", font, 50);
/// sf::Text text("Hello SFML", font, 50);
///
/// // Load a music to play
/// sf::Music music;

Binary file not shown.

Binary file not shown.

View File

@ -294,6 +294,16 @@ namespace SFML
sfRenderWindow_SetJoystickThreshold(This, threshold);
}
////////////////////////////////////////////////////////////
/// <summary>
/// OS-specific handle of the window
/// </summary>
////////////////////////////////////////////////////////////
public override IntPtr SystemHandle
{
get {return sfRenderWindow_GetSystemHandle(This);}
}
////////////////////////////////////////////////////////////
/// <summary>
/// Default view of the window
@ -592,6 +602,9 @@ namespace SFML
[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);
[DllImport("csfml-graphics", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern IntPtr sfRenderWindow_GetSystemHandle(IntPtr This);
#endregion
}
}

View File

@ -341,6 +341,16 @@ namespace SFML
sfWindow_SetJoystickThreshold(This, threshold);
}
////////////////////////////////////////////////////////////
/// <summary>
/// OS-specific handle of the window
/// </summary>
////////////////////////////////////////////////////////////
public virtual IntPtr SystemHandle
{
get {return sfWindow_GetSystemHandle(This);}
}
////////////////////////////////////////////////////////////
/// <summary>
/// Wait for a new event and dispatch it to the corresponding
@ -642,6 +652,9 @@ namespace SFML
[DllImport("csfml-window", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfWindow_SetJoystickThreshold(IntPtr This, float Threshold);
[DllImport("csfml-window", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern IntPtr sfWindow_GetSystemHandle(IntPtr This);
#endregion
}
}

View File

@ -279,7 +279,7 @@ public :
void Bind() const;
////////////////////////////////////////////////////////////
/// \brief Bind the shader (deactivate it)
/// \brief Unbind the shader (deactivate it)
///
/// This function is normally for internal use only, unless
/// you want to use the shader with a custom OpenGL rendering

View File

@ -277,9 +277,9 @@ private :
///
/// // Create a sprite
/// sf::Sprite sprite;
/// text.SetImage(image);
/// text.SetSubRect(sf::IntRect(10, 10, 50, 30));
/// text.Resize(100, 60);
/// sprite.SetImage(image);
/// sprite.SetSubRect(sf::IntRect(10, 10, 50, 30));
/// sprite.Resize(100, 60);
///
/// // Display it
/// window.Draw(sprite); // window is a sf::RenderWindow

View File

@ -144,13 +144,6 @@ public :
/// \brief Reset the view to the given rectangle
///
/// 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
///

View File

@ -409,7 +409,7 @@ public :
};
////////////////////////////////////////////////////////////
/// \brief Specialization of the Utf template for UTF-16
/// \brief Specialization of the Utf template for UTF-32
///
////////////////////////////////////////////////////////////
template <>

View File

@ -433,6 +433,20 @@ public :
////////////////////////////////////////////////////////////
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 :
////////////////////////////////////////////////////////////

View File

@ -76,7 +76,7 @@ myOwnsWindow(false)
myDisplay = static_cast<const WindowImplX11*>(owner)->GetDisplay();
// Get the owner window and its device context
myWindow = static_cast<Window>(owner->GetHandle());
myWindow = static_cast<Window>(owner->GetSystemHandle());
// Create the context
if (myWindow)

View File

@ -277,7 +277,7 @@ WindowImplX11::~WindowImplX11()
////////////////////////////////////////////////////////////
WindowHandle WindowImplX11::GetHandle() const
WindowHandle WindowImplX11::GetSystemHandle() const
{
return myWindow;
}

View File

@ -89,7 +89,7 @@ private :
/// \return Handle of the window
///
////////////////////////////////////////////////////////////
virtual WindowHandle GetHandle() const;
virtual WindowHandle GetSystemHandle() const;
////////////////////////////////////////////////////////////
/// \brief Process incoming events from the operating system

View File

@ -71,7 +71,7 @@ myContext (NULL),
myOwnsWindow (false)
{
// Get the owner window and its device context
myWindow = static_cast<HWND>(owner->GetHandle());
myWindow = static_cast<HWND>(owner->GetSystemHandle());
myDeviceContext = GetDC(myWindow);
// Create the context

View File

@ -200,7 +200,7 @@ WindowImplWin32::~WindowImplWin32()
////////////////////////////////////////////////////////////
WindowHandle WindowImplWin32::GetHandle() const
WindowHandle WindowImplWin32::GetSystemHandle() const
{
return myHandle;
}

View File

@ -78,7 +78,7 @@ private :
/// \return Handle of the window
///
////////////////////////////////////////////////////////////
virtual WindowHandle GetHandle() const;
virtual WindowHandle GetSystemHandle() const;
////////////////////////////////////////////////////////////
/// \brief Process incoming events from the operating system

View File

@ -384,6 +384,13 @@ void Window::SetJoystickThreshold(float threshold)
}
////////////////////////////////////////////////////////////
WindowHandle Window::GetSystemHandle() const
{
return myWindow ? myWindow->GetSystemHandle() : 0;
}
////////////////////////////////////////////////////////////
void Window::OnCreate()
{

View File

@ -130,7 +130,7 @@ public :
/// \return Handle of the window
///
////////////////////////////////////////////////////////////
virtual WindowHandle GetHandle() const = 0;
virtual WindowHandle GetSystemHandle() const = 0;
////////////////////////////////////////////////////////////
/// \brief Show or hide the mouse cursor