~ubuntu-branches/ubuntu/trusty/psychtoolbox-3/trusty-proposed

« back to all changes in this revision

Viewing changes to PsychSourceGL/Cohorts/FTGLTextRenderer/FTGL/FTLayout.h

  • Committer: Package Import Robot
  • Author(s): Yaroslav Halchenko
  • Date: 2013-11-19 23:34:50 UTC
  • mfrom: (3.1.4 experimental)
  • Revision ID: package-import@ubuntu.com-20131119233450-f7nf92vb8qavjmk8
Tags: 3.0.11.20131017.dfsg1-3
Upload to unsable since fresh glew has arrived to sid!

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * FTGL - OpenGL font library
 
3
 *
 
4
 * Copyright (c) 2001-2004 Henry Maddocks <ftgl@opengl.geek.nz>
 
5
 * Copyright (c) 2008 Sam Hocevar <sam@zoy.org>
 
6
 * Copyright (c) 2008 Sean Morrison <learner@brlcad.org>
 
7
 *
 
8
 * Permission is hereby granted, free of charge, to any person obtaining
 
9
 * a copy of this software and associated documentation files (the
 
10
 * "Software"), to deal in the Software without restriction, including
 
11
 * without limitation the rights to use, copy, modify, merge, publish,
 
12
 * distribute, sublicense, and/or sell copies of the Software, and to
 
13
 * permit persons to whom the Software is furnished to do so, subject to
 
14
 * the following conditions:
 
15
 *
 
16
 * The above copyright notice and this permission notice shall be
 
17
 * included in all copies or substantial portions of the Software.
 
18
 *
 
19
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 
20
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 
21
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 
22
 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 
23
 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 
24
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 
25
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
26
 */
 
27
 
 
28
#ifndef __ftgl__
 
29
#   warning This header is deprecated. Please use <FTGL/ftgl.h> from now.
 
30
#   include <FTGL/ftgl.h>
 
31
#endif
 
32
 
 
33
#ifndef __FTLayout__
 
34
#define __FTLayout__
 
35
 
 
36
#ifdef __cplusplus
 
37
 
 
38
 
 
39
class FTLayoutImpl;
 
40
 
 
41
/**
 
42
 * FTLayout is the interface for layout managers that render text.
 
43
 *
 
44
 * Specific layout manager classes are derived from this class. This class
 
45
 * is abstract and deriving classes must implement the protected
 
46
 * <code>Render</code> methods to render formatted text and
 
47
 * <code>BBox</code> methods to determine the bounding box of output text.
 
48
 *
 
49
 * @see     FTFont
 
50
 * @see     FTBBox
 
51
 */
 
52
class FTGL_EXPORT FTLayout
 
