/************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License version 3 * only, as published by the Free Software Foundation. * * OpenOffice.org is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License version 3 for more details * (a copy is included in the LICENSE file that accompanied this code). * * You should have received a copy of the GNU Lesser General Public License * version 3 along with OpenOffice.org. If not, see * * for a copy of the LGPLv3 License. * ************************************************************************/ #ifndef SDEXT_PRESENTER_BITMAP_CONTAINER_HXX #define SDEXT_PRESENTER_BITMAP_CONTAINER_HXX #include #include #include #include #include #include #include #include #include #include #include #include #include namespace css = ::com::sun::star; namespace sdext { namespace presenter { /** Manage a set of bitmap groups as they are used for buttons: three bitmaps, one for the normal state, one for a mouse over effect and one to show that the button has been pressed. A bitmap group is defined by some entries in the configuration. */ class PresenterBitmapContainer : private ::boost::noncopyable { public: /** There is one bitmap for the normal state, one for a mouse over effect and one to show that a button has been pressed. */ class BitmapDescriptor { public: BitmapDescriptor (void); BitmapDescriptor (const ::boost::shared_ptr& rpDefault); enum Mode {Normal, MouseOver, ButtonDown, Disabled, Mask}; css::uno::Reference GetNormalBitmap (void) const; css::uno::Reference GetBitmap ( const Mode eMode, const bool bMissingDefaultsToNormal = true) const; void SetBitmap ( const Mode eMode, const css::uno::Reference& rxBitmap); sal_Int32 mnWidth; sal_Int32 mnHeight; sal_Int32 mnXOffset; sal_Int32 mnYOffset; sal_Int32 mnXHotSpot; sal_Int32 mnYHotSpot; css::util::Color maReplacementColor; enum TexturingMode { Once, Repeat, Stretch }; TexturingMode meHorizontalTexturingMode; TexturingMode meVerticalTexturingMode; private: css::uno::Reference mxNormalBitmap; css::uno::Reference mxMouseOverBitmap; css::uno::Reference mxButtonDownBitmap; css::uno::Reference mxDisabledBitmap; css::uno::Reference mxMaskBitmap; }; /** Create a new bitmap container from a section of the configuration. @param rxComponentContext The component context is used to create new API objects. @param rxCanvas Bitmaps are created specifically for this canvas. @param rsConfigurationBase The name of a configuration node whose sub-tree defines the bitmap sets. */ PresenterBitmapContainer ( const ::rtl::OUString& rsConfigurationBase, const ::boost::shared_ptr& rpParentContainer, const css::uno::Reference& rxComponentContext, const css::uno::Reference& rxCanvas, const ::rtl::OUString& rsBasePath, const css::uno::Reference& rxPresenterHelper = NULL); PresenterBitmapContainer ( const css::uno::Reference& rsRootNode, const ::boost::shared_ptr& rpParentContainer, const css::uno::Reference& rxComponentContext, const css::uno::Reference& rxCanvas, const ::rtl::OUString& rsBasePath, const css::uno::Reference& rxPresenterHelper = NULL); ~PresenterBitmapContainer (void); void Initialize ( const css::uno::Reference& rxComponentContext); /** Return the bitmap set that is associated with the given name. */ ::boost::shared_ptr GetBitmap (const ::rtl::OUString& rsName) const; static ::boost::shared_ptr LoadBitmap ( const css::uno::Reference& rxNode, const ::rtl::OUString& rsPathToBitmapNode, const css::uno::Reference& rxPresenterHelper, const ::rtl::OUString& rsBitmapBasePath, const css::uno::Reference& rxCanvas, const ::boost::shared_ptr& rpDefaultBitmap); private: ::boost::shared_ptr mpParentContainer; typedef ::std::map > BitmapContainer; BitmapContainer maIconContainer; ::rtl::OUString msBasePath; css::uno::Reference mxCanvas; css::uno::Reference mxPresenterHelper; void LoadBitmaps ( const css::uno::Reference& rsRootNode); void ProcessBitmap ( const ::rtl::OUString& rsKey, const css::uno::Reference& rProperties); static ::boost::shared_ptr LoadBitmap ( const css::uno::Reference& rxProperties, const css::uno::Reference& rxPresenterHelper, const ::rtl::OUString& rsBasePath, const css::uno::Reference& rxCanvas, const ::boost::shared_ptr& rpDefault); static BitmapDescriptor::TexturingMode StringToTexturingMode (const ::rtl::OUString& rsTexturingMode); }; typedef PresenterBitmapContainer::BitmapDescriptor PresenterBitmapDescriptor; typedef ::boost::shared_ptr SharedBitmapDescriptor; } } // end of namespace ::sdext::presenter #endif