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  // entry had or has children
43  HAD_CHILDREN = 0x0010,
44  SEMITRANSPARENT = 0x8000, // draw semi-transparent entry bitmaps
45 };
46 namespace o3tl
47 {
48  template<> struct typed_flags<SvTLEntryFlags> : is_typed_flags<SvTLEntryFlags, 0x8017> {};
49 }
50 
52 {
53  friend class SvTreeList;
54  friend class SvListView;
55  friend class SvTreeListBox;
56 
57  typedef std::vector<std::unique_ptr<SvLBoxItem>> ItemsType;
58 
63  sal_uInt32 mnExtraIndent;
64  ItemsType m_Items;
65  void* pUserData;
68  std::optional<Color> mxTextColor;
69 
70 private:
71  void ClearChildren();
72  void SetListPositions();
73  void InvalidateChildrensListPositions();
74 
75  SvTreeListEntry(const SvTreeListEntry& r) = delete;
76  void operator=(SvTreeListEntry const&) = delete;
77 
78 public:
79  static const size_t ITEM_NOT_FOUND = SAL_MAX_SIZE;
80 
82  virtual ~SvTreeListEntry();
83 
84  bool HasChildren() const;
85  bool HasChildListPos() const;
86  sal_uLong GetChildListPos() const;
87 
88  SvTreeListEntries& GetChildEntries() { return m_Children; }
89  const SvTreeListEntries& GetChildEntries() const { return m_Children; }
90 
91  void Clone(SvTreeListEntry* pSource);
92 
93  size_t ItemCount() const;
94 
95  // MAY ONLY BE CALLED IF THE ENTRY HAS NOT YET BEEN INSERTED INTO
96  // THE MODEL, AS OTHERWISE NO VIEW-DEPENDENT DATA ARE ALLOCATED
97  // FOR THE ITEM!
98  void AddItem(std::unique_ptr<SvLBoxItem> pItem);
99  void ReplaceItem(std::unique_ptr<SvLBoxItem> pNewItem, size_t nPos);
100  const SvLBoxItem& GetItem( size_t nPos ) const;
101  SvLBoxItem& GetItem( size_t nPos );
102  const SvLBoxItem* GetFirstItem(SvLBoxItemType eType) const;
103  SvLBoxItem* GetFirstItem(SvLBoxItemType eType);
104  size_t GetPos( const SvLBoxItem* pItem ) const;
105  void* GetUserData() const { return pUserData;}
106  void SetUserData( void* pPtr );
107  void EnableChildrenOnDemand( bool bEnable=true );
108  bool HasChildrenOnDemand() const;
109 
110  SvTLEntryFlags GetFlags() const { return nEntryFlags;}
111  void SetFlags( SvTLEntryFlags nFlags );
112 
113  void SetBackColor( const Color& rColor ) { maBackColor = rColor; }
114  const Color& GetBackColor() const { return maBackColor; }
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* GetParent() const { return pParent; }
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
SvTreeListEntry * GetParent() const
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