Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / include / vcl / toolkit / treelistentry.hxx
blobb8bffecefd30ce978307b8c0a80b6a42dcff5af6
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 #pragma once
22 #if !defined(VCL_DLLIMPLEMENTATION) && !defined(TOOLKIT_DLLIMPLEMENTATION) && !defined(VCL_INTERNALS)
23 #error "don't use this in new code"
24 #endif
26 #include <vcl/dllapi.h>
27 #include <tools/color.hxx>
28 #include <vcl/toolkit/treelistbox.hxx>
29 #include <vcl/toolkit/treelistentries.hxx>
30 #include <o3tl/typed_flags_set.hxx>
32 #include <optional>
33 #include <vector>
34 #include <memory>
36 // flags related to the model
37 enum class SvTLEntryFlags
39 NONE = 0x0000,
40 CHILDREN_ON_DEMAND = 0x0001,
41 DISABLE_DROP = 0x0002,
42 // is set if RequestingChildren has not set any children
43 NO_NODEBMP = 0x0004,
44 // is set if this is a separator line
45 IS_SEPARATOR = 0x0008,
46 // entry had or has children
47 HAD_CHILDREN = 0x0010,
48 SEMITRANSPARENT = 0x8000, // draw semi-transparent entry bitmaps
50 namespace o3tl
52 template<> struct typed_flags<SvTLEntryFlags> : is_typed_flags<SvTLEntryFlags, 0x801f> {};
55 class VCL_DLLPUBLIC SvTreeListEntry
57 friend class SvTreeList;
58 friend class SvListView;
59 friend class SvTreeListBox;
61 typedef std::vector<std::unique_ptr<SvLBoxItem>> ItemsType;
63 SvTreeListEntry* pParent;
64 SvTreeListEntries m_Children;
65 sal_uInt32 nAbsPos;
66 sal_uInt32 nListPos;
67 sal_uInt32 mnExtraIndent;
68 ItemsType m_Items;
69 void* pUserData;
70 SvTLEntryFlags nEntryFlags;
71 std::optional<Color> mxTextColor;
73 private:
74 void ClearChildren();
75 void SetListPositions();
76 void InvalidateChildrensListPositions();
78 SvTreeListEntry(const SvTreeListEntry& r) = delete;
79 void operator=(SvTreeListEntry const&) = delete;
81 public:
82 static const size_t ITEM_NOT_FOUND = SAL_MAX_SIZE;
84 SvTreeListEntry();
85 virtual ~SvTreeListEntry();
87 bool HasChildren() const;
88 bool HasChildListPos() const;
89 sal_uInt32 GetChildListPos() const;
91 SvTreeListEntries& GetChildEntries() { return m_Children; }
92 const SvTreeListEntries& GetChildEntries() const { return m_Children; }
94 void Clone(SvTreeListEntry* pSource);
96 size_t ItemCount() const;
98 // MAY ONLY BE CALLED IF THE ENTRY HAS NOT YET BEEN INSERTED INTO
99 // THE MODEL, AS OTHERWISE NO VIEW-DEPENDENT DATA ARE ALLOCATED
100 // FOR THE ITEM!
101 void AddItem(std::unique_ptr<SvLBoxItem> pItem);
102 void ReplaceItem(std::unique_ptr<SvLBoxItem> pNewItem, size_t nPos);
103 const SvLBoxItem& GetItem( size_t nPos ) const;
104 SvLBoxItem& GetItem( size_t nPos );
105 const SvLBoxItem* GetFirstItem(SvLBoxItemType eType) const;
106 SvLBoxItem* GetFirstItem(SvLBoxItemType eType);
107 size_t GetPos( const SvLBoxItem* pItem ) const;
108 void* GetUserData() const { return pUserData;}
109 void SetUserData( void* pPtr );
110 void EnableChildrenOnDemand( bool bEnable=true );
111 bool HasChildrenOnDemand() const;
113 SvTLEntryFlags GetFlags() const { return nEntryFlags;}
114 void SetFlags( SvTLEntryFlags nFlags );
116 void SetTextColor( std::optional<Color> xColor ) { mxTextColor = xColor; }
117 std::optional<Color> const & GetTextColor() const { return mxTextColor; }
119 void SetExtraIndent(sal_uInt32 nExtraIndent) { mnExtraIndent = nExtraIndent; }
120 sal_uInt32 GetExtraIndent() const { return mnExtraIndent; }
122 SvTreeListEntry* NextSibling() const;
123 SvTreeListEntry* PrevSibling() const;
124 SvTreeListEntry* LastSibling() const;
127 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */