⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 glfont.hpp

📁 ncbi源码
💻 HPP
字号:
/* * =========================================================================== * PRODUCTION $Log: glfont.hpp,v $ * PRODUCTION Revision 1000.1  2004/06/01 19:50:04  gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.17 * PRODUCTION * =========================================================================== */#ifndef GUI_OPENGL___GL_FONT__HPP#define GUI_OPENGL___GL_FONT__HPP/*  $Id: glfont.hpp,v 1000.1 2004/06/01 19:50:04 gouriano Exp $ * =========================================================================== * *                            PUBLIC DOMAIN NOTICE *               National Center for Biotechnology Information * *  This software/database is a "United States Government Work" under the *  terms of the United States Copyright Act.  It was written as part of *  the author's official duties as a United States Government employee and *  thus cannot be copyrighted.  This software/database is freely available *  to the public for use. The National Library of Medicine and the U.S. *  Government have not placed any restriction on its use or reproduction. * *  Although all reasonable efforts have been taken to ensure the accuracy *  and reliability of the software and data, the NLM and the U.S. *  Government do not and cannot warrant the performance or results that *  may be obtained by using this software or data. The NLM and the U.S. *  Government disclaim all warranties, express or implied, including *  warranties of performance, merchantability or fitness for any particular *  purpose. * *  Please cite the author in any work or product based on this material. * * =========================================================================== * * Authors:  Mike DiCuccio * * File Description: *    CGlFont   -- base class for OpenGL fonts *    CGlutFont -- GLUT based bitmap fonts */#include <corelib/ncbiobj.hpp>#include <gui/opengl.h>#include <gui/opengl/glcolor.hpp>#include <map>#include <FL/Enumerations.H>/** @addtogroup GUI_OPENGL * * @{ */BEGIN_NCBI_SCOPE//// Interface class for all OpenGL fonts.//class IGlFont : public CObject{public:    // text truncation types    enum ETruncate {        // do not attempt any kind of truncation        eTruncate_None,        // simply chop the string without providing any details        eTruncate_Empty,        // truncate and append an ellipsis        eTruncate_Ellipsis    };    // metric types    enum EMetric {        // return the height of a capital letter        eMetric_CharHeight,        // return the height of all possible character, including        // ascents and descents        eMetric_FullCharHeight,        // return the widths of all characters        eMetric_AvgCharWidth,        // return the maximum width of all characters        eMetric_MaxCharWidth,        // return the length of a given string without the final advance        // (this is the entire space taken up by only this string)        eMetric_TextWidth,        // return the length of a given string with the final advance        eMetric_FullTextWidth    };    // must provide default ctor - copy ctor is private    IGlFont(void) {}    // destructor    virtual ~IGlFont(void) {}    // Print the appropriate text on the screen.  This function uses the    // current raster position.    virtual void TextOut(const char* text) const = 0;    // Print some text on the screen.  This function uses a specified    // raster position.    virtual void TextOut(float x, float y, const char* text) const = 0;    // Output text into a given rectangle using a particular alignment.    // The alignment is a bitmask of FLTK's Fl_Align enums.  The only    // distinction is that text is *always* inside    virtual void TextOut(float x, float y, float w, float h, const char* text,                         int       align = FL_ALIGN_CENTER,                         ETruncate trunc = eTruncate_Ellipsis) const = 0;    // Determine how much space a piece of text will occupy.  This    // is intended *not* to include the final advance!    virtual float TextWidth (const char* text) const = 0;    // determine the text height    virtual float TextHeight(void) const = 0;    // query the font for certain metrics    virtual float GetMetric(EMetric     metric,                            const char* text = NULL,                            int         len = -1) const = 0;private:    // prohibit    IGlFont(const IGlFont&);    IGlFont& operator= (const IGlFont&);};//// Utility class for managing font encoding / interception in feedback mode//class CGlFeedbackFont{public:    enum    {        eBeginText = 0xBAAB,        eEndText = 0xCBBC,        ePosition = 0xFCEB,        eColor = 0xEFBA    };    union FPackChar    {        float f;        char c[4];    };    static vector<float> EncodeText(GLfloat pos[4],                                    const CGlColor& color,                                    const char* text,                                    size_t length);    static vector<float> EncodeText(GLfloat pos[4],                                    const CGlColor& color,                                    const string& text);    static void DecodeText(const vector<float>& textbuf,                           GLfloat* pos,                           GLfloat* color,                           string& text);};END_NCBI_SCOPE/* @} *//* * =========================================================================== * $Log: glfont.hpp,v $ * Revision 1000.1  2004/06/01 19:50:04  gouriano * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.17 * * Revision 1.17  2004/05/11 18:54:22  dicuccio * Added doxygne modules info * * Revision 1.16  2003/10/02 13:36:21  dicuccio * Made IGlFont::TextOut(...) variant pure virtual * * Revision 1.15  2003/09/29 15:13:16  dicuccio * iLots of documentation clean-ups.  Changed some of the GetMetric() enums to * more clearly describe the metric.  Added ability for GetMetric() to supply text * widths * * Revision 1.14  2003/09/25 17:44:33  dicuccio * Added API for checking font metrics (only height is supported) * * Revision 1.13  2003/09/17 16:17:46  dicuccio * Removed CGlutFont.  Added enumerated type in IGlFont for indicating text * truncation mechanisms * * Revision 1.12  2003/08/28 19:28:28  dicuccio * Made TextOut() functions const; made display lists in CGlBitmapFont mutable * * Revision 1.11  2003/08/22 15:56:15  dicuccio * Inherit from CObject * * Revision 1.10  2003/08/21 12:14:24  dicuccio * Added #include for <gui/opengl.h * * Revision 1.9  2003/08/18 19:25:34  dicuccio * Changed CGlFont to IGlFont - true interface class. * * Revision 1.8  2003/05/13 22:07:18  meric * Replace static constants with enums * * Revision 1.7  2003/05/13 19:23:58  dicuccio * Added CGlFeedbackFont - traps font output in feedback mode, for converting * bitmap -> vector fonts in printing (Peter Meric) * * Revision 1.6  2003/03/25 17:06:55  dicuccio * Changed glut.h --> glut.H to make FLTK happy * * Revision 1.5  2003/01/13 13:11:42  dicuccio * Namespace clean-up.  Retired namespace gui -> converted to namespace ncbi. * Moved all FLUID-generated code into namespace ncbi. * * Revision 1.4  2002/12/19 18:13:03  dicuccio * Added export specifiers for Win32. * * Revision 1.3  2002/11/07 18:24:46  dicuccio * Minor #ifdef changes.  Created macro to wrap dumping of OpenGL state. * * Revision 1.2  2002/11/05 19:52:01  dicuccio * Implemented CGlutFont::EFont as well as 'tors for CGlFont * * Revision 1.1  2002/11/04 20:05:37  dicuccio * Initial revision * * =========================================================================== */#endif  // GUI_OPENGL___GL_FONT__HPP

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -