diff options
author | Tor Lillqvist <tml@iki.fi> | 2013-04-10 20:50:12 +0300 |
---|---|---|
committer | Tor Lillqvist <tml@iki.fi> | 2013-04-10 21:00:44 +0300 |
commit | 1382dad9d244bf437cd9cd181eb708bdaaca3539 (patch) | |
tree | 6ac0e91e27207fab3a795d26384ffcc441ba7b4f | |
parent | 8b7da751fd6ada77980b13745f9b276c311e0963 (diff) |
Minor refactoring: Move a function to the only file where it is used
Change-Id: I98f1eda871eb36cdf61e003d046395698dcdad18
-rw-r--r-- | vcl/Library_vclplug_gen.mk | 1 | ||||
-rw-r--r-- | vcl/inc/unx/soicon.hxx | 33 | ||||
-rw-r--r-- | vcl/unx/generic/app/soicon.cxx | 110 | ||||
-rw-r--r-- | vcl/unx/generic/window/salframe.cxx | 98 |
4 files changed, 87 insertions, 155 deletions
diff --git a/vcl/Library_vclplug_gen.mk b/vcl/Library_vclplug_gen.mk index 5bef1439ffa3..f3c6d7df7e01 100644 --- a/vcl/Library_vclplug_gen.mk +++ b/vcl/Library_vclplug_gen.mk @@ -73,7 +73,6 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_gen,\ vcl/unx/generic/app/salinst \ vcl/unx/generic/app/saltimer \ vcl/unx/generic/app/sm \ - vcl/unx/generic/app/soicon \ vcl/unx/generic/app/wmadaptor \ vcl/unx/generic/dtrans/bmp \ vcl/unx/generic/dtrans/config \ diff --git a/vcl/inc/unx/soicon.hxx b/vcl/inc/unx/soicon.hxx deleted file mode 100644 index 1f7f31a2e8a9..000000000000 --- a/vcl/inc/unx/soicon.hxx +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ -#ifndef _SV_SOICON_HXX -#define _SV_SOICON_HXX - -#include <unx/saltype.h> - -class SalDisplay; -class SalBitmap; -class Bitmap; - -sal_Bool SelectAppIconPixmap( SalDisplay *pDisplay, SalX11Screen nScreen, - sal_uInt16 nIcon, sal_uInt16 iconSize, - Pixmap& icon_pixmap, Pixmap& icon_mask ); -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/generic/app/soicon.cxx b/vcl/unx/generic/app/soicon.cxx deleted file mode 100644 index e08d98f4bdb7..000000000000 --- a/vcl/unx/generic/app/soicon.cxx +++ /dev/null @@ -1,110 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - - -#include <unx/salunx.h> -#include <unx/saldisp.hxx> -#include <unx/salbmp.h> -#include <unx/soicon.hxx> - -#include <vcl/bitmap.hxx> -#include <vcl/bitmapex.hxx> -#include <vcl/graph.hxx> - -#include <svdata.hxx> -#include <svids.hrc> -#include <salbmp.hxx> -#include <impbmp.hxx> - - -sal_Bool SelectAppIconPixmap( SalDisplay *pDisplay, SalX11Screen nXScreen, - sal_uInt16 nIcon, sal_uInt16 iconSize, - Pixmap& icon_pixmap, Pixmap& icon_mask) -{ - if( ! ImplGetResMgr() ) - return sal_False; - - sal_uInt16 nIconSizeOffset; - - if( iconSize >= 48 ) - nIconSizeOffset = SV_ICON_SIZE48_START; - else if( iconSize >= 32 ) - nIconSizeOffset = SV_ICON_SIZE32_START; - else if( iconSize >= 16 ) - nIconSizeOffset = SV_ICON_SIZE16_START; - else - return sal_False; - - BitmapEx aIcon( ResId(nIconSizeOffset + nIcon, *ImplGetResMgr())); - if( sal_True == aIcon.IsEmpty() ) - return sal_False; - - SalTwoRect aRect; - aRect.mnSrcX = 0; aRect.mnSrcY = 0; - aRect.mnSrcWidth = iconSize; aRect.mnSrcHeight = iconSize; - aRect.mnDestX = 0; aRect.mnDestY = 0; - aRect.mnDestWidth = iconSize; aRect.mnDestHeight = iconSize; - - X11SalBitmap *pBitmap = static_cast < X11SalBitmap * > - (aIcon.ImplGetBitmapImpBitmap()->ImplGetSalBitmap()); - - icon_pixmap = XCreatePixmap( pDisplay->GetDisplay(), - pDisplay->GetRootWindow( nXScreen ), - iconSize, iconSize, - DefaultDepth( pDisplay->GetDisplay(), - nXScreen.getXScreen() ) - ); - - pBitmap->ImplDraw( icon_pixmap, - nXScreen, - DefaultDepth( pDisplay->GetDisplay(), - nXScreen.getXScreen() ), - aRect, - DefaultGC( pDisplay->GetDisplay(), - nXScreen.getXScreen() ) ); - - icon_mask = None; - - if( TRANSPARENT_BITMAP == aIcon.GetTransparentType() ) - { - icon_mask = XCreatePixmap( pDisplay->GetDisplay(), - pDisplay->GetRootWindow( pDisplay->GetDefaultXScreen() ), - iconSize, iconSize, 1); - - XGCValues aValues; - aValues.foreground = 0xffffffff; - aValues.background = 0; - aValues.function = GXcopy; - GC aMonoGC = XCreateGC( pDisplay->GetDisplay(), icon_mask, - GCFunction|GCForeground|GCBackground, &aValues ); - - Bitmap aMask = aIcon.GetMask(); - aMask.Invert(); - - X11SalBitmap *pMask = static_cast < X11SalBitmap * > - (aMask.ImplGetImpBitmap()->ImplGetSalBitmap()); - - pMask->ImplDraw(icon_mask, nXScreen, 1, aRect, aMonoGC); - XFreeGC( pDisplay->GetDisplay(), aMonoGC ); - } - - return sal_True; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/generic/window/salframe.cxx b/vcl/unx/generic/window/salframe.cxx index ec482e7801e2..294a39258f1e 100644 --- a/vcl/unx/generic/window/salframe.cxx +++ b/vcl/unx/generic/window/salframe.cxx @@ -50,7 +50,6 @@ #include "unx/saldisp.hxx" #include "unx/salgdi.h" #include "unx/salframe.h" -#include "unx/soicon.hxx" #include "unx/sm.hxx" #include "unx/wmadaptor.hxx" #include "generic/genprn.h" @@ -66,6 +65,9 @@ #include <sal/macros.h> #include <com/sun/star/uno/Exception.hpp> +#include "svids.hrc" +#include "impbmp.hxx" + #include <algorithm> #ifndef Button6 @@ -191,6 +193,80 @@ void X11SalFrame::askForXEmbedFocus( sal_Int32 i_nTimeCode ) GetGenericData()->ErrorTrapPop(); } +static sal_Bool lcl_SelectAppIconPixmap( SalDisplay *pDisplay, SalX11Screen nXScreen, + sal_uInt16 nIcon, sal_uInt16 iconSize, + Pixmap& icon_pixmap, Pixmap& icon_mask) +{ + if( ! ImplGetResMgr() ) + return sal_False; + + sal_uInt16 nIconSizeOffset; + + if( iconSize >= 48 ) + nIconSizeOffset = SV_ICON_SIZE48_START; + else if( iconSize >= 32 ) + nIconSizeOffset = SV_ICON_SIZE32_START; + else if( iconSize >= 16 ) + nIconSizeOffset = SV_ICON_SIZE16_START; + else + return sal_False; + + BitmapEx aIcon( ResId(nIconSizeOffset + nIcon, *ImplGetResMgr())); + if( sal_True == aIcon.IsEmpty() ) + return sal_False; + + SalTwoRect aRect; + aRect.mnSrcX = 0; aRect.mnSrcY = 0; + aRect.mnSrcWidth = iconSize; aRect.mnSrcHeight = iconSize; + aRect.mnDestX = 0; aRect.mnDestY = 0; + aRect.mnDestWidth = iconSize; aRect.mnDestHeight = iconSize; + + X11SalBitmap *pBitmap = static_cast < X11SalBitmap * > + (aIcon.ImplGetBitmapImpBitmap()->ImplGetSalBitmap()); + + icon_pixmap = XCreatePixmap( pDisplay->GetDisplay(), + pDisplay->GetRootWindow( nXScreen ), + iconSize, iconSize, + DefaultDepth( pDisplay->GetDisplay(), + nXScreen.getXScreen() ) + ); + + pBitmap->ImplDraw( icon_pixmap, + nXScreen, + DefaultDepth( pDisplay->GetDisplay(), + nXScreen.getXScreen() ), + aRect, + DefaultGC( pDisplay->GetDisplay(), + nXScreen.getXScreen() ) ); + + icon_mask = None; + + if( TRANSPARENT_BITMAP == aIcon.GetTransparentType() ) + { + icon_mask = XCreatePixmap( pDisplay->GetDisplay(), + pDisplay->GetRootWindow( pDisplay->GetDefaultXScreen() ), + iconSize, iconSize, 1); + + XGCValues aValues; + aValues.foreground = 0xffffffff; + aValues.background = 0; + aValues.function = GXcopy; + GC aMonoGC = XCreateGC( pDisplay->GetDisplay(), icon_mask, + GCFunction|GCForeground|GCBackground, &aValues ); + + Bitmap aMask = aIcon.GetMask(); + aMask.Invert(); + + X11SalBitmap *pMask = static_cast < X11SalBitmap * > + (aMask.ImplGetImpBitmap()->ImplGetSalBitmap()); + + pMask->ImplDraw(icon_mask, nXScreen, 1, aRect, aMonoGC); + XFreeGC( pDisplay->GetDisplay(), aMonoGC ); + } + + return sal_True; +} + void X11SalFrame::Init( sal_uLong nSalFrameStyle, SalX11Screen nXScreen, SystemParentData* pParentData, bool bUseGeometry ) { if( nXScreen.getXScreen() >= GetDisplay()->GetXScreenCount() ) @@ -401,10 +477,10 @@ void X11SalFrame::Init( sal_uLong nSalFrameStyle, SalX11Screen nXScreen, SystemP bool bOk=false; try { - bOk=SelectAppIconPixmap( pDisplay_, m_nXScreen, - mnIconID != 1 ? mnIconID : - (mpParent ? mpParent->mnIconID : 1), 32, - Hints.icon_pixmap, Hints.icon_mask ); + bOk = lcl_SelectAppIconPixmap( pDisplay_, m_nXScreen, + mnIconID != 1 ? mnIconID : + (mpParent ? mpParent->mnIconID : 1), 32, + Hints.icon_pixmap, Hints.icon_mask ); } catch( com::sun::star::uno::Exception& ) { @@ -931,15 +1007,15 @@ void X11SalFrame::SetIcon( sal_uInt16 nIcon ) } pHints = &Hints; - sal_Bool bOk = SelectAppIconPixmap( GetDisplay(), m_nXScreen, - nIcon, iconSize, - pHints->icon_pixmap, pHints->icon_mask ); + sal_Bool bOk = lcl_SelectAppIconPixmap( GetDisplay(), m_nXScreen, + nIcon, iconSize, + pHints->icon_pixmap, pHints->icon_mask ); if ( !bOk ) { // load default icon (0) - bOk = SelectAppIconPixmap( GetDisplay(), m_nXScreen, - 0, iconSize, - pHints->icon_pixmap, pHints->icon_mask ); + bOk = lcl_SelectAppIconPixmap( GetDisplay(), m_nXScreen, + 0, iconSize, + pHints->icon_pixmap, pHints->icon_mask ); } if( bOk ) { |