1f6e50924SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3f6e50924SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4f6e50924SAndrew Rist * or more contributor license agreements. See the NOTICE file 5f6e50924SAndrew Rist * distributed with this work for additional information 6f6e50924SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7f6e50924SAndrew Rist * to you under the Apache License, Version 2.0 (the 8f6e50924SAndrew Rist * "License"); you may not use this file except in compliance 9f6e50924SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11f6e50924SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13f6e50924SAndrew Rist * Unless required by applicable law or agreed to in writing, 14f6e50924SAndrew Rist * software distributed under the License is distributed on an 15f6e50924SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16f6e50924SAndrew Rist * KIND, either express or implied. See the License for the 17f6e50924SAndrew Rist * specific language governing permissions and limitations 18f6e50924SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20f6e50924SAndrew Rist *************************************************************/ 21f6e50924SAndrew Rist 22f6e50924SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #include "precompiled_svx.hxx" 25cdf0e10cSrcweir #include <svx/sdr/primitive2d/sdrprimitivetools.hxx> 26cdf0e10cSrcweir #include <vcl/bmpacc.hxx> 27cdf0e10cSrcweir #include <osl/mutex.hxx> 28cdf0e10cSrcweir #include <vcl/lazydelete.hxx> 29cdf0e10cSrcweir 30cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 31cdf0e10cSrcweir // helper methods 32cdf0e10cSrcweir 33cdf0e10cSrcweir namespace drawinglayer 34cdf0e10cSrcweir { 35cdf0e10cSrcweir namespace primitive2d 36cdf0e10cSrcweir { 37cdf0e10cSrcweir BitmapEx createDefaultCross_3x3(const basegfx::BColor& rBColor) 38cdf0e10cSrcweir { 39cdf0e10cSrcweir static vcl::DeleteOnDeinit< BitmapEx > aRetVal(0); 40cdf0e10cSrcweir static basegfx::BColor aColor; 41cdf0e10cSrcweir ::osl::Mutex m_mutex; 42cdf0e10cSrcweir 43cdf0e10cSrcweir if(!aRetVal.get() || rBColor != aColor) 44cdf0e10cSrcweir { 45cdf0e10cSrcweir // copy values 46cdf0e10cSrcweir aColor = rBColor; 47cdf0e10cSrcweir 48cdf0e10cSrcweir // create bitmap 49cdf0e10cSrcweir Bitmap aContent(Size(3, 3), 24); 50cdf0e10cSrcweir Bitmap aMask(Size(3, 3), 1); 51cdf0e10cSrcweir BitmapWriteAccess* pWContent = aContent.AcquireWriteAccess(); 52cdf0e10cSrcweir BitmapWriteAccess* pWMask = aMask.AcquireWriteAccess(); 53cdf0e10cSrcweir OSL_ENSURE(pWContent && pWMask, "No WriteAccess to bitmap (!)"); 54cdf0e10cSrcweir const Color aVCLColor(aColor); 55cdf0e10cSrcweir const BitmapColor aPixColor(aVCLColor); 56cdf0e10cSrcweir const BitmapColor aMaskColor(0x01); 57cdf0e10cSrcweir 58cdf0e10cSrcweir // Y,X unusual order (!) 59cdf0e10cSrcweir pWContent->SetPixel(0, 1, aPixColor); 60cdf0e10cSrcweir pWContent->SetPixel(1, 0, aPixColor); 61cdf0e10cSrcweir pWContent->SetPixel(1, 1, aPixColor); 62cdf0e10cSrcweir pWContent->SetPixel(1, 2, aPixColor); 63cdf0e10cSrcweir pWContent->SetPixel(2, 1, aPixColor); 64cdf0e10cSrcweir 65cdf0e10cSrcweir pWMask->SetPixel(0, 0, aMaskColor); 66cdf0e10cSrcweir pWMask->SetPixel(0, 2, aMaskColor); 67cdf0e10cSrcweir pWMask->SetPixel(2, 0, aMaskColor); 68cdf0e10cSrcweir pWMask->SetPixel(2, 2, aMaskColor); 69cdf0e10cSrcweir 70cdf0e10cSrcweir aContent.ReleaseAccess(pWContent); 71cdf0e10cSrcweir aMask.ReleaseAccess(pWMask); 72cdf0e10cSrcweir 73cdf0e10cSrcweir // create and exchange at aRetVal 74cdf0e10cSrcweir delete aRetVal.set(new BitmapEx(aContent, aMask)); 75cdf0e10cSrcweir } 76cdf0e10cSrcweir 77cdf0e10cSrcweir return aRetVal.get() ? *aRetVal.get() : BitmapEx(); 78cdf0e10cSrcweir } 79cdf0e10cSrcweir 80*b593925bSmseidel // TODO: Move this bitmap to markers*.png, so it will be part of the icon theme 81cdf0e10cSrcweir BitmapEx createDefaultGluepoint_7x7(const basegfx::BColor& rBColorA, const basegfx::BColor& rBColorB) 82cdf0e10cSrcweir { 83cdf0e10cSrcweir static vcl::DeleteOnDeinit< BitmapEx > aRetVal(0); 84cdf0e10cSrcweir static basegfx::BColor aColorA; 85cdf0e10cSrcweir static basegfx::BColor aColorB; 86cdf0e10cSrcweir ::osl::Mutex m_mutex; 87cdf0e10cSrcweir 88cdf0e10cSrcweir if(!aRetVal.get() || rBColorA != aColorA || rBColorB != aColorB) 89cdf0e10cSrcweir { 90cdf0e10cSrcweir // copy values 91cdf0e10cSrcweir aColorA = rBColorA; 92cdf0e10cSrcweir aColorB = rBColorB; 93cdf0e10cSrcweir 94cdf0e10cSrcweir // create bitmap 95cdf0e10cSrcweir Bitmap aContent(Size(7, 7), 24); 96cdf0e10cSrcweir Bitmap aMask(Size(7, 7), 1); 97cdf0e10cSrcweir BitmapWriteAccess* pWContent = aContent.AcquireWriteAccess(); 98cdf0e10cSrcweir BitmapWriteAccess* pWMask = aMask.AcquireWriteAccess(); 99cdf0e10cSrcweir OSL_ENSURE(pWContent && pWMask, "No WriteAccess to bitmap (!)"); 100cdf0e10cSrcweir const Color aColA(aColorA); 101cdf0e10cSrcweir const Color aColB(aColorB); 102cdf0e10cSrcweir const BitmapColor aPixColorA(aColA); 103cdf0e10cSrcweir const BitmapColor aPixColorB(aColB); 104cdf0e10cSrcweir const BitmapColor aMaskColor(0x01); 105cdf0e10cSrcweir 106cdf0e10cSrcweir // Y,X unusual order (!) 107*b593925bSmseidel pWContent->SetPixel(0, 0, aPixColorA); 108cdf0e10cSrcweir pWContent->SetPixel(0, 1, aPixColorA); 109*b593925bSmseidel pWContent->SetPixel(0, 2, aPixColorA); 110*b593925bSmseidel pWContent->SetPixel(0, 3, aPixColorA); 111*b593925bSmseidel pWContent->SetPixel(0, 4, aPixColorA); 112cdf0e10cSrcweir pWContent->SetPixel(0, 5, aPixColorA); 113*b593925bSmseidel pWContent->SetPixel(0, 6, aPixColorA); 114cdf0e10cSrcweir pWContent->SetPixel(1, 0, aPixColorA); 115cdf0e10cSrcweir pWContent->SetPixel(1, 2, aPixColorA); 116*b593925bSmseidel pWContent->SetPixel(1, 3, aPixColorA); 117cdf0e10cSrcweir pWContent->SetPixel(1, 4, aPixColorA); 118cdf0e10cSrcweir pWContent->SetPixel(1, 6, aPixColorA); 119*b593925bSmseidel pWContent->SetPixel(2, 0, aPixColorA); 120cdf0e10cSrcweir pWContent->SetPixel(2, 1, aPixColorA); 121cdf0e10cSrcweir pWContent->SetPixel(2, 3, aPixColorA); 122cdf0e10cSrcweir pWContent->SetPixel(2, 5, aPixColorA); 123*b593925bSmseidel pWContent->SetPixel(2, 6, aPixColorA); 124*b593925bSmseidel pWContent->SetPixel(3, 0, aPixColorA); 125*b593925bSmseidel pWContent->SetPixel(3, 1, aPixColorA); 126cdf0e10cSrcweir pWContent->SetPixel(3, 2, aPixColorA); 127cdf0e10cSrcweir pWContent->SetPixel(3, 4, aPixColorA); 128*b593925bSmseidel pWContent->SetPixel(3, 5, aPixColorA); 129*b593925bSmseidel pWContent->SetPixel(3, 6, aPixColorA); 130*b593925bSmseidel pWContent->SetPixel(4, 0, aPixColorA); 131cdf0e10cSrcweir pWContent->SetPixel(4, 1, aPixColorA); 132cdf0e10cSrcweir pWContent->SetPixel(4, 3, aPixColorA); 133cdf0e10cSrcweir pWContent->SetPixel(4, 5, aPixColorA); 134*b593925bSmseidel pWContent->SetPixel(4, 6, aPixColorA); 135cdf0e10cSrcweir pWContent->SetPixel(5, 0, aPixColorA); 136cdf0e10cSrcweir pWContent->SetPixel(5, 2, aPixColorA); 137*b593925bSmseidel pWContent->SetPixel(5, 3, aPixColorA); 138cdf0e10cSrcweir pWContent->SetPixel(5, 4, aPixColorA); 139cdf0e10cSrcweir pWContent->SetPixel(5, 6, aPixColorA); 140*b593925bSmseidel pWContent->SetPixel(6, 0, aPixColorA); 141cdf0e10cSrcweir pWContent->SetPixel(6, 1, aPixColorA); 142*b593925bSmseidel pWContent->SetPixel(6, 2, aPixColorA); 143*b593925bSmseidel pWContent->SetPixel(6, 3, aPixColorA); 144*b593925bSmseidel pWContent->SetPixel(6, 4, aPixColorA); 145cdf0e10cSrcweir pWContent->SetPixel(6, 5, aPixColorA); 146*b593925bSmseidel pWContent->SetPixel(6, 6, aPixColorA); 147cdf0e10cSrcweir 148cdf0e10cSrcweir pWContent->SetPixel(1, 1, aPixColorB); 149cdf0e10cSrcweir pWContent->SetPixel(1, 5, aPixColorB); 150cdf0e10cSrcweir pWContent->SetPixel(2, 2, aPixColorB); 151cdf0e10cSrcweir pWContent->SetPixel(2, 4, aPixColorB); 152cdf0e10cSrcweir pWContent->SetPixel(3, 3, aPixColorB); 153cdf0e10cSrcweir pWContent->SetPixel(4, 2, aPixColorB); 154cdf0e10cSrcweir pWContent->SetPixel(4, 4, aPixColorB); 155cdf0e10cSrcweir pWContent->SetPixel(5, 1, aPixColorB); 156cdf0e10cSrcweir pWContent->SetPixel(5, 5, aPixColorB); 157cdf0e10cSrcweir 158cdf0e10cSrcweir aContent.ReleaseAccess(pWContent); 159cdf0e10cSrcweir aMask.ReleaseAccess(pWMask); 160cdf0e10cSrcweir 161cdf0e10cSrcweir // create and exchange at aRetVal 162cdf0e10cSrcweir delete aRetVal.set(new BitmapEx(aContent, aMask)); 163cdf0e10cSrcweir } 164cdf0e10cSrcweir 165cdf0e10cSrcweir return aRetVal.get() ? *aRetVal.get() : BitmapEx(); 166cdf0e10cSrcweir } 167cdf0e10cSrcweir 168cdf0e10cSrcweir } // end of namespace primitive2d 169cdf0e10cSrcweir } // end of namespace drawinglayer 170cdf0e10cSrcweir 171cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 172cdf0e10cSrcweir // eof 173