1*31598a22SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 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 10cdf0e10cSrcweir * 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. 19cdf0e10cSrcweir * 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 #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 50cdf0e10cSrcweir ObjectTreeListBox::ObjectTreeListBox( Window* pParent, const ResId& rRes ) 51cdf0e10cSrcweir : BasicTreeListBox( pParent, rRes ) 52cdf0e10cSrcweir { 53cdf0e10cSrcweir } 54cdf0e10cSrcweir 55cdf0e10cSrcweir ObjectTreeListBox::~ObjectTreeListBox() 56cdf0e10cSrcweir { 57cdf0e10cSrcweir } 58cdf0e10cSrcweir 59cdf0e10cSrcweir void ObjectTreeListBox::Command( const CommandEvent& ) 60cdf0e10cSrcweir { 61cdf0e10cSrcweir } 62cdf0e10cSrcweir 63cdf0e10cSrcweir void ObjectTreeListBox::MouseButtonDown( const MouseEvent& rMEvt ) 64cdf0e10cSrcweir { 65cdf0e10cSrcweir BasicTreeListBox::MouseButtonDown( rMEvt ); 66cdf0e10cSrcweir 67cdf0e10cSrcweir if ( rMEvt.IsLeft() && ( rMEvt.GetClicks() == 2 ) ) 68cdf0e10cSrcweir { 69cdf0e10cSrcweir BasicEntryDescriptor aDesc( GetEntryDescriptor( GetCurEntry() ) ); 70cdf0e10cSrcweir 71cdf0e10cSrcweir if ( aDesc.GetType() == OBJ_TYPE_METHOD ) 72cdf0e10cSrcweir { 73cdf0e10cSrcweir BasicIDEShell* pIDEShell = IDE_DLL()->GetShell(); 74cdf0e10cSrcweir SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL; 75cdf0e10cSrcweir SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL; 76cdf0e10cSrcweir if( pDispatcher ) 77cdf0e10cSrcweir { 78cdf0e10cSrcweir SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, aDesc.GetDocument(), aDesc.GetLibName(), aDesc.GetName(), 79cdf0e10cSrcweir aDesc.GetMethodName(), ConvertType( aDesc.GetType() ) ); 80cdf0e10cSrcweir pDispatcher->Execute( SID_BASICIDE_SHOWSBX, 81cdf0e10cSrcweir SFX_CALLMODE_SYNCHRON, &aSbxItem, 0L ); 82cdf0e10cSrcweir } 83cdf0e10cSrcweir } 84cdf0e10cSrcweir } 85cdf0e10cSrcweir } 86cdf0e10cSrcweir 87cdf0e10cSrcweir 88cdf0e10cSrcweir 89cdf0e10cSrcweir ObjectCatalog::ObjectCatalog( Window * pParent ) 90cdf0e10cSrcweir :FloatingWindow( pParent, IDEResId( RID_BASICIDE_OBJCAT ) ) 91cdf0e10cSrcweir ,aMacroTreeList( this, IDEResId( RID_TLB_MACROS ) ) 92cdf0e10cSrcweir ,aToolBox(this, IDEResId(RID_TB_TOOLBOX), IDEResId(RID_IMGLST_TB_HC)) 93cdf0e10cSrcweir ,aMacroDescr( this, IDEResId( RID_FT_MACRODESCR ) ) 94cdf0e10cSrcweir { 95cdf0e10cSrcweir FreeResource(); 96cdf0e10cSrcweir 97cdf0e10cSrcweir aToolBox.SetOutStyle( TOOLBOX_STYLE_FLAT ); 98cdf0e10cSrcweir aToolBox.SetSizePixel( aToolBox.CalcWindowSizePixel() ); 99cdf0e10cSrcweir aToolBox.SetSelectHdl( LINK( this, ObjectCatalog, ToolBoxHdl ) ); 100cdf0e10cSrcweir 101cdf0e10cSrcweir aMacroTreeList.SetStyle( WB_BORDER | WB_TABSTOP | 102cdf0e10cSrcweir WB_HASLINES | WB_HASLINESATROOT | 103cdf0e10cSrcweir WB_HASBUTTONS | WB_HASBUTTONSATROOT | 104cdf0e10cSrcweir WB_HSCROLL ); 105cdf0e10cSrcweir 106cdf0e10cSrcweir aMacroTreeList.SetSelectHdl( LINK( this, ObjectCatalog, TreeListHighlightHdl ) ); 107cdf0e10cSrcweir aMacroTreeList.SetAccessibleName(String(IDEResId(RID_STR_TLB_MACROS))); 108cdf0e10cSrcweir aMacroTreeList.ScanAllEntries(); 109cdf0e10cSrcweir aMacroTreeList.GrabFocus(); 110cdf0e10cSrcweir 111cdf0e10cSrcweir CheckButtons(); 112cdf0e10cSrcweir 113cdf0e10cSrcweir Point aPos = IDE_DLL()->GetExtraData()->GetObjectCatalogPos(); 114cdf0e10cSrcweir Size aSize = IDE_DLL()->GetExtraData()->GetObjectCatalogSize(); 115cdf0e10cSrcweir if ( aPos.X() == INVPOSITION ) 116cdf0e10cSrcweir { 117cdf0e10cSrcweir // Zentriert nach AppWin: 118cdf0e10cSrcweir Window* pWin = GetParent(); 119cdf0e10cSrcweir aPos = pWin->OutputToScreenPixel( Point( 0, 0 ) ); 120cdf0e10cSrcweir Size aAppWinSz = pWin->GetSizePixel(); 121cdf0e10cSrcweir Size aDlgWinSz = GetSizePixel(); 122cdf0e10cSrcweir aPos.X() += aAppWinSz.Width() / 2; 123cdf0e10cSrcweir aPos.X() -= aDlgWinSz.Width() / 2; 124cdf0e10cSrcweir aPos.Y() += aAppWinSz.Height() / 2; 125cdf0e10cSrcweir aPos.Y() -= aDlgWinSz.Height() / 2; 126cdf0e10cSrcweir } 127cdf0e10cSrcweir SetPosPixel( aPos ); 128cdf0e10cSrcweir if ( aSize.Width() ) 129cdf0e10cSrcweir SetOutputSizePixel( aSize ); 130cdf0e10cSrcweir 131cdf0e10cSrcweir Resize(); // damit der Resize-Handler die Controls anordnet 132cdf0e10cSrcweir 133cdf0e10cSrcweir // make object catalog keyboard accessible 134cdf0e10cSrcweir pParent->GetSystemWindow()->GetTaskPaneList()->AddWindow( this ); 135cdf0e10cSrcweir } 136cdf0e10cSrcweir 137cdf0e10cSrcweir ObjectCatalog::~ObjectCatalog() 138cdf0e10cSrcweir { 139cdf0e10cSrcweir GetParent()->GetSystemWindow()->GetTaskPaneList()->RemoveWindow( this ); 140cdf0e10cSrcweir } 141cdf0e10cSrcweir 142cdf0e10cSrcweir void __EXPORT ObjectCatalog::Move() 143cdf0e10cSrcweir { 144cdf0e10cSrcweir IDE_DLL()->GetExtraData()->SetObjectCatalogPos( GetPosPixel() ); 145cdf0e10cSrcweir } 146cdf0e10cSrcweir 147cdf0e10cSrcweir sal_Bool __EXPORT ObjectCatalog::Close() 148cdf0e10cSrcweir { 149cdf0e10cSrcweir aCancelHdl.Call( this ); 150cdf0e10cSrcweir return sal_True; 151cdf0e10cSrcweir } 152cdf0e10cSrcweir 153cdf0e10cSrcweir void __EXPORT ObjectCatalog::Resize() 154cdf0e10cSrcweir { 155cdf0e10cSrcweir Size aOutSz = GetOutputSizePixel(); 156cdf0e10cSrcweir IDE_DLL()->GetExtraData()->SetObjectCatalogSize( aOutSz ); 157cdf0e10cSrcweir 158cdf0e10cSrcweir Point aTreePos = aMacroTreeList.GetPosPixel(); 159cdf0e10cSrcweir Size aDescrSz = aMacroDescr.GetSizePixel(); 160cdf0e10cSrcweir 161cdf0e10cSrcweir Size aTreeSz; 162cdf0e10cSrcweir long nCtrlWidth = aOutSz.Width() - 2*aTreePos.X(); 163cdf0e10cSrcweir aTreeSz.Width() = nCtrlWidth; 164cdf0e10cSrcweir aTreeSz.Height() = aOutSz.Height() - aTreePos.Y() - 165cdf0e10cSrcweir 2*aTreePos.X() - aDescrSz.Height(); 166cdf0e10cSrcweir 167cdf0e10cSrcweir if ( aTreeSz.Height() > 0 ) 168cdf0e10cSrcweir { 169cdf0e10cSrcweir aMacroTreeList.SetSizePixel( aTreeSz ); 170cdf0e10cSrcweir 171cdf0e10cSrcweir Point aDescrPos( aTreePos.X(), aTreePos.Y()+aTreeSz.Height()+aTreePos.X() ); 172cdf0e10cSrcweir 173cdf0e10cSrcweir aMacroDescr.SetPosSizePixel( aDescrPos, Size( nCtrlWidth, aDescrSz.Height() ) ); 174cdf0e10cSrcweir 175cdf0e10cSrcweir String aDesc = aMacroDescr.GetText(); 176cdf0e10cSrcweir aMacroDescr.SetText(String()); 177cdf0e10cSrcweir aMacroDescr.SetText(aDesc); 178cdf0e10cSrcweir } 179cdf0e10cSrcweir 180cdf0e10cSrcweir // Die Buttons oben bleiben immer unveraendert stehen... 181cdf0e10cSrcweir } 182cdf0e10cSrcweir 183cdf0e10cSrcweir IMPL_LINK( ObjectCatalog, ToolBoxHdl, ToolBox*, pToolBox ) 184cdf0e10cSrcweir { 185cdf0e10cSrcweir sal_uInt16 nCurItem = pToolBox->GetCurItemId(); 186cdf0e10cSrcweir switch ( nCurItem ) 187cdf0e10cSrcweir { 188cdf0e10cSrcweir case TBITEM_SHOW: 189cdf0e10cSrcweir { 190cdf0e10cSrcweir SfxAllItemSet aArgs( SFX_APP()->GetPool() ); 191cdf0e10cSrcweir SfxRequest aRequest( SID_BASICIDE_APPEAR, SFX_CALLMODE_SYNCHRON, aArgs ); 192cdf0e10cSrcweir SFX_APP()->ExecuteSlot( aRequest ); 193cdf0e10cSrcweir 194cdf0e10cSrcweir SvLBoxEntry* pCurEntry = aMacroTreeList.GetCurEntry(); 195cdf0e10cSrcweir DBG_ASSERT( pCurEntry, "Entry?!" ); 196cdf0e10cSrcweir BasicEntryDescriptor aDesc( aMacroTreeList.GetEntryDescriptor( pCurEntry ) ); 197cdf0e10cSrcweir BasicIDEShell* pIDEShell = IDE_DLL()->GetShell(); 198cdf0e10cSrcweir SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL; 199cdf0e10cSrcweir SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL; 200cdf0e10cSrcweir if ( aDesc.GetType() == OBJ_TYPE_MODULE || 201cdf0e10cSrcweir aDesc.GetType() == OBJ_TYPE_DIALOG || 202cdf0e10cSrcweir aDesc.GetType() == OBJ_TYPE_METHOD ) 203cdf0e10cSrcweir { 204cdf0e10cSrcweir if( pDispatcher ) 205cdf0e10cSrcweir { 206cdf0e10cSrcweir SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, aDesc.GetDocument(), aDesc.GetLibName(), aDesc.GetName(), 207cdf0e10cSrcweir aDesc.GetMethodName(), aMacroTreeList.ConvertType( aDesc.GetType() ) ); 208cdf0e10cSrcweir pDispatcher->Execute( SID_BASICIDE_SHOWSBX, 209cdf0e10cSrcweir SFX_CALLMODE_SYNCHRON, &aSbxItem, 0L ); 210cdf0e10cSrcweir } 211cdf0e10cSrcweir } 212cdf0e10cSrcweir else 213cdf0e10cSrcweir { 214cdf0e10cSrcweir ErrorBox( this, WB_OK, String( IDEResId( RID_STR_OBJNOTFOUND ) ) ).Execute(); 215cdf0e10cSrcweir aMacroTreeList.GetModel()->Remove( pCurEntry ); 216cdf0e10cSrcweir CheckButtons(); 217cdf0e10cSrcweir } 218cdf0e10cSrcweir } 219cdf0e10cSrcweir break; 220cdf0e10cSrcweir } 221cdf0e10cSrcweir 222cdf0e10cSrcweir return 0; 223cdf0e10cSrcweir } 224cdf0e10cSrcweir 225cdf0e10cSrcweir 226cdf0e10cSrcweir 227cdf0e10cSrcweir void ObjectCatalog::CheckButtons() 228cdf0e10cSrcweir { 229cdf0e10cSrcweir SvLBoxEntry* pCurEntry = aMacroTreeList.GetCurEntry(); 230cdf0e10cSrcweir BasicEntryType eType = pCurEntry ? ((BasicEntry*)pCurEntry->GetUserData())->GetType() : OBJ_TYPE_UNKNOWN; 231cdf0e10cSrcweir if ( eType == OBJ_TYPE_DIALOG || eType == OBJ_TYPE_MODULE || eType == OBJ_TYPE_METHOD ) 232cdf0e10cSrcweir aToolBox.EnableItem( TBITEM_SHOW, sal_True ); 233cdf0e10cSrcweir else 234cdf0e10cSrcweir aToolBox.EnableItem( TBITEM_SHOW, sal_False ); 235cdf0e10cSrcweir } 236cdf0e10cSrcweir 237cdf0e10cSrcweir 238cdf0e10cSrcweir 239cdf0e10cSrcweir IMPL_LINK_INLINE_START( ObjectCatalog, TreeListHighlightHdl, SvTreeListBox *, pBox ) 240cdf0e10cSrcweir { 241cdf0e10cSrcweir if ( pBox->IsSelected( pBox->GetHdlEntry() ) ) 242cdf0e10cSrcweir UpdateFields(); 243cdf0e10cSrcweir return 0; 244cdf0e10cSrcweir } 245cdf0e10cSrcweir IMPL_LINK_INLINE_END( ObjectCatalog, TreeListHighlightHdl, SvTreeListBox *, pBox ) 246cdf0e10cSrcweir 247cdf0e10cSrcweir 248cdf0e10cSrcweir void ObjectCatalog::UpdateFields() 249cdf0e10cSrcweir { 250cdf0e10cSrcweir SvLBoxEntry* pCurEntry = aMacroTreeList.GetCurEntry(); 251cdf0e10cSrcweir if ( pCurEntry ) 252cdf0e10cSrcweir { 253cdf0e10cSrcweir CheckButtons(); 254cdf0e10cSrcweir aMacroDescr.SetText( String() ); 255cdf0e10cSrcweir SbxVariable* pVar = aMacroTreeList.FindVariable( pCurEntry ); 256cdf0e10cSrcweir if ( pVar ) 257cdf0e10cSrcweir { 258cdf0e10cSrcweir SbxInfoRef xInfo = pVar->GetInfo(); 259cdf0e10cSrcweir if ( xInfo.Is() ) 260cdf0e10cSrcweir aMacroDescr.SetText( xInfo->GetComment() ); 261cdf0e10cSrcweir } 262cdf0e10cSrcweir } 263cdf0e10cSrcweir } 264cdf0e10cSrcweir 265cdf0e10cSrcweir 266cdf0e10cSrcweir void ObjectCatalog::UpdateEntries() 267cdf0e10cSrcweir { 268cdf0e10cSrcweir aMacroTreeList.UpdateEntries(); 269cdf0e10cSrcweir } 270cdf0e10cSrcweir 271cdf0e10cSrcweir void ObjectCatalog::SetCurrentEntry( BasicEntryDescriptor& rDesc ) 272cdf0e10cSrcweir { 273cdf0e10cSrcweir aMacroTreeList.SetCurrentEntry( rDesc ); 274cdf0e10cSrcweir } 275cdf0e10cSrcweir 276cdf0e10cSrcweir ObjectCatalogToolBox_Impl::ObjectCatalogToolBox_Impl( 277cdf0e10cSrcweir Window * pParent, ResId const & rResId, 278cdf0e10cSrcweir ResId const & rImagesHighContrastId): 279cdf0e10cSrcweir ToolBox(pParent, rResId), 280cdf0e10cSrcweir m_aImagesNormal(GetImageList()), 281cdf0e10cSrcweir m_aImagesHighContrast(rImagesHighContrastId), 282cdf0e10cSrcweir m_bHighContrast(false) 283cdf0e10cSrcweir { 284cdf0e10cSrcweir setImages(); 285cdf0e10cSrcweir } 286cdf0e10cSrcweir 287cdf0e10cSrcweir // virtual 288cdf0e10cSrcweir void ObjectCatalogToolBox_Impl::DataChanged(DataChangedEvent const & rDCEvt) 289cdf0e10cSrcweir { 290cdf0e10cSrcweir ToolBox::DataChanged(rDCEvt); 291cdf0e10cSrcweir if ((rDCEvt.GetType() == DATACHANGED_SETTINGS 292cdf0e10cSrcweir || rDCEvt.GetType() == DATACHANGED_DISPLAY) 293cdf0e10cSrcweir && (rDCEvt.GetFlags() & SETTINGS_STYLE) != 0) 294cdf0e10cSrcweir setImages(); 295cdf0e10cSrcweir } 296cdf0e10cSrcweir 297cdf0e10cSrcweir void ObjectCatalogToolBox_Impl::setImages() 298cdf0e10cSrcweir { 299cdf0e10cSrcweir bool bHC = GetSettings().GetStyleSettings().GetHighContrastMode(); 300cdf0e10cSrcweir if (bHC != m_bHighContrast) 301cdf0e10cSrcweir { 302cdf0e10cSrcweir SetImageList(bHC ? m_aImagesHighContrast : m_aImagesNormal); 303cdf0e10cSrcweir m_bHighContrast = bHC; 304cdf0e10cSrcweir } 305cdf0e10cSrcweir } 306