1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_dbaccess.hxx" 30*cdf0e10cSrcweir #ifndef DBAUI_TOOLBOXHELPER_HXX 31*cdf0e10cSrcweir #include "ToolBoxHelper.hxx" 32*cdf0e10cSrcweir #endif 33*cdf0e10cSrcweir #ifndef _SV_TOOLBOX_HXX 34*cdf0e10cSrcweir #include <vcl/toolbox.hxx> 35*cdf0e10cSrcweir #endif 36*cdf0e10cSrcweir #ifndef _SV_SVAPP_HXX 37*cdf0e10cSrcweir #include <vcl/svapp.hxx> 38*cdf0e10cSrcweir #endif 39*cdf0e10cSrcweir #ifndef INCLUDED_SVTOOLS_MISCOPT_HXX 40*cdf0e10cSrcweir #include <svtools/miscopt.hxx> 41*cdf0e10cSrcweir #endif 42*cdf0e10cSrcweir #ifndef DBAUI_TOOLS_HXX 43*cdf0e10cSrcweir #include "UITools.hxx" 44*cdf0e10cSrcweir #endif 45*cdf0e10cSrcweir #ifndef _SVTOOLS_IMGDEF_HXX 46*cdf0e10cSrcweir #include <svtools/imgdef.hxx> 47*cdf0e10cSrcweir #endif 48*cdf0e10cSrcweir #include <vcl/event.hxx> 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir namespace dbaui 51*cdf0e10cSrcweir { 52*cdf0e10cSrcweir DBG_NAME(OToolBoxHelper) 53*cdf0e10cSrcweir OToolBoxHelper::OToolBoxHelper() 54*cdf0e10cSrcweir : m_bIsHiContrast(sal_False) 55*cdf0e10cSrcweir ,m_nSymbolsSize(-1 ) 56*cdf0e10cSrcweir ,m_pToolBox(NULL) 57*cdf0e10cSrcweir { 58*cdf0e10cSrcweir DBG_CTOR(OToolBoxHelper,NULL); 59*cdf0e10cSrcweir 60*cdf0e10cSrcweir OSL_ENSURE(m_nSymbolsSize != SvtMiscOptions().GetCurrentSymbolsSize(),"SymbolsSize should not be identical"); 61*cdf0e10cSrcweir SvtMiscOptions().AddListenerLink( LINK( this, OToolBoxHelper, ConfigOptionsChanged ) ); 62*cdf0e10cSrcweir Application::AddEventListener( LINK( this, OToolBoxHelper, SettingsChanged ) ); 63*cdf0e10cSrcweir } 64*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 65*cdf0e10cSrcweir OToolBoxHelper::~OToolBoxHelper() 66*cdf0e10cSrcweir { 67*cdf0e10cSrcweir SvtMiscOptions().RemoveListenerLink( LINK( this, OToolBoxHelper, ConfigOptionsChanged ) ); 68*cdf0e10cSrcweir Application::RemoveEventListener( LINK( this, OToolBoxHelper, SettingsChanged ) ); 69*cdf0e10cSrcweir DBG_DTOR(OToolBoxHelper,NULL); 70*cdf0e10cSrcweir } 71*cdf0e10cSrcweir 72*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 73*cdf0e10cSrcweir void OToolBoxHelper::checkImageList() 74*cdf0e10cSrcweir { 75*cdf0e10cSrcweir if ( m_pToolBox ) 76*cdf0e10cSrcweir { 77*cdf0e10cSrcweir sal_Int16 nCurSymbolsSize = SvtMiscOptions().GetCurrentSymbolsSize(); 78*cdf0e10cSrcweir if ( nCurSymbolsSize != m_nSymbolsSize || 79*cdf0e10cSrcweir m_bIsHiContrast != m_pToolBox->GetSettings().GetStyleSettings().GetHighContrastMode() ) 80*cdf0e10cSrcweir { 81*cdf0e10cSrcweir m_nSymbolsSize = nCurSymbolsSize; 82*cdf0e10cSrcweir m_bIsHiContrast = m_pToolBox->GetSettings().GetStyleSettings().GetHighContrastMode(); 83*cdf0e10cSrcweir 84*cdf0e10cSrcweir 85*cdf0e10cSrcweir m_pToolBox->SetImageList( getImageList(m_nSymbolsSize,m_bIsHiContrast) ); 86*cdf0e10cSrcweir Size aTbOldSize = m_pToolBox->GetSizePixel(); 87*cdf0e10cSrcweir adjustToolBoxSize(m_pToolBox); 88*cdf0e10cSrcweir Size aTbNewSize = m_pToolBox->GetSizePixel(); 89*cdf0e10cSrcweir resizeControls(Size(aTbNewSize.Width() - aTbOldSize.Width(), 90*cdf0e10cSrcweir aTbNewSize.Height() - aTbOldSize.Height()) 91*cdf0e10cSrcweir ); 92*cdf0e10cSrcweir } 93*cdf0e10cSrcweir } 94*cdf0e10cSrcweir } 95*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 96*cdf0e10cSrcweir IMPL_LINK(OToolBoxHelper, ConfigOptionsChanged, SvtMiscOptions*, /*_pOptions*/) 97*cdf0e10cSrcweir { 98*cdf0e10cSrcweir if ( m_pToolBox ) 99*cdf0e10cSrcweir { 100*cdf0e10cSrcweir SvtMiscOptions aOptions; 101*cdf0e10cSrcweir // check if imagelist changed 102*cdf0e10cSrcweir checkImageList(); 103*cdf0e10cSrcweir if ( aOptions.GetToolboxStyle() != m_pToolBox->GetOutStyle() ) 104*cdf0e10cSrcweir m_pToolBox->SetOutStyle(aOptions.GetToolboxStyle()); 105*cdf0e10cSrcweir } 106*cdf0e10cSrcweir 107*cdf0e10cSrcweir return 0L; 108*cdf0e10cSrcweir } 109*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 110*cdf0e10cSrcweir IMPL_LINK(OToolBoxHelper, SettingsChanged, VclWindowEvent*, _pEvt) 111*cdf0e10cSrcweir { 112*cdf0e10cSrcweir if ( m_pToolBox && _pEvt && _pEvt->GetId() == VCLEVENT_APPLICATION_DATACHANGED ) 113*cdf0e10cSrcweir { 114*cdf0e10cSrcweir DataChangedEvent* pData = reinterpret_cast<DataChangedEvent*>(_pEvt->GetData()); 115*cdf0e10cSrcweir if ( pData && ((( pData->GetType() == DATACHANGED_SETTINGS ) || 116*cdf0e10cSrcweir ( pData->GetType() == DATACHANGED_DISPLAY )) && 117*cdf0e10cSrcweir ( pData->GetFlags() & SETTINGS_STYLE ))) 118*cdf0e10cSrcweir // check if imagelist changed 119*cdf0e10cSrcweir checkImageList(); 120*cdf0e10cSrcweir } 121*cdf0e10cSrcweir 122*cdf0e10cSrcweir return 0L; 123*cdf0e10cSrcweir } 124*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 125*cdf0e10cSrcweir void OToolBoxHelper::setToolBox(ToolBox* _pTB) 126*cdf0e10cSrcweir { 127*cdf0e10cSrcweir sal_Bool bFirstTime = (m_pToolBox == NULL); 128*cdf0e10cSrcweir m_pToolBox = _pTB; 129*cdf0e10cSrcweir if ( m_pToolBox ) 130*cdf0e10cSrcweir { 131*cdf0e10cSrcweir // m_bIsHiContrast = m_pToolBox->GetSettings().GetStyleSettings().GetHighContrastMode(); 132*cdf0e10cSrcweir ConfigOptionsChanged(NULL); 133*cdf0e10cSrcweir if ( bFirstTime ) 134*cdf0e10cSrcweir adjustToolBoxSize(m_pToolBox); 135*cdf0e10cSrcweir } 136*cdf0e10cSrcweir } 137*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 138*cdf0e10cSrcweir } // namespace 139*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 140*cdf0e10cSrcweir 141