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