2007-04-12 14:49:41 +02:00
|
|
|
// Copyright (c) 2007, Rodrigo Braz Monteiro
|
|
|
|
// All rights reserved.
|
|
|
|
//
|
|
|
|
// Redistribution and use in source and binary forms, with or without
|
|
|
|
// modification, are permitted provided that the following conditions are met:
|
|
|
|
//
|
|
|
|
// * Redistributions of source code must retain the above copyright notice,
|
|
|
|
// this list of conditions and the following disclaimer.
|
|
|
|
// * Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
// this list of conditions and the following disclaimer in the documentation
|
|
|
|
// and/or other materials provided with the distribution.
|
|
|
|
// * Neither the name of the Aegisub Group nor the names of its contributors
|
|
|
|
// may be used to endorse or promote products derived from this software
|
|
|
|
// without specific prior written permission.
|
|
|
|
//
|
|
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
|
|
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
// POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
//
|
2009-07-29 07:43:02 +02:00
|
|
|
// Aegisub Project http://www.aegisub.org/
|
|
|
|
|
|
|
|
/// @file gl_text.h
|
|
|
|
/// @see gl_text.cpp
|
|
|
|
/// @ingroup video_output
|
|
|
|
///
|
2007-04-12 14:49:41 +02:00
|
|
|
|
2012-09-25 01:47:38 +02:00
|
|
|
#include <boost/container/map.hpp>
|
|
|
|
|
2012-09-25 01:35:27 +02:00
|
|
|
#include <memory>
|
2013-01-04 16:01:50 +01:00
|
|
|
#include <string>
|
2009-09-11 04:36:34 +02:00
|
|
|
#include <vector>
|
|
|
|
|
2007-09-12 01:22:26 +02:00
|
|
|
#include <wx/font.h>
|
2009-09-11 04:36:34 +02:00
|
|
|
|
2012-12-11 18:44:28 +01:00
|
|
|
namespace {
|
2010-07-23 06:15:36 +02:00
|
|
|
struct OpenGLTextGlyph;
|
2010-06-02 09:22:53 +02:00
|
|
|
class OpenGLTextTexture;
|
2012-12-11 18:44:28 +01:00
|
|
|
}
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
2013-01-04 16:01:50 +01:00
|
|
|
namespace agi { struct Color; }
|
|
|
|
|
|
|
|
typedef boost::container::map<int, OpenGLTextGlyph> glyphMap;
|
2007-04-12 14:49:41 +02:00
|
|
|
|
|
|
|
class OpenGLText {
|
2013-12-12 01:29:48 +01:00
|
|
|
float r = 1.f, g = 1.f, b = 1.f, a = 1.f;
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
2013-12-12 01:29:48 +01:00
|
|
|
int fontSize = 0;
|
|
|
|
bool fontBold = false;
|
|
|
|
bool fontItalics = false;
|
2013-01-04 16:01:50 +01:00
|
|
|
std::string fontFace;
|
2007-04-13 05:52:25 +02:00
|
|
|
wxFont font;
|
|
|
|
|
2007-04-12 14:49:41 +02:00
|
|
|
glyphMap glyphs;
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
2012-12-11 18:44:28 +01:00
|
|
|
std::vector<OpenGLTextTexture> textures;
|
2007-04-12 14:49:41 +02:00
|
|
|
|
2013-12-12 01:29:48 +01:00
|
|
|
OpenGLText(OpenGLText const&) = delete;
|
|
|
|
OpenGLText& operator=(OpenGLText const&) = delete;
|
2007-04-12 14:49:41 +02:00
|
|
|
|
2010-06-02 09:22:53 +02:00
|
|
|
/// @brief Get the glyph for the character chr, creating it if necessary
|
|
|
|
/// @param chr Character to get the glyph of
|
|
|
|
/// @return The appropriate OpenGLTextGlyph
|
|
|
|
OpenGLTextGlyph const& GetGlyph(int chr);
|
|
|
|
/// @brief Create a new glyph
|
|
|
|
OpenGLTextGlyph const& CreateGlyph(int chr);
|
2007-04-12 14:49:41 +02:00
|
|
|
|
2013-01-04 16:01:50 +01:00
|
|
|
void DrawString(const std::string &text,int x,int y);
|
2007-04-12 14:49:41 +02:00
|
|
|
public:
|
2010-06-02 09:22:53 +02:00
|
|
|
/// @brief Get the currently active font
|
2010-07-23 06:15:36 +02:00
|
|
|
wxFont GetFont() const { return font; }
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
2010-06-02 09:22:53 +02:00
|
|
|
/// @brief Set the currently active font
|
|
|
|
/// @param face Name of the desired font
|
|
|
|
/// @param size Size in points of the desired font
|
|
|
|
/// @param bold Should the font be bold?
|
|
|
|
/// @param italics Should the font be italic?
|
2013-01-04 16:01:50 +01:00
|
|
|
void SetFont(std::string const& face, int size, bool bold, bool italics);
|
2010-06-02 09:22:53 +02:00
|
|
|
/// @brief Set the text color
|
|
|
|
/// @param col Color
|
2013-01-04 16:01:50 +01:00
|
|
|
void SetColour(agi::Color col);
|
2010-07-23 06:15:36 +02:00
|
|
|
/// @brief Print a string on screen
|
2010-06-02 09:22:53 +02:00
|
|
|
/// @param text String to print
|
|
|
|
/// @param x x coordinate
|
|
|
|
/// @param y y coordinate
|
2013-01-04 16:01:50 +01:00
|
|
|
void Print(const std::string &text,int x,int y);
|
2010-06-02 09:22:53 +02:00
|
|
|
/// @brief Get the extents of a string printed with the current font in pixels
|
2010-07-23 06:15:36 +02:00
|
|
|
/// @param text String to get extends of
|
|
|
|
/// @param[out] w Width
|
|
|
|
/// @param[out] h Height
|
2013-01-04 16:01:50 +01:00
|
|
|
void GetExtent(const std::string &text,int &w,int &h);
|
2010-07-23 06:15:36 +02:00
|
|
|
|
|
|
|
OpenGLText();
|
|
|
|
~OpenGLText();
|
2007-04-12 14:49:41 +02:00
|
|
|
};
|