mirror of
https://github.com/SFML/SFML.git
synced 2024-11-24 20:31:05 +08:00
Added the window constructor from an existing control
git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/trunk@1070 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
parent
e2cb404ab2
commit
37d3bc2196
@ -244,11 +244,13 @@ PyTypeObject PySfRenderWindowType = {
|
||||
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
|
||||
"Simple wrapper for sf.Window that allows easy 2D rendering.\n\
|
||||
Default constructor : sf.RenderWindow()\n\
|
||||
Other constructor : sf.RenderWindow(Mode, Title, Style::Resize|Style::Close, Params = WindowSettings())\n\
|
||||
Parameters:\n\
|
||||
Construct a new window : sf.RenderWindow(Mode, Title, Style::Resize|Style::Close, Params = WindowSettings())\n\
|
||||
Mode : Video mode to use\n\
|
||||
Title : Title of the window\n\
|
||||
WindowStyle : Window style (Resize | Close by default)\n\
|
||||
Params : Creation parameters (see default constructor for default values)\n\
|
||||
Construct the window from an existing control : sf.RenderWindow(Handle, Params)\n\
|
||||
Handle : handle of the control (long integer)\n\
|
||||
Params : Creation parameters (see default constructor for default values)", /* tp_doc */
|
||||
0, /* tp_traverse */
|
||||
0, /* tp_clear */
|
||||
|
@ -48,11 +48,29 @@ PySfWindow_dealloc(PySfWindow* self)
|
||||
|
||||
static PyObject *
|
||||
PySfWindow_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
||||
{
|
||||
{
|
||||
long Handle;
|
||||
PySfWindowSettings *Params=NULL;
|
||||
PySfWindow *self;
|
||||
self = (PySfWindow *)type->tp_alloc(type, 0);
|
||||
if (self != NULL)
|
||||
self->obj = new sf::Window();
|
||||
if (self != NULL)
|
||||
{
|
||||
if (PyArg_ParseTuple(args, "l|O!:Window.__new__", &Handle, &PySfWindowSettingsType, &Params))
|
||||
{
|
||||
if (Params)
|
||||
{
|
||||
PySfWindowSettingsUpdate(Params);
|
||||
self->obj = new sf::Window((sf::WindowHandle)Handle, *(Params->obj));
|
||||
}
|
||||
else
|
||||
self->obj = new sf::Window((sf::WindowHandle)Handle);
|
||||
}
|
||||
else
|
||||
{
|
||||
PyErr_Clear();
|
||||
self->obj = new sf::Window();
|
||||
}
|
||||
}
|
||||
return (PyObject *)self;
|
||||
}
|
||||
|
||||
@ -99,7 +117,6 @@ PySfWindow_GetEvent(PySfWindow *self, PyObject *args)
|
||||
}
|
||||
|
||||
|
||||
|
||||
PyObject*
|
||||
PySfWindow_Create(PySfWindow* self, PyObject *args, PyObject *kwds)
|
||||
{
|
||||
@ -109,7 +126,7 @@ PySfWindow_Create(PySfWindow* self, PyObject *args, PyObject *kwds)
|
||||
unsigned long WindowStyle = sf::Style::Resize | sf::Style::Close;
|
||||
PySfWindowSettings *Params=NULL;
|
||||
|
||||
const char *kwlist[] = {"VideoMode", "Title", "WindowStyle", "Params", NULL};
|
||||
const char *kwlist[] = {"VideoMode", "Title", "WindowStyle", "Params", NULL};
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!s|IO!:Window.Create", (char **)kwlist, &PySfVideoModeType, &VideoModeTmp, &Title, &WindowStyle, &PySfWindowSettingsType, &Params))
|
||||
return NULL;
|
||||
@ -131,9 +148,17 @@ PySfWindow_Create(PySfWindow* self, PyObject *args, PyObject *kwds)
|
||||
static int
|
||||
PySfWindow_init(PySfWindow *self, PyObject *args, PyObject *kwds)
|
||||
{
|
||||
if (args != NULL)
|
||||
long Handle;
|
||||
PySfWindowSettings *Params;
|
||||
|
||||
if (args != NULL)
|
||||
{
|
||||
if (PyArg_ParseTuple(args, "l|O!:Window.__new__", &Handle, &PySfWindowSettingsType, &Params))
|
||||
return 0;
|
||||
PyErr_Clear();
|
||||
if (PySfWindow_Create(self, args, kwds) == NULL)
|
||||
return -1;
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -344,7 +369,9 @@ Construct a new window : sf.Window(Mode, Title, sf.Style.Resize | sf.Style.Close
|
||||
Title : Title of the window\n\
|
||||
WindowStyle : Window style (Resize | Close by default)\n\
|
||||
Params : Creation parameters (see default constructor for default values)\n\
|
||||
", /* tp_doc */
|
||||
Construct the window from an existing control : sf.Window(Handle, Params)\n\
|
||||
Handle : Platform-specific handle of the control\n\
|
||||
Params : Creation parameters (see default constructor for default values)", /* tp_doc */
|
||||
0, /* tp_traverse */
|
||||
0, /* tp_clear */
|
||||
0, /* tp_richcompare */
|
||||
|
Loading…
Reference in New Issue
Block a user