Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

overlay.h

Go to the documentation of this file.
00001 // overlay.h
00002 //
00003 // Copyright (C) 2001, Chris Laurel <claurel@shatters.net>
00004 //
00005 // This program is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU General Public License
00007 // as published by the Free Software Foundation; either version 2
00008 // of the License, or (at your option) any later version.
00009 
00010 #ifndef _OVERLAY_H_
00011 #define _OVERLAY_H_
00012 
00013 #include <string>
00014 #include <iostream>
00015 #include <celtxf/texturefont.h>
00016 
00017 
00018 class Overlay;
00019 
00020 // Custom streambuf class to support C++ operator style output.  The
00021 // output is completely unbuffered so that it can coexist with printf
00022 // style output which the Overlay class also supports.
00023 class OverlayStreamBuf : public std::streambuf
00024 {
00025  public:
00026     OverlayStreamBuf();
00027 
00028     void setOverlay(Overlay*);
00029 
00030     int overflow(int c = EOF);
00031 
00032     enum UTF8DecodeState
00033     {
00034         UTF8DecodeStart     = 0,
00035         UTF8DecodeMultibyte = 1,
00036     };
00037 
00038  private:
00039     Overlay* overlay;
00040     
00041     UTF8DecodeState decodeState;
00042     wchar_t decodedChar;
00043     unsigned int decodeShift;
00044 };
00045 
00046 
00047 class Overlay : public std::ostream
00048 {
00049  public:
00050     Overlay();
00051     ~Overlay();
00052 
00053     void begin();
00054     void end();
00055 
00056     void setWindowSize(int, int);
00057     void setFont(TextureFont*);
00058 
00059     void rect(float x, float y, float w, float h, bool fill = true);
00060 
00061     void beginText();
00062     void endText();
00063     void print(wchar_t);
00064     void print(char);
00065     void print(char*);
00066     void printf(const char*, ...);
00067     
00068 
00069  private:
00070     int windowWidth;
00071     int windowHeight;
00072     TextureFont* font;
00073     bool useTexture;
00074     bool fontChanged;
00075     int textBlock;
00076 
00077     OverlayStreamBuf sbuf;
00078 };
00079 
00080 #endif // _OVERLAY_H_

Generated on Sat Jan 14 22:30:28 2006 for Celestia by  doxygen 1.4.1