• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

gr_CharWidthsCache.h

Go to the documentation of this file.
00001 /* AbiSource Application Framework
00002  * Copyright (C) 2003, 2013 Hubert Figuiere
00003  * 
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00017  * 02110-1301 USA.
00018  */
00019 
00020 #ifndef _GR_CHAR_WIDTHS_CACHE_H__
00021 #define _GR_CHAR_WIDTHS_CACHE_H__
00022 
00023 #include <map>
00024 #include <string>
00025 
00026 #include "ut_types.h"
00027 
00028 class GR_Font;
00029 class GR_CharWidths;
00030 
00031 class ABI_EXPORT GR_CharWidthsCache
00032 {
00033 public:
00034 
00038     static GR_CharWidthsCache* getCharWidthCache()
00039     {
00040         _instantiate();
00041         return s_pInstance;
00042     }
00043 
00044     enum {
00045         CACHE_FONT_SIZE = 120
00046     };
00047 
00048     static void destroyCharWidthsCache()
00049     {
00050         if(s_pInstance)
00051         {
00052             delete s_pInstance;
00053             s_pInstance = NULL;
00054         }
00055     }
00056 
00057 protected:
00058     typedef std::map<std::string, GR_CharWidths*> FontCache;
00059 
00060     FontCache::iterator addFont (const GR_Font* pFont);
00064     GR_CharWidths*  getWidthsForFont(const GR_Font* pFont);
00065     friend class GR_Font;
00066 private:
00067     GR_CharWidthsCache();
00068     ~GR_CharWidthsCache();
00069 
00073     static void _instantiate(void);
00074 
00078     static GR_CharWidthsCache* s_pInstance;
00082     FontCache m_fontHash;
00083 };
00084 
00085 
00086 #endif

Generated on Sun Feb 14 2021 for AbiWord by  doxygen 1.7.1