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 _SV_IMAGE_HXX
21 : #define _SV_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 : Image( const ResId& rResId );
55 : Image( const Image& rImage );
56 : Image( const BitmapEx& rBitmapEx );
57 : Image( const Bitmap& rBitmap );
58 : Image( const Bitmap& rBitmap, const Bitmap& rMaskBitmap );
59 : Image( const Bitmap& rBitmap, const Color& rColor );
60 : Image( const ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >& rxGraphic );
61 : ~Image();
62 :
63 : Size GetSizePixel() const;
64 :
65 : BitmapEx GetBitmapEx() const;
66 : ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > GetXGraphic() const;
67 :
68 : Image GetColorTransformedImage( ImageColorTransform eColorTransform ) const;
69 :
70 785265 : sal_Bool operator!() const { return( !mpImplData ? true : false ); }
71 : Image& operator=( const Image& rImage );
72 : sal_Bool operator==( const Image& rImage ) const;
73 937 : sal_Bool operator!=( const Image& rImage ) const { return !(Image::operator==( rImage )); }
74 :
75 : private:
76 :
77 : ImplImage* mpImplData;
78 :
79 : SAL_DLLPRIVATE void ImplInit( const BitmapEx& rBmpEx );
80 : };
81 :
82 : class VCL_DLLPUBLIC ImageList
83 : {
84 : public:
85 : ImageList( sal_uInt16 nInit = 8, sal_uInt16 nGrow = 4 );
86 : ImageList( const ResId& rResId );
87 : ImageList( const ::std::vector< OUString >& rNameVector,
88 : const OUString& rPrefix,
89 : const Color* pMaskColor = NULL );
90 : ImageList( const ImageList& rImageList );
91 : ~ImageList();
92 :
93 : void InsertFromHorizontalStrip( const BitmapEx &rBitmapEx,
94 : const std::vector< OUString > &rNameVector );
95 : void InsertFromHorizontalBitmap( const ResId& rResId,
96 : sal_uInt16 nCount,
97 : const Color *pNonAlphaMaskColor,
98 : const Color *pSearchColors = NULL,
99 : const Color *pReplaceColors = NULL,
100 : sal_uLong nColorCount = 0);
101 : BitmapEx GetAsHorizontalStrip() const;
102 : sal_uInt16 GetImageCount() const;
103 : Size GetImageSize() const;
104 :
105 : void AddImage( const OUString& rImageName, const Image& rImage );
106 : void AddImage( sal_uInt16 nNewId, 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 : sal_Bool operator==( const ImageList& rImageList ) const;
126 : sal_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 // _SV_IMAGE_HXX
144 :
145 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|