1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "AppIconControl.hxx"
21 #include <tools/debug.hxx>
22 #include "dbaccess_helpid.hrc"
23 #include "moduledbu.hxx"
24 #include "dbu_app.hrc"
25 #include <vcl/image.hxx>
26 #include "callbacks.hxx"
27 #include "AppElementType.hxx"
28 #include <boost/scoped_ptr.hpp>
30 using namespace ::dbaui
;
31 // class OApplicationIconControl
32 OApplicationIconControl::OApplicationIconControl(vcl::Window
* _pParent
)
33 : SvtIconChoiceCtrl(_pParent
,WB_ICON
| WB_NOCOLUMNHEADER
| WB_HIGHLIGHTFRAME
| /*!WB_NOSELECTION |*/
34 WB_TABSTOP
| WB_CLIPCHILDREN
| WB_NOVSCROLL
| WB_SMART_ARRANGE
| WB_NOHSCROLL
| WB_CENTER
)
35 ,DropTargetHelper(this)
36 ,m_pActionListener(NULL
)
39 struct CategoryDescriptor
41 sal_uInt16 nLabelResId
;
43 sal_uInt16 nImageResId
;
45 { RID_STR_TABLES_CONTAINER
, E_TABLE
, IMG_TABLEFOLDER_TREE_L
},
46 { RID_STR_QUERIES_CONTAINER
, E_QUERY
, IMG_QUERYFOLDER_TREE_L
},
47 { RID_STR_FORMS_CONTAINER
, E_FORM
, IMG_FORMFOLDER_TREE_L
},
48 { RID_STR_REPORTS_CONTAINER
, E_REPORT
, IMG_REPORTFOLDER_TREE_L
}
50 for ( size_t i
=0; i
< sizeof(aCategories
)/sizeof(aCategories
[0]); ++i
)
52 SvxIconChoiceCtrlEntry
* pEntry
= InsertEntry(
53 OUString( ModuleRes( aCategories
[i
].nLabelResId
) ) ,
54 Image( ModuleRes( aCategories
[i
].nImageResId
) ) );
56 pEntry
->SetUserData( new ElementType( aCategories
[i
].eType
) );
59 SetChoiceWithCursor( true );
60 SetSelectionMode(SINGLE_SELECTION
);
63 OApplicationIconControl::~OApplicationIconControl()
68 void OApplicationIconControl::dispose()
70 sal_uLong nCount
= GetEntryCount();
71 for ( sal_uLong i
= 0; i
< nCount
; ++i
)
73 SvxIconChoiceCtrlEntry
* pEntry
= GetEntry( i
);
76 boost::scoped_ptr
<ElementType
> aType(static_cast<ElementType
*>(pEntry
->GetUserData()));
77 pEntry
->SetUserData(NULL
);
80 SvtIconChoiceCtrl::dispose();
83 sal_Int8
OApplicationIconControl::AcceptDrop( const AcceptDropEvent
& _rEvt
)
85 sal_Int8 nDropOption
= DND_ACTION_NONE
;
86 if ( m_pActionListener
)
89 SvxIconChoiceCtrlEntry
* pEntry
= GetEntry(_rEvt
.maPosPixel
);
93 nDropOption
= m_pActionListener
->queryDrop( _rEvt
, GetDataFlavorExVector() );
94 m_aMousePos
= _rEvt
.maPosPixel
;
101 sal_Int8
OApplicationIconControl::ExecuteDrop( const ExecuteDropEvent
& _rEvt
)
103 if ( m_pActionListener
)
104 return m_pActionListener
->executeDrop( _rEvt
);
106 return DND_ACTION_NONE
;
109 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */