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

« back to all changes in this revision

Viewing changes to PsychSourceGL/Cohorts/FTGLTextRenderer/FTGL/FTSimpleLayout.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 __FTSimpleLayout__
 
34
#define __FTSimpleLayout__
 
35
 
 
36
#ifdef __cplusplus
 
37
 
 
38
 
 
39
class FTFont;
 
40
 
 
41
/**
 
42
 * FTSimpleLayout is a specialisation of FTLayout for simple text boxes.
 
43
 *
 
44
 * This class has basic support for text wrapping, left, right and centered
 
45
 * alignment, and text justification.
 
46
 *
 
47
 * @see     FTLayout
 
48
 */
 
49
class FTGL_EXPORT FTSimpleLayout : public FTLayout
 
50
{
 
51
    public:
 
52
        /**
 
53
         * Initializes line spacing to 1.0, alignment to
 
54
         * ALIGN_LEFT and wrap to 100.0
 
55
         */
 
56
        FTSimpleLayout();
 
57
 
 
58
        /**
 
59
         * Destructor
 
60
         */
 
61
        ~FTSimpleLayout();
 
62
 
 
63
        /**
 
64
         * Get the bounding box for a formatted string.
 
65
         *
 
66
         * @param string  A char string.
 
67
         * @param len  The length of the string. If < 0 then all characters
 
68
         *             will be checked until a null character is encountered
 
69
         *             (optional).
 
70
         * @param position  The pen position of the first character (optional).
 
71
         * @return  The corresponding bounding box.
 
72
         */
 
73
        virtual FTBBox BBox(const char* string, const int len = -1,
 
74
                            FTPoint position = FTPoint());
 
75
 
 
76
        /**
 
77
         * Get the bounding box for a formatted string.
 
78
         *
 
79
         * @param string  A wchar_t string.
 
80
         * @param len  The length of the string. If < 0 then all characters
 
81
         *             will be checked until a null character is encountered
 
82
         *             (optional).
 
83
         * @param position  The pen position of the first character (optional).
 
84
         * @return  The corresponding bounding box.
 
85
         */
 
86
        virtual FTBBox BBox(const wchar_t* string, const int len = -1,
 
87
                            FTPoint position = FTPoint());
 
88
 
 
89
        /**
 
90
         * Render a string of characters.
 
91
         *
 
92
         * @param string    'C' style string to be output.
 
93
         * @param len  The length of the string. If < 0 then all characters
 
94
         *             will be displayed until a null character is encountered
 
95
         *             (optional).
 
96
         * @param position  The pen position of the first character (optional).
 
97
         * @param renderMode  Render mode to display (optional)
 
98
         */
 
99
        virtual void Render(const char *string, const int len = -1,
 
100
                            FTPoint position = FTPoint(),
 
101
                            int renderMode = FTGL::RENDER_ALL);
 
102
 
 
103
        /**
 
104
         * Render a string of characters.
 
105
         *
 
106
         * @param string    wchar_t string to be output.
 
107
         * @param len  The length of the string. If < 0 then all characters
 
108
         *             will be displayed until a null character is encountered
 
109
         *             (optional).
 
110
         * @param position  The pen position of the first character (optional).
 
111
         * @param renderMode  Render mode to display (optional)
 
112
         */
 
113
        virtual void Render(const wchar_t *string, const int len = -1,
 
114
                            FTPoint position = FTPoint(),
 
115
                            int renderMode = FTGL::RENDER_ALL);
 
116
 
 
117
        /**
 
118
         * Set the font to use for rendering the text.
 
119
         *
 
120
         * @param fontInit A pointer to the new font.  The font is
 
121
         *                 referenced by this but will not be
 
122
         *                 disposed of when this is deleted.
 
123
         */
 
124
        void SetFont(FTFont *fontInit);
 
125
 
 
126
        /**
 
127
         * @return The current font.
 
128
         */
 
129
        FTFont *GetFont();
 
130
 
 
131
        /**
 
132
         * The maximum line length for formatting text.
 
133
         *
 
134
         * @param LineLength The new line length.
 
135
         */
 
136
        void SetLineLength(const float LineLength);
 
137
 
 
138
        /**
 
139
         * @return The current line length.
 
140
         */
 
141
        float GetLineLength() const;
 
142
 
 
143
        /**
 
144
         * The text alignment mode used to distribute
 
145
         * space within a line or rendered text.
 
146
         *
 
147
         * @param Alignment The new alignment mode.
 
148
         */
 
149
        void SetAlignment(const FTGL::TextAlignment Alignment);
 
150
 
 
151
        /**
 
152
         * @return The text alignment mode.
 
153
         */
 
154
        FTGL::TextAlignment GetAlignment() const;
 
155
 
 
156
        /**
 
157
         * Sets the line height.
 
158
         *
 
159
         * @param LineSpacing The height of each line of text expressed as
 
160
         *                    a percentage of the current fonts line height.
 
161
         */
 
162
        void SetLineSpacing(const float LineSpacing);
 
163
 
 
164
        /**
 
165
         * @return The line spacing.
 
166
         */
 
167
        float GetLineSpacing() const;
 
168
};
 
169
 
 
170
#endif //__cplusplus
 
171
 
 
172
FTGL_BEGIN_C_DECLS
 
173
 
 
174
FTGL_EXPORT FTGLlayout *ftglCreateSimpleLayout(void);
 
175
 
 
176
FTGL_EXPORT void ftglSetLayoutFont(FTGLlayout *, FTGLfont*);
 
177
FTGL_EXPORT FTGLfont *ftglGetLayoutFont(FTGLlayout *);
 
178
 
 
179
FTGL_EXPORT void ftglSetLayoutLineLength(FTGLlayout *, const float);
 
180
FTGL_EXPORT float ftglGetLayoutLineLength(FTGLlayout *);
 
181
 
 
182
FTGL_EXPORT void ftglSetLayoutAlignment(FTGLlayout *, const int);
 
183
FTGL_EXPORT int ftglGetLayoutAlignement(FTGLlayout *);
 
184
 
 
185
FTGL_EXPORT void ftglSetLayoutLineSpacing(FTGLlayout *, const float);
 
186
FTGL_EXPORT float ftglGetLayoutLineSpacing(FTGLlayout *);
 
187
 
 
188
FTGL_END_C_DECLS
 
189
 
 
190
#endif  /* __FTSimpleLayout__ */
 
191