1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_dbaccess.hxx" 26 #ifndef DBAUI_TOOLBOXHELPER_HXX 27 #include "ToolBoxHelper.hxx" 28 #endif 29 #ifndef _SV_TOOLBOX_HXX 30 #include <vcl/toolbox.hxx> 31 #endif 32 #ifndef _SV_SVAPP_HXX 33 #include <vcl/svapp.hxx> 34 #endif 35 #ifndef INCLUDED_SVTOOLS_MISCOPT_HXX 36 #include <svtools/miscopt.hxx> 37 #endif 38 #ifndef DBAUI_TOOLS_HXX 39 #include "UITools.hxx" 40 #endif 41 #ifndef _SVTOOLS_IMGDEF_HXX 42 #include <svtools/imgdef.hxx> 43 #endif 44 #include <vcl/event.hxx> 45 46 namespace dbaui 47 { DBG_NAME(OToolBoxHelper)48 DBG_NAME(OToolBoxHelper) 49 OToolBoxHelper::OToolBoxHelper() 50 : m_bIsHiContrast(sal_False) 51 ,m_nSymbolsSize(-1 ) 52 ,m_pToolBox(NULL) 53 { 54 DBG_CTOR(OToolBoxHelper,NULL); 55 56 OSL_ENSURE(m_nSymbolsSize != SvtMiscOptions().GetCurrentSymbolsSize(),"SymbolsSize should not be identical"); 57 SvtMiscOptions().AddListenerLink( LINK( this, OToolBoxHelper, ConfigOptionsChanged ) ); 58 Application::AddEventListener( LINK( this, OToolBoxHelper, SettingsChanged ) ); 59 } 60 // ----------------------------------------------------------------------------- ~OToolBoxHelper()61 OToolBoxHelper::~OToolBoxHelper() 62 { 63 SvtMiscOptions().RemoveListenerLink( LINK( this, OToolBoxHelper, ConfigOptionsChanged ) ); 64 Application::RemoveEventListener( LINK( this, OToolBoxHelper, SettingsChanged ) ); 65 DBG_DTOR(OToolBoxHelper,NULL); 66 } 67 68 // ----------------------------------------------------------------------------- checkImageList()69 void OToolBoxHelper::checkImageList() 70 { 71 if ( m_pToolBox ) 72 { 73 sal_Int16 nCurSymbolsSize = SvtMiscOptions().GetCurrentSymbolsSize(); 74 if ( nCurSymbolsSize != m_nSymbolsSize || 75 m_bIsHiContrast != m_pToolBox->GetSettings().GetStyleSettings().GetHighContrastMode() ) 76 { 77 m_nSymbolsSize = nCurSymbolsSize; 78 m_bIsHiContrast = m_pToolBox->GetSettings().GetStyleSettings().GetHighContrastMode(); 79 80 81 m_pToolBox->SetImageList( getImageList(m_nSymbolsSize,m_bIsHiContrast) ); 82 Size aTbOldSize = m_pToolBox->GetSizePixel(); 83 adjustToolBoxSize(m_pToolBox); 84 Size aTbNewSize = m_pToolBox->GetSizePixel(); 85 resizeControls(Size(aTbNewSize.Width() - aTbOldSize.Width(), 86 aTbNewSize.Height() - aTbOldSize.Height()) 87 ); 88 } 89 } 90 } 91 // ----------------------------------------------------------------------------- 92 IMPL_LINK(OToolBoxHelper, ConfigOptionsChanged, SvtMiscOptions*, /*_pOptions*/) 93 { 94 if ( m_pToolBox ) 95 { 96 SvtMiscOptions aOptions; 97 // check if imagelist changed 98 checkImageList(); 99 if ( aOptions.GetToolboxStyle() != m_pToolBox->GetOutStyle() ) 100 m_pToolBox->SetOutStyle(aOptions.GetToolboxStyle()); 101 } 102 103 return 0L; 104 } 105 // ----------------------------------------------------------------------------- IMPL_LINK(OToolBoxHelper,SettingsChanged,VclWindowEvent *,_pEvt)106 IMPL_LINK(OToolBoxHelper, SettingsChanged, VclWindowEvent*, _pEvt) 107 { 108 if ( m_pToolBox && _pEvt && _pEvt->GetId() == VCLEVENT_APPLICATION_DATACHANGED ) 109 { 110 DataChangedEvent* pData = reinterpret_cast<DataChangedEvent*>(_pEvt->GetData()); 111 if ( pData && ((( pData->GetType() == DATACHANGED_SETTINGS ) || 112 ( pData->GetType() == DATACHANGED_DISPLAY )) && 113 ( pData->GetFlags() & SETTINGS_STYLE ))) 114 // check if imagelist changed 115 checkImageList(); 116 } 117 118 return 0L; 119 } 120 // ----------------------------------------------------------------------------- setToolBox(ToolBox * _pTB)121 void OToolBoxHelper::setToolBox(ToolBox* _pTB) 122 { 123 sal_Bool bFirstTime = (m_pToolBox == NULL); 124 m_pToolBox = _pTB; 125 if ( m_pToolBox ) 126 { 127 // m_bIsHiContrast = m_pToolBox->GetSettings().GetStyleSettings().GetHighContrastMode(); 128 ConfigOptionsChanged(NULL); 129 if ( bFirstTime ) 130 adjustToolBoxSize(m_pToolBox); 131 } 132 } 133 // ----------------------------------------------------------------------------- 134 } // namespace 135 // ----------------------------------------------------------------------------- 136 137