Version 3.6.0.2, tag libreoffice-3.6.0.2
[LibreOffice.git] / dbaccess / source / ui / app / AppIconControl.cxx
blob657154922292bdbb3367577fc35b7d2c1567f098
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include "AppIconControl.hxx"
30 #include <tools/debug.hxx>
31 #include "dbaccess_helpid.hrc"
32 #include "moduledbu.hxx"
33 #include "dbu_app.hrc"
34 #include <vcl/image.hxx>
35 #include "callbacks.hxx"
36 #include "AppElementType.hxx"
37 #include <memory>
39 using namespace ::dbaui;
40 //==================================================================
41 // class OApplicationIconControl
42 DBG_NAME(OApplicationIconControl)
43 //==================================================================
44 OApplicationIconControl::OApplicationIconControl(Window* _pParent)
45 : SvtIconChoiceCtrl(_pParent,WB_ICON | WB_NOCOLUMNHEADER | WB_HIGHLIGHTFRAME | /*!WB_NOSELECTION |*/
46 WB_TABSTOP | WB_CLIPCHILDREN | WB_NOVSCROLL | WB_SMART_ARRANGE | WB_NOHSCROLL | WB_CENTER)
47 ,DropTargetHelper(this)
48 ,m_pActionListener(NULL)
50 DBG_CTOR(OApplicationIconControl,NULL);
52 struct CategoryDescriptor
54 sal_uInt16 nLabelResId;
55 ElementType eType;
56 sal_uInt16 nImageResId;
57 } aCategories[] = {
58 { RID_STR_TABLES_CONTAINER, E_TABLE, IMG_TABLEFOLDER_TREE_L },
59 { RID_STR_QUERIES_CONTAINER, E_QUERY, IMG_QUERYFOLDER_TREE_L },
60 { RID_STR_FORMS_CONTAINER, E_FORM, IMG_FORMFOLDER_TREE_L },
61 { RID_STR_REPORTS_CONTAINER, E_REPORT, IMG_REPORTFOLDER_TREE_L }
63 for ( size_t i=0; i < sizeof(aCategories)/sizeof(aCategories[0]); ++i)
65 SvxIconChoiceCtrlEntry* pEntry = InsertEntry(
66 String( ModuleRes( aCategories[i].nLabelResId ) ) ,
67 Image( ModuleRes( aCategories[i].nImageResId ) ) );
68 if ( pEntry )
69 pEntry->SetUserData( new ElementType( aCategories[i].eType ) );
72 SetChoiceWithCursor( sal_True );
73 SetSelectionMode(SINGLE_SELECTION);
75 // -----------------------------------------------------------------------------
76 OApplicationIconControl::~OApplicationIconControl()
78 sal_uLong nCount = GetEntryCount();
79 for ( sal_uLong i = 0; i < nCount; ++i )
81 SvxIconChoiceCtrlEntry* pEntry = GetEntry( i );
82 if ( pEntry )
84 ::std::auto_ptr<ElementType> aType(static_cast<ElementType*>(pEntry->GetUserData()));
85 pEntry->SetUserData(NULL);
89 DBG_DTOR(OApplicationIconControl,NULL);
91 // -----------------------------------------------------------------------------
92 sal_Int8 OApplicationIconControl::AcceptDrop( const AcceptDropEvent& _rEvt )
94 sal_Int8 nDropOption = DND_ACTION_NONE;
95 if ( m_pActionListener )
98 SvxIconChoiceCtrlEntry* pEntry = GetEntry(_rEvt.maPosPixel);
99 if ( pEntry )
101 SetCursor(pEntry);
102 nDropOption = m_pActionListener->queryDrop( _rEvt, GetDataFlavorExVector() );
103 m_aMousePos = _rEvt.maPosPixel;
107 return nDropOption;
109 // -----------------------------------------------------------------------------
110 sal_Int8 OApplicationIconControl::ExecuteDrop( const ExecuteDropEvent& _rEvt )
112 if ( m_pActionListener )
113 return m_pActionListener->executeDrop( _rEvt );
115 return DND_ACTION_NONE;
118 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */