Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef INCLUDED_VCL_IMAGE_HXX
21 : #define INCLUDED_VCL_IMAGE_HXX
22 :
23 : #include <vcl/dllapi.h>
24 : #include <tools/gen.hxx>
25 : #include <tools/resid.hxx>
26 : #include <tools/solar.h>
27 : #include <vcl/bitmapex.hxx>
28 : #include <com/sun/star/uno/Reference.hxx>
29 :
30 : #include <vector>
31 :
32 : struct ImplImage;
33 : struct ImplImageList;
34 : namespace com { namespace sun { namespace star { namespace graphic { class XGraphic;} } } }
35 :
36 : #define IMAGE_STDBTN_COLOR Color( 0xC0, 0xC0, 0xC0 )
37 : #define IMAGELIST_IMAGE_NOTFOUND ((sal_uInt16)0xFFFF)
38 :
39 : enum ImageColorTransform
40 : {
41 : IMAGECOLORTRANSFORM_NONE = 0,
42 : IMAGECOLORTRANSFORM_HIGHCONTRAST = 1,
43 : IMAGECOLORTRANSFORM_MONOCHROME_BLACK = 2,
44 : IMAGECOLORTRANSFORM_MONOCHROME_WHITE = 3
45 : };
46 :
47 : class VCL_DLLPUBLIC Image
48 : {
49 : friend class ImageList;
50 : friend class ::OutputDevice;
51 :
52 : public:
53 : Image();
54 : explicit Image( const ResId& rResId );
55 : Image( const Image& rImage );
56 : explicit Image( const BitmapEx& rBitmapEx );
57 : explicit Image( const Bitmap& rBitmap );
58 : Image( const Bitmap& rBitmap, const Bitmap& rMaskBitmap );
59 : Image( const Bitmap& rBitmap, const Color& rColor );
60 : explicit Image( const css::uno::Reference< css::graphic::XGraphic >& rxGraphic );
61 : explicit Image( const OUString &rPNGFileUrl );
62 : ~Image();
63 :
64 : Size GetSizePixel() const;
65 :
66 : BitmapEx GetBitmapEx() const;
67 : css::uno::Reference< css::graphic::XGraphic > GetXGraphic() const;
68 :
69 : Image GetColorTransformedImage( ImageColorTransform eColorTransform ) const;
70 :
71 2065491 : bool operator!() const { return !mpImplData; }
72 : Image& operator=( const Image& rImage );
73 : bool operator==( const Image& rImage ) const;
74 17423 : bool operator!=( const Image& rImage ) const { return !(Image::operator==( rImage )); }
75 :
76 : private:
77 :
78 : ImplImage* mpImplData;
79 :
80 : SAL_DLLPRIVATE void ImplInit( const BitmapEx& rBmpEx );
81 : };
82 :
83 : class VCL_DLLPUBLIC ImageList
84 : {
85 : public:
86 : explicit ImageList( sal_uInt16 nInit = 8, sal_uInt16 nGrow = 4 );
87 : explicit ImageList( const ResId& rResId );
88 : ImageList( const ::std::vector< OUString >& rNameVector,
89 : const OUString& rPrefix,
90 : const Color* pMaskColor = NULL );
91 : ImageList( const ImageList& rImageList );
92 : ~ImageList();
93 :
94 : void InsertFromHorizontalStrip( const BitmapEx &rBitmapEx,
95 : const std::vector< OUString > &rNameVector );
96 : void InsertFromHorizontalBitmap( const ResId& rResId,
97 : sal_uInt16 nCount,
98 : const Color *pNonAlphaMaskColor,
99 : const Color *pSearchColors = NULL,
100 : const Color *pReplaceColors = NULL,
101 : sal_uLong nColorCount = 0);
102 : BitmapEx GetAsHorizontalStrip() const;
103 : sal_uInt16 GetImageCount() const;
104 : Size GetImageSize() const;
105 :
106 : void AddImage( const OUString& rImageName, const Image& rImage );
107 :
108 : void ReplaceImage( const OUString& rImageName, const Image& rImage );
109 :
110 : void RemoveImage( sal_uInt16 nId );
111 :
112 : Image GetImage( sal_uInt16 nId ) const;
113 : Image GetImage( const OUString& rImageName ) const;
114 :
115 : sal_uInt16 GetImagePos( sal_uInt16 nId ) const;
116 : bool HasImageAtPos( sal_uInt16 nId ) const;
117 : sal_uInt16 GetImagePos( const OUString& rImageName ) const;
118 :
119 : sal_uInt16 GetImageId( sal_uInt16 nPos ) const;
120 :
121 : OUString GetImageName( sal_uInt16 nPos ) const;
122 : void GetImageNames( ::std::vector< OUString >& rNames ) const;
123 :
124 : ImageList& operator=( const ImageList& rImageList );
125 : bool operator==( const ImageList& rImageList ) const;
126 : bool operator!=( const ImageList& rImageList ) const { return !(ImageList::operator==( rImageList )); }
127 :
128 : private:
129 :
130 : ImplImageList* mpImplData;
131 : sal_uInt16 mnInitSize;
132 : sal_uInt16 mnGrowSize;
133 :
134 : SAL_DLLPRIVATE void ImplInitBitmapEx( const OUString& rUserImageName,
135 : const ::std::vector< OUString >& rImageNames,
136 : const OUString& rSymbolsStyle,
137 : BitmapEx& rBmpEx,
138 : const Color* pMaskColor ) const;
139 : SAL_DLLPRIVATE void ImplInit( sal_uInt16 nItems, const Size &rSize );
140 : SAL_DLLPRIVATE sal_uInt16 ImplGetImageId( const OUString& rImageName ) const;
141 : };
142 :
143 : #endif // INCLUDED_VCL_IMAGE_HXX
144 :
145 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|