Kaydet (Commit) 1382dad9 authored tarafından Tor Lillqvist's avatar Tor Lillqvist

Minor refactoring: Move a function to the only file where it is used

Change-Id: I98f1eda871eb36cdf61e003d046395698dcdad18
üst 8b7da751
......@@ -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 \
......
/* -*- 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: */
/* -*- 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: */
......@@ -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 )
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment