131598a22SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
331598a22SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
431598a22SAndrew Rist * or more contributor license agreements. See the NOTICE file
531598a22SAndrew Rist * distributed with this work for additional information
631598a22SAndrew Rist * regarding copyright ownership. The ASF licenses this file
731598a22SAndrew Rist * to you under the Apache License, Version 2.0 (the
831598a22SAndrew Rist * "License"); you may not use this file except in compliance
931598a22SAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
1131598a22SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
1331598a22SAndrew Rist * Unless required by applicable law or agreed to in writing,
1431598a22SAndrew Rist * software distributed under the License is distributed on an
1531598a22SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1631598a22SAndrew Rist * KIND, either express or implied. See the License for the
1731598a22SAndrew Rist * specific language governing permissions and limitations
1831598a22SAndrew Rist * under the License.
19cdf0e10cSrcweir *
2031598a22SAndrew Rist *************************************************************/
2131598a22SAndrew Rist
2231598a22SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_basctl.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include <ide_pch.hxx>
28cdf0e10cSrcweir
29cdf0e10cSrcweir
30cdf0e10cSrcweir #include <basic/sbx.hxx>
31cdf0e10cSrcweir #ifndef _SV_CMDEVT_HXX
32cdf0e10cSrcweir #include <vcl/cmdevt.hxx>
33cdf0e10cSrcweir #endif
34cdf0e10cSrcweir #include <vcl/taskpanelist.hxx>
35cdf0e10cSrcweir #include <vcl/sound.hxx>
36cdf0e10cSrcweir #include <objdlg.hrc>
37cdf0e10cSrcweir #include <objdlg.hxx>
38cdf0e10cSrcweir #include <bastypes.hxx>
39cdf0e10cSrcweir #include <basidesh.hrc>
40cdf0e10cSrcweir #include <basidesh.hxx>
41cdf0e10cSrcweir #include <iderdll.hxx>
42cdf0e10cSrcweir #include <iderdll2.hxx>
43cdf0e10cSrcweir #include <sbxitem.hxx>
44cdf0e10cSrcweir
45cdf0e10cSrcweir //#ifndef _SFX_HELP_HXX //autogen
46cdf0e10cSrcweir //#include <sfx2/sfxhelp.hxx>
47cdf0e10cSrcweir //#endif
48cdf0e10cSrcweir
49cdf0e10cSrcweir
ObjectTreeListBox(Window * pParent,const ResId & rRes)50cdf0e10cSrcweir ObjectTreeListBox::ObjectTreeListBox( Window* pParent, const ResId& rRes )
51cdf0e10cSrcweir : BasicTreeListBox( pParent, rRes )
52cdf0e10cSrcweir {
53cdf0e10cSrcweir }
54cdf0e10cSrcweir
~ObjectTreeListBox()55cdf0e10cSrcweir ObjectTreeListBox::~ObjectTreeListBox()
56cdf0e10cSrcweir {
57cdf0e10cSrcweir }
58cdf0e10cSrcweir
Command(const CommandEvent &)59cdf0e10cSrcweir void ObjectTreeListBox::Command( const CommandEvent& )
60cdf0e10cSrcweir {
61cdf0e10cSrcweir }
62cdf0e10cSrcweir
MouseButtonDown(const MouseEvent & rMEvt)63cdf0e10cSrcweir void ObjectTreeListBox::MouseButtonDown( const MouseEvent& rMEvt )
64cdf0e10cSrcweir {
65cdf0e10cSrcweir BasicTreeListBox::MouseButtonDown( rMEvt );
66cdf0e10cSrcweir
67cdf0e10cSrcweir if ( rMEvt.IsLeft() && ( rMEvt.GetClicks() == 2 ) )
68cdf0e10cSrcweir {
69*d67f091bSTsutomu Uchino OpenCurrent();
70*d67f091bSTsutomu Uchino }
71*d67f091bSTsutomu Uchino }
72*d67f091bSTsutomu Uchino
KeyInput(const KeyEvent & rEvt)73*d67f091bSTsutomu Uchino void ObjectTreeListBox::KeyInput( const KeyEvent& rEvt )
74*d67f091bSTsutomu Uchino {
75*d67f091bSTsutomu Uchino if ( rEvt.GetKeyCode() == KEY_RETURN && OpenCurrent() )
76*d67f091bSTsutomu Uchino {
77*d67f091bSTsutomu Uchino return;
78*d67f091bSTsutomu Uchino }
79*d67f091bSTsutomu Uchino BasicTreeListBox::KeyInput( rEvt );
80*d67f091bSTsutomu Uchino }
81*d67f091bSTsutomu Uchino
OpenCurrent()82*d67f091bSTsutomu Uchino bool ObjectTreeListBox::OpenCurrent()
83*d67f091bSTsutomu Uchino {
84cdf0e10cSrcweir BasicEntryDescriptor aDesc( GetEntryDescriptor( GetCurEntry() ) );
85cdf0e10cSrcweir
86cdf0e10cSrcweir if ( aDesc.GetType() == OBJ_TYPE_METHOD )
87cdf0e10cSrcweir {
88cdf0e10cSrcweir BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
89cdf0e10cSrcweir SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL;
90cdf0e10cSrcweir SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL;
91cdf0e10cSrcweir if( pDispatcher )
92cdf0e10cSrcweir {
93cdf0e10cSrcweir SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, aDesc.GetDocument(), aDesc.GetLibName(), aDesc.GetName(),
94cdf0e10cSrcweir aDesc.GetMethodName(), ConvertType( aDesc.GetType() ) );
95cdf0e10cSrcweir pDispatcher->Execute( SID_BASICIDE_SHOWSBX,
96cdf0e10cSrcweir SFX_CALLMODE_SYNCHRON, &aSbxItem, 0L );
97*d67f091bSTsutomu Uchino return true;
98cdf0e10cSrcweir }
99cdf0e10cSrcweir }
100*d67f091bSTsutomu Uchino return false;
101cdf0e10cSrcweir }
102cdf0e10cSrcweir
103cdf0e10cSrcweir
ObjectCatalog(Window * pParent)104cdf0e10cSrcweir ObjectCatalog::ObjectCatalog( Window * pParent )
105cdf0e10cSrcweir :FloatingWindow( pParent, IDEResId( RID_BASICIDE_OBJCAT ) )
106cdf0e10cSrcweir ,aMacroTreeList( this, IDEResId( RID_TLB_MACROS ) )
107cdf0e10cSrcweir ,aToolBox(this, IDEResId(RID_TB_TOOLBOX), IDEResId(RID_IMGLST_TB_HC))
108cdf0e10cSrcweir ,aMacroDescr( this, IDEResId( RID_FT_MACRODESCR ) )
109cdf0e10cSrcweir {
110cdf0e10cSrcweir FreeResource();
111cdf0e10cSrcweir
112cdf0e10cSrcweir aToolBox.SetOutStyle( TOOLBOX_STYLE_FLAT );
113cdf0e10cSrcweir aToolBox.SetSizePixel( aToolBox.CalcWindowSizePixel() );
114cdf0e10cSrcweir aToolBox.SetSelectHdl( LINK( this, ObjectCatalog, ToolBoxHdl ) );
115cdf0e10cSrcweir
116cdf0e10cSrcweir aMacroTreeList.SetStyle( WB_BORDER | WB_TABSTOP |
117cdf0e10cSrcweir WB_HASLINES | WB_HASLINESATROOT |
118cdf0e10cSrcweir WB_HASBUTTONS | WB_HASBUTTONSATROOT |
119cdf0e10cSrcweir WB_HSCROLL );
120cdf0e10cSrcweir
121cdf0e10cSrcweir aMacroTreeList.SetSelectHdl( LINK( this, ObjectCatalog, TreeListHighlightHdl ) );
122cdf0e10cSrcweir aMacroTreeList.SetAccessibleName(String(IDEResId(RID_STR_TLB_MACROS)));
123cdf0e10cSrcweir aMacroTreeList.ScanAllEntries();
124cdf0e10cSrcweir aMacroTreeList.GrabFocus();
125cdf0e10cSrcweir
126cdf0e10cSrcweir CheckButtons();
127cdf0e10cSrcweir
128cdf0e10cSrcweir Point aPos = IDE_DLL()->GetExtraData()->GetObjectCatalogPos();
129cdf0e10cSrcweir Size aSize = IDE_DLL()->GetExtraData()->GetObjectCatalogSize();
130cdf0e10cSrcweir if ( aPos.X() == INVPOSITION )
131cdf0e10cSrcweir {
132cdf0e10cSrcweir // Zentriert nach AppWin:
133cdf0e10cSrcweir Window* pWin = GetParent();
134cdf0e10cSrcweir aPos = pWin->OutputToScreenPixel( Point( 0, 0 ) );
135cdf0e10cSrcweir Size aAppWinSz = pWin->GetSizePixel();
136cdf0e10cSrcweir Size aDlgWinSz = GetSizePixel();
137cdf0e10cSrcweir aPos.X() += aAppWinSz.Width() / 2;
138cdf0e10cSrcweir aPos.X() -= aDlgWinSz.Width() / 2;
139cdf0e10cSrcweir aPos.Y() += aAppWinSz.Height() / 2;
140cdf0e10cSrcweir aPos.Y() -= aDlgWinSz.Height() / 2;
141cdf0e10cSrcweir }
142cdf0e10cSrcweir SetPosPixel( aPos );
143cdf0e10cSrcweir if ( aSize.Width() )
144cdf0e10cSrcweir SetOutputSizePixel( aSize );
145cdf0e10cSrcweir
146cdf0e10cSrcweir Resize(); // damit der Resize-Handler die Controls anordnet
147cdf0e10cSrcweir
148cdf0e10cSrcweir // make object catalog keyboard accessible
149cdf0e10cSrcweir pParent->GetSystemWindow()->GetTaskPaneList()->AddWindow( this );
150cdf0e10cSrcweir }
151cdf0e10cSrcweir
~ObjectCatalog()152cdf0e10cSrcweir ObjectCatalog::~ObjectCatalog()
153cdf0e10cSrcweir {
154cdf0e10cSrcweir GetParent()->GetSystemWindow()->GetTaskPaneList()->RemoveWindow( this );
155cdf0e10cSrcweir }
156cdf0e10cSrcweir
Move()157cdf0e10cSrcweir void __EXPORT ObjectCatalog::Move()
158cdf0e10cSrcweir {
159cdf0e10cSrcweir IDE_DLL()->GetExtraData()->SetObjectCatalogPos( GetPosPixel() );
160cdf0e10cSrcweir }
161cdf0e10cSrcweir
Close()162cdf0e10cSrcweir sal_Bool __EXPORT ObjectCatalog::Close()
163cdf0e10cSrcweir {
164cdf0e10cSrcweir aCancelHdl.Call( this );
165cdf0e10cSrcweir return sal_True;
166cdf0e10cSrcweir }
167cdf0e10cSrcweir
Resize()168cdf0e10cSrcweir void __EXPORT ObjectCatalog::Resize()
169cdf0e10cSrcweir {
170cdf0e10cSrcweir Size aOutSz = GetOutputSizePixel();
171cdf0e10cSrcweir IDE_DLL()->GetExtraData()->SetObjectCatalogSize( aOutSz );
172cdf0e10cSrcweir
173cdf0e10cSrcweir Point aTreePos = aMacroTreeList.GetPosPixel();
174cdf0e10cSrcweir Size aDescrSz = aMacroDescr.GetSizePixel();
175cdf0e10cSrcweir
176cdf0e10cSrcweir Size aTreeSz;
177cdf0e10cSrcweir long nCtrlWidth = aOutSz.Width() - 2*aTreePos.X();
178cdf0e10cSrcweir aTreeSz.Width() = nCtrlWidth;
179cdf0e10cSrcweir aTreeSz.Height() = aOutSz.Height() - aTreePos.Y() -
180cdf0e10cSrcweir 2*aTreePos.X() - aDescrSz.Height();
181cdf0e10cSrcweir
182cdf0e10cSrcweir if ( aTreeSz.Height() > 0 )
183cdf0e10cSrcweir {
184cdf0e10cSrcweir aMacroTreeList.SetSizePixel( aTreeSz );
185cdf0e10cSrcweir
186cdf0e10cSrcweir Point aDescrPos( aTreePos.X(), aTreePos.Y()+aTreeSz.Height()+aTreePos.X() );
187cdf0e10cSrcweir
188cdf0e10cSrcweir aMacroDescr.SetPosSizePixel( aDescrPos, Size( nCtrlWidth, aDescrSz.Height() ) );
189cdf0e10cSrcweir
190cdf0e10cSrcweir String aDesc = aMacroDescr.GetText();
191cdf0e10cSrcweir aMacroDescr.SetText(String());
192cdf0e10cSrcweir aMacroDescr.SetText(aDesc);
193cdf0e10cSrcweir }
194cdf0e10cSrcweir
195cdf0e10cSrcweir // Die Buttons oben bleiben immer unveraendert stehen...
196cdf0e10cSrcweir }
197cdf0e10cSrcweir
IMPL_LINK(ObjectCatalog,ToolBoxHdl,ToolBox *,pToolBox)198cdf0e10cSrcweir IMPL_LINK( ObjectCatalog, ToolBoxHdl, ToolBox*, pToolBox )
199cdf0e10cSrcweir {
200cdf0e10cSrcweir sal_uInt16 nCurItem = pToolBox->GetCurItemId();
201cdf0e10cSrcweir switch ( nCurItem )
202cdf0e10cSrcweir {
203cdf0e10cSrcweir case TBITEM_SHOW:
204cdf0e10cSrcweir {
205cdf0e10cSrcweir SfxAllItemSet aArgs( SFX_APP()->GetPool() );
206cdf0e10cSrcweir SfxRequest aRequest( SID_BASICIDE_APPEAR, SFX_CALLMODE_SYNCHRON, aArgs );
207cdf0e10cSrcweir SFX_APP()->ExecuteSlot( aRequest );
208cdf0e10cSrcweir
209cdf0e10cSrcweir SvLBoxEntry* pCurEntry = aMacroTreeList.GetCurEntry();
210cdf0e10cSrcweir DBG_ASSERT( pCurEntry, "Entry?!" );
211cdf0e10cSrcweir BasicEntryDescriptor aDesc( aMacroTreeList.GetEntryDescriptor( pCurEntry ) );
212cdf0e10cSrcweir BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
213cdf0e10cSrcweir SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL;
214cdf0e10cSrcweir SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL;
215cdf0e10cSrcweir if ( aDesc.GetType() == OBJ_TYPE_MODULE ||
216cdf0e10cSrcweir aDesc.GetType() == OBJ_TYPE_DIALOG ||
217cdf0e10cSrcweir aDesc.GetType() == OBJ_TYPE_METHOD )
218cdf0e10cSrcweir {
219cdf0e10cSrcweir if( pDispatcher )
220cdf0e10cSrcweir {
221cdf0e10cSrcweir SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, aDesc.GetDocument(), aDesc.GetLibName(), aDesc.GetName(),
222cdf0e10cSrcweir aDesc.GetMethodName(), aMacroTreeList.ConvertType( aDesc.GetType() ) );
223cdf0e10cSrcweir pDispatcher->Execute( SID_BASICIDE_SHOWSBX,
224cdf0e10cSrcweir SFX_CALLMODE_SYNCHRON, &aSbxItem, 0L );
225cdf0e10cSrcweir }
226cdf0e10cSrcweir }
227cdf0e10cSrcweir else
228cdf0e10cSrcweir {
229cdf0e10cSrcweir ErrorBox( this, WB_OK, String( IDEResId( RID_STR_OBJNOTFOUND ) ) ).Execute();
230cdf0e10cSrcweir aMacroTreeList.GetModel()->Remove( pCurEntry );
231cdf0e10cSrcweir CheckButtons();
232cdf0e10cSrcweir }
233cdf0e10cSrcweir }
234cdf0e10cSrcweir break;
235cdf0e10cSrcweir }
236cdf0e10cSrcweir
237cdf0e10cSrcweir return 0;
238cdf0e10cSrcweir }
239cdf0e10cSrcweir
240cdf0e10cSrcweir
241cdf0e10cSrcweir
CheckButtons()242cdf0e10cSrcweir void ObjectCatalog::CheckButtons()
243cdf0e10cSrcweir {
244cdf0e10cSrcweir SvLBoxEntry* pCurEntry = aMacroTreeList.GetCurEntry();
245cdf0e10cSrcweir BasicEntryType eType = pCurEntry ? ((BasicEntry*)pCurEntry->GetUserData())->GetType() : OBJ_TYPE_UNKNOWN;
246cdf0e10cSrcweir if ( eType == OBJ_TYPE_DIALOG || eType == OBJ_TYPE_MODULE || eType == OBJ_TYPE_METHOD )
247cdf0e10cSrcweir aToolBox.EnableItem( TBITEM_SHOW, sal_True );
248cdf0e10cSrcweir else
249cdf0e10cSrcweir aToolBox.EnableItem( TBITEM_SHOW, sal_False );
250cdf0e10cSrcweir }
251cdf0e10cSrcweir
252cdf0e10cSrcweir
253cdf0e10cSrcweir
IMPL_LINK_INLINE_START(ObjectCatalog,TreeListHighlightHdl,SvTreeListBox *,pBox)254cdf0e10cSrcweir IMPL_LINK_INLINE_START( ObjectCatalog, TreeListHighlightHdl, SvTreeListBox *, pBox )
255cdf0e10cSrcweir {
256cdf0e10cSrcweir if ( pBox->IsSelected( pBox->GetHdlEntry() ) )
257cdf0e10cSrcweir UpdateFields();
258cdf0e10cSrcweir return 0;
259cdf0e10cSrcweir }
IMPL_LINK_INLINE_END(ObjectCatalog,TreeListHighlightHdl,SvTreeListBox *,pBox)260cdf0e10cSrcweir IMPL_LINK_INLINE_END( ObjectCatalog, TreeListHighlightHdl, SvTreeListBox *, pBox )
261cdf0e10cSrcweir
262cdf0e10cSrcweir
263cdf0e10cSrcweir void ObjectCatalog::UpdateFields()
264cdf0e10cSrcweir {
265cdf0e10cSrcweir SvLBoxEntry* pCurEntry = aMacroTreeList.GetCurEntry();
266cdf0e10cSrcweir if ( pCurEntry )
267cdf0e10cSrcweir {
268cdf0e10cSrcweir CheckButtons();
269cdf0e10cSrcweir aMacroDescr.SetText( String() );
270cdf0e10cSrcweir SbxVariable* pVar = aMacroTreeList.FindVariable( pCurEntry );
271cdf0e10cSrcweir if ( pVar )
272cdf0e10cSrcweir {
273cdf0e10cSrcweir SbxInfoRef xInfo = pVar->GetInfo();
274cdf0e10cSrcweir if ( xInfo.Is() )
275cdf0e10cSrcweir aMacroDescr.SetText( xInfo->GetComment() );
276cdf0e10cSrcweir }
277cdf0e10cSrcweir }
278cdf0e10cSrcweir }
279cdf0e10cSrcweir
280cdf0e10cSrcweir
UpdateEntries()281cdf0e10cSrcweir void ObjectCatalog::UpdateEntries()
282cdf0e10cSrcweir {
283cdf0e10cSrcweir aMacroTreeList.UpdateEntries();
284cdf0e10cSrcweir }
285cdf0e10cSrcweir
SetCurrentEntry(BasicEntryDescriptor & rDesc)286cdf0e10cSrcweir void ObjectCatalog::SetCurrentEntry( BasicEntryDescriptor& rDesc )
287cdf0e10cSrcweir {
288cdf0e10cSrcweir aMacroTreeList.SetCurrentEntry( rDesc );
289cdf0e10cSrcweir }
290cdf0e10cSrcweir
ObjectCatalogToolBox_Impl(Window * pParent,ResId const & rResId,ResId const & rImagesHighContrastId)291cdf0e10cSrcweir ObjectCatalogToolBox_Impl::ObjectCatalogToolBox_Impl(
292cdf0e10cSrcweir Window * pParent, ResId const & rResId,
293cdf0e10cSrcweir ResId const & rImagesHighContrastId):
294cdf0e10cSrcweir ToolBox(pParent, rResId),
295cdf0e10cSrcweir m_aImagesNormal(GetImageList()),
296cdf0e10cSrcweir m_aImagesHighContrast(rImagesHighContrastId),
297cdf0e10cSrcweir m_bHighContrast(false)
298cdf0e10cSrcweir {
299cdf0e10cSrcweir setImages();
300cdf0e10cSrcweir }
301cdf0e10cSrcweir
302cdf0e10cSrcweir // virtual
DataChanged(DataChangedEvent const & rDCEvt)303cdf0e10cSrcweir void ObjectCatalogToolBox_Impl::DataChanged(DataChangedEvent const & rDCEvt)
304cdf0e10cSrcweir {
305cdf0e10cSrcweir ToolBox::DataChanged(rDCEvt);
306cdf0e10cSrcweir if ((rDCEvt.GetType() == DATACHANGED_SETTINGS
307cdf0e10cSrcweir || rDCEvt.GetType() == DATACHANGED_DISPLAY)
308cdf0e10cSrcweir && (rDCEvt.GetFlags() & SETTINGS_STYLE) != 0)
309cdf0e10cSrcweir setImages();
310cdf0e10cSrcweir }
311cdf0e10cSrcweir
setImages()312cdf0e10cSrcweir void ObjectCatalogToolBox_Impl::setImages()
313cdf0e10cSrcweir {
314cdf0e10cSrcweir bool bHC = GetSettings().GetStyleSettings().GetHighContrastMode();
315cdf0e10cSrcweir if (bHC != m_bHighContrast)
316cdf0e10cSrcweir {
317cdf0e10cSrcweir SetImageList(bHC ? m_aImagesHighContrast : m_aImagesNormal);
318cdf0e10cSrcweir m_bHighContrast = bHC;
319cdf0e10cSrcweir }
320cdf0e10cSrcweir }
321