Commit 9b3a3a8ac978f6dcdf320eab2917155d5302ced0

sammy 2008-05-02T13:18:09

* Started documenting the FTLayout C bindings.

diff --git a/src/FTGL/FTLayout.h b/src/FTGL/FTLayout.h
index ac0cb32..e422543 100644
--- a/src/FTGL/FTLayout.h
+++ b/src/FTGL/FTLayout.h
@@ -78,38 +78,49 @@ class FTGL_EXPORT FTLayout
 
 FTGL_BEGIN_C_DECLS
 
+/**
+ * FTGLlayout is the interface for layout managers that render text.
+ */
 struct _FTGLlayout;
 typedef struct _FTGLlayout FTGLlayout;
 
-FTGL_EXPORT FTGLlayout *ftglCreateSimpleLayout(void);
-
-FTGL_EXPORT void ftglDestroyLayout(FTGLlayout*);
-
-FTGL_EXPORT void ftglLayoutBBox (FTGLlayout *, const char*, float []);
-
-FTGL_EXPORT void ftglLayoutRender      (FTGLlayout *, const char *);
-FTGL_EXPORT void ftglLayoutRenderMode  (FTGLlayout *, const char *, int);
-FTGL_EXPORT void ftglLayoutRenderSpace (FTGLlayout *, const char *, float);
-
-FTGL_EXPORT void      ftglLayoutSetFont (FTGLlayout *, FTGLfont*);
-FTGL_EXPORT FTGLfont* ftglLayoutGetFont (FTGLlayout *);
+/**
+ * Destroy an FTGL layout object.
+ *
+ * @param layout  An FTGLlayout* object.
+ */
+FTGL_EXPORT void ftglDestroyLayout(FTGLlayout* layout);
 
-FTGL_EXPORT void  ftglLayoutSetLineLength  (FTGLlayout *, const float);
-FTGL_EXPORT float ftglLayoutGetLineLength  (FTGLlayout *);
+/**
+ * Get the bounding box for a string.
+ *
+ * @param layout  An FTGLlayout* object.
+ * @param string  A char buffer
+ * @param bounds  An array of 6 float values where the bounding box's lower
+ *                left near and upper right far 3D coordinates will be stored.
+ */
+FTGL_EXPORT void ftglGetLayoutBBox(FTGLlayout *layout, const char* string,
+                                   float bounds[6]);
 
-#ifdef __cplusplus /*FIXME: Éric, this is WRONG */
-FTGL_EXPORT void                ftglLayoutSetAlignment   (FTGLlayout *, const FTGL::TextAlignment);
-FTGL_EXPORT FTGL::TextAlignment ftglLayoutGetAlignement  (FTGLlayout *);
-#else
-FTGL_EXPORT void                ftglLayoutSetAlignment   (FTGLlayout *, const int);
-FTGL_EXPORT int                 ftglLayoutGetAlignement  (FTGLlayout *);
-#endif
+/**
+ * Render a string of characters.
+ *
+ * @param layout  An FTGLlayout* object.
+ * @param string  Char string to be output.
+ * @param mode  Render mode to display.
+ */
+FTGL_EXPORT void ftglRenderLayout(FTGLlayout *layout, const char *string,
+                                  int mode);
 
-FTGL_EXPORT void  ftglLayoutSetLineSpacing (FTGLlayout *, const float);
-FTGL_EXPORT float ftglLayoutGetLineSpacing (FTGLlayout *);
+/**
+ * Query a layout for errors.
+ *
+ * @param layout  An FTGLlayout* object.
+ * @return  The current error code.
+ */
+FTGL_EXPORT FT_Error ftglGetLayoutError(FTGLlayout* layout);
 
 FTGL_END_C_DECLS
 
 #endif  /* __FTLayout__ */
 
-
diff --git a/src/FTGL/FTSimpleLayout.h b/src/FTGL/FTSimpleLayout.h
index 10ada2f..6d17313 100644
--- a/src/FTGL/FTSimpleLayout.h
+++ b/src/FTGL/FTSimpleLayout.h
@@ -133,5 +133,25 @@ class FTGL_EXPORT FTSimpleLayout : public FTLayout
 
 #endif //__cplusplus
 
+FTGL_BEGIN_C_DECLS
+
+FTGL_EXPORT FTGLlayout *ftglCreateSimpleLayout(void);
+
+FTGL_EXPORT void ftglRenderLayoutSpace(FTGLlayout *, const char *, float);
+
+FTGL_EXPORT void ftglSetLayoutFont(FTGLlayout *, FTGLfont*);
+FTGL_EXPORT FTGLfont *ftglGetLayoutFont(FTGLlayout *);
+
+FTGL_EXPORT void ftglSetLayoutLineLength(FTGLlayout *, const float);
+FTGL_EXPORT float ftglGetLayoutLineLength(FTGLlayout *);
+
+FTGL_EXPORT void ftglSetLayoutAlignment(FTGLlayout *, const int);
+FTGL_EXPORT int ftglGetLayoutAlignement(FTGLlayout *);
+
+FTGL_EXPORT void ftglSetLayoutLineSpacing(FTGLlayout *, const float);
+FTGL_EXPORT float ftglGetLayoutLineSpacing(FTGLlayout *);
+
+FTGL_END_C_DECLS
+
 #endif  /* __FTSimpleLayout__ */
 
