1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef SD_SLIDESORTER_VIEW_FONT_PROVIDER_HXX 25 #define SD_SLIDESORTER_VIEW_FONT_PROVIDER_HXX 26 27 #include "tools/SdGlobalResourceContainer.hxx" 28 29 #include <boost/shared_ptr.hpp> 30 #include <vcl/mapmod.hxx> 31 32 class Font; 33 class OutputDevice; 34 class VclWindowEvent; 35 36 namespace sd { namespace slidesorter { namespace view { 37 38 /** This simple singleton class provides fonts that are scaled so that they 39 have a fixed height on the given device regardless of its map mode. 40 */ 41 class FontProvider 42 : public SdGlobalResource 43 { 44 public: 45 typedef ::boost::shared_ptr<Font> SharedFontPointer; 46 47 /** Return the single instance of this class. Throws a RuntimeException 48 when no instance can be created. 49 */ 50 static FontProvider& Instance (void); 51 52 /** Return a font that is scaled according to the current map mode of 53 the given device. Repeated calls with a device, not necessarily the 54 same device, with the same map mode will return the same font. The 55 first call with a different map mode will release the old font and 56 create a new one that is correctly scaled. 57 */ 58 SharedFontPointer GetFont (const OutputDevice& rDevice); 59 60 /** Call this method to tell an object to release its currently used 61 font. The next call to GetFont() will then create a new one. 62 Typically called after a DataChange event when for instance a system 63 font has been modified. 64 */ 65 void Invalidate (void); 66 67 private: 68 static FontProvider* mpInstance; 69 70 /** The font that was created by a previous call to GetFont(). It is 71 replaced by another one only when GetFont() is called with a device 72 with a different map mode or by a call to Invalidate(). 73 */ 74 SharedFontPointer maFont; 75 /** The mape mode for which maFont was created. 76 */ 77 MapMode maMapMode; 78 79 FontProvider (void); 80 virtual ~FontProvider (void); 81 82 // Copy constructor is not implemented. 83 FontProvider (const FontProvider&); 84 // Assignment operator is not implemented. 85 FontProvider& operator= (const FontProvider&); 86 }; 87 88 } } } // end of namespace ::sd::slidesorter::view 89 90 #endif 91