1*96de5490SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*96de5490SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*96de5490SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*96de5490SAndrew Rist * distributed with this work for additional information 6*96de5490SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*96de5490SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*96de5490SAndrew Rist * "License"); you may not use this file except in compliance 9*96de5490SAndrew Rist * with the License. You may obtain a copy of the License at 10*96de5490SAndrew Rist * 11*96de5490SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*96de5490SAndrew Rist * 13*96de5490SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*96de5490SAndrew Rist * software distributed under the License is distributed on an 15*96de5490SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*96de5490SAndrew Rist * KIND, either express or implied. See the License for the 17*96de5490SAndrew Rist * specific language governing permissions and limitations 18*96de5490SAndrew Rist * under the License. 19*96de5490SAndrew Rist * 20*96de5490SAndrew Rist *************************************************************/ 21*96de5490SAndrew Rist 22*96de5490SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_dbaccess.hxx" 26cdf0e10cSrcweir #ifndef DBAUI_APPICONCONTROL_HXX 27cdf0e10cSrcweir #include "AppIconControl.hxx" 28cdf0e10cSrcweir #endif 29cdf0e10cSrcweir #ifndef _TOOLS_DEBUG_HXX 30cdf0e10cSrcweir #include <tools/debug.hxx> 31cdf0e10cSrcweir #endif 32cdf0e10cSrcweir #ifndef _DBA_DBACCESS_HELPID_HRC_ 33cdf0e10cSrcweir #include "dbaccess_helpid.hrc" 34cdf0e10cSrcweir #endif 35cdf0e10cSrcweir #ifndef _DBAUI_MODULE_DBU_HXX_ 36cdf0e10cSrcweir #include "moduledbu.hxx" 37cdf0e10cSrcweir #endif 38cdf0e10cSrcweir #ifndef _DBU_APP_HRC_ 39cdf0e10cSrcweir #include "dbu_app.hrc" 40cdf0e10cSrcweir #endif 41cdf0e10cSrcweir #ifndef _IMAGE_HXX //autogen 42cdf0e10cSrcweir #include <vcl/image.hxx> 43cdf0e10cSrcweir #endif 44cdf0e10cSrcweir #ifndef _DBACCESS_UI_CALLBACKS_HXX_ 45cdf0e10cSrcweir #include "callbacks.hxx" 46cdf0e10cSrcweir #endif 47cdf0e10cSrcweir #ifndef DBAUI_APPELEMENTTYPE_HXX 48cdf0e10cSrcweir #include "AppElementType.hxx" 49cdf0e10cSrcweir #endif 50cdf0e10cSrcweir #include <memory> 51cdf0e10cSrcweir 52cdf0e10cSrcweir using namespace ::dbaui; 53cdf0e10cSrcweir //================================================================== 54cdf0e10cSrcweir // class OApplicationIconControl 55cdf0e10cSrcweir DBG_NAME(OApplicationIconControl) 56cdf0e10cSrcweir //================================================================== 57cdf0e10cSrcweir OApplicationIconControl::OApplicationIconControl(Window* _pParent) 58cdf0e10cSrcweir : SvtIconChoiceCtrl(_pParent,WB_ICON | WB_NOCOLUMNHEADER | WB_HIGHLIGHTFRAME | /*!WB_NOSELECTION |*/ 59cdf0e10cSrcweir WB_TABSTOP | WB_CLIPCHILDREN | WB_NOVSCROLL | WB_SMART_ARRANGE | WB_NOHSCROLL | WB_CENTER) 60cdf0e10cSrcweir ,DropTargetHelper(this) 61cdf0e10cSrcweir ,m_pActionListener(NULL) 62cdf0e10cSrcweir { 63cdf0e10cSrcweir DBG_CTOR(OApplicationIconControl,NULL); 64cdf0e10cSrcweir 65cdf0e10cSrcweir struct CategoryDescriptor 66cdf0e10cSrcweir { 67cdf0e10cSrcweir sal_uInt16 nLabelResId; 68cdf0e10cSrcweir ElementType eType; 69cdf0e10cSrcweir sal_uInt16 nImageResId; 70cdf0e10cSrcweir sal_uInt16 nImageResIdHC; 71cdf0e10cSrcweir } aCategories[] = { 72cdf0e10cSrcweir { RID_STR_TABLES_CONTAINER, E_TABLE, IMG_TABLEFOLDER_TREE_L, IMG_TABLEFOLDER_TREE_LHC }, 73cdf0e10cSrcweir { RID_STR_QUERIES_CONTAINER, E_QUERY, IMG_QUERYFOLDER_TREE_L, IMG_QUERYFOLDER_TREE_LHC }, 74cdf0e10cSrcweir { RID_STR_FORMS_CONTAINER, E_FORM, IMG_FORMFOLDER_TREE_L, IMG_FORMFOLDER_TREE_LHC }, 75cdf0e10cSrcweir { RID_STR_REPORTS_CONTAINER, E_REPORT, IMG_REPORTFOLDER_TREE_L,IMG_REPORTFOLDER_TREE_LHC } 76cdf0e10cSrcweir }; 77cdf0e10cSrcweir for ( size_t i=0; i < sizeof(aCategories)/sizeof(aCategories[0]); ++i) 78cdf0e10cSrcweir { 79cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pEntry = InsertEntry( 80cdf0e10cSrcweir String( ModuleRes( aCategories[i].nLabelResId ) ), 81cdf0e10cSrcweir Image( ModuleRes( aCategories[i].nImageResId ) ), 82cdf0e10cSrcweir Image( ModuleRes( aCategories[i].nImageResIdHC ) ) ); 83cdf0e10cSrcweir if ( pEntry ) 84cdf0e10cSrcweir pEntry->SetUserData( new ElementType( aCategories[i].eType ) ); 85cdf0e10cSrcweir } 86cdf0e10cSrcweir 87cdf0e10cSrcweir SetChoiceWithCursor( sal_True ); 88cdf0e10cSrcweir SetSelectionMode(SINGLE_SELECTION); 89cdf0e10cSrcweir } 90cdf0e10cSrcweir // ----------------------------------------------------------------------------- 91cdf0e10cSrcweir OApplicationIconControl::~OApplicationIconControl() 92cdf0e10cSrcweir { 93cdf0e10cSrcweir sal_uLong nCount = GetEntryCount(); 94cdf0e10cSrcweir for ( sal_uLong i = 0; i < nCount; ++i ) 95cdf0e10cSrcweir { 96cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pEntry = GetEntry( i ); 97cdf0e10cSrcweir if ( pEntry ) 98cdf0e10cSrcweir { 99cdf0e10cSrcweir ::std::auto_ptr<ElementType> aType(static_cast<ElementType*>(pEntry->GetUserData())); 100cdf0e10cSrcweir pEntry->SetUserData(NULL); 101cdf0e10cSrcweir } 102cdf0e10cSrcweir } 103cdf0e10cSrcweir 104cdf0e10cSrcweir DBG_DTOR(OApplicationIconControl,NULL); 105cdf0e10cSrcweir } 106cdf0e10cSrcweir // ----------------------------------------------------------------------------- 107cdf0e10cSrcweir sal_Int8 OApplicationIconControl::AcceptDrop( const AcceptDropEvent& _rEvt ) 108cdf0e10cSrcweir { 109cdf0e10cSrcweir sal_Int8 nDropOption = DND_ACTION_NONE; 110cdf0e10cSrcweir if ( m_pActionListener ) 111cdf0e10cSrcweir { 112cdf0e10cSrcweir 113cdf0e10cSrcweir SvxIconChoiceCtrlEntry* pEntry = GetEntry(_rEvt.maPosPixel); 114cdf0e10cSrcweir if ( pEntry ) 115cdf0e10cSrcweir { 116cdf0e10cSrcweir SetCursor(pEntry); 117cdf0e10cSrcweir nDropOption = m_pActionListener->queryDrop( _rEvt, GetDataFlavorExVector() ); 118cdf0e10cSrcweir m_aMousePos = _rEvt.maPosPixel; 119cdf0e10cSrcweir } 120cdf0e10cSrcweir } 121cdf0e10cSrcweir 122cdf0e10cSrcweir return nDropOption; 123cdf0e10cSrcweir } 124cdf0e10cSrcweir // ----------------------------------------------------------------------------- 125cdf0e10cSrcweir sal_Int8 OApplicationIconControl::ExecuteDrop( const ExecuteDropEvent& _rEvt ) 126cdf0e10cSrcweir { 127cdf0e10cSrcweir if ( m_pActionListener ) 128cdf0e10cSrcweir return m_pActionListener->executeDrop( _rEvt ); 129cdf0e10cSrcweir 130cdf0e10cSrcweir return DND_ACTION_NONE; 131cdf0e10cSrcweir } 132