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 : // -----------
37 : // - Defines -
38 : // -----------
39 :
40 : #define IMAGE_STDBTN_COLOR Color( 0xC0, 0xC0, 0xC0 )
41 : #define IMAGELIST_IMAGE_NOTFOUND ((sal_uInt16)0xFFFF)
42 :
43 : // -----------------------
44 : // - ImageColorTransform -
45 : // -----------------------
46 :
47 : enum ImageColorTransform
48 : {
49 : IMAGECOLORTRANSFORM_NONE = 0,
50 : IMAGECOLORTRANSFORM_HIGHCONTRAST = 1,
51 : IMAGECOLORTRANSFORM_MONOCHROME_BLACK = 2,
52 : IMAGECOLORTRANSFORM_MONOCHROME_WHITE = 3
53 : };
54 :
55 : // ---------
56 : // - Image -
57 : // ---------
58 :
59 : class VCL_DLLPUBLIC Image
60 : {
61 : friend class ImageList;
62 : friend class OutputDevice;
63 :
64 : public:
65 : Image();
66 : Image( const ResId& rResId );
67 : Image( const Image& rImage );
68 : Image( const BitmapEx& rBitmapEx );
69 : Image( const Bitmap& rBitmap );
70 : Image( const Bitmap& rBitmap, const Bitmap& rMaskBitmap );
71 : Image( const Bitmap& rBitmap, const Color& rColor );
72 : Image( const ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >& rxGraphic );
73 : ~Image();
74 :
75 : Size GetSizePixel() const;
76 :
77 : BitmapEx GetBitmapEx() const;
78 : ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > GetXGraphic() const;
79 :
80 : Image GetColorTransformedImage( ImageColorTransform eColorTransform ) const;
81 :
82 13716 : sal_Bool operator!() const { return( !mpImplData ? true : false ); }
83 : Image& operator=( const Image& rImage );
84 : sal_Bool operator==( const Image& rImage ) const;
85 236 : sal_Bool operator!=( const Image& rImage ) const { return !(Image::operator==( rImage )); }
86 :
87 : private:
88 :
89 : ImplImage* mpImplData;
90 :
91 : SAL_DLLPRIVATE void ImplInit( const BitmapEx& rBmpEx );
92 : };
93 :
94 : // -------------
95 : // - ImageList -
96 : // -------------
97 :
98 : class VCL_DLLPUBLIC ImageList
99 : {
100 : public:
101 : ImageList( sal_uInt16 nInit = 8, sal_uInt16 nGrow = 4 );
102 : ImageList( const ResId& rResId );
103 : ImageList( const ::std::vector< ::rtl::OUString >& rNameVector,
104 : const ::rtl::OUString& rPrefix,
105 : const Color* pMaskColor = NULL );
106 : ImageList( const ImageList& rImageList );
107 : ~ImageList();
108 :
109 : void InsertFromHorizontalStrip( const BitmapEx &rBitmapEx,
110 : const std::vector< rtl::OUString > &rNameVector );
111 : void InsertFromHorizontalBitmap( const ResId& rResId,
112 : sal_uInt16 nCount,
113 : const Color *pNonAlphaMaskColor,
114 : const Color *pSearchColors = NULL,
115 : const Color *pReplaceColors = NULL,
116 : sal_uLong nColorCount = 0);
117 : BitmapEx GetAsHorizontalStrip() const;
118 : sal_uInt16 GetImageCount() const;
119 : Size GetImageSize() const;
120 :
121 : void AddImage( const ::rtl::OUString& rImageName, const Image& rImage );
122 :
123 : void ReplaceImage( const ::rtl::OUString& rImageName, const Image& rImage );
124 :
125 : void RemoveImage( sal_uInt16 nId );
126 :
127 : Image GetImage( sal_uInt16 nId ) const;
128 : Image GetImage( const ::rtl::OUString& rImageName ) const;
129 :
130 : sal_uInt16 GetImagePos( sal_uInt16 nId ) const;
131 : bool HasImageAtPos( sal_uInt16 nId ) const;
132 : sal_uInt16 GetImagePos( const ::rtl::OUString& rImageName ) const;
133 :
134 : sal_uInt16 GetImageId( sal_uInt16 nPos ) const;
135 :
136 : ::rtl::OUString GetImageName( sal_uInt16 nPos ) const;
137 : void GetImageNames( ::std::vector< ::rtl::OUString >& rNames ) const;
138 :
139 : ImageList& operator=( const ImageList& rImageList );
140 : sal_Bool operator==( const ImageList& rImageList ) const;
141 : sal_Bool operator!=( const ImageList& rImageList ) const { return !(ImageList::operator==( rImageList )); }
142 :
143 : private:
144 :
145 : ImplImageList* mpImplData;
146 : sal_uInt16 mnInitSize;
147 : sal_uInt16 mnGrowSize;
148 :
149 : SAL_DLLPRIVATE void ImplInitBitmapEx( const ::rtl::OUString& rUserImageName,
150 : const ::std::vector< ::rtl::OUString >& rImageNames,
151 : const ::rtl::OUString& rSymbolsStyle,
152 : BitmapEx& rBmpEx,
153 : const Color* pMaskColor ) const;
154 : SAL_DLLPRIVATE void ImplInit( sal_uInt16 nItems, const Size &rSize );
155 : SAL_DLLPRIVATE sal_uInt16 ImplGetImageId( const ::rtl::OUString& rImageName ) const;
156 : };
157 :
158 : #endif // _SV_IMAGE_HXX
159 :
160 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|