Update git submodules
[LibreOffice.git] / include / vcl / toolkit / treelistentry.hxx
blob58228711c377c92c0e4aa579d211f98d442cb1c2
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 <config_options.h>
27 #include <vcl/dllapi.h>
28 #include <tools/color.hxx>
29 #include <vcl/toolkit/treelistbox.hxx>
30 #include <vcl/toolkit/treelistentries.hxx>
31 #include <o3tl/typed_flags_set.hxx>
33 #include <optional>
34 #include <vector>
35 #include <memory>
37 // flags related to the model
38 enum class SvTLEntryFlags
40 NONE = 0x0000,
41 CHILDREN_ON_DEMAND = 0x0001,
42 DISABLE_DROP = 0x0002,
43 // is set if RequestingChildren has not set any children
44 NO_NODEBMP = 0x0004,
45 // is set if this is a separator line
46 IS_SEPARATOR = 0x0008,
47 // entry had or has children
48 HAD_CHILDREN = 0x0010,
49 SEMITRANSPARENT = 0x8000, // draw semi-transparent entry bitmaps
51 namespace o3tl
53 template<> struct typed_flags<SvTLEntryFlags> : is_typed_flags<SvTLEntryFlags, 0x801f> {};
56 class UNLESS_MERGELIBS_MORE(VCL_DLLPUBLIC) SvTreeListEntry
58 friend class SvTreeList;
59 friend class SvListView;
60 friend class SvTreeListBox;
62 typedef std::vector<std::unique_ptr<SvLBoxItem>> ItemsType;
64 SvTreeListEntry* pParent;
65 SvTreeListEntries m_Children;
66 sal_uInt32 nAbsPos;
67 sal_uInt32 nListPos;
68 sal_uInt32 mnExtraIndent;
69 ItemsType m_Items;
70 void* pUserData;
71 SvTLEntryFlags nEntryFlags;
72 std::optional<Color> mxTextColor;
74 private:
75 void ClearChildren();
76 void SetListPositions();
77 void InvalidateChildrensListPositions();
79 SvTreeListEntry(const SvTreeListEntry& r) = delete;
80 void operator=(SvTreeListEntry const&) = delete;
82 public:
83 static const size_t ITEM_NOT_FOUND = SAL_MAX_SIZE;
85 SvTreeListEntry();
86 virtual ~SvTreeListEntry();
88 bool HasChildren() const;
89 bool HasChildListPos() const;
90 sal_uInt32 GetChildListPos() const;
92 SvTreeListEntries& GetChildEntries() { return m_Children; }
93 const SvTreeListEntries& GetChildEntries() const { return m_Children; }
95 void Clone(SvTreeListEntry* pSource);
97 size_t ItemCount() const;
99 // MAY ONLY BE CALLED IF THE ENTRY HAS NOT YET BEEN INSERTED INTO
100 // THE MODEL, AS OTHERWISE NO VIEW-DEPENDENT DATA ARE ALLOCATED
101 // FOR THE ITEM!
102 void AddItem(std::unique_ptr<SvLBoxItem> pItem);
103 void ReplaceItem(std::unique_ptr<SvLBoxItem> pNewItem, size_t nPos);
104 const SvLBoxItem& GetItem( size_t nPos ) const;
105 SvLBoxItem& GetItem( size_t nPos );
106 const SvLBoxItem* GetFirstItem(SvLBoxItemType eType) const;
107 SvLBoxItem* GetFirstItem(SvLBoxItemType eType);
108 size_t GetPos( const SvLBoxItem* pItem ) const;
109 void* GetUserData() const { return pUserData;}
110 void SetUserData( void* pPtr );
111 void EnableChildrenOnDemand( bool bEnable=true );
112 bool HasChildrenOnDemand() const;
114 SvTLEntryFlags GetFlags() const { return nEntryFlags;}
115 void SetFlags( SvTLEntryFlags nFlags );
117 void SetTextColor( std::optional<Color> xColor ) { mxTextColor = xColor; }
118 std::optional<Color> const & GetTextColor() const { return mxTextColor; }
120 void SetExtraIndent(sal_uInt32 nExtraIndent) { mnExtraIndent = nExtraIndent; }
121 sal_uInt32 GetExtraIndent() const { return mnExtraIndent; }
123 SvTreeListEntry* NextSibling() const;
124 SvTreeListEntry* PrevSibling() const;
125 SvTreeListEntry* LastSibling() const;
128 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */