1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: soicon.cxx,v $
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"
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>
43 #include <vcl/graph.hxx>
45 #include <vcl/svdata.hxx>
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() )
55 USHORT nIconSizeOffset
;
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
;
66 BitmapEx
aIcon( ResId(nIconSizeOffset
+ nIcon
, *ImplGetResMgr()));
67 if( TRUE
== aIcon
.IsEmpty() )
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
),
82 DefaultDepth( pDisplay
->GetDisplay(), nScreen
)
85 pBitmap
->ImplDraw( icon_pixmap
,
87 DefaultDepth( pDisplay
->GetDisplay(), nScreen
),
89 DefaultGC(pDisplay
->GetDisplay(), nScreen
) );
93 if( TRANSPARENT_BITMAP
== aIcon
.GetTransparentType() )
95 icon_mask
= XCreatePixmap( pDisplay
->GetDisplay(),
96 pDisplay
->GetRootWindow( pDisplay
->GetDefaultScreenNumber() ),
97 iconSize
, iconSize
, 1);
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();
109 X11SalBitmap
*pMask
= static_cast < X11SalBitmap
* >
110 (aMask
.ImplGetImpBitmap()->ImplGetSalBitmap());
112 pMask
->ImplDraw(icon_mask
, nScreen
, 1, aRect
, aMonoGC
);
113 XFreeGC( pDisplay
->GetDisplay(), aMonoGC
);