1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: SlsFontProvider.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SD_SLIDESORTER_VIEW_FONT_PROVIDER_HXX
32 #define SD_SLIDESORTER_VIEW_FONT_PROVIDER_HXX
34 #include "tools/SdGlobalResourceContainer.hxx"
36 #include <boost/shared_ptr.hpp>
37 #include <vcl/mapmod.hxx>
43 namespace sd
{ namespace slidesorter
{ namespace view
{
45 /** This simple singleton class provides fonts that are scaled so that they
46 have a fixed height on the given device regardless of its map mode.
49 : public SdGlobalResource
52 typedef ::boost::shared_ptr
<Font
> SharedFontPointer
;
54 /** Return the single instance of this class. Throws a RuntimeException
55 when no instance can be created.
57 static FontProvider
& Instance (void);
59 /** Return a font that is scaled according to the current map mode of
60 the given device. Repeated calls with a device, not necessarily the
61 same device, with the same map mode will return the same font. The
62 first call with a different map mode will release the old font and
63 create a new one that is correctly scaled.
65 SharedFontPointer
GetFont (const OutputDevice
& rDevice
);
67 /** Call this method to tell an object to release its currently used
68 font. The next call to GetFont() will then create a new one.
69 Typically called after a DataChange event when for instance a system
70 font has been modified.
72 void Invalidate (void);
75 static FontProvider
* mpInstance
;
77 /** The font that was created by a previous call to GetFont(). It is
78 replaced by another one only when GetFont() is called with a device
79 with a different map mode or by a call to Invalidate().
81 SharedFontPointer maFont
;
82 /** The mape mode for which maFont was created.
87 virtual ~FontProvider (void);
89 // Copy constructor is not implemented.
90 FontProvider (const FontProvider
&);
91 // Assignment operator is not implemented.
92 FontProvider
& operator= (const FontProvider
&);
95 } } } // end of namespace ::sd::slidesorter::view