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