LibreOffice Module vcl (master) 1
treelistentry.hxx
Go to the documentation of this file.
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#pragma once
21
22#if !defined(VCL_DLLIMPLEMENTATION) && !defined(TOOLKIT_DLLIMPLEMENTATION) && !defined(VCL_INTERNALS)
23#error "don't use this in new code"
24#endif
25
26#include <vcl/dllapi.h>
27#include <tools/color.hxx>
31
32#include <optional>
33#include <vector>
34#include <memory>
35
36// flags related to the model
38{
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
49};
50namespace o3tl
51{
52 template<> struct typed_flags<SvTLEntryFlags> : is_typed_flags<SvTLEntryFlags, 0x801f> {};
53}
54
56{
57 friend class SvTreeList;
58 friend class SvListView;
59 friend class SvTreeListBox;
60
61 typedef std::vector<std::unique_ptr<SvLBoxItem>> ItemsType;
62
65 sal_uInt32 nAbsPos;
66 sal_uInt32 nListPos;
67 sal_uInt32 mnExtraIndent;
69 void* pUserData;
71 std::optional<Color> mxTextColor;
72
73private:
74 void ClearChildren();
75 void SetListPositions();
76 void InvalidateChildrensListPositions();
77
78 SvTreeListEntry(const SvTreeListEntry& r) = delete;
79 void operator=(SvTreeListEntry const&) = delete;
80
81public:
82 static const size_t ITEM_NOT_FOUND = SAL_MAX_SIZE;
83
85 virtual ~SvTreeListEntry();
86
87 bool HasChildren() const;
88 bool HasChildListPos() const;
89 sal_uInt32 GetChildListPos() const;
90
91 SvTreeListEntries& GetChildEntries() { return m_Children; }
92 const SvTreeListEntries& GetChildEntries() const { return m_Children; }
93
94 void Clone(SvTreeListEntry* pSource);
95
96 size_t ItemCount() const;
97
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;
112
113 SvTLEntryFlags GetFlags() const { return nEntryFlags;}
114 void SetFlags( SvTLEntryFlags nFlags );
115
116 void SetTextColor( std::optional<Color> xColor ) { mxTextColor = xColor; }
117 std::optional<Color> const & GetTextColor() const { return mxTextColor; }
118
119 void SetExtraIndent(sal_uInt32 nExtraIndent) { mnExtraIndent = nExtraIndent; }
120 sal_uInt32 GetExtraIndent() const { return mnExtraIndent; }
121
122 SvTreeListEntry* NextSibling() const;
123 SvTreeListEntry* PrevSibling() const;
124 SvTreeListEntry* LastSibling() const;
125};
126
127/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SvLBoxItem * GetItem(SvTreeListEntry *, tools::Long nX, SvLBoxTab **ppTab)
std::optional< Color > const & GetTextColor() const
void operator=(SvTreeListEntry const &)=delete
const SvTreeListEntries & GetChildEntries() const
SvTreeListEntries m_Children
void * GetUserData() const
void SetExtraIndent(sal_uInt32 nExtraIndent)
SvTLEntryFlags GetFlags() const
SvTreeListEntries & GetChildEntries()
sal_uInt32 GetExtraIndent() const
sal_uInt32 mnExtraIndent
SvTreeListEntry(const SvTreeListEntry &r)=delete
sal_uInt32 nAbsPos
SvTreeListEntry * pParent
sal_uInt32 nListPos
SvTLEntryFlags nEntryFlags
void SetTextColor(std::optional< Color > xColor)
std::optional< Color > mxTextColor
std::vector< std::unique_ptr< SvLBoxItem > > ItemsType
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
void SetFlags(EVControlBits &rBits, EVControlBits nMask, bool bOn)
NONE
css::uno::Reference< css::animations::XAnimationNode > Clone(const css::uno::Reference< css::animations::XAnimationNode > &xSourceNode, const SdPage *pSource=nullptr, const SdPage *pTarget=nullptr)
SvLBoxItemType
Definition: treelistbox.hxx:96
std::vector< std::unique_ptr< SvTreeListEntry > > SvTreeListEntries
SvTLEntryFlags