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,2024 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
An icon source is a class that loads an icon of any type.
Definition: FXIconSource.h:47
The Application object is the central point of a FOX user-interface.
Definition: FXApp.h:134
FXchar * text()
Get text contents as pointer.
Definition: FXString.h:119
FXApp * getApp() const
Get application.
Definition: FXIconCache.h:79
FXIcon * find(const FXchar *name) const
Find icon by name, return NULL if no icon found in cache.
Definition: FXIconCache.h:100
A stream is a way to serialize data and objects into a byte stream.
Definition: FXStream.h:81
TYPE *& at(const FXchar *ky)
Return reference to slot assocated with given key.
Definition: FXDictionaryOf.h:47
Definition: FX4Splitter.h:28
An Icon is an image with two additional server-side resources: a shape bitmap, which is used to mask ...
Definition: FXIcon.h:42
const FXString & getIconPath() const
Return the current icon search paths.
Definition: FXIconCache.h:91
void setIconPath(const FXString &p)
Set the icon search paths.
Definition: FXIconCache.h:88
void setIconSource(FXIconSource *src)
Change icon source.
Definition: FXIconCache.h:82
Object is the base class for all objects in FOX; in order to receive messages from the user interface...
Definition: FXObject.h:134
FXIcon * insert(const FXString &name)
Insert icon into cache, load it from file if not already cached.
Definition: FXIconCache.h:97
The Icon Cache manages a collection of icons.
Definition: FXIconCache.h:53
FXIcon * find(const FXString &name) const
Find icon by name, return NULL if no icon found in cache.
Definition: FXIconCache.h:103
FXIconSource * getIconSource() const
Return icon source.
Definition: FXIconCache.h:85
FXString provides essential string manipulation capabilities in FOX.
Definition: FXString.h:42

Copyright © 1997-2022 Jeroen van der Zijp