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

FXIconCache.h
1 /********************************************************************************
2 * *
3 * I c o n C a c h e *
4 * *
5 *********************************************************************************
6 * Copyright (C) 1998,2017 by Jeroen van der Zijp. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU Lesser General Public License as published by *
10 * the Free Software Foundation; either version 3 of the License, or *
11 * (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public License *
19 * along with this program. If not, see <http://www.gnu.org/licenses/> *
20 ********************************************************************************/
21 #ifndef FXICONCACHE_H
22 #define FXICONCACHE_H
23 
24 #ifndef FXOBJECT_H
25 #include "FXObject.h"
26 #endif
27 
28 namespace FX {
29 
30 
31 // Forward declarations
32 class FXIcon;
33 class FXIconSource;
34 
35 
36 // Dictionary of icons
37 typedef FXDictionaryOf<FXIcon> FXIconDictionary;
38 
39 
53 class FXAPI FXIconCache : public FXObject {
54  FXDECLARE(FXIconCache)
55 private:
56  FXApp *app; // Application object
57  FXIconSource *loader; // Icon source loads the icons
58  FXIconDictionary dict; // Map filename to icon resource
59  FXString path; // Paths to search for icons
60 protected:
61  FXIconCache();
62 private:
63  FXIconCache(const FXIconCache&);
64  FXIconCache &operator=(const FXIconCache&);
65 public:
66 
68  static const FXchar defaultIconPath[];
69 
70 public:
71 
76  FXIconCache(FXApp* ap,const FXString& sp=defaultIconPath);
77 
79  FXApp* getApp() const { return app; }
80 
82  void setIconSource(FXIconSource* src){ loader=src; }
83 
85  FXIconSource* getIconSource() const { return loader; }
86 
88  void setIconPath(const FXString& p){ path=p; }
89 
91  const FXString& getIconPath() const { return path; }
92 
94  FXIcon* insert(const FXchar* name);
95 
97  FXIcon* insert(const FXString& name){ return insert(name.text()); }
98 
100  FXIcon* find(const FXchar* name) const { return dict.at(name); }
101 
103  FXIcon* find(const FXString& name) const { return dict.at(name); }
104 
106  void remove(const FXchar* name);
107 
109  void remove(const FXString& name){ remove(name.text()); }
110 
112  void clear();
113 
115  virtual void save(FXStream& store) const;
116 
118  virtual void load(FXStream& store);
119 
121  virtual ~FXIconCache();
122  };
123 
124 
125 }
126 
127 #endif

Copyright © 1997-2016 Jeroen van der Zijp