Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   Related Pages  

sglBitmapFont.hpp

00001 /*****************************************************************************
00002  * SGL: A Scene Graph Library
00003  *
00004  * Copyright (C) 1997-2001  Scott McMillan   All Rights Reserved.
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Library General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Library General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Library General Public
00017  * License along with this library; if not, write to the Free
00018  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019  *****************************************************************************
00020  *     File: sglBitmapFont.hpp
00021  *   Author: Tom Stimson
00022  *  Created: 20 April 2000
00023  *  Summary: Class to render text strings.
00024  *****************************************************************************/
00025 
00026 #ifndef __SGL_BITMAP_FONT_HPP
00027 #define __SGL_BITMAP_FONT_HPP
00028 
00029 #include <sgl.h>
00030 #include <sglObject.hpp>
00031 #include <string>
00032 
00033 //============================================================================
00034 
00062 class SGL_DLL_API sglBitmapFont : public sglObject
00063 {
00064 public:
00066    sglBitmapFont() {};
00068    virtual ~sglBitmapFont() {};
00069 
00074    virtual sglBitmapFont* clone() const = 0;
00075 
00080    void rasterString(const string &str) const
00081         { rasterString(str.c_str(), str.size()); }
00082 
00089    virtual void rasterString(const char *str, int len = -1) const = 0;
00090 
00094    virtual unsigned int getHeight() const = 0;
00095 
00099    virtual unsigned int getDescent() const = 0;
00100 
00105    virtual unsigned int getCharWidth(char c) const = 0;
00106 
00111    virtual unsigned int getStringWidth(const string &str) const;
00112 
00117    static void setDefaultFont(sglBitmapFont* font);
00118 
00123    static sglBitmapFont* getDefaultFont() { return s_default_font; }
00124 
00125 private:  // not implemented
00126    sglBitmapFont(const sglBitmapFont &);
00127    sglBitmapFont &operator=(const sglBitmapFont &);
00128 
00129 private:
00130    static sglBitmapFont *s_default_font;
00131 };
00132 
00133 
00134 //============================================================================
00135 
00139 class SGL_DLL_API sglBitmapFont8x13 : public sglBitmapFont
00140 {
00141 public:
00145    sglBitmapFont8x13();
00146 
00148    ~sglBitmapFont8x13();
00149 
00154    virtual sglBitmapFont* clone() const;
00155 
00162    virtual void rasterString(const char *str, int len = -1) const;
00163 
00167    virtual unsigned int getHeight() const;
00168 
00172    virtual unsigned int getDescent() const;
00173 
00178    virtual unsigned int getCharWidth(char c) const;
00179 
00180 private:  // not implemented
00181    sglBitmapFont8x13(const sglBitmapFont8x13 &);
00182    sglBitmapFont8x13 &operator=(const sglBitmapFont8x13 &);
00183 
00184 private:
00185    GLuint  m_list_base;
00186 };
00187 
00188 
00189 //============================================================================
00190 
00191 #if !defined(WIN32) && !defined( MAC_OSX )
00192 # include <X11/Xlib.h>
00193 
00195 
00196 class SGL_DLL_API sglBitmapFontGLX : public sglBitmapFont
00197 {
00198 public:
00203    sglBitmapFontGLX(Font font);
00204 
00206    ~sglBitmapFontGLX();
00207 
00212    virtual sglBitmapFont* clone() const;
00213 
00220    virtual void rasterString(const char *str, int len = -1) const;
00221 
00225    virtual unsigned int getHeight() const;
00226 
00230    virtual unsigned int getDescent() const;
00231 
00236    virtual unsigned int getCharWidth(char c) const;
00237 
00242    virtual unsigned int getStringWidth(const string &str) const;
00243 
00244 private:  // not implemented
00245    sglBitmapFontGLX();
00246    sglBitmapFontGLX(const sglBitmapFontGLX &);
00247    sglBitmapFontGLX &operator=(const sglBitmapFontGLX &);
00248 
00249 private:
00250    Font         m_font;
00251    GLuint       m_list_base;
00252    XFontStruct *m_font_info;
00253 };
00254 #endif
00255 
00256 
00257 #endif

Generated at Mon Jul 1 18:00:04 2002 for SGL by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001