Bump version to 5.0-14
[LibreOffice.git] / dbaccess / source / ui / misc / ToolBoxHelper.cxx
blob52f658e12aeaf96b01e9d9bf5fdf25e1842b18ef
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <dbaccess/ToolBoxHelper.hxx>
21 #include <vcl/toolbox.hxx>
22 #include <vcl/svapp.hxx>
23 #include <svtools/miscopt.hxx>
24 #include "UITools.hxx"
25 #include <svtools/imgdef.hxx>
26 #include <vcl/event.hxx>
27 #include <vcl/settings.hxx>
29 namespace dbaui
31 OToolBoxHelper::OToolBoxHelper()
32 : m_nSymbolsSize(-1)
33 , m_pToolBox(NULL)
36 OSL_ENSURE(m_nSymbolsSize != SvtMiscOptions().GetCurrentSymbolsSize(),"SymbolsSize should not be identical");
37 SvtMiscOptions().AddListenerLink( LINK( this, OToolBoxHelper, ConfigOptionsChanged ) );
38 Application::AddEventListener( LINK( this, OToolBoxHelper, SettingsChanged ) );
40 OToolBoxHelper::~OToolBoxHelper()
42 SvtMiscOptions().RemoveListenerLink( LINK( this, OToolBoxHelper, ConfigOptionsChanged ) );
43 Application::RemoveEventListener( LINK( this, OToolBoxHelper, SettingsChanged ) );
46 void OToolBoxHelper::checkImageList()
48 if ( m_pToolBox )
50 sal_Int16 nCurSymbolsSize = SvtMiscOptions().GetCurrentSymbolsSize();
51 if ( nCurSymbolsSize != m_nSymbolsSize )
53 m_nSymbolsSize = nCurSymbolsSize;
54 setImageList(m_nSymbolsSize);
56 Size aTbOldSize = m_pToolBox->GetSizePixel();
57 adjustToolBoxSize(m_pToolBox);
58 Size aTbNewSize = m_pToolBox->GetSizePixel();
59 resizeControls(Size(aTbNewSize.Width() - aTbOldSize.Width(),
60 aTbNewSize.Height() - aTbOldSize.Height())
66 IMPL_LINK(OToolBoxHelper, ConfigOptionsChanged, SvtMiscOptions*, /*_pOptions*/)
68 if ( m_pToolBox )
70 SvtMiscOptions aOptions;
71 // check if imagelist changed
72 checkImageList();
73 if ( aOptions.GetToolboxStyle() != m_pToolBox->GetOutStyle() )
74 m_pToolBox->SetOutStyle(aOptions.GetToolboxStyle());
77 return 0L;
79 IMPL_LINK(OToolBoxHelper, SettingsChanged, VclWindowEvent*, _pEvt)
81 if ( m_pToolBox && _pEvt && _pEvt->GetId() == VCLEVENT_APPLICATION_DATACHANGED )
83 DataChangedEvent* pData = static_cast<DataChangedEvent*>(_pEvt->GetData());
84 if ( pData && ((( pData->GetType() == DataChangedEventType::SETTINGS ) ||
85 ( pData->GetType() == DataChangedEventType::DISPLAY )) &&
86 ( pData->GetFlags() & AllSettingsFlags::STYLE )))
87 // check if imagelist changed
88 checkImageList();
91 return 0L;
93 void OToolBoxHelper::setToolBox(ToolBox* _pTB)
95 bool bFirstTime = (m_pToolBox == nullptr);
96 m_pToolBox = _pTB;
97 if ( m_pToolBox )
99 ConfigOptionsChanged(NULL);
100 if ( bFirstTime )
101 adjustToolBoxSize(m_pToolBox);
104 } // namespace
106 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */