Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
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>
29 :
30 : using namespace ::dbaui;
31 : // class OApplicationIconControl
32 16 : 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 16 : ,m_pActionListener(NULL)
37 : {
38 :
39 : struct CategoryDescriptor
40 : {
41 : sal_uInt16 nLabelResId;
42 : ElementType eType;
43 : sal_uInt16 nImageResId;
44 : } aCategories[] = {
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 }
49 16 : };
50 80 : for ( size_t i=0; i < sizeof(aCategories)/sizeof(aCategories[0]); ++i)
51 : {
52 : SvxIconChoiceCtrlEntry* pEntry = InsertEntry(
53 : OUString( ModuleRes( aCategories[i].nLabelResId ) ) ,
54 64 : Image( ModuleRes( aCategories[i].nImageResId ) ) );
55 64 : if ( pEntry )
56 64 : pEntry->SetUserData( new ElementType( aCategories[i].eType ) );
57 : }
58 :
59 16 : SetChoiceWithCursor( true );
60 16 : SetSelectionMode(SINGLE_SELECTION);
61 16 : }
62 :
63 24 : OApplicationIconControl::~OApplicationIconControl()
64 : {
65 12 : sal_uLong nCount = GetEntryCount();
66 60 : for ( sal_uLong i = 0; i < nCount; ++i )
67 : {
68 48 : SvxIconChoiceCtrlEntry* pEntry = GetEntry( i );
69 48 : if ( pEntry )
70 : {
71 48 : boost::scoped_ptr<ElementType> aType(static_cast<ElementType*>(pEntry->GetUserData()));
72 48 : pEntry->SetUserData(NULL);
73 : }
74 : }
75 :
76 12 : }
77 :
78 0 : sal_Int8 OApplicationIconControl::AcceptDrop( const AcceptDropEvent& _rEvt )
79 : {
80 0 : sal_Int8 nDropOption = DND_ACTION_NONE;
81 0 : if ( m_pActionListener )
82 : {
83 :
84 0 : SvxIconChoiceCtrlEntry* pEntry = GetEntry(_rEvt.maPosPixel);
85 0 : if ( pEntry )
86 : {
87 0 : SetCursor(pEntry);
88 0 : nDropOption = m_pActionListener->queryDrop( _rEvt, GetDataFlavorExVector() );
89 0 : m_aMousePos = _rEvt.maPosPixel;
90 : }
91 : }
92 :
93 0 : return nDropOption;
94 : }
95 :
96 0 : sal_Int8 OApplicationIconControl::ExecuteDrop( const ExecuteDropEvent& _rEvt )
97 : {
98 0 : if ( m_pActionListener )
99 0 : return m_pActionListener->executeDrop( _rEvt );
100 :
101 0 : return DND_ACTION_NONE;
102 72 : }
103 :
104 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|