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*953ac054Smseidel // TODO: Use the bitmap (Glue_Unselected) from markers*.png, so it will be part of the icon theme 81*953ac054Smseidel BitmapEx createDefaultGluepoint_9x9(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 95*953ac054Smseidel Bitmap aContent(Size(9, 9), 24); 96*953ac054Smseidel Bitmap aMask(Size(9, 9), 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 (!) 1073698e03bSmseidel pWContent->SetPixel(0, 0, aPixColorA); 108cdf0e10cSrcweir pWContent->SetPixel(0, 1, aPixColorA); 1093698e03bSmseidel pWContent->SetPixel(0, 2, aPixColorA); 1103698e03bSmseidel pWContent->SetPixel(0, 3, aPixColorA); 1113698e03bSmseidel pWContent->SetPixel(0, 4, aPixColorA); 112cdf0e10cSrcweir pWContent->SetPixel(0, 5, aPixColorA); 1133698e03bSmseidel pWContent->SetPixel(0, 6, aPixColorA); 114*953ac054Smseidel pWContent->SetPixel(0, 7, aPixColorA); 115*953ac054Smseidel pWContent->SetPixel(0, 8, aPixColorA); 116cdf0e10cSrcweir pWContent->SetPixel(1, 0, aPixColorA); 117cdf0e10cSrcweir pWContent->SetPixel(1, 2, aPixColorA); 1183698e03bSmseidel pWContent->SetPixel(1, 3, aPixColorA); 119cdf0e10cSrcweir pWContent->SetPixel(1, 4, aPixColorA); 120*953ac054Smseidel pWContent->SetPixel(1, 5, aPixColorA); 121cdf0e10cSrcweir pWContent->SetPixel(1, 6, aPixColorA); 122*953ac054Smseidel pWContent->SetPixel(1, 8, aPixColorA); 1233698e03bSmseidel pWContent->SetPixel(2, 0, aPixColorA); 124cdf0e10cSrcweir pWContent->SetPixel(2, 1, aPixColorA); 125cdf0e10cSrcweir pWContent->SetPixel(2, 3, aPixColorA); 126*953ac054Smseidel pWContent->SetPixel(2, 4, aPixColorA); 127cdf0e10cSrcweir pWContent->SetPixel(2, 5, aPixColorA); 128*953ac054Smseidel pWContent->SetPixel(2, 7, aPixColorA); 129*953ac054Smseidel pWContent->SetPixel(2, 8, aPixColorA); 1303698e03bSmseidel pWContent->SetPixel(3, 0, aPixColorA); 1313698e03bSmseidel pWContent->SetPixel(3, 1, aPixColorA); 132cdf0e10cSrcweir pWContent->SetPixel(3, 2, aPixColorA); 133cdf0e10cSrcweir pWContent->SetPixel(3, 4, aPixColorA); 1343698e03bSmseidel pWContent->SetPixel(3, 6, aPixColorA); 135*953ac054Smseidel pWContent->SetPixel(3, 7, aPixColorA); 136*953ac054Smseidel pWContent->SetPixel(3, 8, aPixColorA); 1373698e03bSmseidel pWContent->SetPixel(4, 0, aPixColorA); 138cdf0e10cSrcweir pWContent->SetPixel(4, 1, aPixColorA); 139*953ac054Smseidel pWContent->SetPixel(4, 2, aPixColorA); 140cdf0e10cSrcweir pWContent->SetPixel(4, 3, aPixColorA); 141cdf0e10cSrcweir pWContent->SetPixel(4, 5, aPixColorA); 1423698e03bSmseidel pWContent->SetPixel(4, 6, aPixColorA); 143*953ac054Smseidel pWContent->SetPixel(4, 7, aPixColorA); 144*953ac054Smseidel pWContent->SetPixel(4, 8, aPixColorA); 145cdf0e10cSrcweir pWContent->SetPixel(5, 0, aPixColorA); 146*953ac054Smseidel pWContent->SetPixel(5, 1, aPixColorA); 147cdf0e10cSrcweir pWContent->SetPixel(5, 2, aPixColorA); 148cdf0e10cSrcweir pWContent->SetPixel(5, 4, aPixColorA); 149cdf0e10cSrcweir pWContent->SetPixel(5, 6, aPixColorA); 150*953ac054Smseidel pWContent->SetPixel(5, 7, aPixColorA); 151*953ac054Smseidel pWContent->SetPixel(5, 8, aPixColorA); 1523698e03bSmseidel pWContent->SetPixel(6, 0, aPixColorA); 153cdf0e10cSrcweir pWContent->SetPixel(6, 1, aPixColorA); 1543698e03bSmseidel pWContent->SetPixel(6, 3, aPixColorA); 1553698e03bSmseidel pWContent->SetPixel(6, 4, aPixColorA); 156cdf0e10cSrcweir pWContent->SetPixel(6, 5, aPixColorA); 157*953ac054Smseidel pWContent->SetPixel(6, 7, aPixColorA); 158*953ac054Smseidel pWContent->SetPixel(6, 8, aPixColorA); 159*953ac054Smseidel pWContent->SetPixel(7, 0, aPixColorA); 160*953ac054Smseidel pWContent->SetPixel(7, 2, aPixColorA); 161*953ac054Smseidel pWContent->SetPixel(7, 3, aPixColorA); 162*953ac054Smseidel pWContent->SetPixel(7, 4, aPixColorA); 163*953ac054Smseidel pWContent->SetPixel(7, 5, aPixColorA); 164*953ac054Smseidel pWContent->SetPixel(7, 6, aPixColorA); 165*953ac054Smseidel pWContent->SetPixel(7, 8, aPixColorA); 166*953ac054Smseidel pWContent->SetPixel(8, 0, aPixColorA); 167*953ac054Smseidel pWContent->SetPixel(8, 1, aPixColorA); 168*953ac054Smseidel pWContent->SetPixel(8, 2, aPixColorA); 169*953ac054Smseidel pWContent->SetPixel(8, 3, aPixColorA); 170*953ac054Smseidel pWContent->SetPixel(8, 4, aPixColorA); 171*953ac054Smseidel pWContent->SetPixel(8, 5, aPixColorA); 172*953ac054Smseidel pWContent->SetPixel(8, 6, aPixColorA); 173*953ac054Smseidel pWContent->SetPixel(8, 7, aPixColorA); 174*953ac054Smseidel pWContent->SetPixel(8, 8, aPixColorA); 175cdf0e10cSrcweir 176cdf0e10cSrcweir pWContent->SetPixel(1, 1, aPixColorB); 177*953ac054Smseidel pWContent->SetPixel(1, 7, aPixColorB); 178cdf0e10cSrcweir pWContent->SetPixel(2, 2, aPixColorB); 179*953ac054Smseidel pWContent->SetPixel(2, 6, aPixColorB); 180cdf0e10cSrcweir pWContent->SetPixel(3, 3, aPixColorB); 181*953ac054Smseidel pWContent->SetPixel(3, 5, aPixColorB); 182cdf0e10cSrcweir pWContent->SetPixel(4, 4, aPixColorB); 183*953ac054Smseidel pWContent->SetPixel(5, 3, aPixColorB); 184cdf0e10cSrcweir pWContent->SetPixel(5, 5, aPixColorB); 185*953ac054Smseidel pWContent->SetPixel(6, 2, aPixColorB); 186*953ac054Smseidel pWContent->SetPixel(6, 6, aPixColorB); 187*953ac054Smseidel pWContent->SetPixel(7, 1, aPixColorB); 188*953ac054Smseidel pWContent->SetPixel(7, 7, aPixColorB); 189cdf0e10cSrcweir 190cdf0e10cSrcweir aContent.ReleaseAccess(pWContent); 191cdf0e10cSrcweir aMask.ReleaseAccess(pWMask); 192cdf0e10cSrcweir 193cdf0e10cSrcweir // create and exchange at aRetVal 194cdf0e10cSrcweir delete aRetVal.set(new BitmapEx(aContent, aMask)); 195cdf0e10cSrcweir } 196cdf0e10cSrcweir 197cdf0e10cSrcweir return aRetVal.get() ? *aRetVal.get() : BitmapEx(); 198cdf0e10cSrcweir } 199cdf0e10cSrcweir 200cdf0e10cSrcweir } // end of namespace primitive2d 201cdf0e10cSrcweir } // end of namespace drawinglayer 202cdf0e10cSrcweir 203cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 204cdf0e10cSrcweir // eof 205