Added missing methods in View and Font.

git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/trunk@1118 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
remi-k 2009-05-31 19:03:47 +00:00
parent a28a3b82d3
commit cd4e3ea2ae
2 changed files with 26 additions and 0 deletions

View File

@ -24,6 +24,7 @@
#include "Font.hpp"
#include "Glyph.hpp"
#include "Image.hpp"
#include "compat.hpp"
@ -180,6 +181,15 @@ PySfFont_GetGlyph(PySfFont* self, PyObject *args)
return (PyObject *)Glyph;
}
static PyObject *
PySfFont_GetImage(PySfFont* self)
{
PySfImage *Image;
Image = GetNewPySfImage();
Image->obj = new sf::Image(self->obj->GetImage());
return (PyObject *)Image;
}
static PyMethodDef PySfFont_methods[] = {
{"LoadFromFile", (PyCFunction)PySfFont_LoadFromFile, METH_VARARGS | METH_KEYWORDS, "LoadFromFile(Filename, CharSize, UnicodeCharset) or LoadFromFile(Filename, CharSize, Charset, Encoding='utf8')\n\
Load the font from a file. Returns True if loading was successful.\n\
@ -193,6 +203,8 @@ Load the font from a file in memory. Returns True if loading was successful.\n\
Charset : Characters set to generate (by default, contains the ISO-8859-1 printable characters)"},
{"GetDefaultFont", (PyCFunction)PySfFont_GetDefaultFont, METH_NOARGS | METH_STATIC, "GetDefaultFont()\n\
Get the SFML default built-in font (Arial)."},
{"GetImage", (PyCFunction)PySfFont_GetImage, METH_NOARGS, "GetImage()\n\
Get the image containing the rendered characters (glyphs)."},
{"GetCharacterSize", (PyCFunction)PySfFont_GetCharacterSize, METH_NOARGS, "GetCharacterSize()\n\
Get the base size of characters in the font; All glyphs dimensions are based on this value"},
{"GetGlyph", (PyCFunction)PySfFont_GetGlyph, METH_O, "GetGlyph(CodePoint)\n\

View File

@ -85,6 +85,19 @@ PySfView_GetRect(PySfView* self)
return (PyObject *)Rect;
}
static PyObject *
PySfView_SetFromRect(PySfView* self, PyObject *args)
{
PySfFloatRect *Rect = (PySfFloatRect *)args;
if (!PyObject_TypeCheck(Rect, &PySfFloatRectType))
{
PyErr_SetString(PyExc_TypeError, "View.SetFromRect() Argument is not a sf.FloatRect instance");
return NULL;
}
self->obj->SetFromRect(*(Rect->obj));
Py_RETURN_NONE;
}
static PyObject *
PySfView_Move(PySfView* self, PyObject *args)
{
@ -129,6 +142,7 @@ static PyMethodDef PySfView_methods[] = {
{"Move", (PyCFunction)PySfView_Move, METH_VARARGS, "Move(OffsetX, OffsetY)\nMove the view.\n\
OffsetX : Offset to move the view, on X axis\n\
OffsetY : Offset to move the view, on Y axis"},
{"SetFromRect", (PyCFunction)PySfView_SetFromRect, METH_O, "SetFromRect(ViewRect)\nRebuild the view from a rectangle.\n ViewRect : Rectangle defining the position and size of the view."},
{"SetCenter", (PyCFunction)PySfView_SetCenter, METH_VARARGS, "SetCenter(X, Y)\nChange the center of the view."},
{"SetHalfSize", (PyCFunction)PySfView_SetHalfSize, METH_VARARGS, "SetHalfSize(HalfWidth, HalfHeight)\nChange the half-size of the view."},
{"Zoom", (PyCFunction)PySfView_Zoom, METH_O, "Zoom(Factor)\nResize the view rectangle to simulate a zoom / unzoom effect."},