Branch data 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 <memory>
29 : :
30 : : using namespace ::dbaui;
31 : : //==================================================================
32 : : // class OApplicationIconControl
33 : : DBG_NAME(OApplicationIconControl)
34 : : //==================================================================
35 : 0 : OApplicationIconControl::OApplicationIconControl(Window* _pParent)
36 : : : SvtIconChoiceCtrl(_pParent,WB_ICON | WB_NOCOLUMNHEADER | WB_HIGHLIGHTFRAME | /*!WB_NOSELECTION |*/
37 : : WB_TABSTOP | WB_CLIPCHILDREN | WB_NOVSCROLL | WB_SMART_ARRANGE | WB_NOHSCROLL | WB_CENTER)
38 : : ,DropTargetHelper(this)
39 [ # # ]: 0 : ,m_pActionListener(NULL)
40 : : {
41 : : DBG_CTOR(OApplicationIconControl,NULL);
42 : :
43 : : struct CategoryDescriptor
44 : : {
45 : : sal_uInt16 nLabelResId;
46 : : ElementType eType;
47 : : sal_uInt16 nImageResId;
48 : : } aCategories[] = {
49 : : { RID_STR_TABLES_CONTAINER, E_TABLE, IMG_TABLEFOLDER_TREE_L },
50 : : { RID_STR_QUERIES_CONTAINER, E_QUERY, IMG_QUERYFOLDER_TREE_L },
51 : : { RID_STR_FORMS_CONTAINER, E_FORM, IMG_FORMFOLDER_TREE_L },
52 : : { RID_STR_REPORTS_CONTAINER, E_REPORT, IMG_REPORTFOLDER_TREE_L }
53 : 0 : };
54 [ # # ]: 0 : for ( size_t i=0; i < sizeof(aCategories)/sizeof(aCategories[0]); ++i)
55 : : {
56 : : SvxIconChoiceCtrlEntry* pEntry = InsertEntry(
57 : : String( ModuleRes( aCategories[i].nLabelResId ) ) ,
58 [ # # ][ # # ]: 0 : Image( ModuleRes( aCategories[i].nImageResId ) ) );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
59 [ # # ]: 0 : if ( pEntry )
60 [ # # ]: 0 : pEntry->SetUserData( new ElementType( aCategories[i].eType ) );
61 : : }
62 : :
63 [ # # ]: 0 : SetChoiceWithCursor( sal_True );
64 [ # # ]: 0 : SetSelectionMode(SINGLE_SELECTION);
65 : 0 : }
66 : : // -----------------------------------------------------------------------------
67 [ # # ]: 0 : OApplicationIconControl::~OApplicationIconControl()
68 : : {
69 [ # # ]: 0 : sal_uLong nCount = GetEntryCount();
70 [ # # ]: 0 : for ( sal_uLong i = 0; i < nCount; ++i )
71 : : {
72 [ # # ]: 0 : SvxIconChoiceCtrlEntry* pEntry = GetEntry( i );
73 [ # # ]: 0 : if ( pEntry )
74 : : {
75 : 0 : ::std::auto_ptr<ElementType> aType(static_cast<ElementType*>(pEntry->GetUserData()));
76 [ # # ]: 0 : pEntry->SetUserData(NULL);
77 : : }
78 : : }
79 : :
80 : : DBG_DTOR(OApplicationIconControl,NULL);
81 [ # # ]: 0 : }
82 : : // -----------------------------------------------------------------------------
83 : 0 : sal_Int8 OApplicationIconControl::AcceptDrop( const AcceptDropEvent& _rEvt )
84 : : {
85 : 0 : sal_Int8 nDropOption = DND_ACTION_NONE;
86 [ # # ]: 0 : if ( m_pActionListener )
87 : : {
88 : :
89 : 0 : SvxIconChoiceCtrlEntry* pEntry = GetEntry(_rEvt.maPosPixel);
90 [ # # ]: 0 : if ( pEntry )
91 : : {
92 : 0 : SetCursor(pEntry);
93 : 0 : nDropOption = m_pActionListener->queryDrop( _rEvt, GetDataFlavorExVector() );
94 : 0 : m_aMousePos = _rEvt.maPosPixel;
95 : : }
96 : : }
97 : :
98 : 0 : return nDropOption;
99 : : }
100 : : // -----------------------------------------------------------------------------
101 : 0 : sal_Int8 OApplicationIconControl::ExecuteDrop( const ExecuteDropEvent& _rEvt )
102 : : {
103 [ # # ]: 0 : if ( m_pActionListener )
104 : 0 : return m_pActionListener->executeDrop( _rEvt );
105 : :
106 : 0 : return DND_ACTION_NONE;
107 : : }
108 : :
109 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|