diff --git a/src/FTLayout/FTLayoutGlue.cpp b/src/FTLayout/FTLayoutGlue.cpp
index 3772f36..76b07d7 100644
--- a/src/FTLayout/FTLayoutGlue.cpp
+++ b/src/FTLayout/FTLayoutGlue.cpp
@@ -87,23 +87,19 @@ void ftglDestroyLayout(FTGLlayout *l)
 }
 
 // virtual void BBox(const char* string, float& llx, float& lly, float& llz, float& urx, float& ury, float& urz)
-C_FUN(void, ftglLayoutBBox, (FTGLlayout *f, const char * s, float c[6]),
+C_FUN(void, ftgGetlLayoutBBox, (FTGLlayout *f, const char * s, float c[6]),
       return, BBox, (s, c[0], c[1], c[2], c[3], c[4], c[5]));
 
-// virtual void Render(const char* string);
-C_FUN(void, ftglLayoutRender, (FTGLlayout *f, const char *s),
-      return, Render, (s));
-
 // virtual void Render(const char* string, int renderMode);
-C_FUN(void, ftglLayoutRenderMode, (FTGLlayout *f, const char *s, int r),
+C_FUN(void, ftglRenderLayout, (FTGLlayout *f, const char *s, int r),
       return, Render, (s, r));
 
 // void RenderSpace(const char *string, const float ExtraSpace = 0.0)
-C_FUN(void, ftglLayoutRenderSpace, (FTGLlayout *f, const char *s, float e),
+C_FUN(void, ftglRenderLayoutSpace, (FTGLlayout *f, const char *s, float e),
       return, RenderSpace, (s, e));
 
 // void SetFont(FTFont *fontInit)
-void ftglLayoutSetFont(FTGLlayout *f, FTGLfont *font)
+void ftglSetLayoutFont(FTGLlayout *f, FTGLfont *font)
 {
     if(!f || !f->ptr)
     {
@@ -121,7 +117,7 @@ void ftglLayoutSetFont(FTGLlayout *f, FTGLfont *font)
 }
 
 // FTFont *GetFont()
-FTGLfont *ftglLayoutGetFont(FTGLlayout *f)
+FTGLfont *ftglGetLayoutFont(FTGLlayout *f)
 {
     if(!f || !f->ptr)
     {
@@ -132,28 +128,31 @@ FTGLfont *ftglLayoutGetFont(FTGLlayout *f)
 }
 
 // void SetLineLength(const float LineLength);
-C_FUN(void, ftglLayoutSetLineLength, (FTGLlayout *f, const float length),
+C_FUN(void, ftglSetLayoutLineLength, (FTGLlayout *f, const float length),
       return, SetLineLength, (length));
 
 // float GetLineLength() const
-C_FUN(float, ftglLayoutGetLineLength, (FTGLlayout *f),
+C_FUN(float, ftglGetLayoutLineLength, (FTGLlayout *f),
       return 0.0f, GetLineLength, ());
 
 // void SetAlignment(const TextAlignment Alignment)
-C_FUN(void, ftglLayoutSetAlignment, (FTGLlayout *f, FTGL::TextAlignment a),
+C_FUN(void, ftglSetLayoutAlignment, (FTGLlayout *f, const int a),
       return, SetAlignment, (a));
 
 // TextAlignment GetAlignment() const
-C_FUN(FTGL::TextAlignment, ftglLayoutGetAlignement, (FTGLlayout *f),
+C_FUN(int, ftglGetLayoutAlignement, (FTGLlayout *f),
       return FTGL::ALIGN_LEFT, GetAlignment, ());
 
 // void SetLineSpacing(const float LineSpacing)
-C_FUN(void, ftglLayoutSetLineSpacing, (FTGLlayout *f, const float l),
+C_FUN(void, ftglSetLayoutLineSpacing, (FTGLlayout *f, const float l),
       return, SetLineSpacing, (l));
 
 // float GetLineSpacing() const
-C_FUN(float, ftglLayoutGetLineSpacing, (FTGLlayout *f),
+C_FUN(float, ftglGetLayoutLineSpacing, (FTGLlayout *f),
       return 0.0f, GetLineSpacing, ());
 
+// FT_Error FTLayout::Error() const;
+C_FUN(FT_Error, ftglGetLayoutError, (FTGLlayout *f), return -1, Error, ());
+
 FTGL_END_C_DECLS