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>
30 #include <o3tl/typed_flags_set.hxx>
31 
32 #include <optional>
33 #include <vector>
34 #include <memory>
35 
36 // flags related to the model
37 enum class SvTLEntryFlags
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 };
50 namespace 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;
68  ItemsType m_Items;
69  void* pUserData;
72  std::optional<Color> mxTextColor;
73 
74 private:
75  void ClearChildren();
76  void SetListPositions();
77  void InvalidateChildrensListPositions();
78 
79  SvTreeListEntry(const SvTreeListEntry& r) = delete;
80  void operator=(SvTreeListEntry const&) = delete;
81 
82 public:
83  static const size_t ITEM_NOT_FOUND = SAL_MAX_SIZE;
84 
86  virtual ~SvTreeListEntry();
87 
88  bool HasChildren() const;
89  bool HasChildListPos() const;
90  sal_uInt32 GetChildListPos() const;
91 
92  SvTreeListEntries& GetChildEntries() { return m_Children; }
93  const SvTreeListEntries& GetChildEntries() const { return m_Children; }
94 
95  void Clone(SvTreeListEntry* pSource);
96 
97  size_t ItemCount() const;
98 
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;
113 
114  SvTLEntryFlags GetFlags() const { return nEntryFlags;}
115  void SetFlags( SvTLEntryFlags nFlags );
116 
117  void SetBackColor( const Color& rColor ) { maBackColor = rColor; }
118  const Color& GetBackColor() const { return maBackColor; }
119 
120  void SetTextColor( std::optional<Color> xColor ) { mxTextColor = xColor; }
121  std::optional<Color> const & GetTextColor() const { return mxTextColor; }
122 
123  void SetExtraIndent(sal_uInt32 nExtraIndent) { mnExtraIndent = nExtraIndent; }
124  sal_uInt32 GetExtraIndent() const { return mnExtraIndent; }
125 
126  SvTreeListEntry* NextSibling() const;
127  SvTreeListEntry* PrevSibling() const;
128  SvTreeListEntry* LastSibling() const;
129 };
130 
131 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const Color & GetBackColor() const
std::vector< std::unique_ptr< SvLBoxItem > > ItemsType
SvTLEntryFlags GetFlags() const
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
SvTLEntryFlags
sal_uInt32 GetExtraIndent() const
SvLBoxItemType
SvTreeListEntries m_Children
void SetBackColor(const Color &rColor)
std::optional< Color > const & GetTextColor() const
sal_uInt32 nListPos
Reference< XAnimationNode > Clone(const Reference< XAnimationNode > &xSourceNode, const SdPage *pSource, const SdPage *pTarget)
Control & operator=(const Control &)=delete
void * GetUserData() const
SvLBoxItem * GetItem(SvTreeListEntry *, tools::Long nX, SvLBoxTab **ppTab)
SvTLEntryFlags nEntryFlags
SvTreeListEntries & GetChildEntries()
sal_uInt32 mnExtraIndent
const SvTreeListEntries & GetChildEntries() const
void SetFlags(EVControlBits &rBits, EVControlBits nMask, bool bOn)
void SetExtraIndent(sal_uInt32 nExtraIndent)
std::optional< Color > mxTextColor
void SetTextColor(std::optional< Color > xColor)
SvTreeListEntry * pParent
std::vector< std::unique_ptr< SvTreeListEntry > > SvTreeListEntries
sal_uInt32 nAbsPos