1*c82f2877SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*c82f2877SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*c82f2877SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*c82f2877SAndrew Rist * distributed with this work for additional information
6*c82f2877SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*c82f2877SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*c82f2877SAndrew Rist * "License"); you may not use this file except in compliance
9*c82f2877SAndrew Rist * with the License. You may obtain a copy of the License at
10*c82f2877SAndrew Rist *
11*c82f2877SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*c82f2877SAndrew Rist *
13*c82f2877SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*c82f2877SAndrew Rist * software distributed under the License is distributed on an
15*c82f2877SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*c82f2877SAndrew Rist * KIND, either express or implied. See the License for the
17*c82f2877SAndrew Rist * specific language governing permissions and limitations
18*c82f2877SAndrew Rist * under the License.
19*c82f2877SAndrew Rist *
20*c82f2877SAndrew Rist *************************************************************/
21*c82f2877SAndrew Rist
22*c82f2877SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_vcl.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include <unx/salunx.h>
28cdf0e10cSrcweir #include <unx/saldisp.hxx>
29cdf0e10cSrcweir #include <unx/salbmp.h>
30cdf0e10cSrcweir #include <unx/soicon.hxx>
31cdf0e10cSrcweir
32cdf0e10cSrcweir #include <vcl/salbtype.hxx>
33cdf0e10cSrcweir #include <vcl/bitmap.hxx>
34cdf0e10cSrcweir #include <vcl/bitmapex.hxx>
35cdf0e10cSrcweir #include <vcl/graph.hxx>
36cdf0e10cSrcweir
37cdf0e10cSrcweir #include <svdata.hxx>
38cdf0e10cSrcweir #include <svids.hrc>
39cdf0e10cSrcweir #include <salbmp.hxx>
40cdf0e10cSrcweir #include <impbmp.hxx>
41cdf0e10cSrcweir
42cdf0e10cSrcweir
SelectAppIconPixmap(SalDisplay * pDisplay,int nScreen,sal_uInt16 nIcon,sal_uInt16 iconSize,Pixmap & icon_pixmap,Pixmap & icon_mask)43cdf0e10cSrcweir sal_Bool SelectAppIconPixmap( SalDisplay *pDisplay, int nScreen,sal_uInt16 nIcon, sal_uInt16 iconSize,
44cdf0e10cSrcweir Pixmap& icon_pixmap, Pixmap& icon_mask)
45cdf0e10cSrcweir {
46cdf0e10cSrcweir if( ! ImplGetResMgr() )
47cdf0e10cSrcweir return sal_False;
48cdf0e10cSrcweir
49cdf0e10cSrcweir sal_uInt16 nIconSizeOffset;
50cdf0e10cSrcweir
51cdf0e10cSrcweir if( iconSize >= 48 )
52cdf0e10cSrcweir nIconSizeOffset = SV_ICON_SIZE48_START;
53cdf0e10cSrcweir else if( iconSize >= 32 )
54cdf0e10cSrcweir nIconSizeOffset = SV_ICON_SIZE32_START;
55cdf0e10cSrcweir else if( iconSize >= 16 )
56cdf0e10cSrcweir nIconSizeOffset = SV_ICON_SIZE16_START;
57cdf0e10cSrcweir else
58cdf0e10cSrcweir return sal_False;
59cdf0e10cSrcweir
60cdf0e10cSrcweir BitmapEx aIcon( ResId(nIconSizeOffset + nIcon, *ImplGetResMgr()));
61cdf0e10cSrcweir if( sal_True == aIcon.IsEmpty() )
62cdf0e10cSrcweir return sal_False;
63cdf0e10cSrcweir
64cdf0e10cSrcweir SalTwoRect aRect;
65cdf0e10cSrcweir aRect.mnSrcX = 0; aRect.mnSrcY = 0;
66cdf0e10cSrcweir aRect.mnSrcWidth = iconSize; aRect.mnSrcHeight = iconSize;
67cdf0e10cSrcweir aRect.mnDestX = 0; aRect.mnDestY = 0;
68cdf0e10cSrcweir aRect.mnDestWidth = iconSize; aRect.mnDestHeight = iconSize;
69cdf0e10cSrcweir
70cdf0e10cSrcweir X11SalBitmap *pBitmap = static_cast < X11SalBitmap * >
71cdf0e10cSrcweir (aIcon.ImplGetBitmapImpBitmap()->ImplGetSalBitmap());
72cdf0e10cSrcweir
73cdf0e10cSrcweir icon_pixmap = XCreatePixmap( pDisplay->GetDisplay(),
74cdf0e10cSrcweir pDisplay->GetRootWindow( nScreen ),
75cdf0e10cSrcweir iconSize, iconSize,
76cdf0e10cSrcweir DefaultDepth( pDisplay->GetDisplay(), nScreen )
77cdf0e10cSrcweir );
78cdf0e10cSrcweir
79cdf0e10cSrcweir pBitmap->ImplDraw( icon_pixmap,
80cdf0e10cSrcweir nScreen,
81cdf0e10cSrcweir DefaultDepth( pDisplay->GetDisplay(), nScreen ),
82cdf0e10cSrcweir aRect,
83cdf0e10cSrcweir DefaultGC(pDisplay->GetDisplay(), nScreen ) );
84cdf0e10cSrcweir
85cdf0e10cSrcweir icon_mask = None;
86cdf0e10cSrcweir
87cdf0e10cSrcweir if( TRANSPARENT_BITMAP == aIcon.GetTransparentType() )
88cdf0e10cSrcweir {
89cdf0e10cSrcweir icon_mask = XCreatePixmap( pDisplay->GetDisplay(),
90cdf0e10cSrcweir pDisplay->GetRootWindow( pDisplay->GetDefaultScreenNumber() ),
91cdf0e10cSrcweir iconSize, iconSize, 1);
92cdf0e10cSrcweir
93cdf0e10cSrcweir XGCValues aValues;
94cdf0e10cSrcweir aValues.foreground = 0xffffffff;
95cdf0e10cSrcweir aValues.background = 0;
96cdf0e10cSrcweir aValues.function = GXcopy;
97cdf0e10cSrcweir GC aMonoGC = XCreateGC( pDisplay->GetDisplay(), icon_mask,
98cdf0e10cSrcweir GCFunction|GCForeground|GCBackground, &aValues );
99cdf0e10cSrcweir
100cdf0e10cSrcweir Bitmap aMask = aIcon.GetMask();
101cdf0e10cSrcweir aMask.Invert();
102cdf0e10cSrcweir
103cdf0e10cSrcweir X11SalBitmap *pMask = static_cast < X11SalBitmap * >
104cdf0e10cSrcweir (aMask.ImplGetImpBitmap()->ImplGetSalBitmap());
105cdf0e10cSrcweir
106cdf0e10cSrcweir pMask->ImplDraw(icon_mask, nScreen, 1, aRect, aMonoGC);
107cdf0e10cSrcweir XFreeGC( pDisplay->GetDisplay(), aMonoGC );
108cdf0e10cSrcweir }
109cdf0e10cSrcweir
110cdf0e10cSrcweir return sal_True;
111cdf0e10cSrcweir }
112cdf0e10cSrcweir
113