xref: /trunk/main/sd/source/ui/inc/tools/IconCache.hxx (revision 86e1cf34)
1c45d927aSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3c45d927aSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4c45d927aSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5c45d927aSAndrew Rist  * distributed with this work for additional information
6c45d927aSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7c45d927aSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8c45d927aSAndrew Rist  * "License"); you may not use this file except in compliance
9c45d927aSAndrew Rist  * with the License.  You may obtain a copy of the License at
10c45d927aSAndrew Rist  *
11c45d927aSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12c45d927aSAndrew Rist  *
13c45d927aSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14c45d927aSAndrew Rist  * software distributed under the License is distributed on an
15c45d927aSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16c45d927aSAndrew Rist  * KIND, either express or implied.  See the License for the
17c45d927aSAndrew Rist  * specific language governing permissions and limitations
18c45d927aSAndrew Rist  * under the License.
19c45d927aSAndrew Rist  *
20c45d927aSAndrew Rist  *************************************************************/
21c45d927aSAndrew Rist 
22c45d927aSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef SD_ICON_CACHE_HXX
25cdf0e10cSrcweir #define SD_ICON_CACHE_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "SdGlobalResourceContainer.hxx"
28cdf0e10cSrcweir #include <vcl/image.hxx>
29cdf0e10cSrcweir 
30cdf0e10cSrcweir namespace sd {
31cdf0e10cSrcweir 
32cdf0e10cSrcweir /** This simple class stores frequently used icons so that the classes that
33cdf0e10cSrcweir     use the icons do not have to store them in every one of their
34cdf0e10cSrcweir     instances.
35cdf0e10cSrcweir 
36*86e1cf34SPedro Giffuni     Icons are addressed over their resource id and are loaded on demand.
37cdf0e10cSrcweir 
38cdf0e10cSrcweir     This cache acts like a singleton with a lifetime equal to that of the sd
39cdf0e10cSrcweir     module.
40cdf0e10cSrcweir */
41cdf0e10cSrcweir class IconCache
42cdf0e10cSrcweir     : public SdGlobalResource
43cdf0e10cSrcweir {
44cdf0e10cSrcweir public:
45cdf0e10cSrcweir     /** The lifetime of the returned reference is limited to that of the sd
46cdf0e10cSrcweir         module.
47cdf0e10cSrcweir     */
48cdf0e10cSrcweir     static IconCache& Instance (void);
49cdf0e10cSrcweir 
50cdf0e10cSrcweir     /** Return the icon with the given resource id.
51cdf0e10cSrcweir         @return
52cdf0e10cSrcweir             The returned Image may be empty when there is no icon for the
53*86e1cf34SPedro Giffuni             given id or an error occurred.  Should not happen under normal
54cdf0e10cSrcweir             circumstances.
55cdf0e10cSrcweir     */
56cdf0e10cSrcweir     Image GetIcon (sal_uInt16 nResourceId);
57cdf0e10cSrcweir 
58cdf0e10cSrcweir private:
59cdf0e10cSrcweir     class Implementation;
60cdf0e10cSrcweir     ::std::auto_ptr<Implementation> mpImpl;
61cdf0e10cSrcweir 
62cdf0e10cSrcweir     /** The constructor creates the one instance of the cache and registers
63cdf0e10cSrcweir         it at the SdGlobalResourceContainer to limit is lifetime to that of
64cdf0e10cSrcweir         the sd module.
65cdf0e10cSrcweir     */
66cdf0e10cSrcweir     IconCache (void);
67cdf0e10cSrcweir 
68cdf0e10cSrcweir     /** This destructor is called by SdGlobalResourceContainer.
69cdf0e10cSrcweir     */
70cdf0e10cSrcweir     virtual ~IconCache (void);
71cdf0e10cSrcweir };
72cdf0e10cSrcweir 
73cdf0e10cSrcweir } // end of namespace sd
74cdf0e10cSrcweir 
75cdf0e10cSrcweir #endif
76