Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members
|
00001 /******************************************************************************** 00002 * * 00003 * I c o n D i c t i o n a r y * 00004 * * 00005 ********************************************************************************* 00006 * Copyright (C) 1998,2006 by Jeroen van der Zijp. All Rights Reserved. * 00007 ********************************************************************************* 00008 * This library is free software; you can redistribute it and/or * 00009 * modify it under the terms of the GNU Lesser General Public * 00010 * License as published by the Free Software Foundation; either * 00011 * version 2.1 of the License, or (at your option) any later version. * 00012 * * 00013 * This library is distributed in the hope that it will be useful, * 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00016 * Lesser General Public License for more details. * 00017 * * 00018 * You should have received a copy of the GNU Lesser General Public * 00019 * License along with this library; if not, write to the Free Software * 00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * 00021 ********************************************************************************* 00022 * $Id: FXIconDict.h,v 1.6 2006/02/03 00:33:15 fox Exp $ * 00023 ********************************************************************************/ 00024 #ifndef FXICONDICT_H 00025 #define FXICONDICT_H 00026 00027 #ifndef FXDICT_H 00028 #include "FXDict.h" 00029 #endif 00030 00031 namespace FX { 00032 00033 00034 class FXIconSource; 00035 00036 00037 /** 00038 * The Icon Dictionary manages a collection of icons. The icons are referenced 00039 * by their file name. When first encountering a new file name, the icon is 00040 * located by searching the icon search path for the icon file. If found, the 00041 * services of the icon source object are used to load the icon from the file. 00042 * A custom icon source may be installed to furnish support for additonal 00043 * image file formats. 00044 * Once the icon is loaded, an association between the icon name and the icon 00045 * is entered into the icon dictionary. Subsequent searches for an icon with 00046 * this name will be satisfied from the cached value. 00047 * The lifetype of the icons is managed by the icon dictionary, and thus all 00048 * icons will be deleted when the dictionary is deleted. 00049 */ 00050 class FXAPI FXIconDict : public FXDict { 00051 FXDECLARE(FXIconDict) 00052 private: 00053 FXIconSource *source; // Icon source 00054 FXString path; // Where to search icons 00055 protected: 00056 FXIconDict():source(NULL){} 00057 virtual void *createData(const void*); 00058 virtual void deleteData(void*); 00059 private: 00060 FXIconDict(const FXIconDict&); 00061 FXIconDict &operator=(const FXIconDict&); 00062 public: 00063 00064 /// Default icon search path 00065 static const FXchar defaultIconPath[]; 00066 00067 public: 00068 00069 /** 00070 * Construct icon dictionary, and set initial search path; also 00071 * creates a default icon source object. 00072 */ 00073 FXIconDict(FXApp* app,const FXString& p=defaultIconPath); 00074 00075 /// Change icon source 00076 void setIconSource(FXIconSource *src){ source=src; } 00077 00078 /// Return icon source 00079 FXIconSource* getIconSource() const { return source; } 00080 00081 /// Set icon search path 00082 void setIconPath(const FXString& p){ path=p; } 00083 00084 /// Return current icon search path 00085 const FXString& getIconPath() const { return path; } 00086 00087 /// Insert unique icon loaded from filename into dictionary 00088 FXIcon* insert(const FXchar* name){ return (FXIcon*)FXDict::insert(name,name); } 00089 00090 /// Remove icon from dictionary 00091 FXIcon* remove(const FXchar* name){ return (FXIcon*)FXDict::remove(name); } 00092 00093 /// Find icon by name 00094 FXIcon* find(const FXchar* name){ return (FXIcon*)FXDict::find(name); } 00095 00096 /// Save to stream 00097 virtual void save(FXStream& store) const; 00098 00099 /// Load from stream 00100 virtual void load(FXStream& store); 00101 00102 /// Destroy the icon dict as well as the icon source 00103 virtual ~FXIconDict(); 00104 }; 00105 00106 00107 } 00108 00109 #endif
Copyright © 1997-2005 Jeroen van der Zijp |