1*31598a22SAndrew Rist /**************************************************************
2*31598a22SAndrew Rist *
3*31598a22SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*31598a22SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*31598a22SAndrew Rist * distributed with this work for additional information
6*31598a22SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*31598a22SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*31598a22SAndrew Rist * "License"); you may not use this file except in compliance
9*31598a22SAndrew Rist * with the License. You may obtain a copy of the License at
10*31598a22SAndrew Rist *
11*31598a22SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
13*31598a22SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*31598a22SAndrew Rist * software distributed under the License is distributed on an
15*31598a22SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*31598a22SAndrew Rist * KIND, either express or implied. See the License for the
17*31598a22SAndrew Rist * specific language governing permissions and limitations
18*31598a22SAndrew Rist * under the License.
19*31598a22SAndrew Rist *
20*31598a22SAndrew Rist *************************************************************/
21*31598a22SAndrew Rist
22*31598a22SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_basctl.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir
28cdf0e10cSrcweir #include <ide_pch.hxx>
29cdf0e10cSrcweir
30cdf0e10cSrcweir
31cdf0e10cSrcweir #define _BASIDE_POPUPWINDOWTBX
32cdf0e10cSrcweir #include <tbxctl.hxx>
33cdf0e10cSrcweir #include <svx/svxids.hrc>
34cdf0e10cSrcweir #include <iderid.hxx>
35cdf0e10cSrcweir #include <tbxctl.hrc>
36cdf0e10cSrcweir #include <idetemp.hxx>
37cdf0e10cSrcweir #include <sfx2/imagemgr.hxx>
38cdf0e10cSrcweir #include <svl/aeitem.hxx>
39cdf0e10cSrcweir #include <vcl/toolbox.hxx>
40cdf0e10cSrcweir
41cdf0e10cSrcweir using namespace ::com::sun::star::uno;
42cdf0e10cSrcweir
43cdf0e10cSrcweir
44cdf0e10cSrcweir static ::rtl::OUString aSubToolBarResName( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/insertcontrolsbar" ) );
45cdf0e10cSrcweir
SFX_IMPL_TOOLBOX_CONTROL(TbxControls,SfxAllEnumItem)46cdf0e10cSrcweir SFX_IMPL_TOOLBOX_CONTROL( TbxControls, SfxAllEnumItem )
47cdf0e10cSrcweir
48cdf0e10cSrcweir /*************************************************************************
49cdf0e10cSrcweir |*
50cdf0e10cSrcweir |* WorkWindow Alignment
51cdf0e10cSrcweir |*
52cdf0e10cSrcweir \************************************************************************/
53cdf0e10cSrcweir /*
54cdf0e10cSrcweir IMPL_LINK( PopupWindowTbx, SelectHdl, void*, EMPTYARG )
55cdf0e10cSrcweir {
56cdf0e10cSrcweir if ( IsInPopupMode() )
57cdf0e10cSrcweir EndPopupMode();
58cdf0e10cSrcweir
59cdf0e10cSrcweir aSelectLink.Call( &aTbx.GetToolBox() );
60cdf0e10cSrcweir
61cdf0e10cSrcweir return 0;
62cdf0e10cSrcweir }
63cdf0e10cSrcweir
64cdf0e10cSrcweir PopupWindowTbx::PopupWindowTbx( sal_uInt16 nId, WindowAlign eAlign,
65cdf0e10cSrcweir ResId aRIdWin, ResId aRIdTbx,
66cdf0e10cSrcweir SfxBindings& rBind ) :
67cdf0e10cSrcweir SfxPopupWindow ( nId, aRIdWin, rBind ),
68cdf0e10cSrcweir aTbx ( this, GetBindings(), aRIdTbx )
69cdf0e10cSrcweir {
70cdf0e10cSrcweir FreeResource();
71cdf0e10cSrcweir aTbx.Initialize();
72cdf0e10cSrcweir
73cdf0e10cSrcweir ToolBox& rBox = aTbx.GetToolBox();
74cdf0e10cSrcweir rBox.SetAlign( eAlign );
75cdf0e10cSrcweir if( eAlign == WINDOWALIGN_LEFT )
76cdf0e10cSrcweir SetText( String() );
77cdf0e10cSrcweir
78cdf0e10cSrcweir Size aSize = aTbx.CalcWindowSizePixel();
79cdf0e10cSrcweir rBox.SetSizePixel( aSize );
80cdf0e10cSrcweir SetOutputSizePixel( aSize );
81cdf0e10cSrcweir aSelectLink = rBox.GetSelectHdl();
82cdf0e10cSrcweir rBox.SetSelectHdl( LINK( this, PopupWindowTbx, SelectHdl ) );
83cdf0e10cSrcweir }
84cdf0e10cSrcweir
85cdf0e10cSrcweir SfxPopupWindow* PopupWindowTbx::Clone() const
86cdf0e10cSrcweir {
87cdf0e10cSrcweir return new PopupWindowTbx( GetId(), aTbx.GetAlign(),
88cdf0e10cSrcweir IDEResId( RID_TBXCONTROLS ),
89cdf0e10cSrcweir IDEResId( RID_TOOLBOX ),
90cdf0e10cSrcweir (SfxBindings&) GetBindings() );
91cdf0e10cSrcweir }
92cdf0e10cSrcweir
93cdf0e10cSrcweir void PopupWindowTbx::PopupModeEnd()
94cdf0e10cSrcweir {
95cdf0e10cSrcweir aTbx.GetToolBox().EndSelection();
96cdf0e10cSrcweir SfxPopupWindow::PopupModeEnd();
97cdf0e10cSrcweir }
98cdf0e10cSrcweir
99cdf0e10cSrcweir void PopupWindowTbx::Update()
100cdf0e10cSrcweir {
101cdf0e10cSrcweir ToolBox *pBox = &aTbx.GetToolBox();
102cdf0e10cSrcweir aTbx.Activate( pBox );
103cdf0e10cSrcweir aTbx.Deactivate( pBox );
104cdf0e10cSrcweir }
105cdf0e10cSrcweir
106cdf0e10cSrcweir PopupWindowTbx::~PopupWindowTbx()
107cdf0e10cSrcweir {
108cdf0e10cSrcweir }
109cdf0e10cSrcweir */
110cdf0e10cSrcweir /*************************************************************************
111cdf0e10cSrcweir |*
112cdf0e10cSrcweir |* Klasse fuer Toolbox
113cdf0e10cSrcweir |*
114cdf0e10cSrcweir \************************************************************************/
115cdf0e10cSrcweir
116cdf0e10cSrcweir TbxControls::TbxControls( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) :
117cdf0e10cSrcweir SfxToolBoxControl( nSlotId, nId, rTbx )
118cdf0e10cSrcweir {
119cdf0e10cSrcweir nLastSlot = USHRT_MAX;
120cdf0e10cSrcweir
121cdf0e10cSrcweir rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) );
122cdf0e10cSrcweir rTbx.Invalidate();
123cdf0e10cSrcweir }
124cdf0e10cSrcweir
125cdf0e10cSrcweir /*************************************************************************
126cdf0e10cSrcweir |*
127cdf0e10cSrcweir |* Wenn man ein PopupWindow erzeugen will
128cdf0e10cSrcweir |*
129cdf0e10cSrcweir \************************************************************************/
GetPopupWindowType() const130cdf0e10cSrcweir SfxPopupWindowType TbxControls::GetPopupWindowType() const
131cdf0e10cSrcweir {
132cdf0e10cSrcweir if( nLastSlot == USHRT_MAX )
133cdf0e10cSrcweir return(SFX_POPUPWINDOW_ONCLICK);
134cdf0e10cSrcweir return(SFX_POPUPWINDOW_ONTIMEOUT);
135cdf0e10cSrcweir }
136cdf0e10cSrcweir
StateChanged(sal_uInt16 nSID,SfxItemState eState,const SfxPoolItem * pState)137cdf0e10cSrcweir void TbxControls::StateChanged( sal_uInt16 nSID, SfxItemState eState,
138cdf0e10cSrcweir const SfxPoolItem* pState )
139cdf0e10cSrcweir {
140cdf0e10cSrcweir if( pState )
141cdf0e10cSrcweir {
142cdf0e10cSrcweir SfxAllEnumItem* pItem = PTR_CAST(SfxAllEnumItem, pState);
143cdf0e10cSrcweir if( pItem )
144cdf0e10cSrcweir {
145cdf0e10cSrcweir sal_uInt16 nLastEnum = pItem->GetValue();
146cdf0e10cSrcweir sal_uInt16 nTemp = 0;
147cdf0e10cSrcweir switch( nLastEnum )
148cdf0e10cSrcweir {
149cdf0e10cSrcweir case SVX_SNAP_PUSHBUTTON: nTemp = SID_INSERT_PUSHBUTTON; break;
150cdf0e10cSrcweir case SVX_SNAP_CHECKBOX: nTemp = SID_INSERT_CHECKBOX; break;
151cdf0e10cSrcweir case SVX_SNAP_RADIOBUTTON: nTemp = SID_INSERT_RADIOBUTTON; break;
152cdf0e10cSrcweir case SVX_SNAP_SPINBUTTON: nTemp = SID_INSERT_SPINBUTTON; break;
153cdf0e10cSrcweir case SVX_SNAP_FIXEDTEXT: nTemp = SID_INSERT_FIXEDTEXT; break;
154cdf0e10cSrcweir case SVX_SNAP_GROUPBOX: nTemp = SID_INSERT_GROUPBOX; break;
155cdf0e10cSrcweir case SVX_SNAP_LISTBOX: nTemp = SID_INSERT_LISTBOX; break;
156cdf0e10cSrcweir case SVX_SNAP_COMBOBOX: nTemp = SID_INSERT_COMBOBOX; break;
157cdf0e10cSrcweir case SVX_SNAP_EDIT: nTemp = SID_INSERT_EDIT; break;
158cdf0e10cSrcweir case SVX_SNAP_HSCROLLBAR: nTemp = SID_INSERT_HSCROLLBAR; break;
159cdf0e10cSrcweir case SVX_SNAP_VSCROLLBAR: nTemp = SID_INSERT_VSCROLLBAR; break;
160cdf0e10cSrcweir case SVX_SNAP_PREVIEW: nTemp = SID_INSERT_PREVIEW; break;
161cdf0e10cSrcweir case SVX_SNAP_URLBUTTON: nTemp = SID_INSERT_URLBUTTON; break;
162cdf0e10cSrcweir case SVX_SNAP_IMAGECONTROL: nTemp = SID_INSERT_IMAGECONTROL; break;
163cdf0e10cSrcweir case SVX_SNAP_PROGRESSBAR: nTemp = SID_INSERT_PROGRESSBAR; break;
164cdf0e10cSrcweir case SVX_SNAP_HFIXEDLINE: nTemp = SID_INSERT_HFIXEDLINE; break;
165cdf0e10cSrcweir case SVX_SNAP_VFIXEDLINE: nTemp = SID_INSERT_VFIXEDLINE; break;
166cdf0e10cSrcweir case SVX_SNAP_DATEFIELD: nTemp = SID_INSERT_DATEFIELD; break;
167cdf0e10cSrcweir case SVX_SNAP_TIMEFIELD: nTemp = SID_INSERT_TIMEFIELD; break;
168cdf0e10cSrcweir case SVX_SNAP_NUMERICFIELD: nTemp = SID_INSERT_NUMERICFIELD; break;
169cdf0e10cSrcweir case SVX_SNAP_CURRENCYFIELD: nTemp = SID_INSERT_CURRENCYFIELD; break;
170cdf0e10cSrcweir case SVX_SNAP_FORMATTEDFIELD: nTemp = SID_INSERT_FORMATTEDFIELD; break;
171cdf0e10cSrcweir case SVX_SNAP_PATTERNFIELD: nTemp = SID_INSERT_PATTERNFIELD; break;
172cdf0e10cSrcweir case SVX_SNAP_FILECONTROL: nTemp = SID_INSERT_FILECONTROL; break;
173cdf0e10cSrcweir case SVX_SNAP_TREECONTROL: nTemp = SID_INSERT_TREECONTROL; break;
174cdf0e10cSrcweir }
175cdf0e10cSrcweir if( nTemp )
176cdf0e10cSrcweir {
177cdf0e10cSrcweir rtl::OUString aSlotURL( RTL_CONSTASCII_USTRINGPARAM( "slot:" ));
178cdf0e10cSrcweir aSlotURL += rtl::OUString::valueOf( sal_Int32( nTemp ));
179cdf0e10cSrcweir Image aImage = GetImage( m_xFrame,
180cdf0e10cSrcweir aSlotURL,
181cdf0e10cSrcweir hasBigImages(),
182cdf0e10cSrcweir GetToolBox().GetSettings().GetStyleSettings().GetHighContrastMode() );
183cdf0e10cSrcweir ToolBox& rBox = GetToolBox();
184cdf0e10cSrcweir rBox.SetItemImage(GetId(), aImage);
185cdf0e10cSrcweir nLastSlot = nLastEnum;
186cdf0e10cSrcweir }
187cdf0e10cSrcweir }
188cdf0e10cSrcweir }
189cdf0e10cSrcweir SfxToolBoxControl::StateChanged( nSID, eState,pState );
190cdf0e10cSrcweir }
191cdf0e10cSrcweir
Select(sal_uInt16 nModifier)192cdf0e10cSrcweir void TbxControls::Select( sal_uInt16 nModifier )
193cdf0e10cSrcweir {
194cdf0e10cSrcweir (void)nModifier;
195cdf0e10cSrcweir SfxAllEnumItem aItem( SID_CHOOSE_CONTROLS, nLastSlot );
196cdf0e10cSrcweir SfxViewFrame* pCurFrame = SfxViewFrame::Current();
197cdf0e10cSrcweir DBG_ASSERT( pCurFrame != NULL, "No current view frame!" );
198cdf0e10cSrcweir SfxDispatcher* pDispatcher = pCurFrame ? pCurFrame->GetDispatcher() : NULL;
199cdf0e10cSrcweir if( pDispatcher )
200cdf0e10cSrcweir {
201cdf0e10cSrcweir pDispatcher->Execute( SID_CHOOSE_CONTROLS, SFX_CALLMODE_SYNCHRON, &aItem, 0L );
202cdf0e10cSrcweir }
203cdf0e10cSrcweir }
204cdf0e10cSrcweir
205cdf0e10cSrcweir /*************************************************************************
206cdf0e10cSrcweir |*
207cdf0e10cSrcweir |* Hier wird das Fenster erzeugt
208cdf0e10cSrcweir |* Lage der Toolbox mit GetToolBox() abfragbar
209cdf0e10cSrcweir |* rItemRect sind die Screen-Koordinaten
210cdf0e10cSrcweir |*
211cdf0e10cSrcweir \************************************************************************/
CreatePopupWindow()212cdf0e10cSrcweir SfxPopupWindow* TbxControls::CreatePopupWindow()
213cdf0e10cSrcweir {
214cdf0e10cSrcweir if ( GetSlotId() == SID_CHOOSE_CONTROLS )
215cdf0e10cSrcweir createAndPositionSubToolBar( aSubToolBarResName );
216cdf0e10cSrcweir
217cdf0e10cSrcweir /*
218cdf0e10cSrcweir if (GetId() == SID_CHOOSE_CONTROLS)
219cdf0e10cSrcweir {
220cdf0e10cSrcweir PopupWindowTbx *pWin =
221cdf0e10cSrcweir new PopupWindowTbx( GetId(),
222cdf0e10cSrcweir GetToolBox().IsHorizontal() ?
223cdf0e10cSrcweir WINDOWALIGN_LEFT : WINDOWALIGN_TOP,
224cdf0e10cSrcweir IDEResId( RID_TBXCONTROLS ),
225cdf0e10cSrcweir IDEResId( RID_TOOLBOX ),
226cdf0e10cSrcweir GetBindings() );
227cdf0e10cSrcweir pWin->StartPopupMode(&GetToolBox(), sal_True);
228cdf0e10cSrcweir pWin->Update();
229cdf0e10cSrcweir pWin->StartSelection();
230cdf0e10cSrcweir pWin->Show();
231cdf0e10cSrcweir return(pWin);
232cdf0e10cSrcweir }
233cdf0e10cSrcweir */
234cdf0e10cSrcweir return(0);
235cdf0e10cSrcweir }
236cdf0e10cSrcweir
237cdf0e10cSrcweir
238