Branch libreoffice-5-0-4
[LibreOffice.git] / include / svtools / treelistentry.hxx
blob11478173bbce5b698e88dbc1d250d8ef08a0f128
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 #ifndef INCLUDED_SVTOOLS_TREELISTENTRY_HXX
21 #define INCLUDED_SVTOOLS_TREELISTENTRY_HXX
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>
29 #include <boost/ptr_container/ptr_vector.hpp>
31 // flags related to the model
32 enum class SvTLEntryFlags
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
44 namespace o3tl
46 template<> struct typed_flags<SvTLEntryFlags> : is_typed_flags<SvTLEntryFlags, 0x801f> {};
50 class SVT_DLLPUBLIC SvTreeListEntry
52 friend class SvTreeList;
53 friend class SvListView;
54 friend class SvTreeListBox;
56 typedef boost::ptr_vector<SvLBoxItem> ItemsType;
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;
68 private:
69 void ClearChildren();
70 void SetListPositions();
71 void InvalidateChildrensListPositions();
73 public:
74 static const size_t ITEM_NOT_FOUND = SAL_MAX_SIZE;
76 SvTreeListEntry();
77 SvTreeListEntry(const SvTreeListEntry& r);
78 virtual ~SvTreeListEntry();
80 bool HasChildren() const;
81 bool HasChildListPos() const;
82 sal_uLong GetChildListPos() const;
84 SvTreeListEntries& GetChildEntries() { return maChildren;}
85 const SvTreeListEntries& GetChildEntries() const { return maChildren;}
87 void Clone(SvTreeListEntry* pSource);
89 size_t ItemCount() const;
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 void* GetUserData() const { return pUserData;}
102 void SetUserData( void* pPtr );
103 void EnableChildrenOnDemand( bool bEnable=true );
104 bool HasChildrenOnDemand() const;
105 bool HasInUseEmphasis() const;
107 SvTLEntryFlags GetFlags() const { return nEntryFlags;}
108 void SetFlags( SvTLEntryFlags nFlags );
110 bool GetIsMarked() const { return bIsMarked; }
111 void SetMarked( bool IsMarked ) { bIsMarked = IsMarked; }
113 void SetBackColor( const Color& aColor ) { maBackColor = aColor; }
114 Color GetBackColor() const { return maBackColor; }
117 #endif
119 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */