1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_vcl.hxx" 30 31 #include <unx/salunx.h> 32 #include <unx/saldisp.hxx> 33 #include <unx/salbmp.h> 34 #include <unx/soicon.hxx> 35 36 #include <vcl/salbtype.hxx> 37 #include <vcl/bitmap.hxx> 38 #include <vcl/bitmapex.hxx> 39 #include <vcl/graph.hxx> 40 41 #include <svdata.hxx> 42 #include <svids.hrc> 43 #include <salbmp.hxx> 44 #include <impbmp.hxx> 45 46 47 sal_Bool SelectAppIconPixmap( SalDisplay *pDisplay, int nScreen,sal_uInt16 nIcon, sal_uInt16 iconSize, 48 Pixmap& icon_pixmap, Pixmap& icon_mask) 49 { 50 if( ! ImplGetResMgr() ) 51 return sal_False; 52 53 sal_uInt16 nIconSizeOffset; 54 55 if( iconSize >= 48 ) 56 nIconSizeOffset = SV_ICON_SIZE48_START; 57 else if( iconSize >= 32 ) 58 nIconSizeOffset = SV_ICON_SIZE32_START; 59 else if( iconSize >= 16 ) 60 nIconSizeOffset = SV_ICON_SIZE16_START; 61 else 62 return sal_False; 63 64 BitmapEx aIcon( ResId(nIconSizeOffset + nIcon, *ImplGetResMgr())); 65 if( sal_True == aIcon.IsEmpty() ) 66 return sal_False; 67 68 SalTwoRect aRect; 69 aRect.mnSrcX = 0; aRect.mnSrcY = 0; 70 aRect.mnSrcWidth = iconSize; aRect.mnSrcHeight = iconSize; 71 aRect.mnDestX = 0; aRect.mnDestY = 0; 72 aRect.mnDestWidth = iconSize; aRect.mnDestHeight = iconSize; 73 74 X11SalBitmap *pBitmap = static_cast < X11SalBitmap * > 75 (aIcon.ImplGetBitmapImpBitmap()->ImplGetSalBitmap()); 76 77 icon_pixmap = XCreatePixmap( pDisplay->GetDisplay(), 78 pDisplay->GetRootWindow( nScreen ), 79 iconSize, iconSize, 80 DefaultDepth( pDisplay->GetDisplay(), nScreen ) 81 ); 82 83 pBitmap->ImplDraw( icon_pixmap, 84 nScreen, 85 DefaultDepth( pDisplay->GetDisplay(), nScreen ), 86 aRect, 87 DefaultGC(pDisplay->GetDisplay(), nScreen ) ); 88 89 icon_mask = None; 90 91 if( TRANSPARENT_BITMAP == aIcon.GetTransparentType() ) 92 { 93 icon_mask = XCreatePixmap( pDisplay->GetDisplay(), 94 pDisplay->GetRootWindow( pDisplay->GetDefaultScreenNumber() ), 95 iconSize, iconSize, 1); 96 97 XGCValues aValues; 98 aValues.foreground = 0xffffffff; 99 aValues.background = 0; 100 aValues.function = GXcopy; 101 GC aMonoGC = XCreateGC( pDisplay->GetDisplay(), icon_mask, 102 GCFunction|GCForeground|GCBackground, &aValues ); 103 104 Bitmap aMask = aIcon.GetMask(); 105 aMask.Invert(); 106 107 X11SalBitmap *pMask = static_cast < X11SalBitmap * > 108 (aMask.ImplGetImpBitmap()->ImplGetSalBitmap()); 109 110 pMask->ImplDraw(icon_mask, nScreen, 1, aRect, aMonoGC); 111 XFreeGC( pDisplay->GetDisplay(), aMonoGC ); 112 } 113 114 return sal_True; 115 } 116 117