From cd4e3ea2ae8cfc265936602ca953c82d4f27133e Mon Sep 17 00:00:00 2001
From: remi-k <remi-k@4e206d99-4929-0410-ac5d-dfc041789085>
Date: Sun, 31 May 2009 19:03:47 +0000
Subject: [PATCH] Added missing methods in View and Font.

git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/trunk@1118 4e206d99-4929-0410-ac5d-dfc041789085
---
 python/src/Font.cpp | 12 ++++++++++++
 python/src/View.cpp | 14 ++++++++++++++
 2 files changed, 26 insertions(+)

diff --git a/python/src/Font.cpp b/python/src/Font.cpp
index b7beeafd..4b72cd66 100644
--- a/python/src/Font.cpp
+++ b/python/src/Font.cpp
@@ -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\
diff --git a/python/src/View.cpp b/python/src/View.cpp
index 468f2ad8..39f045c2 100644
--- a/python/src/View.cpp
+++ b/python/src/View.cpp
@@ -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."},