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

FXIconDict.h
Go to the documentation of this file.
1 /********************************************************************************
2 * *
3 * I c o n D i c t i o n a r y *
4 * *
5 *********************************************************************************
6 * Copyright (C) 1998,2006 by Jeroen van der Zijp. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or *
9 * modify it under the terms of the GNU Lesser General Public *
10 * License as published by the Free Software Foundation; either *
11 * version 2.1 of the License, or (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 GNU *
16 * Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public *
19 * License along with this library; if not, write to the Free Software *
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
21 *********************************************************************************
22 * $Id: FXIconDict.h,v 1.6 2006/02/03 00:33:15 fox Exp $ *
23 ********************************************************************************/
24 #ifndef FXICONDICT_H
25 #define FXICONDICT_H
26 
27 #ifndef FXDICT_H
28 #include "FXDict.h"
29 #endif
30 
31 namespace FX {
32 
33 
34 class FXIconSource;
35 
36 
37 /**
38 * The Icon Dictionary manages a collection of icons. The icons are referenced
39 * by their file name. When first encountering a new file name, the icon is
40 * located by searching the icon search path for the icon file. If found, the
41 * services of the icon source object are used to load the icon from the file.
42 * A custom icon source may be installed to furnish support for additonal
43 * image file formats.
44 * Once the icon is loaded, an association between the icon name and the icon
45 * is entered into the icon dictionary. Subsequent searches for an icon with
46 * this name will be satisfied from the cached value.
47 * The lifetype of the icons is managed by the icon dictionary, and thus all
48 * icons will be deleted when the dictionary is deleted.
49 */
50 class FXAPI FXIconDict : public FXDict {
52 private:
53  FXIconSource *source; // Icon source
54  FXString path; // Where to search icons
55 protected:
56  FXIconDict():source(NULL){}
57  virtual void *createData(const void*);
58  virtual void deleteData(void*);
59 private:
60  FXIconDict(const FXIconDict&);
61  FXIconDict &operator=(const FXIconDict&);
62 public:
63 
64  /// Default icon search path
65  static const FXchar defaultIconPath[];
66 
67 public:
68 
69  /**
70  * Construct icon dictionary, and set initial search path; also
71  * creates a default icon source object.
72  */
73  FXIconDict(FXApp* app,const FXString& p=defaultIconPath);
74 
75  /// Change icon source
76  void setIconSource(FXIconSource *src){ source=src; }
77 
78  /// Return icon source
79  FXIconSource* getIconSource() const { return source; }
80 
81  /// Set icon search path
82  void setIconPath(const FXString& p){ path=p; }
83 
84  /// Return current icon search path
85  const FXString& getIconPath() const { return path; }
86 
87  /// Insert unique icon loaded from filename into dictionary
88  FXIcon* insert(const FXchar* name){ return (FXIcon*)FXDict::insert(name,name); }
89 
90  /// Remove icon from dictionary
91  FXIcon* remove(const FXchar* name){ return (FXIcon*)FXDict::remove(name); }
92 
93  /// Find icon by name
94  FXIcon* find(const FXchar* name){ return (FXIcon*)FXDict::find(name); }
95 
96  /// Save to stream
97  virtual void save(FXStream& store) const;
98 
99  /// Load from stream
100  virtual void load(FXStream& store);
101 
102  /// Destroy the icon dict as well as the icon source
103  virtual ~FXIconDict();
104  };
105 
106 
107 }
108 
109 #endif
void * find(const FXchar *ky) const
Find data pointer given key.
char FXchar
Definition: fxdefs.h:387
An icon source is a class that loads an icon of any type.
Definition: FXIconSource.h:49
#define FXAPI
Definition: fxdefs.h:122
Application Object.
Definition: FXApp.h:158
void * insert(const FXchar *ky, const void *ptr, bool mrk=false)
Insert a new entry into the table given key and mark.
#define NULL
Definition: fxdefs.h:41
FXString name(const FXString &file)
Return name and extension part of the path name.
void * remove(const FXchar *ky)
Remove data given key.
An Icon is an image with two additional server-side resources: a shape bitmap, which is used to mask ...
Definition: FXIcon.h:45
The dictionary class maintains a fast-access hash table of entities indexed by a character string...
Definition: FXDict.h:41
The Icon Dictionary manages a collection of icons.
Definition: FXIconDict.h:50
#define FXDECLARE(classname)
Macro to set up class declaration.
Definition: FXObject.h:92
FXString provides essential string manipulation capabilities.
Definition: FXString.h:33

Copyright © 1997-2005 Jeroen van der Zijp