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: tbxctl.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_basctl.hxx"
35 #include <ide_pch.hxx>
38 #define _BASIDE_POPUPWINDOWTBX
40 #include <svx/svxids.hrc>
43 #include <idetemp.hxx>
44 #include <sfx2/imagemgr.hxx>
45 #include <svtools/aeitem.hxx>
46 #include <vcl/toolbox.hxx>
48 using namespace ::com::sun::star::uno
;
51 static ::rtl::OUString
aSubToolBarResName( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/insertcontrolsbar" ) );
53 SFX_IMPL_TOOLBOX_CONTROL( TbxControls
, SfxAllEnumItem
)
55 /*************************************************************************
57 |* WorkWindow Alignment
59 \************************************************************************/
61 IMPL_LINK( PopupWindowTbx, SelectHdl, void*, EMPTYARG )
63 if ( IsInPopupMode() )
66 aSelectLink.Call( &aTbx.GetToolBox() );
71 PopupWindowTbx::PopupWindowTbx( USHORT nId, WindowAlign eAlign,
72 ResId aRIdWin, ResId aRIdTbx,
73 SfxBindings& rBind ) :
74 SfxPopupWindow ( nId, aRIdWin, rBind ),
75 aTbx ( this, GetBindings(), aRIdTbx )
80 ToolBox& rBox = aTbx.GetToolBox();
81 rBox.SetAlign( eAlign );
82 if( eAlign == WINDOWALIGN_LEFT )
85 Size aSize = aTbx.CalcWindowSizePixel();
86 rBox.SetSizePixel( aSize );
87 SetOutputSizePixel( aSize );
88 aSelectLink = rBox.GetSelectHdl();
89 rBox.SetSelectHdl( LINK( this, PopupWindowTbx, SelectHdl ) );
92 SfxPopupWindow* PopupWindowTbx::Clone() const
94 return new PopupWindowTbx( GetId(), aTbx.GetAlign(),
95 IDEResId( RID_TBXCONTROLS ),
96 IDEResId( RID_TOOLBOX ),
97 (SfxBindings&) GetBindings() );
100 void PopupWindowTbx::PopupModeEnd()
102 aTbx.GetToolBox().EndSelection();
103 SfxPopupWindow::PopupModeEnd();
106 void PopupWindowTbx::Update()
108 ToolBox *pBox = &aTbx.GetToolBox();
109 aTbx.Activate( pBox );
110 aTbx.Deactivate( pBox );
113 PopupWindowTbx::~PopupWindowTbx()
117 /*************************************************************************
119 |* Klasse fuer Toolbox
121 \************************************************************************/
123 TbxControls::TbxControls( USHORT nSlotId
, USHORT nId
, ToolBox
& rTbx
) :
124 SfxToolBoxControl( nSlotId
, nId
, rTbx
)
126 nLastSlot
= USHRT_MAX
;
128 rTbx
.SetItemBits( nId
, TIB_DROPDOWN
| rTbx
.GetItemBits( nId
) );
132 /*************************************************************************
134 |* Wenn man ein PopupWindow erzeugen will
136 \************************************************************************/
137 SfxPopupWindowType
TbxControls::GetPopupWindowType() const
139 if( nLastSlot
== USHRT_MAX
)
140 return(SFX_POPUPWINDOW_ONCLICK
);
141 return(SFX_POPUPWINDOW_ONTIMEOUT
);
144 void TbxControls::StateChanged( USHORT nSID
, SfxItemState eState
,
145 const SfxPoolItem
* pState
)
149 SfxAllEnumItem
* pItem
= PTR_CAST(SfxAllEnumItem
, pState
);
152 USHORT nLastEnum
= pItem
->GetValue();
156 case SVX_SNAP_PUSHBUTTON
: nTemp
= SID_INSERT_PUSHBUTTON
; break;
157 case SVX_SNAP_CHECKBOX
: nTemp
= SID_INSERT_CHECKBOX
; break;
158 case SVX_SNAP_RADIOBUTTON
: nTemp
= SID_INSERT_RADIOBUTTON
; break;
159 case SVX_SNAP_SPINBUTTON
: nTemp
= SID_INSERT_SPINBUTTON
; break;
160 case SVX_SNAP_FIXEDTEXT
: nTemp
= SID_INSERT_FIXEDTEXT
; break;
161 case SVX_SNAP_GROUPBOX
: nTemp
= SID_INSERT_GROUPBOX
; break;
162 case SVX_SNAP_LISTBOX
: nTemp
= SID_INSERT_LISTBOX
; break;
163 case SVX_SNAP_COMBOBOX
: nTemp
= SID_INSERT_COMBOBOX
; break;
164 case SVX_SNAP_EDIT
: nTemp
= SID_INSERT_EDIT
; break;
165 case SVX_SNAP_HSCROLLBAR
: nTemp
= SID_INSERT_HSCROLLBAR
; break;
166 case SVX_SNAP_VSCROLLBAR
: nTemp
= SID_INSERT_VSCROLLBAR
; break;
167 case SVX_SNAP_PREVIEW
: nTemp
= SID_INSERT_PREVIEW
; break;
168 case SVX_SNAP_URLBUTTON
: nTemp
= SID_INSERT_URLBUTTON
; break;
169 case SVX_SNAP_IMAGECONTROL
: nTemp
= SID_INSERT_IMAGECONTROL
; break;
170 case SVX_SNAP_PROGRESSBAR
: nTemp
= SID_INSERT_PROGRESSBAR
; break;
171 case SVX_SNAP_HFIXEDLINE
: nTemp
= SID_INSERT_HFIXEDLINE
; break;
172 case SVX_SNAP_VFIXEDLINE
: nTemp
= SID_INSERT_VFIXEDLINE
; break;
173 case SVX_SNAP_DATEFIELD
: nTemp
= SID_INSERT_DATEFIELD
; break;
174 case SVX_SNAP_TIMEFIELD
: nTemp
= SID_INSERT_TIMEFIELD
; break;
175 case SVX_SNAP_NUMERICFIELD
: nTemp
= SID_INSERT_NUMERICFIELD
; break;
176 case SVX_SNAP_CURRENCYFIELD
: nTemp
= SID_INSERT_CURRENCYFIELD
; break;
177 case SVX_SNAP_FORMATTEDFIELD
: nTemp
= SID_INSERT_FORMATTEDFIELD
; break;
178 case SVX_SNAP_PATTERNFIELD
: nTemp
= SID_INSERT_PATTERNFIELD
; break;
179 case SVX_SNAP_FILECONTROL
: nTemp
= SID_INSERT_FILECONTROL
; break;
180 case SVX_SNAP_TREECONTROL
: nTemp
= SID_INSERT_TREECONTROL
; break;
184 rtl::OUString
aSlotURL( RTL_CONSTASCII_USTRINGPARAM( "slot:" ));
185 aSlotURL
+= rtl::OUString::valueOf( sal_Int32( nTemp
));
186 Image aImage
= GetImage( m_xFrame
,
189 GetToolBox().GetDisplayBackground().GetColor().IsDark() );
190 ToolBox
& rBox
= GetToolBox();
191 rBox
.SetItemImage(GetId(), aImage
);
192 nLastSlot
= nLastEnum
;
196 SfxToolBoxControl::StateChanged( nSID
, eState
,pState
);
199 void TbxControls::Select( USHORT nModifier
)
202 SfxAllEnumItem
aItem( SID_CHOOSE_CONTROLS
, nLastSlot
);
203 SfxViewFrame
* pCurFrame
= SfxViewFrame::Current();
204 DBG_ASSERT( pCurFrame
!= NULL
, "No current view frame!" );
205 SfxDispatcher
* pDispatcher
= pCurFrame
? pCurFrame
->GetDispatcher() : NULL
;
208 pDispatcher
->Execute( SID_CHOOSE_CONTROLS
, SFX_CALLMODE_SYNCHRON
, &aItem
, 0L );
212 /*************************************************************************
214 |* Hier wird das Fenster erzeugt
215 |* Lage der Toolbox mit GetToolBox() abfragbar
216 |* rItemRect sind die Screen-Koordinaten
218 \************************************************************************/
219 SfxPopupWindow
* TbxControls::CreatePopupWindow()
221 if ( GetSlotId() == SID_CHOOSE_CONTROLS
)
222 createAndPositionSubToolBar( aSubToolBarResName
);
225 if (GetId() == SID_CHOOSE_CONTROLS)
227 PopupWindowTbx *pWin =
228 new PopupWindowTbx( GetId(),
229 GetToolBox().IsHorizontal() ?
230 WINDOWALIGN_LEFT : WINDOWALIGN_TOP,
231 IDEResId( RID_TBXCONTROLS ),
232 IDEResId( RID_TOOLBOX ),
234 pWin->StartPopupMode(&GetToolBox(), TRUE);
236 pWin->StartSelection();