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 #ifndef INCLUDED_VCL_TREELISTENTRY_HXX
21 #define INCLUDED_VCL_TREELISTENTRY_HXX
23 #include <vcl/dllapi.h>
24 #include <tools/solar.h>
25 #include <tools/color.hxx>
26 #include <vcl/treelistbox.hxx>
27 #include <vcl/treelistentries.hxx>
28 #include <o3tl/typed_flags_set.hxx>
30 #include <o3tl/optional.hxx>
34 // flags related to the model
35 enum class SvTLEntryFlags
38 CHILDREN_ON_DEMAND
= 0x0001,
39 DISABLE_DROP
= 0x0002,
40 // is set if RequestingChildren has not set any children
42 // entry had or has children
43 HAD_CHILDREN
= 0x0010,
44 SEMITRANSPARENT
= 0x8000, // draw semi-transparent entry bitmaps
48 template<> struct typed_flags
<SvTLEntryFlags
> : is_typed_flags
<SvTLEntryFlags
, 0x8017> {};
51 class VCL_DLLPUBLIC SvTreeListEntry
53 friend class SvTreeList
;
54 friend class SvListView
;
55 friend class SvTreeListBox
;
57 typedef std::vector
<std::unique_ptr
<SvLBoxItem
>> ItemsType
;
59 SvTreeListEntry
* pParent
;
60 SvTreeListEntries m_Children
;
65 SvTLEntryFlags nEntryFlags
;
67 o3tl::optional
<Color
> mxTextColor
;
71 void SetListPositions();
72 void InvalidateChildrensListPositions();
74 SvTreeListEntry(const SvTreeListEntry
& r
) = delete;
75 void operator=(SvTreeListEntry
const&) = delete;
78 static const size_t ITEM_NOT_FOUND
= SAL_MAX_SIZE
;
81 virtual ~SvTreeListEntry();
83 bool HasChildren() const;
84 bool HasChildListPos() const;
85 sal_uLong
GetChildListPos() const;
87 SvTreeListEntries
& GetChildEntries() { return m_Children
; }
88 const SvTreeListEntries
& GetChildEntries() const { return m_Children
; }
90 void Clone(SvTreeListEntry
* pSource
);
92 size_t ItemCount() const;
94 // MAY ONLY BE CALLED IF THE ENTRY HAS NOT YET BEEN INSERTED INTO
95 // THE MODEL, AS OTHERWISE NO VIEW-DEPENDENT DATA ARE ALLOCATED
97 void AddItem(std::unique_ptr
<SvLBoxItem
> pItem
);
98 void ReplaceItem(std::unique_ptr
<SvLBoxItem
> pNewItem
, size_t nPos
);
99 const SvLBoxItem
& GetItem( size_t nPos
) const;
100 SvLBoxItem
& GetItem( size_t nPos
);
101 const SvLBoxItem
* GetFirstItem(SvLBoxItemType eType
) const;
102 SvLBoxItem
* GetFirstItem(SvLBoxItemType eType
);
103 size_t GetPos( const SvLBoxItem
* pItem
) const;
104 void* GetUserData() const { return pUserData
;}
105 void SetUserData( void* pPtr
);
106 void EnableChildrenOnDemand( bool bEnable
=true );
107 bool HasChildrenOnDemand() const;
109 SvTLEntryFlags
GetFlags() const { return nEntryFlags
;}
110 void SetFlags( SvTLEntryFlags nFlags
);
112 void SetBackColor( const Color
& rColor
) { maBackColor
= rColor
; }
113 const Color
& GetBackColor() const { return maBackColor
; }
115 void SetTextColor( o3tl::optional
<Color
> xColor
) { mxTextColor
= xColor
; }
116 o3tl::optional
<Color
> const & GetTextColor() const { return mxTextColor
; }
118 SvTreeListEntry
* GetParent() const { return pParent
; }
120 SvTreeListEntry
* NextSibling() const;
121 SvTreeListEntry
* PrevSibling() const;
122 SvTreeListEntry
* LastSibling() const;
127 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */