2010-10-12 15:59:03 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-06-14 17:39:53 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2006-09-17 06:13:47 +00:00
|
|
|
|
2013-05-06 17:19:41 +02:00
|
|
|
#include <dbaccess/ToolBoxHelper.hxx>
|
2002-04-29 06:59:56 +00:00
|
|
|
#include <vcl/toolbox.hxx>
|
2003-04-17 12:26:48 +00:00
|
|
|
#include <vcl/svapp.hxx>
|
2002-04-29 06:59:56 +00:00
|
|
|
#include <svtools/miscopt.hxx>
|
|
|
|
#include "UITools.hxx"
|
|
|
|
#include <svtools/imgdef.hxx>
|
2003-05-19 11:55:49 +00:00
|
|
|
#include <vcl/event.hxx>
|
2014-01-02 23:52:37 +01:00
|
|
|
#include <vcl/settings.hxx>
|
2002-04-29 06:59:56 +00:00
|
|
|
|
|
|
|
namespace dbaui
|
|
|
|
{
|
|
|
|
OToolBoxHelper::OToolBoxHelper()
|
2010-11-16 21:20:50 -08:00
|
|
|
: m_nSymbolsSize(-1 )
|
|
|
|
, m_pToolBox(NULL)
|
2002-04-29 06:59:56 +00:00
|
|
|
{
|
2005-09-23 11:38:14 +00:00
|
|
|
|
2006-01-05 17:02:18 +00:00
|
|
|
OSL_ENSURE(m_nSymbolsSize != SvtMiscOptions().GetCurrentSymbolsSize(),"SymbolsSize should not be identical");
|
2009-11-04 15:39:48 +01:00
|
|
|
SvtMiscOptions().AddListenerLink( LINK( this, OToolBoxHelper, ConfigOptionsChanged ) );
|
2003-04-17 12:26:48 +00:00
|
|
|
Application::AddEventListener( LINK( this, OToolBoxHelper, SettingsChanged ) );
|
2002-04-29 06:59:56 +00:00
|
|
|
}
|
|
|
|
OToolBoxHelper::~OToolBoxHelper()
|
|
|
|
{
|
2009-11-04 15:39:48 +01:00
|
|
|
SvtMiscOptions().RemoveListenerLink( LINK( this, OToolBoxHelper, ConfigOptionsChanged ) );
|
2003-04-17 12:26:48 +00:00
|
|
|
Application::RemoveEventListener( LINK( this, OToolBoxHelper, SettingsChanged ) );
|
|
|
|
}
|
|
|
|
|
2002-04-29 06:59:56 +00:00
|
|
|
void OToolBoxHelper::checkImageList()
|
|
|
|
{
|
|
|
|
if ( m_pToolBox )
|
|
|
|
{
|
2006-01-05 17:02:18 +00:00
|
|
|
sal_Int16 nCurSymbolsSize = SvtMiscOptions().GetCurrentSymbolsSize();
|
2010-11-16 21:20:50 -08:00
|
|
|
if ( nCurSymbolsSize != m_nSymbolsSize )
|
2002-04-29 06:59:56 +00:00
|
|
|
{
|
2006-01-05 17:02:18 +00:00
|
|
|
m_nSymbolsSize = nCurSymbolsSize;
|
2002-04-29 06:59:56 +00:00
|
|
|
|
2010-11-16 23:23:02 -05:00
|
|
|
m_pToolBox->SetImageList( getImageList(m_nSymbolsSize) );
|
2002-04-29 06:59:56 +00:00
|
|
|
Size aTbOldSize = m_pToolBox->GetSizePixel();
|
|
|
|
adjustToolBoxSize(m_pToolBox);
|
|
|
|
Size aTbNewSize = m_pToolBox->GetSizePixel();
|
|
|
|
resizeControls(Size(aTbNewSize.Width() - aTbOldSize.Width(),
|
|
|
|
aTbNewSize.Height() - aTbOldSize.Height())
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-06-20 02:20:58 +00:00
|
|
|
IMPL_LINK(OToolBoxHelper, ConfigOptionsChanged, SvtMiscOptions*, /*_pOptions*/)
|
2002-04-29 06:59:56 +00:00
|
|
|
{
|
|
|
|
if ( m_pToolBox )
|
|
|
|
{
|
|
|
|
SvtMiscOptions aOptions;
|
|
|
|
// check if imagelist changed
|
|
|
|
checkImageList();
|
|
|
|
if ( aOptions.GetToolboxStyle() != m_pToolBox->GetOutStyle() )
|
|
|
|
m_pToolBox->SetOutStyle(aOptions.GetToolboxStyle());
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0L;
|
|
|
|
}
|
2003-05-19 11:55:49 +00:00
|
|
|
IMPL_LINK(OToolBoxHelper, SettingsChanged, VclWindowEvent*, _pEvt)
|
2003-04-17 12:26:48 +00:00
|
|
|
{
|
2003-05-19 11:55:49 +00:00
|
|
|
if ( m_pToolBox && _pEvt && _pEvt->GetId() == VCLEVENT_APPLICATION_DATACHANGED )
|
2003-04-17 12:26:48 +00:00
|
|
|
{
|
2003-05-19 11:55:49 +00:00
|
|
|
DataChangedEvent* pData = reinterpret_cast<DataChangedEvent*>(_pEvt->GetData());
|
|
|
|
if ( pData && ((( pData->GetType() == DATACHANGED_SETTINGS ) ||
|
|
|
|
( pData->GetType() == DATACHANGED_DISPLAY )) &&
|
|
|
|
( pData->GetFlags() & SETTINGS_STYLE )))
|
|
|
|
// check if imagelist changed
|
|
|
|
checkImageList();
|
2003-04-17 12:26:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0L;
|
|
|
|
}
|
2002-04-29 06:59:56 +00:00
|
|
|
void OToolBoxHelper::setToolBox(ToolBox* _pTB)
|
|
|
|
{
|
|
|
|
sal_Bool bFirstTime = (m_pToolBox == NULL);
|
|
|
|
m_pToolBox = _pTB;
|
|
|
|
if ( m_pToolBox )
|
|
|
|
{
|
|
|
|
ConfigOptionsChanged(NULL);
|
|
|
|
if ( bFirstTime )
|
|
|
|
adjustToolBoxSize(m_pToolBox);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} // namespace
|
|
|
|
|
2010-10-12 15:59:03 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|