00001 /* AbiSource Application Framework 00002 * Copyright (C) 2003 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., 59 Temple Place - Suite 330, Boston, MA 00017 * 02111-1307, USA. 00018 */ 00019 00020 #ifndef _GR_CHAR_WIDTHS_CACHE_H__ 00021 #define _GR_CHAR_WIDTHS_CACHE_H__ 00022 00023 #include "ut_types.h" 00024 #include "ut_hash.h" 00025 00026 class GR_Font; 00027 class GR_CharWidths; 00028 00029 class ABI_EXPORT GR_CharWidthsCache 00030 { 00031 public: 00032 00036 static GR_CharWidthsCache* getCharWidthCache() 00037 { 00038 _instantiate(); 00039 return s_pInstance; 00040 } 00041 00042 enum { 00043 CACHE_FONT_SIZE = 120 00044 }; 00045 00046 static void destroyCharWidthsCache() 00047 { 00048 if(s_pInstance) 00049 { 00050 delete s_pInstance; 00051 s_pInstance = NULL; 00052 } 00053 } 00054 00055 protected: 00056 bool addFont (const GR_Font* pFont); 00060 GR_CharWidths* getWidthsForFont(const GR_Font* pFont); 00061 friend class GR_Font; 00062 private: 00063 GR_CharWidthsCache(); 00064 ~GR_CharWidthsCache(); 00065 00069 static void _instantiate(void); 00070 00074 static GR_CharWidthsCache* s_pInstance; 00078 UT_GenericStringMap<GR_CharWidths*>* m_pFontHash; 00079 }; 00080 00081 00082 #endif