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 #ifndef INCLUDED_VCL_TREELISTENTRY_HXX
21 #define INCLUDED_VCL_TREELISTENTRY_HXX
22 
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>
29 
30 #include <optional>
31 #include <vector>
32 #include <memory>
33 
34 // flags related to the model
35 enum class SvTLEntryFlags
36 {
37  NONE = 0x0000,
38  CHILDREN_ON_DEMAND = 0x0001,
39  DISABLE_DROP = 0x0002,
40  // is set if RequestingChildren has not set any children
41  NO_NODEBMP = 0x0004,
42  // is set if this is a separator line
43  IS_SEPARATOR = 0x0008,
44  // entry had or has children
45  HAD_CHILDREN = 0x0010,
46  SEMITRANSPARENT = 0x8000, // draw semi-transparent entry bitmaps
47 };
48 namespace o3tl
49 {
50  template<> struct typed_flags<SvTLEntryFlags> : is_typed_flags<SvTLEntryFlags, 0x801f> {};
51 }
52 
54 {
55  friend class SvTreeList;
56  friend class SvListView;
57  friend class SvTreeListBox;
58 
59  typedef std::vector<std::unique_ptr<SvLBoxItem>> ItemsType;
60 
65  sal_uInt32 mnExtraIndent;
66  ItemsType m_Items;
67  void* pUserData;
70  std::optional<Color> mxTextColor;
71 
72 private:
73  void ClearChildren();
74  void SetListPositions();
75  void InvalidateChildrensListPositions();
76 
77  SvTreeListEntry(const SvTreeListEntry& r) = delete;
78  void operator=(SvTreeListEntry const&) = delete;
79 
80 public:
81  static const size_t ITEM_NOT_FOUND = SAL_MAX_SIZE;
82 
84  virtual ~SvTreeListEntry();
85 
86  bool HasChildren() const;
87  bool HasChildListPos() const;
88  sal_uLong GetChildListPos() const;
89 
90  SvTreeListEntries& GetChildEntries() { return m_Children; }
91  const SvTreeListEntries& GetChildEntries() const { return m_Children; }
92 
93  void Clone(SvTreeListEntry* pSource);
94 
95  size_t ItemCount() const;
96 
97  // MAY ONLY BE CALLED IF THE ENTRY HAS NOT YET BEEN INSERTED INTO
98  // THE MODEL, AS OTHERWISE NO VIEW-DEPENDENT DATA ARE ALLOCATED
99  // FOR THE ITEM!
100  void AddItem(std::unique_ptr<SvLBoxItem> pItem);
101  void ReplaceItem(std::unique_ptr<SvLBoxItem> pNewItem, size_t nPos);
102  const SvLBoxItem& GetItem( size_t nPos ) const;
103  SvLBoxItem& GetItem( size_t nPos );
104  const SvLBoxItem* GetFirstItem(SvLBoxItemType eType) const;
105  SvLBoxItem* GetFirstItem(SvLBoxItemType eType);
106  size_t GetPos( const SvLBoxItem* pItem ) const;
107  void* GetUserData() const { return pUserData;}
108  void SetUserData( void* pPtr );
109  void EnableChildrenOnDemand( bool bEnable=true );
110  bool HasChildrenOnDemand() const;
111 
112  SvTLEntryFlags GetFlags() const { return nEntryFlags;}
113  void SetFlags( SvTLEntryFlags nFlags );
114 
115  void SetBackColor( const Color& rColor ) { maBackColor = rColor; }
116  const Color& GetBackColor() const { return maBackColor; }
117 
118  void SetTextColor( std::optional<Color> xColor ) { mxTextColor = xColor; }
119  std::optional<Color> const & GetTextColor() const { return mxTextColor; }
120 
121  void SetExtraIndent(sal_uInt32 nExtraIndent) { mnExtraIndent = nExtraIndent; }
122  sal_uInt32 GetExtraIndent() const { return mnExtraIndent; }
123 
124  SvTreeListEntry* NextSibling() const;
125  SvTreeListEntry* PrevSibling() const;
126  SvTreeListEntry* LastSibling() const;
127 };
128 
129 #endif
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
sal_uIntPtr sal_uLong
SvLBoxItem * GetItem(SvTreeListEntry *, long nX, SvLBoxTab **ppTab)
SvTLEntryFlags
sal_uInt32 GetExtraIndent() const
SvLBoxItemType
Definition: treelistbox.hxx:98
SvTreeListEntries m_Children
void SetBackColor(const Color &rColor)
std::optional< Color > const & GetTextColor() const
Reference< XAnimationNode > Clone(const Reference< XAnimationNode > &xSourceNode, const SdPage *pSource, const SdPage *pTarget)
Control & operator=(const Control &)=delete
void * GetUserData() const
SvTLEntryFlags nEntryFlags
SvTreeListEntries & GetChildEntries()
sal_uInt32 mnExtraIndent
const SvTreeListEntries & GetChildEntries() const
sal_uLong nListPos
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