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