53
{
 
54
    protected:
 
55
        FTLayout();
 
56
 
 
57
    private:
 
58
        /**
 
59
         * Internal FTGL FTLayout constructor. For private use only.
 
60
         *
 
61
         * @param pImpl  Internal implementation object. Will be destroyed
 
62
         *               upon FTLayout deletion.
 
63
         */
 
64
        FTLayout(FTLayoutImpl *pImpl);
 
65
 
 
66
        /* Allow our internal subclasses to access the private constructor */
 
67
        friend class FTSimpleLayout;
 
68
 
 
69
    public:
 
70
        /**
 
71
         * Destructor
 
72
         */
 
73
        virtual ~FTLayout();
 
74
 
 
75
        /**
 
76
         * Get the bounding box for a formatted string.
 
77
         *
 
78
         * @param string  A char string.
 
79
         * @param len  The length of the string. If < 0 then all characters
 
80
         *             will be checked until a null character is encountered
 
81
         *             (optional).
 
82
         * @param position  The pen position of the first character (optional).
 
83
         * @return  The corresponding bounding box.
 
84
         */
 
85
        virtual FTBBox BBox(const char* string, const int len = -1,
 
86
                            FTPoint position = FTPoint()) = 0;
 
87
 
 
88
        /**
 
89
         * Get the bounding box for a formatted string.
 
90
         *
 
91
         * @param string  A wchar_t string.
 
92
         * @param len  The length of the string. If < 0 then all characters
 
93
         *             will be checked until a null character is encountered
 
94
         *             (optional).
 
95
         * @param position  The pen position of the first character (optional).
 
96
         * @return  The corresponding bounding box.
 
97
         */
 
98
        virtual FTBBox BBox(const wchar_t* string, const int len = -1,
 
99
                            FTPoint position = FTPoint()) = 0;
 
100
 
 
101
        /**
 
102
         * Render a string of characters.
 
103
         *
 
104
         * @param string    'C' style string to be output.
 
105
         * @param len  The length of the string. If < 0 then all characters
 
106
         *             will be displayed until a null character is encountered
 
107
         *             (optional).
 
108
         * @param position  The pen position of the first character (optional).
 
109
         * @param renderMode  Render mode to display (optional)
 
110
         */
 
111
        virtual void Render(const char *string, const int len = -1,
 
112
                            FTPoint position = FTPoint(),
 
113
                            int renderMode = FTGL::RENDER_ALL) = 0;
 
114
 
 
115
        /**
 
116
         * Render a string of characters.
 
117
         *
 
118
         * @param string    wchar_t string to be output.
 
119
         * @param len  The length of the string. If < 0 then all characters
 
120
         *             will be displayed until a null character is encountered
 
121
         *             (optional).
 
122
         * @param position  The pen position of the first character (optional).
 
123
         * @param renderMode  Render mode to display (optional)
 
124
         */
 
125
        virtual void Render(const wchar_t *string, const int len = -1,
 
126
                            FTPoint position = FTPoint(),
 
127
                            int renderMode = FTGL::RENDER_ALL) = 0;
 
128
 
 
129
        /**
 
130
         * Queries the Layout for errors.
 
131
         *
 
132
         * @return  The current error code.
 
133
         */
 
134
        virtual FT_Error Error() const;
 
135
 
 
136
    private:
 
137
        /**
 
138
         * Internal FTGL FTLayout implementation object. For private use only.
 
139
         */
 
140
        FTLayoutImpl *impl;
 
141
};
 
142
 
 
143
#endif //__cplusplus
 
144
 
 
145
FTGL_BEGIN_C_DECLS
 
146
 
 
147
/**
 
148
 * FTGLlayout is the interface for layout managers that render text.
 
149
 */
 
150
struct _FTGLlayout;
 
151
typedef struct _FTGLlayout FTGLlayout;
 
152
 
 
153
/**
 
154
 * Destroy an FTGL layout object.
 
155
 *
 
156
 * @param layout  An FTGLlayout* object.
 
157
 */
 
158
FTGL_EXPORT void ftglDestroyLayout(FTGLlayout* layout);
 
159
 
 
160
/**
 
161
 * Get the bounding box for a string.
 
162
 *
 
163
 * @param layout  An FTGLlayout* object.
 
164
 * @param string  A char buffer
 
165
 * @param bounds  An array of 6 float values where the bounding box's lower
 
166
 *                left near and upper right far 3D coordinates will be stored.
 
167
 */
 
168
FTGL_EXPORT void ftglGetLayoutBBox(FTGLlayout *layout, const char* string,
 
169
                                   float bounds[6]);
 
170
 
 
171
/**
 
172
 * Render a string of characters.
 
173
 *
 
174
 * @param layout  An FTGLlayout* object.
 
175
 * @param string  Char string to be output.
 
176
 * @param mode  Render mode to display.
 
177
 */
 
178
FTGL_EXPORT void ftglRenderLayout(FTGLlayout *layout, const char *string,
 
179
                                  int mode);
 
180
 
 
181
/**
 
182
 * Query a layout for errors.
 
183
 *
 
184
 * @param layout  An FTGLlayout* object.
 
185
 * @return  The current error code.
 
186
 */
 
187
FTGL_EXPORT FT_Error ftglGetLayoutError(FTGLlayout* layout);
 
188
 
 
189
FTGL_END_C_DECLS
 
190
 
 
191
#endif  /* __FTLayout__ */
 
192