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 : #ifndef INCLUDED_SVTOOLS_TREELISTENTRY_HXX
21 : #define INCLUDED_SVTOOLS_TREELISTENTRY_HXX
22 :
23 : #include <svtools/svtdllapi.h>
24 : #include <tools/solar.h>
25 : #include <svtools/treelistbox.hxx>
26 : #include <svtools/treelistentries.hxx>
27 : #include <o3tl/typed_flags_set.hxx>
28 :
29 : #include <boost/ptr_container/ptr_vector.hpp>
30 :
31 : // flags related to the model
32 : enum class SvTLEntryFlags
33 : {
34 : NONE = 0x0000,
35 : CHILDREN_ON_DEMAND = 0x0001,
36 : DISABLE_DROP = 0x0002,
37 : IN_USE = 0x0004,
38 : // is set if RequestingChildren has not set any children
39 : NO_NODEBMP = 0x0008,
40 : // entry had or has children
41 : HAD_CHILDREN = 0x0010,
42 : SEMITRANSPARENT = 0x8000, // draw semi-transparent entry bitmaps
43 : };
44 : namespace o3tl
45 : {
46 : template<> struct typed_flags<SvTLEntryFlags> : is_typed_flags<SvTLEntryFlags, 0x801f> {};
47 : }
48 :
49 :
50 : class SVT_DLLPUBLIC SvTreeListEntry
51 : {
52 : friend class SvTreeList;
53 : friend class SvListView;
54 : friend class SvTreeListBox;
55 :
56 : typedef boost::ptr_vector<SvLBoxItem> ItemsType;
57 :
58 : SvTreeListEntry* pParent;
59 : SvTreeListEntries maChildren;
60 : sal_uLong nAbsPos;
61 : sal_uLong nListPos;
62 : ItemsType maItems;
63 : bool bIsMarked;
64 : void* pUserData;
65 : SvTLEntryFlags nEntryFlags;
66 : Color maBackColor;
67 :
68 : private:
69 : void ClearChildren();
70 : void SetListPositions();
71 : void InvalidateChildrensListPositions();
72 :
73 : public:
74 : static const size_t ITEM_NOT_FOUND = SAL_MAX_SIZE;
75 :
76 : SvTreeListEntry();
77 : SvTreeListEntry(const SvTreeListEntry& r);
78 : virtual ~SvTreeListEntry();
79 :
80 : bool HasChildren() const;
81 : bool HasChildListPos() const;
82 : sal_uLong GetChildListPos() const;
83 :
84 0 : SvTreeListEntries& GetChildEntries() { return maChildren;}
85 0 : const SvTreeListEntries& GetChildEntries() const { return maChildren;}
86 :
87 : void Clone(SvTreeListEntry* pSource);
88 :
89 : size_t ItemCount() const;
90 :
91 : // MAY ONLY BE CALLED IF THE ENTRY HAS NOT YET BEEN INSERTED INTO
92 : // THE MODEL, AS OTHERWISE NO VIEW-DEPENDENT DATEA ARE ALLOCATED
93 : // FOR THE ITEM!
94 : void AddItem( SvLBoxItem* pItem );
95 : void ReplaceItem( SvLBoxItem* pNewItem, size_t nPos );
96 : const SvLBoxItem* GetItem( size_t nPos ) const;
97 : SvLBoxItem* GetItem( size_t nPos );
98 : const SvLBoxItem* GetFirstItem( sal_uInt16 nId ) const;
99 : SvLBoxItem* GetFirstItem( sal_uInt16 nId );
100 : size_t GetPos( const SvLBoxItem* pItem ) const;
101 1059 : void* GetUserData() const { return pUserData;}
102 : void SetUserData( void* pPtr );
103 : void EnableChildrenOnDemand( bool bEnable=true );
104 : bool HasChildrenOnDemand() const;
105 : bool HasInUseEmphasis() const;
106 :
107 231 : SvTLEntryFlags GetFlags() const { return nEntryFlags;}
108 : void SetFlags( SvTLEntryFlags nFlags );
109 :
110 : bool GetIsMarked() const { return bIsMarked; }
111 1 : void SetMarked( bool IsMarked ) { bIsMarked = IsMarked; }
112 :
113 101 : void SetBackColor( const Color& aColor ) { maBackColor = aColor; }
114 211 : Color GetBackColor() const { return maBackColor; }
115 : };
116 :
117 : #endif
118 :
119 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|