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 .
23 #include <tools/shl.hxx>
24 #include <svl/aeitem.hxx>
25 #include <sfx2/dispatch.hxx>
26 #include <sfx2/viewsh.hxx>
27 #include <sfx2/imagemgr.hxx>
28 #include <sfx2/viewfrm.hxx>
29 #include <vcl/toolbox.hxx>
31 #include <svx/dialmgr.hxx>
32 #include <svx/dialogs.hrc>
34 #include "svx/tbxctl.hxx"
35 #include "svx/tbxdraw.hxx"
36 #include "svx/tbxcolor.hxx"
37 #include <com/sun/star/frame/XLayoutManager.hpp>
39 SFX_IMPL_TOOLBOX_CONTROL(SvxTbxCtlDraw
, SfxAllEnumItem
);
41 using namespace ::com::sun::star::uno
;
42 using namespace ::com::sun::star::frame
;
44 // -----------------------------------------------------------------------
46 SvxTbxCtlDraw::SvxTbxCtlDraw( sal_uInt16 nSlotId
, sal_uInt16 nId
, ToolBox
& rTbx
) :
48 SfxToolBoxControl( nSlotId
, nId
, rTbx
),
50 m_sToolboxName( "private:resource/toolbar/drawbar" )
53 rTbx
.SetItemBits( nId
, TIB_CHECKABLE
| rTbx
.GetItemBits( nId
) );
57 // -----------------------------------------------------------------------
59 void SvxTbxCtlDraw::StateChanged( sal_uInt16 nSID
, SfxItemState eState
,
60 const SfxPoolItem
* pState
)
62 GetToolBox().EnableItem( GetId(), ( eState
!= SFX_ITEM_DISABLED
) );
63 SfxToolBoxControl::StateChanged( nSID
, eState
, pState
);
65 Reference
< XLayoutManager
> xLayoutMgr
= getLayoutManager();
66 if ( xLayoutMgr
.is() )
67 GetToolBox().CheckItem(
68 GetId(), xLayoutMgr
->isElementVisible( m_sToolboxName
) != sal_False
);
71 // -----------------------------------------------------------------------
73 SfxPopupWindowType
SvxTbxCtlDraw::GetPopupWindowType() const
75 return SFX_POPUPWINDOW_ONCLICK
;
78 // -----------------------------------------------------------------------
80 void SvxTbxCtlDraw::toggleToolbox()
82 Reference
< XLayoutManager
> xLayoutMgr
= getLayoutManager();
83 if ( xLayoutMgr
.is() )
85 sal_Bool bCheck
= sal_False
;
86 if ( xLayoutMgr
->isElementVisible( m_sToolboxName
) )
88 xLayoutMgr
->hideElement( m_sToolboxName
);
89 xLayoutMgr
->destroyElement( m_sToolboxName
);
94 xLayoutMgr
->createElement( m_sToolboxName
);
95 xLayoutMgr
->showElement( m_sToolboxName
);
98 GetToolBox().CheckItem( GetId(), bCheck
);
102 // -----------------------------------------------------------------------
104 void SvxTbxCtlDraw::Select( sal_Bool
)
109 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */