1*2123d757SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*2123d757SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*2123d757SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*2123d757SAndrew Rist * distributed with this work for additional information 6*2123d757SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*2123d757SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*2123d757SAndrew Rist * "License"); you may not use this file except in compliance 9*2123d757SAndrew Rist * with the License. You may obtain a copy of the License at 10*2123d757SAndrew Rist * 11*2123d757SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*2123d757SAndrew Rist * 13*2123d757SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*2123d757SAndrew Rist * software distributed under the License is distributed on an 15*2123d757SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*2123d757SAndrew Rist * KIND, either express or implied. See the License for the 17*2123d757SAndrew Rist * specific language governing permissions and limitations 18*2123d757SAndrew Rist * under the License. 19*2123d757SAndrew Rist * 20*2123d757SAndrew Rist *************************************************************/ 21*2123d757SAndrew Rist 22*2123d757SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef _SV_IMAGE_H 25cdf0e10cSrcweir #define _SV_IMAGE_H 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <vcl/bitmapex.hxx> 28cdf0e10cSrcweir 29cdf0e10cSrcweir #include <hash_map> 30cdf0e10cSrcweir 31cdf0e10cSrcweir // ---------------- 32cdf0e10cSrcweir // - ImplImageBmp - 33cdf0e10cSrcweir // ---------------- 34cdf0e10cSrcweir 35cdf0e10cSrcweir class ImplImageBmp 36cdf0e10cSrcweir { 37cdf0e10cSrcweir public: 38cdf0e10cSrcweir 39cdf0e10cSrcweir ImplImageBmp(); 40cdf0e10cSrcweir ~ImplImageBmp(); 41cdf0e10cSrcweir 42cdf0e10cSrcweir void Create( long nItemWidth, long nItemHeight, sal_uInt16 nInitSize ); 43cdf0e10cSrcweir void Create( const BitmapEx& rBmpEx, long nItemWidth, long nItemHeight,sal_uInt16 nInitSize ); 44cdf0e10cSrcweir 45cdf0e10cSrcweir void Expand( sal_uInt16 nGrowSize ); 46cdf0e10cSrcweir 47cdf0e10cSrcweir void Replace( sal_uInt16 nPos, sal_uInt16 nSrcPos ); 48cdf0e10cSrcweir void Replace( sal_uInt16 nPos, const ImplImageBmp& rImageBmp, sal_uInt16 nSrcPos ); 49cdf0e10cSrcweir void Replace( sal_uInt16 nPos, const BitmapEx& rBmpEx ); 50cdf0e10cSrcweir 51cdf0e10cSrcweir void ReplaceColors( const Color* pSrcColors, const Color* pDstColors, sal_uIntPtr nColorCount ); 52cdf0e10cSrcweir void ColorTransform( BmpColorMode eColorMode ); 53cdf0e10cSrcweir void Invert(); 54cdf0e10cSrcweir 55cdf0e10cSrcweir BitmapEx GetBitmapEx( sal_uInt16 nPosCount, sal_uInt16* pPosAry ) const; 56cdf0e10cSrcweir 57cdf0e10cSrcweir void Draw( sal_uInt16 nPos, OutputDevice* pDev, const Point& rPos, sal_uInt16 nStyle, const Size* pSize = NULL ); 58cdf0e10cSrcweir 59cdf0e10cSrcweir private: 60cdf0e10cSrcweir 61cdf0e10cSrcweir BitmapEx maBmpEx; 62cdf0e10cSrcweir BitmapEx maDisabledBmpEx; 63cdf0e10cSrcweir BitmapEx* mpDisplayBmp; 64cdf0e10cSrcweir Size maSize; 65cdf0e10cSrcweir sal_uInt8* mpInfoAry; 66cdf0e10cSrcweir sal_uInt16 mnSize; 67cdf0e10cSrcweir 68cdf0e10cSrcweir void ImplUpdateDisplayBmp( OutputDevice* pOutDev ); 69cdf0e10cSrcweir void ImplUpdateDisabledBmpEx( int nPos ); 70cdf0e10cSrcweir 71cdf0e10cSrcweir private: // prevent assignment and copy construction 72cdf0e10cSrcweir ImplImageBmp( const ImplImageBmp& ); 73cdf0e10cSrcweir void operator=( const ImplImageBmp& ); 74cdf0e10cSrcweir }; 75cdf0e10cSrcweir 76cdf0e10cSrcweir // -------------- 77cdf0e10cSrcweir // - ImageTypes - 78cdf0e10cSrcweir // -------------- 79cdf0e10cSrcweir 80cdf0e10cSrcweir enum ImageType { IMAGETYPE_BITMAP, IMAGETYPE_IMAGE }; 81cdf0e10cSrcweir 82cdf0e10cSrcweir // ----------------- 83cdf0e10cSrcweir // - ImplImageList - 84cdf0e10cSrcweir // ----------------- 85cdf0e10cSrcweir 86cdf0e10cSrcweir struct ImageAryData 87cdf0e10cSrcweir { 88cdf0e10cSrcweir ::rtl::OUString maName; 89cdf0e10cSrcweir // Images identified by either name, or by id 90cdf0e10cSrcweir sal_uInt16 mnId; 91cdf0e10cSrcweir BitmapEx maBitmapEx; 92cdf0e10cSrcweir 93cdf0e10cSrcweir ImageAryData(); 94cdf0e10cSrcweir ImageAryData( const rtl::OUString &aName, 95cdf0e10cSrcweir sal_uInt16 nId, const BitmapEx &aBitmap ); 96cdf0e10cSrcweir ImageAryData( const ImageAryData& rData ); 97cdf0e10cSrcweir ~ImageAryData(); 98cdf0e10cSrcweir IsLoadableImageAryData99cdf0e10cSrcweir bool IsLoadable() { return maBitmapEx.IsEmpty() && maName.getLength(); } 100cdf0e10cSrcweir void Load(const rtl::OUString &rPrefix); 101cdf0e10cSrcweir 102cdf0e10cSrcweir ImageAryData& operator=( const ImageAryData& rData ); 103cdf0e10cSrcweir }; 104cdf0e10cSrcweir 105cdf0e10cSrcweir // ------------------------------------------------------------------------------ 106cdf0e10cSrcweir 107cdf0e10cSrcweir struct ImplImageList 108cdf0e10cSrcweir { 109cdf0e10cSrcweir typedef std::vector<ImageAryData *> ImageAryDataVec; 110cdf0e10cSrcweir typedef std::hash_map< rtl::OUString, ImageAryData *, rtl::OUStringHash > 111cdf0e10cSrcweir ImageAryDataNameHash; 112cdf0e10cSrcweir 113cdf0e10cSrcweir ImageAryDataVec maImages; 114cdf0e10cSrcweir ImageAryDataNameHash maNameHash; 115cdf0e10cSrcweir rtl::OUString maPrefix; 116cdf0e10cSrcweir Size maImageSize; 117cdf0e10cSrcweir sal_uIntPtr mnRefCount; 118cdf0e10cSrcweir 119cdf0e10cSrcweir ImplImageList(); 120cdf0e10cSrcweir ImplImageList( const ImplImageList &aSrc ); 121cdf0e10cSrcweir ~ImplImageList(); 122cdf0e10cSrcweir 123cdf0e10cSrcweir void AddImage( const ::rtl::OUString &aName, 124cdf0e10cSrcweir sal_uInt16 nId, const BitmapEx &aBitmapEx ); 125cdf0e10cSrcweir void RemoveImage( sal_uInt16 nPos ); 126cdf0e10cSrcweir sal_uInt16 GetImageCount() const; 127cdf0e10cSrcweir }; 128cdf0e10cSrcweir 129cdf0e10cSrcweir // -------------------- 130cdf0e10cSrcweir // - ImplImageRefData - 131cdf0e10cSrcweir // -------------------- 132cdf0e10cSrcweir 133cdf0e10cSrcweir struct ImplImageRefData 134cdf0e10cSrcweir { 135cdf0e10cSrcweir ImplImageList* mpImplData; 136cdf0e10cSrcweir sal_uInt16 mnIndex; 137cdf0e10cSrcweir ImplImageRefDataImplImageRefData138cdf0e10cSrcweir ImplImageRefData() {} // Um Warning zu umgehen 139cdf0e10cSrcweir ~ImplImageRefData(); 140cdf0e10cSrcweir 141cdf0e10cSrcweir sal_Bool IsEqual( const ImplImageRefData& rData ); 142cdf0e10cSrcweir }; 143cdf0e10cSrcweir 144cdf0e10cSrcweir // ---------------- 145cdf0e10cSrcweir // - ImpImageData - 146cdf0e10cSrcweir // ---------------- 147cdf0e10cSrcweir 148cdf0e10cSrcweir struct ImplImageData 149cdf0e10cSrcweir { 150cdf0e10cSrcweir ImplImageBmp* mpImageBitmap; 151cdf0e10cSrcweir BitmapEx maBmpEx; 152cdf0e10cSrcweir 153cdf0e10cSrcweir ImplImageData( const BitmapEx& rBmpEx ); 154cdf0e10cSrcweir ~ImplImageData(); 155cdf0e10cSrcweir 156cdf0e10cSrcweir sal_Bool IsEqual( const ImplImageData& rData ); 157cdf0e10cSrcweir }; 158cdf0e10cSrcweir 159cdf0e10cSrcweir // ------------- 160cdf0e10cSrcweir // - ImplImage - 161cdf0e10cSrcweir // ------------- 162cdf0e10cSrcweir 163cdf0e10cSrcweir struct ImplImage 164cdf0e10cSrcweir { 165cdf0e10cSrcweir sal_uIntPtr mnRefCount; 166cdf0e10cSrcweir // TODO: use inheritance to get rid of meType+mpData 167cdf0e10cSrcweir void* mpData; 168cdf0e10cSrcweir ImageType meType; 169cdf0e10cSrcweir 170cdf0e10cSrcweir ImplImage(); 171cdf0e10cSrcweir ~ImplImage(); 172cdf0e10cSrcweir 173cdf0e10cSrcweir private: // prevent assignment and copy construction 174cdf0e10cSrcweir ImplImage( const ImplImage&); 175cdf0e10cSrcweir void operator=( const ImplImage&); 176cdf0e10cSrcweir }; 177cdf0e10cSrcweir 178cdf0e10cSrcweir #endif // _SV_IMAGE_H 179