1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
31 OToolBoxHelper::OToolBoxHelper()
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()
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*/)
70 SvtMiscOptions aOptions
;
71 // check if imagelist changed
73 if ( aOptions
.GetToolboxStyle() != m_pToolBox
->GetOutStyle() )
74 m_pToolBox
->SetOutStyle(aOptions
.GetToolboxStyle());
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
93 void OToolBoxHelper::setToolBox(ToolBox
* _pTB
)
95 bool bFirstTime
= (m_pToolBox
== nullptr);
99 ConfigOptionsChanged(NULL
);
101 adjustToolBoxSize(m_pToolBox
);
106 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */