merge the formfield patch from ooo-build
[ooovba.git] / dbaccess / source / ui / app / AppIconControl.cxx
blobec219adec3e01fc94da55af8aacb2452280512bf
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: AppIconControl.cxx,v $
10 * $Revision: 1.11 $
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_dbaccess.hxx"
33 #ifndef DBAUI_APPICONCONTROL_HXX
34 #include "AppIconControl.hxx"
35 #endif
36 #ifndef _TOOLS_DEBUG_HXX
37 #include <tools/debug.hxx>
38 #endif
39 #ifndef _DBA_DBACCESS_HELPID_HRC_
40 #include "dbaccess_helpid.hrc"
41 #endif
42 #ifndef _DBAUI_MODULE_DBU_HXX_
43 #include "moduledbu.hxx"
44 #endif
45 #ifndef _DBU_APP_HRC_
46 #include "dbu_app.hrc"
47 #endif
48 #ifndef _IMAGE_HXX //autogen
49 #include <vcl/image.hxx>
50 #endif
51 #ifndef _DBACCESS_UI_CALLBACKS_HXX_
52 #include "callbacks.hxx"
53 #endif
54 #ifndef DBAUI_APPELEMENTTYPE_HXX
55 #include "AppElementType.hxx"
56 #endif
57 #include <memory>
59 using namespace ::dbaui;
60 //==================================================================
61 // class OApplicationIconControl
62 DBG_NAME(OApplicationIconControl)
63 //==================================================================
64 OApplicationIconControl::OApplicationIconControl(Window* _pParent)
65 : SvtIconChoiceCtrl(_pParent,WB_ICON | WB_NOCOLUMNHEADER | WB_HIGHLIGHTFRAME | /*!WB_NOSELECTION |*/
66 WB_TABSTOP | WB_CLIPCHILDREN | WB_NOVSCROLL | WB_SMART_ARRANGE | WB_NOHSCROLL | WB_CENTER)
67 ,DropTargetHelper(this)
68 ,m_pActionListener(NULL)
70 DBG_CTOR(OApplicationIconControl,NULL);
72 struct CategoryDescriptor
74 USHORT nLabelResId;
75 ElementType eType;
76 USHORT nImageResId;
77 USHORT nImageResIdHC;
78 } aCategories[] = {
79 { RID_STR_TABLES_CONTAINER, E_TABLE, IMG_TABLEFOLDER_TREE_L, IMG_TABLEFOLDER_TREE_LHC },
80 { RID_STR_QUERIES_CONTAINER, E_QUERY, IMG_QUERYFOLDER_TREE_L, IMG_QUERYFOLDER_TREE_LHC },
81 { RID_STR_FORMS_CONTAINER, E_FORM, IMG_FORMFOLDER_TREE_L, IMG_FORMFOLDER_TREE_LHC },
82 { RID_STR_REPORTS_CONTAINER, E_REPORT, IMG_REPORTFOLDER_TREE_L,IMG_REPORTFOLDER_TREE_LHC }
84 for ( size_t i=0; i < sizeof(aCategories)/sizeof(aCategories[0]); ++i)
86 SvxIconChoiceCtrlEntry* pEntry = InsertEntry(
87 String( ModuleRes( aCategories[i].nLabelResId ) ),
88 Image( ModuleRes( aCategories[i].nImageResId ) ),
89 Image( ModuleRes( aCategories[i].nImageResIdHC ) ) );
90 if ( pEntry )
91 pEntry->SetUserData( new ElementType( aCategories[i].eType ) );
94 SetChoiceWithCursor( TRUE );
95 SetSelectionMode(SINGLE_SELECTION);
97 // -----------------------------------------------------------------------------
98 OApplicationIconControl::~OApplicationIconControl()
100 ULONG nCount = GetEntryCount();
101 for ( ULONG i = 0; i < nCount; ++i )
103 SvxIconChoiceCtrlEntry* pEntry = GetEntry( i );
104 if ( pEntry )
106 ::std::auto_ptr<ElementType> aType(static_cast<ElementType*>(pEntry->GetUserData()));
107 pEntry->SetUserData(NULL);
111 DBG_DTOR(OApplicationIconControl,NULL);
113 // -----------------------------------------------------------------------------
114 sal_Int8 OApplicationIconControl::AcceptDrop( const AcceptDropEvent& _rEvt )
116 sal_Int8 nDropOption = DND_ACTION_NONE;
117 if ( m_pActionListener )
120 SvxIconChoiceCtrlEntry* pEntry = GetEntry(_rEvt.maPosPixel);
121 if ( pEntry )
123 SetCursor(pEntry);
124 nDropOption = m_pActionListener->queryDrop( _rEvt, GetDataFlavorExVector() );
125 m_aMousePos = _rEvt.maPosPixel;
129 return nDropOption;
131 // -----------------------------------------------------------------------------
132 sal_Int8 OApplicationIconControl::ExecuteDrop( const ExecuteDropEvent& _rEvt )
134 if ( m_pActionListener )
135 return m_pActionListener->executeDrop( _rEvt );
137 return DND_ACTION_NONE;