1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ToolBoxHelper.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_dbaccess.hxx"
33 #ifndef DBAUI_TOOLBOXHELPER_HXX
34 #include "ToolBoxHelper.hxx"
36 #ifndef _SV_TOOLBOX_HXX
37 #include <vcl/toolbox.hxx>
40 #include <vcl/svapp.hxx>
42 #ifndef INCLUDED_SVTOOLS_MISCOPT_HXX
43 #include <svtools/miscopt.hxx>
45 #ifndef DBAUI_TOOLS_HXX
46 #include "UITools.hxx"
48 #ifndef _SVTOOLS_IMGDEF_HXX
49 #include <svtools/imgdef.hxx>
51 #include <vcl/event.hxx>
55 DBG_NAME(OToolBoxHelper
)
56 OToolBoxHelper::OToolBoxHelper()
57 : m_bIsHiContrast(sal_False
)
61 DBG_CTOR(OToolBoxHelper
,NULL
);
63 OSL_ENSURE(m_nSymbolsSize
!= SvtMiscOptions().GetCurrentSymbolsSize(),"SymbolsSize should not be identical");
64 SvtMiscOptions().AddListener( LINK( this, OToolBoxHelper
, ConfigOptionsChanged
) );
65 Application::AddEventListener( LINK( this, OToolBoxHelper
, SettingsChanged
) );
67 // -----------------------------------------------------------------------------
68 OToolBoxHelper::~OToolBoxHelper()
70 SvtMiscOptions().RemoveListener( LINK( this, OToolBoxHelper
, ConfigOptionsChanged
) );
71 Application::RemoveEventListener( LINK( this, OToolBoxHelper
, SettingsChanged
) );
72 DBG_DTOR(OToolBoxHelper
,NULL
);
75 // -----------------------------------------------------------------------------
76 void OToolBoxHelper::checkImageList()
80 sal_Int16 nCurSymbolsSize
= SvtMiscOptions().GetCurrentSymbolsSize();
81 if ( nCurSymbolsSize
!= m_nSymbolsSize
||
82 m_bIsHiContrast
!= m_pToolBox
->GetBackground().GetColor().IsDark() )
84 m_nSymbolsSize
= nCurSymbolsSize
;
85 m_bIsHiContrast
= m_pToolBox
->GetBackground().GetColor().IsDark();
88 m_pToolBox
->SetImageList( getImageList(m_nSymbolsSize
,m_bIsHiContrast
) );
89 Size aTbOldSize
= m_pToolBox
->GetSizePixel();
90 adjustToolBoxSize(m_pToolBox
);
91 Size aTbNewSize
= m_pToolBox
->GetSizePixel();
92 resizeControls(Size(aTbNewSize
.Width() - aTbOldSize
.Width(),
93 aTbNewSize
.Height() - aTbOldSize
.Height())
98 // -----------------------------------------------------------------------------
99 IMPL_LINK(OToolBoxHelper
, ConfigOptionsChanged
, SvtMiscOptions
*, /*_pOptions*/)
103 SvtMiscOptions aOptions
;
104 // check if imagelist changed
106 if ( aOptions
.GetToolboxStyle() != m_pToolBox
->GetOutStyle() )
107 m_pToolBox
->SetOutStyle(aOptions
.GetToolboxStyle());
112 // -----------------------------------------------------------------------------
113 IMPL_LINK(OToolBoxHelper
, SettingsChanged
, VclWindowEvent
*, _pEvt
)
115 if ( m_pToolBox
&& _pEvt
&& _pEvt
->GetId() == VCLEVENT_APPLICATION_DATACHANGED
)
117 DataChangedEvent
* pData
= reinterpret_cast<DataChangedEvent
*>(_pEvt
->GetData());
118 if ( pData
&& ((( pData
->GetType() == DATACHANGED_SETTINGS
) ||
119 ( pData
->GetType() == DATACHANGED_DISPLAY
)) &&
120 ( pData
->GetFlags() & SETTINGS_STYLE
)))
121 // check if imagelist changed
127 // -----------------------------------------------------------------------------
128 void OToolBoxHelper::setToolBox(ToolBox
* _pTB
)
130 sal_Bool bFirstTime
= (m_pToolBox
== NULL
);
134 // m_bIsHiContrast = m_pToolBox->GetBackground().GetColor().IsDark();
135 ConfigOptionsChanged(NULL
);
137 adjustToolBoxSize(m_pToolBox
);
140 // -----------------------------------------------------------------------------
142 // -----------------------------------------------------------------------------